[debhelper-devel] [debhelper] 03/12: Support automatic building of EOS app packages

Niels Thykier nthykier at moszumanska.debian.org
Sat Jan 20 18:38:35 UTC 2018


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to annotated tag Version_9.20130630co2endless10
in repository debhelper.

commit 75909c065d673077384d6ace293e558dceac98e1
Author: Dan Nicholson <nicholson at endlessm.com>
Date:   Wed Jun 18 17:59:47 2014 +0000

    Support automatic building of EOS app packages
    
       * Debian/Debhelper/Dh_Lib.pm:
         - Support reading a profile from the DEB_BUILD_PROFILES variable.
         - Read the desired app id from the XCBS-EOS-AppId control field.
         - Support querying the package's EOS app id. Use the main package's
           app id if the package does not specify an explicit id.
       * Debian/Debhelper/Buildsystem/autoconf.pm:
       * Debian/Debhelper/Buildsystem/cmake.pm:
       * Debian/Debhelper/Buildsystem/qmake.pm:
         - Set a prefix derived from the app id when eos-app is set in
           DEB_BUILD_PROFILES.
       * dh_install:
         - Adjust prefix of specified install paths for eos-app packages.
       * dh_eosapp:
         - New dh script moving all contents of /usr to /endless/<app> when
           eos-app is set in DEB_BUILD_PROFILES.
       * dh:
         - Run dh_eosapp at the end of the install sequence.
    
    [endlessm/eos-shell#2814]
---
 Debian/Debhelper/Buildsystem/autoconf.pm | 19 +++++++---
 Debian/Debhelper/Buildsystem/cmake.pm    | 11 ++++--
 Debian/Debhelper/Buildsystem/qmake.pm    | 11 ++++--
 Debian/Debhelper/Dh_Lib.pm               | 57 ++++++++++++++++++++++++++++--
 debian/changelog                         | 22 ++++++++++++
 dh                                       |  1 +
 dh_eosapp                                | 60 ++++++++++++++++++++++++++++++++
 dh_install                               | 18 +++++++++-
 8 files changed, 188 insertions(+), 11 deletions(-)

diff --git a/Debian/Debhelper/Buildsystem/autoconf.pm b/Debian/Debhelper/Buildsystem/autoconf.pm
index 20b9fd4..4bde20f 100644
--- a/Debian/Debhelper/Buildsystem/autoconf.pm
+++ b/Debian/Debhelper/Buildsystem/autoconf.pm
@@ -7,7 +7,8 @@
 package Debian::Debhelper::Buildsystem::autoconf;
 
 use strict;
-use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value sourcepackage compat);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value sourcepackage compat
+				 get_buildprofile package_eos_app_id);
 use base 'Debian::Debhelper::Buildsystem::makefile';
 
 sub DESCRIPTION {
@@ -31,12 +32,22 @@ sub configure {
 	# Standard set of options for configure.
 	my @opts;
 	push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE");
-	push @opts, "--prefix=/usr";
+	if (get_buildprofile("eos-app")) {
+		# Build with the app id of the main package by default
+		my $app_prefix=package_eos_app_id();
+
+		push @opts, "--prefix=/endless/" . $app_prefix;
+		push @opts, "--sysconfdir=\${prefix}/etc";
+		push @opts, "--localstatedir=\${prefix}/var";
+	}
+	else {
+		push @opts, "--prefix=/usr";
+		push @opts, "--sysconfdir=/etc";
+		push @opts, "--localstatedir=/var";
+	}
 	push @opts, "--includedir=\${prefix}/include";
 	push @opts, "--mandir=\${prefix}/share/man";
 	push @opts, "--infodir=\${prefix}/share/info";
-	push @opts, "--sysconfdir=/etc";
-	push @opts, "--localstatedir=/var";
 	my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH");
 	if (! compat(8)) {
 	       if (defined $multiarch) {
diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm
index d47821c..98e6740 100644
--- a/Debian/Debhelper/Buildsystem/cmake.pm
+++ b/Debian/Debhelper/Buildsystem/cmake.pm
@@ -7,7 +7,7 @@
 package Debian::Debhelper::Buildsystem::cmake;
 
 use strict;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat get_buildprofile package_eos_app_id);
 use base 'Debian::Debhelper::Buildsystem::makefile';
 
 sub DESCRIPTION {
@@ -41,7 +41,14 @@ sub configure {
 	my @flags;
 
 	# Standard set of cmake flags
-	push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
+	if (get_buildprofile("eos-app")) {
+		# Get package app id for prefix
+		my $app_prefix = package_eos_app_id();
+		push @flags, "-DCMAKE_INSTALL_PREFIX=" . $app_prefix;
+	}
+	else {
+		push @flags, "-DCMAKE_INSTALL_PREFIX=/usr";
+	}
 	push @flags, "-DCMAKE_VERBOSE_MAKEFILE=ON";
 	push @flags, "-DCMAKE_BUILD_TYPE=RelWithDebInfo";
 
diff --git a/Debian/Debhelper/Buildsystem/qmake.pm b/Debian/Debhelper/Buildsystem/qmake.pm
index 91e817f..791f0c6 100644
--- a/Debian/Debhelper/Buildsystem/qmake.pm
+++ b/Debian/Debhelper/Buildsystem/qmake.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::qmake;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(error);
+use Debian::Debhelper::Dh_Lib qw(error get_buildprofile package_eos_app_id);
 use base 'Debian::Debhelper::Buildsystem::makefile';
 
 our $qmake="qmake";
@@ -66,7 +66,14 @@ sub configure {
 		push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}";
 	}
 	push @flags, "QMAKE_STRIP=:";
-	push @flags, "PREFIX=/usr";
+	if (get_buildprofile("eos-app")) {
+		# Build with the app id of the main package by default
+		my $app_prefix=package_eos_app_id();
+		push @flags, "PREFIX=" . $app_prefix;
+	}
+	else {
+		push @flags, "PREFIX=/usr";
+	}
 
 	$this->doit_in_builddir($qmake, @options, @flags, @_);
 }
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 088bb01..f429887 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -18,7 +18,8 @@ use vars qw(@ISA @EXPORT %dh);
 	    &inhibit_log &load_log &write_log &commit_override_log
 	    &dpkg_architecture_value &sourcepackage
 	    &is_make_jobserver_unavailable &clean_jobserver_makeflags
-	    &cross_command &set_buildflags &get_buildoption);
+	    &cross_command &set_buildflags &get_buildoption
+	    &get_buildprofile &package_eos_app_id);
 
 my $max_compat=10;
 
@@ -778,18 +779,20 @@ sub sourcepackage {
 # packages.
 # As a side effect, populates %package_arches and %package_types with the
 # types of all packages (not only those returned).
-my (%package_types, %package_arches);
+my (%package_types, %package_arches, %package_eos_app_ids);
 sub getpackages {
 	my $type=shift;
 
 	%package_types=();
 	%package_arches=();
+	%package_eos_app_ids=();
 	
 	$type="" if ! defined $type;
 
 	my $package="";
 	my $arch="";
 	my $package_type;
+	my $eos_app_id;
 	my @list=();
 	my %seen;
 	open (CONTROL, 'debian/control') ||
@@ -814,11 +817,15 @@ sub getpackages {
 		if (/^(?:X[BC]*-)?Package-Type:\s*(.*)/) {
 			$package_type=$1;
 		}
+		if (/^(?:XCBS-)?EOS-AppId:\s*(.*)/) {
+			$eos_app_id=$1;
+		}
 		
 		if (!$_ or eof) { # end of stanza.
 			if ($package) {
 				$package_types{$package}=$package_type;
 				$package_arches{$package}=$arch;
+				$package_eos_app_ids{$package}=$eos_app_id;
 			}
 
 			if ($package &&
@@ -830,6 +837,7 @@ sub getpackages {
 				push @list, $package;
 				$package="";
 				$arch="";
+				$eos_app_id="";
 			}
 		}
 	}
@@ -849,6 +857,36 @@ sub package_arch {
 	return $package_arches{$package} eq 'all' ? "all" : buildarch();
 }
 
+# Returns the EOS AppID for a package.
+sub package_eos_app_id {
+	my $package=shift;
+
+	$package = $dh{MAINPACKAGE} if ! defined $package;
+	verbose_print("Checking for app ID ${package}");
+	if (! exists $package_eos_app_ids{$package}) {
+		warning "package $package is not in control info";
+		return $package;
+	}
+	if (! $package_eos_app_ids{$package}) {
+		# Return the ID of the main package if there is not a
+		# specific ID for this package.
+		my $app_id;
+
+		if ($package eq $dh{MAINPACKAGE}) {
+			# Just return the package name if no ID set on
+			# the main package.
+			$app_id=$package;
+		}
+		else {
+			$app_id=package_eos_app_id($dh{MAINPACKAGE});
+		}
+		verbose_print("No app ID set, returning ${app_id}");
+		return $app_id;
+	}
+	verbose_print("Found app ID $package_eos_app_ids{$package}");
+	return $package_eos_app_ids{$package};
+}
+
 # Return true if a given package is really a udeb.
 sub is_udeb {
 	my $package=shift;
@@ -980,4 +1018,19 @@ sub get_buildoption {
 	}
 }
 
+# Gets a DEB_BUILD_PROFILES profile, if set.
+sub get_buildprofile {
+	my $wanted=shift;
+
+	verbose_print("Checking for build profile ${wanted}");
+	return undef unless exists $ENV{DEB_BUILD_PROFILES};
+
+	foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_PROFILES})) {
+		verbose_print("Found build profile ${opt}");
+		if ($opt eq $wanted) {
+			return 1;
+		}
+	}
+}
+
 1
diff --git a/debian/changelog b/debian/changelog
index 5dcb825..8b2573c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,25 @@
+debhelper (9.20130630co2endless1) eos; urgency=low
+
+  * Debian/Debhelper/Dh_Lib.pm:
+    - Support reading a profile from the DEB_BUILD_PROFILES variable.
+    - Read the desired app id from the XCBS-EOS-AppId control field.
+    - Support querying the package's EOS app id. Use the main package's
+      app id if the package does not specify an explicit id.
+  * Debian/Debhelper/Buildsystem/autoconf.pm:
+  * Debian/Debhelper/Buildsystem/cmake.pm:
+  * Debian/Debhelper/Buildsystem/qmake.pm:
+    - Set a prefix derived from the app id when eos-app is set in
+      DEB_BUILD_PROFILES.
+  * dh_install:
+    - Adjust prefix of specified install paths for eos-app packages.
+  * dh_eosapp:
+    - New dh script moving all contents of /usr to /endless/<app> when
+      eos-app is set in DEB_BUILD_PROFILES.
+  * dh:
+    - Run dh_eosapp at the end of the install sequence.
+
+ -- Dan Nicholson <nicholson at endlessm.com>  Wed, 18 Jun 2014 17:59:47 +0000
+
 debhelper (9.20130630co2) alphacentauri; urgency=low
 
   * Add --upstart-only dummy argument to dh_installinit
diff --git a/dh b/dh
index 7f81661..0afd375 100755
--- a/dh
+++ b/dh
@@ -395,6 +395,7 @@ my @i = qw{
 	dh_link
 	dh_compress
 	dh_fixperms
+	dh_eosapp
 };
 my @ba=qw{
 	dh_strip
diff --git a/dh_eosapp b/dh_eosapp
new file mode 100755
index 0000000..f7ac736
--- /dev/null
+++ b/dh_eosapp
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_eosapp - move installed files to application prefix
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_eosapp> [S<I<debhelper options>>]
+
+=head1 DESCRIPTION
+
+B<dh_eosapp> is a debhelper program that moves installed files from the
+typical /usr prefix to the application specific /endless/app prefix.
+
+It only operates when DEB_BUILD_PROFILES includes "eos-app".
+
+=cut
+
+init();
+
+if (! get_buildprofile("eos-app")) {
+	exit;
+}
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	my $tmp=tmpdir($package);
+	my $app_id=package_eos_app_id($package);
+	my $cmd;
+
+	# Skip if there is no usr directory
+	if (! -d "${tmp}/usr") {
+		next;
+	}
+
+	# Create the endless prefix if necessary
+	doit("mkdir -p ${tmp}/endless/${app_id}");
+
+	# Move files from /usr to /endless/app and delete /usr
+	$cmd="tar -C ${tmp}/usr -cf- . | tar -C ${tmp}/endless/${app_id} -xpf-";
+	complex_doit($cmd);
+	doit("rm -rf ${tmp}/usr");
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Dan Nicholson <nicholson at endlessm.com>
+
+=cut
diff --git a/dh_install b/dh_install
index 7a6cc61..6040d2e 100755
--- a/dh_install
+++ b/dh_install
@@ -155,13 +155,29 @@ foreach my $package (getpackages()) {
 	foreach my $set (@install) {
 		my $dest;
 		my $tmpdest=0;
-		
+		my $prefix;
+
+		if (get_buildprofile("eos-app")) {
+			# Get the app prefix with the leading / stripped.
+			$prefix="endless/" . package_eos_app_id();
+		}
+
 		if (! defined $dh{AUTODEST} && @$set > 1) {
 			$dest=pop @$set;
+
+			# Adjust the destination if app prefix is set.
+			$dest=~s,^usr/,${prefix}/, if defined $prefix;
+			$dest=~s,^etc/,${prefix}/etc/, if defined $prefix;
+			$dest=~s,^var/,${prefix}/var/, if defined $prefix;
 		}
 
 		my @filelist;
 		foreach my $glob (@$set) {
+			# Adjust the glob if app prefix is set.
+			$glob=~s,^usr/,${prefix}/, if defined $prefix;
+			$glob=~s,^etc/,${prefix}/etc/, if defined $prefix;
+			$glob=~s,^var/,${prefix}/var/, if defined $prefix;
+
 			my @found = glob "$srcdir/$glob";
 			if (! compat(6)) {
 				# Fall back to looking in debian/tmp.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list