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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#! /bin/bash
# this is sourced from lvmbuilder to process the optional parameters.
# lvmbuilder -- Debian package builder using LVM
# Copyright (C) 2007 Kapil Hari Paranjape
# based on:
# pbuilder -- personal Debian package builder
# Copyright (C) 2001-2006 Junichi Uekawa
#
# This program 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.
#
# This program 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 program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# We check all the parameters that are relevant to us
# and add the rest to the pbuilder command line to
# be used to call pbuilder
. /usr/lib/pbuilder/pbuilder-loadconfig
. $LVMBLIB/lvmbuilder-unimplemented
# Storage for the command line
declare -a PBCMDLINE
# The devices
TOTALNAME=lvmbuilder-total
TOTALDEV=/dev/mapper/$TOTALNAME
WORKNAME=lvmbuilder-work
WORKDEV=/dev/mapper/$WORKNAME
while [ -n "$1" ]; do
case "$1" in
# First the meaningful options
--basedev)
BASEDEV="$2";
shift; shift;
;;
--cowdev)
COWDEV="$2";
shift; shift;
;;
--buildplace)
BUILDPLACE="$2";
shift; shift;
;;
--debug)
PBCMDLINE+=("--debug");
set -x;
shift;
;;
--configfile)
if [ ! -f "$2" ]; then
echo "E: Config file $2 does not exist" >&2
exit 1
fi
. "$2";
PBCMDLINE+=("--configfile" "$2");
shift; shift;
;;
# We also grab those options that are likely to be meaningless with
# lvmbuilder
--basetgz)
BASETGZ="$2";
warn_option $1;
shift; shift;
;;
--hookdir)
HOOKDIR="$2";
warn_option $1;
shift; shift;
;;
--preserve-buildplace)
PRESERVE_BUILDPLACE="yes"
warn_option $1;
shift;
;;
--bindmounts)
BINDMOUNTS="${BINDMOUNTS} $2"
warn_option $1;
shift; shift;
;;
--save-after-login|--save-after-exec)
SAVE_AFTER_LOGIN=yes;
warn_option $1;
shift;
;;
--internal-chrootexec)
CHROOTEXEC="$2"
warn_option $1;
shift; shift;
;;
--internal-build-uml)
INTERNAL_BUILD_UML="yes"
IGNORE_UMOUNT="no"
warn_option $1;
shift;
;;
--|*.dsc)
break;
;;
*)
PBCMDLINE+=("$1");
shift;
;;
esac
done
# Add a no-targz option at the end of the cmdline to override
# any conflicting options set by the user
PBCMDLINE+=("--no-targz");
# These variables must be defined properly in order for us to proceed!
BUILDPLACE=${BUILDPLACE:?"E: Build root directory is not defined"}
if [ ! -d "$BUILDPLACE" ] ; then
echo "E: Directory $2 does not exist" >&2
exit 1
else
BUILDPLACE=$(readlink -f "$BUILDPLACE")
PBCMDLINE+=("--buildplace" "$BUILDPLACE")
fi
BASEDEV=${BASEDEV:?"E: Base device is not defined"}
if [ ! -b "$BASEDEV" ] ; then
echo "E: Base device is not a block device" >&2
exit 1
else
BASEDEV=$(readlink -f "$BASEDEV")
fi
COWDEV=${COWDEV:?"E: Cow device is not defined"}
if [ ! -b "$COWDEV" ]; then
echo "E: Cow device is not a block device" >&2
exit 1
else
COWDEV=$(readlink -f "$COWDEV")
fi
PBCMDLINE+=("$@")
|