Skip to Content.
Sympa Menu

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

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 (843a6a631ffd61b8d94de6638fcf960fe405a6be)
  • Date: Wed, 24 Jan 2007 14:31:01 -0600

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

usr/bin/quill | 46 ++++++++----------------
var/lib/quill/ChangeLog | 8 ++++
var/lib/quill/modules/libcore | 74
+++++++++++++++++++++++++++++++++++----
var/lib/quill/modules/libdetails | 2 -
var/lib/quill/modules/libhistory | 23 ++++++++++++
var/lib/quill/modules/libupdate | 49 +++++++++++++++++++++++--
var/lib/quill/version | 2 -
7 files changed, 162 insertions(+), 42 deletions(-)

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

* libhistory: added add_user_history_entries for adding arbitrary
entries
* quill: factored out ask_and_copy_over, so it is optional and saner
along with some reordering and new menu
* libupdate: added another sanity check, sudo support
* libcore: completed check_source_urls with some wierd code
added sudo support for the few nonsorcery commands that can use it

diff --git a/usr/bin/quill b/usr/bin/quill
index 69527b5..76b0428 100755
--- a/usr/bin/quill
+++ b/usr/bin/quill
@@ -140,37 +140,26 @@ if [[ "$QUILL_UPDATE" == "on" ]]
then
SPELL_NAME=$QUILL_TARGET
codex_does_spell_exist $SPELL_NAME || exit 6
+ ask_and_copy_over || exit 7

while true; do
actions=('Update the spell to a newer version' \
- 'Manage patches' \
- 'Add a SCM version' \
+ 'Add arbitrary HISTORY entries' \
+ 'Add a another version' \
+ 'Copy it here from the grimoire or QUILL_GIT_DIR' \
'Copy it under QUILL_GIT_DIR' \
- 'Copy it back from under QUILL_GIT_DIR' \
'Copy it back to the grimoire' \
'Try it out' \
- 'Quit' )
+ 'Quit' ) #'Manage patches'
echo
query_list "What do you want to do?" ANSWER "Quit" "${actions[@]}"

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

- if [[ $ANSWER != ${actions[3]} && $ANSWER != ${actions[4]} && $ANSWER !=
${actions[5]} && $ANSWER != ${actions[6]} ]]
+ if [[ $ANSWER == ${actions[0]} || $ANSWER == ${actions[1]} || $ANSWER ==
${actions[2]} ]]
then
- #copy spell over and move there
echo
- query_msg "Do you want to copy the spell from the grimoire or
QUILL_GIT_DIR?"
- if query "Answer y for grimoire, n for QUILL_GIT_DIR:" y
- then
- codex_get_spell_paths $(codex_find_spell_by_name $SPELL_NAME)
- cd $QUILL_SPELL_DIR
- rm -fr $QUILL_SPELL_DIR/$SPELL_NAME
- cp -r $SECTION_DIRECTORY/$SPELL_NAME $QUILL_SPELL_DIR
- else
- copy_from_git || continue
- fi
- cd $QUILL_SPELL_DIR/$SPELL_NAME
- cp DETAILS DETAILS.orig
+ [[ -d $QUILL_SPELL_DIR/$SPELL_NAME ]] || ask_and_copy_over || continue
echo
fi
case "$ANSWER" in
@@ -192,7 +181,7 @@ then
[[ -z $SPELL_VERSION ]] && error_msg "Empty VERSION!" &&
continue 2

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

#check for multiversion spells
if [[ ${#versions[@]} != 1 ]]
@@ -351,21 +340,20 @@ then
echo

;;
- "${actions[1]}") #"Manage patches"
-#update patchlevel?
-#update HISTORY
-#copy the spell back to the grimoire?
- echo ++"$ANSWER"++ ;;
- "${actions[2]}") #"Add a \$SCM version"
+ "${actions[1]}") #"Add an arbitrary HISTORY entry"
+ add_user_history_entries
+ ;;
+ "${actions[2]}") #"Add another version"
+#SCM or branch?
#update patchlevel?
#update HISTORY
#copy the spell back to the grimoire?
echo ++"$ANSWER"++ ;;
- "${actions[3]}") #"Copy it to $QUILL_GIT_DIR"
- copy_to_git
+ "${actions[3]}") #"Copy it here from the grimoire or QUILL_GIT_DIR"
+ ask_and_copy_over || continue
;;
- "${actions[4]}") #"Copy it back from under QUILL_GIT_DIR"
- copy_from_git
+ "${actions[4]}") #"Copy it under $QUILL_GIT_DIR"
+ copy_to_git || continue
;;
"${actions[5]}") #"Copy it back to the grimoire"
codex_get_spell_paths $(codex_find_spell_by_name $SPELL_NAME)
diff --git a/var/lib/quill/ChangeLog b/var/lib/quill/ChangeLog
index c020053..81839fd 100644
--- a/var/lib/quill/ChangeLog
+++ b/var/lib/quill/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-23 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libhistory: added add_user_history_entries for adding arbitrary
entries
+ * quill: factored out ask_and_copy_over, so it is optional and saner
+ along with some reordering and new menu
+ * libupdate: added another sanity check, sudo support
+ * libcore: completed check_source_urls with some wierd code
+ added sudo support for the few nonsorcery commands that can use it
+
2007-01-22 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libupdate: use find -regex instead of find and grep
fixed count_spaces for unusual files by making it do statistics
diff --git a/var/lib/quill/modules/libcore b/var/lib/quill/modules/libcore
index b728c77..087c5c2 100644
--- a/var/lib/quill/modules/libcore
+++ b/var/lib/quill/modules/libcore
@@ -85,6 +85,14 @@ function quill_rc() {
query_string GURU_EMAIL "${QUERY_COLOR}Please enter your email for the
HISTORY entries.${DEFAULT_COLOR}" "$GURU_EMAIL"
query_string QUILL_SPELL_DIR "${QUERY_COLOR}Where do you want to store
generated spells (absolute path)?${DEFAULT_COLOR}" "$QUILL_SPELL_DIR"
query_string QUILL_GIT_DIR "${QUERY_COLOR}Where is the dir that contains
your git grimoires if you have any (absolute path)?${DEFAULT_COLOR}"
"$QUILL_GIT_DIR"
+ if query "Do you want to use sudo where possible?" ${QUILL_SUDO:-n}
+ then
+ # we need the bash since we call multiple commands at a time
+ # and sudo doesn't like just sudo -c "ls; ls; ls"
+ QUILL_SUDO="sudo bash"
+ else
+ QUILL_SUDO="su"
+ fi
message "Thank you. Now generating ${QUILL_QUILLRC}"
cat << QUA > $QUILL_QUILLRC
QUILL_CONFIG_VERSION="$quill_version"
@@ -92,6 +100,7 @@ function quill_rc() {
GURU_EMAIL="$GURU_EMAIL"
QUILL_SPELL_DIR="$QUILL_SPELL_DIR"
QUILL_GIT_DIR="$QUILL_GIT_DIR"
+ QUILL_SUDO="$QUILL_SUDO"
QUA
mkdir -p "$QUILL_SPELL_DIR" "$QUILL_GIT_DIR"
exit 0
@@ -221,12 +230,12 @@ function quill_final_put_in_grimoire() {
then
error_msg "Permission problems, trying as root ..."
export QUILL_GRIM_NAME QUILL_SECT_NAME QUILL_SPELL_DIR SPELL_NAME
- su -c "$(declare -f quill_final_put_in_grimoire_sub); \
+ ${QUILL_SUDO:-su} -c "$(declare -f quill_final_put_in_grimoire_sub); \
quill_final_put_in_grimoire_sub $3"
fi
else
export QUILL_GRIM_NAME QUILL_SECT_NAME QUILL_SPELL_DIR SPELL_NAME
- su -c "$(declare -f quill_final_put_in_grimoire_sub); \
+ ${QUILL_SUDO:-su} -c "$(declare -f quill_final_put_in_grimoire_sub); \
quill_final_put_in_grimoire_sub $3"
fi

@@ -260,10 +269,12 @@ function quill_purge() {

#---
## @Synopsis checks if spell source urls are valid
+## @Synopsis and perhaps changes them if they are trivially fixable
#---
function check_source_urls() {
- local su i= oldsu old_source_urls="$source_urls"
+ local i= su old_su oldest_su source old_source

+ message "Checking source urls (this may take a while) ..."
for su in $source_urls
do
check_source_url "$su" "$i"
@@ -272,12 +283,64 @@ function check_source_urls() {
message "SOURCE${i}_URL[0] is ok!"
else
# first retry with a changed suffix
- oldsu="$su"
+ old_su="$su"
[[ ${su/.gz/.bz2} == $su ]] && su="${su/.bz2/.gz}" ||
su="${su/.gz/.bz2}"
if check_source_url "$su" "$i"
then
message "SOURCE${i}_URL[0] is ok after changing the file extension!"
- old_source_urls="${old_source_urls/$oldsu/$su}"
+ # tricky tricky - if we only change the url, it is likely
+ # that the accompanying SOURCE will be bad. So we need to change
+ # SOURCEn too. Or just that, if the url contains it as a variable
+
+ # try to unexpanded the url - maybe changing the source is enough
+ old_source=$(sed -n "s, $old_su,,p" <<< "$sources_and_urls")
+ source="$old_source"
+ if [[ ${source/.gz/.bz2} == $source ]]
+ then
+ source="${source/.bz2/.gz}"
+ else
+ source="${source/.gz/.bz2}"
+ fi
+
+ # we need another one since $old_source would match only $old_su
+ # and we also need the substituted $old_su
+ oldest_su="$old_su"
+ substitute_with_variables old_su "$old_source" {SOURCE$i}
+ if grep -Eq "\.(bz2|gz)$" <<< "$old_su"
+ then
+ # the url most likely does not use SOURCE then
+ # however if it does, lets put the substitutions in anyway
+ # so we change the url in the file; reparsing is the next call
+ # also check if it contains the old expanded VERSION ($version)
+
+ # substitute the longer string first, more likely to give correct
results
+ # think 1.2 and 1.2.1
+ if (( ${#SPELL_VERSION} > ${#version} ))
+ then
+ substitute_with_variables su "$old_source" {SOURCE$i}
"$SPELL_NAME" {SPELL} "$SPELL_VERSION" {VERSION} "$version" {VERSION}
+ else
+ substitute_with_variables su "$old_source" {SOURCE$i}
"$SPELL_NAME" {SPELL} "$version" {VERSION} "$SPELL_VERSION" {VERSION}
+ fi
+
+ # some urls may contain other expanded vars that we are not aware
of
+ if grep -q "$oldest_su" DETAILS
+ then # all is fine
+ sed -i "s,$oldest_su,$su," DETAILS
+ else
+ error_msg "Couldn't find $oldest_su in DETAILS,"
+ error_msg "probably due to it containing nonstandard variables"
+ message "Replace it manually with $su"
+ fi
+ add_history_entry "DETAILS: Changed SOURCE${i}_URL[0] extension"
+ else
+ substitute_with_variables source "$SPELL_NAME" {SPELL}
"$SPELL_VERSION" {VERSION}
+ sed -i "s,$old_source,$source," DETAILS
+ # we don't know if the SOURCE is expanded or not, trying just both
extremes
+ substitute_with_variables old_source "$SPELL_NAME" {SPELL}
"$SPELL_VERSION" {VERSION}
+ sed -i "s,$old_source,$source," DETAILS
+ add_history_entry "DETAILS: Changed SOURCE${i} extension"
+ fi
+
else
# if they are still not ok ask for fixed ones
error_msg "SOURCE${i}_URL[0] is hopelessly broken! Fix it manually."
@@ -288,7 +351,6 @@ function check_source_urls() {
[[ ! $i ]] && i=1
let i+=1
done
- source_urls="$old_source_urls"

}

diff --git a/var/lib/quill/modules/libdetails
b/var/lib/quill/modules/libdetails
index fda44d0..a7384c1 100644
--- a/var/lib/quill/modules/libdetails
+++ b/var/lib/quill/modules/libdetails
@@ -113,7 +113,7 @@ function show_spell_source_file_info(){
#---
## @Synopsis Substitute any number of expanded variables in given variable
## @Synopsis with corresponding variable names
-## @param target variable
+## @param target variable (must not be target or target_value)
## @param the string to search for (variable contents)
## @param the replacement for said string (variable name)
## @param the string to search for (variable contents)
diff --git a/var/lib/quill/modules/libhistory
b/var/lib/quill/modules/libhistory
index 2e05edc..3d01d32 100644
--- a/var/lib/quill/modules/libhistory
+++ b/var/lib/quill/modules/libhistory
@@ -56,6 +56,29 @@ function add_history_entries()
}

#---
+## @Synopsis Adds arbitrary HISTORY entries.
+#---
+function add_user_history_entries()
+{
+ local entry modified
+
+ message "Enter the text without the leading tab, spaces or stars. Example:"
+ message "DETAILS: changed SOURCE3_URL[4]"
+ message "When you're done adding new entries, just hit enter on the next
prompt."
+ while true; do
+ query_string entry "What do you want to add? "
+ [[ -z $entry ]] && break
+ add_history_entry "$entry" && modified=1
+ done
+ echo
+ if [[ $modified == "1" ]]; then
+ query "Do you want to review the HISTORY changes?" n &&
+ quill_edit HISTORY
+ echo
+ fi
+}
+
+#---
##
## 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/modules/libupdate b/var/lib/quill/modules/libupdate
index 192dd66..8acdfa9 100644
--- a/var/lib/quill/modules/libupdate
+++ b/var/lib/quill/modules/libupdate
@@ -1,5 +1,6 @@
#---
## @Synopsis Sets up some global variables that contain sources and urls
+## @Synopsis delimited by newlines
#---
function get_sources_and_urls()
{
@@ -124,6 +125,12 @@ function copy_to_git()
{
copy_git_sub || return 1

+ if [[ ! -e $QUILL_SPELL_DIR/$SPELL_NAME ]]
+ then
+ error_msg "There is nothing to copy back!"
+ return 1
+ fi
+
quill_final_put_in_grimoire "$GRIMOIRE2" "$SECTION2" no
unset GRIMOIRE2 SECTION2
}
@@ -143,7 +150,7 @@ function copy_from_git()
then
cp -r "$GRIMOIRE2/$SECTION2/$SPELL_NAME" "$QUILL_SPELL_DIR"
else
- su -c "cp -r '$GRIMOIRE2/$SECTION2/$SPELL_NAME' '$QUILL_SPELL_DIR'"
+ ${QUILL_SUDO:-su} -c "cp -r '$GRIMOIRE2/$SECTION2/$SPELL_NAME'
'$QUILL_SPELL_DIR'"
fi
unset GRIMOIRE2 SECTION2
cd $QUILL_SPELL_DIR/$SPELL_NAME
@@ -178,7 +185,7 @@ function unexpand_source_gpg()
{
local j

- if grep -q $current_check DETAILS.orig
+ if grep -q "$current_check" DETAILS.orig
then
return 0
else # looks like it is expanded
@@ -194,13 +201,13 @@ function unexpand_source_gpg()
echo $current_check
)
fi
- if grep -q $current_check DETAILS.orig
+ if grep -q "$current_check" DETAILS.orig
then # maybe the author doesn't like the ugly braces too
return 0
else
- current_check="$(tr -d "{}" <<< $current_check)"
+ current_check="$(tr -d "{}" <<< "$current_check")"
fi
- if grep -q $current_check DETAILS.orig
+ if grep -q "$current_check" DETAILS.orig
then
return 0
else # give up
@@ -209,6 +216,38 @@ function unexpand_source_gpg()
fi
}

+#---
+## @Synopsis Ask to copy the spell to our working dir - QUILL_SPELL_DIR
+## @Synopsis If QUILL_SPELL_DIR is empty, just do it
+## @Synopsis It also moves there and does the DETAILS.orig copy
+##
+## @return 0 if everything is ok
+## @return 1 otherwise
+#---
+function ask_and_copy_over()
+{
+ local reply noop_answer="No" # noop_answer needs to be only one word!
+
+ [[ ! -d $QUILL_SPELL_DIR/$SPELL_NAME ]] && unset noop_answer
+
+ #copy spell over and move there
+ query_list "Do you want to copy the spell from someplace?" reply "The
grimoire" "The grimoire" "QUILL_GIT_DIR" $noop_answer
+
+ [[ $reply == $noop_answer ]] && return 0
+ if [[ $reply == "The grimoire" ]]
+ then
+ codex_get_spell_paths $(codex_find_spell_by_name $SPELL_NAME) &&
+ cd $QUILL_SPELL_DIR &&
+ rm -fr $QUILL_SPELL_DIR/$SPELL_NAME &&
+ cp -r $SECTION_DIRECTORY/$SPELL_NAME $QUILL_SPELL_DIR &&
+ message "Done."
+ else
+ copy_from_git &&
+ message "Done."
+ fi &&
+ cd $QUILL_SPELL_DIR/$SPELL_NAME &&
+ cp DETAILS DETAILS.orig || return 1
+}

#---
##
diff --git a/var/lib/quill/version b/var/lib/quill/version
index 7ac4e5e..71d6a66 100644
--- a/var/lib/quill/version
+++ b/var/lib/quill/version
@@ -1 +1 @@
-0.1.13
+0.1.14



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

Archive powered by MHonArc 2.6.24.

Top of Page