2020
2121LANG=C
2222
23- set -u
23+ set -ux
24+
25+ # Set consistent umask for reproducible file permissions
26+ umask 0022
2427
2528run ()
2629{
@@ -48,8 +51,9 @@ architecture=$(dpkg-architecture -q DEB_BUILD_ARCH)
4851debuild_options=()
4952dpkg_buildpackage_options=(-us -uc)
5053
51- run mkdir -p /build
52- run cd /build
54+ build_root_dir=" /build"
55+ run mkdir -p " ${build_root_dir} "
56+ run pushd " ${build_root_dir} "
5357find . -not -path ./ccache -a -not -path " ./ccache/*" -delete
5458if which ccache > /dev/null 2>&1 ; then
5559 export CCACHE_COMPILERCHECK=content
@@ -67,6 +71,9 @@ if which ccache > /dev/null 2>&1; then
6771 debuild_options+=(--prepend-path=/usr/lib/ccache)
6872 fi
6973fi
74+ build_dir=" ${build_root_dir} /build-${PACKAGE} -${VERSION} "
75+ run mkdir -p " ${build_dir} "
76+ run pushd " ${build_dir} "
7077run cp /host/tmp/${PACKAGE} -${VERSION} .tar.gz \
7178 ${PACKAGE} _${VERSION} .orig.tar.gz
7279run tar xfz ${PACKAGE} _${VERSION} .orig.tar.gz
@@ -80,7 +87,7 @@ case "${VERSION}" in
8087 ${PACKAGE} -${VERSION}
8188 ;;
8289esac
83- run cd ${PACKAGE} -${VERSION} /
90+ run pushd ${PACKAGE} -${VERSION} /
8491platform=" ${distribution} -${code_name} "
8592if [ -d " /host/tmp/debian.${platform} -${architecture} " ]; then
8693 run cp -rp " /host/tmp/debian.${platform} -${architecture} " debian
@@ -102,7 +109,7 @@ df -h
102109if which ccache > /dev/null 2>&1 ; then
103110 ccache --show-stats --verbose || :
104111fi
105- run cd -
112+ run popd
106113
107114repositories=" /host/repositories"
108115package_initial=$( echo " ${PACKAGE} " | sed -e ' s/\(.\).*/\1/' )
@@ -116,3 +123,7 @@ run \
116123 -exec cp ' {}' " ${pool_dir} /" ' ;'
117124
118125run chown -R " $( stat --format " %u:%g" " ${repositories} " ) " " ${repositories} "
126+ run find " ${repositories} "
127+
128+ run popd
129+ rm -rf " ${build_dir} "
0 commit comments