Skip to Content.
Sympa Menu

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

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 (efcda610bad3f975d8956775c41db33057695f32)
  • Date: Tue, 13 Mar 2007 11:23:06 -0500

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

todo | 10 --
usr/bin/quill | 189
--------------------------------------
var/lib/quill/ChangeLog | 5 +
var/lib/quill/modules/libcore | 30 ++++--
var/lib/quill/modules/libhistory | 2
var/lib/quill/modules/libupdate | 191
+++++++++++++++++++++++++++++++++++++++
var/lib/quill/version | 2
7 files changed, 226 insertions(+), 203 deletions(-)

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

* libhistory: escape & so sed doesn't print the previous header again
* quill: moved a big chunk of update mode to libupdate
* libupdate: added main_update_loop and check_url

diff --git a/todo b/todo
index 01a68fb..6de9474 100644
--- a/todo
+++ b/todo
@@ -6,7 +6,7 @@ new menu choices

* 'Add another version'
branches
- SCM: wierd versions; also needs the autoupdate stuff
+ SCM: wierd versions; also needs the autoupdate stuff; only for -w

* 'Convert to upstream signing'
try automatically on updates (check for .sig)?
@@ -14,7 +14,6 @@ new menu choices
* 'list/remove files?'

update mode:
- * create a main_update_loop and use it in the patching case too
* clean the namespace by moving more stuff into functions, using locals and
documenting global vars used in all functions

@@ -22,12 +21,11 @@ improvements in the standard mode:
* use some of the functions from update mode,
especially the verification stuff
* handle bad entries and ^C better
- * use summon and more of the sorcery code?
- * don't use summon. as it should be able to be run without root privs.

fmxml:
- * improve the speed, dump xml-grep?
- Erm planning to implement own XML parser?
+ * improve the speed
+ * dump xml-grep (awk, sed)?
+ * redo html parsing

documentation:
* write a manpage
diff --git a/usr/bin/quill b/usr/bin/quill
index 11cd561..876e5ae 100755
--- a/usr/bin/quill
+++ b/usr/bin/quill
@@ -183,177 +183,11 @@ then
case "$ANSWER" in
"${actions[0]}") #"Update the spell to a newer version"

- #fetch current versions, ignoring SCM ones
- versions=( $(sed -n 's/\s*\<VERSION=//p' DETAILS |
- grep -Eiv '\$[(]date *+|cvs|svn|tla|git|scm' | sort |
uniq) )
- [[ -z ${versions[@]} ]] && error_msg "No versions to update!" &&
continue
- message "Current relevant version(s): ${versions[@]}"
-
- update_counter="${#versions[@]}"
- #suggest the new one from fm and/or ask for input
- for version in "${versions[@]}"
- do
- if query "Do you want to update $version?" y
- then
- query_spell_version
- [[ -z $SPELL_VERSION ]] && error_msg "Empty VERSION!" &&
continue 2
-
- #save the chosen version
- sed -i "s/\sVERSION=['\"]*${version}['\"]*\s*$/
VERSION=$SPELL_VERSION/" DETAILS
- SPELL_UPDATED=y
-
- #check for multiversion spells
- multiversion_check
-
- # parse the (usually new) source urls
- get_sources_and_urls
-
- while ! check_source_urls; do
- get_sources_and_urls
- done
- # do it again, needed if the source suffix was changed
- get_sources_and_urls
- echo
-
- message "Summoning ..."
- #download; we are not a grimoire so some hacking is needed
- # also workaround sorcery bug #13412
- to_summon="$sources_and_urls"
- for source in $sources
- do
- [[ -e $SOURCE_CACHE/$source ]] &&
- to_summon="$(sed "/^$source /d" <<< "$to_summon")"
- done
- if [[ -z $to_summon ]]
- then
- message "Nothing new to summon, all sources found."
- else
- if ! summon -r <<< "$to_summon"
- then
- error_msg "Summoning failed, aborting update!"
- query "Do you want to edit DETAILS? (you can retry the
update)" n && quill_edit DETAILS
- continue 2
- fi
- fi
- echo
-
- #update HISTORY - already here, so that the patchlevels come
later
- add_history_entries "DETAILS: updated ${if_var:-spell} to
$SPELL_VERSION"
- echo
-
- # ask for SECURITY_PATCHing
- update_patchlevel SECURITY_PATCH
-
- # restore patchlevel
- update_patchlevel PATCHLEVEL skip remove
-
- # remove UPDATED if any
- sed -i "/^\s*UPDATED=/d" DETAILS
-
- #get hashes and save them, removing any previous hash/gpg
- i=
- for source in $sources
- do
- hash=$(quill_hash_get $SOURCE_CACHE/$source)
- # use the original DETAILS, as we already changed the VERSION
- current_check=$(eval ${if_var:-:}; . DETAILS.orig &>
/dev/null; eval echo
\$SOURCE${i}_HASH\$SOURCE${i}_GPG\$SOURCE${i}_IGNORE\$\{MD5[${i:-0}]\})
-
- if [[ -z $current_check ]]
- then
- error_msg "Missing
SOURCE${i}_HASH/SOURCE${i}_GPG/SOURCE${i}_IGNORE"
- message "Add the appropriate one to the spell!"
- [[ ! $i ]] && i=1
- let i+=1
- continue
- fi
-
- #skip SOURCE_IGNORE
- if grep -Eq "volatile|signature|unversioned" <<<
"$current_check"
- then
- [[ ! $i ]] && i=1
- let i+=1
- continue
- fi
-
- # MD5? These contain no :
- if ! grep -q ":" <<< "$current_check"
- then
- new_value=$(count_spaces SOURCE${i}_HASH)
- sed -i
"s/^.*MD5\[${i:-0}\]=['\"]*${current_check}['\"]*\s*$/${new_value}SOURCE${i}_HASH=sha512:$hash/"
DETAILS
- remove_old_sigs "$version"
-
- [[ ! $i ]] && i=1
- let i+=1
- continue
- fi
-
- #SOURCE_GPG?
- if grep -Eq "(^(sha(512|256|1)|md5):.*|UPSTREAM_KEY)" <<<
"$current_check"
- then
- # 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
- # otherwise just do nothing, SOURCE_HASH handling comes next
- else
- #it is a non-upstream gpg
- echo "SOURCE${i}_GPG=$current_check"
- if ! grep -q "gurus.gpg" <<< "$current_check"
- then
- error_msg "This looks like an upstream keyring and should
be marked as such."
- error_msg "Probably with :UPSTREAM_KEY at the end of the
$current_check."
- error_msg "Do not replace it!"
- fi
- if ! query "Do you want to replace SOURCE${i}_GPG with a
hash?" n
- then
- # sign it and continue
- gpg --default-key $GURU_GPGKEY -v --digest-algo SHA512 -o
$QUILL_SPELL_DIR/$SPELL_NAME/$source.sig --detach-sign $SOURCE_CACHE/$source
- echo
- remove_old_sigs "$version"
-
- [[ ! $i ]] && i=1
- let i+=1
- continue
- fi
- fi
-
- # it is either a SOURCE_HASH or the user wants to replace
SOURCE_GPG
- # SOURCE_GPG usually has unexpanded variables, while we have
the expanded
- unexpand_source_gpg || {
- [[ ! $i ]] && i=1
- let i+=1
- continue; }
-
-
- #it is either a SOURCE_HASH or the user wants to replace
SOURCE_GPG
- 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
- remove_old_sigs "$version"
-
- [[ ! $i ]] && i=1
- let i+=1
- done
-
- echo
- else
- let update_counter-=1
- fi
- done
-
- if [[ $update_counter == 0 ]];
- then # there were no updates
- continue
- fi
+ main_update_loop version_bump

# check if WEB_SITE is reachable
WEB_SITE=$(. DETAILS &> /dev/null; echo $WEB_SITE)
- if wget -S --spider "$WEB_SITE" 2>&1 | grep -Eq "ERROR 404|service
not known|301 Moved"
- then
+ if ! check_url "$WEB_SITE"; then
error_msg "The website is not reachable: $WEB_SITE"
message "Fix it."
sleep 3
@@ -378,24 +212,7 @@ then
add_user_history_entries
;;
"${actions[2]}") #"Increment/add PATCHLEVEL or SECURITY_PATCH"
- #fetch current versions, ignoring SCM ones
- versions=( $(sed -n 's/\s*\<VERSION=//p' DETAILS |
- grep -Eiv '\$[(]date *+|cvs|svn|tla|git|scm' | sort |
uniq) )
- [[ -z ${versions[@]} ]] && error_msg "No versions to update!" &&
continue
-
- message "Current relevant version(s): ${versions[@]}"
-
- for version in "${versions[@]}"
- do
- if query "Do you want to do it for $version?" y
- then
- SPELL_VERSION="$version"
- update_patchlevel PATCHLEVEL
- update_patchlevel SECURITY_PATCH
- message "Done."
- SPELL_UPDATED=y
- fi
- done
+ main_update_loop user_increment_patchlevel
;;
# "${actions[2]}") #"Add another version"
#SCM or branch?
diff --git a/var/lib/quill/ChangeLog b/var/lib/quill/ChangeLog
index 46d42b0..a034165 100644
--- a/var/lib/quill/ChangeLog
+++ b/var/lib/quill/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-12 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libhistory: escape & so sed doesn't print the previous header again
+ * quill: moved a big chunk of update mode to libupdate
+ * libupdate: added main_update_loop and check_url
+
2007-03-11 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* quill: loop until the source urls are fixed
* libcore: made check_source_urls have a consistent return value
diff --git a/var/lib/quill/modules/libcore b/var/lib/quill/modules/libcore
index 7350794..4884f03 100644
--- a/var/lib/quill/modules/libcore
+++ b/var/lib/quill/modules/libcore
@@ -396,14 +396,8 @@ function check_source_url() {
rc=$?
elif grep -q http:// <<< "$su"
then
- # the return value acrobatics make both blocks return the same
- wget -S --spider "$su" 2>&1 | grep -Eq "ERROR 404|service not known|301
Moved"
- if [[ $? == 0 ]]
- then
- rc=1
- else
- rc=0
- fi
+ check_url "$su"
+ rc=$?
else
message "SOURCE${i}_URL[0] is not a http or ftp link, assuming it works."
rc=0
@@ -413,6 +407,25 @@ function check_source_url() {
}

#---
+## @Synopsis checks if the url is reachable
+##
+## @param url
+##
+## @return 0 if it is ok
+## @return 1 otherwise
+#---
+function check_url() {
+ wget -S --spider "$1" 2>&1 | grep -Eq "ERROR 404|service not known|301
Moved"
+ # reverse the return value, so the function returns 0 on succes
+ if [[ $? == 1 ]]
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
+#---
## @Synopsis dumps the default spell file function, taking into
## account that devel has a new spell file inheritance scheme
#---
@@ -503,7 +516,6 @@ function clear_html_specials(){
sed -i -f ${QUILL_MODULES}/html_specials.list $file
}

-
#---
## @Synopsis prints a colored error message
#---
diff --git a/var/lib/quill/modules/libhistory
b/var/lib/quill/modules/libhistory
index 413503d..3aaed57 100644
--- a/var/lib/quill/modules/libhistory
+++ b/var/lib/quill/modules/libhistory
@@ -68,7 +68,7 @@ function add_user_history_entries()
while true; do
query_string entry "What do you want to add? "
[[ -z $entry ]] && break
- add_history_entry "$entry"
+ add_history_entry "${entry//&/\&}"
modified=1
done
echo
diff --git a/var/lib/quill/modules/libupdate b/var/lib/quill/modules/libupdate
index ae98ab9..7a13b85 100644
--- a/var/lib/quill/modules/libupdate
+++ b/var/lib/quill/modules/libupdate
@@ -266,6 +266,8 @@ function ask_and_copy_over()
#---
## @Synopsis Checks if the spell is multiversioned and sets the delimiter
## @Synopsis variable (if_var) if it is
+##
+## @Globals "versions" "version"
#---
function multiversion_check()
{
@@ -281,6 +283,195 @@ function multiversion_check()
}

#---
+## @Synopsis Increment/add PATCHLEVEL or SECURITY_PATCH for any valid version
+##
+## @Globals SPELL_VERSION SPELL_UPDATED "version"
+#---
+function user_increment_patchlevel() {
+ if query "Do you want to do it for $version?" y; then
+ SPELL_VERSION="$version"
+ update_patchlevel PATCHLEVEL
+ update_patchlevel SECURITY_PATCH
+ message "Done."
+ SPELL_UPDATED=y
+ fi
+}
+
+#---
+## @Synopsis The core function that ties all the version update stuff
+##
+## @Globals SPELL_VERSION SPELL_UPDATED GURU_GPGKEY QUILL_SPELL_DIR "version"
+#---
+function version_bump() {
+ local update_counter="${#versions[@]}" if_var
+ local to_summon sources_and_urls sources source_urls source
+ local hash current_check i new_value
+ if query "Do you want to update $version?" y; then
+ query_spell_version
+ [[ -z $SPELL_VERSION ]] && error_msg "Empty VERSION!" && continue 2
+
+ #save the chosen version
+ sed -i "s/\sVERSION=['\"]*${version}['\"]*\s*$/ VERSION=$SPELL_VERSION/"
DETAILS
+ SPELL_UPDATED=y
+
+ #check for multiversion spells
+ multiversion_check
+
+ # parse the (usually new) source urls
+ get_sources_and_urls
+
+ while ! check_source_urls; do
+ get_sources_and_urls
+ done
+ # do it again, needed if the source suffix was changed
+ get_sources_and_urls
+ echo
+
+ message "Summoning ..."
+ #download; we are not a grimoire so some hacking is needed
+ # also workaround sorcery bug #13412
+ to_summon="$sources_and_urls"
+ for source in $sources; do
+ [[ -e $SOURCE_CACHE/$source ]] &&
+ to_summon="$(sed "/^$source /d" <<< "$to_summon")"
+ done
+ if [[ -z $to_summon ]]; then
+ message "Nothing new to summon, all sources found."
+ else
+ if ! summon -r <<< "$to_summon"; then
+ error_msg "Summoning failed, aborting update!"
+ query "Do you want to edit DETAILS? (you can retry the update)" n &&
quill_edit DETAILS
+ continue 2
+ fi
+ fi
+ echo
+
+ #update HISTORY - already here, so that the patchlevels come later
+ add_history_entries "DETAILS: updated ${if_var:-spell} to $SPELL_VERSION"
+ echo
+
+ # ask for SECURITY_PATCHing
+ update_patchlevel SECURITY_PATCH
+
+ # restore patchlevel
+ update_patchlevel PATCHLEVEL skip remove
+
+ # remove UPDATED if any
+ sed -i "/^\s*UPDATED=/d" DETAILS
+
+ #get hashes and save them, removing any previous hash/gpg
+ i=
+ for source in $sources; do
+ hash=$(quill_hash_get $SOURCE_CACHE/$source)
+ # use the original DETAILS, as we already changed the VERSION
+ current_check=$(eval ${if_var:-:}; . DETAILS.orig &> /dev/null; eval
echo \$SOURCE${i}_HASH\$SOURCE${i}_GPG\$SOURCE${i}_IGNORE\$\{MD5[${i:-0}]\})
+
+ if [[ -z $current_check ]]; then
+ error_msg "Missing SOURCE${i}_HASH/SOURCE${i}_GPG/SOURCE${i}_IGNORE"
+ message "Add the appropriate one to the spell!"
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue
+ fi
+
+ #skip SOURCE_IGNORE
+ if grep -Eq "volatile|signature|unversioned" <<< "$current_check"; then
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue
+ fi
+
+ # MD5? These contain no :
+ if ! grep -q ":" <<< "$current_check"; then
+ new_value=$(count_spaces SOURCE${i}_HASH)
+ sed -i
"s/^.*MD5\[${i:-0}\]=['\"]*${current_check}['\"]*\s*$/${new_value}SOURCE${i}_HASH=sha512:$hash/"
DETAILS
+ remove_old_sigs "$version"
+
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue
+ fi
+
+ #SOURCE_GPG?
+ if grep -Eq "(^(sha(512|256|1)|md5):.*|UPSTREAM_KEY)" <<<
"$current_check"; then
+ # 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
+ # otherwise just do nothing, SOURCE_HASH handling comes next
+ else
+ #it is a non-upstream gpg
+ echo "SOURCE${i}_GPG=$current_check"
+ if ! grep -q "gurus.gpg" <<< "$current_check"; then
+ error_msg "This looks like an upstream keyring and should be
marked as such."
+ error_msg "Probably with :UPSTREAM_KEY at the end of the
$current_check."
+ error_msg "Do not replace it!"
+ fi
+ if ! query "Do you want to replace SOURCE${i}_GPG with a hash?" n;
then
+ # sign it and continue
+ gpg --default-key $GURU_GPGKEY -v --digest-algo SHA512 -o
$QUILL_SPELL_DIR/$SPELL_NAME/$source.sig --detach-sign $SOURCE_CACHE/$source
+ echo
+ remove_old_sigs "$version"
+
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue
+ fi
+ fi
+
+ # it is either a SOURCE_HASH or the user wants to replace SOURCE_GPG
+ # SOURCE_GPG usually has unexpanded variables, while we have the
expanded
+ unexpand_source_gpg || {
+ [[ ! $i ]] && i=1
+ let i+=1
+ continue; }
+
+
+ #it is either a SOURCE_HASH or the user wants to replace SOURCE_GPG
+ 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
+ remove_old_sigs "$version"
+
+ [[ ! $i ]] && i=1
+ let i+=1
+ done
+
+ echo
+ else
+ let update_counter-=1
+ fi
+ [[ $update_counter == 0 ]] && continue 2 # there were no updates
+
+}
+
+
+#---
+## @Synopsis Loops over relevant spell versions and runs the passed command
+## @Synopsis over each version
+##
+## @Globals none
+#---
+function main_update_loop() {
+ local version versions=()
+
+ #fetch current versions, ignoring SCM ones
+ versions=( $(sed -n 's/\s*\<VERSION=//p' DETAILS |
+ grep -Eiv '\$[(]date *+|cvs|svn|tla|git|scm' | sort | uniq) )
+ [[ -z ${versions[@]} ]] && error_msg "No versions to update!" && continue
+
+ message "Current relevant version(s): ${versions[@]}"
+
+ for version in "${versions[@]}"; do
+ $1
+ done
+
+}
+
+#---
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
diff --git a/var/lib/quill/version b/var/lib/quill/version
index b9cef5b..5fbdf42 100644
--- a/var/lib/quill/version
+++ b/var/lib/quill/version
@@ -1 +1 @@
-0.2.4-rc6
+0.2.4-rc7



  • [SM-Commit] GIT changes to master quill by Jaka Kranjc (efcda610bad3f975d8956775c41db33057695f32), Jaka Kranjc, 03/13/2007

Archive powered by MHonArc 2.6.24.

Top of Page