tazpkg rev 20
Tazpkg install: new option --root=
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Dec 13 21:53:36 2007 +0100 (2007-12-13) |
parents | fa0a764a285f |
children | dea284a89f11 |
files | tazpkg |
line diff
1.1 --- a/tazpkg Wed Dec 12 12:27:55 2007 +0100 1.2 +++ b/tazpkg Thu Dec 13 21:53:36 2007 +0100 1.3 @@ -103,6 +103,7 @@ 1.4 echo -en "\\033[1;31mFailed" 1.5 fi 1.6 echo -e "\\033[0;39m ]" 1.7 + return $CHECK 1.8 } 1.9 1.10 # Check if user is root to install, or remove packages. 1.11 @@ -199,6 +200,11 @@ 1.12 # This function install a package in the rootfs. 1.13 install_package() 1.14 { 1.15 + ROOT=$1 1.16 + if [ -n "$ROOT" ]; then 1.17 + # get absolute path 1.18 + ROOT=$(cd $ROOT; pwd) 1.19 + fi 1.20 mkdir -p $TMP_DIR 1.21 echo "" 1.22 echo -e "\033[1mInstallation of :\033[0m $PACKAGE" 1.23 @@ -208,33 +214,40 @@ 1.24 status 1.25 cd $TMP_DIR 1.26 extract_package 1.27 + SELF_INSTALL=0 1.28 # Include temporary receipt to get the right variables. 1.29 . $PWD/receipt 1.30 + if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then 1.31 + echo -n "Checking post install dependencies... " 1.32 + [ -d "$INSTALLED/${PACKAGE%-[0-9]*}" ] 1.33 + if ! status; then 1.34 + echo "Please run 'tazpkg install $PACKAGE_FILE' and retry." 1.35 + cd .. && rm -rf $TMP_DIR 1.36 + exit 1 1.37 + fi 1.38 + fi 1.39 # Make the installed package data dir to store 1.40 # the receipt and the files list. 1.41 - mkdir -p $INSTALLED/$PACKAGE 1.42 - cp receipt $INSTALLED/$PACKAGE 1.43 - # Include installed receipt. 1.44 - . $INSTALLED/$PACKAGE/receipt 1.45 - # Copy the list of files and the description if found. 1.46 - cp files.list $INSTALLED/$PACKAGE 1.47 + mkdir -p $ROOT$INSTALLED/$PACKAGE 1.48 + cp receipt files.list $ROOT$INSTALLED/$PACKAGE 1.49 + # Copy the description if found. 1.50 if [ -f "description.txt" ]; then 1.51 - cp description.txt $INSTALLED/$PACKAGE 1.52 + cp description.txt $ROOT$INSTALLED/$PACKAGE 1.53 fi 1.54 - if [ `cat $INSTALLED/$PACKAGE/receipt | grep pre_install` ]; then 1.55 + if grep -q pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then 1.56 # Execute post install commands. 1.57 - pre_install 1.58 + pre_install $ROOT 1.59 fi 1.60 echo -n "Installing $PACKAGE... " 1.61 - cp -a fs/* / 1.62 + cp -a fs/* $ROOT/ 1.63 status 1.64 # Remove the temporary random directory. 1.65 echo -n "Removing all tmp files... " 1.66 cd .. && rm -rf $TMP_DIR 1.67 status 1.68 - if [ `cat $INSTALLED/$PACKAGE/receipt | grep post_install` ]; then 1.69 + if grep -q post_install $ROOT$INSTALLED/$PACKAGE/receipt; then 1.70 # Execute post install commands. 1.71 - post_install 1.72 + post_install $ROOT 1.73 fi 1.74 cd $TOP_DIR 1.75 echo "================================================================================" 1.76 @@ -522,9 +535,24 @@ 1.77 check_for_package_on_cmdline 1.78 check_for_package_file 1.79 # Check if forced install. 1.80 - if [ "$3" = "--forced" ]; then 1.81 - continue 1.82 - else 1.83 + DO_CHECK="yes" 1.84 + while [ -n "$3" ]; do 1.85 + case "$3" in 1.86 + --forced) 1.87 + DO_CHECK="no" 1.88 + ;; 1.89 + --root=*) 1.90 + install_package ${3#--root=} 1.91 + exit $? 1.92 + ;; 1.93 + *) shift 2 1.94 + echo -e "\nUnknown option $*.\n" 1.95 + exit 1 1.96 + ;; 1.97 + esac 1.98 + shift 1.99 + done 1.100 + if [ "$DO_CHECK" = "yes" ]; then 1.101 check_for_installed_package 1.102 fi 1.103 install_package 1.104 @@ -646,7 +674,7 @@ 1.105 cd $TMP_DIR 1.106 cp $INSTALLED/$PACKAGE/files.list . 1.107 cp $INSTALLED/$PACKAGE/receipt . 1.108 - cpio -pd fs < files.list 1.109 + cpio -pd fs < files.list 2> /dev/null 1.110 . ./receipt 1.111 src=$TMP_DIR/nowhere 1.112 _pkg=$TMP_DIR/nowhere