diff options
author | agc <agc> | 2011-05-05 06:53:27 +0000 |
---|---|---|
committer | agc <agc> | 2011-05-05 06:53:27 +0000 |
commit | e319622a530b671868c5586a5fd99214fd3c9829 (patch) | |
tree | db00174a1cf4d5b0e094f07065c6ef506ec29ab9 /sysutils/mkmemstick | |
parent | ffe3a59b05221f061010ae5acd26fe1c036413bb (diff) | |
download | pkgsrc-e319622a530b671868c5586a5fd99214fd3c9829.tar.gz |
Initial import of Jared Mcneill's script to create a memory stick from a
NetBSD installation ISO.
Further information can be found here:
http://genericzero.wordpress.com/2009/08/01/install-netbsd-from-a-usb-memory-stick-the-easy-way/
memory stick the easy way
I got tired of having to jump through hoops to install NetBSD on my
Eee PC, so I wrote a simple script to take a NetBSD release ISO and
convert it to an image that can be written to a USB memory stick.
To use the script, simply feed it an ISO and tell it where to write
the resulting image:
$ sh mkmemstick.sh i386cd-5.0.1.iso i386memstick-5.0.1.img
The resulting image can be written to a memory stick using dd(1):
$ dd if=i386memstick-5.0.1.img of=/dev/sd0d
Please note that this script depends on the sysutils/cdrtools package
for extracting the contents of the release ISO.
Hopefully this will be integrated with the build process so these
images are available for those who cannot prepare an image due to lack
of access to a NetBSD machine.
Diffstat (limited to 'sysutils/mkmemstick')
-rw-r--r-- | sysutils/mkmemstick/DESCR | 21 | ||||
-rw-r--r-- | sysutils/mkmemstick/Makefile | 31 | ||||
-rw-r--r-- | sysutils/mkmemstick/PLIST | 2 | ||||
-rw-r--r-- | sysutils/mkmemstick/distinfo | 2 | ||||
-rw-r--r-- | sysutils/mkmemstick/files/mkmemstick.sh | 100 |
5 files changed, 156 insertions, 0 deletions
diff --git a/sysutils/mkmemstick/DESCR b/sysutils/mkmemstick/DESCR new file mode 100644 index 00000000000..128806aeedb --- /dev/null +++ b/sysutils/mkmemstick/DESCR @@ -0,0 +1,21 @@ +memory stick the easy way + +I got tired of having to jump through hoops to install NetBSD on my +Eee PC, so I wrote a simple script to take a NetBSD release ISO and +convert it to an image that can be written to a USB memory stick. + +To use the script, simply feed it an ISO and tell it where to write +the resulting image: + +$ sh mkmemstick.sh i386cd-5.0.1.iso i386memstick-5.0.1.img + +The resulting image can be written to a memory stick using dd(1): + +$ dd if=i386memstick-5.0.1.img of=/dev/sd0d + +Please note that this script depends on the sysutils/cdrtools package +for extracting the contents of the release ISO. + +Hopefully this will be integrated with the build process so these +images are available for those who cannot prepare an image due to lack +of access to a NetBSD machine. diff --git a/sysutils/mkmemstick/Makefile b/sysutils/mkmemstick/Makefile new file mode 100644 index 00000000000..aa88cca9117 --- /dev/null +++ b/sysutils/mkmemstick/Makefile @@ -0,0 +1,31 @@ +# $NetBSD: Makefile,v 1.1.1.1 2011/05/05 06:53:27 agc Exp $ +# + +DISTNAME= mkmemstick-20090801 +CATEGORIES= sysutils +MASTER_SITES= # none +DISTFILES= # none + +MAINTAINER= agc@NetBSD.org +HOMEPAGE= http://genericzero.wordpress.com/2009/08/01/install-netbsd-from-a-usb-memory-stick-the-easy-way/ +COMMENT= Create a memory stick image from NetBSD Installation CDs + +DEPENDS+= cdrtools-[0-9]*:../../sysutils/cdrtools + +PKG_INSTALLATION_TYPES= overwrite pkgviews +PKG_DESTDIR_SUPPORT= user-destdir + +WRKSRC= ${WRKDIR} +USE_LANGUAGES= # none +AUTO_MKDIRS= yes + +do-configure: + cp ${FILESDIR}/mkmemstick.sh ${WRKSRC}/mkmemstick + +do-build: + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/mkmemstick ${DESTDIR}${PREFIX}/bin/mkmemstick + + +.include "../../mk/bsd.pkg.mk" diff --git a/sysutils/mkmemstick/PLIST b/sysutils/mkmemstick/PLIST new file mode 100644 index 00000000000..6409a566242 --- /dev/null +++ b/sysutils/mkmemstick/PLIST @@ -0,0 +1,2 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2011/05/05 06:53:27 agc Exp $ +bin/mkmemstick diff --git a/sysutils/mkmemstick/distinfo b/sysutils/mkmemstick/distinfo new file mode 100644 index 00000000000..3c63788cfc5 --- /dev/null +++ b/sysutils/mkmemstick/distinfo @@ -0,0 +1,2 @@ +$NetBSD: distinfo,v 1.1.1.1 2011/05/05 06:53:27 agc Exp $ + diff --git a/sysutils/mkmemstick/files/mkmemstick.sh b/sysutils/mkmemstick/files/mkmemstick.sh new file mode 100644 index 00000000000..10ffc32aae9 --- /dev/null +++ b/sysutils/mkmemstick/files/mkmemstick.sh @@ -0,0 +1,100 @@ +#!/bin/sh +# +# mkmemstick.sh: Create memory stick image from NetBSD installation CDs +# +# Copyright (C) 2009 Jared D. McNeill <jmcneill@NetBSD.org> + +src="$1" +img="$2" +dstbase="/tmp/makeimg$(id -u)" +dst="${dstbase}/rootfs" +tmpimg="${dstbase}/netbsd.img" +disklabel=" +type: unknown +disk: Memory Stick +label: +flags: +bytes/sector: 512 +sectors/track: 63 +tracks/cylinder: 16 +sectors/cylinder: 1000 +cylinders: @TCYLINDERS@ +total sectors: @TSECTORS@ +rpm: 3600 +interleave: 1 +trackskew: 0 +cylinderskew: 0 +headswitch: 0 +track-to-track seek: 0 +drivedata: 0 + +16 partitions: + a: @SECTORS@ 0 4.2BSD 1024 8192 0 + d: @SECTORS@ 0 unused 0 0 +" + +die() { + echo "fatal: $0" + exit 2 +} + +if [ -z "$img" ]; then + echo "usage: $0 source.iso memdisk.img" + exit 1 +fi + +if [ ! -r "$src" ]; then + echo "$src not found" + exit 1 +fi + +if [ -d "$dst" ]; then + echo "$dst already exists" + exit 1 +fi +if [ -f "$img" ]; then + echo "$img already exists" + exit 1 +fi + +mkdir -p "$dst" || die "couldn't create directory $dst" + +printf " => extracting iso image" +isoinfo -R -f -i "$src" | while read x; do + dstdir="$dst/$(dirname $x)" + dstfile="$(basename $x)" + if [ -f "$dstdir" ]; then + rm "$dstdir" + fi + mkdir -p "$dstdir" + printf . + isoinfo -R -x "$x" -i "$src" > "${dstdir}/${dstfile}" +done +printf " done.\n" + +if [ -f "${dst}/boot.cfg" ]; then + echo " => patching bootloader banner" + cp "${dst}/boot.cfg" "${dstbase}/boot.cfg" || die "couldn't copy boot.cfg to ${dstbase}" + cat "${dstbase}/boot.cfg" | sed 's/installation CD/installation memory stick/' > "${dst}/boot.cfg" +fi +echo " => copying /usr/mdec/boot to $dst" +cp /usr/mdec/boot "$dst" || die "couldn't copy /usr/mdec/boot" + +echo " => building filesystem image" +makefs "$img" "$dst" || die "couldn't build filesystem image" + +echo " => installing bootxx_ffsv1" +/usr/sbin/installboot "$img" /usr/mdec/bootxx_ffsv1 || die "couldn't install bootxx_ffsv1" + +echo " => writing disklabel" +imgsize=$(stat -L -f %z "${img}") +echo "$disklabel" | \ + sed "s/@SECTORS@/$(expr $imgsize / 512)/" | \ + sed "s/@TCYLINDERS@/$(expr $imgsize / 512 / 1000 + 1)/" | \ + sed "s/@TSECTORS@/$(expr $imgsize / 512 + 1)/" >${dstbase}/disklabel +disklabel -R -F "${img}" "${dstbase}/disklabel" || die "couldn't write disklabel" + +echo " => cleaning up" +rm -rf "${dstbase}" + +echo " => done!" |