File: create_replacements.in

package info (click to toggle)
yard 1.17.patch1-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 600 kB
  • ctags: 74
  • sloc: perl: 1,729; sh: 250; makefile: 176; asm: 32
file content (144 lines) | stat: -rw-r--r-- 4,185 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#! @PERL@
# -*- Mode: Perl -*-
# @configure_input@
##############################################################################
##
##  $Id: create_replacements.in,v 1.1.1.1 1998/02/21 11:40:04 fawcett Exp $
##
##  CREATE_REPLACEMENTS
##  Copyright (C) 1996  Tom Fawcett (fawcett@nynexst.com)
##
##  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., 675 Mass Ave, Cambridge, MA 02139, USA.
##------------------------------------------------------------
##
##
##############################################################################
use strict qw(subs refs);
use File::Basename;
use File::Path;
use FileHandle;
use Cwd;
use English;
use lib "@lib_dest@";
use yardconfig;

BEGIN { require "yard_utils.pl" } # Defines info() and error() for compiler

require "Config.pl";		# Just for $oldroot, actually

##############################################################################

create_fstab();
create_rc();
create_lilo_conf();
exit;

##############################################################################

sub create_fstab {
    my($NEWFSTAB) = "./Replacements/etc/fstab";
    open(NEWFSTAB, ">$NEWFSTAB") or die "$NEWFSTAB: $!";
    
    print NEWFSTAB <<BLARD;
# DEVICE	MOUNTPOINT	TYPE	OPTIONS	DUMP	FSCKORDER
#----------------------------------------------------------------
/dev/ram0       /               ext2    defaults
/proc           /proc           proc    defaults
# Entries adapted from existing fstab:
BLARD
	
    my($line);
    open(FSTAB, "/etc/fstab") or die "/etc/fstab: $!\n";
    
    while ($line = <FSTAB>) {
	chop $line;
	next if $line =~ /^\#/ or $line =~ /^\s*$/;
	
	my($device, $mpt, $type, $options, @rest)
	    = split(' ', $line);
	
	if ($device =~ m!^/(proc|dev/ram)! or $type eq "proc") {
	    ## Don't allow /proc or /dev/ram? definitions
	    next;
	    
	} elsif ($type eq 'swap') {
	    ##  Pass swap through unchanged
	    
	} else {
	    ##  By default:
	    ##  - Add a 'noauto' option if it doesn't already have one
	    ##  - Put mountpoint under oldroot
	    $options .= ',noauto' unless $options =~ /\bnoauto\b/;
	    
	    if ($mpt eq '/') {
		$mpt = $CFG::oldroot; # limitation of mount cmd
	    } else {
		$mpt =  $CFG::oldroot . $mpt;
	    }
	}
	
	print NEWFSTAB join("\t", ($device, $mpt, $type, $options,
				   @rest)), "\n";
    }
    
    close(FSTAB);
    close(NEWFSTAB);
    
    print "Created $NEWFSTAB\n";
    
}

##############################################################################

sub create_rc {
    
}

sub create_lilo_conf {
    my($append_line);
    my($lilo_conf) = "/etc/lilo.conf";

    if (-e $lilo_conf) {
	open(LC, "<$lilo_conf") or die "$lilo_conf: $!";
	print "Found your Lilo configuration file $lilo_conf\n";
	while (<LC>) {
	    if (/^\s*append\s*=/) {
		$append_line = $_;
		print "Grabbing lilo APPEND line: $append_line";
	    }
	}
	close(LC);
    } else {
	print "You have no file $lilo_conf.\n";
    }
    
    my($LILO_CONF) = "./Replacements/etc/lilo.conf";
    open(LILO_CONF, ">$LILO_CONF") or die "$LILO_CONF: $!";
    
    print LILO_CONF "boot	  =\$floppy\n";
    print LILO_CONF "install   =/boot/boot.b\n";
    print LILO_CONF "map	  =/boot/map\n";
    print LILO_CONF "read-write\n";
    print LILO_CONF "backup    =/dev/null\n";
    print LILO_CONF $append_line if defined($append_line);
    print LILO_CONF "compact\n";
    print LILO_CONF "image	  =\$kernel_basename\n";
    print LILO_CONF "label	  =Yardboot\n";
    print LILO_CONF "root	  =\$floppy\n";
    
    close(LILO_CONF) or die "closing $LILO_CONF: $!";

    print "Created $LILO_CONF\n";
}