[pacman-dev] Sodeps support
These patches add a -dd option which ignores the version of dependencies only and sodependencies. They are also available online at http://git.server-speed.net/users/flo/pacman/
-dd ignores only the version of a dependency being checked, but not the package itself. Signed-off-by: Florian Pritz <bluewind@xssn.at> --- doc/pacman.8.txt | 1 + lib/libalpm/alpm.h | 2 +- lib/libalpm/deps.c | 2 +- src/pacman/pacman.c | 9 +++++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index de1f51f..80bdd0f 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -126,6 +126,7 @@ Options Skips all dependency checks. Normally, pacman will always check a package's dependency fields to ensure that all dependencies are installed and there are no package conflicts in the system. + Specify this option two times to skip only the version checking. *-f, \--force*:: Bypass file conflict checks and overwrite conflicting files. If the diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 0c01f21..a87e1f8 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -272,7 +272,7 @@ typedef enum _pmtransflag_t { PM_TRANS_FLAG_NODEPS = 1, PM_TRANS_FLAG_FORCE = (1 << 1), PM_TRANS_FLAG_NOSAVE = (1 << 2), - /* (1 << 3) flag can go here */ + PM_TRANS_FLAG_NODEPVERSION = (1 << 3), PM_TRANS_FLAG_CASCADE = (1 << 4), PM_TRANS_FLAG_RECURSE = (1 << 5), PM_TRANS_FLAG_DBONLY = (1 << 6), diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index fd893a6..2124956 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -315,7 +315,7 @@ static int dep_vercmp(const char *version1, pmdepmod_t mod, { int equal = 0; - if(mod == PM_DEP_MOD_ANY) { + if(mod == PM_DEP_MOD_ANY || handle->trans->flags & PM_TRANS_FLAG_NODEPVERSION) { equal = 1; } else { int cmp = alpm_pkg_vercmp(version1, version2); diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 049bc40..612c4b3 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -524,8 +524,13 @@ static int parseargs(int argc, char *argv[]) config->op_q_changelog = 1; break; case 'd': - config->op_q_deps = 1; - config->flags |= PM_TRANS_FLAG_NODEPS; + (config->op_q_deps)++; + if(config->op_q_deps == 1) { + config->flags |= PM_TRANS_FLAG_NODEPS; + } else { + config->flags ^= PM_TRANS_FLAG_NODEPS; + config->flags |= PM_TRANS_FLAG_NODEPVERSION; + } break; case 'e': config->op_q_explicit = 1; -- 1.7.3.1
Support-by: brain0 <thomas@archlinux.org> Support-by: GNU\caustic <Christoph.Schied@uni-ulm.de> Signed-off-by: Florian Pritz <bluewind@xssn.at> --- scripts/makepkg.sh.in | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index de24338..f43d87d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -903,6 +903,28 @@ tidy_install() { fi } +find_soprovides() { + local soprovides + find $pkgdir -type f -name \*.so\* | while read filename + do + if readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then + soarch="$(objdump -a "$filename" 2>/dev/null | \ + sed -rn 's/.* file format elf[0-9]+-(.*)$/\1/p' | tr - _)_$(uname -s)" + sofile=$(readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Library soname: \[(.*)\].*/\1/p') + [ -z "$sofile" ] && sofile="$(basename "$filename")" + + soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile") + soversion=$(sed -rn 's/.*\.so\.(.*)/\1/p' <<< "$sofile") + if in_array "${soname}" ${provides[@]}; then + if ! in_array "${soname}=${soversion}-${soarch}" ${soprovides[@]}; then + echo "${soname}=${soversion}-${soarch}" + soprovides=(${soprovides[@]} "${soname}=${soversion}-${soarch}") + fi + fi + fi + done +} + write_pkginfo() { local builddate=$(date -u "+%s") if [[ -n $PACKAGER ]]; then @@ -938,10 +960,24 @@ write_pkginfo() { [[ $depends ]] && printf "depend = %s\n" "${depends[@]}" [[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]}" [[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}" - [[ $provides ]] && printf "provides = %s\n" "${provides[@]}" [[ $backup ]] && printf "backup = %s\n" "${backup[@]}" local it + + soprovides=$(find_soprovides) + provides=("${provides[@]}" ${soprovides}) + + for it in "${provides[@]}"; do + if grep -q ".*\.so$" <<< "$it"; then + if ! grep -q "\(^\|\s\)${it}=.*" <<< $soprovides; then + error "$(gettext "Can't find library listed in \$provides: %s")" "$it" + return 1 + fi + else + echo "provides = $it" + fi + done + for it in "${packaging_options[@]}"; do local ret="$(check_option $it)" if [[ $ret != "?" ]]; then -- 1.7.3.1
Support-by: brain0 <thomas@archlinux.org> Support-by: GNU\caustic <Christoph.Schied@uni-ulm.de> Signed-off-by: Florian Pritz <bluewind@xssn.at> --- scripts/makepkg.sh.in | 35 ++++++++++++++++++++++++++++++++++- 1 files changed, 34 insertions(+), 1 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index f43d87d..891d80e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -903,6 +903,27 @@ tidy_install() { fi } +find_sodepends() { + local sodepends + find $pkgdir -type f | while read filename + do + soarch="$(objdump -a "$filename" 2>/dev/null | \ + sed -rn 's/.* file format elf[0-9]+-(.*)$/\1/p' | tr - _)_$(uname -s)" + [ -n "$soarch" ] || continue + for sofile in $(readelf -d "$filename" 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p') + do + soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile") + soversion=$(sed -rn 's/.*\.so\.(.*)/\1/p' <<< "$sofile") + if in_array "${soname}" ${depends[@]}; then + if ! in_array "${soname}=${soversion}-${soarch}" ${sodepends[@]}; then + echo "${soname}=${soversion}-${soarch}" + sodepends=(${sodepends[@]} "${soname}=${soversion}-${soarch}") + fi + fi + done + done +} + find_soprovides() { local soprovides find $pkgdir -type f -name \*.so\* | while read filename @@ -957,7 +978,6 @@ write_pkginfo() { [[ $license ]] && printf "license = %s\n" "${license[@]}" [[ $replaces ]] && printf "replaces = %s\n" "${replaces[@]}" [[ $groups ]] && printf "group = %s\n" "${groups[@]}" - [[ $depends ]] && printf "depend = %s\n" "${depends[@]}" [[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]}" [[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}" [[ $backup ]] && printf "backup = %s\n" "${backup[@]}" @@ -965,7 +985,20 @@ write_pkginfo() { local it soprovides=$(find_soprovides) + sodepends=$(find_sodepends) provides=("${provides[@]}" ${soprovides}) + depends=("${depends[@]}" ${sodepends}) + + for it in "${depends[@]}"; do + if grep -q ".*\.so$" <<< "$it"; then + if ! grep -q "\(^\|\s\)${it}=.*" <<< $sodepends; then + error "$(gettext "Can't find library listed in \$depends: %s")" "$it" + return 1 + fi + else + echo "depend = $it" + fi + done for it in "${provides[@]}"; do if grep -q ".*\.so$" <<< "$it"; then -- 1.7.3.1
We don't check the version so we shouldn't confuse the user by showing it in the warning. Signed-off-by: Florian Pritz <bluewind@xssn.at> --- lib/libalpm/deps.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 2124956..2155e2c 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -784,7 +784,11 @@ char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep) break; } - if(dep->version) { + if(handle->trans->flags & PM_TRANS_FLAG_NODEPVERSION) { + opr = ""; + } + + if(dep->version && !(handle->trans->flags & PM_TRANS_FLAG_NODEPVERSION)) { ver = dep->version; } else { ver = ""; -- 1.7.3.1
On Fri, 1 Oct 2010 17:30:03 +0200, Florian Pritz <bluewind@xssn.at> wrote:
These patches add a -dd option which ignores the version of dependencies only and sodependencies.
They are also available online at http://git.server-speed.net/users/flo/pacman/
Someone please signoff the pacman patches (1 and 4) so Allan can merge.
On Fri, Oct 8, 2010 at 12:50 PM, Florian Pritz <bluewind@server-speed.net> wrote:
On Fri, 1 Oct 2010 17:30:03 +0200, Florian Pritz <bluewind@xssn.at> wrote:
These patches add a -dd option which ignores the version of dependencies only and sodependencies.
They are also available online at http://git.server-speed.net/users/flo/pacman/
Someone please signoff the pacman patches (1 and 4) so Allan can merge.
make check failed with deptest001 : pacman -T 'foo>1' segfaulted because we don't have a transaction in this case. Added a quick helper that uses alpm_get_trans_flags and check for -1. Also slightly changed the second patch to do just once : if (nodeps) .... else .... http://code.toofishes.net/cgit/xavier/pacman.git/log/?h=sodeps
On 09/10/10 03:05, Xavier Chantry wrote:
On Fri, Oct 8, 2010 at 12:50 PM, Florian Pritz <bluewind@server-speed.net> wrote:
On Fri, 1 Oct 2010 17:30:03 +0200, Florian Pritz<bluewind@xssn.at> wrote:
These patches add a -dd option which ignores the version of dependencies only and sodependencies.
They are also available online at http://git.server-speed.net/users/flo/pacman/
Someone please signoff the pacman patches (1 and 4) so Allan can merge.
make check failed with deptest001 : pacman -T 'foo>1' segfaulted because we don't have a transaction in this case.
Added a quick helper that uses alpm_get_trans_flags and check for -1. Also slightly changed the second patch to do just once : if (nodeps) .... else ....
http://code.toofishes.net/cgit/xavier/pacman.git/log/?h=sodeps
We probably also need a pactest or two for the -dd flag. Allan
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> --- test/pacman/tests/sync-sdd1.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd2.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd3.py | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/sync-sdd1.py create mode 100644 test/pacman/tests/sync-sdd2.py create mode 100644 test/pacman/tests/sync-sdd3.py diff --git a/test/pacman/tests/sync-sdd1.py b/test/pacman/tests/sync-sdd1.py new file mode 100644 index 0000000..184a66d --- /dev/null +++ b/test/pacman/tests/sync-sdd1.py @@ -0,0 +1,15 @@ +self.description = "-Sdd: -Sdd works" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["provision>=1.0-2"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-Sdd %s" % p1.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=pkg2") diff --git a/test/pacman/tests/sync-sdd2.py b/test/pacman/tests/sync-sdd2.py new file mode 100644 index 0000000..5f1f847 --- /dev/null +++ b/test/pacman/tests/sync-sdd2.py @@ -0,0 +1,15 @@ +self.description = "-Sdd: -S fails" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["provision>=1.0-2"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-S %s" % p1.name + +self.addrule("PACMAN_RETCODE=1") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") diff --git a/test/pacman/tests/sync-sdd3.py b/test/pacman/tests/sync-sdd3.py new file mode 100644 index 0000000..68733af --- /dev/null +++ b/test/pacman/tests/sync-sdd3.py @@ -0,0 +1,15 @@ +self.description = "-Sdd: -Sd works but no deps" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["provision>=1.0-2"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-Sd %s" % p1.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") -- 1.7.3.1
On 11/10/10 03:57, Xavier Chantry wrote:
Signed-off-by: Xavier Chantry<chantry.xavier@gmail.com> --- test/pacman/tests/sync-sdd1.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd2.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd3.py | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/sync-sdd1.py create mode 100644 test/pacman/tests/sync-sdd2.py create mode 100644 test/pacman/tests/sync-sdd3.py
Are you proposing a new test naming scheme here too? Because I like it... Anyway, ack to the tests. Hopefully cases 2 and 3 were already covered, but it does not hurt to explicitly have these as a group. Allan
On Mon, Oct 11, 2010 at 3:52 AM, Allan McRae <allan@archlinux.org> wrote:
On 11/10/10 03:57, Xavier Chantry wrote:
Signed-off-by: Xavier Chantry<chantry.xavier@gmail.com> --- test/pacman/tests/sync-sdd1.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd2.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd3.py | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/sync-sdd1.py create mode 100644 test/pacman/tests/sync-sdd2.py create mode 100644 test/pacman/tests/sync-sdd3.py
Are you proposing a new test naming scheme here too? Because I like it...
Anyway, ack to the tests. Hopefully cases 2 and 3 were already covered, but it does not hurt to explicitly have these as a group.
Well you spotted exactly the two problems I had. First I tried to look for a pactest with -S that failed because a versioned dependency I found provision022.py that almost suited my need. But then with this stupid numbering with almost complete disorder, I never know how to insert new pactests. On one hand, we had 'provision001' style naming describing a functionality, on the other hand 'sync001' which only gives the operation. I just mixed the two to create a new group. Also I thought it was a good illustration for -Sdd to show how -S, -Sd and -Sdd behave in the same situation.
participants (4)
-
Allan McRae
-
Florian Pritz
-
Florian Pritz
-
Xavier Chantry