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

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


Author: tpetazzo-guest
Date: 2005-04-17 22:11:07 +0000 (Sun, 17 Apr 2005)
New Revision: 1284

Modified:
   trunk/tools/opkg-buildpackage/opkg-cleanpackage
Log:
Transform opkg-cleanpackage into a Perl script instead of a Shell script, for coherency with opkg-buildpackage

Modified: trunk/tools/opkg-buildpackage/opkg-cleanpackage
===================================================================
--- trunk/tools/opkg-buildpackage/opkg-cleanpackage	2005-04-17 16:50:49 UTC (rev 1283)
+++ trunk/tools/opkg-buildpackage/opkg-cleanpackage	2005-04-17 22:11:07 UTC (rev 1284)
@@ -1,9 +1,10 @@
-#!/bin/sh
+#!/usr/bin/perl
 
 # opkg-cleanpackage, 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 clean a debian package following the
+# simple perl script to clean a debian package following the
 # pkg-ocaml-maint structure of original source tarball and separate
 # debian dir containing the patches.
 
@@ -20,20 +21,26 @@
 #    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 '-')
+# Build list of files to be deleted
+$difffile     = "${package}_${version}.diff.gz";
+$dscfile      = "${package}_${version}.dsc";
+$changesfiles = "${package}_${version}_*.changes";
+$builddir     = "${package}-${upstreamversion}";
 
-rm -rf ${PACKAGE}-${UPSTREAMVERSION}
-rm -f ${PACKAGE}_${DEBVERSION}.diff.gz
-rm -f ${PACKAGE}_${DEBVERSION}.dsc
-rm -f ${PACKAGE}_${DEBVERSION}_*.changes
-rm -f *.deb
+# Delete unneeded files and directories
+system "rm $difffile";
+system "rm $dscfile";
+system "rm $changesfiles";
+system "rm -rf $builddir";
+system "rm *.deb";