diff --git a/NEWS b/NEWS
index 4ca4e898..a6ef7055 100644
--- a/NEWS
+++ b/NEWS
@@ -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:
diff --git a/lib/package_script.c b/lib/package_script.c
index 0031bab5..3a9b3168 100644
--- a/lib/package_script.c
+++ b/lib/package_script.c
@@ -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:
diff --git a/tests/xbps/libxbps/common/Kyuafile b/tests/xbps/libxbps/common/Kyuafile
index 73610660..838557ef 100644
--- a/tests/xbps/libxbps/common/Kyuafile
+++ b/tests/xbps/libxbps/common/Kyuafile
@@ -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')
diff --git a/tests/xbps/libxbps/shell/Makefile b/tests/xbps/libxbps/shell/Makefile
index e0ef1ea2..5ddb15fe 100644
--- a/tests/xbps/libxbps/shell/Makefile
+++ b/tests/xbps/libxbps/shell/Makefile
@@ -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
diff --git a/tests/xbps/libxbps/shell/scripts_test.sh b/tests/xbps/libxbps/shell/scripts_test.sh
new file mode 100644
index 00000000..f6c9d53f
--- /dev/null
+++ b/tests/xbps/libxbps/shell/scripts_test.sh
@@ -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
+}