Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] patch to quill for freshmeat.net

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Andrew <afrayedknot AT thefrayedknot.armory.com>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] patch to quill for freshmeat.net
  • Date: Thu, 23 Jun 2005 23:49:07 -0700

Oops, I stupidly made the patch in reverse, here it is non-reversed.


--
__________________________________________________________________________
|Andrew D. Stitt | astitt at sourcemage.org |
|irc: afrayedknot | afrayedknot at t.armory.com |
|aim: thefrayedknot or iteratorplusplus | acedit at armory.com |
|Sorcery Team Lead | ftp://t.armory.com/ |
--------------------------------------------------------------------------
--- quill 2005-05-17 21:37:17.000000000 -0700
+++ quill 2005-06-23 23:17:11.000000000 -0700
@@ -42,6 +42,23 @@

}

+function grab_from_xml() {
+ xml_grep --text_only $1 $FRESHMEAT_FILE
+}
+
+
+function hunt_src_url() {
+ local URL
+ local SPELL_NAME=$1
+ URL=$(curl -I $2 2>/dev/null|grep Location|awk '{print $2}'|sed 's/\r//g')
+ # hacky attempt to get source url from sourceforge
+ if echo $URL|grep -q sourceforge; then
+ curl $URL 2>/dev/null|tr '<>' '\n\n'|grep http|grep sourceforge|grep
download|grep -i $SPELL_NAME|
+ cut -f2 -d\"|cut -f1 -d?|head -n 1
+ else
+ echo $URL
+ fi
+}

#---
## Some basic stuff that should be loaded and set
@@ -86,6 +103,39 @@
POSTINSTALLISON=""
FINALISON=""

+
+if [[ $1 == --fmxml ]] && [[ $2 ]]; then
+ FRESHMEAT_XML=$2
+ if ! which xml_grep &>/dev/null; then
+ message "You need xml-twig with xml_grep installed to use freshmeat mode"
+ exit 1
+ fi
+ if ! which curl &>/dev/null; then
+ message "You need curl to use freshmeat mode"
+ exit 1
+ fi
+ # if the argument looks like a url then use that, otherwise
+ # assume the argument is the name of the spell and construct a
+ # url for where we think freshmeat.net stores their xml data
+ if echo $FRESHMEAT_XML|grep -q http://; then
+ FRESHMEAT_XML_URL=$FRESHMEAT_XML
+ else
+
FRESHMEAT_XML_URL=http://freshmeat.net/projects-xml/$FRESHMEAT_XML/${FRESHMEAT_XML}.xml
+ fi
+ # check if we already have the xml file, if we dont, download it
+ if test -f $FRESHMEAT_XML.xml ; then
+ FRESHMEAT_FILE=${FRESHMEAT_XML}.xml
+ else
+ if ! url_download $FRESHMEAT_XML_URL ; then
+ message "Failed to get $FRESHMEAT_XML"
+ exit 1
+ fi
+ FRESHMEAT_FILE=$FILE
+ unset FILE
+ fi
+fi
+
+
## Down to here... from here it's question and answer time
#---

@@ -104,26 +154,65 @@
message "space delimited and not coma delimited${DEFAULT_COLOR}"
message
"-----------------------------------------------------------------------------"

-message "${QUERY_COLOR}Please enter the spell name:${DEFAULT_COLOR}"
-read "SPELL_NAME"
-
-message "${QUERY_COLOR}Please enter the url of the source:${DEFAULT_COLOR}"
-read "SPELL_SRC_URL"
-
-message "${QUERY_COLOR}Please enter the license of the
spell:${DEFAULT_COLOR}"
-read "SPELL_LICENSE"
-
-message "${QUERY_COLOR}Please enter a website for the spell:${DEFAULT_COLOR}"
-read "SPELL_URL"
-
-message "${QUERY_COLOR}Please enter a short description of the
spell:${DEFAULT_COLOR}"
-read "SPELL_SHORT_DESCRIPTION"
-
-message "${QUERY_COLOR}Please enter a description of the
spell:${DEFAULT_COLOR}"
-sleep 2
-message "${PROBLEM_COLOR}!!!PRESS ENTER TO CONTINUE!!!${DEFAULT_COLOR}"
-read
-${EDITOR:-nano} ~/tmp/${SPELL_NAME}
+# fill in variables from xml file
+if [[ $FRESHMEAT_XML ]] ; then
+ SPELL_NAME=$(grab_from_xml projectname_short|tr 'A-Z' 'a-z')
+ for each in url_bz2 url_tgz; do
+ TMP=$(grab_from_xml $each)
+ if [[ $TMP ]] ; then
+ SPELL_SRC_URL=$(hunt_src_url $SPELL_NAME $TMP)
+ break
+ fi
+ done
+ SPELL_URL=$(curl -I $(grab_from_xml url_homepage) 2>&1|grep Location|awk
'{print $2}'|sed 's/\r//g')
+ SPELL_LICENSE=$(grab_from_xml license|awk '{print $NF}'|tr -d '()')
+ SPELL_SHORT_DESCRIPTION=$(grab_from_xml desc_short|sed 's/\r//g')
+ grab_from_xml desc_full|fmt > ~/tmp/${SPELL_NAME}
+fi
+
+# for all the fields that could be filled in, check if they were filled in
+# and if so, give the user an opportunity to change the value
+if ! [[ $SPELL_NAME ]] ||
+ ! query "Is $SPELL_NAME the proper spell name?" y; then
+ message "${QUERY_COLOR}Please enter the spell name:${DEFAULT_COLOR}"
+ read "SPELL_NAME"
+fi
+
+if ! [[ $SPELL_SRC_URL ]] ||
+ ! query "Is $SPELL_SRC_URL the proper source url?" y; then
+ message "${QUERY_COLOR}Please enter the url of the source:${DEFAULT_COLOR}"
+ read "SPELL_SRC_URL"
+fi
+
+if ! [[ $SPELL_LICENSE ]] ||
+ ! query "Is $SPELL_LICENSE the proper license?" y; then
+ message "${QUERY_COLOR}Please enter the license of the
spell:${DEFAULT_COLOR}"
+ read "SPELL_LICENSE"
+fi
+
+if ! [[ $SPELL_URL ]] ||
+ ! query "Is $SPELL_URL the proper website?" y; then
+ message "${QUERY_COLOR}Please enter a website for the
spell:${DEFAULT_COLOR}"
+ read "SPELL_URL"
+fi
+
+if ! [[ $SPELL_SHORT_DESCRIPTION ]] ||
+ ! ( message "${QUERY_COLOR}Is${DEFAULT_COLOR}\n$SPELL_SHORT_DESCRIPTION"
+ query "the proper short description?${DEFAULT_COLOR}" y ; ) ; then
+ message "${QUERY_COLOR}Please enter a short description of the
spell:${DEFAULT_COLOR}"
+ read "SPELL_SHORT_DESCRIPTION"
+fi
+
+if ! test -f ~/tmp/${SPELL_NAME} ||
+ ! ( message "${QUERY_COLOR}Is${DEFAULT_COLOR}"
+ cat ~/tmp/${SPELL_NAME}
+ query "the proper long description?${DEFAULT_COLOR}" y ; ) ; then
+ message "${QUERY_COLOR}Please enter a description of the
spell:${DEFAULT_COLOR}"
+ sleep 2
+ message "${PROBLEM_COLOR}!!!PRESS ENTER TO CONTINUE!!!${DEFAULT_COLOR}"
+ read
+ ${EDITOR:-nano} ~/tmp/${SPELL_NAME}
+fi

message "${QUERY_COLOR}Please enter the dependencies(non optional) of the
spell if any:${DEFAULT_COLOR}"
read "SPELL_DEPENDENCIES"

Attachment: pgpvMfMbr7m7y.pgp
Description: PGP signature




Archive powered by MHonArc 2.6.24.

Top of Page