[pacman-dev] [PATCH] scripts/*.sh.in: Clean up and fix a few bugs
repo-add, repo-remove: 'bsdtar -c * | ...' doesn't work (you need '-f -'). Code clean up eliminated this bug. Removed the multiple checksum support, pacman now only supports MD5, so there's no need for the database to contain multiple checksums. Quote all variables containing file/dir names to prevent paths containing spaces from causing problems. Add msg, warning and error functions. General code clean up. pacman-optimize: Use a sub-directory in /tmp for working files to make it easier to clean up at the end. Add quotes round $@ in die and die_r, otherwise printf can't display the message correctly. makepkg: Disable colour output if stderr is not a tty. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> --- scripts/makepkg.sh.in | 10 +- scripts/pacman-optimize.sh.in | 49 ++++--- scripts/repo-add.sh.in | 297 ++++++++++++++++++++--------------------- scripts/repo-remove.sh.in | 144 +++++++++++++------- 4 files changed, 266 insertions(+), 234 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cd5dbf5..d5b4114 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -66,7 +66,7 @@ PACMAN_OPTS= plain() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf " ${mesg}\n" "$@" >&2 @@ -75,7 +75,7 @@ plain() { msg() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf "==> ${mesg}\n" "$@" >&2 @@ -84,7 +84,7 @@ msg() { msg2() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf " -> ${mesg}\n" "$@" >&2 @@ -93,7 +93,7 @@ msg2() { warning() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 @@ -102,7 +102,7 @@ warning() { error() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 4c47d88..83c56a7 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -63,13 +63,13 @@ There is NO WARRANTY, to the extent permitted by law.\n")" } die() { - error $@ + error "$@" exit 1 } die_r() { - rm -f $lockfile - die $@ + rm -f "$lockfile" + die "$@" } if [ "$1" = "-h" -o "$1" = "--help" ]; then @@ -87,8 +87,8 @@ if [ "$1" != "" ]; then fi # make sure pacman isn't running -if [ -f $lockfile ]; then - die "$(gettext "Pacman lockfile was found. Cannot run while pacman is running.")" +if [ -f "$lockfile" ]; then + die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")" fi if [ ! -d "$dbroot" ]; then @@ -99,55 +99,58 @@ if [ ! -w "$dbroot" ]; then die "$(gettext "You must have correct permissions to optimize the database.")" fi +workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) || + die_r "$(gettext "ERROR: Can not create temp directory for database building.")\n" >&2 + # do not let pacman run while we do this -touch $lockfile +touch "$lockfile" # step 1: sum the old db msg "$(gettext "MD5sum'ing the old database...")" -find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.old +find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old" # step 2: tar it up msg "$(gettext "Tar'ing up %s...")" "$dbroot" -cd $dbroot -bsdtar -czf /tmp/pacmanDB.tgz ./ +cd "$dbroot" +bsdtar -czf "$workdir/pacmanDB.tgz" ./ if [ $? -ne 0 ]; then - rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old + rm -rf "$workdir" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot" fi # step 3: make and sum the new db msg "$(gettext "Making and MD5sum'ing the new db...")" -mkdir $dbroot.new -bsdtar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/ +mkdir "$dbroot.new" +bsdtar -zxpf "$workdir/pacmanDB.tgz" -C "$dbroot.new/" if [ $? -ne 0 ]; then - rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old - rm -rf "$dbroot.new" - die_r "$(gettext "Untar'ing $dbroot failed.")" + rm -rf "$workdir" + die_r "$(gettext "Untar'ing %s failed.")" "$dbroot" fi -find "$dbroot.new" -type f | sort | sed -e 's/pacman.new/pacman/g' | \ - xargs md5sum > /tmp/pacsums.new +find "$dbroot.new" -type f | sort | \ + xargs md5sum | sed 's#.new/##' > "$workdir/pacsums.new" # step 4: compare the sums msg "$(gettext "Checking integrity...")" -diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1 +diff "$workdir/pacsums.old" "$workdir/pacsums.new" >/dev/null 2>&1 if [ $? -ne 0 ]; then # failed # leave /tmp/pacsums.old and .new for checking to see what doesn't match up - rm -rf "$dbroot.new" $lockfile /tmp/pacmanDB.tgz - die_r "$(gettext "integrity check FAILED, reverting to old database.")" + rm -rf "$dbroot.new" + die_r "$(gettext "Integrity check FAILED, reverting to old database.")" fi # step 5: remove the new temporary database and the old one # and use the .tgz to replace the old one msg "$(gettext "Putting the new database in place...")" rm -rf "$dbroot.new" "$dbroot"/* -bsdtar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/ +bsdtar -zxpf "$workdir/pacmanDB.tgz" -C "$dbroot/" # remove the lock file, sum files, and .tgz of database -rm -f $lockfile /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz +rm -f "$lockfile" +rm -rf "$workdir" echo -echo "$(gettext "Finished. Your pacman database has been optimized.")" +msg "$(gettext "Finished. Your pacman database has been optimized.")" echo exit 0 diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index f8c5de2..c2cb297 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -29,6 +29,42 @@ myver='@PACKAGE_VERSION@' FORCE=0 REPO_DB_FILE="" +msg() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf "==> ${mesg}\n" "$@" >&1 + fi +} + +msg2() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf " -> ${mesg}\n" "$@" >&1 + fi +} + +warning() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 + fi +} + +error() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 + fi +} + # print usage instructions usage() { printf "repo-add (pacman) %s\n\n" "$myver" @@ -51,37 +87,28 @@ This is free software; see the source for copying conditions.\n\ There is NO WARRANTY, to the extent permitted by law.\n")" } -# return calculated checksum of package -# arg1 - checksum type -# arg2 - path to package -get_checksum () { - case "$(echo "$1" | tr A-Z a-z)" in - md5) sum=$(md5sum $2); echo ${sum% *} ;; - sha1) sum=$(sha1sum $2); echo ${sum% *} ;; - sha256) sum=$(sha256sum $2); echo ${sum% *} ;; - sha384) sum=$(sha256sum $2); echo ${sum% *} ;; - sha512) sum=$(sha256sum $2); echo ${sum% *} ;; - esac -} - -# return PKGINFO string for checksum type -# arg1 - checksum type -checksum_name () { - case "$(echo "$1" | tr A-Z a-z)" in - md5) echo "MD5SUM" ;; - sha1) echo "SHA1SUM" ;; - sha256) echo "SHA256SUM" ;; - sha384) echo "SHA384SUM" ;; - sha512) echo "SHA512SUM" ;; - esac -} - # test if a file is a repository DB test_repo_db_file () { if [ -f "$REPO_DB_FILE" ]; then - [ "$(bsdtar -tf "$REPO_DB_FILE" | grep -c "/desc")" -gt 0 ] || return 1 + if bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"; then + return 0 # YES + fi else - true + return 0 # YES - No database file is also aloud. + fi + + return 1 # NO +} + +# write a list entry +# arg1 - Entry name +# arg2 - List +# arg3 - File to write to +write_list_entry() { + if [ -n "$2" ]; then + echo "%$1%" >>$3 + echo $2 | tr -s ' ' '\n' >>$3 + echo "" >>$3 fi } @@ -90,60 +117,51 @@ test_repo_db_file () { db_write_entry() { # blank out all variables and set pkgfile - pkgfile=$(readlink -f $1) - export pkgname="" - pkgver="" - pkgdesc="" - url="" - builddate="" - packager="" - csize="" - size="" - _groups="" - _depends="" - _backups="" - _licenses="" - _replaces="" - _provides="" - _conflicts="" - - OLDIFS="$IFS" + local pkgfile=$(readlink -f "$1") + local pkgname pkgver pkgdesc url builddate packager csize size \ + _groups _depends _backups _licenses _replaces _provides _conflicts + + local OLDIFS="$IFS" # IFS (field seperator) is only the newline character IFS=" " # read info from the zipped package - for i in $(bsdtar -xOf "$pkgfile" .PKGINFO | grep -v "^#" |sed 's|\(\w*\)\s*=\s*\(.*\)|\1="\2"|'); do - eval "${i}" - case "$i" in - group=*) _groups="$_groups $group" ;; - depend=*) _depends="$_depends $depend" ;; - backup=*) _backups="$_backups $backup" ;; - license=*) _licenses="$_licenses $license" ;; + local line + for line in $(bsdtar -xOf "$pkgfile" .PKGINFO | \ + grep -v "^#" | sed 's|\(\w*\)\s*=\s*\(.*\)|\1="\2"|'); do + case "$line" in + group=*) _groups="$_groups $group" ;; + depend=*) _depends="$_depends $depend" ;; + backup=*) _backups="$_backups $backup" ;; + license=*) _licenses="$_licenses $license" ;; replaces=*) _replaces="$_replaces $replaces" ;; provides=*) _provides="$_provides $provides" ;; conflict=*) _conflicts="$_conflicts $conflict" ;; + *) eval "$line" ;; esac done IFS=$OLDIFS # get compressed size of package - csize="$(du -b -L $pkgfile | cut -f1)" + csize=$(du -b -L "$pkgfile" | cut -f 1) - cd $gstmpdir + pushd "$gstmpdir" 2>&1 >/dev/null # ensure $pkgname and $pkgver variables were found if [ -z "$pkgname" -o -z "$pkgver" ]; then - printf "$(gettext " error: invalid package file")\n" + error "$(gettext "ERROR: Invalid package file '%s'.")" "$pkgfile" + popd 2>&1 >/dev/null return 1 fi # remove any other package in the DB with same name + local existing for existing in *; do if [ "${existing%-*-*}" = "$pkgname" ]; then - printf "$(gettext ":: removing existing package '%s'")\n" "$existing" - rm -rf $existing + msg2 "$(gettext "Removing existing package '%s'...")" "$existing" + rm -rf "$existing" fi done @@ -152,67 +170,37 @@ db_write_entry() cd "$pkgname-$pkgver" # create desc entry - printf "$(gettext ":: creating 'desc' db entry")\n" - echo -e "%FILENAME%\n$(basename $1)\n" >>desc + msg2 "$(gettext "Creating 'desc' db entry...")" + echo -e "%FILENAME%\n$(basename "$1")\n" >>desc echo -e "%NAME%\n$pkgname\n" >>desc echo -e "%VERSION%\n$pkgver\n" >>desc - if [ -n "$pkgdesc" ]; then - echo -e "%DESC%\n$pkgdesc\n" >>desc - fi - if [ -n "$_groups" ]; then - echo "%GROUPS%" >>desc - echo $_groups | tr -s ' ' '\n' >>desc - echo "" >>desc - fi + [ -n "$pkgdesc" ] && echo -e "%DESC%\n$pkgdesc\n" >>desc + write_list_entry "GROUPS" "$_groups" "desc" [ -n $csize ] && echo -e "%CSIZE%\n$csize\n" >>desc [ -n $size ] && echo -e "%ISIZE%\n$size\n" >>desc # compute checksums - for chk in ${DB_CHECKSUMS[@]}; do - name="$(checksum_name $chk)" - printf "$(gettext ":: computing %s checksums")\n" "$name" - if [ -n "$name" ]; then - echo -e "%$name%\n$(get_checksum $chk $pkgfile)\n" >>desc - fi - done + msg2 "$(gettext "Computing md5 checksums...")" + echo -e "%MD5SUM%\n$(md5sum "$pkgfile" | cut -d ' ' -f 1)\n" >>desc [ -n "$url" ] && echo -e "%URL%\n$url\n" >>desc - if [ -n "$_licenses" ]; then - echo "%LICENSE%" >>desc - echo $_licenses | tr -s ' ' '\n' >>desc - echo "" >>desc - fi + write_list_entry "LICENSE" "$_licenses" "desc" [ -n "$arch" ] && echo -e "%ARCH%\n$arch\n" >>desc [ -n "$builddate" ] && echo -e "%BUILDDATE%\n$builddate\n" >>desc [ -n "$packager" ] && echo -e "%PACKAGER%\n$packager\n" >>desc - - if [ -n "$_replaces" ]; then - echo "%REPLACES%" >>desc - echo $_replaces | tr -s ' ' '\n' >>desc - echo "" >>desc - fi - [ "$FORCE" = "1" ] && echo -e "%FORCE%\n" >>desc + write_list_entry "REPLACES" "$_replaces" "desc" + [ $FORCE -eq 1 ] && echo -e "%FORCE%\n" >>desc # create depends entry - echo ":: creating 'depends' db entry" - if [ -n "$_depends" ]; then - echo "%DEPENDS%" >>depends - echo $_depends | tr -s ' ' '\n' >>depends - echo "" >>depends - fi - if [ -n "$_conflicts" ]; then - echo "%CONFLICTS%" >>depends - echo $_conflicts | tr -s ' ' '\n' >>depends - echo "" >>depends - fi - if [ -n "$_provides" ]; then - echo "%PROVIDES%" >>depends - echo $_provides | tr -s ' ' '\n' >>depends - echo "" >>depends - fi + msg2 "$(gettext "Creating 'depends' db entry...")" + write_list_entry "DEPENDS" "$_depends" "depends" + write_list_entry "CONFLICTS" "$_conflicts" "depends" + write_list_entry "PROVIDES" "$_provides" "depends" # preserve the modification time touch -r "$pkgfile" desc depends + + popd 2>&1 >/dev/null } # end db_write_entry # PROGRAM START @@ -236,10 +224,10 @@ if [ $# -lt 2 ]; then fi # source system and user makepkg.conf -if [ -r @sysconfdir@/makepkg.conf ]; then - source @sysconfdir@/makepkg.conf +if [ -r "@sysconfdir@/makepkg.conf" ]; then + source "@sysconfdir@/makepkg.conf" else - printf "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")\n" >&2 + error "$(gettext "/etc/makepkg.conf not found. Can not continue.")" "@sysconfdir@/makepkg.conf" exit 1 # $E_CONFIG_ERROR fi @@ -248,64 +236,65 @@ if [ -r ~/.makepkg.conf ]; then fi # main routine -if [ $# -gt 1 ]; then - gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ - printf "$(gettext "cannot create temp directory for database building")\n"; \ +gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ + error "$(gettext "Can not create temp directory for database building.")"; \ exit 1) - success=0 - # parse arguements - for arg in $@; do - if [ "$arg" == "--force" -o "$arg" == "-f" ]; then - FORCE=1 - elif [ -z "$REPO_DB_FILE" ]; then - REPO_DB_FILE="$(readlink -f $arg)" - if ! test_repo_db_file; then - printf "$(gettext "error: repository file '%s' is not a proper pacman db")\n" "$REPO_DB_FILE" - exit 1 - elif [ -f "$REPO_DB_FILE" ]; then - printf "$(gettext ":: extracting database to a temporary location")\n" - bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" - fi - else - if [ -f "$arg" ]; then - if ! bsdtar -tf "$arg" .PKGINFO 2>&1 >/dev/null; then - printf "$(gettext "error: '%s' is not a package file, skipping")\n" "$arg" - else - printf "$(gettext ":: adding package '%s'")\n" "$arg" - - this_dir="$(pwd)" - if db_write_entry "$arg"; then - success=1 - fi - cd $this_dir - fi +success=0 +# parse arguements +for arg in "$@"; do + if [ "$arg" == "--force" -o "$arg" == "-f" ]; then + FORCE=1 + elif [ -z "$REPO_DB_FILE" ]; then + REPO_DB_FILE=$(readlink -f "$arg") + if ! test_repo_db_file; then + error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE" + exit 1 + elif [ -f "$REPO_DB_FILE" ]; then + msg "$(gettext "Extracting database to a temporary location...")" + bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" + fi + else + if [ -f "$arg" ]; then + if ! bsdtar -tf "$arg" .PKGINFO 2>&1 >/dev/null; then + error "$(gettext "'%s' is not a package file, skipping")" "$arg" else - printf "$(gettext "error: package '%s' not found")\n" "$arg" + msg "$(gettext "Adding package '%s'")" "$arg" + + if db_write_entry "$arg"; then + success=1 + fi fi + else + error "$(gettext "Package '%s' not found.")" "$arg" fi - done + fi +done - # if all operations were a success, rezip database - if [ "$success" = "1" ]; then - printf "$(gettext ":: creating updated database file %s")\n" "$REPO_DB_FILE" - cd $gstmpdir - if [ -n "$(ls)" ]; then - [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" - [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" - case "$DB_COMPRESSION" in - gz) bsdtar -c * | gzip -9 >$REPO_DB_FILE ;; - bz2) bsdtar -c * | bzip2 -9 >$REPO_DB_FILE ;; - *) printf "$(gettext "warning: no compression set")\n" - bsdtar -c * >$REPO_DB_FILE;; - esac - fi - else - printf "$(gettext ":: no packages modified, nothing to do")\n" +# if all operations were a success, rezip database +if [ $success -eq 1 ]; then + msg "$(gettext "Creating updated database file %s")" "$REPO_DB_FILE" + pushd "$gstmpdir" 2>&1 >/dev/null + + if [ -n "$(ls)" ]; then + [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" + [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" + + case "$DB_COMPRESSION" in + gz) TAR_OPT="z" ;; + bz2) TAR_OPT="j" ;; + *) warning "$(gettext "No compression set.")" ;; + esac + + bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" * fi + + popd 2>&1 >/dev/null +else + msg "$(gettext "No packages modified, nothing to do.")" fi # remove the temp directory used to unzip -[ -d "$gstmpdir" ] && rm -rf $gstmpdir +[ -d "$gstmpdir" ] && rm -rf "$gstmpdir" # vim: set ts=2 sw=2 noet: diff --git a/scripts/repo-remove.sh.in b/scripts/repo-remove.sh.in index 49ff358..ee0c16c 100644 --- a/scripts/repo-remove.sh.in +++ b/scripts/repo-remove.sh.in @@ -29,6 +29,42 @@ myver='@PACKAGE_VERSION@' FORCE=0 REPO_DB_FILE="" +msg() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf "==> ${mesg}\n" "$@" >&1 + fi +} + +msg2() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf " -> ${mesg}\n" "$@" >&1 + fi +} + +warning() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 + fi +} + +error() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 + fi +} + # print usage instructions usage() { printf "$(gettext "repo-remove %s\n\n")" $myver @@ -51,24 +87,28 @@ There is NO WARRANTY, to the extent permitted by law.\n")" # test if a file is a repository DB test_repo_db_file () { if [ -f "$REPO_DB_FILE" ]; then - [ "$(bsdtar -tf "$REPO_DB_FILE" | grep -c "/desc")" -gt 0 ] || return 1 - else - true + if bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"; then + return 0 # YES + fi fi + + return 1 # NO } # remove existing entries from the DB -db_remove_entry() -{ - cd $gstmpdir +db_remove_entry() { + pushd "$gstmpdir" 2>&1 >/dev/null # remove any other package in the DB with same name + local existing for existing in *; do if [ "${existing%-*-*}" = "$1" ]; then - printf "$(gettext ":: removing existing package '%s'")\n" "$existing" - rm -rf $existing + msg2 "$(gettext "Removing existing package '%s'...")" "$existing" + rm -rf "$existing" fi done + + popd &>/dev/null } # end db_remove_entry # PROGRAM START @@ -92,10 +132,10 @@ if [ $# -lt 2 ]; then fi # source system and user makepkg.conf -if [ -r @sysconfdir@/makepkg.conf ]; then - source @sysconfdir@/makepkg.conf +if [ -r "@sysconfdir@/makepkg.conf" ]; then + source "@sysconfdir@/makepkg.conf" else - printf "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")\n" >&2 + error "$(gettext "%s not found. Cannot continue.")" "@sysconfdir@/makepkg.conf" exit 1 # $E_CONFIG_ERROR fi @@ -104,53 +144,53 @@ if [ -r ~/.makepkg.conf ]; then fi # main routine -if [ $# -gt 1 ]; then - gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ - printf "$(gettext "cannot create temp directory for database building")\n"; \ +gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ + error "$(gettext "Cannot create temp directory for database building.")"; \ exit 1) - success=0 - # parse arguements - for arg in $@; do - if [ -z "$REPO_DB_FILE" ]; then - REPO_DB_FILE="$(readlink -f $arg)" - if ! test_repo_db_file; then - printf "$(gettext "error: repository file '%s' is not a proper pacman db")\n" "$REPO_DB_FILE" - exit 1 - elif [ -f "$REPO_DB_FILE" ]; then - printf "$(gettext ":: extracting database to a temporary location")\n" - bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" - fi - else - printf "$(gettext ":: searching for package '%s'")\n" - - this_dir="$(pwd)" - if db_remove_entry "$arg"; then - success=1 - else - printf "$(gettext "error: package matching '%s' not found")\n" "$arg" - fi - cd $this_dir +success=0 +# parse arguements +for arg in "$@"; do + if [ -z "$REPO_DB_FILE" ]; then + REPO_DB_FILE=$(readlink -f "$arg") + if ! test_repo_db_file; then + error "$(gettext "Repository file '%s' is not a proper pacman database.")\n" "$REPO_DB_FILE" + exit 1 + elif [ -f "$REPO_DB_FILE" ]; then + msg "$(gettext "Extracting database to a temporary location...")" + bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" fi - done + else + msg "$(gettext "Searching for package '%s'...")" "$arg" - # if all operations were a success, rezip database - if [ "$success" = "1" ]; then - printf "$(gettext ":: creating updated database file %s")\n" "$REPO_DB_FILE" - cd $gstmpdir - if [ -n "$(ls)" ]; then - [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" - [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" - case "$DB_COMPRESSION" in - gz) bsdtar -c * | gzip -9 >$REPO_DB_FILE ;; - bz2) bsdtar -c * | bzip2 -9 >$REPO_DB_FILE ;; - *) printf "$(gettext "warning: no compression set")\n" - bsdtar -c * >$REPO_DB_FILE;; - esac + if db_remove_entry "$arg"; then + success=1 + else + error "$(gettext "Package matching '%s' not found.")" "$arg" fi - else - printf "$(gettext ":: no packages modified, nothing to do")\n" fi +done + +# if all operations were a success, rezip database +if [ $success -eq 1 ]; then + msg "$(gettext "Creating updated database file '%s'...")" "$REPO_DB_FILE" + pushd "$gstmpdir" 2>&1 >/dev/null + + if [ -n "$(ls)" ]; then + [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" + [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" + case "$DB_COMPRESSION" in + gz) TAR_OPT="z" ;; + bz2) TAR_OPT="j" ;; + *) warning "$(gettext "No compression set.")" ;; + esac + + bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" * + fi + + popd 2>&1 >/dev/null +else + msg "$(gettext "No packages modified, nothing to do.")" fi # remove the temp directory used to unzip -- 1.5.2.5
repo-add, repo-remove: 'bsdtar -c * | ...' doesn't work (you need '-f -'). Code clean up eliminated this bug. Removed the multiple checksum support, pacman now only supports MD5, so there's no need for the database to contain multiple checksums. Quote all variables containing file/dir names to prevent paths containing spaces from causing problems. Add msg, warning and error functions. General code clean up. pacman-optimize: Use a sub-directory in /tmp for working files to make it easier to clean up at the end. Add quotes round $@ in die and die_r, otherwise printf can't display the message correctly. makepkg: Disable colour output if stderr is not a tty. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> --- scripts/makepkg.sh.in | 10 +- scripts/pacman-optimize.sh.in | 49 ++++--- scripts/repo-add.sh.in | 298 ++++++++++++++++++++--------------------- scripts/repo-remove.sh.in | 144 +++++++++++++------- 4 files changed, 267 insertions(+), 234 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cd5dbf5..d5b4114 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -66,7 +66,7 @@ PACMAN_OPTS= plain() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf " ${mesg}\n" "$@" >&2 @@ -75,7 +75,7 @@ plain() { msg() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf "==> ${mesg}\n" "$@" >&2 @@ -84,7 +84,7 @@ msg() { msg2() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf " -> ${mesg}\n" "$@" >&2 @@ -93,7 +93,7 @@ msg2() { warning() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 @@ -102,7 +102,7 @@ warning() { error() { local mesg=$1; shift - if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 else printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 4c47d88..83c56a7 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -63,13 +63,13 @@ There is NO WARRANTY, to the extent permitted by law.\n")" } die() { - error $@ + error "$@" exit 1 } die_r() { - rm -f $lockfile - die $@ + rm -f "$lockfile" + die "$@" } if [ "$1" = "-h" -o "$1" = "--help" ]; then @@ -87,8 +87,8 @@ if [ "$1" != "" ]; then fi # make sure pacman isn't running -if [ -f $lockfile ]; then - die "$(gettext "Pacman lockfile was found. Cannot run while pacman is running.")" +if [ -f "$lockfile" ]; then + die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")" fi if [ ! -d "$dbroot" ]; then @@ -99,55 +99,58 @@ if [ ! -w "$dbroot" ]; then die "$(gettext "You must have correct permissions to optimize the database.")" fi +workdir=$(mktemp -d /tmp/pacman-optimize.XXXXXXXXXX) || + die_r "$(gettext "ERROR: Can not create temp directory for database building.")\n" >&2 + # do not let pacman run while we do this -touch $lockfile +touch "$lockfile" # step 1: sum the old db msg "$(gettext "MD5sum'ing the old database...")" -find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.old +find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old" # step 2: tar it up msg "$(gettext "Tar'ing up %s...")" "$dbroot" -cd $dbroot -bsdtar -czf /tmp/pacmanDB.tgz ./ +cd "$dbroot" +bsdtar -czf "$workdir/pacmanDB.tgz" ./ if [ $? -ne 0 ]; then - rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old + rm -rf "$workdir" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot" fi # step 3: make and sum the new db msg "$(gettext "Making and MD5sum'ing the new db...")" -mkdir $dbroot.new -bsdtar -zxpf /tmp/pacmanDB.tgz -C $dbroot.new/ +mkdir "$dbroot.new" +bsdtar -zxpf "$workdir/pacmanDB.tgz" -C "$dbroot.new/" if [ $? -ne 0 ]; then - rm -f /tmp/pacmanDB.tgz /tmp/pacsums.old - rm -rf "$dbroot.new" - die_r "$(gettext "Untar'ing $dbroot failed.")" + rm -rf "$workdir" + die_r "$(gettext "Untar'ing %s failed.")" "$dbroot" fi -find "$dbroot.new" -type f | sort | sed -e 's/pacman.new/pacman/g' | \ - xargs md5sum > /tmp/pacsums.new +find "$dbroot.new" -type f | sort | \ + xargs md5sum | sed 's#.new/##' > "$workdir/pacsums.new" # step 4: compare the sums msg "$(gettext "Checking integrity...")" -diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1 +diff "$workdir/pacsums.old" "$workdir/pacsums.new" >/dev/null 2>&1 if [ $? -ne 0 ]; then # failed # leave /tmp/pacsums.old and .new for checking to see what doesn't match up - rm -rf "$dbroot.new" $lockfile /tmp/pacmanDB.tgz - die_r "$(gettext "integrity check FAILED, reverting to old database.")" + rm -rf "$dbroot.new" + die_r "$(gettext "Integrity check FAILED, reverting to old database.")" fi # step 5: remove the new temporary database and the old one # and use the .tgz to replace the old one msg "$(gettext "Putting the new database in place...")" rm -rf "$dbroot.new" "$dbroot"/* -bsdtar -zxpf /tmp/pacmanDB.tgz -C "$dbroot"/ +bsdtar -zxpf "$workdir/pacmanDB.tgz" -C "$dbroot/" # remove the lock file, sum files, and .tgz of database -rm -f $lockfile /tmp/pacsums.old /tmp/pacsums.new /tmp/pacmanDB.tgz +rm -f "$lockfile" +rm -rf "$workdir" echo -echo "$(gettext "Finished. Your pacman database has been optimized.")" +msg "$(gettext "Finished. Your pacman database has been optimized.")" echo exit 0 diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index f8c5de2..7420354 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -29,6 +29,42 @@ myver='@PACKAGE_VERSION@' FORCE=0 REPO_DB_FILE="" +msg() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf "==> ${mesg}\n" "$@" >&1 + fi +} + +msg2() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf " -> ${mesg}\n" "$@" >&1 + fi +} + +warning() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 + fi +} + +error() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 + fi +} + # print usage instructions usage() { printf "repo-add (pacman) %s\n\n" "$myver" @@ -51,37 +87,28 @@ This is free software; see the source for copying conditions.\n\ There is NO WARRANTY, to the extent permitted by law.\n")" } -# return calculated checksum of package -# arg1 - checksum type -# arg2 - path to package -get_checksum () { - case "$(echo "$1" | tr A-Z a-z)" in - md5) sum=$(md5sum $2); echo ${sum% *} ;; - sha1) sum=$(sha1sum $2); echo ${sum% *} ;; - sha256) sum=$(sha256sum $2); echo ${sum% *} ;; - sha384) sum=$(sha256sum $2); echo ${sum% *} ;; - sha512) sum=$(sha256sum $2); echo ${sum% *} ;; - esac -} - -# return PKGINFO string for checksum type -# arg1 - checksum type -checksum_name () { - case "$(echo "$1" | tr A-Z a-z)" in - md5) echo "MD5SUM" ;; - sha1) echo "SHA1SUM" ;; - sha256) echo "SHA256SUM" ;; - sha384) echo "SHA384SUM" ;; - sha512) echo "SHA512SUM" ;; - esac -} - # test if a file is a repository DB test_repo_db_file () { if [ -f "$REPO_DB_FILE" ]; then - [ "$(bsdtar -tf "$REPO_DB_FILE" | grep -c "/desc")" -gt 0 ] || return 1 + if bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"; then + return 0 # YES + fi else - true + return 0 # YES - No database file is also aloud. + fi + + return 1 # NO +} + +# write a list entry +# arg1 - Entry name +# arg2 - List +# arg3 - File to write to +write_list_entry() { + if [ -n "$2" ]; then + echo "%$1%" >>$3 + echo $2 | tr -s ' ' '\n' >>$3 + echo "" >>$3 fi } @@ -90,36 +117,26 @@ test_repo_db_file () { db_write_entry() { # blank out all variables and set pkgfile - pkgfile=$(readlink -f $1) - export pkgname="" - pkgver="" - pkgdesc="" - url="" - builddate="" - packager="" - csize="" - size="" - _groups="" - _depends="" - _backups="" - _licenses="" - _replaces="" - _provides="" - _conflicts="" - - OLDIFS="$IFS" + local pkgfile=$(readlink -f "$1") + local pkgname pkgver pkgdesc url builddate packager csize size \ + group depend backup license replaces provides conflict \ + _groups _depends _backups _licenses _replaces _provides _conflicts + + local OLDIFS="$IFS" # IFS (field seperator) is only the newline character IFS=" " # read info from the zipped package - for i in $(bsdtar -xOf "$pkgfile" .PKGINFO | grep -v "^#" |sed 's|\(\w*\)\s*=\s*\(.*\)|\1="\2"|'); do - eval "${i}" - case "$i" in - group=*) _groups="$_groups $group" ;; - depend=*) _depends="$_depends $depend" ;; - backup=*) _backups="$_backups $backup" ;; - license=*) _licenses="$_licenses $license" ;; + local line + for line in $(bsdtar -xOf "$pkgfile" .PKGINFO | \ + grep -v "^#" | sed 's|\(\w*\)\s*=\s*\(.*\)|\1="\2"|'); do + eval "$line" + case "$line" in + group=*) _groups="$_groups $group" ;; + depend=*) _depends="$_depends $depend" ;; + backup=*) _backups="$_backups $backup" ;; + license=*) _licenses="$_licenses $license" ;; replaces=*) _replaces="$_replaces $replaces" ;; provides=*) _provides="$_provides $provides" ;; conflict=*) _conflicts="$_conflicts $conflict" ;; @@ -129,21 +146,23 @@ db_write_entry() IFS=$OLDIFS # get compressed size of package - csize="$(du -b -L $pkgfile | cut -f1)" + csize=$(du -b -L "$pkgfile" | cut -f 1) - cd $gstmpdir + pushd "$gstmpdir" 2>&1 >/dev/null # ensure $pkgname and $pkgver variables were found if [ -z "$pkgname" -o -z "$pkgver" ]; then - printf "$(gettext " error: invalid package file")\n" + error "$(gettext "ERROR: Invalid package file '%s'.")" "$pkgfile" + popd 2>&1 >/dev/null return 1 fi # remove any other package in the DB with same name + local existing for existing in *; do if [ "${existing%-*-*}" = "$pkgname" ]; then - printf "$(gettext ":: removing existing package '%s'")\n" "$existing" - rm -rf $existing + msg2 "$(gettext "Removing existing package '%s'...")" "$existing" + rm -rf "$existing" fi done @@ -152,67 +171,37 @@ db_write_entry() cd "$pkgname-$pkgver" # create desc entry - printf "$(gettext ":: creating 'desc' db entry")\n" - echo -e "%FILENAME%\n$(basename $1)\n" >>desc + msg2 "$(gettext "Creating 'desc' db entry...")" + echo -e "%FILENAME%\n$(basename "$1")\n" >>desc echo -e "%NAME%\n$pkgname\n" >>desc echo -e "%VERSION%\n$pkgver\n" >>desc - if [ -n "$pkgdesc" ]; then - echo -e "%DESC%\n$pkgdesc\n" >>desc - fi - if [ -n "$_groups" ]; then - echo "%GROUPS%" >>desc - echo $_groups | tr -s ' ' '\n' >>desc - echo "" >>desc - fi + [ -n "$pkgdesc" ] && echo -e "%DESC%\n$pkgdesc\n" >>desc + write_list_entry "GROUPS" "$_groups" "desc" [ -n $csize ] && echo -e "%CSIZE%\n$csize\n" >>desc [ -n $size ] && echo -e "%ISIZE%\n$size\n" >>desc # compute checksums - for chk in ${DB_CHECKSUMS[@]}; do - name="$(checksum_name $chk)" - printf "$(gettext ":: computing %s checksums")\n" "$name" - if [ -n "$name" ]; then - echo -e "%$name%\n$(get_checksum $chk $pkgfile)\n" >>desc - fi - done + msg2 "$(gettext "Computing md5 checksums...")" + echo -e "%MD5SUM%\n$(md5sum "$pkgfile" | cut -d ' ' -f 1)\n" >>desc [ -n "$url" ] && echo -e "%URL%\n$url\n" >>desc - if [ -n "$_licenses" ]; then - echo "%LICENSE%" >>desc - echo $_licenses | tr -s ' ' '\n' >>desc - echo "" >>desc - fi + write_list_entry "LICENSE" "$_licenses" "desc" [ -n "$arch" ] && echo -e "%ARCH%\n$arch\n" >>desc [ -n "$builddate" ] && echo -e "%BUILDDATE%\n$builddate\n" >>desc [ -n "$packager" ] && echo -e "%PACKAGER%\n$packager\n" >>desc - - if [ -n "$_replaces" ]; then - echo "%REPLACES%" >>desc - echo $_replaces | tr -s ' ' '\n' >>desc - echo "" >>desc - fi - [ "$FORCE" = "1" ] && echo -e "%FORCE%\n" >>desc + write_list_entry "REPLACES" "$_replaces" "desc" + [ $FORCE -eq 1 ] && echo -e "%FORCE%\n" >>desc # create depends entry - echo ":: creating 'depends' db entry" - if [ -n "$_depends" ]; then - echo "%DEPENDS%" >>depends - echo $_depends | tr -s ' ' '\n' >>depends - echo "" >>depends - fi - if [ -n "$_conflicts" ]; then - echo "%CONFLICTS%" >>depends - echo $_conflicts | tr -s ' ' '\n' >>depends - echo "" >>depends - fi - if [ -n "$_provides" ]; then - echo "%PROVIDES%" >>depends - echo $_provides | tr -s ' ' '\n' >>depends - echo "" >>depends - fi + msg2 "$(gettext "Creating 'depends' db entry...")" + write_list_entry "DEPENDS" "$_depends" "depends" + write_list_entry "CONFLICTS" "$_conflicts" "depends" + write_list_entry "PROVIDES" "$_provides" "depends" # preserve the modification time touch -r "$pkgfile" desc depends + + popd 2>&1 >/dev/null } # end db_write_entry # PROGRAM START @@ -236,10 +225,10 @@ if [ $# -lt 2 ]; then fi # source system and user makepkg.conf -if [ -r @sysconfdir@/makepkg.conf ]; then - source @sysconfdir@/makepkg.conf +if [ -r "@sysconfdir@/makepkg.conf" ]; then + source "@sysconfdir@/makepkg.conf" else - printf "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")\n" >&2 + error "$(gettext "/etc/makepkg.conf not found. Can not continue.")" "@sysconfdir@/makepkg.conf" exit 1 # $E_CONFIG_ERROR fi @@ -248,64 +237,65 @@ if [ -r ~/.makepkg.conf ]; then fi # main routine -if [ $# -gt 1 ]; then - gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ - printf "$(gettext "cannot create temp directory for database building")\n"; \ +gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ + error "$(gettext "Can not create temp directory for database building.")"; \ exit 1) - success=0 - # parse arguements - for arg in $@; do - if [ "$arg" == "--force" -o "$arg" == "-f" ]; then - FORCE=1 - elif [ -z "$REPO_DB_FILE" ]; then - REPO_DB_FILE="$(readlink -f $arg)" - if ! test_repo_db_file; then - printf "$(gettext "error: repository file '%s' is not a proper pacman db")\n" "$REPO_DB_FILE" - exit 1 - elif [ -f "$REPO_DB_FILE" ]; then - printf "$(gettext ":: extracting database to a temporary location")\n" - bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" - fi - else - if [ -f "$arg" ]; then - if ! bsdtar -tf "$arg" .PKGINFO 2>&1 >/dev/null; then - printf "$(gettext "error: '%s' is not a package file, skipping")\n" "$arg" - else - printf "$(gettext ":: adding package '%s'")\n" "$arg" - - this_dir="$(pwd)" - if db_write_entry "$arg"; then - success=1 - fi - cd $this_dir - fi +success=0 +# parse arguements +for arg in "$@"; do + if [ "$arg" == "--force" -o "$arg" == "-f" ]; then + FORCE=1 + elif [ -z "$REPO_DB_FILE" ]; then + REPO_DB_FILE=$(readlink -f "$arg") + if ! test_repo_db_file; then + error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE" + exit 1 + elif [ -f "$REPO_DB_FILE" ]; then + msg "$(gettext "Extracting database to a temporary location...")" + bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" + fi + else + if [ -f "$arg" ]; then + if ! bsdtar -tf "$arg" .PKGINFO 2>&1 >/dev/null; then + error "$(gettext "'%s' is not a package file, skipping")" "$arg" else - printf "$(gettext "error: package '%s' not found")\n" "$arg" + msg "$(gettext "Adding package '%s'")" "$arg" + + if db_write_entry "$arg"; then + success=1 + fi fi + else + error "$(gettext "Package '%s' not found.")" "$arg" fi - done + fi +done - # if all operations were a success, rezip database - if [ "$success" = "1" ]; then - printf "$(gettext ":: creating updated database file %s")\n" "$REPO_DB_FILE" - cd $gstmpdir - if [ -n "$(ls)" ]; then - [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" - [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" - case "$DB_COMPRESSION" in - gz) bsdtar -c * | gzip -9 >$REPO_DB_FILE ;; - bz2) bsdtar -c * | bzip2 -9 >$REPO_DB_FILE ;; - *) printf "$(gettext "warning: no compression set")\n" - bsdtar -c * >$REPO_DB_FILE;; - esac - fi - else - printf "$(gettext ":: no packages modified, nothing to do")\n" +# if all operations were a success, rezip database +if [ $success -eq 1 ]; then + msg "$(gettext "Creating updated database file %s")" "$REPO_DB_FILE" + pushd "$gstmpdir" 2>&1 >/dev/null + + if [ -n "$(ls)" ]; then + [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" + [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" + + case "$DB_COMPRESSION" in + gz) TAR_OPT="z" ;; + bz2) TAR_OPT="j" ;; + *) warning "$(gettext "No compression set.")" ;; + esac + + bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" * fi + + popd 2>&1 >/dev/null +else + msg "$(gettext "No packages modified, nothing to do.")" fi # remove the temp directory used to unzip -[ -d "$gstmpdir" ] && rm -rf $gstmpdir +[ -d "$gstmpdir" ] && rm -rf "$gstmpdir" # vim: set ts=2 sw=2 noet: diff --git a/scripts/repo-remove.sh.in b/scripts/repo-remove.sh.in index 49ff358..ee0c16c 100644 --- a/scripts/repo-remove.sh.in +++ b/scripts/repo-remove.sh.in @@ -29,6 +29,42 @@ myver='@PACKAGE_VERSION@' FORCE=0 REPO_DB_FILE="" +msg() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf "==> ${mesg}\n" "$@" >&1 + fi +} + +msg2() { + local mesg=$1; shift + if [ -t 1 ]; then + printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&1 + else + printf " -> ${mesg}\n" "$@" >&1 + fi +} + +warning() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 + fi +} + +error() { + local mesg=$1; shift + if [ -t 2 ]; then + printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2 + else + printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 + fi +} + # print usage instructions usage() { printf "$(gettext "repo-remove %s\n\n")" $myver @@ -51,24 +87,28 @@ There is NO WARRANTY, to the extent permitted by law.\n")" # test if a file is a repository DB test_repo_db_file () { if [ -f "$REPO_DB_FILE" ]; then - [ "$(bsdtar -tf "$REPO_DB_FILE" | grep -c "/desc")" -gt 0 ] || return 1 - else - true + if bsdtar -tf "$REPO_DB_FILE" | grep -q "/desc"; then + return 0 # YES + fi fi + + return 1 # NO } # remove existing entries from the DB -db_remove_entry() -{ - cd $gstmpdir +db_remove_entry() { + pushd "$gstmpdir" 2>&1 >/dev/null # remove any other package in the DB with same name + local existing for existing in *; do if [ "${existing%-*-*}" = "$1" ]; then - printf "$(gettext ":: removing existing package '%s'")\n" "$existing" - rm -rf $existing + msg2 "$(gettext "Removing existing package '%s'...")" "$existing" + rm -rf "$existing" fi done + + popd &>/dev/null } # end db_remove_entry # PROGRAM START @@ -92,10 +132,10 @@ if [ $# -lt 2 ]; then fi # source system and user makepkg.conf -if [ -r @sysconfdir@/makepkg.conf ]; then - source @sysconfdir@/makepkg.conf +if [ -r "@sysconfdir@/makepkg.conf" ]; then + source "@sysconfdir@/makepkg.conf" else - printf "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")\n" >&2 + error "$(gettext "%s not found. Cannot continue.")" "@sysconfdir@/makepkg.conf" exit 1 # $E_CONFIG_ERROR fi @@ -104,53 +144,53 @@ if [ -r ~/.makepkg.conf ]; then fi # main routine -if [ $# -gt 1 ]; then - gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ - printf "$(gettext "cannot create temp directory for database building")\n"; \ +gstmpdir=$(mktemp -d /tmp/gensync.XXXXXXXXXX) || (\ + error "$(gettext "Cannot create temp directory for database building.")"; \ exit 1) - success=0 - # parse arguements - for arg in $@; do - if [ -z "$REPO_DB_FILE" ]; then - REPO_DB_FILE="$(readlink -f $arg)" - if ! test_repo_db_file; then - printf "$(gettext "error: repository file '%s' is not a proper pacman db")\n" "$REPO_DB_FILE" - exit 1 - elif [ -f "$REPO_DB_FILE" ]; then - printf "$(gettext ":: extracting database to a temporary location")\n" - bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" - fi - else - printf "$(gettext ":: searching for package '%s'")\n" - - this_dir="$(pwd)" - if db_remove_entry "$arg"; then - success=1 - else - printf "$(gettext "error: package matching '%s' not found")\n" "$arg" - fi - cd $this_dir +success=0 +# parse arguements +for arg in "$@"; do + if [ -z "$REPO_DB_FILE" ]; then + REPO_DB_FILE=$(readlink -f "$arg") + if ! test_repo_db_file; then + error "$(gettext "Repository file '%s' is not a proper pacman database.")\n" "$REPO_DB_FILE" + exit 1 + elif [ -f "$REPO_DB_FILE" ]; then + msg "$(gettext "Extracting database to a temporary location...")" + bsdtar -xf "$REPO_DB_FILE" -C "$gstmpdir" fi - done + else + msg "$(gettext "Searching for package '%s'...")" "$arg" - # if all operations were a success, rezip database - if [ "$success" = "1" ]; then - printf "$(gettext ":: creating updated database file %s")\n" "$REPO_DB_FILE" - cd $gstmpdir - if [ -n "$(ls)" ]; then - [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" - [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" - case "$DB_COMPRESSION" in - gz) bsdtar -c * | gzip -9 >$REPO_DB_FILE ;; - bz2) bsdtar -c * | bzip2 -9 >$REPO_DB_FILE ;; - *) printf "$(gettext "warning: no compression set")\n" - bsdtar -c * >$REPO_DB_FILE;; - esac + if db_remove_entry "$arg"; then + success=1 + else + error "$(gettext "Package matching '%s' not found.")" "$arg" fi - else - printf "$(gettext ":: no packages modified, nothing to do")\n" fi +done + +# if all operations were a success, rezip database +if [ $success -eq 1 ]; then + msg "$(gettext "Creating updated database file '%s'...")" "$REPO_DB_FILE" + pushd "$gstmpdir" 2>&1 >/dev/null + + if [ -n "$(ls)" ]; then + [ -f "${REPO_DB_FILE}.old" ] && rm "${REPO_DB_FILE}.old" + [ -f "$REPO_DB_FILE" ] && mv "$REPO_DB_FILE" "${REPO_DB_FILE}.old" + case "$DB_COMPRESSION" in + gz) TAR_OPT="z" ;; + bz2) TAR_OPT="j" ;; + *) warning "$(gettext "No compression set.")" ;; + esac + + bsdtar -c${TAR_OPT}f "$REPO_DB_FILE" * + fi + + popd 2>&1 >/dev/null +else + msg "$(gettext "No packages modified, nothing to do.")" fi # remove the temp directory used to unzip -- 1.5.2.5
Ignore this patch there's a small bug in repo-add, I'm sending the fixed patch in a second. Andrew
On 8/29/07, Andrew Fyfe <andrew@neptune-one.net> wrote:
Ignore this patch there's a small bug in repo-add, I'm sending the fixed patch in a second.
Andrew
A few comments on this patch: 1. If we use the message functions in repo-add/repo-remove and friends, then we should honor the color preference set in makepkg.conf since we source it (correct me if I'm wrong). 2. At some point we should put all these shell script functions we reuse (msg2, error, etc.) into wherever the FHS says they belong so we aren't duplicating so much code, and have each script source them. (Similar to the initscripts /etc/rc.d/functions file). 3. In repo-add, you used both error() and the text "ERROR". This will result in it getting printed twice. 4. This didn't look quite right (missing an '%s'): - printf "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")\n" >&2 + error "$(gettext "/etc/makepkg.conf not found. Can not continue.")" "@sysconfdir@/makepkg.conf" -Dan
Dan McGee wrote:
On 8/29/07, Andrew Fyfe <andrew@neptune-one.net> wrote:
Ignore this patch there's a small bug in repo-add, I'm sending the fixed patch in a second.
Andrew
A few comments on this patch: 1. If we use the message functions in repo-add/repo-remove and friends, then we should honor the color preference set in makepkg.conf since we source it (correct me if I'm wrong). Removed colours for now.
2. At some point we should put all these shell script functions we reuse (msg2, error, etc.) into wherever the FHS says they belong so we aren't duplicating so much code, and have each script source them. (Similar to the initscripts /etc/rc.d/functions file). /usr/lib/pacman?
3. In repo-add, you used both error() and the text "ERROR". This will result in it getting printed twice. Fixed 4. This didn't look quite right (missing an '%s'): - printf "$(gettext "ERROR: /etc/makepkg.conf not found. Can not continue.")\n" >&2 + error "$(gettext "/etc/makepkg.conf not found. Can not continue.")" "@sysconfdir@/makepkg.conf"
Fixed The patch is on my ready_to_pull branch. Andrew
Hi, Could anybody tell me what is this? And how to solve it properly? # pacman -R xorg checking dependencies... error: failed to prepare transaction (could not satisfy dependencies) :: xorg is required by ted # pacman -Qi ted Name : ted Version : 2.17-2 URL : http://www.nllgg.nl/Ted/ License : GPL Groups : None Provides : None Depends On : lesstif bash libtiff libxmu libxpm libpng Removes : None Required By : None Conflicts With : None Installed Size : 6763.94 K Packager : Travis Willard <travis@archlinux.org> Architecture : i686 Build Date : Fri Sep 7 23:53:01 2007 UTC Build Type : Unknown Install Date : Mon Sep 10 15:29:24 2007 UTC Install Reason : Explicitly installed Install Script : No Description : An easy rich text processor (with footnote support)
Monday 10 of September 2007 18:28:10 Sergej Pupykin napisał(a):
Hi,
Could anybody tell me what is this? And how to solve it properly?
# pacman -R xorg checking dependencies... error: failed to prepare transaction (could not satisfy dependencies)
:: xorg is required by ted
# pacman -Qi ted Name : ted Version : 2.17-2 URL : http://www.nllgg.nl/Ted/ License : GPL Groups : None Provides : None Depends On : lesstif bash libtiff libxmu libxpm libpng Removes : None Required By : None Conflicts With : None Installed Size : 6763.94 K Packager : Travis Willard <travis@archlinux.org> Architecture : i686 Build Date : Fri Sep 7 23:53:01 2007 UTC Build Type : Unknown Install Date : Mon Sep 10 15:29:24 2007 UTC Install Reason : Explicitly installed Install Script : No Description : An easy rich text processor (with footnote support)
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
Well, aparently ted requires xorg. Remove ted, so you can remove xorg. If you don't care about ted being broken by xorg's removal, you can use pacman -Rd xorg. Read the pacman documentation. pacman -R --help also, well, helps. Cheers, //m. -- Mateusz Jędrasik <m.jedrasik@gmail.com> tel. +48(79)022-9393, +48(51)69-444-90 http://imachine.szklo.eu.org
Depends On : lesstif bash libtiff libxmu libxpm libpng MJ> Well, aparently ted requires xorg. Remove ted, so you can remove xorg. If you MJ> don't care about ted being broken by xorg's removal, you can use pacman -Rd MJ> xorg.
MJ> Read the pacman documentation. pacman -R --help also, well, helps.
ted does not require xorg, just lesstif, bash, libtiff, libxmu, libxpm, libpng.
Monday 10 of September 2007 18:38:42 Sergej Pupykin napisał(a):
Depends On : lesstif bash libtiff libxmu libxpm libpng
MJ> Well, aparently ted requires xorg. Remove ted, so you can remove xorg. If you MJ> don't care about ted being broken by xorg's removal, you can use pacman -Rd MJ> xorg.
MJ> Read the pacman documentation. pacman -R --help also, well, helps.
ted does not require xorg, just lesstif, bash, libtiff, libxmu, libxpm, libpng.
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
I suppose if libxmu or libxpm was PROVIDED BY xorg, then removing xorg might be equal to removal of libxpm/libxmu, hence the message. Not much more ideas otherwise I'm afraid :) Good luck -- Mateusz Jędrasik <m.jedrasik@gmail.com> tel. +48(79)022-9393, +48(51)69-444-90 http://imachine.szklo.eu.org
SP> Hi,
SP> Could anybody tell me what is this? And how to solve it properly?
SP> # pacman -R xorg SP> checking dependencies... SP> error: failed to prepare transaction (could not satisfy dependencies) SP> :: xorg is required by ted
SP> # pacman -Qi ted SP> Depends On : lesstif bash libtiff libxmu libxpm libpng
I see it is %REQUIREDBY% in /var/lib/pacman/local/xorg-11R7.0-1/depends, but how can I fix it without manualy modifying?
On Mon, Sep 10, 2007 at 08:36:38PM +0400, Sergej Pupykin wrote:
SP> Hi,
SP> Could anybody tell me what is this? And how to solve it properly?
SP> # pacman -R xorg SP> checking dependencies... SP> error: failed to prepare transaction (could not satisfy dependencies) SP> :: xorg is required by ted
SP> # pacman -Qi ted SP> Depends On : lesstif bash libtiff libxmu libxpm libpng
I see it is %REQUIREDBY% in /var/lib/pacman/local/xorg-11R7.0-1/depends, but how can I fix it without manualy modifying?
It's a known 3.0 bug, fixed in 3.1. But why fixing a broken entry if you are going to remove it anyway? Just do pacman -Rd xorg. Otherwise, you could just do pacman -S xorg if that package wasn't removed from the repos :) But pacman -S ted should fix it as well. I actually wrote a little testdb tool just for that purpose, detecting the broken REQUIREDBY fields. http://www.archlinux.org/pipermail/pacman-dev/2007-August/009209.html goes on there: http://www.archlinux.org/pipermail/pacman-dev/2007-September/009249.html I was waiting for other opinions about whether it should be a separate tool, or rather a pacman option, like -Qt or -Qtt.
It's a known 3.0 bug, fixed in 3.1. But why fixing a broken entry if you are going to remove it anyway? Just do pacman -Rd xorg. As I see, in pacman 3.1 "-R xorg" will remove xorg with that broken requiredby field too. Bye, ngaba
---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On Mon, Sep 10, 2007 at 07:42:18PM +0200, Nagy Gabor wrote:
It's a known 3.0 bug, fixed in 3.1. But why fixing a broken entry if you are going to remove it anyway? Just do pacman -Rd xorg. As I see, in pacman 3.1 "-R xorg" will remove xorg with that broken requiredby field too.
Ah yes, seems like your changes to checkdeps also handle this case better. Anyway, looks like this xorg meta package has now been replaced by a xorg group in testing, as many people asked. So it was rather weird, I had both a xorg group and a xorg metapackage, and I had to remove all packages from xorg group first before being able to remove the xorg package. Seems like the pacman_remove function in src/pacman/remove.c may be too basic : it first checks if the target is a group, otherwise it considers it as a package. It can't be both in the same time. But I'm not sure yet what should be pacman's behavior in this case..
Seems like the pacman_remove function in src/pacman/remove.c may be too basic : it first checks if the target is a group, otherwise it considers it as a package. It can't be both in the same time.
But I'm not sure yet what should be pacman's behavior in this case..
When I first tried to install or remove a group, I automatically tried with -Sg and -Rg. Unfortunately -Sg has a different meaning, but IMHO this way would be cleaner (for me), and -Rg would solve your problem. However, user should know what he wants to do... ;-) Bye, ngaba ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On Tue, Sep 11, 2007 at 12:04:22PM +0200, Nagy Gabor wrote:
Seems like the pacman_remove function in src/pacman/remove.c may be too basic : it first checks if the target is a group, otherwise it considers it as a package. It can't be both in the same time.
But I'm not sure yet what should be pacman's behavior in this case..
When I first tried to install or remove a group, I automatically tried with -Sg and -Rg. Unfortunately -Sg has a different meaning, but IMHO this way would be cleaner (for me), and -Rg would solve your problem. However, user should know what he wants to do... ;-)
That's probably a good idea, I made a patch for it. pacman -R xorg will only try to remove the xorg package, pacman -Rg xorg will only try to remove the xorg group.
From f22c3fa84ec2e46f1ff8b0967cd73b077f6d3b72 Mon Sep 17 00:00:00 2001 From: Chantry Xavier <shiningxc@gmail.com> Date: Tue, 11 Sep 2007 15:22:16 +0200 Subject: [PATCH] pacman.c : add -Rg option for removing groups.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com> --- doc/pacman.8 | 3 +++ src/pacman/pacman.c | 1 + src/pacman/remove.c | 46 +++++++++++++++++++++++++++------------------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/doc/pacman.8 b/doc/pacman.8 index 4825f4a..2908f75 100644 --- a/doc/pacman.8 +++ b/doc/pacman.8 @@ -179,6 +179,9 @@ Instructs pacman to ignore file backup designations. Normally, when a file is removed from the system the database is checked to see if the file should be renamed with a .pacsave extension. .TP +.B \-g, --groups +Removes all the members for each package group specified. +.TP .B \-s, --recursive Remove each target specified including all dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index f62e588..e3073bc 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -93,6 +93,7 @@ static void usage(int op, char *myname) printf("%s:\n", str_opt); printf(_(" -c, --cascade remove packages and all packages that depend on them\n")); printf(_(" -d, --nodeps skip dependency checks\n")); + printf(_(" -g, --groups remove all members of a package group\n")); printf(_(" -k, --dbonly only remove database entry, do not remove files\n")); printf(_(" -n, --nosave remove configuration files as well\n")); printf(_(" -s, --recursive remove dependencies also (that won't break packages)\n")); diff --git a/src/pacman/remove.c b/src/pacman/remove.c index e60d3e8..cb71422 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -68,27 +68,35 @@ int pacman_remove(alpm_list_t *targets) return(1); } - /* If the target is a group, ask if its packages should be removed - * (the library can't remove groups for now) - */ - for(i = targets; i; i = alpm_list_next(i)) { - pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i)); - if(grp) { - int all; - const alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp); - - printf(_(":: group %s:\n"), alpm_grp_get_name(grp)); - list_display(" ", pkgnames); - all = yesno(_(" Remove whole content? [Y/n] ")); - - for(p = pkgnames; p; p = alpm_list_next(p)) { - char *pkg = alpm_list_getdata(p); - if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), pkg, (char *)alpm_list_getdata(i))) { - finaltargs = alpm_list_add(finaltargs, strdup(pkg)); + if(config->group) { + /* handle the targets as group since -g was specified */ + for(i = targets; i; i = alpm_list_next(i)) { + pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i)); + char *grpname = alpm_list_getdata(i); + if(grp) { + /* If the target is a group, ask if its packages should be removed + * (the library can't remove groups for now) + */ + int all; + const alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp); + + printf(_(":: group %s:\n"), alpm_grp_get_name(grp)); + list_display(" ", pkgnames); + all = yesno(_(" Remove whole content? [Y/n] ")); + + for(p = pkgnames; p; p = alpm_list_next(p)) { + char *pkg = alpm_list_getdata(p); + if(all || yesno(_(":: Remove %s from group %s? [Y/n] "), pkg, grpname)) { + finaltargs = alpm_list_add(finaltargs, strdup(pkg)); + } } + } else { + printf(_(":: group %s not found\n"), grpname); } - } else { - /* not a group, so add it to the final targets */ + } + } else { + /* handle the targets as actual packages */ + for(i = targets; i; i = alpm_list_next(i)) { finaltargs = alpm_list_add(finaltargs, strdup(alpm_list_getdata(i))); } } -- 1.5.3
That's probably a good idea, I made a patch for it. pacman -R xorg will only try to remove the xorg package, pacman -Rg xorg will only try to remove the xorg group. I must mention a backward: -if the user wants to remove one group and one package with one command, he cannot do that (however, this is a rare, and this is a _front-end_ problem)
In my opinion we should implement both -Sg and -Rg or neither of them. (-Sg now lists the group members, after this we could pick the question to the user: "Do you want to install the whole group?" [yes/no/quit] or we should rename the current -Sg to -Si or to -Sig) Bye, ngaba ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
Tuesday 11 of September 2007 16:22:05 Nagy Gabor napisał(a):
That's probably a good idea, I made a patch for it. pacman -R xorg will only try to remove the xorg package, pacman -Rg xorg will only try to remove the xorg group.
I must mention a backward: -if the user wants to remove one group and one package with one command, he cannot do that (however, this is a rare, and this is a _front-end_ problem)
In my opinion we should implement both -Sg and -Rg or neither of them. (-Sg now lists the group members, after this we could pick the question to the user: "Do you want to install the whole group?" [yes/no/quit] or we should rename the current -Sg to -Si or to -Sig)
Bye, ngaba
---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
_______________________________________________ pacman-dev mailing list pacman-dev@archlinux.org http://archlinux.org/mailman/listinfo/pacman-dev
I don't think we need -Sg. As long as during a pacman -S group_package pacman pus a big info (like currently it does with kde for example or gnome afaik and allows for choosing components) that should/would be ok. Because if you implement -Sg then doing pacman -S xorg will do what? Nothing? Or just install en empty group withtout pulling the actual group contents? Silly ;-) Just my 2 cents.. Cheers -- Mateusz Jędrasik <m.jedrasik@gmail.com> tel. +48(79)022-9393, +48(51)69-444-90 http://imachine.szklo.eu.org
On Tue, Sep 11, 2007 at 04:48:49PM +0200, Mateusz Jedrasik wrote:
Tuesday 11 of September 2007 16:22:05 Nagy Gabor napisał(a):
That's probably a good idea, I made a patch for it. pacman -R xorg will only try to remove the xorg package, pacman -Rg xorg will only try to remove the xorg group.
I must mention a backward: -if the user wants to remove one group and one package with one command, he cannot do that (however, this is a rare, and this is a _front-end_ problem)
In my opinion we should implement both -Sg and -Rg or neither of them. (-Sg now lists the group members, after this we could pick the question to the user: "Do you want to install the whole group?" [yes/no/quit] or we should rename the current -Sg to -Si or to -Sig)
I don't think we need -Sg. As long as during a pacman -S group_package pacman pus a big info (like currently it does with kde for example or gnome afaik and allows for choosing components) that should/would be ok. Because if you implement -Sg then doing pacman -S xorg will do what? Nothing? Or just install en empty group withtout pulling the actual group contents? Silly ;-)
Btw, I hope you all saw the hidden C in the subject. Otherwise, it looks like -S has exactly the opposite problem. It is only possible to install the xorg metapackage, not the xorg group, when both exist.
On 9/11/07, Xavier <shiningxc@gmail.com> wrote:
On Tue, Sep 11, 2007 at 04:48:49PM +0200, Mateusz Jedrasik wrote:
Tuesday 11 of September 2007 16:22:05 Nagy Gabor napisał(a):
That's probably a good idea, I made a patch for it. pacman -R xorg will only try to remove the xorg package, pacman -Rg xorg will only try to remove the xorg group.
I must mention a backward: -if the user wants to remove one group and one package with one command, he cannot do that (however, this is a rare, and this is a _front-end_ problem)
In my opinion we should implement both -Sg and -Rg or neither of them. (-Sg now lists the group members, after this we could pick the question to the user: "Do you want to install the whole group?" [yes/no/quit] or we should rename the current -Sg to -Si or to -Sig)
I don't think we need -Sg. As long as during a pacman -S group_package pacman pus a big info (like currently it does with kde for example or gnome afaik and allows for choosing components) that should/would be ok. Because if you implement -Sg then doing pacman -S xorg will do what? Nothing? Or just install en empty group withtout pulling the actual group contents? Silly ;-)
Btw, I hope you all saw the hidden C in the subject.
Otherwise, it looks like -S has exactly the opposite problem. It is only possible to install the xorg metapackage, not the xorg group, when both exist.
+1 on making -g work both for -S and -R. However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg This gives us a small issue when it comes to the current behavior of -Sg, however, that I have yet to figure out. Anyone know a good way to somehow keep the ability to list the contents of current groups and implement the above? Patches welcome. :) -Dan
2007/9/18, Dan McGee <dpmcgee@gmail.com>:
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg
This gives us a small issue when it comes to the current behavior of -Sg, however, that I have yet to figure out. Anyone know a good way to somehow keep the ability to list the contents of current groups and implement the above? Patches welcome. :)
from pacman -S --help: -l, --list <repo> view a list of packages in a repo I think -Slg [<repo>] would be nice syntax to show all groups in a repo. If repo is omitted - we get the same result as -Sg in pacman 3.0.x. BTW, -Sl lists packages from all repos when repo is not specified, so it should be: -l, --list [<repo>] view a list of packages in a repo (still not fixed in git tree) Sorry for not providing patches, I'm at work on windows box now. -- Roman Kyrylych (Роман Кирилич)
2007/9/18, Roman Kyrylych <roman.kyrylych@gmail.com>:
2007/9/18, Dan McGee <dpmcgee@gmail.com>:
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg
This gives us a small issue when it comes to the current behavior of -Sg, however, that I have yet to figure out. Anyone know a good way to somehow keep the ability to list the contents of current groups and implement the above? Patches welcome. :)
from pacman -S --help: -l, --list <repo> view a list of packages in a repo
I think -Slg [<repo>] would be nice syntax to show all groups in a repo. If repo is omitted - we get the same result as -Sg in pacman 3.0.x. BTW, -Sl lists packages from all repos when repo is not specified, so it should be: -l, --list [<repo>] view a list of packages in a repo (still not fixed in git tree)
Sorry for not providing patches, I'm at work on windows box now.
Xavier pointed out that -Sg used to work with group paramether, so here's a fixed proposal for -Slg: -Slg [<group>] behaves in the same way as old -Sg Why not introduce separate option? - I think that would be more confusing. -- Roman Kyrylych (Роман Кирилич)
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and package install would help to keep the code clean.
This gives us a small issue when it comes to the current behavior of -Sg, however, that I have yet to figure out. Anyone know a good way to somehow keep the ability to list the contents of current groups and implement the above? Patches welcome. :)
-Sig and -Sigg? Bye, ngaba ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On Tue, Sep 18, 2007 at 02:00:24PM +0200, Nagy Gabor wrote:
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and package install would help to keep the code clean.
Which part exactly is confusing?
This gives us a small issue when it comes to the current behavior of -Sg, however, that I have yet to figure out. Anyone know a good way to somehow keep the ability to list the contents of current groups and implement the above? Patches welcome. :)
-Sig and -Sigg?
I wonder if I don't prefer Romashka's proposal. -Slg could list all groups, and -Slg grp could list the contents of the grp group.
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and
On Tue, Sep 18, 2007 at 02:00:24PM +0200, Nagy Gabor wrote: package
install would help to keep the code clean.
Which part exactly is confusing?
I understand Dan's idea, but 1. I don't like "undeterministic" things, so if I (or crond ;-) do a "pacman -Sy favgrp", I want to do a group install independent from the current state of sync repos (today pacman may install a group, tomorrow pacman may install a package...) 2. Why should I do "pacman -S favgrp", when I can do "pacman -Sg favgrp"? 3. Personally, I didn't like the current method either (pacman -S group). But I must mention one advantage of Dan's method: "pacman -S group package" also works (but I never want to do this ;-) Bye, ngaba ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On Tue, Sep 18, 2007 at 02:24:24PM +0200, Nagy Gabor wrote:
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't think group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and
On Tue, Sep 18, 2007 at 02:00:24PM +0200, Nagy Gabor wrote: package
install would help to keep the code clean.
Which part exactly is confusing?
I understand Dan's idea, but 1. I don't like "undeterministic" things, so if I (or crond ;-) do a "pacman -Sy favgrp", I want to do a group install independent from the current state of sync repos (today pacman may install a group, tomorrow pacman may install a package...) 2. Why should I do "pacman -S favgrp", when I can do "pacman -Sg favgrp"? 3. Personally, I didn't like the current method either (pacman -S group).
Just so we're clear, it's only the backward compatibility of 1. that you don't like, right? 1. pacman -S grppkg: look for a package named grppkg, then group You would rather have : 1. pacman -S grppkg: look for a package named grppkg (and ignore a group if there is one) And 2. 3. 4. stay the same.
Idézés Xavier <shiningxc@gmail.com>:
On Tue, Sep 18, 2007 at 02:00:24PM +0200, Nagy Gabor wrote:
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't
group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and package install would help to keep the code clean.
Which part exactly is confusing?
I understand Dan's idea, but 1. I don't like "undeterministic" things, so if I (or crond ;-) do a "pacman -Sy favgrp", I want to do a group install independent from the current state of sync repos (today pacman may install a group, tomorrow pacman may install a
On Tue, Sep 18, 2007 at 02:24:24PM +0200, Nagy Gabor wrote: think package...)
2. Why should I do "pacman -S favgrp", when I can do "pacman -Sg favgrp"? 3. Personally, I didn't like the current method either (pacman -S group).
Just so we're clear, it's only the backward compatibility of 1. that you don't like, right? Of course, sorry, if I wasn't clear. +1 for -Sg and -Rg
---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On 9/18/07, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
Idézés Xavier <shiningxc@gmail.com>:
On Tue, Sep 18, 2007 at 02:00:24PM +0200, Nagy Gabor wrote:
+1 on making -g work both for -S and -R.
However, why don't we do the following for backwards compatability: 1. pacman -S grppkg: look for a package named grppkg, then group 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a package if there is one) 3. pacman -R grppkg: only remove a package named grppkg (I don't
group removal is used enough to warrant keeping backwards compat) 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and package install would help to keep the code clean.
Which part exactly is confusing?
I understand Dan's idea, but 1. I don't like "undeterministic" things, so if I (or crond ;-) do a "pacman -Sy favgrp", I want to do a group install independent from the current state of sync repos (today pacman may install a group, tomorrow pacman may install a
On Tue, Sep 18, 2007 at 02:24:24PM +0200, Nagy Gabor wrote: think package...)
2. Why should I do "pacman -S favgrp", when I can do "pacman -Sg favgrp"? 3. Personally, I didn't like the current method either (pacman -S group).
Just so we're clear, it's only the backward compatibility of 1. that you don't like, right? Of course, sorry, if I wasn't clear. +1 for -Sg and -Rg
I would probably be fine with this behavior, it is just the users you have to contend with. Maybe we could implement it the right way (deterministic behavior) and give a suggestion if no package was found to use '-Sg'? -Dan
2007/9/18, Dan McGee <dpmcgee@gmail.com>:
On 9/18/07, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
Idézés Xavier <shiningxc@gmail.com>:
On Tue, Sep 18, 2007 at 02:00:24PM +0200, Nagy Gabor wrote:
> +1 on making -g work both for -S and -R. > > However, why don't we do the following for backwards compatability: > 1. pacman -S grppkg: look for a package named grppkg, then group > 2. pacman -Sg grppkg: look for a group named grppkg (and ignore a > package if there is one) > 3. pacman -R grppkg: only remove a package named grppkg (I don't
> group removal is used enough to warrant keeping backwards compat) > 4. pacman -Rg grppkg: remove a group named grppkg IMHO that would be a bit confusing. And differentiate between group and package install would help to keep the code clean.
Which part exactly is confusing?
I understand Dan's idea, but 1. I don't like "undeterministic" things, so if I (or crond ;-) do a "pacman -Sy favgrp", I want to do a group install independent from the current state of sync repos (today pacman may install a group, tomorrow pacman may install a
On Tue, Sep 18, 2007 at 02:24:24PM +0200, Nagy Gabor wrote: think package...)
2. Why should I do "pacman -S favgrp", when I can do "pacman -Sg favgrp"? 3. Personally, I didn't like the current method either (pacman -S group).
Just so we're clear, it's only the backward compatibility of 1. that you don't like, right? Of course, sorry, if I wasn't clear. +1 for -Sg and -Rg
I would probably be fine with this behavior, it is just the users you have to contend with. Maybe we could implement it the right way (deterministic behavior) and give a suggestion if no package was found to use '-Sg'?
Seems OK to me. -- Roman Kyrylych (Роман Кирилич)
On Tue, Sep 18, 2007 at 08:45:21AM -0500, Dan McGee wrote:
I would probably be fine with this behavior, it is just the users you have to contend with. Maybe we could implement it the right way (deterministic behavior) and give a suggestion if no package was found to use '-Sg'?
I brought this topic in #archlinux earlier today, and this wasn't much appreciated indeed. - aep said it would be more confusing - wizzomafizzo was strongly against it : "it is simply extra complication for a problem that's never likely to happen and possible to easily undo if it does" - only Xilon said it would make more sense, but also that it would probably confuse users (but that users should RTFM anyway ;) But wizzo may be right. This situation likely won't happen very often, probably only on metapackage -> group transition. If the group appears before the metapackage is removed from the sync database, then you will just been unable to install the group temporarily, until the metapackage is removed from the sync database. So no big deal. (since you already have the metapackage, you probably don't need to install the group anyway) But after that, you also can't remove the metapackage, which might be a little more problematic. The options that Dan originally suggested would still work though. But in this case, I would prefer them more symetrical, that is : -S and -R look for packages first, and then fallback on groups. -Sg and -Rg only look for groups. Secondly, I began working a bit on this, and I have other questions. 1) -S looks for packages first, then fallbacks on groups. But there is actually a second fallback if group isn't found : providers. But I already saw an user once on IRC who was confused by this behavior : "why the hell isn't pacman installing what I asked it to?" But personally, I think it's a neat feature. eg you can "pacman -S cdrtools" because you only remember that name, and don't know it has been replaced by cdrkit. And pacman will automatically pull cdrkit, since cdrtools doesn't exist but is providen by cdrkit. However, this second fallback stored me a bit when working on the code, so I'm asking just in case :) 2) What should pacman do when one of the targets is not found? Currently, it just fails. This might be the best behavior. But there is also a second option, to try installing / removing what it can find. For example, "pacman -S / -R foo xterm bar" would still install / remove xterm, even though foo and bar don't exist. 3) I was testing a -R option that only removed package, not group. But doing pacman -R xterm with it caused : Erreur: could not remove entry 'xterm' from cache That's because the cache was only loaded by alpm_db_readgrp, which isn't used anymore by this -R option, since it doesn't deal with group. But remove_commit still tries to remove the package from the cache in any cases, with _alpm_db_remove_pkgfromcache. This reminds me of another issue I noticed with the cache a while ago, that I didn't know how to fix either : http://www.archlinux.org/pipermail/pacman-dev/2007-July/008693.html
The options that Dan originally suggested would still work though. But in this case, I would prefer them more symetrical, that is :
-S and -R look for packages first, and then fallback on groups. -Sg and -Rg only look for groups.
Yes, that assymetric -R and -S was even worse ;-) But I still prefer the deterministic way.
Secondly, I began working a bit on this, and I have other questions.
1) -S looks for packages first, then fallbacks on groups. But there is actually a second fallback if group isn't found : providers. But I already saw an user once on IRC who was confused by this behavior : "why the hell isn't pacman installing what I asked it to?"
Yes, I don't keep this behaviour in my mind neither. This is rarely used imho, because if I know what I want to install then I use the correct package name; and -Ss also lists package names only.
But personally, I think it's a neat feature. eg you can "pacman -S cdrtools" because you only remember that name, and don't know it has been replaced by cdrkit. And pacman will automatically pull cdrkit, since cdrtools doesn't exist but is providen by cdrkit.
I would prefer a confirmation message like "cdrtools package is not found. However cdrkit package provides it. Do you want to install cdrkit? [Y/n]" But providers can also be used in a symmetric way: As I know, in frugalware repos there is no package named mta, but there are packages which provide mta. So user may want to do a "pacman -S mta" and pacman will choose a provider (~undeterministic). mta provision was introduced as a depend satisfier, so this can be helpful, if user did a "pacman -U darcs...tar.gz" and he got "unsatisfied dependencies: mta", and he want to resolve this by hand (using your famous --asdeps option ;-). During I wrote this paragraph, I started to like the category idea: http://bugs.archlinux.org/task/7132 I start to understand the differences between groups and categories: Groups is designed to install a set of packages, categories is desinged to install few packages from that. So category may contain conflicting packages (imagine mta category here). However, I still prefer using groups as categories. But I can't imagine how we could do "pacman -Sg mta" with the current fronted: it's annoying that if the group has 100 members, I must answer to 100 questions, if I don't want to install the whole group/category. This method would be much better (but harder to implement): media group has the following members: 1-xmms, 2-audacious, 3-bmp, 4-moc ... Which packages do you want to install? 2,4 [or I could answer A (all)]. Bye, ngaba ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On 9/21/07, Nagy Gabor <ngaba@bibl.u-szeged.hu> wrote:
During I wrote this paragraph, I started to like the category idea: http://bugs.archlinux.org/task/7132 I start to understand the differences between groups and categories: Groups is designed to install a set of packages, categories is desinged to install few packages from that. So category may contain conflicting packages (imagine mta category here). However, I still prefer using groups as categories.
Categories are very nice and I'd really like to see them implemented. Categories should _not_ be installable, that, in my mind, is not the purpose of categories. Their purpose is to make searching easier and more organised. Currently it's very hard to search for something without knowing the name. If you want some sort of graphics manipulation program, then you won't necessarily find all of them since you depend on the description or a descriptive name (which most packages won't have). If we had categories we could just skim through the "graphics" (or whatever) category and see all of them there.
But I can't imagine how we could do "pacman -Sg mta" with the current fronted: it's annoying that if the group has 100 members, I must answer to 100 questions, if I don't want to install the whole group/category. This method would be much better (but harder to implement): media group has the following members: 1-xmms, 2-audacious, 3-bmp, 4-moc ... Which packages do you want to install? 2,4 [or I could answer A (all)].
Yes, I just noticed that yesterday when we were having the discussion about pacman -Sg, etc, on IRC. It's very annoying for large groups, so pacman should really be more flexible in the ability to exit. Of course you can Control-C, but that's not "clean" (yes, I know that under the hood pacman cleans up nicely). When asking whether to install all packages in a group, it should have the option to abort. Also when asking for individual packages it could have to option to break out, or skip the rest of the packages and just download what you have selected so far. I guess this should be posted as a feature request rather than on the ML though :)
Categories are very nice and I'd really like to see them implemented. Categories should _not_ be installable, that, in my mind, is not the purpose of categories. Their purpose is to make searching easier and more organised. Currently it's very hard to search for something without knowing the name. If you want some sort of graphics manipulation program, then you won't necessarily find all of them since you depend on the description or a descriptive name (which most packages won't have). If we had categories we could just skim through the "graphics" (or whatever) category and see all of them there. Well, these informations can be listed in PKGDESC field -- in a standardized way (optimized for -Ss search, too). But I still think that group is enough to do that. The (current!) -Sg would feed your needs, if that could also show pkginfos (with an extra -i option for example <- +1 vote for this). So I can't see what should be coded to libalpm. So I ask again ;-): What's wrong with the "graphics" group? An extra "feature": you can also install/remove the "graphics" _category_. Packages can belong to multiple groups (==categories). What's the problem?: There are some not-so-expressive group names (like xfce4-goodies), but who cares... Bye, ngaba
---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
On Fri, Sep 21, 2007 at 09:51:42AM +0200, Nagy Gabor wrote:
The options that Dan originally suggested would still work though. But in this case, I would prefer them more symetrical, that is :
-S and -R look for packages first, and then fallback on groups. -Sg and -Rg only look for groups.
Yes, that assymetric -R and -S was even worse ;-) But I still prefer the deterministic way.
But if 90 % of the users would find this confusing, well...
Secondly, I began working a bit on this, and I have other questions.
1) -S looks for packages first, then fallbacks on groups. But there is actually a second fallback if group isn't found : providers. But I already saw an user once on IRC who was confused by this behavior : "why the hell isn't pacman installing what I asked it to?"
Yes, I don't keep this behaviour in my mind neither. This is rarely used imho, because if I know what I want to install then I use the correct package name; and -Ss also lists package names only.
-Ss also search for providers. Try pacman -Ss cdrtools , and then pacman -Ss ^cdrtools$ .
But personally, I think it's a neat feature. eg you can "pacman -S cdrtools" because you only remember that name, and don't know it has been replaced by cdrkit. And pacman will automatically pull cdrkit, since cdrtools doesn't exist but is providen by cdrkit.
I would prefer a confirmation message like "cdrtools package is not found. However cdrkit package provides it. Do you want to install cdrkit? [Y/n]"
But providers can also be used in a symmetric way: As I know, in frugalware repos there is no package named mta, but there are packages which provide mta. So user may want to do a "pacman -S mta" and pacman will choose a provider (~undeterministic). mta provision was introduced as a depend satisfier, so this can be helpful, if user did a "pacman -U darcs...tar.gz" and he got "unsatisfied dependencies: mta", and he want to resolve this by hand (using your famous --asdeps option ;-).
--asdeps is from Dan btw :) : http://projects.archlinux.org/git/?p=pacman.git;a=commit;h=a1e57cbec8209b64e... About providers, pacman choosing the first provider is really a problem. See the recent bug report : http://bugs.archlinux.org/task/8075
During I wrote this paragraph, I started to like the category idea: http://bugs.archlinux.org/task/7132 I start to understand the differences between groups and categories: Groups is designed to install a set of packages, categories is desinged to install few packages from that. So category may contain conflicting packages (imagine mta category here). However, I still prefer using groups as categories. But I can't imagine how we could do "pacman -Sg mta" with the current fronted: it's annoying that if the group has 100 members, I must answer to 100 questions, if I don't want to install the whole group/category. This method would be much better (but harder to implement): media group has the following members: 1-xmms, 2-audacious, 3-bmp, 4-moc ... Which packages do you want to install? 2,4 [or I could answer A (all)].
That would help solving the multive providers problem as well.
3) I was testing a -R option that only removed package, not group. But doing pacman -R xterm with it caused : Erreur: could not remove entry 'xterm' from cache
That's because the cache was only loaded by alpm_db_readgrp, which isn't used anymore by this -R option, since it doesn't deal with group. But remove_commit still tries to remove the package from the cache in any cases, with _alpm_db_remove_pkgfromcache. This reminds me of another issue I noticed with the cache a while ago, that I didn't know how to fix either : http://www.archlinux.org/pipermail/pacman-dev/2007-July/008693.html
Yes, we should check where we want to load/reload pkgcache to avoid these. Bye, ngaba PS: I don't like group cache ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
Another possibility I thought of was simply keeping "pacman -S" for groups, but with the ability to explicitly "pacman -S group/gnome". That way there won't be a problem if a package conflicts with a group. On the other hand this is very odd behaviour, since it is not semantically correct and it appears that the group is a repository. I don't think there's really an ideal solution to the problem (if there even is one, as wizzomafizzo pointed out). Adding the -g option might be unnecessary, and installing groups isn't a very regular activity. So far I don't think anyone has complained about the functionality of pacman -S, apart from this one instance where xorg was conflicting. And even so, the xorg group is in testing.
On Fri, Sep 21, 2007 at 06:03:09PM +0800, Xilon wrote:
Another possibility I thought of was simply keeping "pacman -S" for groups, but with the ability to explicitly "pacman -S group/gnome". That way there won't be a problem if a package conflicts with a group. On the other hand this is very odd behaviour, since it is not semantically correct and it appears that the group is a repository.
Indeed, that would be a bit odd :)
I don't think there's really an ideal solution to the problem (if there even is one, as wizzomafizzo pointed out). Adding the -g option might be unnecessary, and installing groups isn't a very regular activity. So far I don't think anyone has complained about the functionality of pacman -S, apart from this one instance where xorg was conflicting. And even so, the xorg group is in testing.
Note that there were two differents proposals : 1) -S and -R look for packages first, and then fallback on groups. -Sg and -Rg only look for groups. 2) -S and -R only look for packages -Sg and -Rg only look for groups. The second idea was mostly defended by Nagy. I think I would also prefer this way, but I think that's the only one that could be problematic for users. What would be the problems choosing the more conservative 1) way? -S and -R will still behave exactly the same in the normal case. In the particular case when there is a package and a group with the same name, use -S / -R for installing / removing the package , and -Sg / -Rg for installing / removing the group. Actually, you were right mentioning the pacman -S <repo>/<package> syntax, it's indeed the same problem. In most cases, it isn't needed. But when there is an ambiguity, pacman offers a way to solve it. But having exactly the same syntax for group and repo is probably not a good idea. Maybe we need to find a similar but different syntax then ? That way, we won't need to add a new Rg option, and to replace the existing Sg by something else (like Slg). But imo, doing this is a not a big problem.
On 9/21/07, Xavier <shiningxc@gmail.com> wrote:
Note that there were two differents proposals : 1) -S and -R look for packages first, and then fallback on groups. -Sg and -Rg only look for groups.
2) -S and -R only look for packages -Sg and -Rg only look for groups.
The second proposal appears, from an outside view, to be an unfair restriction. We'd be removing functionality that currently works, and I don't know if I like that. Sure it might clean up the code and all, BUT perfect code for a crippled app is never a good idea. I'd like to put my support behind proposal #1.
On 9/21/07, Xavier <shiningxc@gmail.com> wrote:
Note that there were two differents proposals : 1) -S and -R look for packages first, and then fallback on groups. -Sg and -Rg only look for groups.
2) -S and -R only look for packages -Sg and -Rg only look for groups.
The second proposal appears, from an outside view, to be an unfair restriction. We'd be removing functionality that currently works, and I don't know if I like that.
Sure it might clean up the code and all, BUT perfect code for a crippled app is never a good idea.
Clean-up also implies (slight) speed-up. This is really slight now ;-), because -S also can install provider as Xavier mentioned (<- I don't like this, this is also assymetric: -R doesn't deal with it.) Let me explain: user does a "pacman -S xorfg" (<-typo) -pacman search for packages (fast) with no success. -pacman search for groups (slow!, pacman must read the desc files in sync repos) with no success -pacman search for providers (slow!, pacman must read the depend files too). -pacman stops with an error message So in this special case, if pacman would search for packages only, that would be ~300% speed-up (in my machine). To tell the truth, this is not a reason for me;-) Personally, I find 1.) much more confusing (in the first time, it took ~15 minutes me to figure out how to install a group, pacman -Sh mentions package everywhere, in the manual I still cannot find this information); so my vote: 2.) Bye, ngaba ---------------------------------------------------- SZTE Egyetemi Könyvtár - http://www.bibl.u-szeged.hu This mail sent through IMP: http://horde.org/imp/
participants (9)
-
Aaron Griffin
-
Andrew Fyfe
-
Dan McGee
-
Mateusz Jedrasik
-
Nagy Gabor
-
Roman Kyrylych
-
Sergej Pupykin
-
Xavier
-
Xilon