sm-discuss AT lists.ibiblio.org
Subject: Public SourceMage Discussion List
List archive
- From: Bor Kraljič <pyrobor AT ver.si>
- To: sm-discuss AT lists.ibiblio.org
- Subject: Re: [SM-Discuss] Spell branches
- Date: Mon, 12 Sep 2011 16:29:28 +0200
On 11. of Sep 2011 22:47:14 Ismael Luceno <ismael.luceno AT gmail.com> wrote:
> Some spells support multiple branches. I would like to remove the
> duplication to certain extent, by adding a new function that would
> take a list of branches, query which one the user wants and if it
> should be updated automatically (if applicable).
I have done something like that once for PREPARE for scm versions. However
the
first problem was that FUNCTIONS are not sourced in PREPARE and also that our
goal is to move logic out of spells if possible. And there might be other
reason too. Don't really know what the main reason was. But I have done it
but never commit it.
I am attaching the diff for the function that I made at that time. As far as
I
remember it worked. If it helps... or you find it useful commit it or rewrite
it.
Kind regards,
Bor
>
> Something like:
>
> function select_branch() {
> local spell="$1" tmp &&
> shift &&
>
> if [[ $# > 1 ]]; then
> config_query_list "$spell"_BRANCH \
> "Select one of the available branches:" "$@" &&
> eval tmp=\$"$spell"_BRANCH
> else
> eval "$spell"_BRANCH=\""$1"\" &&
> tmp="$1"
> fi &&
>
> if [[ "${tmp/-*}" = scm ]]; then
> config_query "$spell"_SCM_AUTOUPDATE \
> 'Update on every system update?' n
> fi
> }
>
>
> Opinions?
diff --git a/FUNCTIONS b/FUNCTIONS index 2b2bedc..321f7a7 100755 --- a/FUNCTIONS +++ b/FUNCTIONS @@ -663,13 +663,96 @@ function default_kde3_build() { } + +#--- +## ask user about using scm version and save information so it can be +## used in DETAILS. +## information is saved in SPELL_NAME_SCM and SPELL_NAME_SCM_AUTOUPDATE +## for SPELL=spell-name +## for now manual source of FUNCTIONS in PREPARE is needed: +## . ${GRIMOIRE}/FUNCTIONS && +## prepare_scm_queries +## +#--- +function prepare_scm_queries() { + local up_spell_name=$(get_up_spell_name) && + + local scm_var scm_autoupdate_var + scm_var="${up_spell_name}_SCM" && + scm_autoupdate_var="${up_spell_name}_SCM_AUTOUPDATE" && + + config_query $scm_var "Build the SCM version of $SPELL?" n + + if [[ ${!scm_var} == "y" ]] + then + config_query $scm_autoupdate_var \ + "Automatically update $SPELL on system-update?" n + fi +} + +#--- +## this simplifies the changes in DETAILS file when adding scm version +## it uses generic "scm" all it needs it SOURCE_URL +## +## To use it you have to source FUNCTIONS and there is still one if +## sentence we need... don't really know how could i get rid of that one +## It can be used like this. example: +## SPELL=libnfnetlink +##if [[ "$LIBNFNETLINK_SCM" == "y" ]]; then +##. $GRIMOIRE/FUNCTIONS +##scm_details "git://git.netfilter.org/libnfnetlink.git" +##else +## VERSION=1.0.0 +## SOURCE=$SPELL-$VERSION.tar.bz2 +##SOURCE_DIRECTORY=$BUILD_DIRECTORY/$SPELL-$VERSION +## SOURCE2=$SOURCE.sig +## SOURCE_URL[0]=http://www.netfilter.org/projects/$SPELL/files/$SOURCE +## SOURCE2_URL[0]=${SOURCE_URL[0]}.sig +## SOURCE_GPG=netfilter.gpg:$SOURCE2:UPSTREAM_KEY +## SOURCE2_IGNORE=signature +##fi +## WEB_SITE=http://www.netfilter.org +## ENTERED=20060413 +## LICENSE[0]=GPL +## SHORT="netfilter libnfnetlink" +## long description... +## +## @param pure scm SOURCE_URL +#--- +function scm_details() { + local scm_url=$1 + local up_spell_name=$(get_up_spell_name) + + scm_autoupdate_var="${up_spell_name}_SCM_AUTOUPDATE" + + if [[ ${!scm_autoupdate_var} == y ]]; then + VERSION=$(date +%Y%m%d) + else + VERSION=scm + fi +SOURCE_DIRECTORY=$BUILD_DIRECTORY/$SPELL-scm + SOURCE_IGNORE=volatile + SOURCE_URL[0]=${scm_url}:${SPELL}-scm + FORCE_DOWNLOAD=1 + SOURCE=$SPELL-scm.tar.bz2 +} + +#--- +## to avoid the code duplication lets use one function +#--- +function get_up_spell_name() { + local spell=${1:-$SPELL} + local up_spell_name=$(echo $spell | tr "a-z" "A-Z") && + local up_spell_name=$(echo $up_spell_name | tr "-" "_") && + echo $up_spell_name +} + # Move SPELL_OPTS to OPTS # basicly generic OPTS="$SPELL_OPTS $OPTS" function prepare_opts() { # this is here so that config_query_option can be used without # extra junk - local up_spell_name=$(echo $SPELL | tr "a-z" "A-Z") && - local up_spell_name=$(echo $up_spell_name | tr "-" "_") && + local up_spell_name=$(get_up_spell_name) && local tempopts="${up_spell_name}_OPTS" && OPTS="${!tempopts} $OPTS" }
Attachment:
signature.asc
Description: This is a digitally signed message part.
-
[SM-Discuss] Spell branches,
Ismael Luceno, 09/11/2011
- Re: [SM-Discuss] Spell branches, David Kowis, 09/12/2011
-
Re: [SM-Discuss] Spell branches,
Bor Kraljič, 09/12/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/12/2011
- Re: [SM-Discuss] Spell branches, Bor Kraljič, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
Ismael Luceno, 09/13/2011
- Re: [SM-Discuss] Spell branches, Bor Kraljič, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/12/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/12/2011
-
Re: [SM-Discuss] Spell branches,
Ismael Luceno, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
Ismael Luceno, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/13/2011
- Re: [SM-Discuss] Spell branches, Ismael Luceno, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
Ismael Luceno, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
flux, 09/13/2011
-
Re: [SM-Discuss] Spell branches,
Ismael Luceno, 09/13/2011
Archive powered by MHonArc 2.6.24.