mirror of
https://github.com/fspc/gbootroot.git
synced 2025-02-22 00:23:28 -05:00
Inetd.conf is now automatically commented out where executables don't exist and
put in Replacements.
This commit is contained in:
parent
5ff942d4fe
commit
52b2630fb9
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
# make_debian Copyright (C) 2001 from gBootRoot
|
# make_debian Copyright (C) 2001 from gBootRoot
|
||||||
# Lead Developer and Project Coordinator
|
# Lead Developer and Project Coordinator
|
||||||
@ -20,6 +20,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
use strict;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
|
|
||||||
# You will need to get swim at http://www.sourceforge.net/projects/avd
|
# You will need to get swim at http://www.sourceforge.net/projects/avd
|
||||||
@ -31,8 +32,8 @@ my $nodename = `uname -n`; chomp $nodename;
|
|||||||
my $debian_yard = "Debian-$nodename.yard";
|
my $debian_yard = "Debian-$nodename.yard";
|
||||||
my $status = "/var/lib/dpkg/status";
|
my $status = "/var/lib/dpkg/status";
|
||||||
my $info = "/var/lib/dpkg/info";
|
my $info = "/var/lib/dpkg/info";
|
||||||
my %alternatives; # for checking for alternatives
|
my (%alternatives, @alternatives); # for checking for alternatives
|
||||||
my @alternatives;
|
my %inetd; # checks for inetd binaries.
|
||||||
|
|
||||||
# You need file-rc, and you may add other extra stuff. These packages were
|
# 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,
|
# chosen for woody, so you may need something different. If you add stuff,
|
||||||
@ -81,76 +82,16 @@ close(SWIM);
|
|||||||
|
|
||||||
push(@required_files,@extra_files);
|
push(@required_files,@extra_files);
|
||||||
|
|
||||||
## Template Creation
|
|
||||||
open(DEBIAN,">$template_dir/$debian_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;
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m,/etc/init\.d,) {
|
|
||||||
foreach my $filerc (@filerc) {
|
|
||||||
push(@file_rc,$filerc) if $filerc =~ /$_/;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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";
|
|
||||||
print DEBIAN dirname($_), "/", $alternatives{$_}, "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
#################################################################
|
#################################################################
|
||||||
|
#
|
||||||
|
# EDIT
|
||||||
|
# BELOW
|
||||||
|
#
|
||||||
# Edit below $stuff = << "STUFF" to make changes to the template.
|
# Edit below $stuff = << "STUFF" to make changes to the template.
|
||||||
sub stuff {
|
sub stuff {
|
||||||
|
|
||||||
$stuff = << "STUFF";
|
my $stuff = << "STUFF";
|
||||||
# Generated by make_debian.
|
# Generated by make_debian.
|
||||||
|
|
||||||
# This template creates a complete Debian system which is more streamlined
|
# This template creates a complete Debian system which is more streamlined
|
||||||
@ -292,8 +233,84 @@ return $stuff;
|
|||||||
#################################################################
|
#################################################################
|
||||||
#################################################################
|
#################################################################
|
||||||
|
|
||||||
|
####################
|
||||||
|
## Template Creation
|
||||||
|
|
||||||
|
open(DEBIAN,">$template_dir/$debian_yard")
|
||||||
|
or die "Couldn't open $!\n";
|
||||||
|
open(FILERC,"/etc/runlevel.conf") or die "No runlevel.conf: $!\n";
|
||||||
|
my @filerc = <FILERC>;
|
||||||
|
close(FILERC);
|
||||||
|
|
||||||
|
print DEBIAN stuff();
|
||||||
|
|
||||||
|
my @file_rc;
|
||||||
|
alternatives();
|
||||||
|
inetd_in();
|
||||||
|
foreach (@required_files) {
|
||||||
|
if (-e && !-d) {
|
||||||
|
if ($ARGV[0] && $ARGV[0] eq "doc") {
|
||||||
|
if ($alternatives{$_}) {
|
||||||
|
push(@alternatives,$_);
|
||||||
|
}
|
||||||
|
if ($inetd{$_}) {
|
||||||
|
$inetd{$_} = 1;
|
||||||
|
}
|
||||||
|
print DEBIAN "$_\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (! m,/usr/share/info|/usr/share/man|/usr/share/doc,) {
|
||||||
|
if ($alternatives{$_}) {
|
||||||
|
push(@alternatives,$_);
|
||||||
|
}
|
||||||
|
if ($inetd{$_}) {
|
||||||
|
$inetd{$_} = 1;
|
||||||
|
}
|
||||||
|
print DEBIAN "$_\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m,/etc/init\.d,) {
|
||||||
|
foreach my $filerc (@filerc) {
|
||||||
|
push(@file_rc,$filerc) if $filerc =~ /$_/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inetd_out();
|
||||||
|
|
||||||
|
print DEBIAN "\n# Scripts associated with packages found in info/*\n";
|
||||||
|
print DEBIAN status_info_divert();
|
||||||
|
|
||||||
|
# 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";
|
||||||
|
print DEBIAN dirname($_), "/", $alternatives{$_}, "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(DEBIAN);
|
||||||
|
|
||||||
|
# END TEMPLATE CREATION
|
||||||
|
#######################
|
||||||
|
|
||||||
|
# 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);
|
||||||
|
|
||||||
|
|
||||||
# This creates a status file for use by dpkg and swim.
|
# 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
|
# Although swim could be used to do this, it is more efficient just to
|
||||||
# parse the status file. But because this is a good exercise for
|
# 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
|
# 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
|
# which doesn't actually have a status file .. here would be the order
|
||||||
@ -309,7 +326,7 @@ return $stuff;
|
|||||||
# And this finds all the scripts associated with a package in info/*,
|
# And this finds all the scripts associated with a package in info/*,
|
||||||
# creates an empty available file, and creates the diversions file.
|
# creates an empty available file, and creates the diversions file.
|
||||||
|
|
||||||
sub status_info {
|
sub status_info_divert {
|
||||||
|
|
||||||
$/ = "";
|
$/ = "";
|
||||||
open(STATUS,"$status") or die "Can't find /var/lib/dpkg/status: $!\n";
|
open(STATUS,"$status") or die "Can't find /var/lib/dpkg/status: $!\n";
|
||||||
@ -319,7 +336,7 @@ system "touch $home_yard_replacements/var/lib/dpkg/available";
|
|||||||
open(NEW_STATUS,">$home_yard_replacements/var/lib/dpkg/status")
|
open(NEW_STATUS,">$home_yard_replacements/var/lib/dpkg/status")
|
||||||
or die "Couldn't open $home_yard_replacements/var/lib/dpkg/status: $!\n";
|
or die "Couldn't open $home_yard_replacements/var/lib/dpkg/status: $!\n";
|
||||||
while (<STATUS>) { # keep the order
|
while (<STATUS>) { # keep the order
|
||||||
$stat = $_;
|
my $stat = $_;
|
||||||
my $stat2 = (split(/\n/,$stat))[0]; # might as well
|
my $stat2 = (split(/\n/,$stat))[0]; # might as well
|
||||||
foreach my $rp (@required_packages) {
|
foreach my $rp (@required_packages) {
|
||||||
$rp = (split(/_/,$rp))[0];
|
$rp = (split(/_/,$rp))[0];
|
||||||
@ -334,7 +351,7 @@ close(NEW_STATUS);
|
|||||||
close(STATUS);
|
close(STATUS);
|
||||||
$/ = "\n";
|
$/ = "\n";
|
||||||
|
|
||||||
my %dpkg_divert = [];
|
my %dpkg_divert;
|
||||||
my $dpkg_divert = "dpkg-divert --list|";
|
my $dpkg_divert = "dpkg-divert --list|";
|
||||||
open(DIVERT,"$dpkg_divert")
|
open(DIVERT,"$dpkg_divert")
|
||||||
or die "Couldn't find the dpkg-divert command: $!\n";
|
or die "Couldn't find the dpkg-divert command: $!\n";
|
||||||
@ -350,7 +367,7 @@ while (<DIVERT>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
close(DIVERT);
|
close(DIVERT) or die "Couldn't close: $!\n";
|
||||||
|
|
||||||
open(DIVERT,">$home_yard_replacements/var/lib/dpkg/diversions")
|
open(DIVERT,">$home_yard_replacements/var/lib/dpkg/diversions")
|
||||||
or die "Couldn't open Replacements/var/lib/dpkg/diversions: $!\n";
|
or die "Couldn't open Replacements/var/lib/dpkg/diversions: $!\n";
|
||||||
@ -407,7 +424,7 @@ close(DIVERT);
|
|||||||
|
|
||||||
return @info;
|
return @info;
|
||||||
|
|
||||||
} # end sub status_info
|
} # end sub status_info_divert
|
||||||
|
|
||||||
sub alternatives {
|
sub alternatives {
|
||||||
|
|
||||||
@ -422,9 +439,52 @@ sub alternatives {
|
|||||||
$alternatives{$right} = $left;
|
$alternatives{$right} = $left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
close(LS);
|
||||||
|
|
||||||
} # end sub alternatives
|
} # end sub alternatives
|
||||||
|
|
||||||
|
sub inetd_in {
|
||||||
|
|
||||||
|
my $inetd = "/etc/inetd.conf";
|
||||||
|
open(INETD,"$inetd") or return "Couldn't open /etc/inetd.conf: $!\n";
|
||||||
|
# Basically will ignore anything with less than 7 columns, and
|
||||||
|
# will comment lines where the executables don't exist.
|
||||||
|
while (<INETD>) {
|
||||||
|
if ( (split(/\s+/))[6] && !/^#.*/ ) {
|
||||||
|
my $seventh_column = (split(/\s+/))[6];
|
||||||
|
chomp $seventh_column;
|
||||||
|
$inetd{ basename($seventh_column) } = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(INETD);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub inetd_out {
|
||||||
|
|
||||||
|
my $inetd = "/etc/inetd.conf";
|
||||||
|
open(REP_INETD,">$home_yard_replacements/etc/inetd.conf")
|
||||||
|
or return "Couldn't open Replacements/etc/inetd.conf: $!\n";
|
||||||
|
open(INETD,"$inetd") or return "Couldn't open /etc/inetd.conf: $!\n";
|
||||||
|
while (<INETD>) {
|
||||||
|
if ( (split(/\s+/))[6] && !/^#.*/ ) {
|
||||||
|
my $seventh_column = (split(/\s+/))[6];
|
||||||
|
chomp $seventh_column;
|
||||||
|
if ( $inetd{ basename($seventh_column) } == 1 ) {
|
||||||
|
print REP_INETD $_;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print REP_INETD "# $_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print REP_INETD $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(REP_INETD);
|
||||||
|
close(INETD);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
sub home_builder {
|
sub home_builder {
|
||||||
|
|
||||||
@ -446,3 +506,11 @@ sub home_builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} # end home_builder
|
} # end home_builder
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user