[SM-Commit] GIT changes to master quill by Alexander Tsamutali (38c7927b153c9085114c2fbf7d79540dd7f1a8d7)

Alexander Tsamutali scm at sourcemage.org
Tue Aug 14 15:12:36 EDT 2007


GIT changes to master quill by Alexander Tsamutali <astsmtl at gmail.com>:

 usr/bin/quill                      |    9 +++
 var/lib/quill/ChangeLog            |    6 ++
 var/lib/quill/modules/libcore      |    1 
 var/lib/quill/modules/libhackagedb |  104 +++++++++++++++++++++++++++++++++++++
 var/lib/quill/version              |    2 
 5 files changed, 121 insertions(+), 1 deletion(-)

New commits:
commit 38c7927b153c9085114c2fbf7d79540dd7f1a8d7
Author: Alexander Tsamutali <astsmtl at gmail.com>
Commit: Alexander Tsamutali <astsmtl at gmail.com>

    added Haskell HackageDB support

diff --git a/usr/bin/quill b/usr/bin/quill
index 98d9f42..edb2edb 100755
--- a/usr/bin/quill
+++ b/usr/bin/quill
@@ -75,6 +75,10 @@ while [[ -n $1 ]]; do
                   check_parameter $2
                   QUILL_FETCH_MODE="fsf"
                   shift ;;
+  --hackagedb|-H)
+                  check_parameter $2
+                  QUILL_FETCH_MODE="hdb"
+                  shift ;;
      --update|-u)
                   check_parameter $2
                   QUILL_UPDATE="on"
@@ -114,6 +118,11 @@ while [[ -n $1 ]]; do
                   QUILL_UPDATE="on"
                   QUILL_FETCH_MODE="fsf"
                   shift ;;
+         -Hu|-uH)
+                  check_parameter $2
+                  QUILL_UPDATE="on"
+                  QUILL_FETCH_MODE="hdb"
+                  shift ;;
       --purge|-p) QUILL_MODE="purge"; quill_purge $2 ;;
  --apprentice|-a) QUILL_MODE="apprentice" ;;
        --mage|-m) QUILL_MODE="mage" ;;
diff --git a/var/lib/quill/ChangeLog b/var/lib/quill/ChangeLog
index 8d99479..828e63e 100644
--- a/var/lib/quill/ChangeLog
+++ b/var/lib/quill/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-15 Alexander Tsamutali <astsmtl at gmail.com>
+	* quill: added new mode --hackagedb | -H which fetches information
+	  about the package from Haskell HackageDB
+	* libcore: added HackageDB mode to the help message
+	* libhackagedb: new file, provides HackageDB support
+
 2007-08-12 Andraž "ruskie" Levstik <ruskie at mages.ath.cx>
 	* libfsfdirectory: added support for FSF/UNESCO directory
 	  of Free Software
diff --git a/var/lib/quill/modules/libcore b/var/lib/quill/modules/libcore
index c39a746..f2fe7bd 100644
--- a/var/lib/quill/modules/libcore
+++ b/var/lib/quill/modules/libcore
@@ -591,6 +591,7 @@ OPTIONS:
   --savannah, -a <SPELL>		get spell data from the savannah site
   --gna, -g <SPELL>		get spell data from the gna! site
   --fsf, -F <SPELL>		get spell data from the fsf/unesco directory site
+  --hackagedb, -H <SPELL>	get spell data from Haskell HackageDB if possible
   --update, -u <SPELL>		update exsisting spell
   --apprentice, -a		apprentice mode	(default)
   --mage, -m			mage mode (advanced)
diff --git a/var/lib/quill/modules/libhackagedb b/var/lib/quill/modules/libhackagedb
new file mode 100644
index 0000000..39d912d
--- /dev/null
+++ b/var/lib/quill/modules/libhackagedb
@@ -0,0 +1,104 @@
+#---
+## Haskell HackageDB module
+#---
+
+
+#---
+## @Globals none
+#---
+function quill_hdb_get_files(){
+  local package
+  local package_page
+  local cabal_file
+  local cabal_file_path
+
+  package="$1"
+  package_page="$2"
+  cabal_file="$3"
+
+  if [[ ! -e $package_page ]] ; then
+    message "Attempting to retrieve package page..."
+    wget -q -O $package_page \
+         http://hackage.haskell.org/cgi-bin/hackage-scripts/package/${package}/ || \
+         { error_msg "Error: unable to fetch package page";
+           return 1; }
+  else
+    message "Using cached package page..."
+  fi
+  if [[ ! -e $cabal_file ]] ; then
+    cabal_file_path=$(egrep -o "/packages/archive/${package}/.+/${package}\.cabal" $package_page)
+    message "Attempting to retrieve cabal file..."
+    wget -q -O ${cabal_file}.tmp \
+         http://hackage.haskell.org${cabal_file_path} || \
+         { error_msg "Error: unable to fetch cabal file";
+           return 1; }
+    cat ${cabal_file}.tmp | tr '\t' ' ' > $cabal_file
+    rm ${cabal_file}.tmp
+  else
+    message "Using cached cabal file..."
+  fi
+}
+
+#---
+## @Globals none
+#---
+function quill_hdb_get_info(){
+  local info
+  local package_page
+  local cabal_file
+  local desc_here
+  local possible_line
+
+  info="$1"
+  file="$2"
+
+  if [[ "$info" == "src" ]] ; then
+    echo "http://hackage.haskell.org$(egrep -o "/packages/archive/${package}/.+/${package}-.+\.tar.gz" $file)"
+  elif [[ "$info" == "description" ]] ; then
+    cat $file | while IFS="" ; read line ; do
+      if grep -i -q "^description:" <<< "$line" ; then
+        possible_line=$(sed -e "s/^description: *\(.*\)/\1/" <<< $line)
+        if [[ -n "$possible_line" ]] ; then
+          echo $possible_line
+        fi
+        desc_here=True
+      elif [[ -n "$desc_here" ]] && egrep -q "^[[:alpha:]|-]+:" <<< "$line" ; then
+        break
+      elif [[ -n "$desc_here" ]] ; then
+        echo ${line} | sed -e "s/^ *\.\?//"
+      fi
+    done
+  elif [[ "$info" == "build-depends" ]] ; then
+    grep -i "${info}:" $file | sed -e "s/${info}: *\(.*\)/\1/" | \
+    sed -e "s/\([^><=]\+\)[><=]\+[0-9.]\+/\1/g" | tr -d ',' | \
+    sed -e "s/^base \+\| \+base \+\| \+base$/ /" | \
+    sed -e "s/^unix \+\| \+unix \+\| \+unix$/ /"
+  else
+    grep -i "${info}:" $file | sed -e "s/${info}: *\(.*\)/\1/"
+  fi
+}
+
+#---
+## @Globals SPELL_NAME QUILL_TMP_DIR SPELL_LICENSE
+## @Globals SPELL_SHORT_DESCRIPTION SPELL_DESC_NAME
+## @Globals SPELL_URL SPELL_SRC_URL SPELL_DEPENDENCIES
+#---
+function quill_hdb_core(){
+  local package
+  local package_page
+  local cabal_file
+
+  SPELL_NAME="$1"
+  package="$2"
+
+  package_page=${QUILL_TMP_DIR}/${package}.hdb
+  cabal_file=${QUILL_TMP_DIR}/${package}.cabal
+  quill_hdb_get_files "$package" "$package_page" "$cabal_file" || return 1
+  SPELL_LICENSE="$(quill_hdb_get_info  "license" "$cabal_file")"
+  SPELL_SHORT_DESCRIPTION="$(quill_hdb_get_info  "synopsis" "$cabal_file")"
+  SPELL_DESC_NAME=${SPELL_NAME}.desc
+  quill_hdb_get_info "description" "$cabal_file" > ${QUILL_TMP_DIR}/${SPELL_DESC_NAME}
+  SPELL_URL="$(quill_hdb_get_info  "homepage" "$cabal_file")"
+  SPELL_SRC_URL="$(quill_hdb_get_info "src" "$package_page")"
+  SPELL_DEPENDENCIES="ghc "$(quill_hdb_get_info "build-depends" "$cabal_file")
+}
diff --git a/var/lib/quill/version b/var/lib/quill/version
index 877c334..a0de291 100644
--- a/var/lib/quill/version
+++ b/var/lib/quill/version
@@ -1 +1 @@
-0.2.8-rc4
+0.2.8-rc5



More information about the SM-Commit mailing list