[Pkg-octave-commit] [SCM] Debian packaging for octave-pkg-dev branch, master, updated. debian/1.0.1-2-gf758541

Rafael Laboissiere rafael at laboissiere.net
Thu Mar 15 00:00:25 UTC 2012


The following commit has been merged in the master branch:
commit f758541b2c076db8cd7332809bcf3bc7c89ccfb8
Author: Rafael Laboissiere <rafael at laboissiere.net>
Date:   Thu Mar 15 00:27:07 2012 +0100

    Add script for automating the generation of packages from Octave-Forge sources
    
    The script, called make-octave-forge-debpkg, is obtained from the *.in file
    by substituting the relevant information in debian/control (namely
    Standards-Version, Uploaders, Maintainer, Vcs-Git, and Vcs-Braowser) in
    debian/compat and in debian/changelog (Version).  This is done by the
    substitute.pl script.  A man page is also generated from the POD section.

diff --git a/.gitignore b/.gitignore
index e7c0337..b196b28 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ debian/files
 debian/octave-pkg-dev.debhelper.log
 debian/octave-pkg-dev/
 debian/octave-pkg-dev.substvars
+make-octave-forge-debpkg
+make-octave-forge-debpkg.1
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..56518e8
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1,2 @@
+make-octave-forge-debpkg
+make-octave-forge-debpkg.1
diff --git a/debian/control b/debian/control
index e72e678..83b975e 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,7 @@ Maintainer: Debian Octave Group <pkg-octave-devel at lists.alioth.debian.org>
 Uploaders: Thomas Weber <tweber at debian.org>,
            Sébastien Villemot <sebastien.villemot at ens.fr>
 DM-Upload-Allowed: yes
-Build-Depends: debhelper (>= 9), cdbs
+Build-Depends: debhelper (>= 9), cdbs, libdpkg-perl
 Standards-Version: 3.9.3
 Vcs-Git: git://git.debian.org/git/pkg-octave/octave-pkg-dev.git
 Vcs-Browser: http://git.debian.org/?p=pkg-octave/octave-pkg-dev.git
diff --git a/debian/octave-pkg-dev.install b/debian/octave-pkg-dev.install
index 6252af4..ca92997 100644
--- a/debian/octave-pkg-dev.install
+++ b/debian/octave-pkg-dev.install
@@ -1,2 +1,3 @@
-octave-pkg.mk		usr/share/cdbs/1/class
-octave-pkg-helper	usr/share/octave/debian/dh
+octave-pkg.mk                   usr/share/cdbs/1/class
+octave-pkg-helper	        usr/share/octave/debian/dh
+make-octave-forge-debpkg        usr/bin
\ No newline at end of file
diff --git a/debian/octave-pkg-dev.manpages b/debian/octave-pkg-dev.manpages
new file mode 100644
index 0000000..b46aefa
--- /dev/null
+++ b/debian/octave-pkg-dev.manpages
@@ -0,0 +1 @@
+make-octave-forge-debpkg.1
diff --git a/debian/rules b/debian/rules
index 740d2d0..ff47733 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,3 +7,7 @@ include /usr/share/cdbs/1/rules/debhelper.mk
 
 build/octave-pkg-dev::
 	chmod +x octave-pkg-helper
+	chmod +x substitute.pl
+	./substitute.pl
+	chmod +x make-octave-forge-debpkg
+	pod2man make-octave-forge-debpkg > make-octave-forge-debpkg.1
diff --git a/make-octave-forge-debpkg.in b/make-octave-forge-debpkg.in
new file mode 100755
index 0000000..5851847
--- /dev/null
+++ b/make-octave-forge-debpkg.in
@@ -0,0 +1,245 @@
+#!/usr/bin/perl
+# make-octave-forge-debpkg: Generate a Debian package from the sources of
+#     an Octave-Forge package from scratch
+# This file is part of the octave-pkg-dev Debian package
+
+# Copyright (c) 2012  Rafael Laboissiere <rafael at laboissiere.net>
+#
+# 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+=pod
+
+=head1 NAME
+
+make-octave-forge-debpkg -- Generate a Debian package from the sources of an Octave-Forge package
+
+=head1 SYNOPSIS
+
+=over
+
+=item B<make-octave-forge-debpkg>
+
+=back
+
+=head1 DESCRIPTION
+
+B<make-octave-forge-debpkg> is a helper script for generating a first
+version of a Debian package for an Octave-Forge package. The command should
+be launched from the top directory of the unpacked sources of an
+Octave-Forge packages.  A file called DESCRIPTION must be present, from
+which the informations about the package is gathered.  The following files
+are generated, with sensible contents, but needing further editing:
+
+=over
+
+=item debian/changelog
+
+=item debian/compat
+
+=item debian/control
+
+=item debian/copyright
+
+=item debian/rules
+
+=item debian/source/format
+
+=item debian/watch
+
+=back
+
+=head1 ENVIRONMENT VARIABLES
+
+The environment variables B<DEBFULLNAME> and B<DEBEMAIL> are used for
+generating the identity of the developer, which will appear in
+debian/changelog and debian/copyright. If they do not exist, B<FULLNAME>
+and B<EMAIL> are used instead.
+
+=head1 DISCLAIMER
+
+B<make-octave-forge-debpkg> is distributed in the hope that it will be useful,
+but B<without any warranty>; without even the implied warranty of
+B<merchantability> or B<fitness for a particular purpose>.
+
+=head1 COPYRIGHT
+
+Copyright 2012 Rafael Laboissiere
+
+This script is free software; you can redistribute it and/or
+modify it under the terms of the GNU GPL, v3 or later.
+
+=head1 AUTHOR
+
+Rafael Laboissiere E<lt>rafael at laboissiere.netE<gt>
+
+=cut
+
+### Get program name
+(my $prog = $0) =~ s|.*/||;
+
+### Function for yelling on errrors
+sub croak ($) {
+    my $message = shift;
+    die "$prog:E: $message\n"
+}
+
+### The pkgdata hash will store the data in the DESCRIPTION file
+my %pkgdata;
+
+### Check whether a given field exists in the DESCRIPTION file and exit the
+### program with an error message, in the case the field doe snot exist
+sub check ($) {
+    my $field = shift;
+    exists $pkgdata{$field} or croak "$field not found in DESCRIPTION";
+
+}
+
+### File DESCRIPTION is not here.  Yell loudly.
+-f "DESCRIPTION" or croak "File DESCRIPTION not found";
+
+### REad the fields present in the DESCRIPTION file
+open (FID, "< DESCRIPTION");
+/([^:]+): (.*)/ and $pkgdata{$1} = $2 while (<FID>);
+close FID;
+
+### Check for some mandatory fields
+check ("Name");
+my $name = lc $pkgdata{Name};
+check ("Version");
+my $version = $pkgdata{Version};
+check ("Description");
+my $description = $pkgdata{Description};
+
+### Decide on the pacakge Architecture based on the presence of the src/
+### directory, which typically contains C++ files to be compiled.
+my $architecture = -d "src" ? "any" : "all";
+
+### Create the debian directory, if it does not exist.
+-d "debian" or mkdir "debian";
+
+### Create the debian/compat file.
+my $compat = #Compat#;
+open (FID, "> debian/compat");
+print FID $compat;
+close FID;
+
+### Create the debian/watch file.
+open (FID, "> debian/watch");
+print FID "version=3
+http://octave.sourceforge.net/packages.php \
+    http://downloads\.sourceforge\.net/octave/$name-([\d.]+)\.tar\.gz\?download
+";
+close FID;
+
+### Create the debian/changelog file.
+my $date = qx {date --rfc-2822};
+chomp $date;
+my $developer = exists $ENV{DEBFULLNAME} ? $ENV{DEBFULLNAME}
+                : exists $ENV{FULLNAME} ? $ENV{FULLNAME}
+                : "Joe Developer";
+my $email = exists $ENV{DEBEMAIL} ? $ENV{DEBEMAIL}
+                : exists $ENV{EMAIL} ? $ENV{EMAIL}
+                : "joe\@developer.org";
+my $author = "$developer <$email>";
+
+open (FID, "> debian/changelog");
+print FID "octave-$name ($version-1) unstable; urgency=low
+
+ -- $author  $date
+";
+close FID;
+
+### Create the debian/rules file.
+open (FID, "> debian/rules");
+print FID "#!/usr/bin/make -f
+# -*- makefile -*-
+
+include /usr/share/cdbs/1/class/octave-pkg.mk
+";
+close FID;
+system ("chmod +x debian/rules");
+
+### Create the debian/control file.
+my $uploaders = "#Uploaders#";
+if ($uploaders == "") {
+    $uploaders = "Uploaders: $uploaders
+DM-Upload-Allowed: yes
+";
+}
+
+my $shlibs = "";
+if ($architecture == "any") {
+    $shlibs = ", \${shlibs:Depends}";
+}
+
+open (FID, "> debian/control");
+print FID "Source: octave-$name
+Section: math
+Priority: optional
+Maintainer: Debian Octave Group <pkg-octave-devel\@lists.alioth.debian.org>
+${uploaders}Build-Depends: debhelper (>= $compat), cdbs, octave-pkg-dev (>= #Version#)
+Standards-Version: #Standards-Version#
+Homepage: http://octave.sourceforge.net/$name/
+Vcs-Git: #Vcs-Git#
+Vcs-Browser: #Vcs-Browser#
+
+Package: octave-$name
+Architecture: $architecture
+Depends: \${misc:Depends}, \${octave:Depends}$shlibs
+Description: $description
+ #FIXME#
+ .
+ This Octave add-on package is part of the Octave-Forge project.
+";
+close FID;
+
+### Create the debian/source/format file.
+-d "debian/source" or mkdir "debian/source";
+open (FID, "> debian/source/format");
+print FID "3.0 (quilt)";
+close FID;
+
+### Create the debian/copyright file.
+system ("licensecheck -r --copyright -c '\\.m|\\.cc|\\.h' . "
+         . "| /usr/lib/cdbs/licensecheck2dep5 > debian/copyright");
+
+my $year = qx {date +%Y};
+chomp $year;
+
+### Create the Debian specific part to the debian/control file.
+open (FID, ">> debian/copyright");
+print FID "Files: debian/*
+Copyright: $year $author
+License: GPL-3+
+
+License: GPL-3+
+ 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 3 of the License, or
+ (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License along
+ with this program.  If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General Public
+ License, version 3, can be found in the file
+ `/usr/share/common-licenses/GPL-3'.
+";
+close FID;
diff --git a/substitute.pl b/substitute.pl
new file mode 100755
index 0000000..d8db5bb
--- /dev/null
+++ b/substitute.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -w
+
+use Parse::DebControl;
+use Dpkg::Changelog;
+
+my $parser = new Parse::DebControl;
+my $data = $parser->parse_file ('./debian/control') -> [0];
+
+for my $field ("Git", "Browser") {
+    (my $tmp = $data -> {"Vcs-$field"}) =~ s/pkg-dev/\$name/;
+    $data->{"Vcs-$field"} = $tmp;
+}
+
+open (FID, "< debian/compat");
+$data->{Compat} = join ("", <FID>);
+chomp $data->{Compat};
+close FID;
+
+open (FID, "< debian/changelog");
+while (<FID>) {
+    if (/\(([\d.]+)\)/) {
+        $data->{Version} = $1;
+        last;
+    }
+}
+
+$base = "make-octave-forge-debpkg";
+open (IN, "< $base.in");
+open (OUT, "> $base");
+
+while (<IN>) {
+    for my $field ("Uploaders", "Standards-Version", "Maintainer",
+                   "Vcs-Git", "Vcs-Browser", "Compat", "Version") {
+        s{#$field#}{$data->{$field}};
+    }
+    print OUT;
+}
+
+close IN;
+close OUT;
+

-- 
Debian packaging for octave-pkg-dev



More information about the Pkg-octave-commit mailing list