pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/mkmemstick Initial import of Jared Mcneill's ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8a191b40e015
branches:  trunk
changeset: 588279:8a191b40e015
user:      agc <agc%pkgsrc.org@localhost>
date:      Thu May 05 06:53:27 2011 +0000

description:
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:

 sysutils/mkmemstick/DESCR               |   21 ++++++
 sysutils/mkmemstick/Makefile            |   31 +++++++++
 sysutils/mkmemstick/PLIST               |    2 +
 sysutils/mkmemstick/distinfo            |    2 +
 sysutils/mkmemstick/files/mkmemstick.sh |  100 ++++++++++++++++++++++++++++++++
 5 files changed, 156 insertions(+), 0 deletions(-)

diffs (176 lines):

diff -r 4620994c6095 -r 8a191b40e015 sysutils/mkmemstick/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/mkmemstick/DESCR Thu May 05 06:53:27 2011 +0000
@@ -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 -r 4620994c6095 -r 8a191b40e015 sysutils/mkmemstick/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/mkmemstick/Makefile      Thu May 05 06:53:27 2011 +0000
@@ -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@localhost
+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 -r 4620994c6095 -r 8a191b40e015 sysutils/mkmemstick/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/mkmemstick/PLIST Thu May 05 06:53:27 2011 +0000
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2011/05/05 06:53:27 agc Exp $
+bin/mkmemstick
diff -r 4620994c6095 -r 8a191b40e015 sysutils/mkmemstick/distinfo
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/mkmemstick/distinfo      Thu May 05 06:53:27 2011 +0000
@@ -0,0 +1,2 @@
+$NetBSD: distinfo,v 1.1.1.1 2011/05/05 06:53:27 agc Exp $
+
diff -r 4620994c6095 -r 8a191b40e015 sysutils/mkmemstick/files/mkmemstick.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/mkmemstick/files/mkmemstick.sh   Thu May 05 06:53:27 2011 +0000
@@ -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@localhost>
+
+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!"



Home | Main Index | Thread Index | Old Index