diff options
author | James Meyer <James.meyer@operamail.com> | 2008-10-02 03:23:45 (GMT) |
---|---|---|
committer | James Meyer <James.meyer@operamail.com> | 2008-10-02 03:23:45 (GMT) |
commit | 618d4ad515a93d1e48934be5846edd71270171ec (patch) | |
tree | a22a9294af81215d4a7b1053e5fdb4d746f39d41 /build_tools/clarch/larch/run | |
download | linhes_dev-618d4ad515a93d1e48934be5846edd71270171ec.zip |
initital import
Diffstat (limited to 'build_tools/clarch/larch/run')
-rwxr-xr-x | build_tools/clarch/larch/run/cachepacs | 139 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/gen_repo | 206 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/getPackageServer | 275 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/inpacs | 302 | ||||
-rw-r--r-- | build_tools/clarch/larch/run/jams.cachepacks.larch.patch | 352 | ||||
-rw-r--r-- | build_tools/clarch/larch/run/jams.larch.patch | 110 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/larchify | 140 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/mklarch | 281 | ||||
-rw-r--r-- | build_tools/clarch/larch/run/myusbboot | 89 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/ssh_init | 18 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/usb2bootiso | 66 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/usb2iso | 78 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/usbboot | 100 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/usbboot.orig | 155 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/usbboot_grub | 180 | ||||
-rwxr-xr-x | build_tools/clarch/larch/run/xpack | 122 |
16 files changed, 2613 insertions, 0 deletions
diff --git a/build_tools/clarch/larch/run/cachepacs b/build_tools/clarch/larch/run/cachepacs new file mode 100755 index 0000000..f8b5951 --- /dev/null +++ b/build_tools/clarch/larch/run/cachepacs @@ -0,0 +1,139 @@ +#! /bin/bash +# +# cachepacs - install pkgs to cache dir, but don't isntall +# +# Author: James Meyer (based on inpacs) + + +# Working directory: +TMPDIR=/tmp/inpacs$$ +# File containing (filtered) list of base packages + added packages +basepacks=${TMPDIR}/basepacks + +APP="$( basename $0 )" + +exitfunc () { + # Remove temporary files + rm -rf ${TMPDIR} + exit $1 +} + +# Default pacman db path (this is a statement, not a configuration, so +# do not change it!) +DBPATH="/var/lib/pacman" + +# Default package cache, on the target +TARGETCACHE="${CACHE}" +# A host or remote package cache: +HOSTCACHE="" +# Absolute /path/to/file containing list of packages for 2nd install phase: +ADDEDPACKS="" +# Source file for base package list: +BASEPACKSFILE="" +# Source file for list of vetoed base packages: +VETOFILE="" +# Source directory for pacman database directories: +DBDIR="" +# pacman executable: +PACMANX="pacman -f" +# pacman configuration file +PACMANK="/etc/pacman.conf" + +checkfile () +{ + f=$( readlink -m $1 ) + if ! [ -f "${f}" ]; then + echo "ERROR: File doesn't exist: ${f}" + exitfunc + fi +} + +checkdir () +{ + f=$( readlink -m $1 ) + if ! [ -d "${f}" ]; then + echo "ERROR: Directory doesn't exist: ${f}" + exitfunc + fi +} + + +while getopts ":k:a:c:b:x:y:P:" Option +do + case ${Option} in + k ) checkfile ${OPTARG} + PACMANK=${f} ;; + a ) checkfile ${OPTARG} + CACHEPACKSFILE=${f} ;; + y ) checkdir ${OPTARG} + DBDIR=${f} ;; + P ) checkfile ${OPTARG} + PACMANX=${f} ;; + #* ) usage ;; + esac +done +shift $((${OPTIND} - 1)) +INSTLDIR="$1" + + +# grep the cachedir out of the installed pacman.conf +PCCACHE=`grep CacheDir $INSTLDIR/etc/pacman.conf|cut -d= -f2|cut -d\/ -f2-` +CACHEDIR=${INSTLDIR}/$PCCACHE + +echo "INSTLDIR=${INSTLDIR}" +echo "PACMANK=${PACMANK}" +echo "CACHEDIR=${CACHEDIR}" +echo "DBDIR=${DBDIR}" +echo "PACMANX=${PACMANX}" +echo + + +# test if the script is started by root user. If not, exit +if [ $UID -ne 0 ]; then + echo "Only root can run ${APP}"; exitfunc 1 +fi + +echo "//" +echo "// downloading packages to ${CACHEDIR}" + +PACMAN="${PACMANX} --config ${PACMANK} --noconfirm" + +rm -rf ${TMPDIR} +mkdir -p ${TMPDIR} + +# Helper function for installing a list of packages +doInstall() { + mkdir -p ${INSTLDIR}/sys + mkdir -p ${INSTLDIR}/proc + mount --bind /sys ${INSTLDIR}/sys + mount --bind /proc ${INSTLDIR}/proc + ${PACMAN} -r ${INSTLDIR} -Sw $1 + RET=$? + umount ${INSTLDIR}/proc + umount ${INSTLDIR}/sys + if [ ${RET} -ne 0 ]; then + echo "//" + echo "// Package $1 FAILED." + echo "//" + return 1 + fi +} + + +PACMAN="${PACMAN} --cachedir $CACHEDIR" + +########## GET LIST OF CACHE PACKAGES +echo "//" +echo "// ** Getting cache package list ..." +if [ -n "${CACHEPACKSFILE}" ]; then + echo "// from: ${CACHEPACKSFILE}" + CACHEPKGS=$( cat ${CACHEPACKSFILE} | grep -v "#" ) +else + echo " no cache package file found" + exit 0 +fi + + +doInstall "${CACHEPKGS}" +if [ $? -ne 0 ]; then exitfunc 1; fi +exitfunc diff --git a/build_tools/clarch/larch/run/gen_repo b/build_tools/clarch/larch/run/gen_repo new file mode 100755 index 0000000..86e7b85 --- /dev/null +++ b/build_tools/clarch/larch/run/gen_repo @@ -0,0 +1,206 @@ +#!/usr/bin/env python + +# gen_repo - build a repository db file from a set of packages +# +# Author: Michael Towers (gradgrind) <mt.42@web.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 +# +#---------------------------------------------------------------------------- +# +# Version 1.5 // 7th July 2007 + +import os +import os.path +import sys +import tarfile +from types import * +import re +from subprocess import check_call + +# to add a package: +#check_call(["repo-add", dbfile, pkg, pkg, pkg, ...]) + +# Regex to remove version comparison from package dependency +onlyname = re.compile("([^=><]+).*") + +def create_db(dbname, packagesdir, dep_ignore_list): + os.chdir(packagesdir) + dbfile = dbname + ".db.tar.gz" + if os.path.exists(dbfile): + os.remove(dbfile) + + # Get a list of packages + packages = filter(lambda s: s.endswith(".pkg.tar.gz"), os.listdir(".")) + packages.sort() + + # Use 'repo-add' to build the repo + check_call(["repo-add", dbfile] + packages) + + # Make a dict for keeping track of dependencies + dep_dict = {} + for p in packages: + pkg_dict = get_pkg_info(p) + pkg_name = pkg_dict["pkgname"] + pkg_dbname = pkg_name + "-" + pkg_dict["pkgver"] + # Add dependency info to dependency dict + for d in pkg_dict["depend"]: + # But also need to cater for versioning!!! + # I will just ignore it here ... + dm = onlyname.match(d) + if not dm: + if d: + print "DEBUG: package %s, dependency = '%s'" % (pkg_name, d) + continue + d = dm.group(1) + if not dep_dict.has_key(d): + dep_dict[d] = [False] + dep_dict[d].append(pkg_name) + # Mark packages provided by this one + for p in (pkg_dict["provides"] + [pkg_name]): + if dep_dict.has_key(p): + dep_dict[p][0] = True + else: + dep_dict[p] = [True] + # Mark packages in ignore list + for p in dep_ignore_list: + if dep_dict.has_key(p): + dep_dict[p][0] = True + + # Now display unsatisfied dependencies + # Should add the possibility of declaring a list of packages + # available (e.g. the base set, or all those on the live CD ..." + print "-------------\nUnsatisfied dependencies:" + for d, r in dep_dict.items(): + if not r[0]: + print " ", d, "- needed by: ", + for p in r[1:]: + print p, " ", + print "" + + + +def get_pkg_info(pkg): + tf = tarfile.open(pkg, "r:gz") + pkginfo = tf.extractfile(".PKGINFO") + pkg_dict = {# the first ones go to 'desc' + "pkgname" : None, + "pkgver" : None, + # from here they are optional, and can occur more than once + "depend" : [], + "provides" : [], + } + while True: + l = pkginfo.readline().strip() + if not l: break + if l[0] == "#": continue + split3 = l.split(None, 2) + while len(split3) < 3: split3.append("") + key, eq, value = split3 + if not pkg_dict.has_key(key): continue + val = pkg_dict[key] + if val == None: + pkg_dict[key] = value + continue + if not isinstance(val, ListType): + print "Unexpected situation ...\n key [oldvalue] <- newvalue" + print key, "[%s]" % val, "<-", value + sys.exit(1) + pkg_dict[key].append(value) + pkginfo.close() + return pkg_dict + +def cat(path): + """Python version of 'cat'""" + fp = open(path, "r") + op = "" + for l in fp: + op += l + fp.close() + return op + +def usage(): + print """ + gen_repo package-dir [repo-name] [-- ignore-list] + + Generate a pacman db file for the packages in package-dir. + + If repo-name is given, this will be used as the name for the repository, + otherwise the name of the directory containing the packages will be used. + + All dependencies of the packages in the repository will be listed to + standard output, but a list of packages not to be included in this list + can be specified: + ignore-list should be either a file containing the names of packages + not to be listed as dependencies (separated by space or newline), or a + directory containing 'package directories', like /var/abs/base or + /var/lib/pacman/local + """ + sys.exit(1) + +if __name__ == "__main__": + + if len(sys.argv) < 2: + usage() + if os.getuid() != 0: + print "Must be root to run this" + sys.exit(1) + pkgdir = sys.argv[1] + if (len(sys.argv) == 2) or (sys.argv[2] == "--"): + dbname = os.path.basename(os.path.abspath(pkgdir)) + i = 2 + else: + dbname = sys.argv[2] + i = 3 + if len(sys.argv) == i: + ignore_list = [] + elif (len(sys.argv) == i+2) and (sys.argv[i] == "--"): + ignore_list = sys.argv[i+1] + else: + usage() + if not os.path.isdir(pkgdir): + print "\n1st argument must be a directory" + sys.exit(1) + print "\nCreating pacman database (%s.db.tar.gz) file in %s" % (dbname, pkgdir) + + if ignore_list: + # Get list of packages to be ignored in dependency list + if os.path.isfile(ignore_list): + # A simple file containing the names of packages to ignore + # separated by space or newline. + ignore_list = cat(ignore_list).split() + elif os.path.isdir(ignore_list): + # A directory containing packages or package-directories (like in abs) + l = os.listdir(ignore_list) + # See if there are packages in this directory + lp = filter(lambda s: s.endswith(".pkg.tar.gz"), l) + if lp: + l = map(lambda s: s.replace(".pkg.tar.gz", ""), lp) + re1 = re.compile("(.+)-[^-]+?-[0-9]+") + ignore_list = [] + for f in l: + m = re1.match(f) + if m: + ignore_list.append(m.group(1)) + else: + # the directory contains just the package names (like abs) + ignore_list.append(m) + else: + print "!!! Invalid ignore-list" + usage() + + create_db(dbname, pkgdir, ignore_list) diff --git a/build_tools/clarch/larch/run/getPackageServer b/build_tools/clarch/larch/run/getPackageServer new file mode 100755 index 0000000..170ea73 --- /dev/null +++ b/build_tools/clarch/larch/run/getPackageServer @@ -0,0 +1,275 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +# getPackageServer - select a pacman package server +# +# 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.08.10 + +import getopt, sys, os +from subprocess import Popen, PIPE, STDOUT + +# Build a list structure with areas, subareas and servers +# [ [area1, [ [subarea1, [server1, server2, ...]], +# [subarea2, [server1, server2, ...]], +# ... +# ] +# ], +# [area2, [ [subarea1, [server1, server2, ...]], +# [subarea2, [server1, server2, ...]], +# ... +# ] +# ], +# ... +# ] +def parseFile(path): + areas = [] + header = True + fh = open(path) + for line in fh: + sline = line.strip() + if header: + if not sline.startswith('#'): + header = False + continue + + if not sline: + continue + + if sline.startswith('#'): + if (sline.find('Server =') >= 0): + # Commented out server + continue + if sline.startswith('##'): + # Real comment + continue + # Otherwise assume this is an area name + if sline.startswith('# -'): + # New subarea + servers = [] + subarealist = [sline.split('-', 1)[1].strip(), servers] + subareas.append(subarealist) + else: + # New area (if no subarea, use 'all') + servers = None + subareas = [] + arealist = [sline[1:].strip(), subareas] + areas.append(arealist) + continue + + if sline.startswith('Server ='): + server = sline.split('=')[1].strip() + if (servers == None): + servers = [] + subarealist = ['all', servers] + subareas.append(subarealist) + servers.append(server) + + else: + report("Unexpected line:\n%s\n" % line) + + fh.close() + return areas + +#Menu using 'dialog' +#+++++++++++++++++++ +# geometry: +WIDTH = '76' +HEIGHT = '20' +LINES = '8' +def menu_d(title, text, entries, default=0, header=None): + # Note that dialog indexing starts at 1, not 0! + i = 1 + mlist = [] + for m in entries: + mlist += ["%d" % i, "%-60s" % m] + i += 1 + if header: + text += "\n " + header + cmd = ['dialog', '--title', title, + '--default-item', "%d" % (default+1), + '--menu', text, HEIGHT, WIDTH, LINES] + mlist + #print cmd + p = Popen(cmd, stderr=PIPE) + output = p.communicate()[1] + rc = p.returncode + + if (rc == 0): + return int(output) + elif (rc == 1): + return 0 + else: + assert False + +#Menu using plain console +#++++++++++++++++++++++++ +def menu_c(title, text, entries): + t = "***** %s *****" % title + print t + print "=" * len(t) + print text + i = 0 + ilist = "123456789abcdefghijklmnopqrstuvwxyz" + for m in entries: + print " %s - %-60s" % (ilist[i], m) + i += 1 + print "-----------------------------------------" + print " 0 - Go back" + k = raw_input("Select: ") + if (k == "0"): + return 0 + n = -1 + if k in "123456789": + n = (ord(k) - ord("0")) + elif k in "abcdefghijklmnopqrstuvwxyz": + n = (ord(k) - ord("a") + 10) + assert ((n>0) and (n<=i)) + return n + +def menu(title, text, entries, default=0, header=None): + """General menu, uses 'dialog' if available, else plain console. + """ + if console: + return menu_c(title, text, entries) + else: + return menu_d(title, text, entries, default=0, header=None) + +import re +re1 = re.compile(r"/\$repo/os/.*") +def repoDialog(servers): + serverList = parseFile(servers) + step = 0 + while True: + if (step == 0): + areaList = [a[0] for a in serverList] + a1 = menu("Choose Arch Repository", + "Select a region", + areaList) + if (a1 == 0): + step = -1 + break + step = 1 + + list2 = serverList[a1-1][1] + if (len(list2) == 1): + a = 1 + step = 0 + else: + subareaList = [a[0] for a in list2] + a = menu("Choose Arch Repository", + "Select a sub-region", + subareaList) + if (a == 0): + step = 0 + continue + + mirrorList = list2[a-1][1] + list3 = [re1.sub("", m) for m in mirrorList] + a = menu("Choose Arch Repository", + "Select a mirror", + list3) + if (a > 0): + break + + if (step >= 0): + return mirrorList[a-1] + else: + return None + + +def usage(): + print "Usage:" + print " getPackageServer [-h] [-i <repository list file>] [<pacman.conf>]" + print + print "Select a server for Arch Linux packages. The given pacman.conf" + print "file will be updated to use the chosen server first. Other entries" + print "will not be affected." + print + print " -h Print this message" + print " -i Supply an alternative list of repositories." + print " The default is /etc/pacman.d/mirrorlist" + print " -c Use plain console for interaction even if" + print " 'dialog' is available" + print + print "If no pacman.conf file is supplied, the chosen repository URL will" + print "be output to stdout - mainly for test purposes." + +if __name__ == '__main__': + def report(text): + print text + + repolist = '/etc/pacman.d/mirrorlist' + + # determine whether 'dialog' utility is available + p = Popen(["which", "dialog"], stdout=PIPE, stderr=STDOUT) + output = p.communicate()[1] + console = (p.returncode != 0) + + try: + opts, args = getopt.getopt(sys.argv[1:], "i:hc") + except getopt.GetoptError: + # print help information and exit: + usage() + sys.exit(1) + for o, a in opts: + if (o == "-h"): + usage() + sys.exit() + if (o == "-i"): + repolist = a + if (o == "-c"): + console = True + + if (len(args) > 1): + # print help information and exit: + usage() + sys.exit(1) + + mirror = repoDialog(repolist) + if not mirror: + print "Cancelled" + sys.exit(1) + + if (len(args) == 0): + print mirror + sys.exit(0) + + # Generate pacman.conf file + mirror = "Server = " + mirror + # The value for @carch@ will be substituted when building the package + mirror = mirror.replace("@carch@", "i686") + pcfile = args[0] + pcfh = open(pcfile, "r") + pcf = pcfh.read() + pcfh.close() + os.remove(pcfile) + pcfh = open(pcfile, "w") + for line in pcf.splitlines(True): + pcfh.write(line) + if line.startswith("[core]"): + pcfh.write(mirror.replace("$repo", "core") + "\n") + elif line.startswith("[extra]"): + pcfh.write(mirror.replace("$repo", "extra") + "\n") + elif line.startswith("[community]"): + pcfh.write(mirror.replace("$repo", "community") + "\n") + + pcfh.close() + print "++ Updated %s" % pcfile diff --git a/build_tools/clarch/larch/run/inpacs b/build_tools/clarch/larch/run/inpacs new file mode 100755 index 0000000..7bde214 --- /dev/null +++ b/build_tools/clarch/larch/run/inpacs @@ -0,0 +1,302 @@ +#! /bin/bash +# +# inpacs - install Arch Linux using pacman +# +# 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.08.09 + +# Note that this has quite a few differences to 'pacin' (now deprecated). +# Read the usage blurb carefully, for example the options -c, -a (changed +# defaults), and -x (the format of the veto file has changed slightly). + + +# Working directory: +TMPDIR=/tmp/inpacs$$ +# File containing (filtered) list of base packages + added packages +basepacks=${TMPDIR}/basepacks + +APP="$( basename $0 )" + +exitfunc () { + # Remove temporary files + rm -rf ${TMPDIR} + exit $1 +} + +usage () { + echo + echo "Usage:" + echo " ${APP} [-k <path to pacman configuration file> ]" + echo " [-a <addedpacksfile>]" + echo " [-c <package cache directory>]" + echo " [-b <path to base package list file>]" + echo " [-x <path to vetofile>]" + echo " [-y <path to pacman database directories>]" + echo " [-P <path to pacman executable>]" + echo " <install path>" + echo + echo " -k Use the given file instead of /etc/pacman.conf" + echo + echo " -a Use list of packages in <addedpacksfile> (path/to/file)" + echo " for 2nd install phase. If not specified, only do" + echo " base installation" + echo + echo " -c Use given package cache (on host). Default is to" + echo " create '${CACHE}' on the target and" + echo " use this. If an empty path ('') is given, use the" + echo " default on the host." + echo + echo " -b Use the packages (name only, one per line) in this" + echo " file as the base set, installed during the first stage." + echo " By default this list will be extracted from the" + echo " file 'packages.txt' in the 'core' repository." + echo + echo " -x Remove the packages (name only, one per line)" + echo " in this file from the list of base packages" + echo " before doing the first installation stage." + echo + echo " -y Don't perform 'pacman -Sy' before installing," + echo " but copy the pacman database directories from" + echo " the given parent directory." + echo + echo " -P Use the given pacman executable (possibly" + echo " useful on non-Arch systems)." + echo + echo "${APP} will do an automated Arch Linux installation to the given" + echo "installation directory by installing one or two lists of packages." + echo "It only installs the packages, without configuration." + echo + echo "Initially it installs the set of base packages (though this set" + echo "is fully configurable). It can then, optionally, install a further" + echo "set of additional packages." + echo + echo "Where it gets the packages from is fully configurable (via" + echo "the pacman configuration file and the package cache location)" + echo "By previously mounting a remote package cache using sshfs or" + echo "NFS it is also possible to use that." + echo + exitfunc +} + +# Default package cache (this is a statement, not a configuration, so +# do not change it!) +CACHE="/var/cache/pacman/pkg" +# Default pacman db path (this is a statement, not a configuration, so +# do not change it!) +DBPATH="/var/lib/pacman" + +# Default package cache, on the target +TARGETCACHE="${CACHE}" +# A host or remote package cache: +HOSTCACHE="" +# Absolute /path/to/file containing list of packages for 2nd install phase: +ADDEDPACKS="" +# Source file for base package list: +BASEPACKSFILE="" +# Source file for list of vetoed base packages: +VETOFILE="" +# Source directory for pacman database directories: +DBDIR="" +# pacman executable: +PACMANX="pacman -f" +# pacman configuration file +PACMANK="/etc/pacman.conf" + +checkfile () +{ + f=$( readlink -m $1 ) + if ! [ -f "${f}" ]; then + echo "ERROR: File doesn't exist: ${f}" + exitfunc + fi +} + +checkdir () +{ + f=$( readlink -m $1 ) + if ! [ -d "${f}" ]; then + echo "ERROR: Directory doesn't exist: ${f}" + exitfunc + fi +} + +while getopts ":k:a:c:b:x:y:P:" Option +do + case ${Option} in + k ) checkfile ${OPTARG} + PACMANK=${f} ;; + a ) checkfile ${OPTARG} + ADDEDPACKS=${f} ;; + c ) TARGETCACHE="" + if [ -n "${OPTARG}" ]; then + HOSTCACHE=${OPTARG} + checkdir ${HOSTCACHE} + HOSTCACHE=${f} + fi ;; + b ) checkfile ${OPTARG} + BASEPACKSFILE=${f} ;; + x ) checkfile ${OPTARG} + VETOFILE=${f} ;; + y ) checkdir ${OPTARG} + DBDIR=${f} ;; + P ) checkfile ${OPTARG} + PACMANX=${f} ;; + * ) usage ;; + esac +done +shift $((${OPTIND} - 1)) +INSTLDIR="$1" + +echo "INSTLDIR=${INSTLDIR}" +echo "PACMANK=${PACMANK}" +echo "ADDEDPACKS=${ADDEDPACKS}" +echo "TARGETCACHE=${TARGETCACHE}" +echo "HOSTCACHE=${HOSTCACHE}" +echo "BASEPACKSFILE=${BASEPACKSFILE}" +echo "VETOFILE=${VETOFILE}" +echo "DBDIR=${DBDIR}" +echo "PACMANX=${PACMANX}" +echo + +if [ -d "${INSTLDIR}" ]; then + # This is not a brilliant test, but at least it will pick up + # data files in the destination directory, without being disturbed + # by sub-mounts. + if [ -n "$( find ${INSTLDIR} ! -type d )" ]; then + echo "ERROR: Installation directory (${INSTLDIR}) not empty" + exitfunc 1 + fi +else + echo "ERROR: Installation directory (${INSTLDIR}) does not exist" + echo + usage +fi + +# test if the script is started by root user. If not, exit +if [ $UID -ne 0 ]; then + echo "Only root can run ${APP}"; exitfunc 1 +fi + +echo "//" +echo "// Installing Arch Linux to directory ${INSTLDIR}" + +PACMAN="${PACMANX} --config ${PACMANK} --noconfirm" + +rm -rf ${TMPDIR} +mkdir -p ${TMPDIR} + +# Helper function for installing a list of packages +doInstall() { + mkdir -p ${INSTLDIR}/sys + mkdir -p ${INSTLDIR}/proc + mount --bind /sys ${INSTLDIR}/sys + mount --bind /proc ${INSTLDIR}/proc + ${PACMAN} -r ${INSTLDIR} -S $( cat $1 ) + RET=$? + umount ${INSTLDIR}/proc + umount ${INSTLDIR}/sys + if [ ${RET} -ne 0 ]; then + echo "//" + echo "// Package installation from $1 FAILED." + echo "//" + return 1 + fi +} + +if [ -n "${TARGETCACHE}" ]; then + # This redirects the package cache to the install target + # (change in pacman-3.1) + PACMAN="${PACMAN} --cachedir ${INSTLDIR}${TARGETCACHE}" +elif [ -n "${HOSTCACHE}" ]; then + # This redirects the package cache to an existing non-standard one + PACMAN="${PACMAN} --cachedir ${HOSTCACHE}" +fi + +mkdir -p ${INSTLDIR}${DBPATH}/sync +if [ -n "${DBDIR}" ]; then + echo "//" + echo "// Fetching package dbs from: ${DBDIR}" + for repo in $( grep "^\[.*\]" ${PACMANCONF} | sed "s|\[\(.*\)\]|\1|"); do + if [ "${repo}" != "options" ]; then + echo " ... ${repo}" + cp -a ${DBDIR}/sync/${repo} ${INSTLDIR}${DBPATH}/sync + fi + done + echo "//" +else + echo "//" + echo "// Synchronising package dbs **************" + echo "//" + ${PACMAN} -r ${INSTLDIR} -Sy +fi + +########## GET LIST OF BASE PACKAGES + +echo "//" +echo "// ** Getting base package list ..." +if [ -n "${BASEPACKSFILE}" ]; then + echo "// from: ${BASEPACKSFILE}" + BASEPKGS=$( cat ${BASEPACKSFILE} | grep -v "#" ) +else + BASEPKGS=$( ${PACMAN} -r ${INSTLDIR} -Sg base | sed 's|^base *||') +fi +echo "//" + +########## LIST OF BASE PACKAGES NOW IN ${BASEPKGS} + +########## FILTER LIST OF BASE PACKAGES + +# Build basepacks by filtering BASEPKGS +: > ${basepacks} +# +# Filter out vetoed packages +for p in ${BASEPKGS}; do + if [ -z "${VETOFILE}" ] || \ + ! grep "^[ ]*${p}[ ]*\$" ${VETOFILE} &>/dev/null; then + echo ${p} >> ${basepacks} + fi +done + +########## FILTERED BASE PACKAGE LIST NOW IN FILE ${basepacks} + +if [ -n "${ADDEDPACKS}" ]; then + echo "//" + echo "// ***** Adding additional packages to install list *****" + echo "//" + for p in $( cat ${ADDEDPACKS} | grep -v "#" ); do + if ! grep "^[ ]*${p}[ ]*\$" ${basepacks} &>/dev/null; then + echo ${p} >> ${basepacks} + fi + done +fi + +echo "//" +echo "// ************** Installing selected packages **************" +echo "//" +doInstall ${basepacks} +if [ $? -ne 0 ]; then exitfunc 1; fi + +echo "//" +echo "// *** inpacs finished! Arch Linux has been installed to ${INSTLDIR} ***" +echo "// It is, however, pretty unconfigured ..." +echo "//" + +exitfunc diff --git a/build_tools/clarch/larch/run/jams.cachepacks.larch.patch b/build_tools/clarch/larch/run/jams.cachepacks.larch.patch new file mode 100644 index 0000000..2e40e17 --- /dev/null +++ b/build_tools/clarch/larch/run/jams.cachepacks.larch.patch @@ -0,0 +1,352 @@ +diff -Nur run.orig/cachepacs run/cachepacs +--- run.orig/cachepacs 1970-01-01 00:00:00.000000000 +0000 ++++ run/cachepacs 2008-08-29 02:34:57.000000000 +0000 +@@ -0,0 +1,139 @@ ++#! /bin/bash ++# ++# cachepacs - install pkgs to cache dir, but don't isntall ++# ++# Author: James Meyer (based on inpacs) ++ ++ ++# Working directory: ++TMPDIR=/tmp/inpacs$$ ++# File containing (filtered) list of base packages + added packages ++basepacks=${TMPDIR}/basepacks ++ ++APP="$( basename $0 )" ++ ++exitfunc () { ++ # Remove temporary files ++ rm -rf ${TMPDIR} ++ exit $1 ++} ++ ++# Default pacman db path (this is a statement, not a configuration, so ++# do not change it!) ++DBPATH="/var/lib/pacman" ++ ++# Default package cache, on the target ++TARGETCACHE="${CACHE}" ++# A host or remote package cache: ++HOSTCACHE="" ++# Absolute /path/to/file containing list of packages for 2nd install phase: ++ADDEDPACKS="" ++# Source file for base package list: ++BASEPACKSFILE="" ++# Source file for list of vetoed base packages: ++VETOFILE="" ++# Source directory for pacman database directories: ++DBDIR="" ++# pacman executable: ++PACMANX="pacman -f" ++# pacman configuration file ++PACMANK="/etc/pacman.conf" ++ ++checkfile () ++{ ++ f=$( readlink -m $1 ) ++ if ! [ -f "${f}" ]; then ++ echo "ERROR: File doesn't exist: ${f}" ++ exitfunc ++ fi ++} ++ ++checkdir () ++{ ++ f=$( readlink -m $1 ) ++ if ! [ -d "${f}" ]; then ++ echo "ERROR: Directory doesn't exist: ${f}" ++ exitfunc ++ fi ++} ++ ++ ++while getopts ":k:a:c:b:x:y:P:" Option ++do ++ case ${Option} in ++ k ) checkfile ${OPTARG} ++ PACMANK=${f} ;; ++ a ) checkfile ${OPTARG} ++ CACHEPACKSFILE=${f} ;; ++ y ) checkdir ${OPTARG} ++ DBDIR=${f} ;; ++ P ) checkfile ${OPTARG} ++ PACMANX=${f} ;; ++ #* ) usage ;; ++ esac ++done ++shift $((${OPTIND} - 1)) ++INSTLDIR="$1" ++ ++ ++# grep the cachedir out of the installed pacman.conf ++PCCACHE=`grep CacheDir $INSTLDIR/etc/pacman.conf|cut -d= -f2|cut -d\/ -f2-` ++CACHEDIR=${INSTLDIR}/$PCCACHE ++ ++echo "INSTLDIR=${INSTLDIR}" ++echo "PACMANK=${PACMANK}" ++echo "CACHEDIR=${CACHEDIR}" ++echo "DBDIR=${DBDIR}" ++echo "PACMANX=${PACMANX}" ++echo ++ ++ ++# test if the script is started by root user. If not, exit ++if [ $UID -ne 0 ]; then ++ echo "Only root can run ${APP}"; exitfunc 1 ++fi ++ ++echo "//" ++echo "// downloading packages to ${CACHEDIR}" ++ ++PACMAN="${PACMANX} --config ${PACMANK} --noconfirm" ++ ++rm -rf ${TMPDIR} ++mkdir -p ${TMPDIR} ++ ++# Helper function for installing a list of packages ++doInstall() { ++ mkdir -p ${INSTLDIR}/sys ++ mkdir -p ${INSTLDIR}/proc ++ mount --bind /sys ${INSTLDIR}/sys ++ mount --bind /proc ${INSTLDIR}/proc ++ ${PACMAN} -r ${INSTLDIR} -Sw $1 ++ RET=$? ++ umount ${INSTLDIR}/proc ++ umount ${INSTLDIR}/sys ++ if [ ${RET} -ne 0 ]; then ++ echo "//" ++ echo "// Package $1 FAILED." ++ echo "//" ++ return 1 ++ fi ++} ++ ++ ++PACMAN="${PACMAN} --cachedir $CACHEDIR" ++ ++########## GET LIST OF CACHE PACKAGES ++echo "//" ++echo "// ** Getting cache package list ..." ++if [ -n "${CACHEPACKSFILE}" ]; then ++ echo "// from: ${CACHEPACKSFILE}" ++ CACHEPKGS=$( cat ${CACHEPACKSFILE} | grep -v "#" ) ++else ++ echo " no cache package file found" ++ exit 0 ++fi ++ ++ ++doInstall "${CACHEPKGS}" ++if [ $? -ne 0 ]; then exitfunc 1; fi ++exitfunc +diff -Nur run.orig/inpacs run/inpacs +--- run.orig/inpacs 2008-08-10 10:51:15.000000000 +0000 ++++ run/inpacs 2008-08-29 02:29:31.000000000 +0000 +@@ -116,7 +116,7 @@ + # Source directory for pacman database directories: + DBDIR="" + # pacman executable: +-PACMANX="pacman" ++PACMANX="pacman -f" + # pacman configuration file + PACMANK="/etc/pacman.conf" + +diff -Nur run.orig/jams.larch.patch run/jams.larch.patch +--- run.orig/jams.larch.patch 1970-01-01 00:00:00.000000000 +0000 ++++ run/jams.larch.patch 2008-08-29 02:34:34.000000000 +0000 +@@ -0,0 +1,110 @@ ++Only in run/: cachepacs ++diff -wU4 run.orig/inpacs run/inpacs ++--- run.orig/inpacs 2008-08-10 10:51:15.000000000 +0000 +++++ run/inpacs 2008-08-29 02:29:31.000000000 +0000 ++@@ -115,9 +115,9 @@ ++ VETOFILE="" ++ # Source directory for pacman database directories: ++ DBDIR="" ++ # pacman executable: ++-PACMANX="pacman" +++PACMANX="pacman -f" ++ # pacman configuration file ++ PACMANK="/etc/pacman.conf" ++ ++ checkfile () ++diff -wU4 run.orig/mklarch run/mklarch ++--- run.orig/mklarch 2008-08-10 10:51:15.000000000 +0000 +++++ run/mklarch 2008-08-29 02:29:45.000000000 +0000 ++@@ -22,9 +22,8 @@ ++ # ++ #---------------------------------------------------------------------------- ++ # 2008.06.22 ++ ++- ++ # directory to use for building the CD - the installation root ++ # It must have LOTS of space, ~ 4GB for a 700MB CD ++ INSTLDIR=/home/larchroot ++ ++@@ -162,8 +161,9 @@ ++ fi ++ ++ for fd in $( ls -A ${INSTLDIR} ); do ++ rm -rf ${INSTLDIR}/${fd} +++#lookforme ++ done ++ mkdir -p ${LARCHBUILD} ++ ++ ############### Call 'inpacs' to do the installation ++@@ -186,9 +186,8 @@ ++ exit 1 ++ fi ++ fi ++ INPACSO="${INPACSO} -k pacman.conf" ++- ++ # If necessary add the larch repository to pacman.conf ++ if ! grep '^[larch5]' pacman.conf &>/dev/null; then ++ if [ -d larchrepo ]; then ++ larch5path="file://$( readlink -f larchrepo )" ++@@ -198,14 +197,15 @@ ++ sysarch="i686" ++ fi ++ larch5path="${larch5path}/${sysarch}" ++ fi ++- sed "/\[testing\]/ i \ ++-[larch5]\n\ ++-Server = ${larch5path}\n\ ++-#larch5---\n" -i pacman.conf +++ #sed "/\[testing\]/ i \ +++ echo "[larch5] " >> pacman.conf +++ echo "Server = ${larch5path}" >> pacman.conf ++ fi ++ +++ +++ ++ if ! which pacman &>/dev/null; then ++ if ! [ -x ${startdir}/pacman ]; then ++ echo "ERROR: Couldn't find pacman executable" ++ exit 1 ++@@ -217,17 +217,21 @@ ++ if [ $? -ne 0 ]; then exit 1; fi ++ ++ # Use build version of pacman.conf in live system, without [larch5] repository. ++ # This can be overwritten by a pacman.conf in the profile's overlay. +++ ++ rm -f ${INSTLDIR}/etc/pacman.conf ++-if [ -f pacman.conf.0 ]; then +++if [ -f ${PROFILE}/pacman.conf ]; then ++ # This file should be used in preference to pacman.conf - it is created by ++ # larch-setup on non-Arch systems before commenting out the 'Include' lines. ++- cp pacman.conf.0 ${INSTLDIR}/etc/pacman.conf +++ cp ${PROFILE}/pacman.conf ${INSTLDIR}/etc/pacman.conf ++ else ++ sed '/^\[larch5\]/,/^ *$/ d' <pacman.conf >${INSTLDIR}/etc/pacman.conf ++ fi ++ +++cachepacs -a ${PROFILE}/cache_packs $INPACSO -d ${INSTLDIR} +++ +++ ++ # Generate glibc locales ++ if [ -f ${PROFILE}/locale.gen ]; then ++ echo ++ echo "********** Generating locales **********" ++@@ -247,8 +251,17 @@ ++ fi ++ ++ echo "// ${APP} finished installation of Arch system" ++ echo "//" +++ +++#run script to post-process the new installation +++if [ -f ${PROFILE}/post-process.sh ] +++then +++ ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} +++ echo ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} +++fi +++ +++ ++ if [ -z "${NOLIVE}" ]; then ++ # Get live CD build functions ++ . ${LARCHDATA}/buildlive ++ mklive +diff -Nur run.orig/mklarch run/mklarch +--- run.orig/mklarch 2008-08-10 10:51:15.000000000 +0000 ++++ run/mklarch 2008-08-29 02:29:45.000000000 +0000 +@@ -23,7 +23,6 @@ + #---------------------------------------------------------------------------- + # 2008.06.22 + +- + # directory to use for building the CD - the installation root + # It must have LOTS of space, ~ 4GB for a 700MB CD + INSTLDIR=/home/larchroot +@@ -163,6 +162,7 @@ + + for fd in $( ls -A ${INSTLDIR} ); do + rm -rf ${INSTLDIR}/${fd} ++#lookforme + done + mkdir -p ${LARCHBUILD} + +@@ -187,7 +187,6 @@ + fi + fi + INPACSO="${INPACSO} -k pacman.conf" +- + # If necessary add the larch repository to pacman.conf + if ! grep '^[larch5]' pacman.conf &>/dev/null; then + if [ -d larchrepo ]; then +@@ -199,12 +198,13 @@ + fi + larch5path="${larch5path}/${sysarch}" + fi +- sed "/\[testing\]/ i \ +-[larch5]\n\ +-Server = ${larch5path}\n\ +-#larch5---\n" -i pacman.conf ++ #sed "/\[testing\]/ i \ ++ echo "[larch5] " >> pacman.conf ++ echo "Server = ${larch5path}" >> pacman.conf + fi + ++ ++ + if ! which pacman &>/dev/null; then + if ! [ -x ${startdir}/pacman ]; then + echo "ERROR: Couldn't find pacman executable" +@@ -218,15 +218,19 @@ + + # Use build version of pacman.conf in live system, without [larch5] repository. + # This can be overwritten by a pacman.conf in the profile's overlay. ++ + rm -f ${INSTLDIR}/etc/pacman.conf +-if [ -f pacman.conf.0 ]; then ++if [ -f ${PROFILE}/pacman.conf ]; then + # This file should be used in preference to pacman.conf - it is created by + # larch-setup on non-Arch systems before commenting out the 'Include' lines. +- cp pacman.conf.0 ${INSTLDIR}/etc/pacman.conf ++ cp ${PROFILE}/pacman.conf ${INSTLDIR}/etc/pacman.conf + else + sed '/^\[larch5\]/,/^ *$/ d' <pacman.conf >${INSTLDIR}/etc/pacman.conf + fi + ++cachepacs -a ${PROFILE}/cache_packs $INPACSO -d ${INSTLDIR} ++ ++ + # Generate glibc locales + if [ -f ${PROFILE}/locale.gen ]; then + echo +@@ -248,6 +252,15 @@ + + echo "// ${APP} finished installation of Arch system" + echo "//" ++ ++#run script to post-process the new installation ++if [ -f ${PROFILE}/post-process.sh ] ++then ++ ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} ++ echo ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} ++fi ++ ++ + if [ -z "${NOLIVE}" ]; then + # Get live CD build functions + . ${LARCHDATA}/buildlive diff --git a/build_tools/clarch/larch/run/jams.larch.patch b/build_tools/clarch/larch/run/jams.larch.patch new file mode 100644 index 0000000..9a96d45 --- /dev/null +++ b/build_tools/clarch/larch/run/jams.larch.patch @@ -0,0 +1,110 @@ +Only in run/: cachepacs +diff -wU4 run.orig/inpacs run/inpacs +--- run.orig/inpacs 2008-08-10 10:51:15.000000000 +0000 ++++ run/inpacs 2008-08-29 02:29:31.000000000 +0000 +@@ -115,9 +115,9 @@ + VETOFILE="" + # Source directory for pacman database directories: + DBDIR="" + # pacman executable: +-PACMANX="pacman" ++PACMANX="pacman -f" + # pacman configuration file + PACMANK="/etc/pacman.conf" + + checkfile () +diff -wU4 run.orig/mklarch run/mklarch +--- run.orig/mklarch 2008-08-10 10:51:15.000000000 +0000 ++++ run/mklarch 2008-08-29 02:29:45.000000000 +0000 +@@ -22,9 +22,8 @@ + # + #---------------------------------------------------------------------------- + # 2008.06.22 + +- + # directory to use for building the CD - the installation root + # It must have LOTS of space, ~ 4GB for a 700MB CD + INSTLDIR=/home/larchroot + +@@ -162,8 +161,9 @@ + fi + + for fd in $( ls -A ${INSTLDIR} ); do + rm -rf ${INSTLDIR}/${fd} ++#lookforme + done + mkdir -p ${LARCHBUILD} + + ############### Call 'inpacs' to do the installation +@@ -186,9 +186,8 @@ + exit 1 + fi + fi + INPACSO="${INPACSO} -k pacman.conf" +- + # If necessary add the larch repository to pacman.conf + if ! grep '^[larch5]' pacman.conf &>/dev/null; then + if [ -d larchrepo ]; then + larch5path="file://$( readlink -f larchrepo )" +@@ -198,14 +197,15 @@ + sysarch="i686" + fi + larch5path="${larch5path}/${sysarch}" + fi +- sed "/\[testing\]/ i \ +-[larch5]\n\ +-Server = ${larch5path}\n\ +-#larch5---\n" -i pacman.conf ++ #sed "/\[testing\]/ i \ ++ echo "[larch5] " >> pacman.conf ++ echo "Server = ${larch5path}" >> pacman.conf + fi + ++ ++ + if ! which pacman &>/dev/null; then + if ! [ -x ${startdir}/pacman ]; then + echo "ERROR: Couldn't find pacman executable" + exit 1 +@@ -217,17 +217,21 @@ + if [ $? -ne 0 ]; then exit 1; fi + + # Use build version of pacman.conf in live system, without [larch5] repository. + # This can be overwritten by a pacman.conf in the profile's overlay. ++ + rm -f ${INSTLDIR}/etc/pacman.conf +-if [ -f pacman.conf.0 ]; then ++if [ -f ${PROFILE}/pacman.conf ]; then + # This file should be used in preference to pacman.conf - it is created by + # larch-setup on non-Arch systems before commenting out the 'Include' lines. +- cp pacman.conf.0 ${INSTLDIR}/etc/pacman.conf ++ cp ${PROFILE}/pacman.conf ${INSTLDIR}/etc/pacman.conf + else + sed '/^\[larch5\]/,/^ *$/ d' <pacman.conf >${INSTLDIR}/etc/pacman.conf + fi + ++cachepacs -a ${PROFILE}/cache_packs $INPACSO -d ${INSTLDIR} ++ ++ + # Generate glibc locales + if [ -f ${PROFILE}/locale.gen ]; then + echo + echo "********** Generating locales **********" +@@ -247,8 +251,17 @@ + fi + + echo "// ${APP} finished installation of Arch system" + echo "//" ++ ++#run script to post-process the new installation ++if [ -f ${PROFILE}/post-process.sh ] ++then ++ ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} ++ echo ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} ++fi ++ ++ + if [ -z "${NOLIVE}" ]; then + # Get live CD build functions + . ${LARCHDATA}/buildlive + mklive diff --git a/build_tools/clarch/larch/run/larchify b/build_tools/clarch/larch/run/larchify new file mode 100755 index 0000000..abc0c6d --- /dev/null +++ b/build_tools/clarch/larch/run/larchify @@ -0,0 +1,140 @@ +#! /bin/bash +# +# larchify +# +# 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.02.13 + +# Default target directory: +INSTLDIR=larchroot + +APP="$( basename $0 )" +# Get path to larch base directory, via the location of this script +FULLPATH="$( readlink -f $0 )" +SCRIPTDIR="$( dirname ${FULLPATH} )" +LARCHDATA="$( dirname ${SCRIPTDIR} )" + +startdir=$( pwd ) +# cd to ensure that the following test works even if '.' is in PATH +cd / +apppath="$( which ${APP} 2>/dev/null )" +if [ $? -ne 0 ] || [ "${apppath}" != "${FULLPATH}" ]; then + PATH=${SCRIPTDIR}:${PATH} +fi +cd ${startdir} + +usage () { + echo + echo "Usage:" + echo " ${APP} -h # Show this message" + echo + echo " ${APP} [-irugf] [-p <profile directory>] [<target directory>]" + echo + echo " -p Use the 'profile' in the given directory." + echo " The default is the directory 'profile' in the" + echo " current directory, if it exists. A build without" + echo " a profile is also, in principle, possible." + echo " -i Only rebuild iso (or install to USB-stick)," + echo " don't regenerate CD data" + echo + echo " -r Reuse old system and home sqfs" + echo " -u Don't build iso, but install to USB-stick instead" + echo " -g Use GRUB bootloader (default is isolinux/syslinux)" + echo + echo " -f No interaction. (not recommended)" + echo " The script will just plough straight on and destroy" + echo " your file-system without first asking." + echo + echo "${APP} builds a larch live CD / live USB-stick from the Arch Linux" + echo "installation in <target directory>. The default target directory" + echo "(which can also be a symlink) is 'larchroot' in the current" + echo "working directory." + echo + echo "A profile is a directory containing all the necessary" + echo "configuration details for a larch build. See documentation" + echo "and examples." + echo + exit +} + +PROFILE="" +DONTASK="" +USB="" +GRUB="" +REISO="" +REBUILD="" +REUSE="" +while getopts ":p:irugf" Option +do + case ${Option} in + p ) PROFILE="$( readlink -f ${OPTARG} )" ;; + i ) REISO="-i" ;; + r ) REUSE="-r" ;; + u ) USB="-u" ;; + g ) GRUB="-g" ;; + f ) DONTASK="-f" ;; + * ) usage ;; + esac +done +shift $((${OPTIND} - 1)) +if [ -n "$1" ]; then + INSTLDIR="$1" +fi + +if [ -d "${INSTLDIR}" ]; then + if [ "${INSTLDIR}" = "/" ]; then + INSTLDIR="" + else + INSTLDIR=$( readlink -f ${INSTLDIR} ) + fi +else + echo "ERROR: no target directory supplied" + usage +fi +LARCHBUILD="${INSTLDIR}/.larch" + +if [ -z "${PROFILE}" ]; then + if [ -d ${startdir}/profile ]; then + PROFILE=${startdir}/profile + elif [ -z "${DONTASK}" ]; then + read -p "// Build without a profile? [y/N]: " ans + # Await yes or no + if [ -z "$( echo ${ans} | grep '^ *[yY]' )" ]; then exit 0; fi + echo + fi +elif ! [ -d ${PROFILE} ]; then + echo "ERROR: profile '${PROFILE}' not found " + usage +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 + +# Get live CD build functions +. ${LARCHDATA}/buildlive + +if [ -n "${REISO}" ]; then + buildiso +else + mklive +fi diff --git a/build_tools/clarch/larch/run/mklarch b/build_tools/clarch/larch/run/mklarch new file mode 100755 index 0000000..2a1c574 --- /dev/null +++ b/build_tools/clarch/larch/run/mklarch @@ -0,0 +1,281 @@ +#! /bin/bash +# +# mklarch +# +# 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 + +# directory to use for building the CD - the installation root +# It must have LOTS of space, ~ 4GB for a 700MB CD +INSTLDIR=/home/larchroot + +# Default path to larch5 repositories (architecture is sub-directory) +larch5path="ftp://ftp.berlios.de/pub/larch/larch5.3" + +APP=$( basename $0 ) +# Get path to larch base directory, via the location of this script +FULLPATH=$( readlink -f $0 ) +SCRIPTDIR=$( dirname ${FULLPATH} ) +LARCHDATA=$( dirname ${SCRIPTDIR} ) + +startdir=$( pwd ) +# cd to ensure that the following test works even if '.' is in PATH +cd / +apppath="$( which ${APP} 2>/dev/null )" +if [ $? -ne 0 ] || [ "${apppath}" != "${FULLPATH}" ]; then + PATH=${SCRIPTDIR}:${PATH} +fi +cd ${startdir} + +usage () { + echo + echo "Usage:" + echo " ${APP} -h # Show this message" + echo + echo " ${APP} -a [-f] [-p <profile directory>]" + echo " [-c <package cache directory>]" + echo " [-y <path to pacman database directories>]" + echo " [<build directory>]" + echo + echo " ${APP} [-ugf] [-p <profile directory>]" + echo " [-c <package cache directory>]" + echo " [-y <path to pacman database directories>]" + echo " [<build directory>]" + echo + echo " -a Stop after installing Arch system (don't build live system)." + echo + echo " -p Use the 'profile' in the given directory." + echo + echo " -c Use an alternative package cache directory" + echo " (default is /var/cache/pacman/pkg, on host)" + echo " -y Use existing pacman package database instead" + echo " of performing 'pacman -Sy'." + echo + echo " -u Don't build iso, but install to USB-stick instead" + echo " -g Use GRUB bootloader (default is isolinux/syslinux)" + echo + echo " -f No interaction. (not recommended)" + echo " The script will just plough straight on and destroy" + echo " your file-system without first asking." + echo + echo "${APP} is the master script for the larch live CD / live USB-stick" + echo "builder." + echo + echo "<build directory> is the directory in which all the building will" + echo "be done, by default '${INSTLDIR}'" + echo + echo "A profile is a directory containing all the necessary" + echo "configuration details for a larch build. See documentation" + echo "and examples." + echo + echo "If you want to rebuild a live system without reinstalling it" + echo "(for example if you make minor changes to the profile which" + echo "don't affect the packages, or if you want a USB-stick instead" + echo "of a CD, or if writing to the USB-stick failed for some reason)" + echo "you should look at the 'larchify' script - run it with the '-h'" + echo "option for usage notes." + echo + exit +} + +pROFILE="" +DONTASK="" +NOLIVE="" +USB="" +GRUB="" +PKGCACHE=/var/cache/pacman/pkg +# Options to 'inpacs': +INPACSO="" +while getopts ":p:ac:y:ugf" Option +do + case ${Option} in + p ) PROFILE="$( readlink -f ${OPTARG} )" ;; + a ) NOLIVE="-a" ;; + c ) PKGCACHE="$( readlink -f ${OPTARG} )" ;; + y ) INPACSO="${INPACSO} -y $( readlink -f ${OPTARG} )" ;; + u ) USB="-u" ;; + g ) GRUB="-g" ;; + f ) DONTASK="-f" ;; + * ) usage ;; + esac +done +shift $((${OPTIND} - 1)) +if ! [ -d "${PKGCACHE}" ]; then + echo "Creating package cache: ${PKGCACHE}" + if ! mkdir -p "${PKGCACHE}"; then + echo "ERROR: Couldn't create ${PKGCACHE}" + exit 1 + fi +fi +INPACSO="${INPACSO} -c ${PKGCACHE}" + +if [ -n "$1" ]; then + INSTLDIR=$1 +fi +LARCHBUILD="${INSTLDIR}/.larch" + +if [ -z "${PROFILE}" ]; then + PROFILE=${startdir}/profile +fi +if ! [ -f ${PROFILE}/addedpacks ]; then + echo "ERROR: no 'addedpacks' in profile '${PROFILE}'" + exit 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 "//" +echo "// **********************************************************" +echo "// This will delete EVERYTHING under" +echo "//" +echo "// ${INSTLDIR}" +echo "//" + +if [ -z "${DONTASK}" ]; then + echo "// I really mean it ... Are you sure you want to do this?" + echo "// **********************************************************" + # Await yes or no + read -p "// [y/N]: " ans + if [ -z "$( echo ${ans} | grep '^ *[yY]' )" ]; then exit 0; fi +fi + +for fd in $( ls -A ${INSTLDIR} ); do + rm -rf ${INSTLDIR}/${fd} +#lookforme +done +mkdir -p ${LARCHBUILD} + +############### Call 'inpacs' to do the installation + +if [ -f ${PROFILE}/basepacks ]; then + INPACSO="${INPACSO} -b ${PROFILE}/basepacks" +fi + +if [ -f ${PROFILE}/baseveto ]; then + INPACSO="${INPACSO} -x ${PROFILE}/baseveto" +fi + +if [ -f ${PROFILE}/pacman.conf ]; then + cp ${PROFILE}/pacman.conf . +elif ! [ -f pacman.conf ]; then + if [ -f /etc/pacman.conf ]; then + cp /etc/pacman.conf . + else + echo "ERROR: Couldn't find pacman.conf" + exit 1 + fi +fi +INPACSO="${INPACSO} -k pacman.conf" +if [ x = y ] +then +# If necessary add the larch repository to pacman.conf +if ! grep '^[larch5]' pacman.conf &>/dev/null; then + if [ -d larchrepo ]; then + larch5path="file://$( readlink -f larchrepo )" + else + sysarch="$( uname -m )" + if [ "${sysarch}" != "x86_64" ]; then + sysarch="i686" + fi + larch5path="${larch5path}/${sysarch}" + fi + #sed "/\[testing\]/ i \ + echo "[larch5] " >> pacman.conf + echo "Server = ${larch5path}" >> pacman.conf +fi + +fi + +if ! which pacman &>/dev/null; then + if ! [ -x ${startdir}/pacman ]; then + echo "ERROR: Couldn't find pacman executable" + exit 1 + fi + INPACSO="${INPACSO} -P ${startdir}/pacman" +fi +echo "checking for pre_process.sh" +if [ -f ${PROFILE}/pre-process.sh ] +then + echo "Running pre-process script" + cd ${PROFILE} + ./pre-process.sh + cd - + +else + echo "No pre_process" +fi + +inpacs -a ${PROFILE}/addedpacks ${INPACSO} ${INSTLDIR} +if [ $? -ne 0 ]; then exit 1; fi + +# Use build version of pacman.conf in live system, without [larch5] repository. +# This can be overwritten by a pacman.conf in the profile's overlay. + +rm -f ${INSTLDIR}/etc/pacman.conf +if [ -f ${PROFILE}/pacman.conf ]; then + # This file should be used in preference to pacman.conf - it is created by + # larch-setup on non-Arch systems before commenting out the 'Include' lines. + cp ${PROFILE}/pacman.conf ${INSTLDIR}/etc/pacman.conf +else + sed '/^\[larch5\]/,/^ *$/ d' <pacman.conf >${INSTLDIR}/etc/pacman.conf +fi + +cachepacs -a ${PROFILE}/cache_packs $INPACSO -d ${INSTLDIR} + + +# Generate glibc locales +if [ -f ${PROFILE}/locale.gen ]; then + echo + echo "********** Generating locales **********" + echo + cat ${PROFILE}/locale.gen ${INSTLDIR}/etc/locale.gen >${INSTLDIR}/etc/locale.gen_new + mv -f ${INSTLDIR}/etc/locale.gen_new ${INSTLDIR}/etc/locale.gen + chroot ${INSTLDIR} usr/sbin/locale-gen +fi + +# Generate ssh keys +ssh_init ${INSTLDIR} + +# Set up a symlink to the installation for 'larchify' +rm -f larchroot && ln -sf ${INSTLDIR} ${startdir}/larchroot +if [ $? -ne 0 ]; then + echo "WARNING: Couldn't create 'larchroot' symlink" +fi + +echo "// ${APP} finished installation of Arch system" +echo "//" + +#run script to post-process the new installation +if [ -f ${PROFILE}/post-process.sh ] +then + ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} + echo ${PROFILE}/post-process.sh ${INSTLDIR} ${PROFILE} +fi + + +if [ -z "${NOLIVE}" ]; then + # Get live CD build functions + . ${LARCHDATA}/buildlive + mklive +fi diff --git a/build_tools/clarch/larch/run/myusbboot b/build_tools/clarch/larch/run/myusbboot new file mode 100644 index 0000000..29f2084 --- /dev/null +++ b/build_tools/clarch/larch/run/myusbboot @@ -0,0 +1,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" diff --git a/build_tools/clarch/larch/run/ssh_init b/build_tools/clarch/larch/run/ssh_init new file mode 100755 index 0000000..66a716f --- /dev/null +++ b/build_tools/clarch/larch/run/ssh_init @@ -0,0 +1,18 @@ +#! /bin/sh + +DESTDIR=$1 +echo +echo "************** Generating ssh keys to ${DESTDIR}/etc/ssh **************" +echo +# ssh initialisation - done here so that it doesn't need to be done +# when the cd boots +if [ -x ${DESTDIR}/usr/sbin/sshd ]; then + # Do it on the newly built system, in case the host doesn't have ssh + mount --bind /dev ${DESTDIR}/dev + chroot ${DESTDIR} bin/sh -c "{\ + /usr/bin/ssh-keygen -t rsa1 -N \"\" -f /etc/ssh/ssh_host_key >/dev/null;\ + /usr/bin/ssh-keygen -t rsa -N \"\" -f /etc/ssh/ssh_host_rsa_key >/dev/null;\ + /usr/bin/ssh-keygen -t dsa -N \"\" -f /etc/ssh/ssh_host_dsa_key >/dev/null;\ + }" + umount ${DESTDIR}/dev +fi diff --git a/build_tools/clarch/larch/run/usb2bootiso b/build_tools/clarch/larch/run/usb2bootiso new file mode 100755 index 0000000..cb2190a --- /dev/null +++ b/build_tools/clarch/larch/run/usb2bootiso @@ -0,0 +1,66 @@ +#!/bin/bash + +# usb2bootiso + +# For use after a completed run of mklarch or larchify which has produced +# a larch USB-stick with syslinux boot. It will generate a boot iso for +# use on computers which can't boot from the USB-stick. + +# $1 is the base of the 'livified' Arch installation (larchroot) +# If no path is given, a directory (or symlink) 'larchroot' in the +# working directory will be used. +#=================================================================== +# 2008.06.22 + +APP="$( basename $0 )" +# Get path to larch base directory, via the location of this script +FULLPATH="$( readlink -f $0 )" +SCRIPTDIR="$( dirname ${FULLPATH} )" + +mkiso () +{ + mkisofs -r -l $1 \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + -input-charset=UTF-8 \ + -publisher "designed by gradgrind, licence: GPL" \ + -A "larch-5" \ + -o "bootcd.iso" "${CDDATA}" + + if [ $? -eq 0 ]; then + echo "// Your ISO has been created as bootcd.iso" + else + echo "ERROR: iso build failed" 1>&2 + return 1 + fi +} + +if [ -z "$1" ]; then + if [ -d larchroot ]; then + MP="$( readlink -f larchroot )" + else + echo "Must pass Arch root directory as argument" + exit 1 + fi +else + if ! [ -d $1 ]; then + echo "$1 is not a directory" + exit 1 + fi + MP="$( readlink -f $1 )" +fi + +CDDATA=$( pwd )/bootcd +rm -rf ${CDDATA} +mkdir -p ${CDDATA}/isolinux + +if ! cp -r ${MP}/.larch/cd/isolinux ${CDDATA} &>/dev/null; then + echo "No larch boot files found at ${MP}/.larch/cd/isolinux" + exit 1 +fi +if ! cp ${MP}/usr/lib/syslinux/isolinux.bin ${CDDATA}/isolinux; then + echo "Couldn't find isolinux.bin" + exit 1 +fi + +mkiso "-b isolinux/isolinux.bin -c isolinux/isolinux.boot" + diff --git a/build_tools/clarch/larch/run/usb2iso b/build_tools/clarch/larch/run/usb2iso new file mode 100755 index 0000000..885f726 --- /dev/null +++ b/build_tools/clarch/larch/run/usb2iso @@ -0,0 +1,78 @@ +#!/bin/sh + +# usb2iso + +# For use (especially) after a usb-stick larch system (syslinux based +# only at the moment) has been modified, this will generate a bootable +# iso from it. + +# WARNING - a lot of space is needed as the whole cd content must be copied. + +# $1 is the mount point of the usb-stick. If none use /.livesys/medium +# (i.e. assuming it is being run from a larch system). +# The iso will be generated in the current working directory. +#=================================================================== +# 2008.04.21 + +ISOLINUXBIN=/usr/lib/syslinux/isolinux.bin + +APP="$( basename $0 )" +# Get path to larch base directory, via the location of this script +FULLPATH="$( readlink -f $0 )" +SCRIPTDIR="$( dirname ${FULLPATH} )" + +mkiso () +{ + mkisofs -r -l $1 \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + -input-charset=UTF-8 \ + -publisher "designed by gradgrind, licence: GPL" \ + -A "larch-5" \ + -o "livecd.iso" "${CDDATA}" + + if [ $? -eq 0 ]; then + echo "// Your ISO has been created as livecd.iso" + else + echo "ERROR: iso build failed" 1>&2 + return 1 + fi +} + +if [ -z "$1" ]; then + if [ -d /.livesys/medium/larch ]; then + MP=/.livesys/medium + else + echo "Must pass usb-stick mount-point as argument" + exit 1 + fi +else + if ! [ -d "$1/larch" ]; then + echo "No larch system found at $1" + exit 1 + fi + MP="$( readlink -f $1 )" +fi + +CDDATA=$( pwd )/bootcd +rm -rf ${CDDATA} +mkdir -p ${CDDATA} + +if ! cp -r ${MP}/syslinux ${CDDATA} &>/dev/null; then + echo "No larch boot files found at ${MP}/syslinux" + exit 1 +fi +mv ${CDDATA}/syslinux ${CDDATA}/isolinux +mv ${CDDATA}/isolinux/syslinux.cfg ${CDDATA}/isolinux/isolinux.cfg +if ! cp ${ISOLINUXBIN} ${CDDATA}/isolinux; then + echo "Couldn't find isolinux.bin" + exit 1 +fi + +echo "Copying data, this could take a while" +cp -r ${MP}/larch ${CDDATA} +cp ${MP}/system.sqf ${CDDATA} +cp ${MP}/mods.sqf ${CDDATA} +cp ${MP}/overlay.ovl ${CDDATA} + +mkiso "-b isolinux/isolinux.bin -c isolinux/isolinux.boot" + diff --git a/build_tools/clarch/larch/run/usbboot b/build_tools/clarch/larch/run/usbboot new file mode 100755 index 0000000..dd7f3fe --- /dev/null +++ b/build_tools/clarch/larch/run/usbboot @@ -0,0 +1,100 @@ +#! /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 + +STARTDIR=${2} + +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 files" +stick=/tmp/usbstick +if [ -d ${stick} ] +then + echo "removing $stick" + 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* + +#copy in the important stuff +cp -a ${AINSTALL}/usr/lib/syslinux/* ${stick}/syslinux +cp -a ${AINSTALL}/usr/bin/syslinux ${stick}/syslinux/syslinux +cp -a ${STARTDIR}/bootusb/* ${stick}/syslinux + +echo "copy ${stick}/* to a usb drive and run syslinux/bootinst.sh" + + + diff --git a/build_tools/clarch/larch/run/usbboot.orig b/build_tools/clarch/larch/run/usbboot.orig new file mode 100755 index 0000000..b1f41b4 --- /dev/null +++ b/build_tools/clarch/larch/run/usbboot.orig @@ -0,0 +1,155 @@ +#! /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 + +echo "//" +echo "// **********************************************************" +echo "//" +echo "// ${APP} will prepare a bootable USB stick with your" +echo "// previously prepared larch data from ${CDDATA}" +echo "//" +echo "// Please insert your USB stick, which should already be" +echo "// appropriately partitioned." +echo "//" +echo "// **********************************************************" +echo "//" + +# 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 "// Do you want to continue?" +# Await yes or no +read -p "// [y/N]: " ans +if [ -z "`echo ${ans} | grep '^ *[yY]'`" ]; then exit 2; fi + +echo "//" +echo "// Enter the number of the partition you wish to use (0 to quit):" + +devices=/tmp/devices$$ +:> ${devices} +i=0 +sfdisk -d | grep "/dev/sd[a-z][1-4] " | grep -v "Id= [05]" | \ + sed "s|\(.*\):.*size=\( *[0-9]*\).*|\1 \2|" | while read device sectors; do + + i=$(( ${i} + 1 )) + echo "${device}" >>${devices} + echo "// ${i}: ${device} $(( ${sectors} / 2048 )) MiB" +done + +while true; do + read -p "// Device: " d + if [ "${d}" -eq "0" ]; then exit 1; fi + i=0 + { while read device; do + i=$(( ${i} + 1 )) + if [ "${d}" -eq "${i}" ]; then break 2; fi + done } <${devices} +done + +rm ${devices} + +echo "//" +read -p "// \"${device}\" will now be prepared. Continue? [y/N]: " ans +if [ -z "`echo ${ans} | grep '^ *[yY]'`" ]; then exit 1; fi + +echo "//" +echo "// Formatting ${device} (vfat)" +dev=${device:0:8} +part=${device:8} +sfdisk ${dev} -N${part} <<EOF +,,0e,* +EOF + +dd if=/dev/zero of=${device} bs=512 count=1 +mkfs.vfat ${device} + +echo "// Copying the boot sector" +dd if=${AINSTALL}/usr/lib/syslinux/mbr.bin of=${dev} + +echo "// Copying the files" +stick=/tmp/mnt +mkdir -p ${stick} +umount ${device} &>/dev/null +mount ${device} ${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* + +umount ${stick} + +echo "// Running syslinux" +if [ -n "${AINSTALL}" ]; then + mount --bind /dev ${AINSTALL}/dev + mount --bind /proc ${AINSTALL}/proc + chroot ${AINSTALL} syslinux ${device} + umount ${AINSTALL}/dev + umount ${AINSTALL}/proc +else + syslinux ${device} +fi + +echo "//" +echo "// Done!" +echo "// If all went well your usb stick should now be a bootable larch system" diff --git a/build_tools/clarch/larch/run/usbboot_grub b/build_tools/clarch/larch/run/usbboot_grub new file mode 100755 index 0000000..2f837d5 --- /dev/null +++ b/build_tools/clarch/larch/run/usbboot_grub @@ -0,0 +1,180 @@ +#! /bin/bash +# +# usbboot_grub +# +# 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 )" + if [ ! -x ${AINSTALL}/sbin/grub ]; then + echo "ERROR: ${AINSTALL}/sbin/grub not found" + exit 1 + fi +else + AINSTALL="" + if ! which grub &>/dev/null; then + echo "ERROR: grub not found" + exit 1 + fi +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}/boot/grub/stage1 ]; then + echo "ERROR: grub data not in ${CDDATA}/boot/grub" + exit 1 +fi + +echo "//" +echo "// **********************************************************" +echo "//" +echo "// ${APP} will prepare a bootable USB stick with your" +echo "// previously prepared larch data from ${CDDATA}" +echo "//" +echo "// As an alternative it might render your system unbootable." +echo "// If that thought disturbs you please don't continue." +echo "//" +echo "// This program is DANGEROUS - you have been warned!!!" +echo "//" +echo "// If you are too cool to be concerned about the warnings," +echo "// please insert your USB stick, which should already be" +echo "// appropriately partitioned." +echo "//" +echo "// **********************************************************" +echo "//" + +# 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 "//" +echo "// Enter the number of the partition you wish to use (0 to quit):" + +devices=/tmp/devices$$ +:> ${devices} +i=0 +sfdisk -d | grep "/dev/sd[a-z][1-4] " | grep -v "Id= [05]" | \ + sed "s|\(.*\):.*size=\( *[0-9]*\).*|\1 \2|" | while read device sectors; do + + i=$(( ${i} + 1 )) + echo "${device}" >>${devices} + echo "// ${i}: ${device} $(( ${sectors} / 2048 )) MiB" +done + +while true; do + read -p "// Device: " d + if [ "${d}" -eq "0" ]; then exit 1; fi + i=0 + { while read device; do + i=$(( ${i} + 1 )) + if [ "${d}" -eq "${i}" ]; then break 2; fi + done } <${devices} +done + +rm ${devices} + +echo "//" +read -p "// \"${device}\" will now be prepared. Continue? [y/N]: " ans +if [ -z "`echo ${ans} | grep '^ *[yY]'`" ]; then exit 1; fi + +echo "//" +echo "// Formatting ${device} (ext2)" +dev=${device:0:8} +part=${device:8} +sfdisk ${dev} -N${part} <<EOF +,,L,* +EOF + +mke2fs ${device} + +echo "// Copying the files" +stick=/tmp/mnt +mkdir -p ${stick} +umount ${device} &>/dev/null +mount ${device} ${stick} +if [ $? != 0 ]; then + echo "ERROR: Failed to mount device, quitting" + exit 3 +fi +cp -a ${CDDATA}/* ${stick} +umount ${stick} + +# Convert the device and partion to grub syntax +grubdevice () +{ +## The contents of device.map look something like this: +#(fd0) /dev/fd0 +#(hd0) /dev/hda +#(hd1) /dev/sda +gdev="$( cat ${AINSTALL}${dmap} | grep "${dev}" | cut -f1 | tr -d "()" )" +gpart=$(( ${part} - 1 )) +echo "// Installing GRUB to (${gdev}), root (${gdev},${gpart})" +} + +dmap=/tmp/device.map +rm -f ${AINSTALL}${dmap} +if [ -n "${AINSTALL}" ]; then + # First try to get a device mapping + mount --bind /dev ${AINSTALL}/dev + echo "quit" | chroot ${AINSTALL} grub --no-floppy --device-map=${dmap} --batch + grubdevice + # Now actually install grub + # As far as I can tell, the extra options to grub are not needed here + chroot ${AINSTALL} grub --batch <<EOT +root (${gdev},${gpart}) +setup (${gdev}) +quit +EOT + umount ${AINSTALL}/dev +else + # First try to get a device mapping + echo "quit" | grub --no-floppy --device-map=${dmap} --batch + grubdevice + # Now actually install grub + # As far as I can tell, the extra options to grub are not needed here + grub --batch <<EOT +root (${gdev},${gpart}) +setup (${gdev}) +quit +EOT +fi +rm -f ${AINSTALL}${dmap} + +echo "//" +echo "// Done!" +echo "// If all went well your usb stick should now be a bootable larch system" diff --git a/build_tools/clarch/larch/run/xpack b/build_tools/clarch/larch/run/xpack new file mode 100755 index 0000000..0ebe158 --- /dev/null +++ b/build_tools/clarch/larch/run/xpack @@ -0,0 +1,122 @@ +#! /bin/bash +# +# xpack - simple tool for handling self-extracting archives +# +# Author: Michael Towers <gradgrind[at]online[dot]de> +# +# xpack 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. +# +# xpack 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 xpack; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +#---------------------------------------------------------------------------- +# +# version 1.1 + +# This script serves both as packer and extracter, according to the name used +# to invoke it. When invoked as 'xpack', it will copy itself to the archive +# file (passed on the command line) and then append a tar.gz archive of the +# source directory (passed on the command line). E.g. +# ./xpack path/to/archive xarchive +# To extract the archive, simply run the resulting archive file, passing a +# directory into which it should be unpacked on the command line. E.g. +# ./xarchive newpath/to/directory +# or, bash xarchive newpath/to/directory + +if [ "$( basename "$0" )" != "xpack" ]; then + # extract archive + if [ ! -d "$1" ]; then + echo "ERROR: Destination directory not found" + echo "Usage:" + echo " ${APP} <directory> - Unpack this archive to <directory> (which must exist)" + exit 1 + fi + +# The following lines allow the implementation of the '-r' option to xpack. +# The version of this script which is copied to the generated archive file will, +# in that case, have the '#+#' removed. +#+# # test if the script is started by root user. If not, exit +#+# if [ $UID -ne 0 ]; then +#+# echo "Only root can run $0"; exit 1 +#+# fi + + echo "Extracting archive to $1" + let "SKIP = $( grep --binary-files=text -n -m 1 "^#__ARCHIVE__" "$0" | cut -d ':' -f 1 ) + 1" + + tail -n +$SKIP "$0" | tar -xzC "$1" + exit 0 +fi + +usage () { + echo + echo "Usage:" + echo " ${APP} [-dr] <directory> <archive file>" + echo " Create self-extracting archive from <directory>" + echo + echo " -d Don't include the base directory" + echo " -r Require root permissions for extracting" + echo + exit 1 +} + +NOBASE="" +ROOT="" +while getopts ":dr" Option +do + case ${Option} in + d ) NOBASE="-d" ;; + r ) ROOT="-r" ;; + * ) usage ;; + esac +done +shift $((${OPTIND} - 1)) + +if [ ! -d "$1" ]; then + echo "ERROR: Source directory not found" + usage +fi + +if [ -e "$2" ]; then + echo "ERROR: Destination file exists" + usage +fi + +cp $0 $2 +if [ $? -ne 0 ]; then + echo "ERROR: Cannot write to destination file" + usage +fi + +if [ -n "${ROOT}" ]; then + if [ $UID -ne 0 ]; then + echo "Only root can use the -r opton" + exit 1 + fi + sed -i 's|^#+#||g' $2 +fi + +DIR="$( readlink -f $1 )" +BASE="." +if [ -z "${NOBASE}" ]; then + DIR="$( dirname ${DIR} )" + if [ $? -ne 0 ]; then echo "dirname -f ${DIR} ... failed"; usage; fi + BASE="$( basename $1 )" +fi + +# tar to standard output adds a load of nulls to the output, +# which is a bit untidy and results in warnings, so do it this way: +tar czf $2_ -C ${DIR} ${BASE} +cat $2_ >> $2 +rm $2_ + +# DO NOT delete the next line, which MUST be the last line of 'xpack' +#__ARCHIVE__ |