Added support to pass native machine architecture to pkg scripts (6th arg).

This commit is contained in:
Juan RP 2014-03-12 10:16:37 +01:00
parent 7606691af3
commit ef3b6278a6
5 changed files with 96 additions and 2 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.34 (???):
* Pass another argument to package scripts with the native machine architecture
(uname -m), which can be overrided via XBPS_ARCH environment variable too.
xbps-0.33 (2014-03-11):
* xbps-dgraph: fixed a segfault if rootdir wasn't set:

View File

@ -98,7 +98,7 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp,
rv = xbps_file_exec(xhp, fpath, action, pkgname, version,
update ? "yes" : "no",
xhp->conffile, NULL);
xhp->conffile, xhp->native_arch, NULL);
free(pkgname);
out:

View File

@ -17,6 +17,7 @@ atf_test_program{name="remove_test"}
atf_test_program{name="replace_test"}
atf_test_program{name="installmode_test"}
atf_test_program{name="obsoletefiles_test"}
atf_test_program{name="scripts_test"}
include('find_pkg_orphans/Kyuafile')
include('pkgdb/Kyuafile')

View File

@ -3,7 +3,7 @@ TOPDIR = ../../../..
TESTSHELL = conf_files_test issue6_test issue18_test issue20_test remove_test
TESTSHELL+= replace_test installmode_test obsoletefiles_test
TESTSHELL+= issue31_test
TESTSHELL+= issue31_test scripts_test
include ../Makefile.inc
include $(TOPDIR)/mk/test.mk

View File

@ -0,0 +1,90 @@
#!/usr/bin/env atf-sh
#
# Tests to verify that INSTALL/REMOVE scripts in pkgs work as expected.
create_script() {
cat > "$1" <<_EOF
#!/bin/sh
ACTION="\$1"
PKGNAME="\$2"
VERSION="\$3"
UPDATE="\$4"
CONF_FILE="\$5"
ARCH="\$6"
echo "\$@" >&2
_EOF
chmod +x "$1"
}
atf_test_case script_nargs
script_nargs_head() {
atf_set "descr" "Tests for package scripts: number of arguments"
}
script_nargs_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin
echo "A-1.0_1" > pkg_A/usr/bin/foo
create_script pkg_A/INSTALL
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
xbps-install -C empty.conf -r root --repository=$PWD/some_repo -y A
atf_check_equal $? 0
rval=0
xbps-reconfigure -C empty.conf -r root -f A 2>out
out="$(cat out)"
expected="post A 1.0_1 no empty.conf $(uname -m)"
if [ "$out" != "$expected" ]; then
echo "out: '$out'"
echo "expected: '$expected'"
rval=1
fi
atf_check_equal $rval 0
}
atf_test_case script_arch
script_arch_head() {
atf_set "descr" "Tests for package scripts: XBPS_ARCH overrides \$ARCH"
}
script_arch_body() {
mkdir some_repo root
mkdir -p pkg_A/usr/bin
echo "A-1.0_1" > pkg_A/usr/bin/foo
create_script pkg_A/INSTALL
cd some_repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
xbps-install -C empty.conf -r root --repository=$PWD/some_repo -y A
atf_check_equal $? 0
# Check that XBPS_ARCH overrides $ARCH.
rval=0
XBPS_ARCH=foo xbps-reconfigure -C empty.conf -r root -f A 2>out
out="$(cat out)"
expected="post A 1.0_1 no empty.conf foo"
if [ "$out" != "$expected" ]; then
echo "out: '$out'"
echo "expected: '$expected'"
rval=1
fi
atf_check_equal $rval 0
}
atf_init_test_cases() {
atf_add_test_case script_nargs
atf_add_test_case script_arch
}