[pacman-dev] added --config option to makepkg
I added a --config=value option so you can use makepkg --config=safe and it will source the makepkg.safe file instead of makepkg.conf
From 4669853aac72506201af4d6e9ec79f080177d42f Mon Sep 17 00:00:00 2001 From: Imanol Celaya <ilcra1989@gmail.com> Date: Thu, 7 Aug 2008 13:15:27 +0200 Subject: [PATCH] adds --config=value option to use makepkg.value instead of makepkg.conf, as makepkg.safe or makepkg.blender
Signed-off-by: Imanol Celaya <ilcra1989@gmail.com> --- scripts/makepkg.sh.in | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3604d10..267eb81 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1084,6 +1084,7 @@ usage() { echo "$(gettext " -m, --nocolor Disable colorized output messages")" echo "$(gettext " -o, --nobuild Download and extract files only")" printf "$(gettext " -p <buildscript> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT" + echo "$(gettext " --config=value use /etc/makepkg.value file instead of makepkg.conf")" echo "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")" # fix flyspray feature request #2978 echo "$(gettext " -R, --repackage Repackage contents of pkg/ without building")" @@ -1126,14 +1127,31 @@ _PKGDEST=${PKGDEST} _SRCDEST=${SRCDEST} # Source makepkg.conf; fail if it is not found -if [ -r "$confdir/makepkg.conf" ]; then - source "$confdir/makepkg.conf" -else - error "$(gettext "%s not found.")" "$confdir/makepkg.conf" - plain "$(gettext "Aborting...")" - exit 1 # $E_CONFIG_ERROR +# if --config=value option found, use makepkg.value +CUSTOMCONFIG=0 +for ARG in $@; do +if [ ${ARG:0:9} = "--config=" ]; then + if [ -r "$confdir/makepkg.${ARG:9}" ]; then + plain "$(gettext "Using custom makepkg file: %s")" "$confdir/makepkg.${ARG:9}" + source "$confdir/makepkg.${ARG:9}" + CUSTOMCONFIG=1 + break + else + error "$(gettext "%s not found.")" "$confdir/makepkg.${ARG:9}" + plain "$(gettext "Aborting...")" + exit 1 # $E_CONFIG_ERROR +fi +if [ $CUSTOMCONFIG = 0 ]; then + if [ -r "$confdir/makepkg.conf" ]; then + source "$confdir/makepkg.conf" + else + error "$(gettext "%s not found.")" "$confdir/makepkg.conf" + plain "$(gettext "Aborting...")" + exit 1 # $E_CONFIG_ERROR + fi fi + # Source user-specific makepkg.conf overrides if [ -r ~/.makepkg.conf ]; then source ~/.makepkg.conf @@ -1166,7 +1184,7 @@ while true; do # Pacman Options --noconfirm) PACMAN_OPTS="$PACMAN_OPTS --noconfirm" ;; --noprogressbar) PACMAN_OPTS="$PACMAN_OPTS --noprogressbar" ;; - + # Makepkg Options --allsource) SOURCEONLY=2 ;; --asroot) ASROOT=1 ;; -- 1.5.6.5
On Thu, Aug 7, 2008 at 1:25 PM, hoar heor <archye@pycut.com.ar> wrote:
I added a --config=value option so you can use makepkg --config=safe and it will source the makepkg.safe file instead of makepkg.conf
I don't want to sound too harsh, but this patch looks quite complex for what it does, does not use gettext like every other options, and seems rather useless to me. If you really need to have two different makepkg.conf, you could just set up symlinks. ln -sf /etc/makepkg.conf.safe /etc/makepkg.conf ln -sf /etc/makepkg.conf.default /etc/makepkg.conf You could even use an alias to switch faster. I also thought about another way, but I am not totally sure it works, and it is less clean and more complicated than a symlink. You could just use makepkg.conf as a simple wrapper for different configs, checking an environment variable : if [ -n "$SAFE" ]; then source makepkg.conf.safe else source makepkg.conf.default fi Then SAFE=1 makepkg .... or something like that.
I don't want to sound too harsh, but this patch looks quite complex for what it does, does not use gettext like every other options, and seems rather useless to me.
I don't really understand what you mean with gettext, as far as I know it's using it(although I maybe had skipped something) well, it's not only intended to be used with "safe" makepkg, look it this way, someone has -arch and -mute changed to his platform so the packages are optimized, the problem is that they won't work on other processor, if that person builds the package for a repo he will have to change makepkg.conf in this way he could do makepkg --config=release and it would source makepkg.release(witch obviously must have had created earlier), or maybe a specific makepkg for one package makepkg --config=python wich would use makepkg.python I know i't's a bit complicated, but otherwise it would source the file several times if there are more arguments(maybe there's some other way simpler to do it that I haven't noticed, anyway I'm still looking at the source to simplify it)
On Thu, Aug 7, 2008 at 2:17 PM, hoar heor <archye@pycut.com.ar> wrote:
I don't really understand what you mean with gettext, as far as I know it's using it(although I maybe had skipped something)
<snip>
I know i't's a bit complicated, but otherwise it would source the file several times if there are more arguments(maybe there's some other way simpler to do it that I haven't noticed, anyway I'm still looking at the source to simplify it)
I meant getopts of course...
well, it's not only intended to be used with "safe" makepkg, look it this way, someone has -arch and -mute changed to his platform so the packages are optimized, the problem is that they won't work on other processor, if that person builds the package for a repo he will have to change makepkg.conf in this way he could do makepkg --config=release and it would source makepkg.release(witch obviously must have had created earlier), or maybe a specific makepkg for one package makepkg --config=python wich would use makepkg.python
Obviously, the symlinks solution is not limited to two configs either. And the env var way can be modified as well to support any configs. Just use MAKEPKGCONF="configname" Then makepkg.conf can be just one line : source /etc/${MAKEPKGCONF:-makepkg.conf.default}
On Thu, Aug 7, 2008 at 7:43 AM, Xavier <shiningxc@gmail.com> wrote:
On Thu, Aug 7, 2008 at 2:17 PM, hoar heor <archye@pycut.com.ar> wrote:
I don't really understand what you mean with gettext, as far as I know it's using it(although I maybe had skipped something)
<snip>
I know i't's a bit complicated, but otherwise it would source the file several times if there are more arguments(maybe there's some other way simpler to do it that I haven't noticed, anyway I'm still looking at the source to simplify it)
I meant getopts of course...
well, it's not only intended to be used with "safe" makepkg, look it this way, someone has -arch and -mute changed to his platform so the packages are optimized, the problem is that they won't work on other processor, if that person builds the package for a repo he will have to change makepkg.conf in this way he could do makepkg --config=release and it would source makepkg.release(witch obviously must have had created earlier), or maybe a specific makepkg for one package makepkg --config=python wich would use makepkg.python
Obviously, the symlinks solution is not limited to two configs either.
And the env var way can be modified as well to support any configs. Just use MAKEPKGCONF="configname" Then makepkg.conf can be just one line : source /etc/${MAKEPKGCONF:-makepkg.conf.default}
Let's take a step back here. Problem: it is not easy to build packages with different makepkg.conf files. Seemingly simple solution: add a command-line parameter to specify a different config file. The original solution proposed was too restrictive IMO, we do crazy things with adding extensions to a hardcoded /etc/makpkg.* location and who knows what. We should at least give the option of picking a config file from any location. Besides that, we may need to revisit the fact that both /etc/makepkg.conf and ~/.makepkg.conf are currently read; is this really not sufficient for most needs? To be honest, makepkg is so rarely run as root and almost always run as a user that it makes more sense to only read the homedir file if we weren't trying to be backward compatible. But now I'm off on a tangent. :) What was wrong with moving the config file reading after the getopt options parsing? Did I miss something, or can't we handle a --config option in this same fashion? I agree we might have a valuable feature request here; I just think the first patch took the wrong approach and was too specific anyway. -Dan
here is a much simpler approach, now it takes any config file from any location.
From 916f0b0f36e290138e20d59cd1f7f0245a436ffa Mon Sep 17 00:00:00 2001 From: Imanol Celaya <ilcra1989@gmail.com> Date: Thu, 7 Aug 2008 16:18:10 +0200 Subject: [PATCH] added custom config location option
Signed-off-by: Imanol Celaya <ilcra1989@gmail.com> --- scripts/makepkg.sh.in | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3604d10..72b9b7f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1190,6 +1190,7 @@ while true; do -R|--repackage) REPKG=1 ;; --source) SOURCEONLY=1 ;; -s|--syncdeps) DEP_BIN=1 ;; + --config) shift; CONFLOCATION=$1 ;; -h|--help) usage; exit 0 ;; # E_OK -V|--version) version; exit 0 ;; # E_OK @@ -1236,6 +1237,10 @@ if [ "$CLEANCACHE" = "1" ]; then fi fi +if [ ! -z $CONFLOCATION ]; then + source $CONFLOCATION +fi + if [ -z $BUILDSCRIPT ]; then error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$confdir/makepkg.conf" exit 1 -- 1.5.6.5
On Thu, Aug 7, 2008 at 4:20 PM, hoar heor <archye@pycut.com.ar> wrote:
here is a much simpler approach, now it takes any config file from any location.
It is getting better but you missed the part about "moving the config file reading after the getopt options parsing", among other things.
It is getting better but you missed the part about "moving the config file reading after the getopt options parsing", among other things.
true, thanks
participants (3)
-
Dan McGee
-
hoar heor
-
Xavier