| 1 |
#! /bin/bash |
| 2 |
# this is sourced from lvmbuilder to process the optional parameters. |
| 3 |
# lvmbuilder -- Debian package builder using LVM |
| 4 |
# Copyright (C) 2007 Kapil Hari Paranjape |
| 5 |
# based on: |
| 6 |
# pbuilder -- personal Debian package builder |
| 7 |
# Copyright (C) 2001-2006 Junichi Uekawa |
| 8 |
# |
| 9 |
# This program is free software; you can redistribute it and/or modify |
| 10 |
# it under the terms of the GNU General Public License as published by |
| 11 |
# the Free Software Foundation; either version 2 of the License, or |
| 12 |
# (at your option) any later version. |
| 13 |
# |
| 14 |
# This program is distributed in the hope that it will be useful, |
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
# GNU General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU General Public License |
| 20 |
# along with this program; if not, write to the Free Software |
| 21 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 |
|
| 23 |
|
| 24 |
# We check all the parameters that are relevant to us |
| 25 |
# and add the rest to the pbuilder command line to |
| 26 |
# be used to call pbuilder |
| 27 |
. /usr/lib/pbuilder/pbuilder-loadconfig |
| 28 |
. $LVMBLIB/lvmbuilder-unimplemented |
| 29 |
|
| 30 |
|
| 31 |
# Storage for the command line |
| 32 |
declare -a PBCMDLINE |
| 33 |
|
| 34 |
# The devices |
| 35 |
TOTALNAME=lvmbuilder-total |
| 36 |
TOTALDEV=/dev/mapper/$TOTALNAME |
| 37 |
WORKNAME=lvmbuilder-work |
| 38 |
WORKDEV=/dev/mapper/$WORKNAME |
| 39 |
|
| 40 |
while [ -n "$1" ]; do |
| 41 |
case "$1" in |
| 42 |
# First the meaningful options |
| 43 |
--basedev) |
| 44 |
BASEDEV="$2"; |
| 45 |
shift; shift; |
| 46 |
;; |
| 47 |
--cowdev) |
| 48 |
COWDEV="$2"; |
| 49 |
shift; shift; |
| 50 |
;; |
| 51 |
--buildplace) |
| 52 |
BUILDPLACE="$2"; |
| 53 |
shift; shift; |
| 54 |
;; |
| 55 |
--debug) |
| 56 |
PBCMDLINE+=("--debug"); |
| 57 |
set -x; |
| 58 |
shift; |
| 59 |
;; |
| 60 |
--configfile) |
| 61 |
if [ ! -f "$2" ]; then |
| 62 |
echo "E: Config file $2 does not exist" >&2 |
| 63 |
exit 1 |
| 64 |
fi |
| 65 |
. "$2"; |
| 66 |
PBCMDLINE+=("--configfile" "$2"); |
| 67 |
shift; shift; |
| 68 |
;; |
| 69 |
# We also grab those options that are likely to be meaningless with |
| 70 |
# lvmbuilder |
| 71 |
--basetgz) |
| 72 |
BASETGZ="$2"; |
| 73 |
warn_option $1; |
| 74 |
shift; shift; |
| 75 |
;; |
| 76 |
--hookdir) |
| 77 |
HOOKDIR="$2"; |
| 78 |
warn_option $1; |
| 79 |
shift; shift; |
| 80 |
;; |
| 81 |
--preserve-buildplace) |
| 82 |
PRESERVE_BUILDPLACE="yes" |
| 83 |
warn_option $1; |
| 84 |
shift; |
| 85 |
;; |
| 86 |
--bindmounts) |
| 87 |
BINDMOUNTS="${BINDMOUNTS} $2" |
| 88 |
warn_option $1; |
| 89 |
shift; shift; |
| 90 |
;; |
| 91 |
--save-after-login|--save-after-exec) |
| 92 |
SAVE_AFTER_LOGIN=yes; |
| 93 |
warn_option $1; |
| 94 |
shift; |
| 95 |
;; |
| 96 |
--internal-chrootexec) |
| 97 |
CHROOTEXEC="$2" |
| 98 |
warn_option $1; |
| 99 |
shift; shift; |
| 100 |
;; |
| 101 |
--internal-build-uml) |
| 102 |
INTERNAL_BUILD_UML="yes" |
| 103 |
IGNORE_UMOUNT="no" |
| 104 |
warn_option $1; |
| 105 |
shift; |
| 106 |
;; |
| 107 |
--|*.dsc) |
| 108 |
break; |
| 109 |
;; |
| 110 |
*) |
| 111 |
PBCMDLINE+=("$1"); |
| 112 |
shift; |
| 113 |
;; |
| 114 |
esac |
| 115 |
done |
| 116 |
|
| 117 |
# Add a no-targz option at the end of the cmdline to override |
| 118 |
# any conflicting options set by the user |
| 119 |
PBCMDLINE+=("--no-targz"); |
| 120 |
|
| 121 |
# These variables must be defined properly in order for us to proceed! |
| 122 |
BUILDPLACE=${BUILDPLACE:?"E: Build root directory is not defined"} |
| 123 |
if [ ! -d "$BUILDPLACE" ] ; then |
| 124 |
echo "E: Directory $2 does not exist" >&2 |
| 125 |
exit 1 |
| 126 |
else |
| 127 |
BUILDPLACE=$(readlink -f "$BUILDPLACE") |
| 128 |
PBCMDLINE+=("--buildplace" "$BUILDPLACE") |
| 129 |
fi |
| 130 |
BASEDEV=${BASEDEV:?"E: Base device is not defined"} |
| 131 |
if [ ! -b "$BASEDEV" ] ; then |
| 132 |
echo "E: Base device is not a block device" >&2 |
| 133 |
exit 1 |
| 134 |
else |
| 135 |
BASEDEV=$(readlink -f "$BASEDEV") |
| 136 |
fi |
| 137 |
COWDEV=${COWDEV:?"E: Cow device is not defined"} |
| 138 |
if [ ! -b "$COWDEV" ]; then |
| 139 |
echo "E: Cow device is not a block device" >&2 |
| 140 |
exit 1 |
| 141 |
else |
| 142 |
COWDEV=$(readlink -f "$COWDEV") |
| 143 |
fi |
| 144 |
|
| 145 |
PBCMDLINE+=("$@") |
| 146 |
|