[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pbuilder automation



On Sun, Sep 29, 2002 at 10:05:49AM +1000, Brian May wrote:
> dpkg-buildpackage: automatically does 1, and 2, and leaves
> result in a known location for the next step.
> 
> debrelease: automatically uploads result to Debian.
> 
> This doesn't appear to be immediately possible with pbuilder,
> because pdebuild does not sign the package, put it
> in the location expected by debrelease, or even set the
> privileges correctly, to allow the non-root user write
> access.

I have hacked a perl function that takes a *.changes file as its input
parameter.

It will move (or rather copy) all files associated with this *.changes
file to ../ (the same location as dpkg-buildpackage).

It even seems to work! Amazing!

Then I attached the last two extra lines onto the end of pdebuild,
which will copy the files and sign them with debsign.

The only task left is to run debrelease to upload to Debian.
After you test the result of course.

The full scripts, in case anybody else wants them are attached.

No guarantees that this will work flawless, especially if you don't use
i386 (you will notice my hardcoded reference to i386 in pdebuild), but
these problems should be easy to fix.
--
Brian May <bam@snoopy.apana.org.au>
#! /bin/bash
set -e

while ! test -d ./debian -o "$(pwd)" = "/" ; do
    cd ..;
done

if test ! -d ./debian; then
    echo "Cannot find ./debian dir"
    exit 1
fi;

. /usr/lib/pbuilder/pbuilder-checkparams
dpkg-buildpackage -S -us -uc -r$BUILDSOURCEROOTCMD || true
$PBUILDERROOTCMD pbuilder build "$@" ../$(dpkg-parsechangelog|sed -n 's/^Source: //p')_$(dpkg-parsechangelog|sed -n 's/^Version: \(.*:\|\)//p').dsc
pdebuild-move /var/cache/pbuilder/result/$(dpkg-parsechangelog|sed -n 's/^Source: //p')_$(dpkg-parsechangelog|sed -n 's/^Version: \(.*:\|\)//p')_i386.changes
debsign ../$(dpkg-parsechangelog|sed -n 's/^Source: //p')_$(dpkg-parsechangelog|sed -n 's/^Version: \(.*:\|\)//p')_i386.changes
#!/usr/bin/perl -w
use strict;
use Digest::MD5;
use Proc::WaitStat qw(waitstat_die);

sub check($$$) {
	my ($md5sum,$size,$file) = @_;

        open(FILE, $file) or die "Can't open '$file': $!";
        binmode(FILE);

	my $calc = Digest::MD5->new->addfile(*FILE)->hexdigest;
	my $csize = -s $file;

	return 0 if ($md5sum ne $calc);
	return 0 if ($size != $csize);
	return 1;
}

my %package;
my %isok;

unshift(@ARGV, '-') unless @ARGV;
while ($ARGV = shift) {
  my $infile = $ARGV;

  my $package = undef;
  my $section = "top";
  my ($cpatch,$cfile) = ($ARGV =~ /^(.*\/)([^\/]*)$/);

  print "cp $infile ..\n";
  system("cp",$infile,"..");
  waitstat_die($?,"cp $infile ..");

  open(INFILE, $infile);
  while (<INFILE>) {
    if ($section eq "top") {
      if (/^Files:\s*$/) {
        $section = "files";
      } elsif (/^Source:\s*([\w\.-]+)$/) {
        $package = $1;
	print "---$1---\n";
	#$package{$package}{$cfile} = $ARGV;
	$isok{$package} = 1;
      }
    } elsif ($section eq "files") {
	if (/^\s*$/) {
		$section = "top";
	} else {
	    	my ($md5sum,$size,$section,$priority,$file) = split;

		my $path = $cpatch . $file;

		$package{$package}{$file} = $path;
		if (!check($md5sum,$size,$path)) {
			$isok{$package} = 0;
		    	print "Bad file $file in $ARGV\n";
		}
	}
    }
  }
}

for my $i (keys %package) {
	next if (!$isok{$i}); 

	for my $file (keys %{$package{$i}}) {
		my $path = $package{$i}{$file};
		print "cp $path ../$file\n";
		system("cp",$path,"../$file");
		waitstat_die($?,"cp $path ../$file");
	}
}
	

Reply to: