Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master quill by Jaka Kranjc (a31ff56922df86ae1447a5d3cc327441c2f41099)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT mail.sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master quill by Jaka Kranjc (a31ff56922df86ae1447a5d3cc327441c2f41099)
  • Date: Sun, 21 Jan 2007 12:05:51 -0600

GIT changes to master quill by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

usr/bin/quill | 44 ++++++++++++++++------
var/lib/quill/ChangeLog | 11 +++++
var/lib/quill/modules/libcore | 2 -
var/lib/quill/modules/libupdate | 77
++++++++++++++++++++++++++--------------
4 files changed, 95 insertions(+), 39 deletions(-)

New commits:
commit a31ff56922df86ae1447a5d3cc327441c2f41099
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

* quill: improved version, hash matching and error handling
added reconfigure query to "Try it out"
skip upstream keys when asking for substitution with hashes
misc gpg and hash changing fixes
* libupdate: update history when incrementing patchlevels
simplified get_sources_and_urls
fixed update_patchlevel and made it add the variable if it isn't
there
added a new function count_spaces for '=' aligning purposes
* libcore: improved quill_edit invocation message

Now it passes the glibc update test! :D

diff --git a/usr/bin/quill b/usr/bin/quill
index 2897fdb..1a2c28f 100755
--- a/usr/bin/quill
+++ b/usr/bin/quill
@@ -155,7 +155,7 @@ then

[[ $ANSWER == "Quit" ]] && exit 0

- if [[ $ANSWER != ${actions[4]} || $ANSWER == ${actions[5]} || $ANSWER ==
${actions[6]} ]]
+ if [[ $ANSWER != ${actions[4]} && $ANSWER != ${actions[5]} && $ANSWER !=
${actions[6]} ]]
then
#copy spell over and move there
codex_get_spell_paths $(codex_find_spell_by_name $SPELL_NAME)
@@ -181,7 +181,7 @@ then
query_spell_version

#save the chosen version
- sed -i "s/\<VERSION=$version\>/VERSION=$SPELL_VERSION/" DETAILS
+ sed -i
"s/\<VERSION=['\"]*${version}['\"]*\s*$/VERSION=$SPELL_VERSION/" DETAILS

#check for multiversion spells
if [[ $(grep -cE "\<SOURCE.?=" DETAILS) != 1 ]]
@@ -245,13 +245,16 @@ then
then
message "Nothing new to summon, all sources found."
else
- summon -r <<< "$to_summon"
+ summon -r <<< "$to_summon" || {
+ message "${PROBLEM_COLOR}Summoning failed, aborting
update!$DEFAULT_COLOR"
+ continue 2; }
fi
+ echo

# ask for SECURITY_PATCHing
update_patchlevel SECURITY_PATCH

- #restore patchlevel?
+ # restore patchlevel
update_patchlevel PATCHLEVEL skip remove

#get hashes and save them, removing any previous hash/gpg
@@ -271,15 +274,28 @@ then
fi

#SOURCE_GPG?
- if ! grep -Eq "(sha(512|256|1)|md5):.*:" <<< "$current_check"
- then #it is a gpg
- if ! query "Do you want to replace SOURCE${i}_GPG with a
hash?" n
+ if ! grep -Eq "(^(sha(512|256|1)|md5):.*|UPSTREAM_KEY)" <<<
"$current_check"
+ then #it is a non-upstream gpg
+ echo "SOURCE${i}_GPG=$current_check"
+ if query "Do you want to replace SOURCE${i}_GPG with a
hash?" n
then
+ #TODO: else sign it and continue
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue
+ else
message "Here is the hash for SOURCE$i anyway, if you need
it later: $hash"
[[ ! $i ]] && i=1
let i+=1
continue
- #TODO: else sign it and continue
+ fi
+ else
+ # UPSTREAM_HASH is rare and probably not fetched - ignoring
+ if grep -q "UPSTREAM_KEY" <<< "$current_check"
+ then
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue
fi
fi

@@ -311,8 +327,9 @@ then
fi

#it is either a SOURCE_HASH or the user wants to replace
SOURCE_GPG
-echo "+$current_check++"
- sed -i
"s/^\(\s*\)SOURCE${i}_[^=]*=['\"]*${current_check}['\"]*\s*$/\1SOURCE${i}_HASH=sha512:$hash/"
DETAILS
+#echo "+$current_check++"
+ new_value=$(count_spaces SOURCE${i}_HASH)
+ sed -i
"s/^.*SOURCE${i}_[^=]*=['\"]*${current_check}['\"]*\s*$/${new_value}SOURCE${i}_HASH=sha512:$hash/"
DETAILS

# remove sigs, trying not to touch any that are still needed
if ! grep -q "VERSION=$version *$" DETAILS;
@@ -341,13 +358,12 @@ echo "+$current_check++"
continue
fi

- echo
rm DETAILS.orig
if query "Do you want to review the update or add custom
modifications?" y
then
quill_edit
+ echo
fi
- echo

echo
message "Done with updating the spell!"
@@ -381,7 +397,11 @@ echo "+$current_check++"
fi
;;
"${actions[6]}") #"Try it out"
+ if query "Do you want to cast -r? (possibly needed for multiversion
spells)" n; then
+ cast -r $SPELL_NAME
+ else
cast -c $SPELL_NAME
+ fi
;;
esac

diff --git a/var/lib/quill/ChangeLog b/var/lib/quill/ChangeLog
index 43dbb53..bdc5049 100644
--- a/var/lib/quill/ChangeLog
+++ b/var/lib/quill/ChangeLog
@@ -1,3 +1,14 @@
+2007-01-21 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * quill: improved version, hash matching and error handling
+ added reconfigure query to "Try it out"
+ skip upstream keys when asking for substitution with hashes
+ misc gpg and hash changing fixes
+ * libupdate: update history when incrementing patchlevels
+ simplified get_sources_and_urls
+ fixed update_patchlevel and made it add the variable if it isn't
there
+ added a new function count_spaces for '=' aligning purposes
+ * libcore: improved quill_edit invocation message
+
2007-01-20 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* quill: improved the parameter parsing and added two shortcuts
(getopts?)
removed redundant message, codex_does_spell_exsist prints its own
diff --git a/var/lib/quill/modules/libcore b/var/lib/quill/modules/libcore
index 1acd00a..dabb7ea 100644
--- a/var/lib/quill/modules/libcore
+++ b/var/lib/quill/modules/libcore
@@ -121,7 +121,7 @@ function quill_welcome() {
function quill_edit() {
local spell_file type

- message "Now invoking $EDITOR to edit spell files."
+ message "Now invoking $EDITOR to edit ${1:-spell files}."
cd ${QUILL_SPELL_DIR}/${SPELL_NAME}
for spell_file in ${1:-*}
do
diff --git a/var/lib/quill/modules/libupdate b/var/lib/quill/modules/libupdate
index 7a88581..21741c8 100644
--- a/var/lib/quill/modules/libupdate
+++ b/var/lib/quill/modules/libupdate
@@ -4,8 +4,8 @@
function get_sources_and_urls()
{
sources_and_urls=$(eval ${if_var:-:}; . DETAILS &> /dev/null;
get_spell_files_and_urls)
- sources=$(sed 's/^\(\S*\)\s.*$/\1/' <<< "$sources_and_urls" )
- source_urls=$(sed 's/^\S*\s\(.\S*\)\s.*$/\1/' <<< "$sources_and_urls" )
+ sources=$(cut -d" " -f1 <<< "$sources_and_urls")
+ source_urls=$(cut -d" " -f2 <<< "$sources_and_urls")
}

#---
@@ -18,28 +18,28 @@ function conditional_set_var()
}

#---
-## @Synopsis Increments or removes PATCHLEVEL or SECURITY_PATCH. Ask first
-## @Synopsis unless the second argument is "skip"
+## @Synopsis Increments or removes PATCHLEVEL or SECURITY_PATCH. Asks first
+## @Synopsis unless the second argument is "skip". Adds variable if
necessary.
##
## @param PATCHLEVEL or SECURITY_PATCH - work with which wone?
## @param (optional) skip the query? skip to skip
-## @param (optional) remove or increment? remove to remove
+## @param (optional) remove, increment, add? remove to remove
## @param (optional) default answer for the query, default is n
#---
function update_patchlevel()
{
- local current_value
+ local current_value=$(conditional_set_var $1)

- current_value=$(conditional_set_var $1)
- if [[ ! -z $current_value ]]
+ if [[ -z $current_value ]]
then
- if [[ $2 != skip ]]
+ [[ $3 == remove ]] && message "${PROBLEM_COLOR}remove or
add?$DEFAULT_COLOR" && return 1
+ if [[ $2 == skip ]] || query "Do you want to add $1?" ${4:-n}
+ then
+ update_patchlevel_sub $1 none add
+ fi
+ else
+ if [[ $2 == skip ]] || query "Do you want to increment $1?" ${4:-n}
then
- if query "Do you want to increment $1?" ${4:-n}
- then
- update_patchlevel_sub $1 $current_value $3
- fi
- else
update_patchlevel_sub $1 $current_value $3
fi
fi
@@ -47,22 +47,48 @@ function update_patchlevel()

function update_patchlevel_sub()
{
- local current_value=$2 action=$3 new_value
- new_value=$(( current_value+=1 ))
+ local current_value=$2 action=$3 new_value count

- if (( $(grep -c "^[^#]*$1=['\"]*${current_value}['\"]*" DETAILS) > 1 ))
+ if [[ $current_value == none ]]
then
- message "Two or more $1 variables with the same value found."
- message "All will be changed - revert the bad ones manually."
- fi
- if [[ $action != remove ]]
- then
- sed -i "/^[^#]*$1=['\"]*${current_value}['\"]*/ s,=.*$,=$new_value,"
DETAILS
- else #PATCHLEVEL removal on version updates
- sed -i "/^[^#]*$1=['\"]*${current_value}['\"]*/d" DETAILS
+ new_value=$(count_spaces $1)
+ sed -i "s,VERSION=$SPELL_VERSION,&\n$new_value$1=1," DETAILS
+ add_history_entry "DETAILS: $1++"
+ else
+ new_value=$(( current_value + 1 ))
+ count=$(grep -c "^[^#]*$1=['\"]*${current_value}['\"]* *$" DETAILS)
+ if (( $count > 1 ))
+ then
+ echo
+ message "Two or more $1 variables with the same value found."
+ message "All will be changed - revert the bad ones manually."
+ echo
+ fi
+ if [[ $action == remove ]]
+ then #PATCHLEVEL removal on version updates
+ sed -i "/^[^#]*$1=['\"]*${current_value}['\"]*/d" DETAILS
+ else
+ sed -i "/^[^#]*$1=['\"]*${current_value}['\"]*/ s,=.*$,=$new_value,"
DETAILS
+ add_history_entry "DETAILS: $1++"
+ fi
fi
}

+#---
+## @Synopsis Compute how to insert $1, so = will be aligned properly
+##
+## @return string with adequate number of spaces
+#---
+function count_spaces()
+{
+ local count spaces eq_col
+ eq_col=$(awk -F '=' '{ print length($1); exit}' DETAILS)
+ count=$(( $eq_col - ${#1} ))
+ for (( i=0 ; i<$count; i++ )) ; do
+ spaces="$spaces "
+ done
+ echo "$spaces"
+}

#---
## @Synopsis Copies the spell to $QUILL_GIT_DIR
@@ -93,7 +119,6 @@ function copy_to_git()
rm -r "$GRIMOIRE2/$SECTION2/$SPELL_NAME"/*

quill_final_put_in_grimoire "$GRIMOIRE2" "$SECTION2" no
- echo
}

#---



  • [SM-Commit] GIT changes to master quill by Jaka Kranjc (a31ff56922df86ae1447a5d3cc327441c2f41099), Jaka Kranjc, 01/21/2007

Archive powered by MHonArc 2.6.24.

Top of Page