summaryrefslogtreecommitdiff
path: root/debian/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'debian/scripts')
-rw-r--r--debian/scripts/dbs-build.mk94
-rw-r--r--debian/scripts/dbs_split83
-rw-r--r--debian/scripts/dpkg-arch.mk7
-rw-r--r--debian/scripts/file2cat13
4 files changed, 197 insertions, 0 deletions
diff --git a/debian/scripts/dbs-build.mk b/debian/scripts/dbs-build.mk
new file mode 100644
index 0000000..1fe8000
--- /dev/null
+++ b/debian/scripts/dbs-build.mk
@@ -0,0 +1,94 @@
+#!/usr/bin/make -f
+# Separate tarball/patch build system by Adam Heath <doogie@debian.org>
+# Modified by Ben Collins <bcollins@debian.org>
+
+SHELL = /bin/bash -e
+SOURCE_DIR = build-tree
+STAMP_DIR = stampdir
+PATCH_DIR = debian/patches
+SCRIPT_DIR = /usr/share/dbs
+
+patched = $(STAMP_DIR)/patch
+unpacked = $(STAMP_DIR)/unpack
+
+ifdef TAR_DIR
+ BUILD_TREE = $(SOURCE_DIR)/$(TAR_DIR)
+else
+ BUILD_TREE = $(SOURCE_DIR)
+endif
+
+dh_mak_deps = $(shell DH_COMPAT=$(DH_COMPAT) perl $(SCRIPT_DIR)/dbs_split makedeps)
+dh_gen_deps = $(shell DH_COMPAT=$(DH_COMPAT) perl $(SCRIPT_DIR)/dbs_split gendeps)
+
+$(dh_mak_deps): $(dh_gen_deps)
+ perl $(SCRIPT_DIR)/dbs_split
+
+setup: $(dh_mak_deps)
+ dh_testdir
+ @-up-scripts
+ $(MAKE) -f debian/rules $(unpacked) $(patched)
+
+$(patched)/: $(STAMP_DIR)/created $(unpacked)
+ test -d $(STAMP_DIR)/patches || mkdir -p $(STAMP_DIR)/patches
+ @if [ -d "$(PATCH_DIR)" ]; then \
+ mkdir -p $(STAMP_DIR)/log/patches; \
+ for f in `(cd $(PATCH_DIR); find -type f ! -name 'chk-*') | sort | \
+ sed s,'./',,g`; do \
+ stampfile=$(STAMP_DIR)/patches/$$f; \
+ log=$(STAMP_DIR)/log/patches/$$f; \
+ if [ ! -e $$stampfile ]; then \
+ echo -n "Applying patch $(PATCH_DIR)/$$f ... "; \
+ if $(SHELL) $(SCRIPT_DIR)/file2cat $(PATCH_DIR)/$$f | \
+ (cd $(SOURCE_DIR);patch -p0 --no-backup-if-mismatch) > $$log 2>&1; then \
+ echo successful.; \
+ touch $$stampfile; \
+ else \
+ echo "failed! (check $$log for reason)"; \
+ exit 1; \
+ fi; \
+ else \
+ echo Already applied $(PATCH_DIR)/$$f.; \
+ fi; \
+ done; \
+ fi
+ touch $@
+
+unpacked: $(unpacked)
+$(unpacked): $(STAMP_DIR)/created
+ mkdir -p $(STAMP_DIR)/sources $(SOURCE_DIR) $(STAMP_DIR)/log/sources
+ @for f in `find . -type f -maxdepth 1 -name \*.tgz -o -name \*.tar.gz -o \
+ -name \*.tar.bz -o -name \*.tar.bz2 | sort | sed s,'./',,g`; do \
+ stampfile=$(STAMP_DIR)/sources/`basename $$f`; \
+ log=$(STAMP_DIR)/log/sources/`basename $$f`; \
+ if [ ! -e $$stampfile ]; then \
+ echo -n "Extracting source $$f ... "; \
+ if $(SHELL) $(SCRIPT_DIR)/file2cat $$f | \
+ (cd $(SOURCE_DIR); tar xv) > $$log 2>&1; then \
+ echo successful.; \
+ touch $$stampfile; \
+ else \
+ echo failed!; \
+ exit 1; \
+ fi; \
+ else \
+ echo Already unpacked $$f.; \
+ fi; \
+ done
+ touch $@
+
+make_patch:
+ mv $(BUILD_TREE) $(BUILD_TREE).new
+ rm -rf $(STAMP_DIR)
+ $(MAKE) -f debian/rules $(unpacked) $(patched)
+ifndef TAR_DIR
+ diff -urN $(BUILD_TREE) $(BUILD_TREE).new > new.diff
+else
+ (cd $(SOURCE_DIR) && diff -urN $(TAR_DIR) $(TAR_DIR).new || true) > new.diff
+endif
+ rm -rf $(BUILD_TREE)
+ mv $(BUILD_TREE).new $(BUILD_TREE)
+ @echo; ls -l new.diff
+
+$(STAMP_DIR)/created:
+ test -d $(STAMP_DIR) || mkdir $(STAMP_DIR)
+ touch $(STAMP_DIR)/created
diff --git a/debian/scripts/dbs_split b/debian/scripts/dbs_split
new file mode 100644
index 0000000..13f4d82
--- /dev/null
+++ b/debian/scripts/dbs_split
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+
+$control = 'debian/control';
+if ( -d 'debian/packages.d' ) {
+ $dir = 'debian/packages.d';
+} else {
+ $dir = 'debian';
+}
+$needclean = 0;
+$needlist = 0;
+$needdeps = 0;
+
+if (defined($ENV{'DH_COMPAT'})) {
+ $dh = $ENV{'DH_COMPAT'};
+} else {
+ $dh = 0;
+}
+
+if (@ARGV) {
+ $temp = shift;
+ if ($temp eq "clean") { $needclean = 1; }
+ elsif ($temp eq "makedeps") { $needlist = 1; }
+ elsif ($temp eq "gendeps") { $needdeps = 1; }
+}
+
+@packages = ();
+$first_package = "";
+
+open (CONTROL, "< $control");
+
+while (<CONTROL>) {
+ if (m/^Package:/) {
+ $package = (split)[1];
+ if ($first_package eq "" and $dh < 2) {
+ $first_package = $package;
+ }
+ if ( -f "${dir}/${package}.in" ) {
+ push @packages, $package;
+ }
+ }
+}
+
+close CONTROL;
+
+while (@packages) {
+ $package = shift(@packages);
+ $inhead = 1;
+ $opened = 0;
+ if ($needdeps) {
+ print "${dir}/${package}.in ";
+ next;
+ }
+ open (IN, "< ${dir}/${package}.in");
+ while (<IN>) {
+ if (m/^\%(.*)\%$/) {
+ if ($needclean) {
+ if ($package ne $first_package) {
+ system("rm -f debian/${package}.${1}");
+ } else {
+ system("rm -f debian/${1}");
+ }
+ } elsif ($needlist) {
+ if ($package ne $first_package) {
+ print "debian/${package}.${1} ";
+ } else {
+ print "debian/${1} ";
+ }
+ } else {
+ $inhead = 0;
+ if ($opened) { close OUT; } else { $opened = 1; }
+ if ($package ne $first_package) {
+ open OUT, "> debian/${package}.${1}";
+ } else {
+ open OUT, "> debian/${1}";
+ }
+ }
+ } elsif (!$inhead) {
+ print OUT $_;
+ }
+ }
+ close OUT;
+ close IN;
+}
diff --git a/debian/scripts/dpkg-arch.mk b/debian/scripts/dpkg-arch.mk
new file mode 100644
index 0000000..4a3ab3d
--- /dev/null
+++ b/debian/scripts/dpkg-arch.mk
@@ -0,0 +1,7 @@
+# see dpkg-architecture(8)
+DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+DEB_BUILD_GNU_CPU := $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
+DEB_BUILD_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
+DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
+DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
diff --git a/debian/scripts/file2cat b/debian/scripts/file2cat
new file mode 100644
index 0000000..d95d77e
--- /dev/null
+++ b/debian/scripts/file2cat
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ "$1" = "" ]; then
+ echo "Usage: file2cat <file>"
+ exit 1
+fi
+
+case "$1" in
+ *.gz|*.Z|*.tgz) cmd=zcat;;
+ *.bz|*.bz2) cmd=bzcat;;
+ *) cmd=cat;;
+esac
+$cmd $1