From cfd0cbc35a2f042d8de283e3c78c4baa7bc49454 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 6 Nov 2006 23:46:38 +0100 Subject: [PATCH 1/1] initial checkin --- debian/changelog | 52 +++++++++++++ debian/compat | 1 + debian/control | 13 ++++ debian/copyright | 27 +++++++ debian/dirs | 2 + debian/docs | 0 debian/rules | 69 +++++++++++++++++ grml2usb | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ grml2usb.8 | 59 +++++++++++++++ 9 files changed, 447 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100755 debian/rules create mode 100755 grml2usb create mode 100644 grml2usb.8 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..c0501ff --- /dev/null +++ b/debian/changelog @@ -0,0 +1,52 @@ +grml2usb (0.6-1) unstable; urgency=low + + * Allow overwriting of $TMPMNT. + + -- Michael Prokop Wed, 4 Oct 2006 22:50:58 +0200 + +grml2usb (0.5-1) unstable; urgency=low + + * bailout if mounting of target device failes. + + -- Michael Prokop Mon, 11 Sep 2006 23:47:01 +0200 + +grml2usb (0.4-1) unstable; urgency=low + + * Check for existence of syslinux before running the script. + * Updated copyright file (new fsfs address). + + -- Michael Prokop Sat, 3 Jun 2006 21:02:53 +0200 + +grml2usb (0.3-1) unstable; urgency=low + + * Added uninstall option. + * Improved error handling and its output. + * Added colors to improve manual text parsing. + + -- Michael Prokop Fri, 10 Mar 2006 20:19:28 +0100 + +grml2usb (0.2-1) unstable; urgency=low + + * Improved usage information. + + -- Michael Prokop Tue, 10 Jan 2006 09:35:20 +0100 + +grml2usb (0.1-3) unstable; urgency=low + + * Changed 'cp -a' to 'cp -dR --preserve=mode,timestamps' so we don't + get the ownership-permission-warnings. + + -- Michael Prokop Fri, 2 Sep 2005 18:02:22 +0200 + +grml2usb (0.1-2) unstable; urgency=low + + * Fixed small typo (SYSDEV/TMPDEV) [thanks for hint, tklauser!]. + + -- Michael Prokop Wed, 17 Aug 2005 21:50:32 +0200 + +grml2usb (0.1-1) unstable; urgency=low + + * Initial release. + + -- Michael Prokop Sun, 14 Aug 2005 15:31:04 +0200 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..c74d66e --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: grml2usb +Section: grml +Priority: optional +Maintainer: Michael Prokop +Build-Depends: debhelper (>= 4.0.0) +Standards-Version: 3.6.2 + +Package: grml2usb +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, syslinux, mtools +Description: install grml-system to usb device + This script installs a grml-system (more precive: a grml-iso) to + an usb device. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..50cb906 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Michael Prokop on +Sun, 14 Aug 2005 15:31:04 +0200. + +It was downloaded from http://grml.org/ + +Upstream Author: Michael Prokop + +Copyright: + + This software is copyright (c) 2004-2005 by Michael Prokop. + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, + USA. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..ca882bb --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..e69de29 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..01b49f8 --- /dev/null +++ b/debian/rules @@ -0,0 +1,69 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/grml2usb. + install -m 755 grml2usb debian/grml2usb/usr/sbin/ + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installman grml2usb.8 + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/grml2usb b/grml2usb new file mode 100755 index 0000000..1a69cb4 --- /dev/null +++ b/grml2usb @@ -0,0 +1,224 @@ +#!/bin/sh +# Filename: grml2usb +# Purpose: install grml-system to usb-device +# Authors: grml-team (grml.org), (c) Michael Prokop +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2. +# Latest change: Mit Okt 04 22:52:03 CEST 2006 [mika] +################################################################################ + +# colors {{{ + CRE=" " + NORMAL="" + RED="" + GREEN="" + YELLOW="" + BLUE="" + MAGENTA="" + CYAN="" + WHITE="" +# }}} + +# usercheck {{{ + if ! [ -x "$(which syslinux)" ] ; then + echo 1>&2 "${RED}Error: syslinux is not available. Please install it before running this script.${NORMAL}" ; exit 2 + fi + + if [ "$UID" != 0 ]; then + echo 1>&2 "${RED}Error: please run this script with uid 0 (root).${NORMAL}" ; exit 1 + fi +# }}} + +# set variables {{{ + if [[ $DEBUG -gt 0 ]]; then +# set -x + debugit(){ + echo $* + } + else + debugit(){ + echo $* >/dev/null + } + fi + + if [ "$1" == "uninstall" ] ; then + UNINSTALL=1 + fi + + LANG='C' + LANGUAGE='C' + LC_ALL='C' + PROGRAMNAME=${0##*/} + VERSION='0.6' + ISO="$1" + DEVICE="$2" + [ -n "$TMPMNT" ] || TMPMNT='/mnt/test' + [ -d "$TMPMNT" ] || mkdir -p $TMPMNT +# }}} + +# helper functions {{{ +bailout(){ + echo + echo "Exiting - umounting /mnt/test and $DEVICE" + umount /mnt/test 2>/dev/null + umount $DEVICE 2>/dev/null + exit 1 +} + +usage() +{ + echo 1>&2 "${BLUE}$PROGRAMNAME $VERSION${NORMAL} - install grml-system to usb-device + +This program installs a grml-iso to an usb-device to be able to boot +from usb. Make sure you have a grml-iso, syslinux (just run +'apt-get install syslinux' on debian-systems) and root access. + +Usage: + $PROGRAMNAME grml.iso /mount/point + + Notice: /mount/point is the mountpoint set up for your USB device in /etc/fstab + /mount/point should not be mounted at the time running $PROGRAMNAME + +Usage example - install grml-small to usb-device on /mnt/external1: + $PROGRAMNAME grml_small_0.2.iso /mnt/external1 + +Usage example - delete grml-installation from /mnt/external1: + $PROGRAMNAME uninstall /mnt/external1 + +For more information take a look at http://wiki.grml.org/doku.php?id=usb +Report bugs, send wishes and feedback to the grml team: +http://grml.org/bugs/ - contact (at) grml.org +" +} + +notice(){ + echo " +Installing grml to $DEVICE should have been successful! + +Tips: + + Use the usb cheatcode on bootprompt if you experience any problems with + booting grml via usb/firewire, so boot with 'grml scandelay' on bootprompt. + This adds a 'sleep' while trying to access the usb-stick and the module + should have enough time to access it. Using scandeleay=seconds is possible + as well, use 'grml scandelay=20' to wait 20 seconds before trying to access + the external device with grml on it. + + Also make sure you have tested all available modes of USB-boot in + the BIOS of your computer. Often found as USB-HDD, USB-FDD and + USB-ZIP in the bootmenu. + + Take a look at http://wiki.grml.org/doku.php?id=usb for more information." +} + +info(){ + echo "${BLUE}$PROGRAMNAME ${VERSION}${NORMAL} - install grml-system to usb-device" + echo +} + +vfat_warning(){ + echo "Warning: make sure that your usb-device is preformated with vfat. +If not please run it e.g. via: mkfs.vfat -F 16 -v /dev/sda1" + echo +} + +mount_device(){ + if grep ${DEVICE} /proc/mounts ; then + echo echo 1>&2 "${WHITE}${DEVICE} already mounted${NORMAL}" + else + echo -n "Mounting ${DEVICE}: " + debugit "debug: mount $DEVICE" + mount $DEVICE && echo "${WHITE}done${NORMAL}" || bailout + fi +} + +mount_iso(){ + echo -n "Mounting ${ISO} to ${TMPMNT}: " + debugit "debug: mount -o loop ${ISO} ${TMPMNT}" + if mount -o loop ${ISO} ${TMPMNT} ; then + echo "${WHITE}done${NORMAL}" + else + echo 1>&2 "${RED}Problem? You got an error saying 'mount: could not find any free loop device'? +Possible solution: losetup -d /dev/loop/0${NORMAL}" + exit 1 + fi +} + +unmount(){ + echo -n "Unmounting ${DEVICE} and ${TMPMNT}." + umount ${TMPMNT} + umount ${DEVICE} +} + +copyit(){ + echo -n "Installing data from ${ISO} to ${DEVICE} (will take some time): " + debugit "debug: cp -dR --preserve=mode,timestamps ${TMPMNT}/* ${DEVICE}" + debugit "debug: mv ${DEVICE}/boot/isolinux/* ${DEVICE}/" + if cp -dR --preserve=mode,timestamps ${TMPMNT}/* ${DEVICE} ; then + echo "# filelist of $PROGRAMNAME on $(date) using $ISO on ${DEVICE}:" > $DEVICE/grml2hd.filelist + find ${TMPMNT} -type f | grep -v isolinux | sed 's#^/mnt/test/##' | tr A-Z a-z >> $DEVICE/grml2hd.filelist && \ + find ${DEVICE}/boot/isolinux -type f | sed 's#.*isolinux/##' | tr A-Z a-z >> $DEVICE/grml2hd.filelist && \ + mv ${DEVICE}/boot/isolinux/* ${DEVICE}/ && \ + rmdir ${DEVICE}/boot/isolinux && \ + rmdir ${DEVICE}/boot/ + sync && echo "${WHITE}done${NORMAL}" + else + unmount + return 1 + fi +} + +run_syslinux(){ + DEV=$(echo ${DEVICE%/}) + TMPDEV=$(grep ${DEV} /etc/fstab | awk '{print $1}') + SYSDEV=$(echo ${TMPDEV%/}) + echo -n "Running syslinux on ${SYSDEV}: " + debugit "debug: syslinux ${SYSDEV}" + syslinux ${SYSDEV} && echo "${WHITE}done${NORMAL}" || echo 1>&2 "${RED}Problem when running syslinux? +Try to call it manually via 'syslinux /dev/sda1' if you installed grml to /dev/sda1'${NORMAL}" +} + +# }}} + +# main program {{{ +trap bailout 1 2 3 15 + +if [[ $# != 2 ]]; then + usage ; exit 1 +fi + +if [ -n "$UNINSTALL" ] ; then + echo "${BLUE}$PROGRAMNAME - ${VERSION}" + echo "${BLUE}Uninstalling grml from ${DEVICE} based on ${DEVICE}/grml2hd.filelist.${NORMAL}" + if mount_device ; then + if [ -f ${DEVICE}/grml2hd.filelist ] ; then + for file in `cat $DEVICE/grml2hd.filelist | grep -v '^#'` ; do + echo -n "removing ${file} on ${DEVICE}: " + rm ${DEVICE}/${file} && echo "${WHITE}done${NORMAL}" || echo "${RED}error${NORMAL}" + done + echo -n "removing directory grml/images/ on ${DEVICE}: " + rmdir ${DEVICE}/grml/images/ && echo "${WHITE}done${NORMAL}" || echo "${RED}error${NORMAL}" + echo -n "removing directory grml/ on ${DEVICE}: " + rmdir ${DEVICE}/grml && echo "${WHITE}done${NORMAL}" || echo "${RED}error${NORMAL}" + echo -n "removing filelist grml2hd.filelist on ${DEVICE}: " + rm ${DEVICE}/grml2hd.filelist && echo "${WHITE}done${NORMAL}" || echo "${RED}error${NORMAL}" + echo -n "Unmounting ${DEVICE}:" + umount $DEVICE && echo "${WHITE}done${NORMAL}" || echo "${RED}error${NORMAL}" + else + echo 1>&2 "${RED}File ${DEVICE}/grml2hd.filelist not found. I have nothing to delete therefor. Exiting.${NORMAL}" + fi + fi +else + info + vfat_warning && \ + mount_iso && \ + mount_device && \ + copyit && \ + unmount && \ + run_syslinux && \ + notice +fi +# }}} + +## END OF FILE ################################################################# +# vim:foldmethod=marker diff --git a/grml2usb.8 b/grml2usb.8 new file mode 100644 index 0000000..ac8ba9d --- /dev/null +++ b/grml2usb.8 @@ -0,0 +1,59 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH GRML2USB 8 "August 14, 2005" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +grml2usb \- program to do something +.SH SYNOPSIS +.B grml2usb +.RI [ options ] " files" ... +.br +.B bar +.RI [ options ] " files" ... +.SH DESCRIPTION +This manual page documents briefly the +.B grml2usb +and +.B bar +commands. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBgrml2usb\fP is a program that... +.SH OPTIONS +These programs follow the usual GNU command line syntax, with long +options starting with two dashes (`-'). +A summary of options is included below. +For a complete description, see the Info files. +.TP +.B \-h, \-\-help +Show summary of options. +.TP +.B \-v, \-\-version +Show version of program. +.SH SEE ALSO +.BR bar (1), +.BR baz (1). +.br +The programs are documented fully by +.IR "The Rise and Fall of a Fooish Bar" , +available via the Info system. +.SH AUTHOR +grml2usb was written by . +.PP +This manual page was written by Michael Prokop , +for the Debian project (but may be used by others). -- 2.1.4