#!/bin/bash # # Written by Benjamin Schieder # Modified by Juergen Sawinski to create # a package based on freshmeat info # # Use: # newpackage.sh [-main] / # # will create .desc and .conf. .desc will contain the [D] and [COPY] # already filled in. The other tags are mentioned with TODO. # # .conf will contain an empty _main() { } and custmain="_main" # if -main is specified. # # --- ROCK-COPYRIGHT-NOTE-BEGIN --- # # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # Please add additional copyright information _after_ the line containing # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by # the ./scripts/Create-CopyPatch script. Do not edit this copyright text! # # ROCK Linux: rock-src/misc/archive/fmnewpackage.sh # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf # # 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; either version 2 of the License, or # (at your option) any later version. A copy of the GNU General Public # License can be found at Documentation/COPYING. # # Many people helped and are helping developing ROCK Linux. Please # have a look at https://www.rocklinux.org/ and the Documentation/TEAM # file for details. # # --- ROCK-COPYRIGHT-NOTE-END --- # extract_xml_name() { local tmp="`tr -d "\012" < $2 | grep $3 | sed "s,.*<$3>\([^<]*\)<.*,\1," | sed 's, ,\n[T] ,g' | sed 's,^\[T\] $,,'`" eval "$1=\"\$tmp\"" } get_download() { local location download_file="" download_url="" for arg; do if curl -s -I -f "$arg" -o "header.log"; then location="`grep Location: header.log | sed -e 's,Location:[ ]\([.0-9A-Za-z:/% -]*\).*,\1,' -e 's,prdownloads.sourceforge.net,dl.sourceforge.net,'`" download_file="`basename $location`" download_url="`dirname $location`/" 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 "https://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 '' $fmname.xml | sed 's,.*\(.*\),\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="https://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" found=0 while read line ; do if [ ${found} -eq 1 ] ; then dev_name="`echo ${line} | sed 's,^ *,,g' | cut -f1,2 -d' '`" fi if [ "${line//Author:/}" != "${line}" ] ; then found=1 else found=0 fi done < ${fmname}.html dev_mail="`grep 'contact developer' "$fmname.html" | sed 's,^.*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_mail" -o -z "$dev_name" ] ; then dev_name="TODO: " dev_mail="Author" 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 ;; esac rm -f $fmname.xml else return 1 fi } if [ "$1" == "-main" ] ; then create_main=1 shift fi if [ $# -lt 2 -o $# -gt 2 ] ; then cat <<-EEE Usage: $0