Added a logfile from F-10 install
[febootstrap.git] / febootstrap-run.sh
1 #!/bin/bash -
2 # febootstrap-run
3 # (C) Copyright 2009 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 # Written by Richard W.M. Jones <rjones@redhat.com>
20
21 TEMP=`getopt \
22         -o g:i: \
23         --long help,ro \
24         -n febootstrap-run -- "$@"`
25 if [ $? != 0 ]; then
26     echo "febootstrap-run: problem parsing the command line arguments"
27     exit 1
28 fi
29 eval set -- "$TEMP"
30
31 readonly=no
32
33 usage ()
34 {
35     echo "Usage: febootstrap-run [--options] DIR [CMD]"
36     echo "Please read febootstrap-run(8) man page for more information."
37 }
38
39 while true; do
40     case "$1" in
41         --ro)
42             readonly=yes
43             shift;;
44         --help)
45             usage
46             exit 0;;
47         --)
48             shift
49             break;;
50         *)
51             echo "Internal error!"
52             exit 1;;
53     esac
54 done
55
56 if [ $# -lt 1 ]; then
57     usage
58     exit 1
59 fi
60
61 target="$1"
62 shift
63
64 if [ ! -f "$target"/fakeroot.log ]; then
65     echo "febootstrap-run: $target: not a root filesystem"
66     exit 1
67 fi
68
69 if [ "$readonly" = "no" ]; then
70     fakeroot -i "$target"/fakeroot.log -s "$target"/fakeroot.log \
71         fakechroot -s \
72         chroot "$target" "$@"
73 else
74     fakeroot -i "$target"/fakeroot.log \
75         fakechroot -s \
76         chroot "$target" "$@"
77 fi