File: native-install

package info (click to toggle)
crosshurd 1.7.66
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 244 kB
  • sloc: sh: 714; makefile: 2
file content (328 lines) | stat: -rwxr-xr-x 9,890 bytes parent folder | download | duplicates (2)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#!/bin/bash
#
# Copyright (c) 1998, 1999, 2000, 2002  by Marcus Brinkmann.
# Copyright (c) 2003, 2004, 2005 by Robert Millan.
# Licensed under the GNU GPLv2 or later.
#
# Parts of this script was taken from the SETUP script in Hurd CVS. 


export \
PATH="/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"

# Make sure the filesystem is writeable
echo Checking if your filesystem is really writeable..
case $OSTYPE in
  "")		echo failed to identify system ; exit 1 ;;
  gnu)		if which fsysopts >/dev/null ; then fsysopts / --writable ; fi ;;
  linux-gnu)	if which mount >/dev/null ; then mount -o rw,remount / ; fi ;;
  *)		if which mount >/dev/null ; then mount -o rw / ; fi ;;
esac

set -e

# This must come before evaluating `uname -s` because, on GNU,
# without the pflocal server set as a translator on
# /servers/socket/1, pipes cannot be created.
if ! test -e /servers/socket/1 && which settrans >/dev/null ; then
  settrans -c /servers/socket/1 /hurd/pflocal
fi

system=`uname -s`

parent_term="$TERM"

case "${system}" in
  GNU)
	if [ "$TERM" = "dumb" ] ; then
	  export TERM=mach
	fi
	if showtrans --silent /proc ; then
		echo Existing system found, exitting.
		exit 1
	fi

	if ! showtrans --silent /dev/console ; then

		# Set up standard passive translators
		echo
		echo Setting up the translators. If you get Operation not supported errors,
		echo you have forgotten to use '-o hurd' when creating the ext2 filesystem.

		settrans -k /servers/socket/1 /hurd/pflocal
		settrans -c /servers/socket/2 /hurd/pfinet -6 /servers/socket/26
		settrans -c /servers/socket/26 /hurd/pfinet -4 /servers/socket/2
		settrans -k /servers/exec /hurd/exec
		settrans -c /servers/crash-suspend /hurd/crash --suspend
		settrans -c /servers/crash-kill /hurd/crash --kill
		settrans -c /servers/password /hurd/password
	        settrans -c /servers/default-pager /hurd/proxy-defpager
		#chmod +x /servers/default-pager

		# Not functional yet:
		settrans -c /servers/crash-dump-core /hurd/crash --dump-core
		if [ ! -e /servers/crash ] ; then
			ln -s crash-kill /servers/crash
		fi
		if [ ! -e /servers/socket/local ] ; then
			ln -s 1 /servers/socket/local
		fi
		if [ ! -e /servers/socket/inet ] ; then
			ln -s 2 /servers/socket/inet
		fi

		# We need /dev/fd to call scripts.
		cd /dev
		bash ./MAKEDEV -v fd

		# Setup crucial devices.
		echo
		echo The next job is to setup device files.
		cd /dev
		bash ./MAKEDEV -v std ptyp ptyq com0
		bash ./MAKEDEV vcs tty1 tty2 tty3 tty4 tty5 tty6

		# Not crucial, but will not hurt either.
		bash ./MAKEDEV hd0
	fi

	# Make sure that the runsystem stuff will work
	if [ -e /usr/libexec/runsystem.gnu -a -e /usr/libexec/runsystem ] ; then
	  echo Removing /usr/libexec/runsystem again, so the Hurd package can
	  echo take care about it.
	  rm /usr/libexec/runsystem
	fi
  ;;
  Linux)
	mount -t proc proc /proc
	test -e /etc/mtab || ln -s /proc/mounts /etc/mtab
	cd /dev && MAKEDEV std generic
  ;;
  *FreeBSD)
	if test -e /dev/null && test ! -c /dev/null ; then
	  echo "/dev/null exists but is not a character device, removing it"
	  rm -f /dev/null
	fi
	case `uname -r` in
	  4.*)	echo Copy device files into /dev before running $0
		exit ;;
	  *)	mount -t devfs null /dev ;;
	esac
	if [ "$TERM" = "dumb" ] ; then
	  export TERM=cons25
	fi
  ;;
esac

# Debian set up.
echo
echo Configuring Debian packages.

# Avoid username resolving errors
cp /usr/share/base-passwd/passwd.master /etc/passwd
cp /usr/share/base-passwd/group.master /etc/group

# Make sure /etc/shadow is available
/usr/sbin/shadowconfig on

debs=`for i in /var/cache/apt/archives/*.deb ; do
case $i in
  /var/cache/apt/archives/dpkg_*.deb) ;;
  *) echo $i ;;
esac ; done`
ssd=`which start-stop-daemon || echo /usr/sbin/start-stop-daemon`

# install dpkg and libc
dpkg --force-depends -i /var/cache/apt/archives/gawk_*.deb
dpkg --force-depends -i /var/cache/apt/archives/base-{files,passwd}_*.deb
dpkg --force-depends -i /var/cache/apt/archives/dpkg_*.deb
if ! test -e ${ssd}.real ; then mv ${ssd}{,.real} ; fi
cp /bin/true $ssd
dpkg --force-depends -i /var/cache/apt/archives/libc[0-9]*.deb
dpkg --force-depends -i /var/cache/apt/archives/perl-base_*.deb
dpkg --force-depends -i /var/cache/apt/archives/debconf_*.deb

# reinstall hurd package, if applicable
if [ -e /var/cache/apt/archives/hurd_*.deb ] ; then
	dpkg --force-depends -i /var/cache/apt/archives/adduser_*.deb
	dpkg --force-depends -i /var/cache/apt/archives/hurd_*.deb
fi

# unpack required packages
for i in /var/cache/apt/archives/*.deb ; do
	dpkg-deb --field $i Priority | grep ^required > /dev/null \
	&& dpkg --force-depends --skip-same-version --unpack $i
done
# also unpack the important packages (possibly dependencies of required packages)
for i in /var/cache/apt/archives/*.deb ; do
	dpkg-deb --field $i Priority | grep ^important > /dev/null \
	&& dpkg --force-depends --skip-same-version --unpack $i
done
dpkg --force-depends --skip-same-version --unpack /var/cache/apt/archives/insserv_*.deb
dpkg --configure --pending --force-configure-any --force-depends
if ! test -e ${ssd}.real ; then mv ${ssd}{,.real} ; fi
cp /bin/true $ssd

# install base packages
for i in /var/cache/apt/archives/*.deb ; do
	dpkg --force-overwrite --force-confold \
	--skip-same-version --unpack $i
done
dpkg  --force-confold --skip-same-version  --configure -a
mv $ssd{.real,}

# post-install configuration

# some boot tarballs have a hacked inittab, let's restore it.
if [ -e /usr/share/sysvinit/inittab ] ; then
        cp /usr/share/sysvinit/inittab /etc/inittab
fi

case "${system}" in
  GNU)
	echo I just make sure that /usr/libexec/runsystem is properly updated.
	if [ ! -e /usr/libexec/runsystem -a -e /usr/libexec/runsystem.gnu ] ; then
	  echo WHOA! We\'re in deep trouble. The Hurd package did not update
	  echo the link in /usr/libexec/runsystem. For now, I am making a link
	  echo manually, but please report this.
	  ln -s runsystem.gnu /usr/libexec/runsystem
	fi

	# fstab stuff
	fstype=`fsysopts / | perl -ne 'm!^\s*(?:[^\s]*/)?([^\s]+?)(?:\.static)?\s+.*?\s+([^\s]+)\s*$!; print $1;'`
	rootpart=`fsysopts / | perl -ne 'm!^\s*(?:[^\s]*/)?([^\s]+?)(?:\.static)?\s+.*?\s+([^\s]+)\s*$!; print $2;' | sed -e 's/.*part:\(.*\):device:\(.*\)/\2s\1/' | sed -e "s/^device\://"`
	if [ ! -e /dev/${rootpart} ] ; then
		cd /dev
		bash ./MAKEDEV ${rootpart} || true
	fi

	if [ x${fstype} = xext2fs ] ; then
		fstype=ext2
	fi
        fstype_dummy="ext2"
        rootpart_dummy="hd0s2"
	swappart_dummy="hd0s1"

	#proc=`ps ax | grep hurd/term | grep dev/console | sed -e 's/[a-z ]*\([0-9]*\) .*/\1/'`
	#if [ ! -z $proc ] ; then
	#	echo
	#	echo Found dangling console server, which will suck up
	#	echo every second character you type. That is a bug, and
	#	echo I will kill this process for you.
	#	kill $proc
	#fi
	procfs="none"
  ;;
  *FreeBSD)
	cat > /etc/network/interfaces << __EOF__
# Sample /etc/network/interfaces file for GNU/kFreeBSD

auto lo0
iface lo0 inet loopback

# DHCP network (replace ed0 with your interface, if different)
#auto ed0
#iface ed0 inet dhcp

# Static network (replace ed0 with your interface, if different)
#auto ed0
#iface ed0 inet static
#	address 192.168.0.3
#	network 192.168.0.0
#	netmask 255.255.255.0
#	gateway 192.168.0.1
__EOF__

	# fstab stuff
	fstype="`mount | grep ' on / ' | cut -d '(' -f 2 | cut -d ',' -f 1`"
	rootpart="`mount | grep ' on / ' | cut -d / -f 3 | cut -d ' ' -f 1`"
        fstype_dummy="ufs"
        rootpart_dummy="ad0s1a"
	swappart_dummy="ad0s1b"

	# hack for installs from livecd
	case "$fstype:$rootpart" in
	  cd9660:*|*:/dev/acd*)
	    fstype="$fstype_dummy"
	    rootpart="$rootpart_dummy"
	  ;;
	esac
	procfs="linprocfs"
  ;;
  Linux)
	umount /proc

	# fstab stuff
	fstype="`mount | grep ' on / ' | cut -d ' ' -f 5`"
	rootpart="`mount | grep ' on / ' | cut -d / -f 3 | cut -d ' ' -f 1`"
        fstype_dummy="ext2"
        swappart_dummy="hda2"
        rootpart_dummy="hda1"
	procfs="proc"
  ;;
esac

fstab_dummy="\
#/dev/${rootpart_dummy}	/		${fstype_dummy}	rw			1	1
#/dev/${swappart_dummy}	none		swap	sw			0	0
"
fstab_good="\
/dev/${rootpart}	/		${fstype}	rw			1	1
#/dev/${swappart_dummy}	none		swap	sw			0	0
"

cat > /etc/fstab << __EOF__
# /etc/fstab: static file system information
#
# <file system>	<mount point>	<type>	<options>		<dump>	<pass>
__EOF__

echo
echo "********************************************************************************"
echo " Native-install done."
echo "********************************************************************************"
echo

if [ ! -e /dev/${rootpart} ] ; then
	echo Couldn\'t determine root partition, sorry.
	echo You have to edit /etc/fstab to match your system.
	echo However, for your convenience, I will install a dummy entry.
	echo "$fstab_dummy" >> /etc/fstab
else
	echo Your root partition is /dev/${rootpart}.
	echo Your file system type is ${fstype}.
	echo If this information is not correct, you need to edit /etc/fstab.
	echo "$fstab_good" >> /etc/fstab
fi

if [ "${procfs}" != "none" ] ; then
  echo "null	/proc	${procfs}	rw	0 0" >> /etc/fstab
fi

echo
echo "If you have a swap partition, please add it to /etc/fstab."
echo
echo "Available editors are:"
which nano vi zile emacs || true
echo

echo 'You should now set a root password with the passwd command.'
echo

case "${system}:$parent_term" in
  GNU:*)
    echo 'Then you can reboot with reboot-hurd, and enter multi-user mode.'
    echo 'Note that you will have to activate the Hurd console manually'
    echo 'currently.'
    echo 'To do this, run'
    echo '  console -d vga -d pc_kbd --repeat=kbd -d pc_mouse --repeat=mouse \'
    echo '          -d generic_speaker -c /dev/vcs'
    echo 'as root after you have logged in.'
    ;;
  *FreeBSD:dumb)
    echo "Looks like you are using a dumb terminal.  In order to get a fully"
    echo "functional one, you need to run \"export TERM=cons25\"."
    ;;
esac

sync