[27542] in Source-Commits

home help back first fref pref prev next nref lref last post

debathena-thirdparty commit: Rewrite of new thirdparty infrastructure

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Mon Dec 16 13:47:26 2013

Date: Mon, 16 Dec 2013 13:47:19 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201312161847.rBGIlJmS023541@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/debathena-thirdparty/commit/e492ad352254ecbe09c894f46497a02f2d6cfb3d
commit e492ad352254ecbe09c894f46497a02f2d6cfb3d
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Fri Oct 4 11:26:28 2013 -0400

    Rewrite of new thirdparty infrastructure
    
    - Abandon old installer idea for new package which generates
      dependencies/recommendations at package build time.
    - Use chdist(1) on Ubuntu to enable multiverse at package
      build time
    - Add new build-dependencies on lsb-release and devscripts
    - Drop cdbs build dependency and update debhelper one to
      7.0.50~, since we're using overrides
    
    Additional changes:
    
    - Syntax errors in the list files are now fatal.
    - Slave dependencies are added correctly
    - A missing distro-specific file is not an error
    - Package is now arch-dependent, since there are some i386-only
      packages.

 debian/changelog                     |   11 +++-
 debian/control                       |    7 +-
 debian/debathena-thirdparty.defs     |    2 -
 debian/debathena-thirdparty.install  |    4 -
 debian/debathena-thirdparty.postinst |   41 -----------
 debian/debathena-thirdparty.prerm    |   43 -----------
 debian/rules                         |   12 ++--
 debian/thirdparty                    |  128 ----------------------------------
 generate-package-list.pl             |  103 +++++++++++++++++++---------
 9 files changed, 92 insertions(+), 259 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 91d01f1..0545c73 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,18 @@
 debathena-thirdparty (1.2) unstable; urgency=low
 
+  [ Alexander Chernyakhovsky ]
   * Add git-buildpackage configuration
   * Set source format to 3.0 (native)
 
- -- Alexander Chernyakhovsky <achernya@mit.edu>  Sun, 29 Sep 2013 05:24:10 -0400
+  [ Jonathan Reed ]
+  * Use chdist to generate the list of packages on Ubuntu, so as to
+    include multiverse.
+  * Build-Depend on lsb-release (for lsb_release) and devscripts (for chdist)
+  * Syntax errors in the common package list are now fatal
+  * This package is now an arch-dependent package, since the final package
+    list will differ across architectures (I'm look at you, mit-scheme)
+
+ -- Jonathan Reed <jdreed@mit.edu>  Mon, 16 Dec 2013 13:42:19 -0500
 
 debathena-thirdparty (1.1) unstable; urgency=low
 
diff --git a/debian/control b/debian/control
index 627e38e..d717875 100644
--- a/debian/control
+++ b/debian/control
@@ -3,11 +3,12 @@ Section: debathena/base
 Priority: extra
 Standards-Version: 3.9.3
 Maintainer: Debathena Project <debathena@mit.edu>
-Build-Depends: cdbs, debhelper (>= 6), libapt-pkg-perl
+Build-Depends: debhelper (>= 7.0.50~), libapt-pkg-perl, lsb-release, devscripts
 
 Package: debathena-thirdparty
-Architecture: all
-Depends: ${misc:Depends}
+Architecture: any
+Depends: ${misc:Depends}, ${debathena-thirdparty-depends}
+Recommends: ${debathena-thirdparty-recommends}
 Replaces: debathena-thirdparty-accessories, debathena-thirdparty-audio, debathena-thirdparty-communication, debathena-thirdparty-graphics, debathena-thirdparty-information, debathena-thirdparty-languages, debathena-thirdparty-libraries, debathena-thirdparty-numerical, debathena-thirdparty-programming, debathena-thirdparty-simulation, debathena-thirdparty-sound, debathena-thirdparty-text, debathena-thirdparty-utilities
 Breaks: debathena-thirdparty-accessories, debathena-thirdparty-audio, debathena-thirdparty-communication, debathena-thirdparty-graphics, debathena-thirdparty-information, debathena-thirdparty-languages, debathena-thirdparty-libraries, debathena-thirdparty-numerical, debathena-thirdparty-programming, debathena-thirdparty-simulation, debathena-thirdparty-sound, debathena-thirdparty-text, debathena-thirdparty-utilities
 Description: Debathena thirdparty software, monolithic version
diff --git a/debian/debathena-thirdparty.defs b/debian/debathena-thirdparty.defs
deleted file mode 100644
index 80b07dc..0000000
--- a/debian/debathena-thirdparty.defs
+++ /dev/null
@@ -1,2 +0,0 @@
-thirdparty	cat /var/lib/debathena-thirdparty/status
-thirdparty-upd	test -e /var/lib/debathena-thirdparty/update_required && echo no || echo yes
diff --git a/debian/debathena-thirdparty.install b/debian/debathena-thirdparty.install
deleted file mode 100644
index b03f148..0000000
--- a/debian/debathena-thirdparty.install
+++ /dev/null
@@ -1,4 +0,0 @@
-dependencies var/lib/debathena-thirdparty
-recommendations var/lib/debathena-thirdparty
-debian/thirdparty usr/lib/debathena-thirdparty
-debian/debathena-thirdparty.defs etc/athena/athinfo.defs.d
diff --git a/debian/debathena-thirdparty.postinst b/debian/debathena-thirdparty.postinst
deleted file mode 100644
index 93015a4..0000000
--- a/debian/debathena-thirdparty.postinst
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-# postinst script for debathena-thirdparty
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postinst> `configure' <most-recently-configured-version>
-#        * <old-postinst> `abort-upgrade' <new version>
-#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-#          <new-version>
-#        * <postinst> `abort-remove'
-#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-#          <failed-install-package> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-    configure)
-	touch /var/lib/debathena-thirdparty/update_required
-	echo "ok|Package configured" > /var/lib/debathena-thirdparty/status
-    ;;
-
-    abort-upgrade|abort-remove|abort-deconfigure)
-    ;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/debathena-thirdparty.prerm b/debian/debathena-thirdparty.prerm
deleted file mode 100644
index 22803ab..0000000
--- a/debian/debathena-thirdparty.prerm
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-# prerm script for #PACKAGE#
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <prerm> `remove'
-#        * <old-prerm> `upgrade' <new-version>
-#        * <new-prerm> `failed-upgrade' <old-version>
-#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
-#        * <deconfigured's-prerm> `deconfigure' `in-favour'
-#          <package-being-installed> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-    remove|deconfigure)
-	rm -f /var/lib/debathena-thirdparty/status
-	rm -f /var/lib/debathena-thirdparty/update_required
-    ;;
-
-    upgrade)
-    ;;
-
-    failed-upgrade)
-    ;;
-
-    *)
-        echo "prerm called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/rules b/debian/rules
index 9a5be8f..b245476 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,10 +1,12 @@
 #!/usr/bin/make -f
 
-include /usr/share/cdbs/1/rules/debhelper.mk
+%:
+	dh $@
 
-common-build-indep::
+override_dh_gencontrol:
 	./generate-package-list.pl
+	dh_gencontrol -- -Tthirdparty.substvars
 
-clean::
-	rm -f recommendations dependencies
-
+override_dh_clean:
+	dh_clean
+	rm -f thirdparty.substvars
diff --git a/debian/thirdparty b/debian/thirdparty
deleted file mode 100755
index ad80768..0000000
--- a/debian/thirdparty
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/bin/sh
-#
-# debathena-thirdparty "installer"
-#
-# Consider "set -e" at some point
-
-LISTDIR=/var/lib/debathena-thirdparty
-LOG=/var/log/athena-thirdparty
-STATFILE=/var/lib/debathena-thirdparty/status
-FLAGFILE=/var/lib/debathena-thirdparty/update_required
-NOLOGIN=/var/run/athena-nologin
-
-status=ok
-statusmsg="Nothing to do"
-
-complain() {
-    status="error"
-    statusmsg="$*"
-}
-
-whine() {
-    status="warning"
-    statusmsg="$*"
-}
-	
-save_state() {
-    rm -f $STATFILE
-    echo "$status|$statusmsg" > $STATFILE
-}  
-
-save_success() {
-    status="ok"
-    statusmsg="$*"
-}
-
-finish() {
-    echo "*Ending thirdparty installation at $(date)"
-    echo "-----"
-    echo
-    rm -f $NOLOGIN
-    save_state
-    exit
-}
-
-should_install() {
-    # Removing any debathena package is not allowed.
-    if apt-get -s install "$@" | egrep -q '^Remv debathena-'; then
-	return 1
-    else
-	return 0
-    fi
-}
-
-install() {
-    if [ "0" != "$(id -u)" ]; then
-	echo "Root privileges required for installation." >&2
-	exit 1
-    fi
-    touch $NOLOGIN
-    exec 3>&1
-    exec >> $LOG 2>&1
-    trap finish EXIT
-    echo "** Beginning thirdparty installation at $(date)"
-    export DEBIAN_FRONTEND=noninteractive
-    echo "** Required package list:"
-    cat "${LISTDIR}/dependencies"
-    echo "** Trying monolithic transaction..."
-    if should_install $(cat ${LISTDIR}/dependencies); then
-	echo "** Simulation successful, continuing..."
-	if apt-get -y install $(cat ${LISTDIR}/dependencies); then
-	    echo "** Monolithic transaction succeeded."
-	else
-	    echo "** Monolitic transaction failed (shouldn't happen)"
-	fi
-    else
-	echo "** Simulation unsuccessful (would remove debathena packages)"
-	echo "** Installing required packages one by one..."
-	for pkg in $(cat "${LISTDIR}/dependencies"); do
-	    echo "** Installing $pkg..."
-	    if ! should_install $pkg; then
-		echo "** Installation of $pkg is IMPOSSIBLE"
-		complain "Some required packages are impossible to install"
-	    else
-		apt-get -y install $pkg
-		if [ $? != 0 ]; then
-		    echo "** Installation of $pkg FAILED"
-		    complain "Some required packages failed to install"
-		fi
-	    fi
-	done
-    fi
-    echo "** Recommended package list:"
-    cat "${LISTDIR}/recommendations"
-    echo "** Installing recommended packages..."
-    for pkg in $(cat "${LISTDIR}/recommendations"); do
-	echo "** Installing $pkg..."
-	if ! should_install $pkg; then
-	    echo "** Installation of $pkg is IMPOSSIBLE"
-	    whine "Some optional packages are impossible to install"
-	else
-	    apt-get -y install $pkg
-	    if [ $? != 0 ]; then
-		echo "** Installation of $pkg FAILED"
-		whine "Some optional packages failed to install"
-	    fi
-	fi
-    done
-    rm $FLAGFILE
-    save_success "Packages installed ok"
-}
-
-case "$1" in 
-    install)
-	install
-	;;
-    up-to-date)
-	[ -e "$FLAGFILE" ] && exit 1
-	exit 0
-	;;
-    *)
-	echo "Usage: $0 [install | up-to-date]"
-	exit 1
-	;;
-esac
-exit 0
-
-
-    
diff --git a/generate-package-list.pl b/generate-package-list.pl
index e11c000..605f31f 100755
--- a/generate-package-list.pl
+++ b/generate-package-list.pl
@@ -7,6 +7,7 @@ use locale; # for sort
 use Cwd qw(abs_path);
 use File::Basename;
 
+use File::Temp qw(tempdir);
 use Getopt::Std;
 use AptPkg::Config '$_config';
 use AptPkg::Cache;
@@ -24,6 +25,17 @@ sub debug {
     }
 }
 
+sub run_command {
+    my @cmd = @_;
+    debug("Running: " . join(' ', @cmd));
+    my $rv = system(@cmd);
+    if ($rv == -1) {
+	die "Failed to execute command: $!\n";
+    } elsif ($rv != 0) {
+	die "$cmd[0] died with status: " . ($? >> 8) . "\n";
+    }
+}
+
 my $codename = `lsb_release -sc`;
 die "Can't determine codename" unless ($? == 0);
 chomp($codename);
@@ -33,6 +45,24 @@ chomp($codename);
 
 print "Using lists in $opt_l\nWriting output files to $opt_d\n";
 
+my $lsbrelease = `lsb_release -is`;
+chomp $lsbrelease;
+debug("lsb release: $lsbrelease");
+my $chdist_dir = tempdir(CLEANUP=>1);
+if ($lsbrelease eq 'Ubuntu') {
+    my $mirrorhost = 'localhost:9999';
+    if (exists($ENV{'MIRRORHOST'})) {
+	$mirrorhost = $ENV{'MIRRORHOST'};
+    }
+    debug("Ubuntu detected.");
+    run_command('chdist', '--data-dir', $chdist_dir, 'create', $codename,
+		'http://' . $mirrorhost . '/ubuntu', $codename,
+		'main', 'restricted', 'universe', 'multiverse');
+    run_command('chdist', '--data-dir', $chdist_dir,
+		'apt-get', $codename, 'update');
+    $ENV{'APT_CONFIG'} = join('/', $chdist_dir, $codename, 'etc/apt/apt.conf');
+}
+
 debug("Initializing APT cache");
 # Initialize the APT configuration
 $_config->init;
@@ -51,8 +81,7 @@ while (<COMMON>) {
     next if /^#/;
     next unless /\S/;
     if (/^-/) {
-	warn "Ignoring invalid package exclusion in the common file, line $.";
-	next;
+	die "Syntax error: package exclusion in the common file, line $.";
     } 
     if (/^(\S+) \| (\S+)$/) {
 	debug("Examining conditional line: $_");
@@ -81,30 +110,34 @@ while (<COMMON>) {
 }
 close(COMMON);
 
-open(DIST, join('/', $opt_l, $codename)) || die "Can't open $opt_l/$codename";
-debug("Reading distro-specific file");
-while (<DIST>) {
-    chomp;
-    s/^\s+//;
-    s/\s+$//;
-    next if /^#/;
-    next unless /\S/;
-    if (/^-(\S+)$/) {
-	if (exists($packages{$1})) {
-	    debug("Deleting $1 from package list.");
-	    delete($packages{$1});
+if (-f join('/', $opt_l, $codename)) {
+    open(DIST, join('/', $opt_l, $codename)) || die "Can't open $opt_l/$codename";
+    debug("Reading distro-specific file");
+    while (<DIST>) {
+	chomp;
+	s/^\s+//;
+	s/\s+$//;
+	next if /^#/;
+	next unless /\S/;
+	if (/^-(\S+)$/) {
+	    if (exists($packages{$1})) {
+		debug("Deleting $1 from package list.");
+		delete($packages{$1});
+	    } else {
+		warn("Package $1 is not in package list, so can't remove it.");
+	    }
+	} elsif (/^\?(\S+)$/) {
+	    debug("Adding $1 to recommendations");
+	    $packages{$1} = 2;
 	} else {
-	    warn("Package $1 is not in package list, so can't remove it.");
+	    debug("Adding $_ to dependencies");
+	    $packages{$_} = 1;
 	}
-    } elsif (/^\?(\S+)$/) {
-	debug("Adding $1 to recommendations");
-	$packages{$1} = 2;
-    } else {
-	debug("Adding $_ to dependencies");
-	$packages{$_} = 1;
     }
+    close(DIST);
+} else {
+    print "Note: No distro-specific file found.\n";
 }
-close(DIST);
 
 foreach my $pkgname (sort(keys(%packages))) {
     my $pkg = $cache->{$pkgname};
@@ -132,18 +165,24 @@ foreach my $pkgname (sort(keys(%packages))) {
     }
 }
 
-debug("Writing out lists");
-open(DEPS, '>', join('/', $opt_d, 'dependencies')) || die "Can't open $opt_d/dependencies for writing";
-open(RECS, '>', join('/', $opt_d, 'recommendations')) || die "Can't open $opt_d/dependencies for writing";
-foreach (sort(keys(%packages))) {
-    if ($packages{$_} == 2) {
-	print RECS "$_\n";
+my @recs = ();
+my @deps = ();
+foreach my $p (sort(keys(%packages))) {
+    if ($packages{$p} == 2) {
+	push @recs, $p;
     } else {
-	print DEPS "$_\n";
+	push @deps, $p;
+	if (exists($depends{$p})) {
+	    foreach (@{$depends{$p}}) {
+		debug("Adding $_ because we added $p");
+		push @deps, $_;
+	    }
+	}
     }
 }
-close(DEPS);
-close(RECS);
+open(SUBSTVARS, '>', join('/', $opt_d, 'thirdparty.substvars')) || die "Can't write to $opt_d/thirdparty.substvars";
+printf SUBSTVARS "debathena-thirdparty-depends=%s\n", join(',', @deps);
+printf SUBSTVARS "debathena-thirdparty-recommends=%s\n", join(',', @recs);
+close(SUBSTVARS);
 print "Done.\n";
 exit 0;
-	

home help back first fref pref prev next nref lref last post