[arch-projects] [devtools][patch][makechrootpkg] Actually pass extra arguments to makepkg

Joel Teichroeb joel at teichroeb.net
Sun Mar 16 01:09:30 EDT 2014


I didn't know that -- would work. The documentation didn't mention that.

The line "*) makepkg_args="$makepkg_args -$arg $OPTARG" ;;" is still wrong
though as doing "--" will end getopt and then makepkg is called with
${*:$OPTIND}
meaning that the parameters aren't handled by the getopts loop. Instead,
how about this patch? It fixes the usage and removes the broken line.

---
 makechrootpkg.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/makechrootpkg.in b/makechrootpkg.in
index d03b703..fc17b8a 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -35,7 +35,7 @@ src_owner=${SUDO_USER:-$USER}
 usage() {
  echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
  echo ' Run this script in a PKGBUILD dir to build a package inside a'
- echo ' clean chroot. All unrecognized arguments passed to this script'
+ echo ' clean chroot. All arguments passed to this script after --'
  echo ' will be passed to makepkg.'
  echo ''
  echo ' The chroot dir consists of the following directories:'
@@ -78,7 +78,6 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
  l) copy="$OPTARG" ;;
  n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
  T) temp_chroot=true; copy+="-$$" ;;
- *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
  esac
 done

-- 
1.9.0





On Sat, Mar 15, 2014 at 9:48 PM, Dave Reisner <d at falconindy.com> wrote:

>
> On Mar 16, 2014 12:36 AM, "Joel Teichroeb" <joel at teichroeb.net> wrote:
> >
> > Currently, if a user has extra arguments on the end of their
> makechrootpkg command it prints an error and does not add those arguments
> to the makepkg command line as expected. As far as I can tell it would have
> never worked this way because according to the specifications for
> getopts[1] if there is no ":" at the start of the argument list $OPTARG
> will not be set and $arg will be set to "?", but if there is a ":" $OPTARG
> will be set to the unknown argument. Unfortunately this means we can not
> easily get the argument to an unknown option.
>
> This works just fine if you use the end-of-options delimiter to exit the
> getopts loop, e.g.:
>
> makechrootpkg /path/to/chroot -- -R
>
> >
> > [1]
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html
> > ---
> >  makechrootpkg.in | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/makechrootpkg.in b/makechrootpkg.in
> > index d03b703..7e5f8e8 100644
> > --- a/makechrootpkg.in
> > +++ b/makechrootpkg.in
> > @@ -66,7 +66,7 @@ usage() {
> >   exit 1
> >  }
> >
> > -while getopts 'hcur:I:l:nTD:d:' arg; do
> > +while getopts ':hcur:I:l:nTD:d:' arg; do
> >   case "$arg" in
> >   h) usage ;;
> >   c) clean_first=true ;;
> > @@ -78,7 +78,7 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
> >   l) copy="$OPTARG" ;;
> >   n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
> >   T) temp_chroot=true; copy+="-$" ;;
> > - *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
> > + *) makepkg_args="$makepkg_args -$OPTARG" ;;
> >   esac
> >  done
> >
> > --
> > 1.9.0
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20140315/0cac186b/attachment.html>


More information about the arch-projects mailing list