diff --git a/yard/scripts/make_debian b/yard/scripts/make_debian index af55982..29f8f15 100755 --- a/yard/scripts/make_debian +++ b/yard/scripts/make_debian @@ -1,5 +1,25 @@ #!/usr/bin/perl +# make_debian from gBootRoot Copyright (C) 2000, 2001 +# Lead Developer and Project Coordinator +# Jonathan Rosenbaum +# +# http://gbootroot.sourceforge.net + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + # You will need to get swim at http://www.sourceforge.net/projects/avd my $home = "$ENV{HOME}/.gbootroot"; my $home_yard = "$home/yard"; @@ -9,6 +29,8 @@ my $nodename = `uname -n`; chomp $nodename; my $debian_yard = "Debian-$nodename.yard"; my $status = "/var/lib/dpkg/status"; my $info = "/var/lib/dpkg/info"; +my %alternatives; # for checking for alternatives +my @alternatives; # You need file-rc, and you may add other extra stuff. These packages were # chosen for woody, so you may need something different. If you add stuff, @@ -32,7 +54,7 @@ debconf-utils); # Options: to include or remove docs /usr/share/{doc,man,info} # and other stuff which creates fluff. -system "swim --search \"Priority: required\" > /dev/null 2>&1"; +system "swim --search \"Priority: required\" --no"; my $swim_packages = "swim -qS|"; my $swim_list = "swim -qSl|"; # Not using --df for empty directories. $, = " "; @@ -67,13 +89,20 @@ close(FILERC); print DEBIAN stuff(); my @file_rc; +alternatives(); foreach (@required_files) { if (-e && !-d) { if ($ARGV[0] eq "doc") { + if ($alternatives{$_}) { + push(@alternatives,$_); + } print DEBIAN "$_\n"; } else { if (! m,/usr/share/info|/usr/share/man|/usr/share/doc,) { + if ($alternatives{$_}) { + push(@alternatives,$_); + } print DEBIAN "$_\n"; } } @@ -85,9 +114,19 @@ foreach (@required_files) { } } + print DEBIAN "\n# Scripts associated with packages found in info/*\n"; print DEBIAN status_info(); +# alternatives +print DEBIAN "\n# Alternative stuff.\n"; +foreach (@alternatives) { + if ($alternatives{$_}) { + print DEBIAN "/etc/alternatives/", $alternatives{$_}, "\n"; + print DEBIAN "/var/lib/dpkg/alternatives/", $alternatives{$_}, "\n"; + } +} + close(DEBIAN); @@ -103,87 +142,9 @@ map { [ (split(/\s/,$_))[0], $_ ] } print MY_FILERC @sortedrc; close(MY_FILERC); -# This creates a status file for use by dpkg and swim. -# Although swim could be used to do this, it is more effecient just to -# parse the status file. But because this is a good exercise for -# using this script to create a status file found from packages on a system -# which doesn't actually have a status file .. here would be the order -# needed when using swim to query: -# -# Package, Status, Priority, Section, Installed-Size, Maintainer, Source, -# Version, Replaces, Provides, Depends, Pre-Depends, Recommends, Suggests, -# Conflicts, Conffiles, Description. -# -# Conffiles would have to be handled both before and after Root Filesystem -# creation so that their md5sums could be accounted for in status. -# -# And this finds all the scripts associated with a package in info/*. - -sub status_info { - -$/ = ""; -open(STATUS,"$status") or die "Can't find /var/lib/dpkg/status: $!\n"; -home_builder("$home_yard_replacements/var/lib/dpkg"); -system "touch $home_yard_replacements/var/lib/dpkg/available"; - #or die "Couldn't create Replacements/var/lib/dpkg/available: $!\n"; -open(NEW_STATUS,">$home_yard_replacements/var/lib/dpkg/status") - or die "Couldn't open $home_yard_replacements/var/lib/dpkg/status: $!\n"; -while () { # keep the order - $stat = $_; - my $stat2 = (split(/\n/,$stat))[0]; # might as well - foreach my $rp (@required_packages) { - $rp = (split(/_/,$rp))[0]; - # Deal with names with + - $rp =~ s/\+/\\+/g if $rp !~ /\\+/g; - if ($stat2 =~ /^Package: $rp$/) { - print NEW_STATUS $stat; - } - } -} -close(NEW_STATUS); -close(STATUS); -$/ = "\n"; - -my @info; -foreach my $rp (@required_packages) { - $rp = (split(/_/,$rp))[0]; - # Get rid of the escapes from the previous invocation. - $rp =~ s/\\//g if $rp =~ /\\+/g; - - # Figure out info/* .. this covers it for now. - if (-f "$info/$rp.preinst") { - push(@info,"$info/$rp.preinst\n"); - } - if (-f "$info/$rp.postinst") { - push(@info,"$info/$rp.postinst\n"); - } - if (-f "$info/$rp.prerm") { - push(@info,"$info/$rp.prerm\n"); - } - if (-f "$info/$rp.postrm") { - push(@info,"$info/$rp.postrm\n"); - } - if (-f "$info/$rp.list") { - push(@info,"$info/$rp.list\n"); - } - if (-f "$info/$rp.shlibs") { - push(@info,"$info/$rp.shlibs\n"); - } - if (-f "$info/$rp.conffiles") { - push(@info,"$info/$rp.conffiles\n"); - } - if (-f "$info/$rp.md5sums") { - push(@info,"$info/$rp.md5sums\n"); - } - if (-f "$info/$rp.config") { - push(@info,"$info/$rp.config\n"); - } -} - -return @info; - -} # end sub status_info - +################################################################# +################################################################# +# Edit below $stuff = << "STUFF" to make changes to the template. sub stuff { $stuff = << "STUFF"; @@ -199,10 +160,6 @@ $stuff = << "STUFF"; # user: user passwd: user # Uses devfs. -# Alternatives aren't working so you will have to use the real name like -# nvi for vi and w.procps for w. Not all libs are associated with packages -# but that isn't a big deal. - # IMPORTANT NOTE: Things slow down noticeably when the buffer gets too big in # the verbosity box so consider closing it with the slider for faster # generation. Look at /tmp/verbose instead. @@ -327,6 +284,106 @@ STUFF return $stuff; } # end sub stuff +################################################################# +################################################################# + +# This creates a status file for use by dpkg and swim. +# Although swim could be used to do this, it is more effecient just to +# parse the status file. But because this is a good exercise for +# using this script to create a status file found from packages on a system +# which doesn't actually have a status file .. here would be the order +# needed when using swim to query: +# +# Package, Status, Priority, Section, Installed-Size, Maintainer, Source, +# Version, Replaces, Provides, Depends, Pre-Depends, Recommends, Suggests, +# Conflicts, Conffiles, Description. +# +# Conffiles would have to be handled both before and after Root Filesystem +# creation so that their md5sums could be accounted for in status. +# +# And this finds all the scripts associated with a package in info/*. + +sub status_info { + +$/ = ""; +open(STATUS,"$status") or die "Can't find /var/lib/dpkg/status: $!\n"; +home_builder("$home_yard_replacements/var/lib/dpkg"); +system "touch $home_yard_replacements/var/lib/dpkg/available"; + #or die "Couldn't create Replacements/var/lib/dpkg/available: $!\n"; +open(NEW_STATUS,">$home_yard_replacements/var/lib/dpkg/status") + or die "Couldn't open $home_yard_replacements/var/lib/dpkg/status: $!\n"; +while () { # keep the order + $stat = $_; + my $stat2 = (split(/\n/,$stat))[0]; # might as well + foreach my $rp (@required_packages) { + $rp = (split(/_/,$rp))[0]; + # Deal with names with + + $rp =~ s/\+/\\+/g if $rp !~ /\\+/g; + if ($stat2 =~ /^Package: $rp$/) { + print NEW_STATUS $stat; + } + } +} +close(NEW_STATUS); +close(STATUS); +$/ = "\n"; + +my @info; +foreach my $rp (@required_packages) { + $rp = (split(/_/,$rp))[0]; + # Get rid of the escapes from the previous invocation. + $rp =~ s/\\//g if $rp =~ /\\+/g; + + # Figure out info/* .. this covers it for now. + if (-f "$info/$rp.preinst") { + push(@info,"$info/$rp.preinst\n"); + } + if (-f "$info/$rp.postinst") { + push(@info,"$info/$rp.postinst\n"); + } + if (-f "$info/$rp.prerm") { + push(@info,"$info/$rp.prerm\n"); + } + if (-f "$info/$rp.postrm") { + push(@info,"$info/$rp.postrm\n"); + } + if (-f "$info/$rp.list") { + push(@info,"$info/$rp.list\n"); + } + if (-f "$info/$rp.shlibs") { + push(@info,"$info/$rp.shlibs\n"); + } + if (-f "$info/$rp.conffiles") { + push(@info,"$info/$rp.conffiles\n"); + } + if (-f "$info/$rp.md5sums") { + push(@info,"$info/$rp.md5sums\n"); + } + if (-f "$info/$rp.config") { + push(@info,"$info/$rp.config\n"); + } +} + +return @info; + +} # end sub status_info + +sub alternatives { + + my $ls = "ls -l /etc/alternatives|"; + my @ls; + open(LS,$ls) or die "No ls?: $!\n"; + while () { + if (/->/) { + my($left,$right) = split(" -> "); + chomp $right; + $left =~ s/^.*\d+\s//g; + $alternatives{$right} = $left; + } + } + +} # end sub alternatives + sub home_builder {