1 | #!/bin/sh |
---|
2 | # $Id: makeroot.sh,v 1.24 2004-05-16 21:19:01 ghudson Exp $ |
---|
3 | |
---|
4 | if [ $# -lt 1 ]; then |
---|
5 | echo "Usage: $0 rootdir [fullversion]" >&2 |
---|
6 | exit 1 |
---|
7 | fi |
---|
8 | |
---|
9 | root=$1 |
---|
10 | ver=$2 |
---|
11 | |
---|
12 | case `machtype` in |
---|
13 | linux) |
---|
14 | sysprefix=/afs/.dev.mit.edu/system/rhlinux |
---|
15 | syscontrol=control/control-${ver:-current} |
---|
16 | pwconv=/usr/sbin/pwconv |
---|
17 | |
---|
18 | mkdir -p "$root/dev" |
---|
19 | /dev/MAKEDEV -d "$root/dev" std |
---|
20 | |
---|
21 | cd "$sysprefix" |
---|
22 | list=`awk '{ x = $2; } END { print x; }' "$syscontrol"` |
---|
23 | rpms=`awk '/\/athena-/ { next; } { print $1; }' $list` |
---|
24 | |
---|
25 | mkdir -p "$root/var/lib/rpm" "$root/etc" |
---|
26 | touch "$root/etc/fstab" |
---|
27 | rpm --root "$root" --initdb |
---|
28 | rpm --root "$root" -ivh $rpms |
---|
29 | |
---|
30 | # Make links into destination area. |
---|
31 | ln -s ../build/athtools/usr/athena "$root/usr/athena" |
---|
32 | ln -s ../build/athtools/usr/afsws "$root/usr/afsws" |
---|
33 | |
---|
34 | # So packages can figure out where sendmail is. (sendmail normally |
---|
35 | # comes from athena-sendmail, which we don't install; this is simpler |
---|
36 | # than installing either the athena-sendmail or a native sendmail RPM.) |
---|
37 | touch "$root/usr/sbin/sendmail" |
---|
38 | chmod a+x "$root/usr/sbin/sendmail" |
---|
39 | ;; |
---|
40 | |
---|
41 | sun4) |
---|
42 | pwconv=/usr/sbin/pwconv |
---|
43 | |
---|
44 | # Create an admin file for pkgadd, which will skip most checks, but |
---|
45 | # will check package dependencies. |
---|
46 | admin=/tmp/admin$$ |
---|
47 | rm -rf "$admin" |
---|
48 | cat > "$admin" << 'EOF' |
---|
49 | mail= |
---|
50 | instance=unique |
---|
51 | partial=nocheck |
---|
52 | runlevel=nocheck |
---|
53 | idepend=quit |
---|
54 | rdepend=quit |
---|
55 | space=nocheck |
---|
56 | setuid=nocheck |
---|
57 | conflict=nocheck |
---|
58 | action=nocheck |
---|
59 | basedir=default |
---|
60 | EOF |
---|
61 | |
---|
62 | # Install packages. |
---|
63 | for i in `cat /install/cdrom/.order.install`; do |
---|
64 | echo "$i: \c" |
---|
65 | pkgadd -n -R "$root" -a "$admin" -d /install/cdrom "$i" |
---|
66 | done 2>/dev/null |
---|
67 | cp /install/cdrom/INST_RELEASE "$root/var/sadm/system/admin" |
---|
68 | rm -f "$admin" |
---|
69 | |
---|
70 | # Install patches. |
---|
71 | jot -b y 50 | patchadd -d -R "$root" -u -M /install/patches \ |
---|
72 | `cat /install/patches/current-patches` |
---|
73 | |
---|
74 | # /usr/lib/isaexec (a front end which selects between the sparcv7 and |
---|
75 | # sparcv9 versions of a binary) doesn't work in a chrooted environment |
---|
76 | # (getexecname() fails due to lack of procfs). The only binary |
---|
77 | # linked to isaexec relevant to the build system is "sort". Work |
---|
78 | # around the problem by copying the sparcv9 "sort" to /usr/bin, |
---|
79 | # since ensuring that procfs is always mounted in the chroot area is a |
---|
80 | # little messy. |
---|
81 | rm -f "$root/usr/bin/sort" |
---|
82 | cp "$root/usr/bin/sparcv9/sort" "$root/usr/bin/sort" |
---|
83 | |
---|
84 | # Make devices. |
---|
85 | cd "$root" |
---|
86 | drvconfig -r devices -p "$root/etc/path_to_inst" |
---|
87 | devlinks -t "$root/etc/devlink.tab" -r "$root" |
---|
88 | disks -r "$root" |
---|
89 | |
---|
90 | # third/gnome-utils wants to know where to look for log messages. |
---|
91 | touch "$root/var/adm/messages" |
---|
92 | |
---|
93 | # pkgadd needs to use mnttab. We can fake it out by copying /etc/mnttab. |
---|
94 | cp /etc/mnttab "$root/etc" |
---|
95 | |
---|
96 | # Make links into destination area. |
---|
97 | ln -s ../build/athtools/usr/athena "$root/usr/athena" |
---|
98 | ln -s ../build/athtools/usr/afsws "$root/usr/afsws" |
---|
99 | ln -s ../build/athtools/usr/gcc "$root/usr/gcc" |
---|
100 | |
---|
101 | # So packages can figure out where sendmail is. (sendmail normally |
---|
102 | # comes from MIT-sendmail, which we don't install; this is simpler |
---|
103 | # than installing either the MIT-sendmail or a native sendmail package.) |
---|
104 | touch "$root/usr/lib/sendmail" |
---|
105 | chmod a+x "$root/usr/lib/sendmail" |
---|
106 | ;; |
---|
107 | |
---|
108 | esac |
---|
109 | |
---|
110 | # It's really convenient to have a nice shell in the build root area, |
---|
111 | # at least on Solaris. |
---|
112 | mkdir -p "$root/bin/athena" |
---|
113 | cp /bin/athena/tcsh "$root/bin/athena/tcsh" |
---|
114 | |
---|
115 | # Make sure there is no smmsp user in the passwd file; Solaris has one |
---|
116 | # by default, and it confuses sendmail. |
---|
117 | grep -v '^smmsp' $root/etc/passwd > $root/etc/passwd.new |
---|
118 | mv $root/etc/passwd.new $root/etc/passwd |
---|
119 | chmod 644 $root/etc/passwd |
---|
120 | |
---|
121 | # Likewise for the group file. |
---|
122 | grep -v '^smmsp' $root/etc/group > $root/etc/group.new |
---|
123 | mv $root/etc/group.new $root/etc/group |
---|
124 | chmod 644 $root/etc/group |
---|
125 | |
---|
126 | # The discuss build needs the discuss user to be in the passwd file. |
---|
127 | grep '^discuss' /etc/passwd >> $root/etc/passwd |
---|
128 | |
---|
129 | # Create the shadow password file, so programs such as passwd get |
---|
130 | # configured properly. |
---|
131 | chroot $root $pwconv |
---|
132 | |
---|
133 | # Prepare the source locker symlinks. |
---|
134 | mkdir -p "$root/mit" |
---|
135 | ln -s /afs/dev.mit.edu/source/src-current $root/mit/source |
---|
136 | if [ -n "$ver" ]; then |
---|
137 | ln -s /afs/dev.mit.edu/source/src-$ver $root/mit/source-$ver |
---|
138 | fi |
---|