diff options
author | xtraeme <xtraeme@pkgsrc.org> | 2004-02-26 03:58:50 +0000 |
---|---|---|
committer | xtraeme <xtraeme@pkgsrc.org> | 2004-02-26 03:58:50 +0000 |
commit | f53b741a39232fb073a1468df2e19eeeec721f33 (patch) | |
tree | aa6c382c8caaedb8fd75f0ba1b8a5b46b5fe790e /sysutils | |
parent | c6f109c1c76e22e47a98da9202d3b40f07f15a00 (diff) | |
download | pkgsrc-f53b741a39232fb073a1468df2e19eeeec721f33.tar.gz |
Initial import of mklivecd-0.1.
mklivecd is a simple shell script that allows you to build a custom
NetBSD LiveCD on i386-based machines.
Thanks to Thomas Klausner for his help writing the manual page.
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/mklivecd/DESCR | 2 | ||||
-rw-r--r-- | sysutils/mklivecd/Makefile | 40 | ||||
-rw-r--r-- | sysutils/mklivecd/PLIST | 9 | ||||
-rw-r--r-- | sysutils/mklivecd/distinfo | 2 | ||||
-rw-r--r-- | sysutils/mklivecd/files/KERN-LIVECD | 202 | ||||
-rw-r--r-- | sysutils/mklivecd/files/Makefile.bootfloppy | 43 | ||||
-rw-r--r-- | sysutils/mklivecd/files/bootkern.mk | 24 | ||||
-rw-r--r-- | sysutils/mklivecd/files/mfs_rcd | 57 | ||||
-rw-r--r-- | sysutils/mklivecd/files/mklivecd.8 | 309 | ||||
-rwxr-xr-x | sysutils/mklivecd/files/mklivecd.sh | 583 | ||||
-rw-r--r-- | sysutils/mklivecd/files/personal_config | 27 |
11 files changed, 1298 insertions, 0 deletions
diff --git a/sysutils/mklivecd/DESCR b/sysutils/mklivecd/DESCR new file mode 100644 index 00000000000..443b078322c --- /dev/null +++ b/sysutils/mklivecd/DESCR @@ -0,0 +1,2 @@ +mklivecd is a simple shell script that allows you to build a custom +NetBSD LiveCD on i386-based machines. diff --git a/sysutils/mklivecd/Makefile b/sysutils/mklivecd/Makefile new file mode 100644 index 00000000000..0226a1f3306 --- /dev/null +++ b/sysutils/mklivecd/Makefile @@ -0,0 +1,40 @@ +# $NetBSD: Makefile,v 1.1.1.1 2004/02/26 03:58:51 xtraeme Exp $ + +DISTNAME= mklivecd-0.1 +CATEGORIES= sysutils +MASTER_SITES= # empty +DISTFILES= # empty + +MAINTAINER= xtraeme@NetBSD.org +COMMENT= Build a NetBSD i386 Live CD via command line + +DEPENDS+= cdrecord-[0-9]*:../../sysutils/cdrecord + +PKG_INSTALLATION_TYPES= overwrite pkgviews + +ONLY_FOR_PLATFORM= NetBSD-*-i386 + +WRKSRC= ${WRKDIR} +EXTRACT_ONLY= # empty +NO_CHECKSUM= YES +NO_CONFIGURE= YES +NO_BUILDLINK= YES +NO_BUILD= YES +USE_LANGUAGES= # empty + +INSTALLATION_DIRS= share/mklivecd sbin + +FILES= bootkern.mk Makefile.bootfloppy \ + KERN-LIVECD mfs_rcd personal_config + +do-install: + @${SED} -e "s,@PREFIX@,${PREFIX},g" ${FILESDIR}/mklivecd.sh > \ + ${WRKDIR}/mklivecd + ${INSTALL_DATA_DIR} ${PREFIX}/share/mklivecd + ${INSTALL_SCRIPT} ${WRKDIR}/mklivecd ${PREFIX}/sbin + ${INSTALL_MAN} ${FILESDIR}/mklivecd.8 ${PREFIX}/man/man8 +.for F in ${FILES} + ${INSTALL_DATA} ${FILESDIR}/${F} ${PREFIX}/share/mklivecd +.endfor + +.include "../../mk/bsd.pkg.mk" diff --git a/sysutils/mklivecd/PLIST b/sysutils/mklivecd/PLIST new file mode 100644 index 00000000000..2b6baa4e987 --- /dev/null +++ b/sysutils/mklivecd/PLIST @@ -0,0 +1,9 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2004/02/26 03:58:51 xtraeme Exp $ +man/man8/mklivecd.8 +sbin/mklivecd +share/mklivecd/KERN-LIVECD +share/mklivecd/Makefile.bootfloppy +share/mklivecd/bootkern.mk +share/mklivecd/mfs_rcd +share/mklivecd/personal_config +@dirrm share/mklivecd diff --git a/sysutils/mklivecd/distinfo b/sysutils/mklivecd/distinfo new file mode 100644 index 00000000000..56d3357a416 --- /dev/null +++ b/sysutils/mklivecd/distinfo @@ -0,0 +1,2 @@ +$NetBSD: distinfo,v 1.1.1.1 2004/02/26 03:58:51 xtraeme Exp $ + diff --git a/sysutils/mklivecd/files/KERN-LIVECD b/sysutils/mklivecd/files/KERN-LIVECD new file mode 100644 index 00000000000..c88d0ecaa19 --- /dev/null +++ b/sysutils/mklivecd/files/KERN-LIVECD @@ -0,0 +1,202 @@ +# $Id: KERN-LIVECD,v 1.1.1.1 2004/02/26 03:58:53 xtraeme Exp $ + +include "arch/i386/conf/std.i386" + +makeoptions COPTS="-Os" # Optimise for space. Implies -O2 +maxusers 8 # estimated number of users +options I686_CPU +options INSECURE # disable kernel security levels +options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT +options USERCONF # userconf(4) support +#options PIPE_SOCKETPAIR # smaller, but slower pipe(2) +#options MALLOC_NOINLINE # Not inlining MALLOC saves memory + +#options DDB # in-kernel debugger +#options DDB_HISTORY_SIZE=512 # enable history editing in DDB +#options COMPAT_16 # NetBSD 1.6 +#options COMPAT_386BSD_MBRPART # recognize old partition ID + +# File systems +file-system FFS # UFS +file-system UNION # union file system +file-system MFS # memory file system +file-system NFS # Network File System client +file-system CD9660 # ISO 9660 + Rock Ridge file system +file-system SMBFS # smbfs file system +file-system MSDOSFS # MS-DOS file system + +#options VNODE_OP_NOINLINE # Not inlining vnode op calls saves mem + +# Networking options +options INET # IP + ICMP + TCP + UDP +options INET6 # IPv6 + +options SYSVMSG # System V-like message queues +options SYSVSEM # System V-like semaphores +options SYSVSHM # System V-like memory sharing +options P1003_1B_SEMAPHORE # p1003.1b semaphore support + +# wscons options +# +# builtin terminal emulations +options WSEMUL_VT100 # VT100 / VT220 emulation +options WS_KERNEL_FG=WSCOL_MAGENTA +options WSDISPLAY_COMPAT_SYSCONS +options WSDISPLAY_COMPAT_PCVT # emulate some ioctls +options WSDISPLAY_COMPAT_USL # VT handling +options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes + +# Kernel root file system and dump configuration. +config netbsd root on cd0a type cd9660 dumps on none + +# Device configuration +mainbus0 at root + +cpu* at mainbus? +acpi0 at mainbus0 + +# ACPI devices +acpibut* at acpi? # ACPI Button +acpiec* at acpi? # ACPI Embedded Controller +acpilid* at acpi? # ACPI Lid Switch + +# Mainboard devices +com* at acpi? # Serial communications interface +lpt* at acpi? # Parallel port +npx* at acpi? # Math coprocessor +pckbc* at acpi? # PC keyboard controller + +# Basic Bus Support + +# PCI bus support +pci* at mainbus? bus ? +pci* at pchb? bus ? +pci* at ppb? bus ? + +# PCI bridges +pchb* at pci? dev ? function ? # PCI-Host bridges +pcib* at pci? dev ? function ? # PCI-ISA bridges +ppb* at pci? dev ? function ? # PCI-PCI bridges + +# ISA bus support +isa0 at mainbus? +isa0 at pcib? + +# wscons +pckbd* at pckbc? # PC keyboard +pms* at pckbc? # PS/2 mouse for wsmouse +vga* at pci? dev ? function ? +wsdisplay* at vga? console ? +wskbd* at pckbd? console ? +wsmouse* at pms? mux 0 + +# IDE and related devices +# PCI IDE controllers - see pciide(4) for supported hardware. +# The 0x0001 flag force the driver to use DMA, even if the driver doesn't know +# how to set up DMA modes for this chip. This may work, or may cause +# a machine hang with some controllers. +viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers + +# IDE drives +# Flags are used only with controllers that support DMA operations +# and mode settings (e.g. some pciide controllers) +# The lowest order four bits (rightmost digit) of the flags define the PIO +# mode to use, the next set of four bits the DMA mode and the third set the +# UltraDMA mode. For each set of four bits, the 3 lower bits define the mode +# to use, and the last bit must be 1 for this setting to be used. +# For DMA and UDMA, 0xf (1111) means 'disable'. +# 0x0fac means 'use PIO mode 4, DMA mode 2, disable UltraDMA'. +# (0xc=1100, 0xa=1010, 0xf=1111) +# 0x0000 means "use whatever the drive claims to support". +atabus* at ata? +wd* at atabus? drive ? flags 0x0000 + +# ATAPI bus support +atapibus* at atapi? + +# ATAPI devices +# flags have the same meaning as for IDE drives. +cd* at atapibus? drive ? flags 0x0000 # ATAPI CD-ROM drives + +# Network Interfaces + +# PCI network interfaces +rtk* at pci? dev ? function ? # Realtek +ex* at pci? dev ? function ? # 3Com 90x[BC] + +# MII/PHY support +ukphy* at mii? phy ? # generic unknown PHYs + + +# Audio Devices + +# PCI audio devices +auvia* at pci? dev ? function ? # VIA VT82C686A integrated AC'97 Audio + +# Audio support +audio* at audiobus? + +# USB Controller and Devices + +# PCI USB controllers +# The EHCI is not ready for prime time. +#ehci* at pci? dev ? function ? # Enhanced Host Controller +ohci* at pci? dev ? function ? # Open Host Controller +uhci* at pci? dev ? function ? # Universal Host Controller (Intel) + +# USB bus support +#usb* at ehci? +usb* at ohci? +usb* at uhci? + +# USB Hubs +uhub* at usb? +uhub* at uhub? port ? configuration ? interface ? + +# USB HID device +uhidev* at uhub? port ? configuration ? interface ? + +# USB Mice +ums* at uhidev? reportid ? +wsmouse* at ums? mux 0 + +# USB Keyboards +ukbd* at uhidev? reportid ? +wskbd* at ukbd? console ? mux 1 + +# USB Generic HID devices +uhid* at uhidev? reportid ? + +# USB Printer +ulpt* at uhub? port ? configuration ? interface ? + +# USB Modem +umodem* at uhub? port ? configuration ? +ucom* at umodem? + +# USB Mass Storage +umass* at uhub? port ? configuration ? interface ? +wd* at umass? + +# USB Generic driver +ugen* at uhub? port ? + +# Pseudo-Devices + +# disk/mass storage pseudo-devices +#pseudo-device md 1 # memory disk device (ramdisk) +pseudo-device vnd 4 # disk-like interface to files + +# network pseudo-devices +pseudo-device bpfilter 8 # Berkeley packet filter +pseudo-device loop # network loopback + +# miscellaneous pseudo-devices +pseudo-device pty 2 # pseudo-terminals (Sysinst needs two) +pseudo-device rnd # /dev/random and in-kernel generator + +# wscons pseudo-devices +pseudo-device wsmux # mouse & keyboard multiplexor + +# a pseudo device needed for SMBFS +pseudo-device nsmb # experimental - SMB requester diff --git a/sysutils/mklivecd/files/Makefile.bootfloppy b/sysutils/mklivecd/files/Makefile.bootfloppy new file mode 100644 index 00000000000..ebe7504aef2 --- /dev/null +++ b/sysutils/mklivecd/files/Makefile.bootfloppy @@ -0,0 +1,43 @@ +# $NetBSD: Makefile.bootfloppy,v 1.1.1.1 2004/02/26 03:58:58 xtraeme Exp $ +# $Id: Makefile.bootfloppy,v 1.1.1.1 2004/02/26 03:58:58 xtraeme Exp $ + +# Makefile snippet to create a set of USTAR floppies +# + +# +# Required variables: +# FLOPPYBASE Basename of floppies. Floppy number ${n} will +# be generated as ${FLOPPYBASE}${n}.fs +# FLOPPYKERNEL Kernel to copy +# +# Optional variables: +# FLOPPYKERNDIR ${FLOPPYKERNEL} is from ${.CURDIR}/../${FLOPPYKERNDIR} +# FLOPPY_BOOT Bootstrap to use. [${DESTDIR}/usr/mdec/boot] +# FLOPPYBOOTOPTIONS Options for installboot, eg -o console=com0 +# + +.include <bsd.own.mk> +.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" + +FLOPPYMAX?= 1 +FLOPPYSIZE?= 2880 +.if defined(FLOPPYSIZE) && (${FLOPPYSIZE} != 2880) +FLOPPYMETAFILE!= printf "USTAR.volsize.%o" ${FLOPPYSIZE} +.else +FLOPPYSIZE= 2880 +.endif +FLOPPYKERNDIR?= instkernel +FLOPPYSUFFIX?= .fs +MDEC= ${DESTDIR}/usr/mdec +FLOPPYINSTBOOT= "${TOOL_INSTALLBOOT} ${FLOPPYBOOTOPTIONS} -m${MACHINE} @IMAGE@ ${MDEC}/bootxx_ustarfs" +FLOPPYKERNOBJ!= cd ${FLOPPYKERNDIR} && ${PRINTOBJDIR} + +FLOPPY_BOOT?= ${MDEC}/boot +FLOPPY_NETBSD= ${FLOPPYKERNOBJ}/${FLOPPYKERNEL} +FLOPPYFILES= boot ${FLOPPYMETAFILE} netbsd + +FLOPPY_RELEASEDIR= @ISODIR@/stand + +.include "${DISTRIBDIR}/common/Makefile.tarfloppy" + +.include <bsd.prog.mk> diff --git a/sysutils/mklivecd/files/bootkern.mk b/sysutils/mklivecd/files/bootkern.mk new file mode 100644 index 00000000000..c18a9158169 --- /dev/null +++ b/sysutils/mklivecd/files/bootkern.mk @@ -0,0 +1,24 @@ +# $NetBSD: bootkern.mk,v 1.1.1.1 2004/02/26 03:58:56 xtraeme Exp $ +# $Id: bootkern.mk,v 1.1.1.1 2004/02/26 03:58:56 xtraeme Exp $ + +# This Makefile builds a boot image on a 2.88M-sized image. +# +# Since NetBSD currently can't write 2.88M diskettes, it's only +# use is as a boot image for El Torito bootable CD-ROM images. +# +# To prepare a CD, do the following steps: +# 1) create a release(7) tree called NetBSD-1.3I +# 2) create NetBSD-1.3I/boot.i386/ and place boot.fs in that directory +# 3) do ``mkisofs -A "NetBSD ${version}" -b boot.i386/boot.fs -f \ +# -o i386-cd.img -r -T NetBSD-1.3I'' +# (you may omit '-f' if you're not using symlinks in the release tree) +# This should place the image in i386-cd.img, which can hopefully +# be used to burn a CD. + +FLOPPYBASE= cdlive-boot +FLOPPYPAD= 1 +FLOPPYSIZE= 5760 +FLOPPYKERNEL= netbsd +FLOPPYKERNDIR= ${.CURDIR}/@KERNEL_NAME@ + +.include "${.CURDIR}/Makefile.bootfloppy" diff --git a/sysutils/mklivecd/files/mfs_rcd b/sysutils/mklivecd/files/mfs_rcd new file mode 100644 index 00000000000..a63318b67cc --- /dev/null +++ b/sysutils/mklivecd/files/mfs_rcd @@ -0,0 +1,57 @@ +# $Id: mfs_rcd,v 1.1.1.1 2004/02/26 03:58:56 xtraeme Exp $ +# +# Mount mfs directories and unpack the required file +# before anything. + +# PROVIDE: LiveCD +# BEFORE: disks + +. /etc/rc.subr + +name="mfsrc" +rcvar=$name + +start_cmd="mfsrc_start" +stop_cmd="mfsrc_stop" + +mfsrc_start() +{ + cat <<_EOF + +############################################################################## +############################################################################## +####### ############## +####### Welcome to the NetBSD Live CD! ############## +####### Please visit us: http://www.NetBSD.org/ ############## +####### ############## +####### Copyright (C) 2004, Juan RP <xtraeme@NetBSD.org> ############## +####### ############## +############################################################################## +############################################################################## + +_EOF + echo "=> Mounting Memory based filesystems..." + mount_mfs @MNT_DEV_ARGS@ swap /dev + mount_mfs @MNT_ETC_ARGS@ swap /etc + mount_mfs @MNT_VAR_ARGS@ swap /var + mount_mfs @MNT_ROOT_ARGS@ swap /root + mount_mfs @MNT_TMP_ARGS@ swap /tmp + @HOME@ + @HOMETAR@ + @USRPKGETC@ + @USRPKGETCTAR@ + + for f in mfs_dev mfs_etc mfs_var mfs_root + do + tar xfjp /stand/$f.tbz -C / + done + echo "=> Finished successfully." +} + +mfsrc_stop() +{ + echo "Please don't do that :-)" +} + +load_rc_config $name +run_rc_command "$1" diff --git a/sysutils/mklivecd/files/mklivecd.8 b/sysutils/mklivecd/files/mklivecd.8 new file mode 100644 index 00000000000..a2c1e313d73 --- /dev/null +++ b/sysutils/mklivecd/files/mklivecd.8 @@ -0,0 +1,309 @@ +.\" $NetBSD: mklivecd.8,v 1.1.1.1 2004/02/26 03:58:54 xtraeme Exp $ +.\" +.\" mklivecd - Build a NetBSD Live CD for i386 machines +.\" Copyright (c) 2004 Juan RP <xtraeme@NetBSD.org> +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" 3. Neither the name of author nor the names of its contributors may +.\" be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd February 25, 2004 +.Dt MKLIVECD 8 +.Os +.Sh NAME +.Nm mklivecd +.Nd build a +.Nx +Live CD for i386 machines +.Sh SYNOPSIS +.Nm +.Ar target +.Sh DESCRIPTION +.Nm +allows you to build your own +.Nx +Live CD, so you don't need to install +.Nx +to any disk, because it will run directly from the CD-ROM. +.Sh CONFIGURATION +.Nm +reads the parameters of the main configuration file +stored inside +.Pa $HOME/.mklivecd/mklivecd.conf , +so be sure you have modified it with your +preferences before starting any target. +.Pp +Configuration files are simple shell scripts that define +variables. +The default values shown here are those written in the template when +issuing the +.Ar config +target. +.Bl -tag -width 15n -offset indent +.It SOURCEDIR +The +.Nx +source directory. +Defaults to +.Pa /usr/src . +.It PKGSRCDIR +The +.Nx +packages collection directory. +When the +.Ar chroot +target is invoked, the pkgsrc directory will be mounted via +.Xr mount_null 8 , +and you could install any package. +Defaults to +.Pa /usr/pkgsrc . +.It SHAREDIR +The main directory used to store the Makefiles, kernel, example configuration +files, etc. +Defaults to +.Pa $PREFIX/share/mklivecd/ . +.It BASEDIR +Primary directory used to store the main directories and the final ISO image. +Defaults to +.Pa $HOME/livecd . +.It WORKDIR +Directory used to store the object files and kernel built by the target +.Ql kernel . +Defaults to +.Pa $BASEDIR/work . +.It ISODIR +Directory used to store the main +.Nx +base distribution. +Defaults to +.Pa $BASEDIR/iso . +.It BASE_SETS_DIR +The base sets directory. +Defaults to +.Pa $HOME/release/binary/sets . +.It X11_SETS_DIR +The X11 sets directory. +Defaults to +.Pa $BASE_SETS_DIR . +.It BASE_SETS +Base sets which will be unpacked into +.Pa $ISODIR . +Sets used by default are: +.Pa etc.tgz base.tgz comp.tgz text.tgz . +.It X11_SETS +X11 sets which will be unpacked into +.Pa $ISODIR . +Sets used by default are: +.Pa xbase.tgz xcomp.tgz xfont.tgz xserver.tgz . +.It ENABLE_X11 +If set to +.Sy yes +then X11 sets and configuration files will be unpacked automatically. +Defaults to +.Sy no . +.It BLANK_BEFORE_BURN +Used in the +.Ar burn +target to blank a CD-RW before burning the +.Nx +Live CD ISO image. +Useful if you use CD-RW. +Defaults to +.Sy no . +.It CDROM_DEVICE +Used in the target +.Ar burn +to specify the CD-ROM device. +Defaults to +.Sy 15,1,0 . +.It PERSONAL_CONFIG +If set to +.Sy yes , +then +.Pa personal_config +file will be used. +See below for details. +Defaults to +.Sy no . +.It BOOTKERN +Name of the +.Nx +kernel used for the boot image. +Defaults to +.Sy KERN-LIVECD . +.It KERNEL_NAME +Name of the built +.Nx +kernel. +Useful if you want to change the default behaviour of the build process. +Defaults to +.Sy MKLIVECD . +.It IMAGE_NAME +Name of the final ISO image, e.g.: +.Pa My_NetBSD_Live_CD_ISO_Image.iso . +Defaults to +.Sy NetBSD-LiveCD . +.It PKG_SYSCONFDIR +Directory where the pkgsrc settings are stored, by default +.Nm +preserves this behaviour and uses +.Pa usr/pkg/etc . +.It REMOVE_DIRS +Take care with this option, because it will remove all directories when +the target +.Ar iso +is invoked. +It could be useful if you don't want to include some directories +on the CD, or your free space is small. +Defaults to +.Pa altroot rescue usr/share/info . +.It MNT_{MOUNT_POINT}_ARGS +This specifies the arguments passed to the +.Xr mount 8 +command used in the +.Pa mfs_rcd +script, when the +.Nx +Live CD is booted. +You shouldn't add +.Sy swap +at the end, because it will be added automatically by +the script. +.El +.Sh TARGETS +A target specifies what +.Nm +should do (as in make). +The following list describes all supported targets, +in the logical order in which you should call them. +.Bl -tag -width 15n -offset indent +.It Ar config +Create a sample +.Pa mklivecd.conf +file. +You should edit it after the creation as you will probably want to +change the default configuration, especially paths. +.It Ar kernel +Builds the specified kernel +.Pa $BOOTKERN +into the +.Pa $ISODIR +directory. +.It Ar base +Install the +.Pa $BASE_SETS +and +.Pa $X11_SETS +into the +.Pa $ISODIR +directory and prepare the base system for the next target, +which is the most important: +.Ar chroot . +.It Ar chroot +Enters the chroot environment. +Uses +.Xr ksh 1 +as default shell. +.It Ar iso +Builds the ISO image +.Pa $IMAGE_NAME +into +.Pa $BASEDIR +and removes all directories specified in +.Pa $REMOVE_DIRS +before it, to save some space. +.It Ar burn +Burns the ISO image +.Pa $IMAGE_NAME +on the CD-ROM with +.Xr cdrecord 1 . +Use the +.Pa $CDROM_DEVICE +variable to specify the default device. +.It Ar clean +Cleans the +.Pa $WORKDIR +directory and the base +.Nx +tree in +.Pa $ISODIR , +except the CD-ROM boot image +.Pa /stand/cdlive-boot.fs +and the +.Nx +kernel +.Pa /netbsd . +.El +.Ss What should I do in the chroot jail? +While working in the chroot environment, you can +add users, install binary packages, modify +.Pa /etc/ttys , +etc. +You can enter the chroot as often as you want, +.Nm +will create the tarballs automatically when you leave +the chroot. +.Ss How can I use the PERSONAL_CONFIG option? +When +.Ar PERSONAL_CONFIG +is set to +.Sy yes , +.Pa $HOME/.mklivecd/personal_config +will be used. +For example, you can copy some configuration directories +from +.Ar $HOME +to the +.Ar $ISODIR/$HOME +directory. +Please take a look at the example file located in +.Ar ${PREFIX}/share/mklivecd . +.Sh NOTES +.Pa PKG_SYSCONFDIR +defaults to +.Ar usr/pkg/etc +without a starting slash. +This shouldn't be added because +.Nm +adds this automatically in the script, otherwise your real PKG_SYSCONFDIR +directory will be copied instead of the one located in +.Pa $ISODIR . +.Pp +An example kernel config file, +.Pa KERN-LIVECD , +has been installed into +.Ar ${PREFIX}/share/mklivecd , +based on the -current branch. +You should copy your own kernel config file into +.Ar $HOME/.mklivecd . +The +.Sy BOOTKERN +variable should point at it. +.Sh SEE ALSO +.Xr packages 7 , +.Xr mount_null 8 +.Sh AUTHORS +The +.Nm +utility was written by +.An Juan RP Aq xtraeme@NetBSD.org . diff --git a/sysutils/mklivecd/files/mklivecd.sh b/sysutils/mklivecd/files/mklivecd.sh new file mode 100755 index 00000000000..4ae406b4ef2 --- /dev/null +++ b/sysutils/mklivecd/files/mklivecd.sh @@ -0,0 +1,583 @@ +#!/bin/sh +# +# $NetBSD: mklivecd.sh,v 1.1.1.1 2004/02/26 03:58:56 xtraeme Exp $ +# +# Copyright (c) 2004 Juan RP <xtraeme@NetBSD.org> +# All rights Reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of author nor the names of its contributors may +# be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# ====================================================================== # +# mklivecd - Build a NetBSD LiveCD! for i386 machines. # +# ====================================================================== # + +progname=$(basename $0) +config_dir="$HOME/.mklivecd/" +config_file="$config_dir/mklivecd.conf" +pers_conffile="personal_config" +tmp_file="/tmp/${progname}.$$" + +MKISOFS="@PREFIX@/bin/mkisofs" +CDRECORD="@PREFIX@/bin/cdrecord" + +# ====================================================================== # +# My functions :-) # +# ====================================================================== # + +usage() +{ + cat <<_usage_ + + ${progname}: [target] + + Target operations: + + kernel Build and install the Boot kernel image + iso Build the ISO 9660 image + burn Burn the ISO image via cdrecord + base Install the base/x11 sets into ISODIR + chroot chroot into the livecd + clean Clean the work directory + config Create the default configuration file + +_usage_ + + exit 1 +} + +showmsg() +{ + echo "===> $@" +} + +bye() +{ + _exitarg="$1" + rm -f $tmp_file; exit $_exitarg +} + +do_conf() +{ + BASE_VARS="SOURCEDIR PKGSRCDIR SHAREDIR BASEDIR WORKDIR ISODIR \ + BASE_SETS_DIR X11_SETS_DIR BASE_SETS X11_SETS" + + MISC_VARS="ENABLE_X11 BLANK_BEFORE_BURN CDROM_DEVICE PERSONAL_CONFIG \ + BOOTKERN KERNEL_NAME IMAGE_NAME PKG_SYSCONFDIR REMOVE_DIRS" + + MNT_VARS="MNT_DEV_ARGS MNT_ETC_ARGS MNT_VAR_ARGS \ + MNT_ROOT_ARGS MNT_TMP_ARGS MNT_HOME_ARGS \ + MNT_PKG_SYSCONFDIR_ARGS" + + # Base directories/sets + : ${SOURCEDIR:=/usr/src} + : ${PKGSRCDIR:=/usr/pkgsrc} + : ${SHAREDIR:=@PREFIX@/share/mklivecd} + : ${BASEDIR:=$HOME/livecd} + : ${WORKDIR:=${BASEDIR}/work} + : ${ISODIR:=${BASEDIR}/iso} + : ${BASE_SETS_DIR:=$HOME/release/binary/sets} + : ${X11_SETS_DIR:=${BASE_SETS_DIR}} + : ${BASE_SETS:=etc.tgz base.tgz comp.tgz text.tgz} + : ${X11_SETS:=xbase.tgz xcomp.tgz xfont.tgz xserver.tgz} + + # Miscellaneous options + : ${ENABLE_X11:=no} + : ${BLANK_BEFORE_BURN:=no} + : ${CDROM_DEVICE:=15,1,0} + : ${PERSONAL_CONFIG:=no} + : ${BOOTKERN:=KERN-LIVECD} + : ${KERNEL_NAME:=MKLIVECD} + : ${IMAGE_NAME:=NetBSD-LiveCD} + : ${PKG_SYSCONFDIR:=usr/pkg/etc} + : ${REMOVE_DIRS:=altroot usr/share/info} + + # Mount arguments + : ${MNT_DEV_ARGS:=-o noatime -s 5m} + : ${MNT_ETC_ARGS:=-o noatime -s 2m} + : ${MNT_VAR_ARGS:=-o noatime -s 10m} + : ${MNT_ROOT_ARGS:=-o noatime -s 5m} + : ${MNT_TMP_ARGS:=-o noatime -s 10m} + : ${MNT_HOME_ARGS:=-o noatime -s 50m} + : ${MNT_PKG_SYSCONFDIR_ARGS:=-o noatime -s 1m} + + if [ ! -d $config_dir ]; then + mkdir $config_dir + fi + + if [ ! -f $config_dir/$pers_conffile ]; then + cp $SHAREDIR/$pers_conffile $config_dir + fi + + if [ ! -f $config_file ]; then + cat >> $config_file <<EOF +# --*-sh-*-- +# +# mklivecd - configuration file +# See mklivecd(8) for a detailed description of each variable. +# +# Generated automatically on $(date). + +EOF + echo "# Base directories/options" >> $config_file + for var in `echo $BASE_VARS | tr ' ' '\n'` + do + eval val=\""\$$var"\" + echo "$var=\"$val\"" >> $config_file + done + echo >> $config_file + + echo "# Miscellaneous options" >> $config_file + for var in `echo $MISC_VARS | tr ' ' '\n'` + do + eval val=\""\$$var"\" + echo "$var=\"$val\"" >> $config_file + done + echo >> $config_file + + echo "# Mount arguments" >> $config_file + for var in `echo $MNT_VARS | tr ' ' '\n'` + do + eval val=\""\$$var"\" + echo "$var=\"$val\"" >> $config_file + done + echo >> $config_file + + echo "=> Configuration file created, now please edit it." + else + . $config_file + + if [ ! -d $SOURCEDIR/sys ]; then + showmsg "Cannot find $SOURCEDIR, please download" + showmsg "the src module." + bye 1 + fi + fi +} + +do_conf_reset() +{ + for F in ${BASE_VARS} ${MISC_VARS} ${MNT_VARS} + do + eval $F=\"\" + done +} + +do_cdlive() +{ + . $config_file + + vars="$BASEDIR $ISODIR $WORKDIR" + + for value in $vars + do + if [ ! -d $value ]; then + mkdir -p $value + fi + done + + case "$1" in + kernel) + showmsg "Building boot image on $(date)" + echo + showmsg "Using the following values:" + showmsg " SHAREDIR=$SHAREDIR" + showmsg " WORKDIR=$WORKDIR" + showmsg " ISODIR=$ISODIR" + showmsg " BASEDIR=$BASEDIR" + showmsg "Using kernel: $BOOTKERN" + showmsg "Kernel name: $KERNEL_NAME" + echo + sleep 2 + sed -e "s,@KERNEL_NAME@,${KERNEL_NAME}," \ + $SHAREDIR/bootkern.mk > $WORKDIR/Makefile + sed -e "s,@ISODIR@,${ISODIR},g" $SHAREDIR/Makefile.bootfloppy \ + > $WORKDIR/Makefile.bootfloppy + + # if there's a kernel in ~/.mklivecd, use it, otherwise + # use the default one located in SHAREDIR. + if [ -s $config_dir/$BOOTKERN ]; then + cp $config_dir/$BOOTKERN $WORKDIR + else + cp $SHAREDIR/$BOOTKERN $WORKDIR + fi + + cd $WORKDIR + [ ! -d $WORKDIR/$KERNEL_NAME ] && mkdir $WORKDIR/$KERNEL_NAME + config -s $SOURCEDIR/sys -b $WORKDIR/$KERNEL_NAME \ + $BOOTKERN + cd $KERNEL_NAME + make depend + make COPTS="-Os" # Don't use additional flags + cd $WORKDIR + make USETOOLS=no COPTS= # Don't use tools/copts + if [ $? -eq 0 ]; then + [ ! -d $ISODIR/stand ] && mkdir -p $ISODIR/stand + cp cdlive-boot1.fs $ISODIR/stand/cdlive-boot.fs + cp netbsd $ISODIR + make clean + rm -rf $KERNEL_NAME + echo + showmsg "Build successful" + showmsg "Boot/kernel image installed!" + showmsg "Next step: ${progname} base" + echo + else + echo + showmsg "Build failed" + showmsg "Boot/kernel image not installed!" + echo + fi + ;; + base) + chown root:wheel $ISODIR/netbsd $ISODIR/stand/* + + for F in ${BASE_SETS} + do + if [ ! -f $BASE_SETS_DIR/$F ]; then + showmsg "Target base failed!" + showmsg "Can't find $F, exiting." + bye 1 + fi + done + + showmsg "Installing base sets" + for S in ${BASE_SETS} + do + if [ -f $BASE_SETS_DIR/$S ]; then + echo "=> Unpacking $S" + tar xfzp $BASE_SETS_DIR/$S -C $ISODIR + fi + done + + if [ "${ENABLE_X11}" = "yes" ]; then + for FX in ${X11_SETS} + do + if [ ! -f $X11_SETS_DIR/$FX ]; then + showmsg "Can't find $FX, disabling X11." + DISABLE_X11=yes + break + fi + done + + if [ "$DISABLE_X11" = "" ]; then + showmsg "Installing X11 sets" + for X in ${X11_SETS} + do + if [ -f $X11_SETS_DIR/$X ]; then + echo "=> Unpacking $X" + tar xfzp $X11_SETS_DIR/$X -C $ISODIR + fi + done + fi + fi # ENABLE_X11 + + cp $SHAREDIR/mfs_rcd $ISODIR/etc/rc.d + + # /etc/rc.conf + showmsg "Installing configuration files" + sed -e "s,rc_configured=NO,rc_configured=YES,g" \ + $ISODIR/etc/rc.conf > $ISODIR/etc/rc.conf.fixed + mv $ISODIR/etc/rc.conf.fixed $ISODIR/etc/rc.conf + touch $ISODIR/etc/fstab + + ( \ + echo "mfsrc=yes"; \ + echo "dhclient=yes dhclient_flags=-q"; \ + echo "wscons=yes"; \ + echo "hostname=$KERNEL_NAME"; \ + echo "nfs_client=yes"; \ + echo "inetd=no"; \ + echo "ntpdate=yes"; \ + echo "savecore=no"; \ + ) >> $ISODIR/etc/rc.conf + + # /etc/rc.d/root could umount the mfs directories, + # so it's best not to touch them. + + rm $ISODIR/etc/rc.d/root + cat > $ISODIR/etc/rc.d/root <<_EOF_ +#!/bin/sh +# +# \$NetBSD: mklivecd.sh,v 1.1.1.1 2004/02/26 03:58:56 xtraeme Exp $ +# + +# PROVIDE: root +# REQUIRE: fsck + +. /etc/rc.subr + +name="root" +start_cmd="root_start" +stop_cmd=":" + +root_start() +{ + rm -f /fastboot +} + +load_rc_config \$name +run_rc_command "\$1" +_EOF_ + # Make sure the devices are created before creating + # the .tbz files. + + showmsg "Creating devices" + cd $ISODIR/dev && ./MAKEDEV all + echo + showmsg "Target base successful" + showmsg "Base system installed" + showmsg "Next step: ${progname} chroot" + ;; + chroot) + if [ ! -f $ISODIR/.prompt_done ]; then + ( \ + echo "export PS1=\"$KERNEL_NAME> \""; \ + echo "set -o emacs"; \ + ) > $ISODIR/etc/profile + touch $ISODIR/.prompt_done + else + showmsg "Prompt already set!" + fi + + if [ ! -d $ISODIR/usr/pkgsrc ]; then + mkdir $ISODIR/usr/pkgsrc + fi + + if [ ! -f $ISODIR/usr/share/misc/termcap ]; then + cp /usr/share/misc/termcap* \ + $ISODIR/usr/share/misc + fi + + showmsg "Entering into the chroot!" + + if [ -d $PKGSRCDIR ]; then + showmsg "Mounting pkgsrc directory." + mount_null $PKGSRCDIR $ISODIR/usr/pkgsrc + else + showmsg "Can't find $PKGSRCDIR, disabling it" + fi + + echo + chroot $ISODIR /bin/ksh + echo + showmsg "Unmounting pkgsrc." + + if [ ! -d $ISODIR/root ]; then + showmsg "Target chroot failed!" + showmsg "Can't find root directory, exiting." + bye 1 + fi + + cd $ISODIR + cp -f $SHAREDIR/mfs_rcd $ISODIR/etc/rc.d + + SUBST_H="mount_mfs $MNT_HOME_ARGS swap /home" + SUBST_HT="tar xfjp /stand/mfs_home.tbz -C /" + SUBST_S="mount_mfs $MNT_PKG_SYSCONFDIR_ARGS swap /$PKG_SYSCONFDIR" + SUBST_ST="tar xfjp /stand/mfs_pkg_sysconfdir.tbz -C /" + + sed -e "s,@MNT_DEV_ARGS@,$MNT_DEV_ARGS,g" \ + -e "s,@MNT_ETC_ARGS@,$MNT_ETC_ARGS,g" \ + -e "s,@MNT_VAR_ARGS@,$MNT_VAR_ARGS,g" \ + -e "s,@MNT_ROOT_ARGS@,$MNT_ROOT_ARGS,g" \ + -e "s,@MNT_TMP_ARGS@,$MNT_TMP_ARGS,g" \ + $ISODIR/etc/rc.d/mfs_rcd > $ISODIR/etc/rc.d/mfs_rcd.in + mv $ISODIR/etc/rc.d/mfs_rcd.in $ISODIR/etc/rc.d/mfs_rcd + + for U in root var dev etc home + do + if [ -d $ISODIR/$U ]; then + tar cfjp $ISODIR/stand/mfs_$U.tbz $U >/dev/null 2>&1 + showmsg "Creating /stand/mfs_$U.tbz" + fi + done + + if [ -d $ISODIR/home ]; then + sed -e "s,@HOME@,$SUBST_H," \ + -e "s,@HOMETAR@,$SUBST_HT," \ + $ISODIR/etc/rc.d/mfs_rcd > $ISODIR/etc/rc.d/mfs_rcd.f + mv $ISODIR/etc/rc.d/mfs_rcd.f $ISODIR/etc/rc.d/mfs_rcd + else + sed -e "s,@HOME@,," -e "s,@HOMETAR@,," \ + $ISODIR/etc/rc.d/mfs_rcd > $ISODIR/etc/rc.d/mfs_rcd.f + mv $ISODIR/etc/rc.d/mfs_rcd.f $ISODIR/etc/rc.d/mfs_rcd + fi + + if [ -d $ISODIR/$PKG_SYSCONFDIR ]; then + tar cfjp $ISODIR/stand/mfs_pkg_sysconfdir.tbz \ + $PKG_SYSCONFDIR >/dev/null 2>&1 + showmsg "Creating /stand/mfs_pkg_sysconfdir.tbz" + sed -e "s,@USRPKGETC@,$SUBST_S," \ + -e "s,@USRPKGETCTAR@,$SUBST_ST," \ + $ISODIR/etc/rc.d/mfs_rcd > $ISODIR/etc/rc.d/mfs_rcd.f + mv $ISODIR/etc/rc.d/mfs_rcd.f $ISODIR/etc/rc.d/mfs_rcd + else + sed -e "s,@USRPKGETC@,," -e "s,@USRPKGETCTAR@,," \ + $ISODIR/etc/rc.d/mfs_rcd > $ISODIR/etc/rc.d/mfs_rcd.f + mv $ISODIR/etc/rc.d/mfs_rcd.f $ISODIR/etc/rc.d/mfs_rcd + fi + + if [ "${ENABLE_X11}" = "yes" ]; then + if [ -f /etc/X11/XF86Config ]; then + cp /etc/X11/XF86Config $ISODIR/etc/X11 + fi + fi + + if [ "${PERSONAL_CONFIG}" = "yes" -a -f $config_dir/$pers_conffile ]; then + echo + showmsg "Running personal config file" + . $config_dir/$pers_conffile + showmsg "Done!" + echo + elif [ "${PERSONAL_CONFIG}" = "yes" -a ! -f $config_dir/$pers_conffile ]; then + echo + showmsg "Can't find personal configuration file, please" + showmsg "disable it if you don't want to use it, or otherwise" + showmsg "use the example file to see how to create your" + showmsg "own custom file." + echo + else + continue + fi + + # Make sure mfs_rcd has the right permissions, because + # it could be critical!. + + chmod -R a+rx $ISODIR/etc/rc.d + + umount $ISODIR/usr/pkgsrc + rm $ISODIR/.prompt_done + showmsg "Size: $(du -sh $ISODIR)" + ;; + clean) + showmsg "Cleaning WORKDIR: $WORKDIR" + rm -rf $WORKDIR + for F in bin dev etc lib libexec mnt rescue \ + root tmp usr var sbin home + do + if [ -d $ISODIR/$F ]; then + rm -rf $ISODIR/$F + fi + done + showmsg "Done" + ;; + iso) + if [ ! -f $ISODIR/netbsd ]; then + showmsg "Target iso failed!" + showmsg "Can't find NetBSD kernel" + bye 1 + elif [ ! -f $ISODIR/stand/mfs_etc.tbz ]; then + showmsg "Target iso failed!" + showmsg "Can't find mfs_etc.tbz file" + bye 1 + fi + + echo + showmsg "Removing not needed directories:" + for RM in ${REMOVE_DIRS} + do + if [ -d $ISODIR/$RM ]; then + echo "=> Removing $RM..."; rm -rf $ISODIR/$RM + else + echo "=> Nonexistent directory: $RM" + fi + done + + sleep 2 # Because I want to see the messages :-) + + if [ ! -f $BASEDIR/$IMAGE_NAME.iso ]; then + echo + showmsg "Creating ISO CD9660 image" + $MKISOFS -nobak -b stand/cdlive-boot.fs \ + -o $BASEDIR/$IMAGE_NAME.iso -J -R $ISODIR + fi + + ;; + burn) + if [ ! -f $BASEDIR/$IMAGE_NAME.iso ]; then + showmsg "Can't find iso image!" + bye 1 + fi + + if [ $BLANK_BEFORE_BURN = "yes" ]; then + $CDRECORD dev=$CDROM_DEVICE -v blank=fast + fi + + $CDRECORD dev=$CDROM_DEVICE -v $BASEDIR/$IMAGE_NAME.iso + ;; + esac + +} + +checkconf() +{ + if [ -f $config_file ]; then + [ `id -u` -ne 0 ] && showmsg "must be run as root" && bye 1 + do_conf_reset; . $config_file; do_conf + else + showmsg "$config_file does not exist" + bye 1 + fi +} + +# =========================================================================== # +# Main program # +# =========================================================================== # + +if [ $# -lt 1 ]; then + usage +fi + +case "$1" in + iso) + checkconf + do_cdlive iso + ;; + kernel) + do_cdlive kernel + ;; + base) + checkconf + do_cdlive base + ;; + chroot) + checkconf + do_cdlive chroot + ;; + clean) + checkconf + do_cdlive clean + ;; + config) + do_conf + ;; + burn) + checkconf + do_cdlive burn + ;; +esac + +exit 0 # agur! diff --git a/sysutils/mklivecd/files/personal_config b/sysutils/mklivecd/files/personal_config new file mode 100644 index 00000000000..424a70a8bbf --- /dev/null +++ b/sysutils/mklivecd/files/personal_config @@ -0,0 +1,27 @@ +# +# $Id: personal_config,v 1.1.1.1 2004/02/26 03:58:51 xtraeme Exp $ +# +# Personal configuration example file for mklivecd. +# + +for f in zshrc xinitrc +do + if [ ! -f $ISODIR/$HOME/.$f ]; then + cp $HOME/.$f $ISODIR/$HOME + echo "=> Copying .$f" + else + echo "=> Skipping .$f, already exists" + fi +done + +for d in pekwm sylpheed gkrellm2 xmms xchat2 +do + if [ ! -d $ISODIR/$HOME/.$d ]; then + cp -r $HOME/.$d $ISODIR/$HOME + echo "=> Copying .$d" + else + echo "=> Skipping .$d, already exists" + fi +done + +chown -R juan:users $ISODIR/$HOME |