debian-cd-clone/tools/link.pl

66 lines
1.3 KiB
Perl
Raw Normal View History

1999-11-11 16:10:37 -01:00
#!/usr/bin/perl -w
use strict;
my $symlink_farm = $ENV{'SYMLINK'} || 0;
my $link_verbose = $ENV{'VERBOSE'} || 0;
my $link_copy = $ENV{'COPYLINK'} || 0;
1999-11-11 16:10:37 -01:00
sub good_link ($$) {
my ($src, $dest) = @_;
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
if (! -e $dest) {
# Check if the destination directory does exist
my $ddir = $dest;
$ddir =~ s#/?[^/]+$##g;
if ($ddir eq "")
{
$ddir = ".";
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
if (! -d $ddir) # Create it if not
{
system("mkdir -p $ddir");
}
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
# Link the files
if ($symlink_farm) {
print "Symlink: $dest => $src\n" if ($link_verbose >= 3);
if (not symlink ($src, $dest)) {
print STDERR "Symlink from $src to $dest failed: $!\n";
}
} elsif ($link_copy) {
print "Copy: $dest => $src\n" if ($link_verbose >= 3);
if (system("cp -ap $src $dest")) {
my $err_num = $? >> 8;
my $sig_num = $? & 127;
print STDERR "Copy from $src to $dest failed: cp exited with error code $err_num, signal $sig_num\n";
}
} else {
print "Hardlink: $dest => $src\n" if ($link_verbose >= 3);
if (not link ($src, $dest)) {
print STDERR "Link from $src to $dest failed: $!\n";
}
1999-11-11 16:10:37 -01:00
}
}
}
sub real_file ($) {
my $link = shift;
my ($dir, $to);
while (-l $link) {
$dir = $link;
$dir =~ s#[^/]+/?$##;
if ($to = readlink($link)) {
$link = $dir . $to;
} else {
print STDERR "Can't readlink $link: $!\n";
}
}
return $link;
}
1;