tazpkg rev 110
Tazpkg: allow any character in VERSION
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Jul 01 19:52:14 2008 +0000 (2008-07-01) |
parents | 4e5d0c5958bb |
children | 94bd7f860e6f |
files | tazpkg |
line diff
1.1 --- a/tazpkg Tue Jul 01 08:35:12 2008 +0000 1.2 +++ b/tazpkg Tue Jul 01 19:52:14 2008 +0000 1.3 @@ -169,10 +169,28 @@ 1.4 fi 1.5 } 1.6 1.7 +# Get package name in a directory 1.8 +package_fullname_in_dir() 1.9 +{ 1.10 + . $1/receipt 1.11 + echo $PACKAGE-$VERSION$EXTRAVERSION 1.12 +} 1.13 + 1.14 +# Get package name that is already installed. 1.15 +get_installed_package_pathname() 1.16 +{ 1.17 + for i in $INSTALLED/${1%%-*}*; do 1.18 + if [ "$1" = "$(package_fullname_in_dir $i)" ]; then 1.19 + echo $i 1.20 + return 1.21 + fi 1.22 + done 1.23 +} 1.24 + 1.25 # Check if a package is already installed. 1.26 check_for_installed_package() 1.27 { 1.28 - if [ -d "$INSTALLED/${PACKAGE%-[0-9A-Z]*}" ]; then 1.29 + if [ -n "$(get_installed_package_pathname $PACKAGE)" ]; then 1.30 echo -e " 1.31 $PACKAGE is already installed. You can use the --forced option to force 1.32 installation or remove it and reinstall.\n" 1.33 @@ -196,12 +214,31 @@ 1.34 fi 1.35 } 1.36 1.37 +# Get a package name in packages.list (whatever the version is). 1.38 +get_package_fullname_in_list() 1.39 +{ 1.40 + local pkg=$1 1.41 + while [ "$pkg" != "${pkg%-*}" ]; do 1.42 + case "$pkg" in 1.43 + *[0-9]);; 1.44 + *) break;; # version must end is 0..9 1.45 + esac 1.46 + pkg=${pkg%-*} 1.47 + if grep -q ^$pkg $2; then 1.48 + grep ^$pkg $2 # echo 1.49 + break 1.50 + fi 1.51 + done 1.52 +} 1.53 + 1.54 # Check for a package in packages.list. Used by get and get-install to grep 1.55 # package basename. 1.56 check_for_package_in_list() 1.57 { 1.58 - if grep -q "^$PACKAGE-[0-9A-Z]" $LOCALSTATE/packages.list; then 1.59 - PACKAGE=`grep ^$PACKAGE-[0-9A-Z] $LOCALSTATE/packages.list` 1.60 + local pkg 1.61 + pkg=$(get_package_fullname_in_list $PACKAGE $LOCALSTATE/packages.list) 1.62 + if [ -n "$pkg" ]; then 1.63 + PACKAGE=$pkg 1.64 else 1.65 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n" 1.66 exit 0 1.67 @@ -248,9 +285,9 @@ 1.68 . $PWD/receipt 1.69 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then 1.70 echo -n "Checking post install dependencies... " 1.71 - [ -d "$INSTALLED/${PACKAGE%-[0-9A-Z]*}" ] 1.72 + [ -n "$(get_installed_package_pathname $PACKAGE)" ] 1.73 if ! status; then 1.74 - echo "Please run 'tazpkg install $PACKAGE_FILE' and retry." 1.75 + echo "Please run 'tazpkg install $PACKAGE_FILE' in / and retry." 1.76 cd .. && rm -rf $TMP_DIR 1.77 exit 1 1.78 fi 1.79 @@ -334,10 +371,16 @@ 1.80 # the TAZPKG_BASENAME in the local packages.list. 1.81 if [ -f "$TOP_DIR/packages.list" ]; then 1.82 echo "Checking if $pkg exist in local list... " 1.83 - TAZPKG_BASENAME=`grep -e ^$pkg-[0-9A-Z] $TOP_DIR/packages.list` 1.84 - if [ -f "$TAZPKG_BASENAME.tazpkg" ]; then 1.85 - tazpkg install $TAZPKG_BASENAME.tazpkg 1.86 - fi 1.87 + mkdir $TMP_DIR 1.88 + for i in $pkg-*.tazpkg; do 1.89 + ( cd $TMP_DIR ; cpio -i receipt ) < $i 1.90 + if grep -q ^$(package_fullname_in_dir $TMP_DIR)$ $TOP_DIR/packages.list 1.91 + then 1.92 + tazpkg install $i 1.93 + break 1.94 + fi 1.95 + done 1.96 + rm -rf $TMP_DIR 1.97 # Install deps from the mirror. 1.98 else 1.99 if [ ! -f "$LOCALSTATE/packages.list" ]; then 1.100 @@ -1161,9 +1204,9 @@ 1.101 else 1.102 # Check if the installed package is in the current list (other 1.103 # mirror or local). 1.104 - if grep -q "^$PACKAGE-[0-9A-Z]" packages.list; then 1.105 + NEW_PACKAGE=$(get_package_fullname_in_list $PACKAGE packages.list) 1.106 + if [ -n "$NEW_PACKAGE" ]; then 1.107 # Set new pkg and version for futur comparaison 1.108 - NEW_PACKAGE=`grep ^$PACKAGE-[0-9A-Z] packages.list` 1.109 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/` 1.110 # Change '-' and 'pre' to points. 1.111 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`