mirror of
				https://github.com/fspc/gbootroot.git
				synced 2025-11-04 08:15:36 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			151 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			151 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/perl
 | 
						|
 | 
						|
# You will need to get swim at http://www.sourceforge.net/projects/avd
 | 
						|
my $home = "$ENV{HOME}/.gbootroot";
 | 
						|
my $home_yard = "$home/yard";
 | 
						|
my $template_dir = "$home_yard/templates/";
 | 
						|
my $home_yard_replacements = "$home_yard/Replacements";
 | 
						|
 | 
						|
# And tests will be ran here for file-rc and swim
 | 
						|
# Options: to include or remove docs /usr/share/{doc,man,info}
 | 
						|
 | 
						|
system "swim --search \"Priority: required\" > /dev/null 2>&1";
 | 
						|
my $swim_packages = "swim -qS|";
 | 
						|
my $swim_list = "swim -qSl|";
 | 
						|
my $file_rc = "swim -ql file-rc|";
 | 
						|
 | 
						|
open(SWIM,$swim_packages) or die "Couldn't open $?\n";
 | 
						|
my @required_packages = <SWIM>; chomp @required_packages;
 | 
						|
close(SWIM);
 | 
						|
 | 
						|
open(SWIM,$swim_list) or die "Couldn't open $?\n";
 | 
						|
my @required_files = <SWIM>; chomp @required_files;
 | 
						|
close(SWIM);
 | 
						|
 | 
						|
open(SWIM,$file_rc) or die "Couldn't open $?\n";
 | 
						|
my @extra_files = <SWIM>; chomp @extra_files;
 | 
						|
close(SWIM);
 | 
						|
 | 
						|
push(@required_files,@extra_files);
 | 
						|
 | 
						|
open(DEBIAN,">$template_dir/Debian-test.yard") 
 | 
						|
	or die "Couldn't open $?\n";
 | 
						|
open(FILERC,"/etc/runlevel.conf") or die "No runlevel.conf: $?\n";
 | 
						|
@filerc = <FILERC>;
 | 
						|
close(FILERC);
 | 
						|
 | 
						|
print DEBIAN stuff();
 | 
						|
 | 
						|
my @file_rc;
 | 
						|
foreach (@required_files) {
 | 
						|
    if (-e && !-d) {
 | 
						|
	if ($ARGV[0] eq "doc") {
 | 
						|
	    print DEBIAN "$_\n";
 | 
						|
	}
 | 
						|
	else {
 | 
						|
	    if (! m,/usr/share/info|/usr/share/man|/usr/share/doc,) {
 | 
						|
		print DEBIAN "$_\n";
 | 
						|
	    }
 | 
						|
	}
 | 
						|
	if (m,/etc/init\.d,) {
 | 
						|
	    foreach my $filerc (@filerc) {
 | 
						|
		     push(@file_rc,$filerc) if $filerc =~ /$_/;		
 | 
						|
	    }
 | 
						|
	}		   
 | 
						|
    }
 | 
						|
}
 | 
						|
close(DEBIAN);
 | 
						|
 | 
						|
 | 
						|
# This creates a tweaked runlevel.conf which is easier then trying to figure
 | 
						|
# out which symlinks to use in /etc/rc?d.
 | 
						|
 | 
						|
open(MY_FILERC,">$home_yard_replacements/etc/runlevel.conf") 
 | 
						|
    or die "Couldn't open $home_yard_replacements/etc/runlevel.conf: $?\n"; 
 | 
						|
my @sortedrc = map { $_->[1] }
 | 
						|
sort { $a->[0] <=> $b->[0] }
 | 
						|
map { [ (split(/\s/,$_))[0], $_ ] }
 | 
						|
@file_rc;
 | 
						|
print MY_FILERC @sortedrc;
 | 
						|
close(MY_FILERC);
 | 
						|
 | 
						|
sub stuff {
 | 
						|
 | 
						|
$stuff = << "STUFF";
 | 
						|
# This template creates a complete Debian system which is more streamlined 
 | 
						|
# than the base.tgz used for normal installations.  Once everything is made, 
 | 
						|
# you can use user-mode-linux to tweak the system, as well as apt. 
 | 
						|
# Make-debian generates all the information you need, you will need swim and 
 | 
						|
# file-rc installed, and you will have to be running a Debian system to make 
 | 
						|
# this template.  Make-debian ditches info, man, and doc files by default,
 | 
						|
# use the "doc" option to make documentation.  
 | 
						|
#
 | 
						|
# 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.
 | 
						|
 | 
						|
# The STUFF NEEDED in order for init to work.
 | 
						|
/etc/runlevel.conf <=  Replacements/etc/runlevel.conf
 | 
						|
/etc/init.d/rc
 | 
						|
/etc/init.d/rcS
 | 
						|
/etc/inittab <= Replacements/etc/inittab.debian
 | 
						|
/etc/default/rcS
 | 
						|
 | 
						|
# Stuff to save to return init to old state prior to file-rc
 | 
						|
/etc/init.d/rc.links
 | 
						|
/etc/init.d/rcS.links 
 | 
						|
/usr/sbin/update-rc.d.links
 | 
						|
 | 
						|
# Important stuff
 | 
						|
/etc/fstab	<= ./Replacements/etc/fstab.new
 | 
						|
/etc/passwd*
 | 
						|
/etc/group*
 | 
						|
 | 
						|
# The information needed so that dpkg can work.
 | 
						|
/var/lib/dpkg/diversions <= Replacements/var/lib/dpkg/diversions
 | 
						|
/var/lib/dpkg/cmethopt
 | 
						|
/var/lib/dpkg/lock
 | 
						|
/var/lib/dpkg/status <=  Replacements/var/lib/dpkg/status
 | 
						|
/var/lib/dpkg/methods/disk
 | 
						|
/var/lib/dpkg/methods/floppy
 | 
						|
/var/lib/dpkg/methods/mnt
 | 
						|
/var/lib/dpkg/info
 | 
						|
/var/lib/dpkg/updates
 | 
						|
/var/lib/dpkg/alternatives
 | 
						|
 | 
						|
# Devices
 | 
						|
/dev/MAKEDEV # a link
 | 
						|
/dev/mem	
 | 
						|
/dev/kmem
 | 
						|
/dev/null       
 | 
						|
/dev/zero
 | 
						|
/dev/ram*
 | 
						|
/dev/console
 | 
						|
/dev/tty[0-9]
 | 
						|
/dev/hd[abcd]*              
 | 
						|
/dev/ttyS[0-9]		    
 | 
						|
/dev/fd0*                   
 | 
						|
/dev/sd*                    
 | 
						|
/dev/cdrom 
 | 
						|
/dev/modem       
 | 
						|
/dev/pts*
 | 
						|
/dev/ptmx
 | 
						|
/dev/initctl
 | 
						|
/dev/urandom
 | 
						|
/dev/ubd0 <= Replacements/dev/ubd0
 | 
						|
 | 
						|
#  Empty directories
 | 
						|
/mnt        
 | 
						|
/proc               
 | 
						|
/tmp                
 | 
						|
/var/tmp
 | 
						|
/var/run
 | 
						|
/var/lock
 | 
						|
/var/log
 | 
						|
 | 
						|
## ALL the REQUIRED files generated by make-debian
 | 
						|
STUFF
 | 
						|
 | 
						|
return $stuff;
 | 
						|
} # end sub stuff
 | 
						|
 |