summaryrefslogtreecommitdiffstats
path: root/build_tools/clarch/larch/run/myusbboot
blob: 29f20840c9e4d2c128fbbbfbf43619d2aee099bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /bin/bash
#
# usbboot
#
# Author: Michael Towers <gradgrind[at]online[dot]de>
#
# This file is part of the larch project.
#
#    larch 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; either version 2 of the License, or
#    (at your option) any later version.
#
#    larch 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 larch; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
#----------------------------------------------------------------------------
# 2008.06.22

APP="$( basename $0 )"

usage () {
    echo
    echo "Usage:"
    echo "  ${APP} [<Arch installation root directory>]"
    echo
    echo "   Prepare a bootable USB-stick from a larch build."
    echo "   If no Arch directory is given, '/' is assumed."
    exit 1
}

if [ -n "$1" ]; then
    AINSTALL="$( readlink -f $1 )"
else
    AINSTALL=""
fi
CDDATA=${AINSTALL}/.larch/cd

if [ ! -f ${CDDATA}/system.sqf ]; then
    echo "ERROR: ${CDDATA} does not contain larch cd data"
    usage
fi
if [ ! -f ${CDDATA}/isolinux/isolinux.cfg ]; then
    echo "ERROR: isolinux data not in ${CDDATA}/isolinux"
    exit 1
fi

if ! [ -f ${AINSTALL}/usr/bin/syslinux ]; then
    echo "ERROR: syslinux not found -"
    echo "      it must be installed on live system"
    return 1
fi

# test if the script is started by root user. If not, exit
if [ $UID -ne 0 ]; then
    echo "Only root can run ${APP}"; exit 1
fi


echo "// Copying the boot sector"
dd if=${AINSTALL}/usr/lib/syslinux/mbr.bin of=${dev}

echo "// Copying the files"
stick=/tmp/usbstick
if [ -f ${stick} ]
then
    rm -rf ${stick} 
fi
 mkdir -p ${stick}

if [ $? != 0 ]; then
  echo "ERROR: Failed to mount device, quitting"
  exit 3
fi

cp -a ${CDDATA}/* ${stick}
mv ${stick}/isolinux ${stick}/syslinux
mv ${stick}/syslinux/isolinux.cfg ${stick}/syslinux/syslinux.cfg
rm -f ${stick}/syslinux/isolinux*

echo "//"
echo "// Done!"
echo "// If all went well your usb stick should now be a bootable larch system"