summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hudson-Doyle <[email protected]>2024-02-01 10:24:35 +1300
committerMichael Hudson-Doyle <[email protected]>2024-10-23 09:30:38 +0200
commit60f9d7a51683bd02a878ee195dda3d30907c9260 (patch)
treeadf6bbd2b1151801898f1d4b62378e002f616850
parent8c1125d936e828768bb9d34e39a60395a46555d0 (diff)
remove list2cds and everything to do with sizing images
list2cds is a complicated script that can check e.g. that all packages that a package on the ISO is also included and divides a set of packages into multiple ISOs each of which are under a certain size but we turn absolutely all of this functionality off and so we can replace its invocation with a call to 'cp'. Also remove all the slightly hairy code that tries to work out what size limit to pass to list2cds (which it was already ignoring).
-rw-r--r--CONF.sh39
-rw-r--r--Makefile6
-rwxr-xr-xbuild_all.sh30
-rwxr-xr-xtools/list2cds692
4 files changed, 5 insertions, 762 deletions
diff --git a/CONF.sh b/CONF.sh
index 927f9ba..5be0181 100644
--- a/CONF.sh
+++ b/CONF.sh
@@ -19,10 +19,6 @@ unset MKISOFS || true
unset MKISOFS_OPTS || true
unset ISOLINUX || true
unset EXCLUDE || true
-unset NODEPENDS || true
-unset NORECOMMENDS || true
-unset NOSUGGESTS || true
-unset DEFBINSIZE || true
unset FASTSUMS || true
unset DI_CODENAME || true
unset OMIT_MANUAL || true
@@ -247,37 +243,6 @@ export ISOLINUX=1
# the proper official CD run does not work
#ATTEMPT_FALLBACK=yes
-# Set your disk size here in MB. Used in calculating package and
-# source file layouts in build.sh and build_all.sh. Defaults are for
-# CD-R. For DVD-R the size limit is 4700372992 (see ubuntu-cdimage
-# lib/cdimage/tree.py:DailyTreePublisher.size_limit) but we express here
-# in MiB, so round down to 4482MiB (4699717632 bytes). If we round up to
-# 4483MiB we will *probably* still fit, but the limit would be 384KiB above
-# the actual limit so there's some risk of being oversize for media.
-if [ "$CDIMAGE_DVD" = 1 ]; then
- export DEFBINSIZE=4482
-else
- #export DEFBINSIZE=700
- export DEFBINSIZE=4600
-fi
-
-# We don't want certain packages to take up space on CD1...
-#export EXCLUDE="$BASEDIR"/tasks/exclude-sarge
-# ...but they are okay for other CDs (UNEXCLUDEx == may be included on CD >= x)
-#export UNEXCLUDE2="$BASEDIR"/tasks/unexclude-CD2-sarge
-# Any packages listed in EXCLUDE but not in any UNEXCLUDE will be
-# excluded completely.
-
-export NODEPENDS=1
-
-# Set this if the recommended packages should be skipped when adding
-# package on the CD. The default is 'false'.
-export NORECOMMENDS=1
-
-# Set this if the suggested packages should be skipped when adding
-# package on the CD. The default is 'true'.
-export NOSUGGESTS=1
-
# Image format:
# iso = Output an image in ISO 9660 format (.iso)
# img = Output a raw partitioned disk image (.img)
@@ -293,10 +258,6 @@ export FASTSUMS=1
# for all architectures.
#export KERNEL_PARAMS="priority=critical"
-# If set to 0, never overflow binary CDs (for when you only want a single CD
-# and want to know when it overflows).
-export OVERFLOWBINCDS=0
-
# If set, overrides the boot picture used.
if [ -z "$SPLASHRLE" ]; then
export SPLASHRLE="$BASEDIR/data/$DI_CODENAME/splash.rle"
diff --git a/Makefile b/Makefile
index bcea514..3b5ac59 100644
--- a/Makefile
+++ b/Makefile
@@ -20,9 +20,6 @@ export CPPARCH=$(subst -,_,$(subst +,_,$(FULLARCH)))
ifndef VERBOSE_MAKE
Q=@
endif
-ifndef SIZELIMIT
-export SIZELIMIT=$(shell echo -n $$[ 690 * 1024 * 1024 ])
-endif
ifndef TASK
ifneq (,$(wildcard $(BASEDIR)/tasks/auto/$(IMAGE_TYPE)/$(PROJECT)/$(DIST)/MASTER))
TASK=$(BASEDIR)/tasks/auto/$(IMAGE_TYPE)/$(PROJECT)/$(DIST)/MASTER
@@ -105,7 +102,6 @@ endif
## Internal variables
apt=$(BASEDIR)/tools/apt-selection
-list2cds=$(BASEDIR)/tools/list2cds
add_packages=$(BASEDIR)/tools/add_packages
add_dirs=$(BASEDIR)/tools/add_dirs
add_bin_doc=$(BASEDIR)/tools/add-bin-doc
@@ -291,7 +287,7 @@ list: bin-list
bin-list: ok apt-update bin-genlist $(BDIR)/1.packages
$(BDIR)/1.packages:
@echo "Dispatching the packages on all the CDs ..."
- $(Q)$(list2cds) $(BDIR)/list $(SIZELIMIT)
+ $(Q)cp $(BDIR)/list $(BDIR)/1.packages
# Generate the complete listing of packages from the task
# Build a nice list without doubles and without spaces
diff --git a/build_all.sh b/build_all.sh
index 51f9b26..6371093 100755
--- a/build_all.sh
+++ b/build_all.sh
@@ -29,36 +29,14 @@ do
make init
echo " ... selecting packages to include"
- SIZE_ARGS=''
- for CD in 1; do
- size=`eval echo '$'"BOOT_SIZE_${CD}"`
- [ "$size" = "" ] && size=0
- mult=`eval echo '$'"SIZE_MULT_${CD}"`
- [ "$mult" = "" ] && mult=100
- FULL_SIZE=`echo "($DEFBINSIZE - $size) * 1024 * 1024" | bc`
- echo "INFO: Reserving $size MB on CD $CD for boot files. SIZELIMIT=$FULL_SIZE."
- if [ $mult != 100 ]; then
- echo " INFO: Reserving "$((100-$mult))"% of the CD for extra metadata"
- FULL_SIZE=`echo "$FULL_SIZE * $mult" / 100 | bc`
- echo " INFO: SIZELIMIT now $FULL_SIZE."
- fi
- SIZE_ARGS="$SIZE_ARGS SIZELIMIT${CD}=$FULL_SIZE"
- done
+ make bin-list
echo " ... building the images"
- make bin-list $SIZE_ARGS
export OUT=$TMP_OUT/$FULLARCH; mkdir -p $OUT
- make bin-official_images $SIZE_ARGS
+ make bin-official_images
if [ $? -gt 0 ]; then
echo "ERROR WHILE BUILDING OFFICIAL IMAGES !!" >&2
- if [ "$ATTEMPT_FALLBACK" = "yes" ]; then
- echo "I'll try to build a simple (non-bootable) CD" >&2
- make clean
- make installtools
- make bin-images $SIZE_ARGS
- else
- # exit 1
- continue
- fi
+ # exit 1
+ continue
fi
echo Generating list files for images
make pi-makelist
diff --git a/tools/list2cds b/tools/list2cds
deleted file mode 100755
index e7884ee..0000000
--- a/tools/list2cds
+++ /dev/null
@@ -1,692 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Copyright 1999 Rapha�l Hertzog <[email protected]>
-# See the README file for the license
-#
-# This script takes 2 arguments on input :
-# - a filename listing all the packages to include
-# - a size-limit for each CD
-#
-
-use strict;
-
-my $list = shift;
-my $deflimit = $ENV{'SIZELIMIT'} || shift || 639631360;
-my $limit = $ENV{'SIZELIMIT1'} || $deflimit;
-
-my $nonfree = $ENV{'NONFREE'} || 0;
-my $extranonfree = $ENV{'EXTRANONFREE'} || 0;
-my $complete = $ENV{'COMPLETE'} || 0;
-my $exclude = "$list.exclude";
-my $nodepends = $ENV{'NODEPENDS'} || 0;
-my $norecommends = $ENV{'NORECOMMENDS'} || 0;
-my $nosuggests = $ENV{'NOSUGGESTS'} || 1;
-my $maxcds = 1;
-my $overflowbincds = $ENV{'OVERFLOWBINCDS'} || 1;
-
-my $apt = "$ENV{'BASEDIR'}/tools/apt-selection";
-my $dir = "$ENV{'TDIR'}/$ENV{'CODENAME'}-$ENV{'FULLARCH'}";
-my $verbose = $ENV{'VERBOSE'} || 0;
-
-$| = 1; # Autoflush for debugging
-
-open(LOG, ">$dir/log.list2cds") || die "Can't write in $dir/log.list2cds !\n";
-
-sub msg {
- my $level = shift;
- if ($verbose >= $level) {
- print @_;
- }
- print LOG @_;
-}
-
-my %included;
-my %excluded;
-my %packages;
-
-msg(0, "======================================================================
-Here are the settings you've chosen for making the list:
-List of prefered packages: $list
-Exclude file: $exclude
-");
-msg(0, "Complete selected packages with all the rest: "); msg(0, yesno($complete)."\n");
-msg(0, "Include non-free packages: "); msg(0, yesno($nonfree)."\n");
-msg(0, "======================================================================
-");
-
-# Get the information on all packages
-my $oldrs = $/;
-$/ = '';
-open(AVAIL, "$apt cache dumpavail |") || die "Can't fork : $!\n";
-my ($p, $re);
-while (defined($_=<AVAIL>)) {
- next if not m/^Package: (\S+)\s*$/m;
- $p = $1;
- $included{$p} = 0;
- $packages{$p}{"Package"} = $p;
- foreach $re (qw(Version Priority Section Filename Size MD5sum)) {
- (m/^$re: (\S+)\s*$/m and $packages{$p}{$re} = $1)
- || msg(1, "Header field '$re' missing for package '$p'.\n");
- }
- $packages{$p}{"Depends"} = [];
- $packages{$p}{"Suggests"} = [];
- $packages{$p}{"Recommends"} = [];
- $packages{$p}{"IsUdeb"} = ($packages{$p}{"Filename"} =~ /.udeb$/) ? 1 : 0;
-}
-close AVAIL or die "apt-cache failed : $@ ($!)\n";
-$/ = $oldrs;
-
-# Get the list of excluded packages
-%excluded = %included;
-my $count_excl = 0;
-if (-e $exclude) {
- open (EXCL, "< $exclude") || die "Can't open $exclude : $!\n";
- while (defined($_=<EXCL>)) {
- chomp;
- s/\#.*$//;
- next if m/^\s*$/;
- if (not exists $packages{$_}) {
- msg(1, "INIT: Package '$_' is in excluded but " .
- "doesn't exist. Ignored.\n");
- next;
- }
- $excluded{$_} = 'user choice';
- $count_excl++;
- }
- close EXCL;
-}
-
-# Now exclude more packages because of the non-free rules
-if (not $nonfree) {
- foreach (grep { $packages{$_}{"Section"} =~ /non-free/ }
- (keys %packages)) {
- $excluded{$_} = 'nonfree';
- $count_excl++;
- }
-}
-
-msg(0, "Statistics:
-Number of packages: @{ [scalar(keys %packages)] }
-Number of excluded: $count_excl of @{ [scalar(keys %excluded)] }
-======================================================================
-
-");
-
-open(STATS, "> $dir/stats.excluded")
- || die "Can't write in stats.excluded: $!\n";
-foreach (keys %excluded) {
- print STATS "$_ => $excluded{$_}\n";
-}
-close (STATS);
-
-# Browse the list of packages to include
-my ($total_size, $cd_size, $size, $cd) = (0, 0, 0, 1);
-my %cds;
-
-=pod
-# Generate a dependency tree for each package
-msg(0, "-- Generating dependencies tree with apt-cache depends...\n");
-my (@list) = keys %packages;
-while (@list) {
- my (@pkg) = splice(@list,0,200);
- $ENV{'LC_ALL'} = 'C'; # Required since apt is now translated
- open (APT, "$apt cache depends @pkg |") || die "Can't fork : $!\n";
- my (@res) = (<APT>);
- close APT or die "� apt-cache depends � failed ... \n" .
- "you must have apt >= 0.3.11.1 !\n";
- # Getting rid of conflicts/replaces/provides
- my $i = 0;
- my $nb_lines = scalar @res;
- push @res, ""; # Avoid warnings ...
- while ($i < $nb_lines) {
- if ($res[$i] !~ m/^(\S+)\s*$/) {
- msg(0, "UNEXPECTED: Line `$res[$i]' while parsing " .
- "end of deptree from '$p'\n");
- }
- $p = $1; $i++;
- msg(2, " Dependency tree of `$p' ...\n");
- read_depends (\$i, \@res, $p);
- }
-
-}
-=cut
-
-# Start to look for packages wanted by the user ...
-msg(0, "-- Starting to add packages to the CDs ...\n");
-open (LIST, "< $list") || die "Can't open $list : $!\n";
-while (defined($_=<LIST>)) {
- chomp;
- next if m/^\s*$/;
- if ($_ eq 'FORCE-CD-BREAK') {
- msg(0, "CD break encountered at $cd_size bytes.\n");
- new_cd();
- next;
- }
- if (not exists $packages{$_}) {
- msg(1, "WARNING: '$_' does not appear to be available ... " .
- "(ignored)\n");
- next;
- }
- next if $excluded{$_};
- if ($included{$_}) {
- msg(3, "$_ has already been included.\n");
- next;
- }
- # This is because udebs tend to have bad dependencies but work
- # nevertheless ... this may be removed once the udebs have a
- # better depencency system
- if ($packages{$_}{"IsUdeb"}) {
- add_to_cd($cd, $packages{$_}{"Size"}, [$_]);
- } else {
- add_package ($_, ! $norecommends, ! $nosuggests);
- }
-}
-close LIST;
-
-# All requested packages have been included
-# But we'll continue to add if $complete was requested
-if ($complete) {
- msg(0, "-- Now we'll add all the packages not yet included ...\n");
- # Try to sort them by section even if packages from
- # other sections will get in through dependencies
- # With some luck, most of them will already be here
- foreach my $p (sort { ($packages{$a}{"Section"} cmp $packages{$b}{"Section"})
- || ($a cmp $b) }
- grep { not ($included{$_} or $excluded{$_}) } keys %packages) {
- add_package ($p, 0, 0);
- }
-}
-msg(0, "CD $cd will only be filled with $cd_size bytes ...\n");
-
-# Now select the non-free packages for an extra CD
-if ($extranonfree and (! $nonfree))
-{
- my ($p, @toinclude);
-
- # Finally accept non-free packages ...
- foreach $p (grep { $excluded{$_} eq "nonfree" } (keys %excluded))
- {
- $excluded{$p} = 0;
- push @toinclude, $p;
- }
-
- # Start a new CD
- $cd++;
- $cd_size = 0;
- $limit = $ENV{"SIZELIMIT$cd"} || $deflimit;
- msg(0, "Limit for non-free CD $cd is $limit.\n");
-
- # Include non-free packages
- foreach $p (@toinclude)
- {
- add_package($p, 1, 1);
- }
-
- # If a contrib package was listed in the list of packages to
- # include and if COMPLETE=0 there's a chance that the package
- # will not get included in any CD ... so I'm checking the complete
- # list again
- open (LIST, "< $list") || die "Can't open $list : $!\n";
- while (defined($_=<LIST>)) {
- chomp;
- next if m/^\s*$/;
- next if $_ eq 'FORCE-CD-BREAK';
- next if $included{$_};
- next if $excluded{$_};
- if (not exists $packages{$_}) {
- msg(1, "WARNING: '$_' does not appear to be available ... " .
- "(ignored)\n");
- next;
- }
- add_package ($_, 1, 1);
- }
- close LIST;
-
- # Try to include other packages that could not be included
- # before (because they depends on excluded non-free packages)
- if ($complete)
- {
- foreach $p (sort { ($packages{$a}{"Section"}
- cmp $packages{$b}{"Section"}) || ($a cmp $b) }
- grep { not ($included{$_} or $excluded{$_}) }
- keys %packages)
- {
- add_package ($p, 0, 0);
- }
- }
-
- msg(0, "CD $cd will only be filled with $cd_size bytes ...\n");
-}
-
-# Remove old files
-foreach (glob("$dir/*.packages")) {
- unlink $_;
-}
-
-# Now write the lists down
-my $numcds=0;
-foreach (sort { $a <=> $b } keys %cds) {
- if ($maxcds && $numcds+1 > 1) {
- msg(0, "Stopping at CD $numcds\n");
- last;
- }
- $numcds++;
-
- my $count = 0;
- open(CDLIST, "> $dir/$_.packages")
- || die "Can't write in $dir/$_.packages: $!\n";
- foreach (@{$cds{$_}}) {
- print CDLIST "$_\n";
- $count++;
- }
- close CDLIST;
- msg(0, "CD $_ will have $count packages.\n");
-}
-if ($numcds == 0) {
- open(CDLIST, "> $dir/1.packages")
- || die "Can't write in $dir/1.packages: $!\n";
- close CDLIST;
-}
-
-close LOG;
-
-## END OF MAIN
-## BEGINNING OF SUBS
-
-sub read_depends {
- my $i = shift; # Ref
- my $lines = shift; # Ref
- my $pkg = shift; # string
- my $types = "(?:Pre)?Depends|Suggests|Recommends|Replaces|Conflicts";
- my (@dep, @rec, @sug);
- my ($type, $or, $elt);
-
- while ($lines->[$$i] =~ m/^\s([\s\|])($types):/) {
- $type = $2; $or = $1;
- # Get rid of replaces and conflicts ...
- if (($type eq "Replaces") or ($type eq "Conflicts")) {
- $$i++;
- while ($lines->[$$i] =~ m/^\s{4}/) {
- $$i++;
- }
- next;
- }
- # Check the kind of depends : or, virtual, normal
- if ($or eq '|') {
- $elt = read_ordepends ($i, $lines);
- } elsif ($lines->[$$i] =~ m/^\s\s$type: <([^>]+)>/) {
- $elt = read_virtualdepends ($i, $lines);
- } elsif ($lines->[$$i] =~ m/^\s\s$type: (\S+)/) {
- $elt = $1; $$i++;
- # Special case for packages providing not
- # truely virtual packages
- if ($lines->[$$i] =~ m/^\s{4}/) {
- $elt = [ $elt ];
- while ($lines->[$$i] =~ m/\s{4}(\S+)/) {
- push @{$elt}, $1;
- $$i++;
- }
- }
- } else {
- msg(0, "ERROR: Unknown depends line : $lines->[$$i]\n");
- foreach ($$i - 3 .. $$i + 3) {
- msg(0, " ", $lines->[$_]);
- }
- }
- $type =~ s/^Pre//; # PreDepends are like Depends for me
- next if dep_satisfied($elt);
- push @{$packages{$pkg}{$type}}, $elt;
- }
-}
-
-sub dep_satisfied {
- my $p = shift;
- if (ref $p) {
- foreach (@{$p}) {
- return 1 if $included{$_};
- }
- } else {
- return $included{$p};
- }
- return 0;
-}
-
-sub read_ordepends {
- my $i = shift;
- my $lines = shift;
- my @or = ();
- my ($val,$dep, $last) = ('','',0);
-
- while ($lines->[$$i]
- =~ m/^\s([\s\|])((?:Pre)?Depends|Suggests|Recommends): (\S+)/) {
- $val = $3;
- $last = 1 if $1 ne '|'; #Stop when no more '|'
- if ($val =~ m/^<.*>$/) {
- $dep = read_virtualdepends ($i, $lines);
- if (ref $dep) {
- push @or, @{$dep};
- } else {
- push @or, $dep;
- }
- } else {
- push @or, $val; $$i++;
- # Hack for packages providing not a truely
- # virtual package
- while ($lines->[$$i] =~ m/^\s{4}(\S+)/) {
- push @or, $1;
- $$i++;
- }
- }
- last if $last;
- }
- return \@or;
-}
-
-sub read_virtualdepends {
- my $i = shift;
- my $lines = shift;
- my $virtual;
- my @or = ();
-
- #Check for the lines with <>
- if ($lines->[$$i]
- =~ m/^\s[\s\|]((?:Pre)?Depends|Recommends|Suggests): <([^>]+)>/) {
- $virtual = $2;
- $$i++
- }
- # Now look at the alternatives on the following lines
- while ($lines->[$$i] =~ m/^\s{4}(\S+)/) {
- push @or, $1;
- $$i++;
- }
- if (@or) {
- return \@or;
- } else {
- return $virtual;
- }
-}
-
-sub new_cd {
- $cd++;
- $cd_size = 0;
- # New limit
- $limit = $ENV{"SIZELIMIT$cd"} || $deflimit;
- msg(2, "Limit for CD $cd is $limit.\n");
-
- # Unexclude packages
- unexclude ($cd);
-}
-
-sub add_package {
- my $p = shift;
- my $add_rec = shift; # Do we look for recommends
- my $add_sug = shift; # Do we look for suggests
-
- msg(2, "+ Trying to add $p...\n");
- if ($included{$p}) {
- msg(2, " Already included ...\n");
- return;
- }
-
- # Get all dependencies (not yet included) of each package
- my (@dep) = (get_missing ($p));
-
- # Stop here if apt failed
- if (not scalar(@dep)) {
- msg(2, "Can't add $p ... dependency problem.\n");
- return;
- }
-
- msg(3, " \@dep before checklist = @dep\n");
-
- # Check if all packages are allowed (fail if one cannot)
- if (not check_list (\@dep, 1)) {
- msg(2, "Can't add $p ... one of the package needed has " .
- "been refused.\n");
- return;
- }
-
- msg(3, " \@dep after checklist = @dep\n");
-
- if ($add_rec) {
- #TODO: Look for recommends (not yet included !!)
- add_recommends (\@dep);
- # Check again but doesn't fail if one of the package cannot be
- # installed, just ignore it (it will be removed from @dep)
- if (not check_list (\@dep, 0)) {
- msg(0, "UNEXPECTED: It shouldn't fail here !\n");
- return;
- }
- msg(3, " \@dep after checklist2 = @dep\n");
- }
-
- if ($add_sug) {
- #TODO: Look for suggests (not yet included !!)
- add_suggests (\@dep);
- # Check again but doesn't fail if one of the package cannot be
- # installed, just ignore it (it will be removed from @dep)
- if (not check_list (\@dep, 0)) {
- msg(0, "UNEXPECTED: It shouldn't fail here !\n");
- return;
- }
- msg(3, " \@dep after checklist3 = @dep\n");
- }
-
- # All packages are ok, now check for the size issue
- $size = get_size (\@dep);
-
- # Creation of a new CD when needed
- if ($overflowbincds and $cd_size + $size > $limit) {
- my $try_size = $cd_size + $size;
- msg(0, "CD $cd filled with $cd_size bytes ... ",
- "(limit was $limit, would have taken $try_size)\n");
- new_cd();
- }
-
- add_to_cd ($cd, $size, \@dep);
-}
-
-sub accepted {
- my $p = shift;
- return not $excluded{$p} if (exists $excluded{$p});
- # Return false for a non-existant package ...
- msg(1, "WARNING: $p cannot be accepted, it doesn't exist ...\n");
- return 0;
-}
-
-sub add_suggests {
- my $list = shift;
- my $p; # = shift;
- my @copy = @{$list}; # A copy is needed since I'll modify the array
-
- foreach $p (@copy) {
- add_missing($list, $packages{$p}{"Suggests"});
- }
-
-}
-
-sub add_recommends {
- my $list = shift;
- my $p; # = shift;
- my @copy = @{$list}; # A copy is needed since I'll modify the array
-
- foreach $p (@copy) {
- add_missing($list, $packages{$p}{"Recommends"});
- }
-
-}
-
-sub get_missing {
- my $p = shift;
- my @list = ($p);
-
- if (not add_missing (\@list, $packages{$p}{"Depends"})) {
- return ();
- }
-
- return (@list);
-}
-
-# Recursive function adding to the
-sub add_missing {
- my $list = shift;
- my $new = shift;
- my @backup = @{$list};
- my $ok = 1;
- return $ok if $nodepends;
-
- # Check all dependencies
- foreach (@{$new}) {
- next if dep_satisfied ($_);
- # If it's an OR
- if (ref) {
- my $or_ok = 0;
- # Loop over each package in the OR
- foreach my $pkg (@{$_}) {
- next if not accepted ($pkg);
- # If the package is already included
- # then don't worry
- if ($included{$pkg}) {
- $or_ok = 1;
- last;
- }
- # Check we don't already have the package
- if (is_in ($pkg, $list)) {
- $or_ok = 1;
- last;
- # Otherwise try to add it
- } else {
- #Instead of doing a bad choice I'm
- #including all packages that do
- #fit to the needs
- push (@{$list}, $pkg);
- if (add_missing ($list,
- $packages{$pkg}{"Depends"}))
- {
- $or_ok = 1;
- } else {
- pop @{$list};
- }
- }
- }
- $ok &&= $or_ok;
- # Else it's a simple dependency
- } else {
- if (not exists $packages{$_}) {
- msg(1, "$_ doesn't exist...\n");
- $ok = 0;
- last;
- }
- next if $included{$_}; # Already included, don't worry
- next if is_in ($_, $list);
- push @{$list}, $_;
- if (not add_missing ($list, $packages{$_}{"Depends"})) {
- pop @{$list};
- $ok = 0;
- }
- }
- }
- # If a problem has come up, then restore the original list
- if (not $ok) {
- @{$list} = @backup;
- }
- return $ok;
-}
-
-# Check if $value is in @{$array}
-sub is_in {
- my $value = shift;
- my $array = shift;
- foreach my $key (@{$array}) {
- return 1 if ($key eq $value);
- }
- return 0;
-}
-
-# The size of a group of packages
-sub get_size {
- my $arrayref = shift;
- my $size = 0;
- foreach (@{$arrayref}) {
- $size += $packages{$_}{"Size"};
- }
- return $size;
-}
-
-# Check a list of packages
-sub check_list {
- my $ref = shift;
- my $fail = shift;
- my $ok = 1;
- my @to_remove = ();
- foreach (@{$ref}) {
- if (not exists $excluded{$_}) {
- msg(1," $_ has been refused because it doesn't exist ...\n");
- $ok = 0;
- push @to_remove, $_;
- next;
- }
- if (not accepted($_)) {
- msg(1," $_ has been refused because of $excluded{$_} ...\n");
- $ok = 0;
- push @to_remove, $_;
- next;
- }
- if ($included{$_}) {
- msg(1,
- " $_ has already been included in CD $included{$_}.\n");
- push @to_remove, $_;
- next;
- }
- }
- foreach my $removed (@to_remove) {
- msg(2, " Removing $removed ...\n");
- @{$ref} = grep { $_ ne $removed } @{$ref};
- }
- return ($fail ? $ok : 1);
-}
-
-# Add packages to the current CD number $cd
-sub add_to_cd {
- my $cd = shift;
- my $size = shift;
- my $ref = shift;
-
- msg(2, " \$cd_size = $cd_size, \$size = $size\n");
-
- $cd_size += $size;
- $total_size += $size;
-
- foreach my $pkg (@{$ref}) {
- $included{$pkg} = $cd;
- }
- $cds{$cd} = [] if not ref $cds{$cd};
- msg(2, " Adding @{$ref} to CD $cd ...\n");
- push(@{$cds{$cd}}, @{$ref});
-}
-
-# Unexclude packages before given CD is started
-sub unexclude {
- my $cd = shift;
- my $unexclude = $ENV{"UNEXCLUDE$cd"} || "$list.unexclude$cd";
-
- if (-e $unexclude) {
- open (UNEXCL, "< $unexclude") || die "Can't open $unexclude : $!\n";
- while (defined($_=<UNEXCL>)) {
- chomp;
- if (not exists $packages{$_}) {
- msg(1, "Package '$_' is in unexcluded but " .
- "doesn't exist. Ignored.\n");
- next;
- }
- $excluded{$_} = 0;
- msg(1, "Unexcluding package '$_'\n");
- }
- close UNEXCL;
- }
-}
-
-sub yesno {
- my $in = shift;
- return $in ? "yes" : "no";
-}