[SCM] Debian package checker branch, master, updated. 2.5.1-202-g0eb83f5
The following commit has been merged in the master branch:
commit 0eb83f591be1f8c0f8ad697f0895c1385d818435
Author: Niels Thykier <niels@thykier.net>
Date: Sun Aug 7 17:05:33 2011 +0200
Created a helper tool to make debs for t/debs
The helper can create basic deb files from a root dir and some
control files. It handles some of the common tasks in the debs
test suites.
diff --git a/t/debs/control-field-traversal-4/Makefile b/t/debs/control-field-traversal-4/Makefile
index 02942c4..4682a17 100644
--- a/t/debs/control-field-traversal-4/Makefile
+++ b/t/debs/control-field-traversal-4/Makefile
@@ -1,8 +1,7 @@
name = control-field-traversal-4
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/
+ mkdir -p root/usr/share/doc/
# create a symlink to (usr/share/doc/)dpkg which will make
# copyright-file warn that it can't check whether the symlink
# points to a foreign package if the directory traversal did
@@ -14,14 +13,10 @@ all:
# if the bogus source package name is not catched. This results
# into a valid symlink which is enough for copyright-file to
# determine that 'source/dpkg' does not exist.
- ln -s dpkg usr/share/doc/$(name)
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- tar cfz control.tar.gz control
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ ln -s dpkg root/usr/share/doc/$(name)
+
+ create-deb -o $(name).deb --root root/ control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb debian-binary
+ rm -rf root
diff --git a/t/debs/control-files-bad/Makefile b/t/debs/control-files-bad/Makefile
index 518ff47..efb4fc3 100644
--- a/t/debs/control-files-bad/Makefile
+++ b/t/debs/control-files-bad/Makefile
@@ -1,19 +1,25 @@
name = control-files-bad
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
chown 0:0 control
chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
+
+ cd root && md5sum usr/share/doc/$(name)/* > ../md5sums
chmod 755 md5sums
- tar -czf control.tar.gz --owner=nobody control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ # create a "special control.tar.gz" ; create-deb will
+ # use it, instead of creating its own.
+ tar czf control.tar.gz --owner=nobody control md5sums
+
+ # --no-fix-perm and --no-md5sums are not strictly needed
+ # but the former is to make it explicit and the latter
+ # prevents it from re-generating an unused md5sums file
+ create-deb -o $(name).deb --no-fix-perm --no-md5sums \
+ --root root/
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root/
diff --git a/t/debs/control-files-weird-files/Makefile b/t/debs/control-files-weird-files/Makefile
index c10ee59..ac762c2 100644
--- a/t/debs/control-files-weird-files/Makefile
+++ b/t/debs/control-files-weird-files/Makefile
@@ -1,20 +1,14 @@
name = control-files-weird-files
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
touch triggers
- tar -czf control.tar.gz control md5sums \
- special-file isinstallable triggers
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ create-deb -o $(name).deb --root root/ control triggers \
+ special-file isinstallable
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary triggers
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary triggers
+ rm -rf root/
diff --git a/t/debs/copyright-file-foreign-package/Makefile b/t/debs/copyright-file-foreign-package/Makefile
index 9b8aee0..960ca7d 100644
--- a/t/debs/copyright-file-foreign-package/Makefile
+++ b/t/debs/copyright-file-foreign-package/Makefile
@@ -1,16 +1,11 @@
name = copyright-file-foreign-package
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/
- ln -s other-package usr/share/doc/$(name)
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- tar cfz control.tar.gz control
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/
+ ln -s other-package root/usr/share/doc/$(name)
+
+ create-deb -o $(name).deb --no-md5sums --root root/ control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb debian-binary
+ rm -rf root/
diff --git a/t/debs/deb-format-ancient-file/Makefile b/t/debs/deb-format-ancient-file/Makefile
index 89d2771..b2ede8c 100644
--- a/t/debs/deb-format-ancient-file/Makefile
+++ b/t/debs/deb-format-ancient-file/Makefile
@@ -1,19 +1,21 @@
+name = deb-format-ancient-file
+
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/deb-format-ancient-file
- cp copyright changelog usr/share/doc/deb-format-ancient-file
- gzip -9 usr/share/doc/deb-format-ancient-file/changelog
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
env TZ=GMT touch -t 197001010000 \
- usr/share/doc/deb-format-ancient-file/changelog.gz
- tar -c -z -f data.tar.gz usr
+ root/usr/share/doc/$(name)/changelog.gz
+
chown 0:0 control
chmod 644 control
env TZ=GMT touch -t 197001010000 control
- md5sum usr/share/doc/deb-format-ancient-file/* > md5sums
- tar -c -z -f control.tar.gz control md5sums
- ar rc deb-format-ancient-file.deb \
- debian-binary control.tar.gz data.tar.gz
+
+ # Use --no-fix-perm to avoid it messing with the
+ # our created "mod-times"
+ create-deb -o $(name).deb --no-fix-perm \
+ --root root/ control
clean:
rm -f *.tar.gz *.deb md5sums debian-binary
- rm -rf usr
+ rm -rf root
diff --git a/t/debs/deb-format-extra-member/Makefile b/t/debs/deb-format-extra-member/Makefile
index 9159288..77fd334 100644
--- a/t/debs/deb-format-extra-member/Makefile
+++ b/t/debs/deb-format-extra-member/Makefile
@@ -1,17 +1,16 @@
+name = deb-format-extra-member
+
all:
- echo '2.0' > debian-binary
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root control
+
+ # add the extra element in the end
echo 'foo' > extra-stuff
- mkdir -p usr/share/doc/deb-format-extra-member
- cp copyright changelog usr/share/doc/deb-format-extra-member
- gzip -9 usr/share/doc/deb-format-extra-member/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/deb-format-extra-member/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc deb-format-extra-member.deb \
- debian-binary control.tar.gz data.tar.gz extra-stuff
+ ar q $(name).deb extra-stuff
clean:
rm -f *.tar.gz *.deb md5sums debian-binary extra-stuff
- rm -rf usr
+ rm -rf root
diff --git a/t/debs/deb-format-lzma/Makefile b/t/debs/deb-format-lzma/Makefile
index d03041b..b217bc1 100644
--- a/t/debs/deb-format-lzma/Makefile
+++ b/t/debs/deb-format-lzma/Makefile
@@ -1,17 +1,12 @@
+name = deb-format-lzma
+
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/deb-format-lzma
- cp copyright changelog usr/share/doc/deb-format-lzma
- gzip -9 usr/share/doc/deb-format-lzma/changelog
- tar cf data.tar usr
- lzma data.tar
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/deb-format-lzma/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc deb-format-lzma.deb \
- debian-binary control.tar.gz data.tar.lzma
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root -c lzma control
clean:
rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -rf root
diff --git a/t/debs/deb-format-record-size/Makefile b/t/debs/deb-format-record-size/Makefile
index 4f223f9..29a8a52 100644
--- a/t/debs/deb-format-record-size/Makefile
+++ b/t/debs/deb-format-record-size/Makefile
@@ -1,14 +1,18 @@
+name = deb-format-record-size
+
+# Build the deb manully, since we need to fiddle with
+# with the record-size.
all:
echo '2.0' > debian-binary
- mkdir -p usr/share/doc/deb-format-record-size
- cp copyright changelog usr/share/doc/deb-format-record-size
- gzip -9 usr/share/doc/deb-format-record-size/changelog
+ mkdir -p usr/share/doc/$(name)
+ cp copyright changelog usr/share/doc/$(name)
+ gzip -9 usr/share/doc/$(name)/changelog
tar --record-size=4096 -c -z -f data.tar.gz usr
chown 0:0 control
chmod 644 control
- md5sum usr/share/doc/deb-format-record-size/* > md5sums
+ md5sum usr/share/doc/$(name)/* > md5sums
tar --record-size=4096 -c -z -f control.tar.gz control md5sums
- ar rc deb-format-record-size.deb \
+ ar rc $(name).deb \
debian-binary control.tar.gz data.tar.gz
clean:
diff --git a/t/debs/deb-format-wrong-order/Makefile b/t/debs/deb-format-wrong-order/Makefile
index fa0ccdd..1fe1c37 100644
--- a/t/debs/deb-format-wrong-order/Makefile
+++ b/t/debs/deb-format-wrong-order/Makefile
@@ -1,14 +1,18 @@
+name = deb-format-wrong-order
+
+# Done by hand, create-deb cannot do this and it would
+# be "too much effort" to make it be able to do it.
all:
echo '2.0' > debian-binary
- mkdir -p usr/share/doc/deb-format-wrong-order
- cp copyright changelog usr/share/doc/deb-format-wrong-order
- gzip -9 usr/share/doc/deb-format-wrong-order/changelog
+ mkdir -p usr/share/doc/$(name)
+ cp copyright changelog usr/share/doc/$(name)
+ gzip -9 usr/share/doc/$(name)/changelog
tar cfz data.tar.gz usr
chown 0:0 control
chmod 644 control
- md5sum usr/share/doc/deb-format-wrong-order/* > md5sums
+ md5sum usr/share/doc/$(name)/* > md5sums
tar cfz control.tar.gz control md5sums
- ar rc deb-format-wrong-order.deb \
+ ar rc $(name).deb \
debian-binary data.tar.gz control.tar.gz
clean:
diff --git a/t/debs/description-synopsis-spaces/Makefile b/t/debs/description-synopsis-spaces/Makefile
index d0152b2..bacfdc0 100644
--- a/t/debs/description-synopsis-spaces/Makefile
+++ b/t/debs/description-synopsis-spaces/Makefile
@@ -1,18 +1,12 @@
name = description-synopsis-spaces
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root
diff --git a/t/debs/fields-general-bad/Makefile b/t/debs/fields-general-bad/Makefile
index cbb2279..43078c4 100644
--- a/t/debs/fields-general-bad/Makefile
+++ b/t/debs/fields-general-bad/Makefile
@@ -2,18 +2,12 @@ filename = fields-general-bad
name = $(filename)?
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(filename).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(filename).deb --root root control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root
diff --git a/t/debs/fields-general-missing/Makefile b/t/debs/fields-general-missing/Makefile
index 1cbbd0e..2f6351e 100644
--- a/t/debs/fields-general-missing/Makefile
+++ b/t/debs/fields-general-missing/Makefile
@@ -1,18 +1,12 @@
name = fields-general-missing
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root/ control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root
diff --git a/t/debs/fields-malformed-source/Makefile b/t/debs/fields-malformed-source/Makefile
index dd9605a..b3ee1c8 100644
--- a/t/debs/fields-malformed-source/Makefile
+++ b/t/debs/fields-malformed-source/Makefile
@@ -1,18 +1,12 @@
name = fields-malformed-source
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root
diff --git a/t/debs/fields-multi-arch-illegal/Makefile b/t/debs/fields-multi-arch-illegal/Makefile
index 9a36520..4bcb219 100644
--- a/t/debs/fields-multi-arch-illegal/Makefile
+++ b/t/debs/fields-multi-arch-illegal/Makefile
@@ -1,18 +1,12 @@
name = fields-multi-arch-illegal
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar czf data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root/ control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root
diff --git a/t/debs/fields-multi-arch-unknown/Makefile b/t/debs/fields-multi-arch-unknown/Makefile
index 35de369..09b4df8 100644
--- a/t/debs/fields-multi-arch-unknown/Makefile
+++ b/t/debs/fields-multi-arch-unknown/Makefile
@@ -1,18 +1,12 @@
name = fields-multi-arch-unknown
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar czf data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root/ control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root/
diff --git a/t/debs/fields-obsolete-relation/Makefile b/t/debs/fields-obsolete-relation/Makefile
index 9fcd420..6076006 100644
--- a/t/debs/fields-obsolete-relation/Makefile
+++ b/t/debs/fields-obsolete-relation/Makefile
@@ -1,18 +1,12 @@
name = fields-obsolete-relation
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root/ control
clean:
- rm -f *.tar.gz *.tar.lzma *.deb md5sums debian-binary
- rm -rf usr
+ rm -f *.tar.gz *.deb md5sums debian-binary
+ rm -rf root/
diff --git a/t/debs/fields-wildcard-binary/Makefile b/t/debs/fields-wildcard-binary/Makefile
index d232ffd..68cdb32 100644
--- a/t/debs/fields-wildcard-binary/Makefile
+++ b/t/debs/fields-wildcard-binary/Makefile
@@ -1,18 +1,12 @@
name = fields-wildcard-binary
all:
- echo '2.0' > debian-binary
- mkdir -p usr/share/doc/$(name)
- cp copyright changelog usr/share/doc/$(name)
- gzip -9 usr/share/doc/$(name)/changelog
- tar cfz data.tar.gz usr
- chown 0:0 control
- chmod 644 control
- md5sum usr/share/doc/$(name)/* > md5sums
- tar cfz control.tar.gz control md5sums
- ar rc $(name).deb \
- debian-binary control.tar.gz data.tar.gz
+ mkdir -p root/usr/share/doc/$(name)
+ cp copyright changelog root/usr/share/doc/$(name)
+ gzip -9 root/usr/share/doc/$(name)/changelog
+
+ create-deb -o $(name).deb --root root/ control
clean:
rm -f *.tar.gz *.deb md5sums debian-binary
- rm -rf usr
+ rm -rf root/
diff --git a/t/helpers/bin/create-deb b/t/helpers/bin/create-deb
new file mode 100755
index 0000000..39ac8f7
--- /dev/null
+++ b/t/helpers/bin/create-deb
@@ -0,0 +1,158 @@
+#!/usr/bin/perl
+
+# create-deb -- helper tool for the lintian test suite
+#
+# Copyright (C) 2011 Niels Thykier
+#
+# This program is free software. It is distributed 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.
+#
+# 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, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+use strict;
+use warnings;
+
+
+use Getopt::Long;
+use Cwd();
+
+# known compression styles
+my %TAR_OPTIONS = (
+ 'gz' => ['-z'],
+ 'bz2' => ['-j'],
+ 'lzma' => ['-I', 'lzma'],
+);
+
+# Permissions
+# Only added the files actually used in the test suite so far
+# - extend as needed
+my %PERM = (
+ 'control' => 0644,
+ 'md5sums' => 0644,
+ 'triggers' => 0644,
+ 'isinstallable' => 0755, # udeb
+);
+
+# default values
+my %val = (
+ 'compression' => 'gz',
+ 'fix-perm' => 1,
+);
+
+# Accepted options
+my %opts = (
+ 'out-file|o=s' => \$val{'out-file'},
+ 'help|h' => sub { usage(); exit 0; },
+ 'root=s' => \$val{'root'},
+ 'compression|c=s' => \$val{'compression'},
+ 'md5sums!' => \$val{'md5sums'},
+ 'fix-perm!' => \$val{'fix-perm'},
+);
+
+my $cwd;
+my $data;
+
+Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
+
+GetOptions(%opts)
+ or die "error parsing options\n";
+
+die "Missing --out-file option\n" unless $val{'out-file'};
+
+die "Missing --root option\n" unless $val{'root'};
+
+die "Unknown compression \"$val{'compression'}\"\n" unless exists $TAR_OPTIONS{$val{'compression'}};
+
+# default to "on" unless we are given an md5sums file explicitly
+$val{'md5sums'} = 1 unless defined $val{'md5sums'} || grep { $_ eq 'md5sums'} @ARGV;
+
+$cwd = Cwd::cwd();
+
+if ($val{'md5sums'}) {
+ runsystem("cd $val{'root'} && find -type f -a -! -ipath etc/ -print0 | xargs -0 md5sum >> $cwd/md5sums");
+ push @ARGV, 'md5sums' if -s 'md5sums'; # only add if it is not empty.
+}
+
+# Create the data.tar.$ext
+$data = "data.tar.$val{'compression'}";
+
+runsystem('tar', '-C', $val{'root'}, @{ $TAR_OPTIONS{$val{'compression'}} },
+ '-cf', "$cwd/$data", '.');
+
+# control.tar.gz
+
+unless ( -e 'control.tar.gz' ) {
+ if ($val{'fix-perm'}) {
+ chown 0, 0, @ARGV;
+ foreach my $f (@ARGV) {
+ if (my $perm = $PERM{$f}) {
+ chmod $perm, $f;
+ }
+ }
+ }
+ runsystem('tar', 'czf', 'control.tar.gz', @ARGV);
+}
+
+# debian-binary
+open my $bv, '>', 'debian-binary' or die "opening debian-binary: $!";
+print $bv "2.0\n";
+close $bv or die "closing debian-binary: $!";
+
+# ar the deb file
+runsystem('ar', 'rc', $val{'out-file'}, 'debian-binary', 'control.tar.gz', $data);
+
+exit 0;
+
+### helpers ###
+
+sub usage {
+ print <<EOF ;
+usage: $0 [options] -o <file.deb> --root <dir> control-file[... files]
+
+ --root <dir> Everything in <dir> will be put in the data.tar
+ -c, --compression <c> The extension used for the data.tar; defaults to "gz"
+ --help Prints usage info and exits
+ -o, --out-file <file> The name of the resulting deb file.
+ --[no-]md5sums Whether to auto-generate an md5sums. This file will
+ automatically be added to the control files if
+ generated. This is on by default, unless an md5sums
+ is passed.
+ --[no-]fix-perm Whether to auto-fix permissions and owner for control
+ files. Defaults to on. This will modify the perm of
+ the actual controls passed!
+
+Creates a deb file from a root directory and some control files. The
+control files are assumed to be in the current directory or the
+resulting control.tar.gz may be messed up (which may, of course, be
+intentional).
+
+If control.tar.gz already exists, it will be reused instead of creating a
+new one.
+
+Note: This writes debian-binary, data.tar.<c> and control.tar.gz to
+the current directory. If --md5sums is in effect, it will also generate
+a md5sums in the current directory.
+
+Note: This does not use dpkg-deb, so it can be used to generate deb
+files that dpkg-deb would (now or in the future) refuse to build.
+
+EOF
+
+}
+
+sub runsystem {
+ my $r = system @_;
+ die "system @_ failed (exit status: " . (($r >> 8) & 0xff) .")\n" if $r;
+}
+
diff --git a/t/runtests b/t/runtests
index cf65355..3102a61 100755
--- a/t/runtests
+++ b/t/runtests
@@ -29,6 +29,8 @@
use strict;
use warnings;
+use Cwd();
+
use threads;
use Thread::Queue;
@@ -127,6 +129,13 @@ unless (-d $TESTSET) {
fail("test set directory $TESTSET does not exist");
}
+if ( -d "$TESTSET/helpers/bin") {
+ # Add the test helpers to PATH
+ my $tpath = Cwd::abs_path("$TESTSET/helpers/bin");
+ fail "Cannot resolve $TESTSET/helpers/bin: $!" unless $tpath;
+ $ENV{'PATH'} = "$tpath:$ENV{'PATH'}";
+}
+
# Getopt::Long assigns 0 as default value if none was specified
if ($JOBS == 0 && -r '/proc/cpuinfo') {
open(CPU, '<', '/proc/cpuinfo')
@@ -712,7 +721,7 @@ sub run_tests{
my $okay = eval { $code->($t); };
if (!$okay || $@) {
if ($@) {
- msg_print "FAIELD\n";
+ msg_print "FAILED\n";
print STDERR "$@\n";
}
exit 1 unless $run_all_tests;
--
Debian package checker
Reply to: