[pacman-dev] [PATCH] makepkg: allow epoch to be overridden
We can override pkgver and pkgrel so it is only logical to add epoch to that list Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4b8f167..88afe7b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,9 +44,9 @@ startdir="$PWD" packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') -splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ - 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ - 'backup' 'options' 'install' 'changelog') +splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \ + 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \ + 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides # Options @@ -1455,10 +1455,13 @@ check_sanity() { fi done || ret=1 - if [[ ! $epoch =~ ^[0-9]*$ ]]; then - error "$(gettext "%s must be an integer.")" "epoch" - ret=1 - fi + awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | + while read i; do + if [[ ! $i =~ ^[0-9]*$ ]]; then + error "$(gettext "%s must be an integer.")" "epoch" + return 1 + fi + done || ret=1 if [[ $arch != 'any' ]]; then if ! in_array $CARCH ${arch[@]}; then -- 1.7.6
When epoch, pkgver and/or pkgrel were overridden in a split package function, makepkg failed hard finding the real version for checking if packages were already built or trying to install packages. Fix the get_full_version function to deal with overrides and return the actual package version. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 45 +++++++++++++++++++++++++++------------------ 1 files changed, 27 insertions(+), 18 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 88afe7b..09b2ae6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -141,8 +141,7 @@ clean_up() { msg "$(gettext "Cleaning up...")" rm -rf "$pkgdir" "$srcdir" if [[ -n $pkgbase ]]; then - # TODO: this wasn't properly fixed in commit 2020e629 - local fullver=$(get_full_version $epoch $pkgver $pkgrel) + local fullver=$(get_full_version) # Can't do this unless the BUILDSCRIPT has been sourced. if (( BUILDFUNC )); then rm -f "${pkgbase}-${fullver}-${CARCH}-build.log"* @@ -237,15 +236,27 @@ get_url() { } ## -# usage : get_full_version( $epoch, $pkgver, $pkgrel ) +# usage : get_full_version( [$pkgname] ) # return : full version spec, including epoch (if necessary), pkgver, pkgrel ## get_full_version() { - if [[ $1 -eq 0 ]]; then - # zero epoch case, don't include it in version - echo $2-$3 + if [[ -z $1 ]]; then + if (( ! $epoch )); then + echo $pkgver-$pkgrel + else + echo $epoch:$pkgver-$pkgrel + fi else - echo $1:$2-$3 + for i in pkgver pkgrel epoch; do + local indirect="${i}_override" + eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p") + [[ -z ${!indirect} ]] && eval "${indirect}=\${${i}}" + done + if (( ! $epoch_override )); then + echo $pkgver_override-$pkgrel_override + else + echo $epoch_override:$pkgver_override-$pkgrel_override + fi fi } @@ -874,7 +885,7 @@ run_function() { local ret=0 local restoretrap if (( LOGGING )); then - local fullver=$(get_full_version $epoch $pkgver $pkgrel) + local fullver=$(get_full_version) local BUILDLOG="${startdir}/${pkgbase}-${fullver}-${CARCH}-$pkgfunc.log" if [[ -f $BUILDLOG ]]; then local i=1 @@ -1108,7 +1119,7 @@ write_pkginfo() { echo "# $(LC_ALL=C date -u)" echo "pkgname = $1" (( SPLITPKG )) && echo pkgbase = $pkgbase - echo "pkgver = $(get_full_version $epoch $pkgver $pkgrel)" + echo "pkgver = $(get_full_version)" echo "pkgdesc = $pkgdesc" echo "url = $url" echo "builddate = $builddate" @@ -1252,7 +1263,7 @@ create_package() { "$PKGEXT" ; EXT=$PKGEXT ;; esac - local fullver=$(get_full_version $epoch $pkgver $pkgrel) + local fullver=$(get_full_version) local pkg_file="$PKGDEST/${nameofpkg}-${fullver}-${PKGARCH}${PKGEXT}" local ret=0 @@ -1365,7 +1376,7 @@ create_srcpackage() { "$SRCEXT" ;; esac - local fullver=$(get_full_version $epoch $pkgver $pkgrel) + local fullver=$(get_full_version) local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}" # tar it up @@ -1401,8 +1412,7 @@ install_package() { local fullver pkg pkglist for pkg in ${pkgname[@]}; do - # TODO: this wasn't properly fixed in commit 2020e629 - fullver=$(get_full_version $epoch $pkgver $pkgrel) + fullver=$(get_full_version $pkg) if [[ -f $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT} ]]; then pkglist+=" $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT}" else @@ -2157,7 +2167,7 @@ fi if (( ! SPLITPKG )); then - fullver=$(get_full_version $epoch $pkgver $pkgrel) + fullver=$(get_full_version) if [[ -f $PKGDEST/${pkgname}-${fullver}-${CARCH}${PKGEXT} \ || -f $PKGDEST/${pkgname}-${fullver}-any${PKGEXT} ]] \ && ! (( FORCE || SOURCEONLY || NOBUILD )); then @@ -2174,8 +2184,7 @@ else allpkgbuilt=1 somepkgbuilt=0 for pkg in ${pkgname[@]}; do - # TODO: this wasn't properly fixed in commit 2020e629 - fullver=$(get_full_version $epoch $pkgver $pkgrel) + fullver=$(get_full_version $pkg) if [[ -f $PKGDEST/${pkg}-${fullver}-${CARCH}${PKGEXT} \ || -f $PKGDEST/${pkg}-${fullver}-any${PKGEXT} ]]; then somepkgbuilt=1 @@ -2235,7 +2244,7 @@ if (( INFAKEROOT )); then exit 0 # $E_OK fi -fullver=$(get_full_version $epoch $pkgver $pkgrel) +fullver=$(get_full_version) msg "$(gettext "Making package: %s")" "$pkgbase $fullver ($(date))" # if we are creating a source-only package, go no further @@ -2381,7 +2390,7 @@ else fi fi -fullver=$(get_full_version $epoch $pkgver $pkgrel) +fullver=$(get_full_version) msg "$(gettext "Finished making: %s")" "$pkgbase $fullver ($(date))" install_package -- 1.7.6
On 22/07/11 22:04, Allan McRae wrote:
We can override pkgver and pkgrel so it is only logical to add epoch to that list
Signed-off-by: Allan McRae<allan@archlinux.org>
The version in my working branch also updates the documentation... (doc/PKGBUILD.8.txt and proto/PKGBUILD-split.proto) Allan
On Fri, Jul 22, 2011 at 10:04:31PM +1000, Allan McRae wrote:
We can override pkgver and pkgrel so it is only logical to add epoch to that list
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4b8f167..88afe7b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,9 +44,9 @@ startdir="$PWD"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') -splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ - 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ - 'backup' 'options' 'install' 'changelog') +splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \ + 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \ + 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
# Options @@ -1455,10 +1455,13 @@ check_sanity() { fi done || ret=1
- if [[ ! $epoch =~ ^[0-9]*$ ]]; then - error "$(gettext "%s must be an integer.")" "epoch" - ret=1 - fi + awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | + while read i; do + if [[ ! $i =~ ^[0-9]*$ ]]; then + error "$(gettext "%s must be an integer.")" "epoch" + return 1 + fi + done || ret=1
if [[ $arch != 'any' ]]; then if ! in_array $CARCH ${arch[@]}; then -- 1.7.6
I see 2 issues: 1) s/return/exit/ or remove the '|| ret=1'. Both are not needed. return, even from inside a subshell will work as expected. 2) This doesn't handle comments after the epoch value. awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | { read i _ if [[ $i != +([[:digit:]]) ]]; then error "$(gettext "%s must be an integer.")" "epoch" return 1 fi }
On 22/07/11 23:55, Dave Reisner wrote:
On Fri, Jul 22, 2011 at 10:04:31PM +1000, Allan McRae wrote:
We can override pkgver and pkgrel so it is only logical to add epoch to that list
Signed-off-by: Allan McRae<allan@archlinux.org> --- scripts/makepkg.sh.in | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4b8f167..88afe7b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,9 +44,9 @@ startdir="$PWD"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') -splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ - 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ - 'backup' 'options' 'install' 'changelog') +splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \ + 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \ + 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
# Options @@ -1455,10 +1455,13 @@ check_sanity() { fi done || ret=1
- if [[ ! $epoch =~ ^[0-9]*$ ]]; then - error "$(gettext "%s must be an integer.")" "epoch" - ret=1 - fi + awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | + while read i; do + if [[ ! $i =~ ^[0-9]*$ ]]; then + error "$(gettext "%s must be an integer.")" "epoch" + return 1 + fi + done || ret=1
if [[ $arch != 'any' ]]; then if ! in_array $CARCH ${arch[@]}; then -- 1.7.6
I see 2 issues: 1) s/return/exit/ or remove the '|| ret=1'. Both are not needed. return, even from inside a subshell will work as expected.
Does either of those options work? We want only ret=1 set on failure and not exiting from the function so the rest of the checks are performed.
2) This doesn't handle comments after the epoch value.
awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | { read i _ if [[ $i != +([[:digit:]]) ]]; then error "$(gettext "%s must be an integer.")" "epoch" return 1 fi }
On Sat, Jul 23, 2011 at 12:10:32AM +1000, Allan McRae wrote:
On 22/07/11 23:55, Dave Reisner wrote:
On Fri, Jul 22, 2011 at 10:04:31PM +1000, Allan McRae wrote:
We can override pkgver and pkgrel so it is only logical to add epoch to that list
Signed-off-by: Allan McRae<allan@archlinux.org> --- scripts/makepkg.sh.in | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4b8f167..88afe7b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,9 +44,9 @@ startdir="$PWD"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') -splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ - 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ - 'backup' 'options' 'install' 'changelog') +splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \ + 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \ + 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
# Options @@ -1455,10 +1455,13 @@ check_sanity() { fi done || ret=1
- if [[ ! $epoch =~ ^[0-9]*$ ]]; then - error "$(gettext "%s must be an integer.")" "epoch" - ret=1 - fi + awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | + while read i; do + if [[ ! $i =~ ^[0-9]*$ ]]; then + error "$(gettext "%s must be an integer.")" "epoch" + return 1 + fi + done || ret=1
if [[ $arch != 'any' ]]; then if ! in_array $CARCH ${arch[@]}; then -- 1.7.6
I see 2 issues: 1) s/return/exit/ or remove the '|| ret=1'. Both are not needed. return, even from inside a subshell will work as expected.
Does either of those options work? We want only ret=1 set on failure and not exiting from the function so the rest of the checks are performed.
Then you want to 'exit 1' from the subshell so that the '|| ret=1' is triggered.
2) This doesn't handle comments after the epoch value.
awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | { read i _ if [[ $i != +([[:digit:]]) ]]; then error "$(gettext "%s must be an integer.")" "epoch" return 1 fi }
On 23/07/11 00:13, Dave Reisner wrote:
On Sat, Jul 23, 2011 at 12:10:32AM +1000, Allan McRae wrote:
On 22/07/11 23:55, Dave Reisner wrote:
On Fri, Jul 22, 2011 at 10:04:31PM +1000, Allan McRae wrote:
We can override pkgver and pkgrel so it is only logical to add epoch to that list
Signed-off-by: Allan McRae<allan@archlinux.org> --- scripts/makepkg.sh.in | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4b8f167..88afe7b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,9 +44,9 @@ startdir="$PWD"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') -splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ - 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ - 'backup' 'options' 'install' 'changelog') +splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \ + 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \ + 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
# Options @@ -1455,10 +1455,13 @@ check_sanity() { fi done || ret=1
- if [[ ! $epoch =~ ^[0-9]*$ ]]; then - error "$(gettext "%s must be an integer.")" "epoch" - ret=1 - fi + awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | + while read i; do + if [[ ! $i =~ ^[0-9]*$ ]]; then + error "$(gettext "%s must be an integer.")" "epoch" + return 1 + fi + done || ret=1
if [[ $arch != 'any' ]]; then if ! in_array $CARCH ${arch[@]}; then -- 1.7.6
I see 2 issues: 1) s/return/exit/ or remove the '|| ret=1'. Both are not needed. return, even from inside a subshell will work as expected.
Does either of those options work? We want only ret=1 set on failure and not exiting from the function so the rest of the checks are performed.
Then you want to 'exit 1' from the subshell so that the '|| ret=1' is triggered.
As opposed to now when it is triggered? Not saying that exit is not the better way to go, just that return works... Allan
On Sat, Jul 23, 2011 at 12:21:24AM +1000, Allan McRae wrote:
On 23/07/11 00:13, Dave Reisner wrote:
On Sat, Jul 23, 2011 at 12:10:32AM +1000, Allan McRae wrote:
On 22/07/11 23:55, Dave Reisner wrote:
On Fri, Jul 22, 2011 at 10:04:31PM +1000, Allan McRae wrote:
We can override pkgver and pkgrel so it is only logical to add epoch to that list
Signed-off-by: Allan McRae<allan@archlinux.org> --- scripts/makepkg.sh.in | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4b8f167..88afe7b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -44,9 +44,9 @@ startdir="$PWD"
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') -splitpkg_overrides=('pkgver' 'pkgrel' 'pkgdesc' 'arch' 'license' 'groups' \ - 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' \ - 'backup' 'options' 'install' 'changelog') +splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'license' \ + 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \ + 'replaces' 'backup' 'options' 'install' 'changelog') readonly -a packaging_options other_options splitpkg_overrides
# Options @@ -1455,10 +1455,13 @@ check_sanity() { fi done || ret=1
- if [[ ! $epoch =~ ^[0-9]*$ ]]; then - error "$(gettext "%s must be an integer.")" "epoch" - ret=1 - fi + awk -F'=' '/^[[:space:]]*epoch=/ { $1=""; print $0 }' "$BUILDFILE" | + while read i; do + if [[ ! $i =~ ^[0-9]*$ ]]; then + error "$(gettext "%s must be an integer.")" "epoch" + return 1 + fi + done || ret=1
if [[ $arch != 'any' ]]; then if ! in_array $CARCH ${arch[@]}; then -- 1.7.6
I see 2 issues: 1) s/return/exit/ or remove the '|| ret=1'. Both are not needed. return, even from inside a subshell will work as expected.
Does either of those options work? We want only ret=1 set on failure and not exiting from the function so the rest of the checks are performed.
Then you want to 'exit 1' from the subshell so that the '|| ret=1' is triggered.
As opposed to now when it is triggered? Not saying that exit is not the better way to go, just that return works...
Allan
I withdraw my complaint =P d
participants (2)
-
Allan McRae
-
Dave Reisner