[Pkg-ocaml-maint-commits] r1285 - trunk/tools/opkg-buildpackage

Thomas Petazzoni tpetazzo-guest@costa.debian.org
Sun, 17 Apr 2005 22:26:25 +0000


Author: tpetazzo-guest
Date: 2005-04-17 22:26:25 +0000 (Sun, 17 Apr 2005)
New Revision: 1285

Modified:
   trunk/tools/opkg-buildpackage/opkg-cleanpackage
   trunk/tools/opkg-buildpackage/opkg-editpatch
Log:
opkg-editpatch converted to Perl. Force file removal in opkg-cleanpackage to avoid stupid warnings

Modified: trunk/tools/opkg-buildpackage/opkg-cleanpackage
===================================================================
--- trunk/tools/opkg-buildpackage/opkg-cleanpackage	2005-04-17 22:11:07 UTC (rev 1284)
+++ trunk/tools/opkg-buildpackage/opkg-cleanpackage	2005-04-17 22:26:25 UTC (rev 1285)
@@ -2,7 +2,7 @@
 
 # opkg-cleanpackage, Version 0.1
 # Copyright (C) 2005      Thomas Petazzoni <thomas.petazzoni@enix.org>
-#               2003 2004 Ralf Treinen <treinen@debian.org>
+#               2003 2004 Ralf Treinen     <treinen@debian.org>
 #
 # simple perl script to clean a debian package following the
 # pkg-ocaml-maint structure of original source tarball and separate
@@ -39,8 +39,8 @@
 $builddir     = "${package}-${upstreamversion}";
 
 # Delete unneeded files and directories
-system "rm $difffile";
-system "rm $dscfile";
-system "rm $changesfiles";
+system "rm -f $difffile";
+system "rm -f $dscfile";
+system "rm -f $changesfiles";
 system "rm -rf $builddir";
-system "rm *.deb";
+system "rm -f *.deb";

Modified: trunk/tools/opkg-buildpackage/opkg-editpatch
===================================================================
--- trunk/tools/opkg-buildpackage/opkg-editpatch	2005-04-17 22:11:07 UTC (rev 1284)
+++ trunk/tools/opkg-buildpackage/opkg-editpatch	2005-04-17 22:26:25 UTC (rev 1285)
@@ -1,9 +1,10 @@
-#!/bin/sh
+#!/usr/bin/perl
 
 # opkg-editpatch, Version 0.1
-# Copyright (C) 2005 Thomas Petazzoni <thomas.petazzoni@enix.org>
+# Copyright (C) 2005      Thomas Petazzoni <thomas.petazzoni@enix.org>
+#               2003 2004 Ralf Treinen     <treinen@debian.org>
 #
-# simple shell script to edit a patch (using dpatch tools) in a debian
+# simple perl script to edit a patch (using dpatch tools) in a debian
 # package following the pkg-ocaml-maint structure of original source
 # tarball and separate debian dir containing the patches.
 
@@ -20,44 +21,44 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-if [ ! -f debian/changelog ] ; then
-  echo "Not in package directory"
-  exit 1
-fi
+open(CHL, "debian/changelog") || die "cannot open debian/changelog.\n";
+while(<CHL>){
+    last unless /^\s*$/;
+}
+close CHL;
 
-LINE=$(cat debian/changelog | head -1)
+# Get package name and version from changelog file
+($package,$version) = m/^\s*([a-zA-Z\d\+\-\.:]*)\s*\(([A-Za-z\d\+\-\.]*)\).*$/;
+$upstreamversion = $version;
+$upstreamversion =~ s/\-[^\-]*$//;
 
-# Separate package name and version
-PACKAGE=$(echo $LINE | sed 's/^\([^\ ]*\)\ .*$/\1/')
-DEBVERSION=$(echo $LINE | sed 's/^\([^\ ]*\) (\([0-9\.\-]*\))\ .*$/\2/')
-UPSTREAMVERSION=$(echo $DEBVERSION | cut -f 1 -d '-')
+$tarball = "${package}_${upstreamversion}.orig.tar.gz";
 
-TARBALL=${PACKAGE}_${UPSTREAMVERSION}.orig.tar.gz
-
 # First of all clean up everything
-opkg-cleanpackage
+system "opkg-cleanpackage";
 
 # Uncompress orig
-tar xvzf $TARBALL
+system "tar xvzf ${tarball}";
 
 # Rename to correct thing
-mv ${PACKAGE}-${UPSTREAMVERSION}.orig ${PACKAGE}-${UPSTREAMVERSION}
+system "mv ${package}-${upstreamversion}.orig ${package}-${upstreamversion}";
 
 # Copy Debian directory
-cp -a debian/ ${PACKAGE}-${UPSTREAMVERSION}
+system "cp -a debian/ ${package}-${upstreamversion}";
 
 # Go into the directory
-cd ${PACKAGE}-${UPSTREAMVERSION}
+chdir ("${package}-${upstreamversion}");
 
 # Edit the patch
-dpatch-edit-patch $1
+system "dpatch-edit-patch $ARGV[0]";
 
-if [ $? -eq 230 ] ; then 
-   cd ..
-   rm -rf ${PACKAGE}-${UPSTREAMVERSION}
-fi
+if ($? == 230) {
+    chdir ("..");
+    system "rm -rf ${package}-${upstreamversion}";
+    exit;
+}
 
-cd ..
-rm -rf debian
-cp -a ${PACKAGE}-${UPSTREAMVERSION}/debian .
-rm -rf ${PACKAGE}-${UPSTREAMVERSION}
+chdir ("..");
+system "rm -rf debian";
+system "cp -a ${package}-${upstreamversion}/debian .";
+system "rm -rf ${package}-${upstreamversion}";