From f19bca3bce0fc8d1a22acc6bf013666aba9c9fe1 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 10 Nov 2015 12:04:15 +0100 Subject: [PATCH 1/5] hooks/do-pkg: clean up 00-gen-pkg.sh --- common/hooks/do-pkg/00-gen-pkg.sh | 55 ++++++------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh index 099f889e5de..6749b7a9b34 100644 --- a/common/hooks/do-pkg/00-gen-pkg.sh +++ b/common/hooks/do-pkg/00-gen-pkg.sh @@ -30,9 +30,7 @@ genpkg() { fi cd $pkgdir - if [ -n "$preserve" ]; then - _preserve="-p" - fi + _preserve=${preserve:+-p} if [ -s ${PKGDESTDIR}/rdeps ]; then _deps="$(cat ${PKGDESTDIR}/rdeps)" fi @@ -46,48 +44,15 @@ genpkg() { _gitrevs="$(cat ${XBPS_STATEDIR}/gitrev)" fi - if [ -n "$provides" ]; then - local _provides= - for f in ${provides}; do - _provides="${_provides} ${f}" - done - fi - if [ -n "$conflicts" ]; then - local _conflicts= - for f in ${conflicts}; do - _conflicts="${_conflicts} ${f}" - done - fi - if [ -n "$replaces" ]; then - local _replaces= - for f in ${replaces}; do - _replaces="${_replaces} ${f}" - done - fi - if [ -n "$reverts" ]; then - local _reverts= - for f in ${reverts}; do - _reverts="${_reverts} ${f}" - done - fi - if [ -n "$mutable_files" ]; then - local _mutable_files= - for f in ${mutable_files}; do - _mutable_files="${_mutable_files} ${f}" - done - fi - if [ -n "$conf_files" ]; then - local _conf_files= - for f in ${conf_files}; do - _conf_files="${_conf_files} ${f}" - done - fi - if [ -n "$alternatives" ]; then - local _alternatives= - for f in ${alternatives}; do - _alternatives="${_alternatives} ${f}" - done - fi + # Stripping whitespaces + local _provides="$(echo $provides)" + local _conflicts="$(echo $conflicts)" + local _replaces="$(echo $replaces)" + local _reverts="$(echo $reverts)" + local _mutable_files="$(echo $mutable_files)" + local _conf_files="$(echo $conf_files)" + local _alternatives="$(echo $alternatives)" + local _tags="$(echo $tags)" msg_normal "Creating $binpkg for repository $pkgdir ...\n" From 67757b5708caa5b8694c0420b42ec5a737595f3f Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 17 Nov 2015 18:54:41 +0100 Subject: [PATCH 2/5] hooks/do-pkg/00-gen-pkg.sh: enable globbing for conf_files. --- common/hooks/do-pkg/00-gen-pkg.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh index 6749b7a9b34..3ace80fedcf 100644 --- a/common/hooks/do-pkg/00-gen-pkg.sh +++ b/common/hooks/do-pkg/00-gen-pkg.sh @@ -1,5 +1,18 @@ # This hook generates a XBPS binary package from an installed package in destdir. +expand_dstdir() { + local glob_list= result= glob= file= + + for glob; do + glob_list+=" $DESTDIR/$glob" + done + shopt -s extglob + for file in $glob_list; do + result+=" ${file#$DESTDIR/}" + done + shopt -u extglob +} + genpkg() { local pkgdir="$1" arch="$2" desc="$3" pkgver="$4" binpkg="$5" local _preserve _deps _shprovides _shrequires _gitrevs _provides _conflicts @@ -50,7 +63,7 @@ genpkg() { local _replaces="$(echo $replaces)" local _reverts="$(echo $reverts)" local _mutable_files="$(echo $mutable_files)" - local _conf_files="$(echo $conf_files)" + local _conf_files="$(expand_dstdir $conf_files)" local _alternatives="$(echo $alternatives)" local _tags="$(echo $tags)" From ef24b7b7cc53b654924da9ece818fc0aa1c26d01 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Wed, 18 Nov 2015 09:44:34 +0100 Subject: [PATCH 3/5] common: move expand_destdir to environment/pkg; change lint check. --- common/environment/pkg/.empty | 0 common/environment/pkg/extglob.sh | 17 +++++++++++++++++ common/hooks/do-pkg/00-gen-pkg.sh | 15 ++------------- common/hooks/pre-pkg/99-pkglint.sh | 6 ++++-- 4 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 common/environment/pkg/.empty create mode 100644 common/environment/pkg/extglob.sh diff --git a/common/environment/pkg/.empty b/common/environment/pkg/.empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/common/environment/pkg/extglob.sh b/common/environment/pkg/extglob.sh new file mode 100644 index 00000000000..be620cec704 --- /dev/null +++ b/common/environment/pkg/extglob.sh @@ -0,0 +1,17 @@ +# This provides the extglob function to expand wildcards in the destdir + +expand_destdir() { + local glob_list= result= glob= file= + + for glob; do + glob_list+=" $DESTDIR/$glob" + done + shopt -s extglob + for file in $glob_list; do + result+=" ${file#$DESTDIR/}" + done + shopt -u extglob + echo $result +} + + diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh index 3ace80fedcf..8ffa91d8e5a 100644 --- a/common/hooks/do-pkg/00-gen-pkg.sh +++ b/common/hooks/do-pkg/00-gen-pkg.sh @@ -1,17 +1,6 @@ # This hook generates a XBPS binary package from an installed package in destdir. -expand_dstdir() { - local glob_list= result= glob= file= - - for glob; do - glob_list+=" $DESTDIR/$glob" - done - shopt -s extglob - for file in $glob_list; do - result+=" ${file#$DESTDIR/}" - done - shopt -u extglob -} +source ${XBPS_COMMONDIR}/environment/pkg/extglob.sh genpkg() { local pkgdir="$1" arch="$2" desc="$3" pkgver="$4" binpkg="$5" @@ -63,7 +52,7 @@ genpkg() { local _replaces="$(echo $replaces)" local _reverts="$(echo $reverts)" local _mutable_files="$(echo $mutable_files)" - local _conf_files="$(expand_dstdir $conf_files)" + local _conf_files="$(expand_destdir $conf_files)" local _alternatives="$(echo $alternatives)" local _tags="$(echo $tags)" diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh index d42877814b6..d584b78d7a1 100644 --- a/common/hooks/pre-pkg/99-pkglint.sh +++ b/common/hooks/pre-pkg/99-pkglint.sh @@ -1,5 +1,7 @@ # This hook checks for common issues related to void. +source ${XBPS_COMMONDIR}/environment/pkg/extglob.sh + hook() { local error=0 filename= rev= libname= conflictPkg= conflictFile= local conflictRev= ignore= found= mapshlibs=$XBPS_COMMONDIR/shlibs @@ -25,8 +27,8 @@ hook() { done # Check that configuration files really exist. - for f in ${conf_files}; do - if [ ! -f ${PKGDESTDIR}/${f} ]; then + for f in $(expand_destdir ${conf_files}); do + if [ ! -f "${PKGDESTDIR}/${f}" ]; then msg_red "${pkgver}: '$f' configuration file not in PKGDESTDIR!\n" error=1 fi From 18e288fd2c9ef42ee7beff5f6a4eee888f197185 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Wed, 18 Nov 2015 10:00:56 +0100 Subject: [PATCH 4/5] common: remove unneccessary 'source's; move extglob.sh to install --- common/environment/install/extglob.sh | 15 +++++++++++++++ common/environment/pkg/extglob.sh | 18 +----------------- common/hooks/do-pkg/00-gen-pkg.sh | 2 -- common/hooks/pre-pkg/99-pkglint.sh | 2 -- 4 files changed, 16 insertions(+), 21 deletions(-) create mode 100644 common/environment/install/extglob.sh mode change 100644 => 120000 common/environment/pkg/extglob.sh diff --git a/common/environment/install/extglob.sh b/common/environment/install/extglob.sh new file mode 100644 index 00000000000..048218c60dc --- /dev/null +++ b/common/environment/install/extglob.sh @@ -0,0 +1,15 @@ +# This provides the extglob function to expand wildcards in the destdir + +expand_destdir() { + local glob_list= result= glob= file= + + for glob; do + glob_list+=" $DESTDIR/$glob" + done + shopt -s extglob + for file in $glob_list; do + result+=" ${file#$DESTDIR/}" + done + shopt -u extglob + echo $result +} diff --git a/common/environment/pkg/extglob.sh b/common/environment/pkg/extglob.sh deleted file mode 100644 index be620cec704..00000000000 --- a/common/environment/pkg/extglob.sh +++ /dev/null @@ -1,17 +0,0 @@ -# This provides the extglob function to expand wildcards in the destdir - -expand_destdir() { - local glob_list= result= glob= file= - - for glob; do - glob_list+=" $DESTDIR/$glob" - done - shopt -s extglob - for file in $glob_list; do - result+=" ${file#$DESTDIR/}" - done - shopt -u extglob - echo $result -} - - diff --git a/common/environment/pkg/extglob.sh b/common/environment/pkg/extglob.sh new file mode 120000 index 00000000000..727ffaf5645 --- /dev/null +++ b/common/environment/pkg/extglob.sh @@ -0,0 +1 @@ +../install/extglob.sh \ No newline at end of file diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh index 8ffa91d8e5a..ab010ff42f8 100644 --- a/common/hooks/do-pkg/00-gen-pkg.sh +++ b/common/hooks/do-pkg/00-gen-pkg.sh @@ -1,7 +1,5 @@ # This hook generates a XBPS binary package from an installed package in destdir. -source ${XBPS_COMMONDIR}/environment/pkg/extglob.sh - genpkg() { local pkgdir="$1" arch="$2" desc="$3" pkgver="$4" binpkg="$5" local _preserve _deps _shprovides _shrequires _gitrevs _provides _conflicts diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh index d584b78d7a1..e9015e25365 100644 --- a/common/hooks/pre-pkg/99-pkglint.sh +++ b/common/hooks/pre-pkg/99-pkglint.sh @@ -1,7 +1,5 @@ # This hook checks for common issues related to void. -source ${XBPS_COMMONDIR}/environment/pkg/extglob.sh - hook() { local error=0 filename= rev= libname= conflictPkg= conflictFile= local conflictRev= ignore= found= mapshlibs=$XBPS_COMMONDIR/shlibs From 82b736b616d347e7db440e18455dcb97b706d9aa Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Wed, 18 Nov 2015 11:19:09 +0100 Subject: [PATCH 5/5] common: expand_destdir rewrite --- common/environment/install/extglob.sh | 23 +++++++++++++---------- common/hooks/do-pkg/00-gen-pkg.sh | 2 +- common/hooks/pre-pkg/99-pkglint.sh | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/common/environment/install/extglob.sh b/common/environment/install/extglob.sh index 048218c60dc..c0bf59d74a1 100644 --- a/common/environment/install/extglob.sh +++ b/common/environment/install/extglob.sh @@ -1,15 +1,18 @@ # This provides the extglob function to expand wildcards in the destdir expand_destdir() { - local glob_list= result= glob= file= + local result= glob= file= - for glob; do - glob_list+=" $DESTDIR/$glob" - done - shopt -s extglob - for file in $glob_list; do - result+=" ${file#$DESTDIR/}" - done - shopt -u extglob - echo $result + ( + set -f + for glob in $@; do + files=$(echo "${PKGDESTDIR}/${glob}") + set +f + for file in $files; do + result+="${blank}${file#$PKGDESTDIR/}" + blank=" " + done + done + echo "$result" + ) } diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh index ab010ff42f8..75d47d36496 100644 --- a/common/hooks/do-pkg/00-gen-pkg.sh +++ b/common/hooks/do-pkg/00-gen-pkg.sh @@ -50,7 +50,7 @@ genpkg() { local _replaces="$(echo $replaces)" local _reverts="$(echo $reverts)" local _mutable_files="$(echo $mutable_files)" - local _conf_files="$(expand_destdir $conf_files)" + local _conf_files="$(expand_destdir "$conf_files")" local _alternatives="$(echo $alternatives)" local _tags="$(echo $tags)" diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh index e9015e25365..441da4a59f7 100644 --- a/common/hooks/pre-pkg/99-pkglint.sh +++ b/common/hooks/pre-pkg/99-pkglint.sh @@ -25,7 +25,7 @@ hook() { done # Check that configuration files really exist. - for f in $(expand_destdir ${conf_files}); do + for f in $(expand_destdir "${conf_files}"); do if [ ! -f "${PKGDESTDIR}/${f}" ]; then msg_red "${pkgver}: '$f' configuration file not in PKGDESTDIR!\n" error=1