The scripts have been rewritten to separate code from data.

This allows to use different config files without having to
edit the code scripts.
This commit is contained in:
Jens Schweikhardt 2004-01-03 15:46:31 +00:00
parent de5f692d9e
commit cb61d5bff4
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=19459
7 changed files with 557 additions and 307 deletions

View file

@ -13,12 +13,14 @@ INSTALL_COMPRESSED?= gz
INSTALL_ONLY_COMPRESSED?=
# SGML content
SRCS= article.sgml stage_1.sh stage_2.sh stage_3.mk
SRCS= article.sgml stage_1.conf.default stage_1.sh stage_2.conf.default \
stage_2.sh stage_3.mk
DOC_PREFIX?= ${.CURDIR}/../../..
afterinstall:
${INSTALL_DOCS} ${.CURDIR}/stage_1.sh ${.CURDIR}/stage_2.sh \
${INSTALL_DOCS} ${.CURDIR}/stage_1.sh ${.CURDIR}/stage_1.conf.default \
${.CURDIR}/stage_2.sh ${.CURDIR}/stage_2.conf.default \
${.CURDIR}/stage_3.mk ${DESTDIR}
.include "${DOC_PREFIX}/share/mk/doc.project.mk"

View file

@ -20,17 +20,17 @@
</affiliation>
</author>
<copyright>
<year>2002</year>
<year>2002,2003,2004</year>
<holder>Jens Schweikhardt</holder>
</copyright>
<pubdate>$FreeBSD$</pubdate>
<legalnotice id="trademarks" role="trademarks">
&tm-attrib.freebsd;
&tm-attrib.adobe;
&tm-attrib.general;
</legalnotice>
&tm-attrib.freebsd;
&tm-attrib.adobe;
&tm-attrib.general;
</legalnotice>
</articleinfo>
<abstract>
@ -167,8 +167,8 @@
<para>There are also downsides in the approach taken by &scratch.ap;
that you should bear in mind.</para>
<!-- XXX: A nice idea would be to write stage2.sh using a jail
that runs into the newly installed world from stage1. Having
<!-- XXX: A nice idea would be to write stage_2.sh using a jail
that runs into the newly installed world from stage_1. Having
properly set up a network address as the jail's primary IP
address, it might even be possible to build ports in a chroot
without uninstalling anything from the 'host' system. But
@ -179,9 +179,9 @@
<para>While compiling the ports during stage two the system can
not be used for its usual duties. If you run a production server
you have to consider the downtime caused by stage two. The ports
compiled by <filename>stage_2.sh</filename> below require about 4
hours to build on an AMD1800+ SCSI system with 10krpm disks and
1GB of RAM.</para>
compiled by <filename>stage_2.conf.default</filename> below require
about 4 hours to build on an AMD1800+ SCSI system with 10krpm disks
and 1GB of RAM.</para>
</listitem>
</itemizedlist>
@ -229,11 +229,36 @@
<sect1 id="stage1">
<title>Stage One: System Installation</title>
<para>The following is my <filename>stage_1.sh</filename>. You
need to customize it in various places to match your idea of
the <quote>perfect system</quote>. I have tried to
extensively comment the places you should adapt. The points to
ponder are:</para>
<para>The first version of this article used a single shell script
for stage one where all your customization had to be done by editing
the script. After valuable user feedback I have decided to
separate the code and data in the scripts. This allows to have
different configuration data sets to install different systems
without changing any of the code scripts.</para>
<para>The code script for stage one is
<filename>stage_1.sh</filename> and when run with exactly one
argument, like</para>
<informalexample>
<screen>&prompt.root; <userinput>./stage_1.sh <replaceable>default</replaceable></userinput></screen>
</informalexample>
<para>will read its configuration from
<filename>stage_1.conf.default</filename> and write a log to
<filename>stage_1.log.default</filename>.</para>
<para>The following is my <filename>stage_1.conf.default</filename>.
You need to customize it in various places to match your idea of the
<quote>perfect system</quote>. I have tried to extensively comment
the places you should adapt. The configuration script must provide
four shell functions, <command>create_file_systems</command>,
<command>create_etc_fstab</command>, <command>copy_files</command>
and <command>all_remaining_customization</command> (in case it
matters: this is also the sequence in which they will be called
from <filename>stage_1.sh</filename>).
<para>The points to ponder are:</para>
<itemizedlist>
<listitem>
@ -260,21 +285,16 @@
<para>Luxury items.</para>
<para>What you want immediately after booting the new system and
even before starting stage two. In my case this is <filename
role="package">shells/zsh</filename> because this is the login
shell for my account as specified in <filename>/etc/passwd</filename>.
Strictly speaking you can do without luxury items, because all you
need to do is log in as root and run the next stage.</para>
<para>The reason for not simply installing all my beloved ports
during stage one is that in theory and in practice there are
bootstrap and consistency issues: stage one has your old kernel
running, but the chrooted environment consists of new binaries
and headers. If the new system for example supports a new system
call (according to its headers), some configure-type script
might try to use it and get killed because it executes on the
old kernel. I have seen other issues when I tried building
<filename role="package">lang/perl5</filename>.</para>
even before starting stage two. The reason for not simply
installing all my beloved ports during stage one is that in
theory and in practice there are bootstrap and consistency
issues: stage one has your old kernel running, but the chrooted
environment consists of new binaries and headers. If the new
system for example supports a new system call (according to its
headers), some configure-type script might try to use it and get
killed because it executes on the old kernel. I have seen other
issues when I tried building <filename
role="package">lang/perl5</filename>.</para>
</listitem>
</itemizedlist>
@ -313,9 +333,10 @@
<para>The <filename>stage_1.sh</filename> script will stop at the
first command that fails (returns a non-zero exit status) due to
<command>set -e</command>, so you cannot overlook errors. You should
correct any errors in your version of
<filename>stage_1.sh</filename> before you go on.</para>
<command>set -e</command>, so you cannot overlook errors. It will
also stop if you use an unset environment variable, probably due
to a typo. You should correct any errors in your version of
<filename>stage_1.conf.default</filename> before you go on.</para>
<para>In <filename>stage_1.sh</filename> we invoke
<command>mergemaster</command>. Even if none of the files requires a
@ -332,7 +353,7 @@ Do you wish to delete what is left of /var/tmp/temproot.stage1? [no] <userinput>
new system later (unless already there).</para>
<para>After that it will list the files it installed, making use of
a pager (&man.more.1; by default, optionally &man.less.1;):</para>
a pager, &man.more.1; by default, optionally &man.less.1;:</para>
<screen>*** You chose the automatic install option for files that did not
exist on your system. The following were installed for you:
@ -354,26 +375,25 @@ Do you wish to delete what is left of /var/tmp/temproot.stage1? [no] <userinput>
<para>The answer does not matter since we will run &man.cap.mkdb.1; in any
case.</para>
<para>Everything <filename>stage_1.sh</filename> does is logged to
<filename>stage_1.log</filename> for you to examine if you wish to
do so.</para>
<para>Here is the author's <filename>stage_1.sh</filename>, which
you need to modify substantially, especially steps 1, 2, 5 and 6.</para>
<para>Here is the author's <ulink
url="stage_1.conf.default"><filename>stage_1.conf.default</filename></ulink>,
which you need to modify substantially. The comments give you
enough information what to change.</para>
<warning>
<para>Please pay attention to the &man.newfs.8; commands.
While you can not create new file systems on mounted partitions, the
script will happily erase any unmounted
<filename>/dev/da3s1a</filename>, <filename>/dev/vinum/var_a</filename>
and <filename>/dev/vinum/usr_a</filename>. This can be enough to ruin
<filename>/dev/da0s1a</filename>, <filename>/dev/da0s1e</filename>
and <filename>/dev/da2s1e</filename>. This can be enough to ruin
your day, so be sure to modify the device names.</para>
</warning>
<programlisting><inlinegraphic fileref="stage_1.sh" format="linespecific"></programlisting>
<programlisting><inlinegraphic fileref="stage_1.conf.default" format="linespecific"></programlisting>
<para>Download <ulink
url="stage_1.sh"><filename>stage_1.sh</filename></ulink>.</para>
url="stage_1.conf.default"><filename>stage_1.conf.default</filename>
</ulink>.</para>
<para>Running this script installs a system that when booted
provides:</para>
@ -418,8 +438,15 @@ Do you wish to delete what is left of /var/tmp/temproot.stage1? [no] <userinput>
install my favorite ports. It can be run any number of times and
will skip all ports that are already installed. It supports the
<emphasis>dryrun</emphasis> option (<option>-n</option>) to just
show what would be done. You will certainly want to edit the list of
ports, and possibly change a few environment variables.</para>
show what would be done. You run it like <filename>stage_1.sh</filename>
with exactly one argument to denote a config file, e.g.</para>
<informalexample>
<screen>&prompt.root; <userinput>./stage_2.sh <replaceable>default</replaceable></userinput></screen>
</informalexample>
<para>which will read the list of ports from
<filename>stage_2.conf.default</filename>.</para>
<para>The list of ports consists of lines with two or more space
separated words: the category and the port, optionally followed by
@ -459,17 +486,14 @@ news inn-stable CONFIGURE_ARGS="--enable-uucp-rnews --enable-setgid-inews" make
<filename>stage_2.sh</filename> mysteriously skips a port or stops
processing, this is likely the reason.</para>
<para>Here is <filename>stage_2.sh</filename>. It creates a log file
named <filename>LOGDIR/category+port</filename> for each port
it actually installs. If you do not have
<filename>stage_2.sh</filename> on a shared partition make sure you
copy it to the new system before you boot it.</para>
<para>Below is <filename>stage_2.conf.default</filename>. A log file named
<filename>LOGDIR/category+port</filename> is created for each port
it actually installs.</para>
<programlisting><inlinegraphic fileref="stage_2.sh" format="linespecific"></programlisting>
<programlisting><inlinegraphic fileref="stage_2.conf.default" format="linespecific"></programlisting>
<para>Download <ulink
url="stage_2.sh"><filename>stage_2.sh</filename></ulink>.</para>
</sect1>
url="stage_2.conf.default"><filename>stage_2.conf.default</filename></ulink>.</para>
<sect1 id="stage3">
<title>Stage Three</title>
@ -495,12 +519,6 @@ news inn-stable CONFIGURE_ARGS="--enable-uucp-rnews --enable-setgid-inews" make
system, either by putting it on a shared partition or copying it
somewhere on the new system.</para>
<programlisting><inlinegraphic fileref="stage_3.mk" format="linespecific"></programlisting>
<para>Download <ulink
url="stage_3.mk"><filename>stage_3.mk</filename></ulink>.</para>
</sect1>
<sect1 id="limitations">
<title>Limitations</title>
@ -510,9 +528,9 @@ news inn-stable CONFIGURE_ARGS="--enable-uucp-rnews --enable-setgid-inews" make
than typing <literal>yes</literal> when asked to accept some license.
If such input is read from the standard input, we simply pipe the
appropriate answers to the installation command (usually <command>make
install</command>; this is how we deal with <filename
role="package">java/linux-sun-jdk13</filename> in
<filename>stage_2.sh</filename>).</para>
install</command>; this is how I deal with <filename
role="package">java/linux-sun-jdk14</filename> in
<filename>stage_2.conf.default</filename>).</para>
<para>This strategy for example does not work for <filename
role="package">editors/staroffice52</filename>, which requires that
@ -567,10 +585,47 @@ Creating bzip'd tar ball in '/usr/ports/editors/staroffice52/staroffice-5.2_1.tb
areas:</para>
<note>
<para>If you do not use the device file system (&man.devfs.5;)
you may want to create devices for some of your hardware with
&man.MAKEDEV.8; in stage one, step six.</para>
<para>If you do not use the device file system, &man.devfs.5;, you
may want to create devices for some of your hardware with
&man.MAKEDEV.8; in <command>all_remaining_customization</command>.
</para>
</note>
</sect1>
<sect1 id="files">
<title>The Files</title>
<para>Here are the three files you need beside the config files
already shown above.</para>
<para>This is the <ulink
url="stage_1.sh"><filename>stage_1.sh</filename></ulink>
script, which you should not need to modify.</para>
<programlisting><inlinegraphic fileref="stage_1.sh" format="linespecific"></programlisting>
<para>Download <ulink
url="stage_1.sh"><filename>stage_1.sh</filename></ulink>.</para>
<para>This is the <ulink
url="stage_2.sh"><filename>stage_2.sh</filename></ulink>
script. You may want to modify the variables at the
beginning.</para>
<programlisting><inlinegraphic fileref="stage_2.sh" format="linespecific"></programlisting>
<para>Download <ulink
url="stage_2.sh"><filename>stage_2.sh</filename></ulink>.</para>
<para>This is my <ulink
url="stage_3.mk"><filename>stage_3.mk</filename></ulink> to
give you an idea how to automate all reconfiguration.</para>
<programlisting><inlinegraphic fileref="stage_3.mk" format="linespecific"></programlisting>
<para>Download <ulink
url="stage_3.mk"><filename>stage_3.mk</filename></ulink>.</para>
</sect1>
</article>

View file

@ -0,0 +1,178 @@
# This file: stage_1.conf.default, sourced by stage_1.sh.
#
# $Id: stage_1.conf.default,v 1.1 2004-01-03 15:46:31 schweikh Exp $
# $FreeBSD$
# Root mount point where you create the new system. Because it is only
# used as a mount point, no space will be used on that file system as all
# files are of course written to the mounted file system(s).
DESTDIR="/newroot"
# Where your src tree is.
SRC="/usr/src"
# Your kernel config name as from make buildkernel KERNCONF=...
KERNCONF="HAL9000"
# Available time zones are those under /usr/share/zoneinfo.
TIMEZONE="Europe/Berlin"
#
# The create_file_systems function must create the mountpoints under
# DESTDIR, create the file systems, and then mount them under DESTDIR.
#
create_file_systems () {
# The new root file system. Mandatory.
# Change DEVICE names or risk foot shooting.
# You must use newfs -O 1 for the root fs if you want to boot it from grub.
DEVICE=/dev/da0s1a
mkdir -p ${DESTDIR}
chown root:wheel ${DESTDIR}
newfs -O 1 ${DEVICE}
tunefs -n enable ${DEVICE}
mount -o noatime ${DEVICE} ${DESTDIR}
# Additional file systems and initial mount points. Optional.
DEVICE=/dev/da0s1e
newfs ${DEVICE}
tunefs -n enable ${DEVICE}
mkdir -m 755 ${DESTDIR}/var
chown root:wheel ${DESTDIR}/var
mount -o noatime ${DEVICE} ${DESTDIR}/var
DEVICE=/dev/da2s1e
newfs ${DEVICE}
tunefs -n enable ${DEVICE}
mkdir -m 755 ${DESTDIR}/usr
chown root:wheel ${DESTDIR}/usr
mount -o noatime ${DEVICE} ${DESTDIR}/usr
}
#
# The create_etc_fstab function must create an fstab matching the
# file systems created in create_file_systems.
#
create_etc_fstab () {
cat <<EOF >${DESTDIR}/etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/da0s1b none swap sw 0 0
/dev/da1s2b none swap sw 0 0
/dev/da2s2b none swap sw 0 0
/dev/da3s2b none swap sw 0 0
/dev/da0s1a / ufs rw,noatime 1 1
/dev/da0s1e /var ufs rw,noatime 1 1
/dev/da2s1e /usr ufs rw,noatime 1 1
/dev/vinum/Share /share ufs rw,noatime 0 2
/dev/vinum/home /home ufs rw,noatime 0 2
/dev/vinum/ncvs /home/ncvs ufs rw,noatime 0 2
/dev/vinum/ports /usr/ports ufs rw,noatime 0 2
/dev/ad0s1 /2k ntfs ro,noauto 0 0
/dev/ad0s6 /linux ext2fs ro 0 0
#
/dev/cd0 /cdrom cd9660 ro,noauto 0 0
/dev/cd1 /dvd cd9660 ro,noauto 0 0
proc /proc procfs rw 0 0
linproc /compat/linux/proc linprocfs rw 0 0
EOF
chmod 644 ${DESTDIR}/etc/fstab
chown root:wheel ${DESTDIR}/etc/fstab
}
#
# The copy_files function is used to copy files before mergemaster is run.
#
copy_files () {
# Add or remove from this list at your discretion. Mostly mandatory.
for f in \
/.profile \
/etc/group \
/etc/hosts \
/etc/inetd.conf \
/etc/ipfw.conf \
/etc/make.conf \
/etc/master.passwd \
/etc/nsswitch.conf \
/etc/ntp.conf \
/etc/printcap \
/etc/profile \
/etc/rc.conf \
/etc/resolv.conf \
/etc/start_if.xl0 \
/etc/ttys \
/etc/ppp/* \
/etc/mail/aliases \
/etc/mail/aliases.db \
/etc/mail/hal9000.mc \
/etc/mail/service.switch \
/etc/ssh/*key* \
/etc/ssh/*_config \
/etc/X11/XF86Config-4 \
/var/cron/tabs/root \
/var/files \
/root/.profile \
/boot/splash.bmp \
/boot/loader.conf \
/boot/device.hints ; do
cp -p ${f} ${DESTDIR}${f}
done
}
#
# Everything else you want to tune in the new system.
# NOTE: Do not install too many binaries here. With the old system running and
# the new binaries and headers installed you are likely to run into bootstrap
# problems. Ports should be compiled after you have booted in the new system.
#
all_remaining_customization () {
# Without the compat symlink the linux_base files end up on the root fs:
cd ${DESTDIR}
mkdir -m 755 usr/compat; chown root:wheel usr/compat; ln -s usr/compat
mkdir -m 755 usr/compat/linux; chown root:wheel usr/compat/linux
mkdir -m 555 usr/compat/linux/proc; chown root:wheel usr/compat/linux/proc
mkdir -m 755 boot/grub; chown root:wheel boot/grub
mkdir -m 755 linux 2k; chown root:wheel linux 2k
mkdir -m 755 src; chown root:wheel src
mkdir -m 755 share; chown root:wheel share
mkdir -m 755 dvd cdrom; chown root:wheel dvd cdrom
mkdir -m 755 home; chown root:wheel home
mkdir -m 755 usr/ports; chown root:wheel usr/ports
# My personal preference is to symlink tmp -> var/tmp. Optional.
cd ${DESTDIR}; rmdir tmp; ln -s var/tmp
# Make spooldirs for the printers in my /etc/printcap.
cd ${DESTDIR}/var/spool/output/lpd; mkdir -p as od ev te lp da
touch ${DESTDIR}/var/log/lpd-errs
# If you do not have /home on a shared partition, you may want to copy it:
# mkdir -p ${DESTDIR}/home
# cd /home; tar cf - . | (cd ${DESTDIR}/home; tar xpvf -)
case ${REVISION} in
4.*)
# 4.x without devfs: create non-standard devices to match your hardware.
cd ${DESTDIR}/dev
./MAKEDEV all
./MAKEDEV da0 da0s1h da0s2h da0s3h da0s4h
./MAKEDEV da1 da1s1h da1s2h da1s3h da1s4h
./MAKEDEV da2 da2s1h da2s2h da2s3h da2s4h
./MAKEDEV da3 da3s1h da3s2h da3s3h da3s4h
./MAKEDEV bktr0 cd1
if test -d /dev/vinum; then
# 'vinum makedev' can only create devices in /dev, thus use cpio.
cd /dev; find vinum -print | cpio -pv ${DESTDIR}/dev
fi
;;
5.*)
# Starting with FreeBSD 5.x, perl lives in /usr/local/bin but many scripts
# use a hardcoded #!/usr/bin/perl; use a symlink to make them work.
# Effectively mandatory.
cd ${DESTDIR}/usr/bin; ln -s ../local/bin/perl
;;
esac
}
# vim: tabstop=2:expandtab:shiftwidth=2:syntax=sh:
# EOF $RCSfile: stage_1.conf.default,v $

View file

@ -1,11 +1,13 @@
#!/bin/sh
#
# stage_1.sh - FreeBSD From Scratch, Stage 1: System Installation.
# Usage: ./stage_1.sh
# Usage: ./stage_1.sh profile
# will read ./stage_1.conf.profile
# and write ./stage_1.log.profile
#
# $Id: stage_1.sh,v 1.3 2004-01-03 15:46:31 schweikh Exp $
# $FreeBSD$
set -x -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
# Prerequisites:
@ -13,46 +15,21 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
# a) Successfully completed "make buildworld" and "make buildkernel"
# b) Unused partitions (at least one for the root fs, probably more for
# the new /usr and /var, to your liking.)
# c) A customized stage_1.conf.profile file.
# Root mount point where you create the new system. Because it is only
# used as a mount point, no space will be used on that file system as all
# files are of course written to the mounted file system(s).
DESTDIR=/newroot
SRC=/usr/src # Where your src tree is.
if test $# -ne 1; then
echo "usage: stage_1.sh profile" 1>&2
exit 1
fi
# ---------------------------------------------------------------------------- #
# Step 1: Create an empty directory tree below $DESTDIR.
# ---------------------------------------------------------------------------- #
step_one () {
# The new root file system. Mandatory.
# Change device names (DEV_*) or risk foot shooting.
DEV_ROOT=/dev/da3s1a
mkdir -p ${DESTDIR}
newfs ${DEV_ROOT}
tunefs -n enable ${DEV_ROOT}
mount -o noatime ${DEV_ROOT} ${DESTDIR}
# Additional file systems and initial mount points. Optional.
DEV_VAR=/dev/vinum/var_a
newfs ${DEV_VAR}
tunefs -n enable ${DEV_VAR}
mkdir -m 755 ${DESTDIR}/var
mount -o noatime ${DEV_VAR} ${DESTDIR}/var
DEV_USR=/dev/vinum/usr_a
newfs ${DEV_USR}
tunefs -n enable ${DEV_USR}
mkdir -m 755 ${DESTDIR}/usr
mount -o noatime ${DEV_USR} ${DESTDIR}/usr
mkdir -m 755 -p ${DESTDIR}/usr/ports
mount /dev/vinum/ports ${DESTDIR}/usr/ports
create_file_systems
# Now create all the other directories. Mandatory.
cd ${SRC}/etc; make distrib-dirs DESTDIR=${DESTDIR}
# My personal preference is to symlink tmp -> var/tmp. Optional.
cd ${DESTDIR}; rmdir tmp; ln -s var/tmp
}
# ---------------------------------------------------------------------------- #
@ -60,36 +37,8 @@ step_one () {
# ---------------------------------------------------------------------------- #
step_two () {
# Add or remove from this list at your discretion. Mostly mandatory.
for f in \
/.profile \
/etc/group \
/etc/hosts \
/etc/inetd.conf \
/etc/ipfw.conf \
/etc/make.conf \
/etc/master.passwd \
/etc/nsswitch.conf \
/etc/ntp.conf \
/etc/printcap \
/etc/profile \
/etc/rc.conf \
/etc/resolv.conf \
/etc/start_if.xl0 \
/etc/ttys \
/etc/ppp/* \
/etc/mail/aliases \
/etc/mail/aliases.db \
/etc/mail/hal9000.mc \
/etc/mail/service.switch \
/etc/ssh/*key* \
/etc/ssh/*_config \
/etc/X11/XF86Config-4 \
/boot/splash.bmp \
/boot/loader.conf \
/boot/device.hints ; do
cp -p ${f} ${DESTDIR}${f}
done
copy_files
# Delete mergemaster's temproot, if any.
TEMPROOT=/var/tmp/temproot.stage1
if test -d ${TEMPROOT}; then
@ -101,7 +50,7 @@ step_two () {
pwd_mkdb -d ${DESTDIR}/etc -p ${DESTDIR}/etc/master.passwd
# Mergemaster does not create empty files, e.g. in /var/log. Do so now,
# but do not clobber files that may have been copied in the loop above.
# but do not clobber files that may have been copied with copy_files.
cd ${TEMPROOT}
find . -type f | sed 's,^\./,,' |
while read f; do
@ -123,6 +72,11 @@ step_two () {
step_three () {
cd ${SRC}
make installworld DESTDIR=${DESTDIR}
# Install additional compatibility libraries (optional). Use this if you
# have programs dynamically linked against libc.so.4, i.e. if you see
# /usr/libexec/ld-elf.so.1: Shared object "libc.so.4" not found
cd lib/compat/compat4x.i386
make all install DESTDIR=${DESTDIR}
}
# ---------------------------------------------------------------------------- #
@ -135,86 +89,40 @@ step_four () {
# If you have not copied them in Step 2, cp them as shown in the next 2 lines.
# cp sys/boot/forth/loader.conf ${DESTDIR}/boot/defaults
# cp sys/i386/conf/GENERIC.hints ${DESTDIR}/boot/device.hints
make installkernel DESTDIR=${DESTDIR} KERNCONF=HAL9000
make installkernel DESTDIR=${DESTDIR} KERNCONF=${KERNCONF}
}
# ---------------------------------------------------------------------------- #
# Step 5: Install or modify a few essential files.
# Step 5: Install /etc/fstab and time zone info.
# ---------------------------------------------------------------------------- #
step_five () {
# Create /etc/fstab; mandatory. Modify to match your devices.
cat <<EOF >${DESTDIR}/etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/da3s1b none swap sw 0 0
/dev/da4s2b none swap sw 0 0
/dev/da3s1a / ufs rw 1 1
/dev/da1s2a /src ufs rw 0 2
/dev/da2s2f /share ufs rw 0 2
/dev/vinum/var_a /var ufs rw 0 2
/dev/vinum/usr_a /usr ufs rw 0 2
/dev/vinum/home /home ufs rw 0 2
/dev/vinum/ncvs /home/ncvs ufs rw,noatime 0 2
/dev/vinum/ports /usr/ports ufs rw,noatime 0 2
#
/dev/cd0 /dvd cd9660 ro,noauto 0 0
/dev/cd1 /cdrom cd9660 ro,noauto 0 0
proc /proc procfs rw 0 0
EOF
create_etc_fstab
# More directories; optional.
mkdir -m 755 -p ${DESTDIR}/src; chown root:wheel ${DESTDIR}/src
mkdir -m 755 -p ${DESTDIR}/share; chown root:wheel ${DESTDIR}/share
mkdir -m 755 -p ${DESTDIR}/dvd; chown root:wheel ${DESTDIR}/dvd
mkdir -m 755 -p ${DESTDIR}/home; chown root:wheel ${DESTDIR}/home
mkdir -m 755 -p ${DESTDIR}/usr/ports; chown root:wheel ${DESTDIR}/usr/ports
# Set up time zone info; pretty much mandatory.
cp ${DESTDIR}/usr/share/zoneinfo/Europe/Berlin ${DESTDIR}/etc/localtime
# Setup time zone info; pretty much mandatory.
cp ${DESTDIR}/usr/share/zoneinfo/${TIMEZONE} ${DESTDIR}/etc/localtime
if test -r /etc/wall_cmos_clock; then
cp -p /etc/wall_cmos_clock ${DESTDIR}/etc/wall_cmos_clock
fi
}
# ---------------------------------------------------------------------------- #
# Step 6: Things important to me when I first login to a new system.
# NOTE: Do not install too many binaries here. With the old system running and
# the new binaries and headers installed you are likely to run into bootstrap
# problems. Ports should be compiled after you have booted in the new system.
# Step 6: All remaining customization.
# ---------------------------------------------------------------------------- #
step_six () {
chroot ${DESTDIR} sh -c "cd /usr/ports/shells/zsh; make clean install clean"
chroot ${DESTDIR} sh -c "cd /etc/mail; make install" # configure sendmail
# Without the compat symlink the linux_base files end up on the root fs:
cd ${DESTDIR}; mkdir -m 755 usr/compat
chown root:wheel usr/compat; ln -s usr/compat
mkdir -m 755 usr/compat/linux
mkdir -m 755 boot/grub
# Make spooldirs for the printers in my /etc/printcap.
cd ${DESTDIR}/var/spool/output/lpd; mkdir -p as od ev te lp da
touch ${DESTDIR}/var/log/lpd-errs
# More files I want to inherit from the old system.
for f in \
/var/cron/tabs/root \
/var/mail/* \
/boot/grub/*; do
cp -p ${f} ${DESTDIR}${f}
done
# If you do not have /home on a shared partition, you may want to copy it:
# mkdir -p ${DESTDIR}/home
# cd /home; tar cf - . | (cd ${DESTDIR}/home; tar xpvf -)
# Starting with FreeBSD 5.x, perl lives in /usr/local/bin but many scripts
# use a hardcoded #!/usr/bin/perl; use a symlink to make them work.
cd ${DESTDIR}/usr/bin; ln -s ../local/bin/perl
cd ${DESTDIR}/usr; rmdir src; ln -s ../src/current src
all_remaining_customization
}
do_steps () {
echo "PROFILE=${PROFILE}"
echo "DESTDIR=${DESTDIR}"
echo "SRC=${SRC}"
echo "KERNCONF=${KERNCONF}"
echo "TIMEZONE=${TIMEZONE}"
echo "TYPE=${TYPE}"
echo "REVISION=${REVISION}"
echo "BRANCH=${BRANCH}"
step_one
step_two
step_three
@ -223,6 +131,27 @@ do_steps () {
step_six
}
do_steps 2>&1 | tee stage_1.log
# ---------------------------------------------------------------------------- #
# The ball starts rolling here.
# ---------------------------------------------------------------------------- #
# EOF $RCSfile: stage_1.sh,v $ vim: tabstop=2:expandtab:
PROFILE="$1"
set -x -e -u # Stop for any error or use of an undefined variable.
. ./stage_1.conf.${PROFILE}
# Determine a few variables from the sources that were used to make the
# world. The variables can be used to modify actions, e.g. depending on
# whether we install a 4.x or 5.x system. The result of the eval will be
# something like
#
# TYPE="FreeBSD"
# REVISION="4.9"
# BRANCH="RC"
#
eval $(awk '/^(TYPE|REVISION|BRANCH)=/' ${SRC}/sys/conf/newvers.sh)
echo "=> Logging to stage_1.log.${PROFILE}"
do_steps 2>&1 | tee stage_1.log.${PROFILE}
# vim: tabstop=2:expandtab:shiftwidth=2:
# EOF $RCSfile: stage_1.sh,v $

View file

@ -0,0 +1,78 @@
# vim: syntax=sh
# $Id: stage_2.conf.default,v 1.1 2004-01-03 15:46:31 schweikh Exp $
# $FreeBSD$
shells zsh
lang perl5 make install; use.perl port
archivers unzip
archivers zip
security sudo
x11-servers XFree86-4-Server
x11 wrapper
x11 XFree86-4-libraries
x11 XFree86-4-clients
x11-fonts XFree86-4-font75dpi
x11-fonts XFree86-4-font100dpi
x11-fonts XFree86-4-fontScalable
x11-fonts urwfonts
x11-fonts webfonts make WITH_NETSCAPE_ALIASES=yes install
x11-toolkits open-motif
x11-wm ctwm
security openssh-askpass
astro xplanet
astro xephem
editors vim
print ghostscript-gnu make A4=yes BATCH=yes install
print psutils-a4
print a2ps-a4
print gv
print acroread5
print transfig
print teTeX
# NOTE: jdk14 needs linprocfs(5) mounted or it will hang indefinitely.
java linux-sun-jdk14 mount -a linproc; yes | make install
java jdk14 mount -a linproc; make -DNODEBUG install
www apache2
www weblint
www amaya
www mozilla-firebird
www mozilla make WITHOUT_MAILNEWS=yes WITHOUT_COMPOSER=yes WITHOUT_LDAP=yes WITHOUT_CHATZILLA=yes WITHOUT_XMLTERM=yes install
www checkbot
www privoxy
graphics xfig
graphics xv
multimedia xawtv
graphics graphviz
lang expect
lang gawk
lang TenDRA unset MAKEOBJDIRPREFIX; make install
news tin
net freebsd-uucp
net cvsup-without-gui
net pathchar make NO_CHECKSUM=yes install
ftp wget
ftp ncftp3
textproc ispell
german ispell-neu
german ispell-alt
textproc docproj make JADETEX=no HAVE_MOTIF=yes install
sysutils samefile
sysutils pstree
sysutils mkisofs
sysutils cdrtools
#sysutils grub currently (0.93) marked BROKEN
devel ddd
devel gindent
devel ctags
devel ElectricFence
devel strace
mail procmail make BATCH=yes install
mail metamail
mail mutt-devel
emulators mtools
sysutils portupgrade
news inn-stable CONFIGURE_ARGS="--enable-uucp-rnews --enable-setgid-inews" make install
misc figlet-fonts
textproc gmat
security gpa
mail spamoracle
multimedia mplayer make WITHOUT_RUNTIME_CPUDETECTION=yes WITH_GUI=yes BATCH=yes install

View file

@ -1,27 +1,36 @@
#!/bin/sh
#
# stage_2.sh - FreeBSD From Scratch, Stage 2: Ports Installation.
# Usage: ./stage_2.sh
# Usage: ./stage_2.sh {configname}
#
# $Id: stage_2.sh,v 1.2 2004-01-03 15:46:31 schweikh Exp $
# $FreeBSD$
DBDIR=/var/db/pkg
PORTS=/usr/ports
LOGDIR=/home/root/setup/ports.log; mkdir -p ${LOGDIR}
DBDIR="/var/db/pkg"
PORTS="/usr/ports"
LOGDIR="/home/root/setup/ports.log"; mkdir -p ${LOGDIR}
# Set some variables used by more than one port.
PAPERSIZE=a4; export PAPERSIZE
USA_RESIDENT=NO; export USA_RESIDENT
# The linprocfs appears to be required for certain java/jdk* ports.
if mount | grep '^linprocfs'; then
: # linprocfs already mounted.
else
mount /compat/linux/proc
fi
MYNAME=$(basename $0)
MYNAME="$(basename $0)"
usage () {
exec >&2
echo "usage: ${MYNAME} [-hn]"
echo "usage: ${MYNAME} [-hn] configname"
echo ""
echo " Options:"
echo " -h Print this help text."
echo " -n Dryrun: just show what would be done."
echo ""
echo " The config file (stage_2.conf.configname) is a list of"
echo " ports to install with one entry per line. Each line"
echo " consists of two or three space separated fields:"
echo " category, port, and optionally a build command."
echo ""
exit 1
}
@ -33,81 +42,17 @@ set -- $args
DRYRUN=
for i; do
case "$i" in
-n) DRYRUN=yes;;
--) break;;
-n) DRYRUN="yes"; shift;;
--) shift; break;;
*) usage;;
esac
done
if test $# -eq 1; then
DATAFILE="$1"
else
usage
fi
cat << EOF |
lang perl5
security sudo
x11-servers XFree86-4-Server
x11 wrapper
x11 XFree86-4-libraries
x11 XFree86-4-clients
x11-fonts XFree86-4-font75dpi
x11-fonts XFree86-4-font100dpi
x11-fonts XFree86-4-fontScalable
x11-fonts urwfonts
x11-fonts webfonts
x11-toolkits open-motif
x11 rxvt
x11-wm ctwm
security openssh-askpass
astro xplanet
astro setiathome make BATCH=yes install
astro xephem
editors vim
print ghostscript-gnu make A4=yes BATCH=yes install
print a2ps-a4
print psutils-a4
print gv
print acroread5
print transfig
archivers zip
archivers unzip
java linux-sun-jdk13 yes | make install
java jdk13
www apache2
www weblint
www amaya
www mozilla make WITHOUT_MAILNEWS=yes WITHOUT_CHATZILLA=yes install
www netscape48-navigator
www checkbot
www privoxy
graphics xfig
graphics xv
graphics fxtv
lang expect
news tin
net freebsd-uucp
net cvsup-without-gui
net pathchar make NO_CHECKSUM=yes install
ftp wget
ftp ncftp3
textproc ispell
german ispell-neu
german ispell-alt
textproc docproj make JADETEX=yes HAVE_MOTIF=yes install
sysutils samefile
sysutils pstree
sysutils mkisofs
sysutils cdrtools
sysutils grub
devel ddd
devel ctags
devel ElectricFence
mail procmail make BATCH=yes install
mail metamail
mail mutt
mail spamoracle
emulators mtools
sysutils portupgrade
news inn-stable CONFIGURE_ARGS="--enable-uucp-rnews --enable-setgid-inews" make install
misc figlet-fonts
textproc gmat
EOF
while read CATEGORY NAME CMD; do
case "${CATEGORY}" in
\#*) continue;;
@ -126,22 +71,32 @@ while read CATEGORY NAME CMD; do
fi
LOG="${LOGDIR}/${CATEGORY}+${NAME}"
echo "===> Installing ${CATEGORY}/${NAME}; logging to ${LOG}"
test -n "${CMD}" || CMD="make install"
test -n "${CMD}" || CMD="make install < /dev/null"
if test -n "${DRYRUN}"; then
echo "${CMD}"
if ls ${PKGNAME}.* >/dev/null 2>&1; then
echo pkg_add -v ${PKGNAME}.*
else
echo "${CMD}"
fi
continue
fi
date "++++++++++ %v %T +++++++++" > ${LOG}
date "++++ Started %v %T +++" > ${LOG}
STARTED=$(date +%s)
echo "CMD: ${CMD}" >> ${LOG}
(
make clean
eval "${CMD}"
# make clean # Uncomment if diskspace is tight under ${PORTS}.
if ls ${PKGNAME}.* >/dev/null 2>&1; then
echo "Found package" ${PKGNAME}.*
pkg_add -v ${PKGNAME}.*
else
make clean
eval "${CMD}"
make clean # Uncomment if diskspace is tight under ${PORTS}.
fi
) 2>&1 | tee -a ${LOG}
done
FINISHED=$(date +%s)
DURATION=$(dc -e "${FINISHED} ${STARTED} - p")
date "++++ Finished %v %T after ${DURATION} secs +++" >> ${LOG}
done < stage_2.conf.${DATAFILE}
# Install StarOffice as a package, created on old the system with
# "make package", because the port uses an interactive X11 install.
#pkg_add ${PORTS}/editors/staroffice52/staroffice-*.tbz
# EOF $RCSfile: stage_2.sh,v $ vim: tabstop=4:
# vim: tabstop=4:
# EOF $RCSfile: stage_2.sh,v $

View file

@ -5,6 +5,7 @@
# It is a good idea to make sure any target can be made more than
# once without ill effect.
#
# $Id: stage_3.mk,v 1.2 2004-01-03 15:46:31 schweikh Exp $
# $FreeBSD$
.POSIX:
@ -12,10 +13,11 @@
message:
@echo "Please use one of the following targets:"
@echo "config_apache"
@echo "config_firebird"
@echo "config_inn"
@echo "config_javaplugin"
@echo "config_nullplugin"
@echo "config_privoxy"
@echo "config_setiathome"
@echo "config_sgml"
@echo "config_sudo"
@echo "config_TeX"
@ -23,11 +25,14 @@ message:
@echo "config_uucp"
@echo "all -- all of the above"
all: config_apache \
all: \
config_apache \
config_firebird \
config_inn \
config_javaplugin \
config_nullplugin \
config_privoxy \
config_setiathome \
config_sgml \
config_sudo \
config_TeX \
@ -39,6 +44,7 @@ config_apache:
perl -pi \
-e 's/#ServerName new.host.name/ServerName hal9000.s.shuttle.de/;' \
-e 's/^ServerAdmin.*/ServerAdmin schweikh\@schweikhardt.net/;' \
-e 's/^Listen.*/Listen 127.0.0.1:80/;' \
-e 's,/usr/local/www/cgi-bin/,/home/opt/www/cgi-bin/,;' \
/usr/local/etc/apache2/httpd.conf
# 2. Restore symlinks to web pages.
@ -46,11 +52,29 @@ config_apache:
ln -fs /home/schweikh/prj/homepage schweikhardt.net; \
ln -fs /home/opt/www/test .
config_firebird:
# Make this group wheel writable to allow extensions being installed.
chmod -R g+w /usr/X11R6/lib/firebird/lib/mozilla-1.5/chrome
config_inn:
pw usermod -n news -d /usr/local/news -s /bin/sh
mkdir -p /share/news/spool/outgoing \
/share/news/spool/incoming \
/share/news/spool/articles \
/share/news/spool/overview \
/share/news/spool/tmp \
/share/news/db
chown -R news:news /share/news
# Give the news system its initial configuration.
cd /home/root/setup; \
install -C -o news -g news -m 664 active newsgroups /usr/local/news/db
if test ! -f /share/news/db/active; then \
echo "installing /share/news/db/active"; \
install -C -o news -g news -m 664 active /share/news/db; \
fi; \
if test ! -f /share/news/db/newsgroups; then \
echo "installing /share/news/db/newsgroups"; \
install -C -o news -g news -m 664 newsgroups /share/news/db; \
fi
# The innd.sh that comes with the port is broken, it
# checks for history.pag which does not exist.
cd /home/root/setup; \
@ -71,29 +95,56 @@ config_inn:
>/usr/local/news/etc/newsfeeds
# Configure inn.conf.
perl -pi \
-e 's/^(organization:\s*).*/$$1 An Open Pod Bay Door/;' \
-e 's/^(organization:\s*).*/$$1 "An Open Pod Bay Door"/;' \
-e 's/^(pathhost:\s*).*/$$1 hal9000.schweikhardt.net/;' \
-e 's/^(server:).*/$$1 localhost/;' \
-e 's/^(domain:).*/$$1 schweikhardt.net/;' \
-e 's/^(fromhost:).*/$$1 schweikhardt.net/;' \
-e 's,^(moderatormailer:).*,$$1 \%s\@moderators.isc.org,;' \
-e 's,^(pathdb:\s*).*,$$1/share/news/db,;' \
-e 's,/usr/local/news/spool,/share/news/spool,;' \
/usr/local/news/etc/inn.conf
# Create empty history, if none there.
# See post-install in /usr/ports/news/inn-stable/Makefile.
cd /share/news/db; \
if test ! -f history; then \
touch history; \
chmod 644 history; \
chown news:news history; \
su -fm news -c "/usr/local/news/bin/makedbz -i"; \
for s in dir hash index; do \
mv history.n.$${s} history.$${s}; \
done; \
fi
# Satisfy inncheck:
cd /usr/local/news/etc; \
chown news:news *; \
chmod 640 control.ctl expire.ctl nntpsend.ctl readers.conf
/usr/local/news/bin/inncheck
config_javaplugin:
cd /usr/local/lib/netscape-linux/plugins; \
if ! test -h javaplugin.so; then \
ln -s ../../../linux-sun-jdk1.3.1/jre/plugin/i386/ns4/javaplugin.so; \
fi; \
ls -l javaplugin.so
# Mozilla Firebird:
cd /usr/X11R6/lib/firebird/lib/mozilla-1.5/plugins; \
ln -fs /usr/local/jdk1.4.2/jre/plugin/i386/ns610/libjavaplugin_oji.so
# Plain Mozilla:
cd /usr/X11R6/lib/mozilla/plugins; \
ln -fs /usr/local/jdk1.4.2/jre/plugin/i386/ns610/libjavaplugin_oji.so
# Move the nullplugin out of the way. With a .mozilla/*/*/prefs.js entry of
# user_pref("plugin.display_plugin_downloader_dialog", false);
# this suppresses popup dialogs for unavailable plugins (flash, shockwave, ...)
NULLPLUGINS = /usr/X11R6/lib/mozilla/libnullplugin.so \
/usr/X11R6/lib/mozilla/plugins/libnullplugin.so
config_nullplugin:
for p in $(NULLPLUGINS); do \
if test -r $$p; then \
mv $$p $$p.orig; \
fi; \
done
config_privoxy:
install -C -o root -g wheel -m 644 config /usr/local/etc/privoxy
config_setiathome:
perl -pi \
-e 's,^.*seti_wrkdir.*#,seti_wrkdir=/home/nobody/setiathome #,;' \
/usr/local/etc/rc.setiathome.conf
install -C -o root -g wheel -m 755 privoxy.sh /usr/local/etc/rc.d
config_sgml:
cp -p /usr/local/share/gmat/sgml/ISO_8879-1986/entities/* \
@ -117,13 +168,14 @@ config_TeX:
config_tin:
# Point tin to our files.
printf "%s\n%s\n%s\n" \
"activefile=/usr/local/news/db/active" \
"newsgroupsfile=/usr/local/news/db/newsgroups" \
"spooldir=/share/news/spool/articles" \
printf "%s\n%s\n%s\n" \
"activefile=/share/news/db/active" \
"newsgroupsfile=/share/news/db/newsgroups" \
"spooldir=/share/news/spool/articles" \
>/usr/local/etc/tin.defaults
config_uucp:
cd /etc/mail; make install SENDMAIL_MC=/etc/mail/hal9000.mc
# UUCP expects to find /usr/bin/rnews.
cd /usr/bin; ln -fs ../local/news/bin/rnews .
# Actual UUCP configuration.
@ -143,4 +195,5 @@ config_uucp:
# Trigger uucico after booting.
mkdir -p /usr/local/etc/rc.d; cp uucp.sh /usr/local/etc/rc.d
# EOF $RCSfile: stage_3.mk,v $ vim: tabstop=4:
# vim: tabstop=4:
# EOF $RCSfile: stage_3.mk,v $