1999-11-11 16:10:37 -01:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use strict;
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
use Compress::Zlib;
|
2006-12-10 17:57:29 -01:00
|
|
|
use File::stat;
|
1999-11-11 16:10:37 -01:00
|
|
|
|
|
|
|
my $mirror = $ENV{'MIRROR'} || die "Set the MIRROR var ...\n";
|
2000-06-30 00:04:03 +00:00
|
|
|
my $localdebs = $ENV{'LOCALDEBS'} || $mirror;
|
2002-03-21 17:30:24 -01:00
|
|
|
my $security = $ENV{'SECURITY'} || $mirror;
|
1999-11-11 16:10:37 -01:00
|
|
|
my $basedir = $ENV{'BASEDIR'} || die "Set the BASEDIR var ...\n";
|
2005-12-13 01:04:33 -01:00
|
|
|
my $codename = $ENV{'CODENAME'} || die "Set the CODENAME var ...\n";
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
my $tdir = $ENV{'TDIR'} || die "Set the TDIR var ...\n";
|
1999-11-11 16:10:37 -01:00
|
|
|
|
2006-12-10 17:57:29 -01:00
|
|
|
require "$basedir/tools/link.pl";
|
1999-11-11 16:10:37 -01:00
|
|
|
|
2006-12-10 17:57:29 -01:00
|
|
|
my $iso_blksize = 2048;
|
|
|
|
my $log_opened = 0;
|
|
|
|
my $old_split = $/;
|
1999-11-11 16:10:37 -01:00
|
|
|
|
2006-12-10 17:57:29 -01:00
|
|
|
sub msg_ap {
|
2006-12-11 16:52:25 -01:00
|
|
|
my $level = shift;
|
|
|
|
if (!$log_opened) {
|
2006-12-29 04:57:21 -01:00
|
|
|
open(AP_LOG, ">> $tdir/$codename/log.add_packages")
|
|
|
|
|| die "Can't write in $tdir/log.add_packages!\n";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
print AP_LOG @_;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub size_in_blocks {
|
|
|
|
my $size_in_bytes = shift;
|
|
|
|
return (1 + int(($size_in_bytes + $iso_blksize - 1) / $iso_blksize));
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
# From a package name and section, work out the directory where its
|
|
|
|
# corresponding Packages file should live
|
|
|
|
sub Packages_dir {
|
2006-12-11 16:52:25 -01:00
|
|
|
my $dir = shift;
|
|
|
|
my $file = shift;
|
|
|
|
my $section = shift;
|
|
|
|
|
|
|
|
my ($pdir, $dist);
|
|
|
|
|
|
|
|
if ($file =~ /\/main\//) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$dist = "main";
|
2006-12-11 16:52:25 -01:00
|
|
|
} elsif ($file =~ /\/contrib\//) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$dist = "contrib";
|
2006-12-11 16:52:25 -01:00
|
|
|
} elsif ($file =~ /\/non-free\//) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$dist = "non-free";
|
2007-05-12 01:35:39 +00:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
$dist = "local";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
$pdir = "$dir/dists/$codename/$dist";
|
|
|
|
if ($section eq "debian-installer") {
|
2006-12-29 04:57:21 -01:00
|
|
|
$pdir = "$dir/dists/$codename/$dist/debian-installer";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
return $pdir;
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Dump the apt-cached data into a Packages file; make the parent dir
|
|
|
|
# for the Packages file if necesssary
|
|
|
|
sub add_Packages_entry {
|
2006-12-11 16:52:25 -01:00
|
|
|
my ($p, $file, $section, $pdir, $pkgfile, $gz);
|
|
|
|
my $dir = shift;
|
|
|
|
my $arch = shift;
|
|
|
|
my ($st1, $st2, $size1, $size2);
|
|
|
|
my $blocks_added = 0;
|
|
|
|
my $old_blocks = 0;
|
|
|
|
my $new_blocks = 0;
|
|
|
|
|
|
|
|
m/^Package: (\S+)/m and $p = $1;
|
|
|
|
m/^Section: (\S+)/m and $section = $1;
|
|
|
|
|
|
|
|
if ($arch eq "source") {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Directory: (\S+)/mi and $file = $1;
|
|
|
|
$pdir = Packages_dir($dir, $file, $section) . "/source";
|
|
|
|
$pkgfile = "$pdir/Sources";
|
2006-12-11 16:52:25 -01:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Filename: (\S+)/mi and $file = $1;
|
|
|
|
$pdir = Packages_dir($dir, $file, $section) . "/binary-$arch";
|
|
|
|
$pkgfile = "$pdir/Packages";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_ap(0, " Adding $p to $pkgfile(.gz)\n");
|
|
|
|
|
|
|
|
if (! -d $pdir) {
|
2006-12-29 04:57:21 -01:00
|
|
|
system("mkdir -p $pdir");
|
|
|
|
$blocks_added++;
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (-e $pkgfile) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$st1 = stat("$pkgfile");
|
|
|
|
$old_blocks = size_in_blocks($st1->size);
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (-e "$pkgfile.gz") {
|
2006-12-29 04:57:21 -01:00
|
|
|
$st1 = stat("$pkgfile.gz");
|
|
|
|
$old_blocks += size_in_blocks($st1->size);
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
open(PFILE, ">>$pkgfile");
|
|
|
|
print PFILE $_;
|
|
|
|
close(PFILE);
|
|
|
|
|
|
|
|
$gz = gzopen("$pkgfile.gz", "ab9") or die "Failed to open $pkgfile.gz: $gzerrno\n";
|
|
|
|
$gz->gzwrite($_) or die "Failed to write $pkgfile.gz: $gzerrno\n";
|
|
|
|
$gz->gzclose();
|
|
|
|
$st1 = stat("$pkgfile");
|
|
|
|
$st2 = stat("$pkgfile.gz");
|
|
|
|
$size1 = $st1->size;
|
|
|
|
$size2 = $st2->size;
|
|
|
|
|
|
|
|
$new_blocks += size_in_blocks($st1->size);
|
|
|
|
$new_blocks += size_in_blocks($st2->size);
|
|
|
|
$blocks_added += ($new_blocks - $old_blocks);
|
|
|
|
msg_ap(0, " now $size1 / $size2 bytes, $blocks_added blocks added\n");
|
|
|
|
return $blocks_added;
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub add_md5_entry {
|
2006-12-11 16:52:25 -01:00
|
|
|
my $dir = shift;
|
|
|
|
my $arch = shift;
|
|
|
|
my ($pdir, $file, $md5);
|
|
|
|
my $md5file = "$dir/md5sum.txt";
|
|
|
|
my ($st, $size);
|
|
|
|
my $p;
|
|
|
|
my $blocks_added = 0;
|
|
|
|
my $old_blocks = 0;
|
|
|
|
my $new_blocks = 0;
|
|
|
|
|
|
|
|
m/^Package: (\S+)/mi and $p = $1;
|
|
|
|
|
|
|
|
if (-e $md5file) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$st = stat("$md5file");
|
|
|
|
$old_blocks = size_in_blocks($st->size);
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
open(MD5FILE, ">>$md5file");
|
|
|
|
|
|
|
|
if ($arch eq "source") {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Directory: (\S+)/mi and $pdir = $1;
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*dsc)/m and print MD5FILE "$1 ./$pdir/$3\n";
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*tar.gz)/m and print MD5FILE "$1 ./$pdir/$3\n";
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*diff.gz)/m and print MD5FILE "$1 ./$pdir/$3\n";
|
2006-12-11 16:52:25 -01:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Filename: (\S+)/m and $file = $1;
|
|
|
|
m/^MD5sum: (\S+)/m and print MD5FILE "$1 ./$file\n";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
close(MD5FILE);
|
|
|
|
msg_ap(0, " Adding $p to $md5file\n");
|
|
|
|
$st = stat("$md5file");
|
|
|
|
$size = $st->size;
|
|
|
|
$new_blocks = size_in_blocks($st->size);
|
|
|
|
$blocks_added = $new_blocks - $old_blocks;
|
|
|
|
msg_ap(0, " now $size bytes, added $blocks_added blocks\n");
|
|
|
|
|
|
|
|
return $blocks_added;
|
1999-11-11 16:10:37 -01:00
|
|
|
}
|
|
|
|
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
# Roll back the results of add_Packages_entry()
|
|
|
|
sub remove_Packages_entry {
|
2006-12-11 16:52:25 -01:00
|
|
|
my ($p, $file, $section, $pdir, $pkgfile, $tmp_pkgfile, $match, $gz);
|
|
|
|
my $dir = shift;
|
|
|
|
my $arch = shift;
|
|
|
|
my ($st1, $st2, $size1, $size2);
|
|
|
|
my $blocks_removed = 0;
|
|
|
|
my $old_blocks = 0;
|
|
|
|
my $new_blocks = 0;
|
|
|
|
|
|
|
|
m/^Package: (\S+)/m and $p = $1;
|
|
|
|
m/^Section: (\S+)/m and $section = $1;
|
|
|
|
|
|
|
|
if ($arch eq "source") {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Directory: (\S+)/mi and $file = $1;
|
|
|
|
$pdir = Packages_dir($dir, $file, $section) . "/source";
|
|
|
|
$pkgfile = "$pdir/Sources";
|
2006-12-11 16:52:25 -01:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Filename: (\S+)/mi and $file = $1;
|
|
|
|
$pdir = Packages_dir($dir, $file, $section) . "/binary-$arch";
|
|
|
|
$pkgfile = "$pdir/Packages";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (-e $pkgfile) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$st1 = stat("$pkgfile");
|
|
|
|
$old_blocks += size_in_blocks($st1->size);
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
if (-e "$pkgfile.gz") {
|
2006-12-29 04:57:21 -01:00
|
|
|
$st2 = stat("$pkgfile.gz");
|
|
|
|
$old_blocks += size_in_blocks($st2->size);
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
$tmp_pkgfile = "$pkgfile" . ".rollback";
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
msg_ap(0, " Removing $p from $pkgfile(.gz)\n");
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
open(IFILE, "<$pkgfile");
|
|
|
|
open(OFILE, ">>$tmp_pkgfile");
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
$gz = gzopen("$pkgfile.gz", "wb9");
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
while (defined($match = <IFILE>)) {
|
2006-12-29 04:57:21 -01:00
|
|
|
if (! ($match =~ /^Package: \Q$p\E$/m)) {
|
|
|
|
print OFILE $match;
|
|
|
|
$gz->gzwrite($match) or die "Failed to write $pkgfile.gz: $gzerrno\n";
|
|
|
|
}
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
$gz->gzclose();
|
|
|
|
close(IFILE);
|
|
|
|
close(OFILE);
|
|
|
|
|
|
|
|
rename $tmp_pkgfile, $pkgfile;
|
|
|
|
$st1 = stat("$pkgfile");
|
|
|
|
$st2 = stat("$pkgfile.gz");
|
|
|
|
$size1 = $st1->size;
|
|
|
|
$size2 = $st2->size;
|
|
|
|
$new_blocks += size_in_blocks($st1->size);
|
|
|
|
$new_blocks += size_in_blocks($st2->size);
|
|
|
|
$blocks_removed += ($old_blocks - $new_blocks);
|
|
|
|
msg_ap(0, " now $size1 / $size2 bytes, $blocks_removed blocks removed\n");
|
|
|
|
return $blocks_removed;
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub remove_md5_entry {
|
2006-12-11 16:52:25 -01:00
|
|
|
my $dir = shift;
|
|
|
|
my $arch = shift;
|
|
|
|
my ($pdir, $file, $md5, $match, $present);
|
|
|
|
my $md5file = "$dir/md5sum.txt";
|
|
|
|
my $tmp_md5file = "$dir/md5sum.txt.tmp";
|
|
|
|
my @fileslist;
|
|
|
|
my ($st, $size, $p);
|
|
|
|
my $blocks_removed = 0;
|
|
|
|
my $old_blocks = 0;
|
|
|
|
my $new_blocks = 0;
|
|
|
|
|
|
|
|
$/ = $old_split; # Browse by line again
|
|
|
|
|
|
|
|
m/^Package: (\S+)/mi and $p = $1;
|
|
|
|
if ($arch eq "source") {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Directory: (\S+)/mi and $pdir = $1;
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*dsc)/m and push(@fileslist, "$1 ./$pdir/$3");
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*diff.gz)/m and push(@fileslist, "$1 ./$pdir/$3");
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*tar.gz)/m and push(@fileslist, "$1 ./$pdir/$3");
|
2006-12-11 16:52:25 -01:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
m/^Filename: (\S+)/m and $file = $1;
|
|
|
|
m/^MD5Sum: (\S+)/mi and push(@fileslist, "$1 ./$file");
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (-e $md5file) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$st = stat("$md5file");
|
|
|
|
$old_blocks = size_in_blocks($st->size);
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
open(IFILE, "<$md5file");
|
|
|
|
open(OFILE, ">>$tmp_md5file");
|
|
|
|
while (defined($match = <IFILE>)) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$present = 0;
|
|
|
|
foreach my $entry (@fileslist) {
|
|
|
|
if (($match =~ /\Q$entry\E$/m)) {
|
|
|
|
$present++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$present) {
|
|
|
|
print OFILE $match;
|
|
|
|
}
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
close(IFILE);
|
|
|
|
close(OFILE);
|
|
|
|
|
|
|
|
$/ = ''; # Browse by paragraph again
|
|
|
|
rename $tmp_md5file, $md5file;
|
|
|
|
msg_ap(0, " Removing $p from md5sum.txt\n");
|
|
|
|
$st = stat("$dir/md5sum.txt");
|
|
|
|
$size = $st->size;
|
|
|
|
$new_blocks = size_in_blocks($st->size);
|
|
|
|
$blocks_removed = $old_blocks - $new_blocks;
|
|
|
|
msg_ap(0, " now $size bytes, $blocks_removed blocks removed\n");
|
|
|
|
return $blocks_removed;
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
2006-12-11 16:52:25 -01:00
|
|
|
sub get_file_blocks {
|
|
|
|
my $realfile = shift;
|
|
|
|
my $st;
|
2007-01-22 22:06:30 -01:00
|
|
|
$st = stat($realfile) or die "unable to stat file $realfile: $!\n";
|
2006-12-11 16:52:25 -01:00
|
|
|
return size_in_blocks($st->size);
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
2006-12-10 17:57:29 -01:00
|
|
|
sub add_packages {
|
2006-12-11 16:52:25 -01:00
|
|
|
my ($p, @files, $d, $realfile, $source, $section, $name, $pkgfile, $pdir);
|
2006-12-29 04:57:21 -01:00
|
|
|
my $dir;
|
2006-12-11 16:52:25 -01:00
|
|
|
|
|
|
|
my $total_blocks = 0;
|
|
|
|
my $rollback = 0;
|
|
|
|
my $option = shift;
|
|
|
|
if ($option =~ /--rollback/) {
|
2006-12-29 04:57:21 -01:00
|
|
|
$rollback = 1;
|
|
|
|
$dir = shift;
|
2006-12-11 16:52:25 -01:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
$dir = $option;
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! -d $dir) {
|
2006-12-29 04:57:21 -01:00
|
|
|
die "add_packages: $dir is not a directory ...";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
2006-12-29 04:57:21 -01:00
|
|
|
my $pkg = shift;
|
2007-04-19 23:38:29 +00:00
|
|
|
my ($arch, $component, $pkgname) = split /:/, $pkg;
|
2006-12-11 16:52:25 -01:00
|
|
|
|
|
|
|
msg_ap(0, "Looking at $pkg: arch $arch, package $pkgname, rollback $rollback\n");
|
|
|
|
|
|
|
|
$/ = ''; # Browse by paragraph
|
|
|
|
|
|
|
|
$ENV{'ARCH'} = $arch;
|
|
|
|
if ($arch eq "source") {
|
2006-12-29 04:57:21 -01:00
|
|
|
open (LIST, "$basedir/tools/apt-selection cache showsrc $pkgname |")
|
|
|
|
|| die "Can't fork : $!\n";
|
2006-12-11 16:52:25 -01:00
|
|
|
} else {
|
2006-12-29 04:57:21 -01:00
|
|
|
open (LIST, "$basedir/tools/apt-selection cache show $pkgname |")
|
|
|
|
|| die "Can't fork : $!\n";
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
while (defined($_ = <LIST>)) {
|
2006-12-29 04:57:21 -01:00
|
|
|
undef @files;
|
|
|
|
|
|
|
|
m/^Package: (\S+)/m and $p = $1;
|
|
|
|
m/^Section: (\S+)/m and $section = $1;
|
|
|
|
|
|
|
|
$source = $mirror;
|
|
|
|
if ($arch eq "source") {
|
|
|
|
m/^Directory: (\S+)/m and $pdir = $1;
|
|
|
|
$source=$security if $pdir=~m:updates/:;
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*dsc)/m and push(@files, "$pdir/$3");
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*diff.gz)/m and push(@files, "$pdir/$3");
|
|
|
|
m/^ (\S+) (\S+) ((\S+).*tar.gz)/m and push(@files, "$pdir/$3");
|
|
|
|
} else {
|
|
|
|
m/^Filename: (\S+)/mi and push(@files, $1);
|
|
|
|
$source=$security if $1=~m:updates/:;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($rollback) {
|
|
|
|
# Remove the Packages entry/entries for the specified package
|
|
|
|
$total_blocks -= remove_Packages_entry($dir, $arch, $_);
|
|
|
|
$total_blocks -= remove_md5_entry($dir, $arch, $_);
|
|
|
|
|
|
|
|
foreach my $file (@files) {
|
2007-05-12 01:28:47 +00:00
|
|
|
my $missing = 0;
|
2006-12-29 04:57:21 -01:00
|
|
|
# Count how big the file is we're removing, for checking if the disc is full
|
2007-05-12 01:28:47 +00:00
|
|
|
if (! -e "$source/$file") {
|
|
|
|
msg_ap(0, "Can't find $file in the main archive, trying local\n");
|
|
|
|
if (-e "$localdebs/$file") {
|
|
|
|
$source = $localdebs;
|
|
|
|
} else {
|
|
|
|
die "$file not found under either $source or $localdebs\n";
|
|
|
|
}
|
|
|
|
}
|
2006-12-29 04:57:21 -01:00
|
|
|
$realfile = real_file ("$source/$file");
|
|
|
|
$total_blocks -= get_file_blocks($realfile);
|
|
|
|
|
|
|
|
# Remove the link
|
2007-02-27 19:05:32 -01:00
|
|
|
unlink ("$dir/$file") || msg_ap(0, "Couldn't delete file $dir/$file\n");
|
|
|
|
msg_ap(0, " Rollback: removed $dir/$file\n");
|
2006-12-29 04:57:21 -01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$total_blocks += add_Packages_entry($dir, $arch, $_);
|
|
|
|
$total_blocks += add_md5_entry($dir, $arch, $_);
|
|
|
|
|
|
|
|
foreach my $file (@files) {
|
2007-05-12 01:28:47 +00:00
|
|
|
|
2006-12-29 04:57:21 -01:00
|
|
|
# And put the file in the CD tree (with a (hard) link)
|
2007-05-12 01:28:47 +00:00
|
|
|
if (! -e "$source/$file") {
|
|
|
|
msg_ap(0, "Can't find $file in the main archive, trying local\n");
|
|
|
|
if (-e "$localdebs/$file") {
|
|
|
|
$source = $localdebs;
|
|
|
|
} else {
|
|
|
|
die "$file not found under either $source or $localdebs\n";
|
|
|
|
}
|
|
|
|
}
|
2006-12-29 04:57:21 -01:00
|
|
|
$realfile = real_file ("$source/$file");
|
|
|
|
|
|
|
|
if (! -e "$dir/$file") {
|
|
|
|
# Count how big the file is, for checking if the disc
|
|
|
|
# is full. ONLY do this if the file is not already
|
|
|
|
# linked in - consider binary-all packages on a
|
|
|
|
# multi-arch disc
|
|
|
|
$total_blocks += get_file_blocks($realfile);
|
|
|
|
$total_blocks += good_link ($realfile, "$dir/$file");
|
|
|
|
msg_ap(0, " Linked $dir/$file\n");
|
|
|
|
} else {
|
|
|
|
msg_ap(0, " $dir/$file already linked in\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-11 16:52:25 -01:00
|
|
|
}
|
|
|
|
close LIST or die "Something went wrong with apt-cache : $@ ($!)\n";
|
|
|
|
msg_ap(0, " size $total_blocks\n");
|
|
|
|
$/ = $old_split; # Return to line-orientation
|
|
|
|
return $total_blocks;
|
Merge of changes from Steve's development branch to take us to
debian-cd version 3.0.0. Highlights:
* Support now added for multi-arch CDs/DVDs, including mixed
binary/source discs. Multi-arch discs should be bootable on those
multiple arches, modulo boot-sector clashes. Extra support added
in boot-i386 and boot-amd64 to make the 2 main arches happily
co-exist.
* Disc sizing is now much more intelligent - sizes are defined
depending on the disk type chosen at the start, and discs are now
filled exactly to those sizes while files are added rather than
the old up-front guessing method. Equally, the metadata on the
disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is
generated as much as possible while this is happening to make the
sizing code incredibly accurate. Using this method of disc sizing
means that customising discs should be much easier/safer - either
add custom contents at the start and debian-cd will fill the
remainder of the disc, or afterwards roll back the packages on the
disc and add extras later.
* Source is now treated as (almost) just another arch, with most of
the special casing for source hidden internally. If asking for
source-only discs, they will simply be built using all the
available sources. If combined with other arches, the sources will
automatically be chosen to match the binary packages. Meeting GPL
requirements was never so easy!
* Removed lots of old cruft to clean up the codebase:
+ non-US support
+ woody support
+ lots of old support scripts that have been made redundant
+ significantly simpler Makefile, much easier to follow
+ old boot-$ARCH.calc files for estimating boot-file sizes are now
(obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
|
|
|
}
|
|
|
|
|
2006-12-10 17:57:29 -01:00
|
|
|
1;
|