aboutsummaryrefslogtreecommitdiff
path: root/examples/lvmpbuilder/lib/lvmbuilder-modules
blob: 8857f09043559d5c3c97ce6a9e62019254446c7b (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
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
#! /bin/bash
# The functions used to mount and unmount the filesystems for lvmbuilder
#   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

# lvmbuilder by Kapil Hari Paranjape <kapil@debian.org> 2007 Aug 15
# pbuilder by Junichi Uekawa <dancer@debian.org> 2001 Aug 25

set -e 

function clean_basedev(){
    	echo -n "This will wipe out $BASEDEV. Proceed?[y/N]"
    	read ans
    	if [ "$ans" != "y" -a "$ans" != "Y" ] 
    	then
    		exit 0
	fi
    	echo "Making new file system at $BASEDEV."
	mke2fs $BASEDEV
}

function unmount_basedev(){
	umount $BASEDEV
	e2fsck -f -v $BASEDEV
}

function setup_workplace(){
	# Size computations
	BASESIZE=$(blockdev --getsize $BASEDEV)
	COWSIZE=$(blockdev --getsize $COWDEV)
	TOTAL=$[ $COWSIZE + $BASESIZE ]

	# Load the necessary modules
	modprobe dm_zero dm_mirror dm_snapshot dm_mod

	## Create the total base device
	# It consists of the base device extended by zeroes.
	# The length of the zeroes is the size of the cow.
	( echo 0 $BASESIZE linear $BASEDEV 0 ; \
	  echo $BASESIZE $COWSIZE zero ) | \
	  dmsetup create $TOTALNAME

	## Create the work device
	# It is the snapshot device with the all writes
	# going to the cow device. The file-system is resized
	# to the maximum extent possible.
	echo 0 $TOTAL snapshot $TOTALDEV $COWDEV n 16 | \
	  dmsetup create $WORKNAME

	[ -b $WORKDEV ] && resize2fs $WORKDEV
    	mount $WORKDEV $BUILDPLACE
}

function takedown_workplace(){
	umount /dev/mapper/lvmbuilder-work
	dmsetup remove lvmbuilder-work
	dmsetup remove lvmbuilder-total
}

function showhelp(){
    cat <<EOF
lvmbuilder - Debian package builder using pbuilder and lvm
Copyright 2007 Kapil Hari Paranjape
Based on:
pbuilder - a personal builder
Copyright 2001-2006 Junichi Uekawa
Distributed under GNU Public License version 2 or later

lvmbuilder [operation] [lvmbuilder-options]

command lines:
lvmbuilder create [--basedev base-device-path] [--distribution sarge|etch|sid|experimental]
  Creates a base distribution on an ext2 filesystem on the base block device 

lvmbuilder update [--basedev base-device-path] [--distribution sarge|etch|sid|experimental]
  Updates a base distribution on an ext2 filesystem on the base block device

lvmbuilder build [--basedev base-device-path] [--cowdev cow-device-path] pkgsrc.dsc
  Builds using the base distribution with all writes going to cow block device.
  Requires a .dsc filename

lvmbuilder clean [--basedev base-device-path]
  Creates a fresh ext2fs file system on the base block device.

lvmbuilder login
lvmbuilder execute -- [command] [command-options]
  Logs in to the build environment and execute command.

lvmbuilder dumpconfig
  Dumps configuration information to stdout for debugging.

lvmbuilder-options:
 --basedev [base device location]
 --cowdev [cow device location]
 --buildplace [location of build]
 --mirror [mirror location]
 --othermirror [other mirror location in apt deb-line format, delimited with | signs]
 --http-proxy [proxy]
 --distribution [distribution(sarge|sid|etch|experimental)]
 --buildresult [location-to-copy-build-result]
 --aptcache [location of retrieved package files]
 --removepackages [packages-to-remove on pbuilder create]
 --extrapackages [packages-to-add on pbuilder create]
 --configfile [configuration file to load]
 --debemail [mail address]
 --debbuildopts [dpkg-buildpackage options]
 --logfile [filename to output log]
 --pkgname-logfile
 --aptconfdir [overriding apt config dir]
 --timeout [timeout time]
 --override-config 
 --binary-arch
 --debug
 --autocleanaptcache
 --debootstrapopts [debootstrap options]
 --debootstrap [debootstrap|cdebootstrap]

EOF
    exit 1
}