aboutsummaryrefslogtreecommitdiff
path: root/pbuilder-modules
blob: 372aaf8bfc25f80990f94859a687022b6eeb2339 (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
#! /bin/bash
# common modules for pbuilder.

function showhelp () {
    cat <<EOF
pbuilder - a personal builder
Copyright 2001 Junichi Uekawa
Distributed under GNU Public License version 2 or later

pbuilder [operation] [operation options]

command lines:
pbuilder create [--basetgz base.tgz-path] [--distribution woody|sid]
  Creates a base.tgz

pbuilder update [--basetgz base.tgz-path] [--distribution woody|sid]
  Updates a base.tgz

pbuilder build [--basetgz base.tgz-path] pbuilder_2.2.0-1.dsc
  Builds using the base.tgz. Requires a .dsc filename

pbuilder clean
  Cleans the temporal build directory.

pbuilder login
  Logs in to the build environment

Operation Options:
 --basetgz [base.tgz location]
 --buildplace [location of build]
 --mirror [mirror location]
 --nonusmirror [non-US mirror location]
 --othermirror [other mirror location in apt deb-line format, delimited with | signs]
 --http-proxy [proxy]
 --distribution [distribution(potato/woody/sid)]
 --buildresult [location-to-copy-build-result]
EOF
    exit 1
}

function umountproc () {
    if [ "$USEPROC" = "yes" ]; then
	echo " -> unmounting proc"
	umount "$BUILDPLACE/proc"
    fi
}

function mountproc () {
    if [ "$USEPROC" = "yes" ]; then
	echo " -> mounting proc"
	mkdir -p $BUILDPLACE/proc
	mount -t proc /proc "$BUILDPLACE/proc"
    fi
}

function cleanbuildplace () {
    if [ -d "$BUILDPLACE" ]; then 
	echo cleaning the build env
	rm -rf "$BUILDPLACE"
    fi;
}

function abortingfunction () {
    # rolling back to abort.
    umountproc
    cleanbuildplace
}

function installaptlines (){
    echo Installing apt-lines
    rm "$BUILDPLACE"/etc/apt/sources.list
    test -n "$DISTRIBUTION" && (
	echo "Distribution not specified, please specify" >&2
	exit 1
    )
    if [ -n "$BUILDPLACE" ] ; then
	cat >> "$BUILDPLACE"/etc/apt/sources.list << EOF
deb $MIRRORSITE $DISTRIBUTION main contrib non-free
deb-src $MIRRORSITE $DISTRIBUTION main contrib non-free
EOF
    fi
    if [ -n "$NONUSMIRRORSITE" ]; then 
	cat  >> "$BUILDPLACE"/etc/apt/sources.list << EOF
deb $NONUSMIRRORSITE $DISTRIBUTION/non-US main contrib non-free
deb-src $NONUSMIRRORSITE $DISTRIBUTION/non-US main contrib non-free
EOF
    fi
    if [ -n "$OTHERMIRROR" ]; then 
	echo "$OTHERMIRROR" | tr "|" "\n" >> "$BUILDPLACE"/etc/apt/sources.list 
    fi
    
}

function extractbuildplace () {
    # after calling this function, umountproc, and cleanbuildplace
    # needs to be called. 
    cleanbuildplace
    echo "building the build env"
    echo " -> extracting base.tgz"
    mkdir -p "$BUILDPLACE"
    (cd "$BUILDPLACE" && tar xfzp "$BASETGZ")
    mountproc
    mkdir -p "$BUILDPLACE/tmp/buildd"
    echo " -> copying local configuration"
    for a in passwd hosts hostname resolv.conf; do 
	cp /etc/$a "$BUILDPLACE/etc/$a";
    done
    
    if [ -n "$DISTRIBUTION" ]; then
	installaptlines
    fi
}

#required for some packages to install...
export LANG=C
export LC_ALL=C