From 13a1d5883c9aa81ee10d61cbe4c2f2223dad9a50 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 14 Feb 2012 10:11:43 -0600 Subject: scripts: unset CDPATH if cd is used This wonderful/awful little bash shell variable wrecks havoc on `cd` calls in shell scripts. Unset CDPATH in makepkg where we use `cd` quite heavily. In pacman-optimize, we can move the change directory logic into the bsdtar call so we are left with no usages of `cd` in the script. Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 2 ++ scripts/pacman-optimize.sh.in | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80bb1c94..5e8687e7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -36,6 +36,8 @@ export TEXTDOMAINDIR='@localedir@' # file -i does not work on Mac OSX unless legacy mode is set export COMMAND_MODE='legacy' +# Ensure CDPATH doesn't screw with our cd calls +unset CDPATH myver='@PACKAGE_VERSION@' confdir='@sysconfdir@' diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 47d8814a..8a4e7224 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -122,8 +122,7 @@ 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 "$workdir/pacman-db.tar.gz" ./ +bsdtar -czf "$workdir/pacman-db.tar.gz" -C "$dbroot" ./ if (( $? )); then rm -rf "$workdir" die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot" -- cgit v1.2.3-70-g09d2 From 6c78f0d56007ae5bbbaf9f15f6399e6e2967dd76 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 14 Feb 2012 12:12:24 -0600 Subject: Update SIGPIPE signal handler comment Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 414d5d76..ee95e8a7 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -436,8 +436,8 @@ static int curl_download_internal(struct dload_payload *payload, curl_easy_setopt(curl, CURLOPT_WRITEDATA, localf); - /* ignore any SIGPIPE signals- these may occur if our FTP socket dies or - * something along those lines. Store the old signal handler first. */ + /* Ignore any SIGPIPE signals. With libcurl, these shouldn't be happening, + * but better safe than sorry. Store the old signal handler first. */ mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe); mask_signal(SIGINT, &inthandler, &orig_sig_int); -- cgit v1.2.3-70-g09d2 From edd81f3e8b505be2f7c7a18d3c28956b82264c45 Mon Sep 17 00:00:00 2001 From: Christoph Vigano Date: Tue, 14 Feb 2012 21:31:04 +0100 Subject: makepkg: fix syntax error in remove_deps This fixes a problem that occurs if you tell makepkg to remove installed dependencies (just to be sure) but there are none. As the $ was missing in front of deplist, the check never happened and 'pacman -Rn' was called which obviously failed. Dan: later reported as FS#28448. Signed-off-by: Christoph Vigano Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 5e8687e7..9766c8c6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -521,7 +521,7 @@ remove_deps() { local deplist deplist=($(grep -xvFf <(printf "%s\n" "${original_pkglist[@]}") \ <(printf "%s\n" "${current_pkglist[@]}") || true)) - if [[ -z deplist ]]; then + if [[ -z $deplist ]]; then return fi -- cgit v1.2.3-70-g09d2 From 9a1ff474f1fe03e8bfdaf81ffc9a4881a44baea9 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 15 Feb 2012 15:16:23 -0600 Subject: Revert "Enable recursive/needed sync on SyncFirst" This reverts commit 09034520325efcc2e684f05fa7a99c02bad1f5be. Tests affected by this revert have been adjusted; additionally a few EXIST tests have been removed where there is already a VERSION test doing the job for us. Signed-off-by: Dan McGee --- src/pacman/sync.c | 2 -- test/pacman/tests/sync302.py | 8 ++++---- test/pacman/tests/sync303.py | 3 --- test/pacman/tests/sync305.py | 3 --- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 4f10e6b9..fcc887ae 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -963,8 +963,6 @@ int pacman_sync(alpm_list_t *targets) FREELIST(targs); targs = packages; config->flags = 0; - config->flags |= ALPM_TRANS_FLAG_RECURSE; - config->flags |= ALPM_TRANS_FLAG_NEEDED; config->op_s_upgrade = 0; } else { FREELIST(packages); diff --git a/test/pacman/tests/sync302.py b/test/pacman/tests/sync302.py index b44aaed4..78e45c33 100644 --- a/test/pacman/tests/sync302.py +++ b/test/pacman/tests/sync302.py @@ -38,12 +38,12 @@ self.option["SyncFirst"] = ["pacman"] self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_EXIST=pacman") self.addrule("PKG_VERSION=pacman|1.0-2") self.addrule("PKG_EXIST=glibc") -self.addrule("PKG_VERSION=glibc|2.15-1") self.addrule("PKG_EXIST=curl") -self.addrule("PKG_VERSION=curl|7.22-1") self.addrule("PKG_EXIST=libarchive") -self.addrule("PKG_VERSION=libarchive|2.8.5-1") +# TODO: when SyncFirst recursive comes back, re-enable these +#self.addrule("PKG_VERSION=glibc|2.15-1") +#self.addrule("PKG_VERSION=curl|7.22-1") +#self.addrule("PKG_VERSION=libarchive|2.8.5-1") self.addrule("PKG_EXIST=zlib") diff --git a/test/pacman/tests/sync303.py b/test/pacman/tests/sync303.py index b717dd2c..9d7bab58 100644 --- a/test/pacman/tests/sync303.py +++ b/test/pacman/tests/sync303.py @@ -29,10 +29,7 @@ self.option["SyncFirst"] = ["pacman"] self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_EXIST=pacman") self.addrule("PKG_VERSION=pacman|1.0-2") self.addrule("PKG_EXIST=glibc-awesome") self.addrule("PKG_VERSION=glibc-awesome|2.13-2") self.addrule("PKG_EXIST=zlib") - -self.expectfailure = True diff --git a/test/pacman/tests/sync305.py b/test/pacman/tests/sync305.py index 24fcee48..62005b58 100644 --- a/test/pacman/tests/sync305.py +++ b/test/pacman/tests/sync305.py @@ -61,7 +61,4 @@ self.option["SyncFirst"] = ["pacman"] self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_EXIST=pacman") self.addrule("PKG_VERSION=pacman|4.0.1-2") - -self.expectfailure = True -- cgit v1.2.3-70-g09d2 From 85712814cdbfa301e5827fafd6bfb8ac0886079c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 15 Feb 2012 15:40:01 -0600 Subject: Revert "Add -S --recursive operation" This reverts commit f3fa77bcf1d792971c314f8c0de255866e89f3f3 along with making other necessary changes to fully back this (mis)feature out until we can do it correctly. The quick summary here is this was not implemented correctly; provides are not fully taken into account in this logic, and making that happen exposes a lot of other flaws in this code that are covered up later on in the dependency resolving process by several other pieces of convoluted and conditional logic. Tests have been adjusted accordingly. Some test EXISTS conditions have been removed as we already know the package is installed locally, and we also are checking the VERSION condition anyway. With these two related revert commits, we do have some changes in test pass/fail results: * upgrade078.py: does not pass, this is due to --recursive getting removed for -U/-S operations after this commit. * sync302.py: the version checks have been disabled, so this test continues to pass but has been scaled back in scope. * sync303.py: now passes, was failing before. * sync304.py: still failing, was failing before. * sync305.py: now passes, was failing before. * sync306.py: still passes, was passing before. Signed-off-by: Dan McGee --- doc/pacman.8.txt | 7 ------- lib/libalpm/deps.c | 29 ----------------------------- src/pacman/conf.h | 1 - src/pacman/pacman.c | 8 +------- test/pacman/tests/sync304.py | 2 -- test/pacman/tests/sync306.py | 1 - test/pacman/tests/upgrade078.py | 17 ++++++++--------- 7 files changed, 9 insertions(+), 56 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 275f8ac0..1ec5e7c3 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -411,13 +411,6 @@ system upgrade and install/upgrade the foo package in the same operation. *\--needed*:: Do not reinstall the targets that are already up to date. -*\--recursive*:: - Recursively reinstall all dependencies of the targets. This forces upgrades - or reinstalls of all dependencies without requiring explicit version - requirements. This is most useful in combination with the '\--needed' flag, - which will induce a deep dependency upgrade without any unnecessary - reinstalls. - Handling Config Files[[HCF]] ---------------------------- diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 89f6d691..0c0a054e 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -723,12 +723,6 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs, return 0; } - if(handle->trans->flags & ALPM_TRANS_FLAG_RECURSE) { - /* removing local packages from the equation causes the entire dep chain to - * get pulled for each target- e.g., pactree -u output */ - localpkgs = NULL; - } - /* Create a copy of the packages list, so that it can be restored on error */ packages_copy = alpm_list_copy(*packages); @@ -781,29 +775,6 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs, alpm_list_free(deps); } - if(handle->trans->flags & ALPM_TRANS_FLAG_NEEDED) { - /* remove any deps that were pulled that match installed version */ - /* odd loop syntax so we can modify the list as we iterate */ - i = *packages; - while(i) { - alpm_pkg_t *tpkg = i->data; - alpm_pkg_t *local = _alpm_db_get_pkgfromcache( - handle->db_local, tpkg->name); - if(local && _alpm_pkg_compare_versions(tpkg, local) == 0) { - /* with the NEEDED flag, packages up to date are not reinstalled */ - _alpm_log(handle, ALPM_LOG_DEBUG, - "not adding dep %s-%s as it is not needed, same version\n", - local->name, local->version); - j = i; - i = i->next; - *packages = alpm_list_remove_item(*packages, j); - free(j); - } else { - i = i->next; - } - } - } - if(ret != 0) { alpm_list_free(*packages); *packages = packages_copy; diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 9e14925a..42f25298 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -127,7 +127,6 @@ enum { OP_ARCH, OP_PRINTFORMAT, OP_GPGDIR, - OP_RECURSIVE, OP_DBONLY }; diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 381e0b71..c0c3bb8b 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -135,7 +135,6 @@ static void usage(int op, const char * const myname) } else if(op == PM_OP_UPGRADE) { printf("%s: %s {-U --upgrade} [%s] <%s>\n", str_usg, myname, str_opt, str_file); addlist(_(" --needed do not reinstall up to date packages\n")); - addlist(_(" --recursive reinstall all dependencies of target packages\n")); printf("%s:\n", str_opt); } else if(op == PM_OP_QUERY) { printf("%s: %s {-Q --query} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg); @@ -167,7 +166,6 @@ static void usage(int op, const char * const myname) addlist(_(" -w, --downloadonly download packages but do not install/upgrade anything\n")); addlist(_(" -y, --refresh download fresh package databases from the server\n")); addlist(_(" --needed do not reinstall up to date packages\n")); - addlist(_(" --recursive reinstall all dependencies of target packages\n")); } else if(op == PM_OP_DATABASE) { printf("%s: %s {-D --database} <%s> <%s>\n", str_usg, myname, str_opt, str_pkg); printf("%s:\n", str_opt); @@ -512,9 +510,6 @@ static int parsearg_remove(int opt) case 'c': config->flags |= ALPM_TRANS_FLAG_CASCADE; break; case 'n': config->flags |= ALPM_TRANS_FLAG_NOSAVE; break; case 's': - case OP_RECURSIVE: - /* 's' is the legacy flag here, but since recursive is used in -S without - * a shortopt, we need to do funky tricks */ if(config->flags & ALPM_TRANS_FLAG_RECURSE) { config->flags |= ALPM_TRANS_FLAG_RECURSEALL; } else { @@ -537,7 +532,6 @@ static int parsearg_upgrade(int opt) case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break; case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break; case OP_NEEDED: config->flags |= ALPM_TRANS_FLAG_NEEDED; break; - case OP_RECURSIVE: config->flags |= ALPM_TRANS_FLAG_RECURSE; break; case OP_IGNORE: parsearg_util_addlist(&(config->ignorepkg)); break; @@ -612,6 +606,7 @@ static int parseargs(int argc, char *argv[]) {"print", no_argument, 0, 'p'}, {"quiet", no_argument, 0, 'q'}, {"root", required_argument, 0, 'r'}, + {"recursive", no_argument, 0, 's'}, {"search", no_argument, 0, 's'}, {"unrequired", no_argument, 0, 't'}, {"upgrades", no_argument, 0, 'u'}, @@ -637,7 +632,6 @@ static int parseargs(int argc, char *argv[]) {"arch", required_argument, 0, OP_ARCH}, {"print-format", required_argument, 0, OP_PRINTFORMAT}, {"gpgdir", required_argument, 0, OP_GPGDIR}, - {"recursive", no_argument, 0, OP_RECURSIVE}, {"dbonly", no_argument, 0, OP_DBONLY}, {0, 0, 0, 0} }; diff --git a/test/pacman/tests/sync304.py b/test/pacman/tests/sync304.py index 4ac1a015..18058c99 100644 --- a/test/pacman/tests/sync304.py +++ b/test/pacman/tests/sync304.py @@ -19,9 +19,7 @@ self.option["SyncFirst"] = ["pacman"] self.args = "-Su" self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_EXIST=pacman") self.addrule("PKG_VERSION=pacman|4.0.1-1") -self.addrule("PKG_EXIST=pyalpm") self.addrule("PKG_VERSION=pyalpm|2-1") self.expectfailure = True diff --git a/test/pacman/tests/sync306.py b/test/pacman/tests/sync306.py index ca7a547e..c7401d07 100644 --- a/test/pacman/tests/sync306.py +++ b/test/pacman/tests/sync306.py @@ -59,5 +59,4 @@ self.addpkg2db("local", lp7) self.args = "-S pacman" self.addrule("PACMAN_RETCODE=0") -self.addrule("PKG_EXIST=pacman") self.addrule("PKG_VERSION=pacman|4.0.1-2") diff --git a/test/pacman/tests/upgrade078.py b/test/pacman/tests/upgrade078.py index 718d5871..8ef32456 100644 --- a/test/pacman/tests/upgrade078.py +++ b/test/pacman/tests/upgrade078.py @@ -20,15 +20,15 @@ expat_lpkg = pmpkg("expat", "2.0.1-6") self.addpkg2db("local", expat_lpkg) # Sync db -curl_sync = pmpkg("curl", "7.21.7-1") -self.addpkg2db("sync", curl_sync) +perl_sync = pmpkg("perl", "5.14.1-3") +perl_sync.depends = ["glibc"] +self.addpkg2db("sync", perl_sync) glibc_sync = pmpkg("glibc", "2.1.4-4") self.addpkg2db("sync", glibc_sync) -perl_sync = pmpkg("perl", "5.14.1-3") -perl_sync.depends = ["glibc"] -self.addpkg2db("sync", perl_sync) +curl_sync = pmpkg("curl", "7.21.7-1") +self.addpkg2db("sync", curl_sync) expat_sync = pmpkg("expat", "2.0.1-6") self.addpkg2db("sync", expat_sync) @@ -46,11 +46,10 @@ self.addrule("PKG_DEPENDS=git|perl") self.addrule("PKG_DEPENDS=perl|glibc") self.addrule("PKG_EXIST=git") self.addrule("PKG_VERSION=git|1.7.6-1") -self.addrule("PKG_EXIST=curl") self.addrule("PKG_VERSION=curl|7.21.7-1") -self.addrule("PKG_EXIST=glibc") self.addrule("PKG_VERSION=glibc|2.1.4-4") -self.addrule("PKG_EXIST=perl") self.addrule("PKG_VERSION=perl|5.14.1-3") -self.addrule("PKG_EXIST=expat") self.addrule("PKG_VERSION=expat|2.0.1-6") + +# --recursive operation was removed for now +self.expectfailure = True -- cgit v1.2.3-70-g09d2 From 242006933d31c88b844f8f8d0c2f0806763cc51f Mon Sep 17 00:00:00 2001 From: Eric Bélanger Date: Thu, 16 Feb 2012 00:56:29 -0500 Subject: pacsysclean: Fix script description and accept -o option without hyphen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close FS#28434 Signed-off-by: Eric Bélanger Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- contrib/pacsysclean.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/pacsysclean.in b/contrib/pacsysclean.in index c87082e0..a4accd56 100755 --- a/contrib/pacsysclean.in +++ b/contrib/pacsysclean.in @@ -1,11 +1,11 @@ #!/bin/bash -# pacsysclean - Sort installed packages by decreasing installed size. Useful for system clean-up. +# pacsysclean - Sort installed packages by increasing installed size. Useful for system clean-up. PACMAN_OPTS= usage() { - echo "pacsysclean - Sort installed packages by decreasing installed size." + echo "pacsysclean - Sort installed packages by increasing installed size." echo echo "Usage: pacsysclean [options]" echo @@ -26,6 +26,9 @@ fi IFS=$'\n' name="^Name.*: (.*)$" size="^Installed Size.*: (.*) KiB$" + +[[ $PACMAN_OPTS != -* ]] && PACMAN_OPTS="-$PACMAN_OPTS" + for line in $(LANG=C pacman -Qi $PACMAN_OPTS); do if [[ $line =~ $name ]]; then printf "%s\t" ${BASH_REMATCH[1]} -- cgit v1.2.3-70-g09d2 From ca4142714137b16feabac09c4cda86b0a75036f8 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 15 Feb 2012 22:50:51 -0500 Subject: parseopts: normalize options into an array Modify parse_options logic to fill an array instead of printing parsed options. Avoid eval like the plague. Because it is the plague. Fixes bugs such as FS#28445. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- scripts/library/parse_options.sh | 32 +++++++++++--------------------- scripts/makepkg.sh.in | 6 +++--- scripts/pacman-key.sh.in | 6 +++--- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/scripts/library/parse_options.sh b/scripts/library/parse_options.sh index 48fd42cd..39038de6 100644 --- a/scripts/library/parse_options.sh +++ b/scripts/library/parse_options.sh @@ -23,17 +23,15 @@ parse_options() { [[ ${match} = ${1:2}:: && -n $2 && ${2:0:1} != "-" ]] && needsargument=1 if (( ! needsargument )); then - printf ' %s' "$1" + OPTRET+=("$1") else if [[ -n $2 ]]; then - printf ' %s ' "$1" + OPTRET+=("$1" "$2") shift - printf "'%q" "$1" while [[ -n $2 && ${2:0:1} != "-" ]]; do shift - printf " %q" "$1" + OPTRET+=("$1") done - printf "'" else printf "@SCRIPTNAME@: $(gettext "option %s requires an argument\n")" "'$1'" >&2 ret=1 @@ -57,26 +55,22 @@ parse_options() { ( -n ${1:$i+1} || ( -n $2 && ${2:0:1} != "-" ) ) ]] && needsargument=1 if (( ! needsargument )); then - printf ' -%s' "${1:i:1}" + OPTRET+=("-${1:i:1}") else if [[ -n ${1:$i+1} ]]; then - printf ' -%s ' "${1:i:1}" - printf "'%q" "${1:$i+1}" + OPTRET+=("-${1:i:1}" "${1:i+1}") while [[ -n $2 && ${2:0:1} != "-" ]]; do shift - printf " %q" "$1" + OPTRET+=("$1") done - printf "'" else if [[ -n $2 ]]; then - printf ' -%s ' "${1:i:1}" + OPTRET+=("-${1:i:1}" "$2") shift - printf "'%q" "$1" while [[ -n $2 && ${2:0:1} != "-" ]]; do shift - printf " %q" "$1" + OPTRET+=("$1") done - printf "'" else printf "@SCRIPTNAME@: $(gettext "option %s requires an argument\n")" "'-${1:i:1}'" >&2 @@ -91,15 +85,11 @@ parse_options() { fi done else - unused_options="${unused_options} '$1'" + unused_options+=("$1") fi shift done - printf " --" - [[ $unused_options ]] && printf ' %s' "${unused_options[@]}" - [[ $1 ]] && printf " '%s'" "$@" - printf "\n" - + OPTRET+=('--' "${unused_options[@]}") return $ret -} \ No newline at end of file +} diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 9766c8c6..805c31a9 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1906,11 +1906,11 @@ OPT_LONG+=",version,config:" # Pacman Options OPT_LONG+=",noconfirm,noprogressbar" -if ! OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@")"; then +if ! parse_options $OPT_SHORT $OPT_LONG "$@"; then echo; usage; exit 1 # E_INVALID_OPTION; fi -eval set -- "$OPT_TEMP" -unset OPT_SHORT OPT_LONG OPT_TEMP +set -- "${OPTRET[@]}" +unset OPT_SHORT OPT_LONG OPTRET while true; do case "$1" in diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in index 45ece51b..4b678041 100644 --- a/scripts/pacman-key.sh.in +++ b/scripts/pacman-key.sh.in @@ -504,11 +504,11 @@ OPT_LONG="add::,config:,delete:,edit-key:,export::,finger::,gpgdir:" OPT_LONG+=",help,import:,import-trustdb:,init,keyserver:,list-keys::,list-sigs::" OPT_LONG+=",lsign-key:,populate::,recv-keys:,refresh-keys::,updatedb" OPT_LONG+=",verify:,version" -if ! OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@")"; then +if ! parse_options $OPT_SHORT $OPT_LONG "$@"; then echo; usage; exit 1 # E_INVALID_OPTION; fi -eval set -- "$OPT_TEMP" -unset OPT_SHORT OPT_LONG OPT_TEMP +set -- "${OPTRET[@]}" +unset OPT_SHORT OPT_LONG OPTRET if [[ $1 == "--" ]]; then usage; -- cgit v1.2.3-70-g09d2 From 4899b5bd864919830fe4ce5786d37a00ab5a0da3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 19 Feb 2012 23:04:12 -0600 Subject: diskspace: ensure we match only full path components If one had a mountpoint at '/e' (don't ask), a file being installed to '/etc' would map to it incorrectly. Ensure we do more than just prefix matching on paths by doing some more sanity checks once the simple strncmp() call succeeds. Signed-off-by: Dan McGee --- lib/libalpm/diskspace.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index d0f52a63..45908b22 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -179,8 +179,20 @@ static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points, for(mp = mount_points; mp != NULL; mp = mp->next) { alpm_mountpoint_t *data = mp->data; + /* first, check if the prefix matches */ if(strncmp(data->mount_dir, real_path, data->mount_dir_len) == 0) { - return data; + /* now, the hard work- a file like '/etc/myconfig' shouldn't map to a + * mountpoint '/e', but only '/etc'. If the mountpoint ends in a trailing + * slash, we know we didn't have a mismatch, otherwise we have to do some + * more sanity checks. */ + if(data->mount_dir[data->mount_dir_len - 1] == '/') { + return data; + } else if(strlen(real_path) >= data->mount_dir_len) { + const char next = real_path[data->mount_dir_len]; + if(next == '/' || next == '\0') { + return data; + } + } } } -- cgit v1.2.3-70-g09d2 From fe659153d5971e41b7483bb40c31cd40f58f9d9c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 19 Feb 2012 23:24:26 -0600 Subject: Give better error messages on database locking failures This was noted when trying to perform an operation on a pacman database on a read-only file system. Print the actual underlying errno string, and only show the "you can remove" message if the lock file actually exists. Before: $ pacman -Su error: failed to init transaction (unable to lock database) if you're sure a package manager is not already running, you can remove /e/db.lck After: $ pacman -Su error: failed to init transaction (unable to lock database) error: could not lock database: Read-only file system Signed-off-by: Dan McGee --- src/pacman/util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 0b076d97..f7f8ecf5 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -69,9 +69,13 @@ void trans_init_error(void) pm_printf(ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"), alpm_strerror(err)); if(err == ALPM_ERR_HANDLE_LOCK) { - fprintf(stderr, _(" if you're sure a package manager is not already\n" - " running, you can remove %s\n"), - alpm_option_get_lockfile(config->handle)); + const char *lockfile = alpm_option_get_lockfile(config->handle); + pm_printf(ALPM_LOG_ERROR, _("could not lock database: %s\n"), + strerror(errno)); + if(access(lockfile, F_OK) == 0) { + fprintf(stderr, _(" if you're sure a package manager is not already\n" + " running, you can remove %s\n"), lockfile); + } } } -- cgit v1.2.3-70-g09d2 From 78adb71f20ee335dff49e34d33f04817a40002b6 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 21 Dec 2011 16:42:47 -0600 Subject: Don't check diskspace when using --dbonly Mostly a waste of time. Sure, we no longer make sure your pacman database partition has enough space, but if you are using this option you better know what you are doing anyway. Signed-off-by: Dan McGee (cherry picked from commit ee969006056c86e88d5f179a7575d64f23d5b252) --- lib/libalpm/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index a946a7df..185878aa 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1137,7 +1137,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) } /* check available disk space */ - if(handle->checkspace) { + if(handle->checkspace && !(trans->flags & ALPM_TRANS_FLAG_DBONLY)) { EVENT(handle, ALPM_EVENT_DISKSPACE_START, NULL, NULL); _alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space\n"); -- cgit v1.2.3-70-g09d2