OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

171 lines
4.5 KiB

#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: lib/sde-package/.../freshmeat
# Copyright (C) 2006 - 2008 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
#Description: Create based on freshmeat.net information
#Alias: fm
extract_xml_name() {
local tmp="`tr -d "\012" < $2 | grep $3 |
sed -e "s|.*<$3>\([^<]*\)<.*|\1|" -e 's|
|\n|g'`"
eval "$1=\"\$tmp\""
}
get_download() {
for arg; do
if curl -s -I -f "$arg" -o "header.log"; then
location="`sed -n 's/\r// ; s/Location: *//p' header.log`"
rm -f header.log
return
fi
done
rm -f header.log
}
read_fm_config() {
local fmname=$1
curl_options= #--disable-epsv -#
if curl -s -f $resume $curl_options "http://freshmeat.net/projects-xml/$fmname/$fmname.xml" -o "$fmname.xml"; then
extract_xml_name project $fmname.xml projectname_full
extract_xml_name title $fmname.xml desc_short
extract_xml_name desc $fmname.xml desc_full
extract_xml_name urlh $fmname.xml url_homepage
extract_xml_name license $fmname.xml license
extract_xml_name version $fmname.xml latest_release_version
extract_xml_name url_tbz $fmname.xml url_bz2
extract_xml_name url_tgz $fmname.xml url_tgz
extract_xml_name url_zip $fmname.xml url_zip
extract_xml_name url_cvs $fmname.xml url_cvs
url="$(curl -I $urlh 2>/dev/null | grep "^Location:" | sed -e 's,^Location: \(.*\)$,\1,' | tr -d '\015' )"
get_download $url_tbz $url_tgz $url_zip #@FIXME $url_cvs
# grep trove categories for status IDs
for trove_id in `grep '<trove_id>' $fmname.xml | sed 's,.*<trove_id>\(.*\)</trove_id>,\1,g'` ; do
case $trove_id in
9) status="Alpha"
;;
10) status="Beta"
;;
11,12) status="Stable"
;;
# there is no default
esac
done
# download package fm-page and grep for the author
html="http://freshmeat.net/projects/$fmname/"
curl -I -s "$html" -o "header.log"
html_new="`grep Location: header.log | sed 's,Location:[ ]\([.0-9A-Za-z:/%?_= -]*\).*,\1,'`"
[ ! -z "$html_new" ] && html="$html_new"
unset html_new
rm -f header.log
curl -s "$html" -o "$fmname.html"
dev_name="`grep 'contact developer' "$fmname.html" | sed 's,^[[:blank:]]*\(.*\)[[:blank:]]<a.*$,\1,' | sed 's, *$,,g'`"
dev_mail="`grep 'contact developer' "$fmname.html" | sed 's,^.*<a href=\"mailto:\(.*\)\">.*$,\1,'`"
echo "__at__ @" >subst
echo "__dot__ ." >>subst
echo "|at| @" >>subst
echo "|dot| ." >>subst
echo "\\[at\\] @" >>subst
echo "\\[dot\\] ." >>subst
echo "(at) @" >>subst
echo "(dot) ." >>subst
echo -n "$dev_mail" >dev_mail
# for some strange reason, this doesn't work:
# cat subst | while read from to ; do
# export dev_mail="${dev_mail// $from /$to}"
# done
# dev_mail will have the same value as before
cat subst | while read from to ; do
dev_mail="`cat dev_mail`"
dev_mail="${dev_mail// $from /$to}"
echo -n "$dev_mail" >dev_mail
done
dev_mail="`cat dev_mail`"
rm -f subst $fmname.html dev_mail
if [ -z "$dev_name" ]; then
dev_mail=
elif [ -z "$dev_mail" ]; then
dev_mail="TODO: Mail Address"
else
dev_mail="<$dev_mail>"
fi
#cleanup license
case "$license" in
*GPL*Library*)
license=LGPL
;;
*GPL*Documentation*)
license=FDL
;;
*GPL*)
license=GPL
;;
*Mozilla*Public*)
license=MPL
;;
*MIT*)
license=MIT
;;
*BSD*)
license=BSD
;;
*Artistic*)
license=Artistic
;;
esac
rm -f $fmname.xml
else
return 1
fi
}
if [ $# -ne 1 ]; then
echo "Usage: $0 <name>" >&2
exit 1
elif ! read_fm_config "$1"; then
echo "$1: not found in freshmeat" >&2
exit 1
fi
# [I]
title="`echo "$title" | sed 's/^\(.\)/\U\1/ ; s/\.$//'`"
[ -z "$title" ] || echo "[I] $title"
# [T]
desc="`echo "$desc" | sed '1s/^\(.\)/\U\1/ ; s/\. *\(.\)/. \U\1/g'`"
if [ -n "$desc" ]; then
echo "$desc" | fmt --width 75 | sed -e 's,^,[T] ,'
fi
# [U]
[ -z "$url" ] || echo "[U] $url"
# [A]
[ -z "$dev_name$dev_mail" ] || echo "[A] $dev_name $dev_mail"
# [L]
[ -z "$license" ] || echo "[L] $license"
# [S]
[ -z "$status" ] || echo "[S] $status"
# [V]
[ -z "$version" ] || echo "[V] $version"
# [D]
[ -z "$location" ] || echo "[D] $location"