fedora-rpmdevtools fedora-rpmdevtools.spec, 1.73, 1.74 fedora-newrpmspec, 1.4, 1.5

Ville Skytta (scop) fedora-extras-commits at redhat.com
Thu Oct 6 16:04:15 UTC 2005


Author: scop

Update of /cvs/fedora/fedora-rpmdevtools
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11791

Modified Files:
	fedora-rpmdevtools.spec fedora-newrpmspec 
Log Message:
Teach fedora-newrpmspec to detect and use different specfile variants.


Index: fedora-rpmdevtools.spec
===================================================================
RCS file: /cvs/fedora/fedora-rpmdevtools/fedora-rpmdevtools.spec,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- fedora-rpmdevtools.spec	6 Oct 2005 15:59:38 -0000	1.73
+++ fedora-rpmdevtools.spec	6 Oct 2005 16:03:53 -0000	1.74
@@ -134,6 +134,7 @@
 - check-rpaths-worker: give out an hint about usage and the detected issues
   at the first detected error (Enrico Scholz).
 - Remove some redundancy from the Perl spec template.
+- Teach fedora-newrpmspec to detect and use different specfile variants.
 
 * Fri Jul  8 2005 Ville Skyttä <ville.skytta at iki.fi> - 1.1-1
 - Drop more pre-FC2 compat stuff from Perl spec template.


Index: fedora-newrpmspec
===================================================================
RCS file: /cvs/fedora/fedora-rpmdevtools/fedora-newrpmspec,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- fedora-newrpmspec	24 Mar 2005 16:32:39 -0000	1.4
+++ fedora-newrpmspec	6 Oct 2005 16:03:53 -0000	1.5
@@ -2,47 +2,90 @@
 
 # $Id$
 
-SPEC="/usr/share/fedora/spectemplate-minimal.spec"
-
-newrpmspec.help() {
-	echo "fedora-newrpmspec creates a new Fedora spec template"
-	echo ""
-	echo "Usage:"
-	echo "fedora-newrpmspec               without parameter creates a spec template"
-	echo "                                called newpackage.spec"
-	echo "fedora-newrpmspec <app name>    creates a spec template for <app name>"
-        echo "                                called <app name>.spec"	
-	echo "fedora-newrpmspec -h|--help     show this usage information"
-	exit 42
+SPECDIR="/usr/share/fedora"
+DEFTYPE="minimal"
+DEFSPEC="newpackage.spec"
+
+usage() {
+    ret=${1:-0}
+    cat <<EOF
+Usage: fedora-newrpmspec [option]... [appname]
+
+Options:
+  -o FILE  Output the specfile to FILE.  "-" means stdout.  The default is
+           "<appname>.spec", or "$DEFSPEC" if appname is not given.
+  -t TYPE  Force use of the TYPE spec template.  The default is "$DEFTYPE",
+           see $SPECDIR/spectemplate-*.spec for available types.
+  -h       Show this usage message
+EOF
+    exit $ret
 }
 
-newrpmspec.default() {
+appname=
+specfile=
+spectype=
+
+while [ -n "$1" ] ; do
+    case "$1" in
+        -t|--type)
+            shift
+            spectype="$1"
+            ;;
+        -o|--output)
+            shift
+            specfile="$1"
+            ;;
+        -h|--help)
+            usage 0
+            ;;
+        *.spec)
+            [ -z "$specfile" ] && specfile="$1"
+            [ -z "$appname"  ] && appname="$(basename $1 .spec)"
+            ;;
+        *)
+            appname="$1"
+            [ -z "$specfile" ] && specfile="$appname.spec"
+            ;;
+    esac
+    shift
+done
+
+specfilter=
+if [ -z "$spectype" ] ; then
+    case "$appname" in
+        perl-*)
+            spectype=perl
+            cpandist="${appname##perl-}"
+            specfilter="; s/^%setup.*/%setup -q -n $cpandist-%{version}/ \
+               ; s|^\\(URL:\\s*\\).*|\1http://search.cpan.org/dist/$cpandist/|"
+            ;;
+        [Pp]y*)
+            spectype=python
+            ;;
+        *)
+            spectype=$DEFTYPE
+            ;;
+    esac
+fi
+
+tempspec="$SPECDIR/spectemplate-$spectype.spec"
 
-if [ "$1" = "" ]; then 
-	if [ -f newpackage.spec ]; then
-    		echo "newpackage.spec already exists.  Exiting."
-	else
-    		echo "RPM spec template has been copied to newpackage.spec."
-    		cp $SPEC newpackage.spec
-	fi
-else
-	if [ -f $1.spec ]; then
-		echo "$1.spec already exists.  Exiting."
-	else
-		cat $SPEC | sed -e "s/^\\(Name:\\s*\\)/\\1$1/" > $1.spec
-		echo "RPM spec template has been copied to $1.spec."
-	fi
+if [ ! -f "$tempspec" ] ; then
+    echo "Template \"$tempspec\" not found, exiting."
+    exit 1
 fi
-exit 42
-}
 
-case $1 in
+[ -z "$specfile" ] && specfile="$DEFSPEC"
+if [ -f "$specfile" ] ; then
+    echo "Output file \"$specfile\" already exists, exiting."
+    exit 2
+elif [ "$specfile" = "-" ] ; then
+    specfile=/dev/stdout
+fi
 
--h|--help)
-	newrpmspec.help
-	;;
-*)	
-	newrpmspec.default $1
-	;;
-esac
+cat "$tempspec" | sed -e "s/^\\(Name:\\s*\\)/\\1$appname/ $specfilter" \
+  > "$specfile"
 
+if [ "$specfile" != "/dev/stdout" ] ; then
+    echo "Skeleton specfile ($spectype) has been created to \"$specfile\"."
+fi




More information about the fedora-extras-commits mailing list