2015-06-11 11:27:39 +01:00
|
|
|
#!/usr/bin/env bash
|
2011-09-20 17:18:04 +01:00
|
|
|
|
2015-09-17 15:55:31 +01:00
|
|
|
set -o pipefail
|
2011-09-20 17:18:04 +01:00
|
|
|
|
2017-03-11 14:50:06 +00:00
|
|
|
GNOME_FTP=ftp.gnome.org/pub/GNOME/sources
|
2011-09-20 17:18:04 +01:00
|
|
|
|
2015-09-23 10:46:02 +01:00
|
|
|
# projects that don't follow the GNOME major versioning, or that we don't want to
|
|
|
|
# programmatically update
|
2017-09-28 01:27:11 +01:00
|
|
|
NO_GNOME_MAJOR="ghex gtkhtml gdm gucharmap"
|
2015-09-23 10:46:02 +01:00
|
|
|
|
2015-09-17 15:55:31 +01:00
|
|
|
usage() {
|
2017-09-24 12:15:50 +01:00
|
|
|
echo "Usage: $0 <show project>|<update project>|<update-all> [major.minor]" >&2
|
2011-09-20 17:18:04 +01:00
|
|
|
exit 0
|
2015-09-17 15:55:31 +01:00
|
|
|
}
|
|
|
|
|
2017-09-24 12:15:50 +01:00
|
|
|
if [ "$#" -lt 1 ]; then
|
2015-09-17 15:55:31 +01:00
|
|
|
usage
|
2011-09-20 17:18:04 +01:00
|
|
|
fi
|
|
|
|
|
2017-09-24 12:15:50 +01:00
|
|
|
GNOME_TOP=pkgs/desktops/gnome-3
|
2011-09-20 17:18:04 +01:00
|
|
|
|
2017-03-11 14:50:06 +00:00
|
|
|
action=$1
|
2011-09-20 17:18:04 +01:00
|
|
|
|
|
|
|
# curl -l ftp://... doesn't work from my office in HSE, and I don't want to have
|
|
|
|
# any conversations with sysadmin. Somehow lftp works.
|
|
|
|
if [ "$FTP_CLIENT" = "lftp" ]; then
|
|
|
|
ls_ftp() {
|
|
|
|
lftp -c "open $1; cls"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ls_ftp() {
|
2015-09-17 14:48:06 +01:00
|
|
|
curl -s -l "$1"/
|
2011-09-20 17:18:04 +01:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2015-09-23 10:46:02 +01:00
|
|
|
find_project() {
|
2017-03-11 14:50:06 +00:00
|
|
|
exec find "$GNOME_TOP" -mindepth 2 -maxdepth 2 -type d "$@"
|
2015-09-23 10:46:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
show_project() {
|
2017-03-11 14:50:06 +00:00
|
|
|
local project=$1
|
|
|
|
local majorVersion=$2
|
|
|
|
local version=
|
2015-09-23 10:46:02 +01:00
|
|
|
|
|
|
|
if [ -z "$majorVersion" ]; then
|
|
|
|
echo "Looking for available versions..." >&2
|
2017-03-11 14:50:06 +00:00
|
|
|
local available_baseversions=$(ls_ftp ftp://${GNOME_FTP}/${project} | grep '[0-9]\.[0-9]' | sort -t. -k1,1n -k 2,2n)
|
|
|
|
if [ "$?" -ne 0 ]; then
|
2015-09-23 10:46:02 +01:00
|
|
|
echo "Project $project not found" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "The following versions are available:\n ${available_baseversions[@]}" >&2
|
|
|
|
echo -en "Choose one of them: " >&2
|
|
|
|
read majorVersion
|
2015-09-17 15:55:31 +01:00
|
|
|
fi
|
|
|
|
|
2015-09-23 10:46:02 +01:00
|
|
|
if echo "$majorVersion" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+"; then
|
|
|
|
# not a major version
|
2017-03-11 14:50:06 +00:00
|
|
|
version=$majorVersion
|
2015-09-23 10:46:02 +01:00
|
|
|
majorVersion=$(echo "$majorVersion" | cut -d '.' -f 1,2)
|
2011-09-20 17:18:04 +01:00
|
|
|
fi
|
2015-09-23 10:46:02 +01:00
|
|
|
|
2017-03-11 14:50:06 +00:00
|
|
|
local FTPDIR=${GNOME_FTP}/${project}/${majorVersion}
|
2015-09-23 10:46:02 +01:00
|
|
|
|
|
|
|
#version=`curl -l ${FTPDIR}/ 2>/dev/null | grep LATEST-IS | sed -e s/LATEST-IS-//`
|
|
|
|
# gnome's LATEST-IS is broken. Do not trust it.
|
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
|
|
|
local files=$(ls_ftp "${FTPDIR}")
|
|
|
|
declare -A versions
|
|
|
|
|
|
|
|
for f in $files; do
|
|
|
|
case $f in
|
|
|
|
(LATEST-IS-*|*.news|*.changes|*.sha256sum|*.diff*):
|
|
|
|
;;
|
|
|
|
($project-*.*.9*.tar.*):
|
|
|
|
tmp=${f#$project-}
|
|
|
|
tmp=${tmp%.tar*}
|
|
|
|
echo "Ignored unstable version ${tmp}" >&2
|
|
|
|
;;
|
|
|
|
($project-*.tar.*):
|
|
|
|
tmp=${f#$project-}
|
|
|
|
tmp=${tmp%.tar*}
|
|
|
|
versions[${tmp}]=1
|
|
|
|
;;
|
|
|
|
(*):
|
|
|
|
echo "UNKNOWN FILE $f" >&2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
echo "Found versions ${!versions[@]}" >&2
|
2017-03-11 14:50:06 +00:00
|
|
|
version=$(echo ${!versions[@]} | sed -e 's/ /\n/g' | sort -t. -k1,1n -k 2,2n -k 3,3n | tail -n1)
|
2015-09-23 10:46:02 +01:00
|
|
|
if [ -z "$version" ]; then
|
|
|
|
echo "No version available for major $majorVersion" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Latest version is: ${version}" >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
local name=${project}-${version}
|
|
|
|
echo "Fetching .sha256 file" >&2
|
2017-03-11 14:50:06 +00:00
|
|
|
local sha256out=$(curl -s -f http://"${FTPDIR}"/"${name}".sha256sum)
|
2015-09-23 10:46:02 +01:00
|
|
|
|
|
|
|
if [ "$?" -ne "0" ]; then
|
|
|
|
echo "Version not found" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
extensions=( "xz" "bz2" "gz" )
|
|
|
|
echo "Choosing archive extension (known are ${extensions[@]})..." >&2
|
|
|
|
for ext in ${extensions[@]}; do
|
|
|
|
if echo -e "$sha256out" | grep -q "\\.tar\\.${ext}$"; then
|
|
|
|
ext_pref=$ext
|
|
|
|
sha256=$(echo -e "$sha256out" | grep "\\.tar\\.${ext}$" | cut -f1 -d\ )
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "Chosen ${ext_pref}, hash is ${sha256}" >&2
|
|
|
|
|
|
|
|
echo "# Autogenerated by maintainers/scripts/gnome.sh update
|
2015-09-17 15:55:31 +01:00
|
|
|
|
|
|
|
fetchurl: {
|
|
|
|
name = \"${project}-${version}\";
|
2012-01-06 00:54:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2015-09-17 14:20:33 +01:00
|
|
|
url = mirror://gnome/sources/${project}/${majorVersion}/${project}-${version}.tar.${ext_pref};
|
2015-09-17 15:55:31 +01:00
|
|
|
sha256 = \"${sha256}\";
|
2011-09-20 17:18:04 +01:00
|
|
|
};
|
2015-09-17 15:55:31 +01:00
|
|
|
}"
|
|
|
|
|
2015-09-23 10:46:02 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
update_project() {
|
2017-03-11 14:50:06 +00:00
|
|
|
local project=$1
|
|
|
|
local majorVersion=$2
|
2015-09-23 10:46:02 +01:00
|
|
|
|
2015-09-17 15:55:31 +01:00
|
|
|
# find project in nixpkgs tree
|
2015-09-23 10:46:02 +01:00
|
|
|
projectPath=$(find_project -name "$project" -print)
|
2015-09-17 15:55:31 +01:00
|
|
|
if [ -z "$projectPath" ]; then
|
|
|
|
echo "Project $project not found under $GNOME_TOP"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-09-23 10:46:02 +01:00
|
|
|
src=$(show_project "$project" "$majorVersion")
|
|
|
|
|
|
|
|
if [ "$?" -eq "0" ]; then
|
|
|
|
echo "Updating $projectPath/src.nix" >&2
|
2017-03-11 14:50:06 +00:00
|
|
|
echo -e "$src" > "$projectPath"/src.nix
|
2015-09-23 10:46:02 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-03-11 14:50:06 +00:00
|
|
|
if [ "$action" = "update-all" ]; then
|
|
|
|
majorVersion=$2
|
2015-09-23 10:46:02 +01:00
|
|
|
if [ -z "$majorVersion" ]; then
|
|
|
|
echo "No major version specified" >&2
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
# find projects
|
|
|
|
projects=$(find_project -exec basename '{}' \;)
|
|
|
|
for project in $projects; do
|
|
|
|
if echo "$NO_GNOME_MAJOR"|grep -q $project; then
|
|
|
|
echo "Skipping $project"
|
|
|
|
else
|
|
|
|
echo "= Updating $project to $majorVersion" >&2
|
2017-03-11 14:50:06 +00:00
|
|
|
update_project "$project" "$majorVersion"
|
2015-09-23 10:46:02 +01:00
|
|
|
echo >&2
|
|
|
|
fi
|
|
|
|
done
|
2015-09-17 15:55:31 +01:00
|
|
|
else
|
2017-03-11 14:50:06 +00:00
|
|
|
project=$2
|
|
|
|
majorVersion=$3
|
2015-09-23 10:46:02 +01:00
|
|
|
|
|
|
|
if [ -z "$project" ]; then
|
|
|
|
echo "No project specified, exiting" >&2
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2017-03-11 14:50:06 +00:00
|
|
|
if [ "$action" = show ]; then
|
|
|
|
show_project "$project" "$majorVersion"
|
|
|
|
elif [ "$action" = update ]; then
|
|
|
|
update_project "$project" "$majorVersion"
|
2015-09-23 10:46:02 +01:00
|
|
|
else
|
|
|
|
echo "Unknown action $action" >&2
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
fi
|