# HG changeset patch # User Antoine Bodin # Date 1295910108 -3600 # Node ID bed335284b2eac0a50d1da6148e3229220857cce # Parent 7c7613903abef08df91d0fa3f281cb9dee511b58 Use library libtaz, libtaz/commons; use can now use several option at the same time with install/get-install diff -r 7c7613903abe -r bed335284b2e tazpkg --- a/tazpkg Mon Jan 24 22:47:08 2011 +0100 +++ b/tazpkg Tue Jan 25 00:01:48 2011 +0100 @@ -27,6 +27,8 @@ # Script variables # #################### +source /usr/lib/slitaz/libtaz +source_lib commons . /etc/slitaz/tazpkg.conf # Include gettext helper script. @@ -49,6 +51,7 @@ PACKAGE_FILE=$2 TARGET_DIR=$3 TOP_DIR=`pwd` +TMP_DIR=$tmp/$RANDOM INSTALL_LIST="" # Path to tazpkg used dir and configuration files @@ -60,12 +63,8 @@ # Check if the directories and files used by Tazpkg # exist. If not and user is root we create them. if test $(id -u) = 0 ; then - if [ ! -d "$CACHE_DIR" ]; then - mkdir -p $CACHE_DIR - fi - if [ ! -d "$INSTALLED" ]; then - mkdir -p $INSTALLED - fi + check_dir $CACHE_DIR + check_dir $INSTALLED if [ ! -f "$LOCALSTATE/mirror" ]; then echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror fi @@ -126,32 +125,6 @@ reconfigure `gettext \"Replay post install script from package.\"`" } -# Status function with color (supported by Ash). -status() -{ - local CHECK=$? - echo -en "\\033[70G[ " - if [ $CHECK = 0 ]; then - echo -en "\\033[1;33m`gettext \"OK\"`" - else - echo -en "\\033[1;31m`gettext \"Failed\"`" - fi - echo -e "\\033[0;39m ]" - return $CHECK -} - -# Check if user is root to install, or remove packages. -check_root() -{ - if test $(id -u) != 0 ; then - echo - gettext \ -"You must be root to run tazpkg with this option. Please use the command: -su followed by the root password to become super-user."; echo - echo "" && exit 0 - fi -} - # Check for a package name on cmdline. check_for_package_on_cmdline() { @@ -1756,28 +1729,14 @@ # Get repositories priority list. look_for_priority + get_options_list="root forced list" + get_options # Check if forced install. DO_CHECK="yes" - ROOT="" - while [ -n "$3" ]; do - case "$3" in - --forced) - DO_CHECK="no" - ;; - --root=*) - ROOT="${3#--root=}" - ;; - --list=*) - INSTALL_LIST="${3#--list=}" - ;; - *) shift 2 - echo -e "\n`gettext \"Unknow option\"` $*.\n" >&2 - exit 1 - ;; - esac - shift - done + [ "$forced" ] && DO_CHECK=no + [ "$root" ] && ROOT="$root" + [ "$list" ] && INSTALL_LIST="$list" if [ "$DO_CHECK" = "yes" ]; then check_for_installed_package $ROOT fi @@ -2638,26 +2597,13 @@ # Get repositories priority list. look_for_priority + get_options_list="root forced list" + get_options DO_CHECK="" - while [ -n "$3" ]; do - case "$3" in - --forced) - DO_CHECK="no" - ;; - --root=*) - ROOT="${3#--root=}" - ;; - --list=*) - INSTALL_LIST="${3#--list=}" - ;; - *) shift 2 - echo -e "\n`gettext \"Unknow option\"` $*.\n" >&2 - exit 1 - ;; - esac - shift - done + [ "$forced" ] && DO_CHECK=no + [ "$root" ] && ROOT="$root" + [ "$list" ] && INSTALL_LIST="$list" AUTOEXEC="no" if ! check_for_package_in_list check; then PACKAGE=get-$PACKAGE diff -r 7c7613903abe -r bed335284b2e tazpkg.conf --- a/tazpkg.conf Mon Jan 24 22:47:08 2011 +0100 +++ b/tazpkg.conf Tue Jan 25 00:01:48 2011 +0100 @@ -4,31 +4,5 @@ # Auto-installation of packages dependencies. AUTO_INSTALL_DEPS="yes" -# Path to all packages meta files (lists, receipt, desc). -LOCALSTATE="/var/lib/tazpkg" - -# Path to downloaded packages by get-install command. -CACHE_DIR="/var/cache/tazpkg" - # Path to Tazpkg log file. LOG="/var/log/tazpkg.log" - -# Path to the temporary directory used to extract packages. -TMP_DIR="/tmp/tazpkg-$$-$RANDOM" - -# Packages categories. -CATEGORIES=" -base-system -x-window -utilities -network -graphics -multimedia -office -development -system-tools -security -games -misc -meta -non-free"