From e62c2357b2764e6cb30bff1ec510ec21f7efcab5 Mon Sep 17 00:00:00 2001 From: Michael Howe Date: Tue, 5 Feb 2013 11:53:41 +0000 Subject: [PATCH] Addition of build-package (not yet ready to be deployed) --- bin/build-package | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 bin/build-package diff --git a/bin/build-package b/bin/build-package new file mode 100755 index 0000000..271384b --- /dev/null +++ b/bin/build-package @@ -0,0 +1,81 @@ +#!/usr/bin/perl +# +# Script to build Debian packages. +# +use strict; +use warnings; +use Getopt::Long; +use File::Temp qw/tempdir/; +use Cwd; + +my $svn = "/usr/bin/svn"; +my $dpkgsource = "/usr/bin/dpkg-source"; +my $cowpoke = "/usr/bin/cowpoke"; +my $rsync = "/usr/bin/rsync"; +my $debsign = "/usr/bin/debsign"; +my @debsign_opts = (); + +my $buildhost = "wowbagger.internal.michaelhowe.org"; + +my $arch = 'amd64'; +my $dist = 'squeeze'; + +my $path = $ARGV[0]; + +unless( $path ){ + die "Error - no path specified\n"; +} + +my $workingdir = getcwd(); + +my $exportdir = tempdir( CLEANUP => 1 ); + +my @exportcmd = ( $svn, 'export', $path, "$exportdir/export" ); +print "Running '@exportcmd'\n"; +system( @exportcmd ) == 0 + or die "Could not run svn export: $!"; + +chdir( $exportdir ) + or die "Can't chdir to $exportdir: $!"; + +my @sourcecmd = ( $dpkgsource, "-b", "$exportdir/export" ); + +system( @sourcecmd ) ==0 + or die "Could not run dpkg-source: $!"; + +print "Built in $exportdir\n"; + +chdir( $workingdir ); + +my ( $dscfile ) = glob( "$exportdir/*.dsc" ); +my $remote_uploaddir = "cowbuilder-incoming/$$"; +warn "Statically defined /home/michael!"; +my $remote_outputdir = "/home/michael/cowbuilder-outgoing/$$"; # FIXME + +$ENV{INCOMING_DIR} = $remote_uploaddir; +my $resdirname = "${arch}_${dist}_RESULT_DIR"; + +$ENV{$resdirname} = "$remote_outputdir"; +my @cowpokecmd = ( $cowpoke, "--arch=$arch", "--dist=$dist", $dscfile ); +print "Running @cowpokecmd"; +system( @cowpokecmd ) == 0 + or die "Could not run cowpoke: $!"; + +my $local_outputdir = tempdir( DIR => $workingdir ); + +my @rsynccmd = ( $rsync, "-az", "$buildhost:$remote_outputdir/", "$local_outputdir/" ); +print "Running @rsynccmd\n"; +system( @rsynccmd ) == 0 + or die "Could not run rsync: $!"; + +# Clean up remote side: +# Note that this currently won't work +#my @sshcleanupcmd = ( $ssh, "rm", "-rf", $remote_outputdir ); + +my @changefiles = glob( "$local_outputdir/*.changes" ); + +foreach my $changefile ( @changefiles ){ + my @debsigncmd = ( $debsign, @debsign_opts, $changefile ); + system( @debsigncmd ) == 0 + or warn "Could not sign changes file $changefile: $!"; +} -- 2.39.5