OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

144 lines
3.7 KiB

# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: lib/sde-package/update.in
# Copyright (C) 2006 - 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
package_patch_update() {
local descfile="$1" ver="$2" location="$3"
local oldver= sedopt=
local tmpfile=$( mktemp )
oldver=$( sed -n -e 's,^\[V\][ \t]\+\([^ \t]\+\)[ \t]*,\1,p' "$descfile" | head -n 1 )
echo_info "$pkg ($oldver -> $ver)"
awk -f $SDEROOT/lib/sde-package/package-update.awk -v "ver=$ver" -v "location=$location" "$descfile" > $tmpfile
if diff -u $descfile $tmpfile; then
echo_warning "No change detected."
else
cp $tmpfile "$descfile"
fi
rm -f $tmpfile
}
package_do_update() {
local pkg="$1" ver="$2" location="$3"
local confdir=$( ls -1d "$SDEROOT/package/"*"/$pkg" 2> /dev/null )
local descfile="${confdir}/${pkg}.desc"
local oldver=
if [ -z "$confdir" -o ! -f "$descfile" ]; then
echo_error "Package '$pkg' doesn't exist."
return 1
elif [ -z "$ver" ]; then
echo_info "Updating checksum for $pkg."
else
package_patch_update "$descfile" "$ver" "$location"
fi
cd "$SDEROOT"
./bin/sde-download -q "$pkg" && ./lib/sde-package/patch-cksum.sh "$pkg" | patch -p0
}
package_update_md5() {
local md5="$1" baseurl=
local nolocation= location=
shift
echo_info "Loading MD5 file from '$md5'"
if [ "$1" == "--no-location" ]; then
nolocation=yes; shift
echo_info "(Using individual download locations)"
fi
baseurl="${md5%/*}"
curl "$md5" | while read md5sum file; do
pkg=$( echo "$file" | sed -e 's,-[0-9].*,,' | tr [A-Z] [a-z] )
if [ -z "$pkg" ]; then
echo_arror "Failed to detect package name for '$file'."
continue
fi
case "$pkg" in
exo)
pkg=lib${pkg} ;;
gtk-xfce-engine)
pkg=${pkg}2 ;;
kde-i18n/*)
pkg=${pkg#*/} ;;
terminal)
pkg=xfce4-terminal ;;
esac
confdir=$( ls -1d $SDEROOT/package/*/$pkg 2> /dev/null || true )
if [ -z "$confdir" -o ! -f "$confdir/$pkg.desc" ]; then
echo_error "Failed to detect package name for '$file' ($pkg)."
continue
fi
ver=$( echo "$file" | sed -n -e 's,.*-\([0-9].*\)\.tar\.bz2,\1,p' )
if [ -z "$ver" ]; then
echo_error "Failed to detect new version for $pkg ($file)."
continue
fi
if [ -z "$nolocation" ]; then
location="$baseurl/$file";
package_do_update "$pkg" "$ver" "${location%/*}/"
else
package_do_update "$pkg" "$ver"
fi
done
}
package_update() {
local pkg= ver=
local nolocation=
local location=
if [ "$1" == "--no-location" ]; then
nolocation=yes; shift
elif [ "$1" == "--location" ]; then
location="$2"; shift 2
fi
if [ "$1" == "--md5" ]; then
package_update_md5 "$2" ${nolocation:+--no-location}
return $?
elif [ $# -eq 2 ]; then
# package and version
pkg="$( echo "$1" | tr A-Z a-z)"
ver="$2"
elif [ $# -eq 1 ]; then
# package or verion?
pkg="$( echo "$1" | tr A-Z a-z)"
if [ ! -d "$( echo "$SDEROOT/package/"*"/$pkg/" )" ]; then
pkg="$( package_autodetect )"
ver="$1"
fi
elif [ $# -eq 0 ]; then
# can i refresh an autodetected package?
pkg=$( package_autodetect )
else
echo_error "Invalid Syntax."
. $SDEROOT/lib/sde-help.in
help_command package
return 1
fi
if [ -n "$pkg" ]; then
package_do_update "$pkg" "$ver" "${location}"
else
echo_error "I could't guess which package you want to update."
. $SDEROOT/lib/sde-help.in
help_command package
return 2
fi
}