-
Notifications
You must be signed in to change notification settings - Fork 1
/
01-create-boostrap-mirror.bash
executable file
·164 lines (146 loc) · 5.07 KB
/
01-create-boostrap-mirror.bash
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
#
# Determines the list of packages to create a baseline Ubuntu install
# and mirrors those packages locally.
#
# The Ubuntu release and architecture are set in:
# config.sh
#
# Note: This script can be used after the fact to update the mirror
# with additional packages. This is useful the mirror has already
# been created and you discover a few more packages are required for
# the minimal guest vm.
#
if [ -z $UB_CONFIGURED ]; then
echo "Please execute 'guest.bash' to configure the environment first."
exit 1
fi
# Initialise some helpers
. ${UB_HOME}/functions.bash
mkdir -p ${U_RELEASE}-${U_ARCH}-bootstrap/tmp
#
# Find the list of baseline packages.
#
(cd ${U_RELEASE}-${U_ARCH}-bootstrap
if [ -r debootstrap.packages ]; then
linfo "Using existing debootstrap.packages"
else
linfo "Creating debootstrap.packages"
debootstrap --print-debs --arch=${U_ARCH} ${U_RELEASE} `pwd`/tmp > debootstrap.packages
if [ $? -ne 0 ]; then
lerror "debootstrap exited with: $?"
rm -f debootstrap.packages
die "UBE001"
fi
linfo "Found the following packages"
cat debootstrap.packages
fi
)
#
# Create the mirror
#
mkdir -p ${U_RELEASE}-${U_ARCH}-bootstrap/mirror
(cd ${U_RELEASE}-${U_ARCH}-bootstrap/mirror
mkdir -p conf
cat > conf/distributions <<EOF
Codename: ${U_RELEASE}
Architectures: ${U_ARCH} source
Description: Ubuntu ${U_RELEASE}-${U_ARCH} (Required packages only)
Components: main universe
Update: ubuntu-${U_RELEASE}-${U_ARCH}
Codename: ${U_RELEASE}-updates
Architectures: ${U_ARCH} source
Description: Ubuntu ${U_RELEASE}-${U_ARCH} Updates (Required packages only)
Components: main universe
Update: ubuntu-${U_RELEASE}-${U_ARCH}-updates
Codename: ${U_RELEASE}-security
Architectures: ${U_ARCH} source
Description: Ubuntu ${U_RELEASE}-${U_ARCH} Security (Required packages only)
Components: main universe
Update: ubuntu-${U_RELEASE}-${U_ARCH}-security
EOF
cat > conf/updates <<EOF
Name: ubuntu-${U_RELEASE}-${U_ARCH}
Method: ${U_MIRROR}
Components: main universe
Architectures: ${U_ARCH} source
FilterList: purge all-packages.mirror
VerifyRelease: blindtrust
Name: ubuntu-${U_RELEASE}-${U_ARCH}-updates
Method: ${U_MIRROR}
Components: main universe
Architectures: ${U_ARCH} source
FilterList: purge all-packages.mirror
VerifyRelease: blindtrust
Name: ubuntu-${U_RELEASE}-${U_ARCH}-security
Method: ${U_MIRROR}
Components: main universe
Architectures: ${U_ARCH} source
FilterList: purge all-packages.mirror
VerifyRelease: blindtrust
EOF
# Create a mirror request file based on the orignal package list
for pkg in $(cat ../debootstrap.packages); do
echo $pkg install;
done > conf/debootstrap.mirror || die "UBE002"
linfo "The following packages to be mirrored are listed in:" `pwd`/conf/debootstrap.mirror
linfo " partial listing:"
cat conf/debootstrap.mirror | sort | head -3
echo "..."
cat conf/debootstrap.mirror | sort | tail -2
# Add the list of additional packages from the ${UB_HOME}/additional.packages
# Note: we copy it and filter out comments and empty lines.
if [ -r ${UB_HOME}/additional.packages ]; then
linfo "Finding dependencies for packages listed in: ${UB_HOME}/additional.packages"
cat ${UB_HOME}/additional.packages | grep -Ev '^#.*|^\s*$' | sort > packages-to-mirror
else
lerror "Please specify at least a kernel in: ${UB_HOME}/additional.packages"
die "UBE003"
fi
if [ -r ${UB_HOME}/mirror.packages ]; then
linfo "Finding dependencies for packages listed in: ${UB_HOME}/mirror.packages"
cat ${UB_HOME}/mirror.packages | grep -Ev '^#.*|^\s*$' | sort >> packages-to-mirror
fi
cat packages-to-mirror
# Use configure and use germinate to find out the dependencies for those additional packages.
mkdir -p seeds
touch seeds/blacklist
touch seeds/supported
cat > seeds/STRUCTURE <<EOF
required:
supported:
EOF
linfo "Seeding with: " `pwd`/seeds/required
for pkg in $(cat packages-to-mirror); do
echo " * $pkg";
done > seeds/required
linfo "Germinating... this code take a while"
mkdir -p germinate
(cd germinate && \
germinate -v -m ${U_MIRROR} \
-a ${U_ARCH} \
-d ${U_RELEASE} \
-c main,universe \
-s seeds \
-S file://`pwd`/.. || die "UBE004"
)
linfo "Defining the complete list of packages in: " `pwd`/conf/all-packages.mirror
cat conf/debootstrap.mirror > germinate/all-packages.mirror
for pkg in $(cat germinate/required \
| tail -n +3 \
| head -n -2 \
| cut -d '|' -f 1); do
echo $pkg install;
done >> germinate/all-packages.mirror
cat germinate/all-packages.mirror | sort -u > conf/all-packages.mirror
cat conf/all-packages.mirror | head -3
echo " ..."
cat conf/all-packages.mirror | tail -2
#
# Now finally populate the mirror
linfo "Populating the mirror. This could take some time..."
reprepro --noskipold -V update ${U_RELEASE} || die "UBE005"
reprepro --noskipold -V update ${U_RELEASE}-updates || die "UBE006"
reprepro --noskipold -V update ${U_RELEASE}-security || die "UBE007"
linfo "Successfully populated the mirror!"
)