Merge lp:~smoser/maas-images/trunk.moved2git into lp:maas-images
- trunk.moved2git
- Merge into maas-ephemerals
Status: | Merged |
---|---|
Merged at revision: | 413 |
Proposed branch: | lp:~smoser/maas-images/trunk.moved2git |
Merge into: | lp:maas-images |
Diff against target: |
11524 lines (+21/-11177) 58 files modified
README (+11/-224) README.di-scraping (+0/-56) README.testing (+0/-32) bin/fake-maas-cloudimg2eph2 (+0/-83) bin/img2squashfs (+0/-289) bin/kh-xgene (+0/-39) bin/kpack-from-image (+0/-565) bin/maas-cloudimg2eph2 (+0/-687) bin/maas-cloudimg2ephemeral (+0/-725) bin/maas-qcow2targz (+0/-235) bin/meph2-build (+0/-28) bin/meph2-cloudimg-sync (+0/-27) bin/meph2-import (+0/-27) bin/meph2-util (+0/-27) bin/moved-to-git (+10/-0) bin/netboot-mirror (+0/-27) bin/unshare-pidns (+0/-24) conf/bootloaders.yaml (+0/-67) conf/centos.yaml (+0/-87) conf/meph-v2.yaml (+0/-226) conf/meph-v3.yaml (+0/-228) curtin/centos6/curtin-hooks.py (+0/-393) curtin/centos6/finalize.py (+0/-99) curtin/centos6/python_wrapper (+0/-11) curtin/centos7/curtin-hooks.py (+0/-396) curtin/centos7/finalize.py (+0/-108) curtin/centos7/python_wrapper (+0/-11) exdata/README (+0/-19) exdata/dates.txt (+0/-10) exdata/hcc/info.txt (+0/-1) exdata/muc/precise-armhf-p.yaml (+0/-55) exdata/muc/precise-armhf-q.yaml (+0/-40) exdata/muc/precise-armhf-r.yaml (+0/-40) exdata/muc/precise-armhf-s.yaml (+0/-23) exdata/muc/precise-armhf-t.yaml (+0/-15) meph2/__init__.py (+0/-8) meph2/commands/__init__.py (+0/-1) meph2/commands/build_image.py (+0/-119) meph2/commands/cloudimg_sync.py (+0/-304) meph2/commands/dpkg.py (+0/-332) meph2/commands/flags.py (+0/-111) meph2/commands/meph2_util.py (+0/-451) meph2/commands/mimport.py (+0/-339) meph2/commands/netboot_mirror.py (+0/-158) meph2/netinst.py (+0/-712) meph2/stream.py (+0/-363) meph2/ubuntu_info.py (+0/-114) meph2/url_helper.py (+0/-74) meph2/util.py (+0/-310) notes/description.txt (+0/-225) notes/example-1.txt (+0/-255) notes/example-2.txt (+0/-280) setup.py (+0/-24) system-setup (+0/-143) tests/unittests/file_item_data.json (+0/-1579) tests/unittests/test_netboot.py (+0/-46) tools/genstream-muc (+0/-272) tox.ini (+0/-33) |
To merge this branch: | bzr merge lp:~smoser/maas-images/trunk.moved2git |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert C Jennings (community) | Approve | ||
Andres Rodriguez (community) | Approve | ||
maintainers of maas images | Pending | ||
Review via email: mp+355495@code.launchpad.net |
Commit message
maas-images has moved its development from bzr to git.
Please update your workflow to use git. Instead of
bzr branch lp:maas-images
use:
git clone https:/
This bzr repository is no longer functional.
Description of the change
Robert C Jennings (rcj) wrote : | # |
We'll want to do this next week on Tuesday so we're not travelling and we're awake. But this is great. I'll hold putting this in 'approved' until then though.
Robert C Jennings (rcj) wrote : | # |
Scott, The 'git clone' cmd you include in this MP does not work today. On my system I need 'git clone lp:~maas-images-maintainers/maas-images'. Thoughts?
Scott Moser (smoser) wrote : | # |
@Robert,
Fixed. I had to 'Configure Code' for the maas-images project and point it at lp:~maas-images-maintainers/maas-images/+git/maas-images
all set now.
Scott Moser (smoser) wrote : | # |
Per Daniel on Friday 9-21:
smoser: roaksoax: FYI, we won't want the bzr repo to go away for a week or two as we tie up loose ends.
I plan on merging this on Tuesday October 2.
Robert C Jennings (rcj) : | # |
Scott Moser (smoser) wrote : | # |
just a reminder, i'll push this tomorrow (tuesday october 2).
at some point in the US/Eastern day
Preview Diff
1 | === modified file 'README' |
2 | --- README 2017-10-06 20:42:21 +0000 |
3 | +++ README 2018-09-21 12:24:04 +0000 |
4 | @@ -1,224 +1,11 @@ |
5 | -This builds maas ephemeral images from daily builds of cloud images. |
6 | -Ie, it creates stuff that goes on |
7 | - http://maas.ubuntu.com/images/ephemeral-v2/daily |
8 | -from stuff on |
9 | - http://cloud-images.ubuntu.com/daily |
10 | - |
11 | -== setup == |
12 | - Run './system-setup' to set up the system. |
13 | - This will install necessary dependencies. |
14 | - |
15 | - the tools expect that the 'bin' dir is in $PATH. |
16 | - |
17 | - export PATH=$PWD/bin:$PATH |
18 | - |
19 | -== building images == |
20 | -You can build images and kernel in one of 2 ways |
21 | - |
22 | -=== build a single release/arch combination === |
23 | -This will build output for a single release and architecture. |
24 | -You must provide a url or file to use as the source image. |
25 | - |
26 | - meph2-build arch release version source-image output.d |
27 | - |
28 | -example: |
29 | - $ burl=http://cloud-images.ubuntu.com/daily/server/ |
30 | - $ meph2-build amd64 xenial 20160101 \ |
31 | - $burl/xenial/current/xenial-server-cloudimg-amd64-root.tar.xz \ |
32 | - xenial-output.d/ |
33 | - |
34 | -This will build from source-image into output.d for 'arch' and 'release'. |
35 | -The 'version' provided is a serial (YYYYMMDD such as 20160101). |
36 | -source-image can be either a url or a local file of type |
37 | - '.tar.gz', '-root.tar.gz', or '-root.tar.xz' or '.img' |
38 | - |
39 | -In order to collect debian installer data you will need '--enable-di'. |
40 | - |
41 | -=== syncing against cloud-images.ubuntu.com === |
42 | -This will pull the latest images down from cloud-images.ubuntu.com |
43 | -and build maas images and kernel data all in one go. It only builds |
44 | -if it notices that maas images are out of date with cloud-images. |
45 | -To force a build, use '--target=force' |
46 | - |
47 | - To run: |
48 | - meph2-cloudimg-sync out.d |
49 | - |
50 | - You can then add filters to the end, like 'release=trusty' or |
51 | - 'arch=amd64'. The resultant out.d/streams/v1/ will have information |
52 | - copied from maas.ubuntu.com for all other products, but will only |
53 | - create new content for products that match the provided filters. |
54 | - |
55 | - If the maas ephemeral data is up to date with the latest cloud image daily |
56 | - then meph2-cloudimg-sync will not do anything. |
57 | - |
58 | -In order to 'rebuild' something. To create a new '20160101.1' even when |
59 | -there is an existing '20160101' maas image and the latest cloud image |
60 | -is 20160101, then pass '--rebuild=20160101:20160101.1'. |
61 | - |
62 | -For faster debugging, you can disable the crawling of d-i kernel/initramfs |
63 | -by passing '--disable-di' |
64 | - |
65 | -=== debugging === |
66 | -To debug and use the fake 'maas-cloudimg2eph2', run like: |
67 | - env MAAS_CLOUDIMG2EPH2=fake-maas-cloudimg2eph2 meph2-cloudimg-sync out.d |
68 | - |
69 | - This will still download di-kernels and di-initramfs. |
70 | - |
71 | -It will produce output that looks much like the final output, but |
72 | -runs in seconds rather than minutes. |
73 | - |
74 | -=== Enabling Proposed === |
75 | -For development and test purposes using Ubuntu proposed or PPA can |
76 | -be very useful. |
77 | - |
78 | -You can enable the proposed archive by simply editing the config |
79 | -file conf/meph-v3.yaml and specifying '--conf=conf/meph-v3.yaml'. |
80 | - |
81 | - enable_proposed: True |
82 | - |
83 | -Alternatively, you can simply pass '--proposed' to 'meph2-build' or |
84 | -to 'meph2-cloudimg-sync'. |
85 | - |
86 | -=== Adding PPAs === |
87 | -You can build images with any number of PPAs added and additional |
88 | -packages installed into the image through the environment variables |
89 | -M2E_ADD_REPOS and M2E_ADD_PACKAGES which are read by |
90 | -maas-cloudimg2ephemeral. |
91 | - |
92 | -M2E_ADD_REPOS is a space-delimited list of repositories to pass |
93 | -to 'add-apt-repository'. M2E_ADD_PACKAGES is a space-delimited |
94 | -list of packages that will be installed into the image, and will |
95 | -thus affect both the image and the initramfs produced from it. |
96 | - |
97 | -For example: |
98 | - |
99 | - $ rel=xenial ; arch=amd64 |
100 | - $ burl=http://cloud-images.ubuntu.com/ |
101 | - $ file=$rel-server-cloudimg-amd64.squashfs |
102 | - $ wget $burl/$rel/current/$rel-server-cloudimg-amd64.squashfs -O "$file" |
103 | - |
104 | - $ export M2E_ADD_REPOS=ppa:smoser/lp1711760 |
105 | - $ meph2-build --config=conf/meph-v3.yaml \ |
106 | - $arch $rel $(date +"%Y%m%d") $file $rel-output.d/ |
107 | - |
108 | -== streams management == |
109 | -Building as above will create out.d that has *metadata* describing |
110 | -everything that is in the source stream and also the things that were |
111 | -just built. data (images) will only be present for the newly built things. |
112 | - |
113 | -So after building new data and metadata, you'll then insert the new data into |
114 | -an existing stream. This option (meph2-util insert) is additive only. |
115 | - |
116 | - |
117 | -=== insert data === |
118 | -Given output of a meph2-cloudimg-sync command above in build-output.d |
119 | -and local daily stream directory daily-stream.d you can add the new data |
120 | -with: |
121 | - |
122 | - meph2-util insert build-output.d daily-stream.d |
123 | - |
124 | -If you do not want to sign (create .gpg and .sjson files), then you will |
125 | -have to use '--no-sign'. |
126 | - |
127 | -You can use '--dry-run' to only report what would be done. |
128 | - |
129 | -=== Promoting Builds === |
130 | -Promoting is done on a specific version of a product. |
131 | -You promote a daily build to a released build with a given label. |
132 | -Likely that label is 'release'. |
133 | - |
134 | - # list the product-ids and version are available for promotion |
135 | - $ sstream-query --output-format="%(product_name)s %(version_name)s" --max=1 \ |
136 | - daily.d/streams/v1/index.json arch=i386 | sort -u |
137 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-p 20140414 |
138 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-q 20140414 |
139 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-r 20140414 |
140 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-s 20140414 |
141 | - com.ubuntu.maas.daily:v2:boot:13.10:i386:hwe-s 20140416 |
142 | - com.ubuntu.maas.daily:v2:boot:14.04:i386:hwe-t 20140416.1 |
143 | - |
144 | - # promote the listed version |
145 | - $ meph2-util promote --label=release \ |
146 | - daily.d/streams/v1/index.json releases.d/ 20140414 \ |
147 | - product_name=com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-q |
148 | - |
149 | - |
150 | -== cleaning old images == |
151 | -Cleaning is done in 2 parts: |
152 | - * cleaning meta-data (removing entries from the products files) |
153 | - * finding orphans: identify which files in the tree are no longer referenced. |
154 | - * purging orphans: removing files that are known to have been orpaned for |
155 | - a given amount of time (3 days). |
156 | - |
157 | -=== cleaning meta-data === |
158 | - |
159 | -clean-md is the meph-util subcommand that allows you to keep only a given |
160 | -number of builds. For example, to keep the latest 3 versions of every |
161 | -product in the meta-data, you would run: |
162 | - |
163 | - meph2-util clean-md --max=3 daily-sream.d/ |
164 | - |
165 | -This *only* modifies the meta-data, it does not delete files, use find-orphans |
166 | -and reap-orphans for that. |
167 | - |
168 | -There is a --dry-run and --no-sign arguments also. |
169 | - |
170 | -=== finding orphans === |
171 | - |
172 | -finding orphans creates a json formated file that contains a entry for each |
173 | -file that is no longer referenced, and a timestamp of "now" (when it was first |
174 | -found to be orphaned). |
175 | - |
176 | -Example usage: |
177 | - The following will populate my-orphans.json. Subsequent runs will update |
178 | - my-orphans.json with any new items, but will not update first-orphaned |
179 | - timestamp. |
180 | - |
181 | - $ meph2-util find-orphans my-orphans.json ./daily/ ./daily/streams/v1/*.json |
182 | - |
183 | -More complex usage: |
184 | - Its possible that 2 streams dirs could share a data directory, similar |
185 | - to the 'pool' concept of apt for debian packages. For example, the following |
186 | - directory tree layout (note, 'path' elements would have 'data' in them in |
187 | - this example): |
188 | - |
189 | - daily/ |
190 | - data -> ../data/ |
191 | - streams/v1/index.json |
192 | - streams/v1/daily.json |
193 | - released/ |
194 | - data -> ../data |
195 | - streams/v1/index.json |
196 | - streams/v1/released.json |
197 | - data/ |
198 | - trusty/... |
199 | - utopic/... |
200 | - |
201 | - Then, we could run meph-util find-orphans with: |
202 | - |
203 | - $ meph2-util find-orphans my-orphans.json ./data/ \ |
204 | - ./daily/streams/v1/index.json released/streams/v1/index.json |
205 | - |
206 | - That will look through files in data/ that are not referenced by path |
207 | - elements in either the daily/streams/v1/ or released/streams/v1/ files. |
208 | - |
209 | - There is no --dry-run for finding orphans as it is non-destructive. |
210 | - |
211 | - |
212 | -=== cleaning / reaping orphans === |
213 | -Reaping orphans is what actually removes files. There is a '--dry-run' to |
214 | -indicate what would be done. |
215 | - |
216 | -its usage is fairly simple. |
217 | - |
218 | - $ meph2-util reap-orphans --older 7d my-orphans.json ./data/ |
219 | - |
220 | -'--older' takes input like: |
221 | - Ni |
222 | - Where N is a number and i can be one of: |
223 | - d: days |
224 | - h: hours |
225 | - m: minutes |
226 | - s: seconds |
227 | - |
228 | -The default is '3d'. |
229 | +**************************************************************************** |
230 | +** maas-images has moved its development from bzr to git. ** |
231 | +** ** |
232 | +** If you are seeing this message, it means you have checked out via bzr. ** |
233 | +** Please update your workflow to use git. Instead of ** |
234 | +** bzr branch lp:maas-images ** |
235 | +** use: ** |
236 | +** git clone https://git.launchpad.net/maas-images ** |
237 | +** ** |
238 | +** This bzr repository is no longer functional. ** |
239 | +**************************************************************************** |
240 | |
241 | === removed file 'README.di-scraping' |
242 | --- README.di-scraping 2015-06-01 18:43:11 +0000 |
243 | +++ README.di-scraping 1970-01-01 00:00:00 +0000 |
244 | @@ -1,56 +0,0 @@ |
245 | -Part of the processes of creating maas ephemeral images and streams data |
246 | -is scraping the d-i installer data from an archive location. This is not |
247 | -a very pretty process. Part of that blame resides in the very un-clean |
248 | -data that has to be interpreted. |
249 | - |
250 | -The way this is currently handled is with an intermediate simplestreams |
251 | -stream. The code in meph2/netinst.py. It can be excercise for test with |
252 | -bin/netboot-mirror . |
253 | - |
254 | -For example: |
255 | - ./bin/netboot-mirror --dry-run -vvv --arches=i386 --releases=trusty out.d |
256 | - |
257 | -That will create a NetbootMirrorReader that will scrape i386 data for trusty |
258 | -mirror trusty from the mirrors specified in meph2/netinst.py HTTP_MIRRORS. |
259 | - |
260 | -The logging there is useful to see what is happening. |
261 | - |
262 | - |
263 | -== Details == |
264 | -The d-i data lives at |
265 | - <mirror>/dists/<release><pocket>/installer-<arch>/ |
266 | -Where <release> is like 'trusty' and <pocket> like '-updates', '' or |
267 | -'-proposed'. |
268 | -For example: |
269 | - http://archive.ubuntu.com/ubuntu/dists/precise-updates/main/installer-i386/ |
270 | - |
271 | -The NetbootReader scrapes apache html to get a list of d-i versions available |
272 | -like '20101020ubuntu136.20'. |
273 | - |
274 | -So given "version_dir" as the above mirro/dists/..../<version> |
275 | -Then SHA256SUM and MD5SUM files are pulled from |
276 | - <mirror>/dists/trusty/main/installer-i386/<version>/images/ |
277 | -Example |
278 | - http://archive.ubuntu.com/ubuntu/dists/precise-updates/main/installer-i386/20101020ubuntu136.20/images/ |
279 | - |
280 | -Then, we try to extract clean data from each line in that sums file via |
281 | -the get_file_item_data method. |
282 | - |
283 | -The end result is that NetbootMirrorReader is a simplestreams mirror |
284 | -that can be read. |
285 | - |
286 | -It has products like: |
287 | - com.ubuntu.installer:netboot:14.04:i386 |
288 | - |
289 | -You can fully see this mirror by running: |
290 | - netboot-mirror [--arches=i386] [--releases=trusty] out.d |
291 | -and looking in |
292 | - out.d/streams/v1/com.ubuntu.installer:released:netboot.json |
293 | - |
294 | -== d-i data to maas ephemeral == |
295 | -The 'bin/maas-cloudimg2ephemeral' program then uses this streams formated data |
296 | -from the NetbootMirrorReader to as a clean set of data. And re-forms that |
297 | -data to fit its purposes. |
298 | - |
299 | -The intermediate step of NetbootReader is not necessary, but the NetbootReader |
300 | -code existed previously from an attempt to provide that data in a consistent format. |
301 | |
302 | === removed file 'README.testing' |
303 | --- README.testing 2014-05-30 18:27:15 +0000 |
304 | +++ README.testing 1970-01-01 00:00:00 +0000 |
305 | @@ -1,32 +0,0 @@ |
306 | -To get local copies of maas ephemerals, you can do: |
307 | - |
308 | - burl=http://maas.ubuntu.com/images/ephemeral-v2 |
309 | - for stream in releases daily; do |
310 | - sstream-mirror --no-item-download \ |
311 | - $burl/$stream/streams/v1/index.json "$stream.d"; done |
312 | - |
313 | - |
314 | -Then, to test promote you could do: |
315 | - $ sstream-query --output-format="%(product_name)s %(version_name)s" --max=1 \ |
316 | - daily.d/streams/v1/index.json arch=i386 | sort -u |
317 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-p 20140414 |
318 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-q 20140414 |
319 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-r 20140414 |
320 | - com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-s 20140414 |
321 | - com.ubuntu.maas.daily:v2:boot:13.10:i386:hwe-s 20140416 |
322 | - com.ubuntu.maas.daily:v2:boot:14.04:i386:hwe-t 20140416.1 |
323 | - |
324 | - $ sstream-query \ |
325 | - --output-format="%(product_name)s %(version_name)s/%(item_name)s" \ |
326 | - releases.d/streams/v1/index.json | sort -u > before |
327 | - |
328 | - $ meph2-util promote --no-sign --skip-file-copy --label=release \ |
329 | - daily.d/streams/v1/index.json releases.d/ 20140414 \ |
330 | - product_name=com.ubuntu.maas.daily:v2:boot:12.04:i386:hwe-q |
331 | - |
332 | - $ sstream-query \ |
333 | - --output-format="%(product_name)s %(version_name)s/%(item_name)s" \ |
334 | - releases.d/streams/v1/index.json | sort -u > after |
335 | - |
336 | - That will add the provided product to the releases.d/streams/ data. |
337 | - It will not copy the files because of '--skip-file-copy'. |
338 | |
339 | === removed file 'TODO' |
340 | === modified file 'bin/fake-maas-cloudimg2eph2' |
341 | --- bin/fake-maas-cloudimg2eph2 2015-11-06 21:07:45 +0000 |
342 | +++ bin/fake-maas-cloudimg2eph2 1970-01-01 00:00:00 +0000 |
343 | @@ -1,83 +0,0 @@ |
344 | -#!/bin/bash |
345 | -set -f |
346 | - |
347 | -error() { echo "$@" 1>&2; } |
348 | - |
349 | -short_opts="a:k:p:v" |
350 | -long_opts="arch:,kernel:,krd-pack:,manifest:,verbose" |
351 | -getopt_out=$(getopt --name "${0##*/}" \ |
352 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
353 | - eval set -- "${getopt_out}" || |
354 | - { echo "bad arguments to $0"; exit 1; } |
355 | - |
356 | -gzip=true |
357 | -arch="" |
358 | -kernel="" |
359 | -manif="" |
360 | -kpacks=( ) |
361 | -while [ $# -ne 0 ]; do |
362 | - cur=$1 |
363 | - next=$2 |
364 | - case "$cur" in |
365 | - -a|--arch) arch="$next"; shift;; |
366 | - -k|--kernel) kernel=$next; shift;; |
367 | - -p|--krd-pack) kpacks[${#kpacks[@]}]=$next; shift;; |
368 | - --manifest) manif="$next"; shift;; |
369 | - --no-gzip) gzip=false;; |
370 | - --) shift; break;; |
371 | - esac |
372 | - shift; |
373 | -done |
374 | - |
375 | -src=$1 |
376 | -root_gz=$2 |
377 | - |
378 | -ensure_d() { local d=""; d=$(dirname "$1"); mkdir -p "$d"; } |
379 | - |
380 | -ensure_d "$root_gz" |
381 | -$gzip && gzip_prog="gzip -c" || gzip_prog="cat" |
382 | - |
383 | -error "src=$src arch=$arch kernel=$kernel output=$root_gz" |
384 | -dd if=/dev/zero bs=1024 count=1024 2>/dev/null | $gzip_prog > "$root_gz" |
385 | -if [ -n "$manif" ]; then |
386 | - npkg=10 |
387 | - for((i=0;i<$npkg;i++)); do |
388 | - printf "bogus-package-%02d\t0.$((($npkg-$i)%$npkg))\n" "$i" |
389 | - done > "$manif" |
390 | -fi |
391 | - |
392 | -OIFS="$IFS" |
393 | -for kpack in "${kpacks[@]}"; do |
394 | - flags="" |
395 | - pkg=""; kout=""; iout=""; dtbs=""; |
396 | - IFS=","; set -- $kpack ; IFS="$OIFS" |
397 | - error "kpack: $*" |
398 | - while [ $# -ne 0 ]; do |
399 | - case "$1" in |
400 | - --dtb=*|--dtb) |
401 | - [ "$1" = "--dtb" ] && |
402 | - { data="$2"; shift; } || data="${1#--dtb=}" |
403 | - echo "dtb-${data%%=*}" > "${data#*=}";; |
404 | - -*) flags="$flags $1";; |
405 | - *) |
406 | - if [ -z "$pkg" ]; then |
407 | - pkg="$1" |
408 | - elif [ -z "$kout" ]; then |
409 | - kout="$1" |
410 | - ensure_d "$kout" |
411 | - echo "kernel: $pkg" > "$kout" |
412 | - elif [ -z "$iout" ]; then |
413 | - iout="$1" |
414 | - ensure_d "$iout" |
415 | - echo "kernel: $pkg" > "$iout" |
416 | - else |
417 | - error "confused by $*" |
418 | - fi |
419 | - esac |
420 | - shift; |
421 | - done |
422 | - ensure_d "$kout" |
423 | - ensure_d "$iout" |
424 | - echo "kernel: $pkg" > "$kout" |
425 | - echo "initrd: $pkg" > "$iout" |
426 | -done |
427 | |
428 | === target is u'moved-to-git' |
429 | === modified file 'bin/img2squashfs' |
430 | --- bin/img2squashfs 2018-09-19 20:59:56 +0000 |
431 | +++ bin/img2squashfs 1970-01-01 00:00:00 +0000 |
432 | @@ -1,289 +0,0 @@ |
433 | -#!/bin/bash |
434 | - |
435 | -VERBOSITY=1 |
436 | -TEMP_D="" |
437 | -VALID_FORMATS=( auto img-tar root-image root-image-gz root-tar squashfs-image |
438 | - dir ) |
439 | - |
440 | -error() { echo "$@" 1>&2; } |
441 | -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } |
442 | - |
443 | -Usage() { |
444 | - cat <<EOF |
445 | -Usage: ${0##*/} [ options ] source-image output-squash-image |
446 | - |
447 | - convert 'source-image' into a squashfs filesystem image. |
448 | - |
449 | - source-image is a file in one of: |
450 | - ${VALID_FORMATS[*]} |
451 | - |
452 | - output-squash-image will be a squashfs image. |
453 | - |
454 | - options: |
455 | - -v | --verbose increase verbosity |
456 | - -f | --format F source-image is of format F. default: auto. |
457 | - must be one of: |
458 | - auto: determine based on file and name heuristics |
459 | - img-tar: tarball of root image (image file named .img) |
460 | - root-image: filesytem (ext[234] in a file) |
461 | - root-image-gz: root-image that is compressed with gzip |
462 | - root-tar: tarball of / (supports .tar.xz .tar.gz) |
463 | - squashfs-image: a squahsfs image (.squashfs) |
464 | - -O | --owner O change ownership of output to O (user:group) |
465 | - |
466 | - Example: |
467 | - ${0##*/} --format=my.tar.gz my.squashfs |
468 | -EOF |
469 | -} |
470 | - |
471 | -bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return 1; } |
472 | -cleanup() { |
473 | - [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}" |
474 | -} |
475 | - |
476 | -ddebug() { |
477 | - local level="$1"; shift; |
478 | - [ "${level}" -gt "${VERBOSITY}" ] && return |
479 | - error "$(date -R):" "$@" |
480 | -} |
481 | - |
482 | -debug() { |
483 | - local level=${1}; shift; |
484 | - [ "${level}" -gt "${VERBOSITY}" ] && return |
485 | - error "${@}" |
486 | -} |
487 | - |
488 | -inargs() { |
489 | - #inargs(needle, [haystack]) |
490 | - # return true if needle is in haystack |
491 | - local needle="$1" i="" |
492 | - shift |
493 | - for i in "$@"; do |
494 | - [ "$i" = "$needle" ] && return 0 |
495 | - done |
496 | - return 1 |
497 | -} |
498 | - |
499 | -get_img_from_tar() { |
500 | - # given 'img' (image.tar.gz), extract it and put the .img file in 'out' |
501 | - local img="$1" out="$2" tempd="$3" |
502 | - local mtmp=$(mktemp -d "${tempd}/img_from_tar.XXXXXX") |
503 | - tar -C "$mtmp" -Sxf "$img" || |
504 | - { error "failed to extract $img"; return 1; } |
505 | - local f="" found="" |
506 | - for f in "${mtmp}/"*; do |
507 | - [ ! -f "$f" -o "${f%.img}" = "$f" ] && continue |
508 | - [ -z "$found" ] || |
509 | - { error "multiple .img found in $img"; return 1; } |
510 | - found="$f" |
511 | - done |
512 | - [ -n "$found" ] || { error "no .img in $img"; return 1; } |
513 | - mv "$found" "$out" && rm -Rf "$mtmp" |
514 | -} |
515 | - |
516 | -determine_format() { |
517 | - local input="$1" fmt="$2" fout="" |
518 | - inargs "$fmt" "${VALID_FORMATS[@]}" || { |
519 | - error "provided '--format=$fmt' not a valid format:" \ |
520 | - "${VALID_FORMATS[*]}" |
521 | - return 1; |
522 | - } |
523 | - [ "$fmt" != "auto" ] && _RET="$fmt" && return 0 |
524 | - if [ -d "$input" ]; then |
525 | - debug 1 "${input} is a directory"; |
526 | - _RET="dir" |
527 | - return |
528 | - fi |
529 | - fout=$(LANG=C file "$input") || |
530 | - { error "failed: file $input"; return 1; } |
531 | - case "${fout#$input: }" in |
532 | - "gzip compressed"*) |
533 | - fout=$(zcat "$input" | file -) |
534 | - case "${fout#*: }" in |
535 | - POSIX\ tar*) fmt="img-tar";; |
536 | - *) fmt="root-image-gz";; |
537 | - esac |
538 | - ;; |
539 | - "POSIX tar"*) fmt="img-tar";; |
540 | - *ext[234]\ filesystem*) fmt="root-image";; |
541 | - *[Ss]quashfs*) fmt="squashfs-image";; |
542 | - *) |
543 | - # if the above failed (on trusty a .tar.gz file was reported |
544 | - # as a Minux file system) then try filename based heuristics |
545 | - case "$input" in |
546 | - *-root.t??|*-root.tar|*-root.tar.??) fmt="root-tar";; |
547 | - *.tar.gz|*.tgz|*.tar) fmt="img-tar";; |
548 | - *.gz) fmt="root-image-gz";; |
549 | - *.squashfs) fmt="squashfs-image";; |
550 | - *) |
551 | - error "WARN: file '$input' did not match name hueristics" |
552 | - fmt="root-image";; |
553 | - esac |
554 | - debug 1 "guessing $input is $fmt based on name and 'file' [$fout]";; |
555 | - esac |
556 | - debug 1 "determined format is $fmt" |
557 | - _RET="$fmt" |
558 | -} |
559 | - |
560 | -get_usable_input() { |
561 | - # given 'input' in format 'fmt' return: |
562 | - # _RET_fmt: the format of _RET_path. either |
563 | - # fs-image : a mountable filesystem image. |
564 | - # dir : a directory |
565 | - # _RET_path: full path to a file in tempd |
566 | - local input="$1" fmt="$2" tempd="$3" cmd="" |
567 | - case "$fmt" in |
568 | - img-tar) |
569 | - _RET_fmt="fs-image" |
570 | - _RET_path="fs-image" |
571 | - get_img_from_tar "$input" "${tempd}/fs-image" "${tempd}" |
572 | - return;; |
573 | - root-image-gz) |
574 | - _RET_fmt="fs-image" |
575 | - _RET_path="$tempd/fs-image" |
576 | - zcat -c "$input" > "$tempd/fs-image.tmp" && |
577 | - mv "$tempd/fs-image.tmp" "$tempd/fs-image" |
578 | - return;; |
579 | - root-image) |
580 | - _RET_fmt="fs-image" |
581 | - _RET_path="$tempd/fs-image" |
582 | - ln -s "$(readlink -f "$input")" "${tempd}/fs-image" |
583 | - return;; |
584 | - squashfs-image) |
585 | - _RET_fmt="squashfs-image" |
586 | - _RET_path="${tempd}/fs-image" |
587 | - ln -s "$(readlink -f "$input")" "${tempd}/fs-image" |
588 | - return;; |
589 | - root-tar) |
590 | - _RET_fmt="dir" |
591 | - _RET_path="${tempd}/fs-dir" |
592 | - mkdir "${_RET_path}" |
593 | - cmd=( tar -C "${_RET_path}" -xpSf "$input" \ |
594 | - --numeric-owner --xattrs "--xattrs-include=*" ) |
595 | - debug 1 "extracting $fmt with ${cmd[*]}" |
596 | - "${cmd[@]}" || { |
597 | - error "failed: extracting $fmt with ${cmd[*]}" |
598 | - return 1; |
599 | - } |
600 | - return |
601 | - ;; |
602 | - dir) |
603 | - _RET_fmt="dir" |
604 | - _RET_path="${tempd}/fs-dir" |
605 | - ln -s "$(readlink -f "$input")" "${tempd}/fs-dir" |
606 | - return;; |
607 | - *) |
608 | - error "Unknown format '$fmt'"; |
609 | - return 1;; |
610 | - esac |
611 | -} |
612 | - |
613 | - |
614 | -dir2squashfs() { |
615 | - local src_d="$1" out="$2" owner="${3:-$(id -u):$(id -g)}" |
616 | - local tmpfile ret="" cmd="" |
617 | - tmpfile="${out}.${0##*/}.$$" || return |
618 | - cmd=( mksquashfs "$src_d" "$tmpfile" -xattrs -comp xz ) |
619 | - ddebug 1 "starting: ${cmd[*]}" |
620 | - "${cmd[@]}" |
621 | - ret=$? |
622 | - ddebug 1 "finished: returned $ret" |
623 | - if [ $ret -eq 0 ]; then |
624 | - chown "$owner" "$tmpfile" || |
625 | - { error "failed chown $owner $tmpfile"; return 1; } |
626 | - mv "$tmpfile" "$out" || |
627 | - { error "failed to move file to $out"; return 1; } |
628 | - else |
629 | - rm -f "$tmpfile" |
630 | - error "mksquashfs failed [$ret]: ${cmd[*]}." |
631 | - fi |
632 | - return $ret |
633 | -} |
634 | - |
635 | -fsimage2squashfs() { |
636 | - local src="$1" out="$2" owner="$3" |
637 | - local sudo="sudo" |
638 | - [ "$(id -u )" = "0" ] && sudo="" |
639 | - local cmd="" |
640 | - cmd=( mount-image-callback "$src" -- |
641 | - "$0" dir2squashfs _MOUNTPOINT_ "$out" $owner ) |
642 | - debug 1 "calling ${cmd[*]}" |
643 | - "${cmd[@]}" |
644 | -} |
645 | - |
646 | -main() { |
647 | - local short_opts="hf:O:v" |
648 | - local long_opts="help,format:,owner:,verbose" |
649 | - local getopt_out="" |
650 | - getopt_out=$(getopt --name "${0##*/}" \ |
651 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
652 | - eval set -- "${getopt_out}" || |
653 | - { bad_Usage; return; } |
654 | - |
655 | - local cur="" next="" input="" output="" owner="" fmt_in="auto" fmt="" |
656 | - while [ $# -ne 0 ]; do |
657 | - cur="$1"; next="$2"; |
658 | - case "$cur" in |
659 | - -h|--help) Usage ; exit 0;; |
660 | - -f|--format) fmt_in="$next"; shift;; |
661 | - -O|--owner) owner="$next"; shift;; |
662 | - -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));; |
663 | - --) shift; break;; |
664 | - esac |
665 | - shift; |
666 | - done |
667 | - |
668 | - [ $# -eq 2 ] || { bad_Usage "must provide input and output."; return; } |
669 | - src_in="$1" |
670 | - output="$2" |
671 | - |
672 | - TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || |
673 | - { error "failed to make tempdir"; return 1; } |
674 | - trap cleanup EXIT |
675 | - local tempd="${TEMP_D}" |
676 | - |
677 | - determine_format "${src_in}" "${fmt_in}" || return |
678 | - local fmt="${_RET}" |
679 | - debug 1 "format of '${src_in}' is '$fmt'" |
680 | - |
681 | - case "$fmt" in |
682 | - dir|squashfs-image|root-tar) :;; |
683 | - *) |
684 | - [ "$(id -u)" = "0" ] || { |
685 | - error "Cannot convert $fmt to squashfs as non-root"; |
686 | - return 1; |
687 | - } |
688 | - esac |
689 | - get_usable_input "${src_in}" "$fmt" "$tempd" || return |
690 | - local cfmt="${_RET_fmt}" tpath="${_RET_path}" |
691 | - |
692 | - debug 1 "got format '$cfmt' at temp path '$tpath'" |
693 | - if [ "$cfmt" = "squashfs-image" ]; then |
694 | - local tmpf="$output.$$" |
695 | - cp "$src_in" "$tmpf" && |
696 | - { [ -z "$owner" ] || chown "$owner" "$tmpf" ; } && |
697 | - mv "$tmpf" "$output" || { |
698 | - rm -f "$tmpf" |
699 | - error "failed copying $src_in to $output" |
700 | - return 1 |
701 | - } |
702 | - elif [ -f "$tpath" ]; then |
703 | - fsimage2squashfs "$tpath" "$output" "$owner" || return |
704 | - elif [ -d "$tpath" ]; then |
705 | - dir2squashfs "$tpath/" "$output" || return |
706 | - else |
707 | - error "failed. path='$tpath' cfmt=${cfmt}" |
708 | - return 1 |
709 | - fi |
710 | - error "output in $output. took ${SECONDS}s." |
711 | - return 0 |
712 | -} |
713 | - |
714 | -if [ "$1" = "dir2squashfs" ]; then |
715 | - shift |
716 | - dir2squashfs "$@" |
717 | -else |
718 | - main "$@" |
719 | -fi |
720 | - |
721 | -# vi: ts=4 expandtab |
722 | |
723 | === target is u'moved-to-git' |
724 | === modified file 'bin/kh-xgene' |
725 | --- bin/kh-xgene 2016-10-13 21:52:32 +0000 |
726 | +++ bin/kh-xgene 1970-01-01 00:00:00 +0000 |
727 | @@ -1,39 +0,0 @@ |
728 | -#!/bin/bash |
729 | - |
730 | -cleanup() { [ -n "$TEMP_D" ] && rm -Rf "${TEMP_D}"; } |
731 | -error() { echo "$@" 1>&2; } |
732 | -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } |
733 | - |
734 | -compress_type() { |
735 | - local file="$1" |
736 | - magic="$(od -x -N2 $file | head -1 | cut -d' ' -f2)" |
737 | - case $magic in |
738 | - 8b1f) |
739 | - echo "gzip" |
740 | - ;; |
741 | - *) |
742 | - echo "none" |
743 | - ;; |
744 | - esac |
745 | -} |
746 | - |
747 | -TEMP_D=$(mktemp -d "${0##*/}.XXXXXX") && |
748 | - trap cleanup EXIT || exit 1 |
749 | - |
750 | -kernel="$1" |
751 | -initrd="$2" |
752 | -info=${VERSION_FLAVOR:-"unknown-ver unknown-flavor"} |
753 | - |
754 | -cp "$kernel" "${TEMP_D}/kernel" || |
755 | - fail "failed copy kernel '$kernel'" |
756 | -cp "$initrd" "${TEMP_D}/initrd" || |
757 | - fail "failed copy initrd '$initrd'" |
758 | - |
759 | -comp="$(compress_type ${TEMP_D}/kernel)" |
760 | -mkimage -A arm -O linux -T kernel -C $comp -a 0x80000 -e 0x80000 \ |
761 | - -n "kernel $info" -d "${TEMP_D}/kernel" "$kernel" || |
762 | - fail "failed mkimage for kernel"; |
763 | -comp="$(compress_type ${TEMP_D}/initrd)" |
764 | -mkimage -A arm -O linux -T ramdisk -C $comp -a 0x0 -e 0x0 \ |
765 | - -n "ramdisk $info" -d "${TEMP_D}/initrd" "$initrd" || |
766 | - fail "failed mkimage for initrd"; |
767 | |
768 | === target is u'moved-to-git' |
769 | === modified file 'bin/kpack-from-image' |
770 | --- bin/kpack-from-image 2018-07-09 18:28:07 +0000 |
771 | +++ bin/kpack-from-image 1970-01-01 00:00:00 +0000 |
772 | @@ -1,565 +0,0 @@ |
773 | -#!/bin/bash |
774 | - |
775 | -VERBOSITY=0 |
776 | -TEMP_D="" |
777 | -COPY_TYPES="auto overlay qcow2 cp none" |
778 | -UBUNTU_MIRROR=${UBUNTU_MIRROR:-"http://archive.ubuntu.com/ubuntu/"} |
779 | -UBUNTU_MIRROR_PORTS=${UBUNTU_MIRROR_PORTS:-"http://ports.ubuntu.com/ubuntu-ports/"} |
780 | -PROPOSED_ARCHIVE_FILE="/etc/apt/sources.list.d/proposed.list" |
781 | -command -v unshare-pidns >/dev/null 2>&1 || PATH="${0%/*}:$PATH" |
782 | - |
783 | -error() { echo "$@" 1>&2; } |
784 | -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } |
785 | - |
786 | -Usage() { |
787 | - cat <<EOF |
788 | -Usage: ${0##*/} [ options ] image kernel-package out-dir |
789 | - |
790 | - Install kernel-package into image and copy the generated kernel |
791 | - and initrd out into out-dir |
792 | - out-dir/ |
793 | - kernel |
794 | - initrd |
795 | - dtb-<filename>.dtb # for each file in lib/firmare/<ver>/device-tree |
796 | - |
797 | - Requires sudo to invoke mount-image-callback. |
798 | - |
799 | - options: |
800 | - --kihelper PROG invoke PROG with kernel and initrd |
801 | - This allows re-packing (ie, mkimage the files) |
802 | - PROG is invoked with 2 arguments: |
803 | - kernel-path initrd-path |
804 | - it will have in its environment: |
805 | - ROOT: path to the mounted 'image' |
806 | - VERSION_FLAVOR: a string like 3.13.0-29-generic |
807 | - --copy mode use 'mode' to copy. default: auto |
808 | - one of: ${COPY_TYPES} |
809 | - overlay can be used only with mount-image-callback support |
810 | -EOF |
811 | -} |
812 | - |
813 | -bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return 1; } |
814 | -cleanup() { |
815 | - [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}" |
816 | -} |
817 | - |
818 | -debug() { |
819 | - local level=${1}; shift; |
820 | - [ "${level}" -gt "${VERBOSITY}" ] && return |
821 | - error "${@}" |
822 | -} |
823 | - |
824 | -disable_services() { |
825 | - local dir="$1" |
826 | - cat > "$dir/usr/sbin/policy-rc.d" <<"EOF" |
827 | -#!/bin/sh |
828 | -while true; do |
829 | - case "$1" in |
830 | - -*) shift ;; |
831 | - makedev) exit 0 ;; |
832 | - x11-common) exit 0 ;; |
833 | - *) exit 101 ;; |
834 | - esac |
835 | -done |
836 | -EOF |
837 | - [ $? -eq 0 ] && chmod 755 "$dir/usr/sbin/policy-rc.d" || |
838 | - { error "failed to write policy-rc.d"; return 1; } |
839 | -} |
840 | - |
841 | -undisable_services() { |
842 | - local dir="$1" |
843 | - rm -f "$dir/usr/sbin/policy-rc.d" |
844 | -} |
845 | - |
846 | -_chroot() { |
847 | - local dir="$1" |
848 | - shift |
849 | - if [ "$dir" = "/" ]; then |
850 | - "$@" |
851 | - else |
852 | - chroot "$dir" "$@" |
853 | - fi |
854 | -} |
855 | - |
856 | -replace_newaliases() { |
857 | - local dir="$1" |
858 | - debug 1 "hacking around newaliases in root (LP: #1531299)" |
859 | - _chroot "$dir" dpkg-divert --local --rename --add /usr/bin/newaliases && |
860 | - ln -s /bin/true "$dir/usr/bin/newaliases" |
861 | -} |
862 | - |
863 | -unreplace_newaliases() { |
864 | - local dir="$1" chroot_dir="" |
865 | - debug 1 "un-diverting newaliases in root" |
866 | - [ "$dir/bin/true" -ef "$dir/usr/bin/newaliases" ] || return 0 |
867 | - rm -f "$dir/usr/bin/newaliases" |
868 | - _chroot "$dir" dpkg-divert --local --rename --remove /usr/bin/newaliases |
869 | -} |
870 | - |
871 | -kernel_from_mp() { |
872 | - # this is the unwrapped function that actually does everything |
873 | - # it essentially gets called by mount-image-callback. |
874 | - local short_opts="hv" |
875 | - local long_opts="chown-to:,help,kihelper:,proposed,verbose" |
876 | - local getopt_out="" |
877 | - getopt_out=$(getopt --name "${0##*/}" \ |
878 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
879 | - eval set -- "${getopt_out}" || |
880 | - { bad_Usage; return; } |
881 | - |
882 | - local cur="" next="" |
883 | - local output="" copy=true chown_to="" gid="" uid="" kihelper="" |
884 | - local proposed="false" |
885 | - local skip_update=${KPACK_SKIP_APT_UPDATE:-false} |
886 | - |
887 | - while [ $# -ne 0 ]; do |
888 | - cur="$1"; next="$2"; |
889 | - case "$cur" in |
890 | - --chown-to) chown_to=$next; shift;; |
891 | - -h|--help) Usage ; exit 0;; |
892 | - -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));; |
893 | - --kihelper) kihelper="$next"; shift;; |
894 | - --proposed) proposed=true;; |
895 | - --skip-update) skip_update=true;; |
896 | - --) shift; break;; |
897 | - esac |
898 | - shift; |
899 | - done |
900 | - |
901 | - [ $# -eq 3 ] || |
902 | - { bad_Usage "expected 3 args, got $# [$*]"; return; } |
903 | - local mp="$1" kpkg="$2" outd="$3" |
904 | - |
905 | - local me="" myd="" |
906 | - me=$(readlink -f "$0") && myd="${me%/*}" || |
907 | - { error "couldn't figure out full path to $0"; return 1; } |
908 | - |
909 | - if [ -n "$kihelper" ]; then |
910 | - if ! command -v "$kihelper" >/dev/null 2>&1 ; then |
911 | - [ -x "$myd/$kihelper" ] || |
912 | - { error "failed to find kihelper"; return 1; } |
913 | - kihelper="$myd/$kihelper" |
914 | - fi |
915 | - fi |
916 | - if [ ! -d "$outd" ]; then |
917 | - mkdir -p "$outd" || |
918 | - { error "failed mkdir $outd"; return 1; } |
919 | - if [ -n "$chown_to" ]; then |
920 | - chown "$chown_to" "$outd" || { |
921 | - error "failed chown output dir '$outd' to '$chown_to'"; |
922 | - return 1; |
923 | - } |
924 | - fi |
925 | - fi |
926 | - |
927 | - local ch_outd="/tmp/output" |
928 | - KPACK_SKIP_APT_UPDATE=$skip_update CHROOTED_VERBOSITY=$VERBOSITY \ |
929 | - PROPOSED=$proposed \ |
930 | - unshare-pidns \ |
931 | - chroot "$mp" /bin/bash -s chrooted "$kpkg" "$ch_outd" < "$me" || |
932 | - { error "failed chroot and kernel install"; return 1; } |
933 | - |
934 | - if [ -n "$kihelper" ]; then |
935 | - local verflav="" |
936 | - read verflav < "$mp/$ch_outd/verflav" |
937 | - debug 1 "using $kihelper verflav='$verflav'" |
938 | - ROOT="$mp" VERSION_FLAVOR="$verflav" "$kihelper" \ |
939 | - "$mp/${ch_outd}/kernel" "$mp/${ch_outd}/initrd" || |
940 | - { error "$kihelper failed"; return 1; } |
941 | - fi |
942 | - |
943 | - if [ -n "$chown_to" ]; then |
944 | - ( cd "$mp/$ch_outd" && chown "$chown_to" * ) || { |
945 | - error "failed chown $mp/$ch_outd/*"; |
946 | - return 1; |
947 | - } |
948 | - fi |
949 | - |
950 | - mv "$mp/$ch_outd/"* "$outd" || |
951 | - { error "failed move files from chrooted outdi '$ch_outd'"; return 1; } |
952 | - |
953 | -} |
954 | - |
955 | -config_addl_modules() { |
956 | - local root="${1:-/}" rel="$2" fname="" |
957 | - fname="${root%/}/etc/initramfs-tools/hooks/kpack_extra" |
958 | - cat > "$fname" <<EOF |
959 | -#!/bin/sh |
960 | -. /usr/share/initramfs-tools/hook-functions |
961 | - |
962 | -copy_modules_dir kernel/drivers/char/ipmi # LP: #1333271 |
963 | -copy_modules_dir kernel/drivers/net/usb # LP: #1552378 |
964 | -manual_add_modules bcache # LP: #1513176 |
965 | -manual_add_modules hpilo # LP: #1761639 |
966 | -case $(dpkg --print-architecture) in |
967 | - arm64) |
968 | - manual_add_modules i2c-thunderx # LP: #1702976 |
969 | - ;; |
970 | -esac |
971 | -EOF |
972 | - if [ "$rel" = "precise" ]; then |
973 | - echo "manual_add_modules squashfs # (LP: #1501834)" >> "$fname" |
974 | - fi |
975 | - [ $? -eq 0 ] || { error "failed writing $fname"; return 1; } |
976 | - chmod 755 "$fname" || |
977 | - { error "failed setting execute on $fname"; return 1; } |
978 | - |
979 | - return 0 |
980 | -} |
981 | - |
982 | -config_add_zfs() { |
983 | - # In order for curtin to use zfs when booted in ephemeral we need the |
984 | - # module included. This could also be achieved by zfs-initramfs package. |
985 | - # However, that would bring in /sbin/zfs. We do not need use the 'zfs' |
986 | - # command or the kernel module *in* the initramfs, we just need the module |
987 | - # present so it can be used in install environment (LP: #1737592). |
988 | - local root="${1:-/}" rel="$2" fname="" |
989 | - fname="${root%/}/etc/initramfs-tools/hooks/kpack_zfs" |
990 | - case "$rel" in |
991 | - precise|trusty) return 0;; |
992 | - esac |
993 | - debug 1 "Will include zfs modules for release $rel." |
994 | - cat > "$fname" <<"EOF" |
995 | -. /usr/share/initramfs-tools/hook-functions |
996 | - |
997 | -manual_add_modules zfs # (LP: #1737592) |
998 | -EOF |
999 | - [ $? -eq 0 ] || { error "failed writing to $fname for zfs"; return 1; } |
1000 | - chmod 755 "$fname" || { |
1001 | - error "failed adding execute to $fname for zfs"; |
1002 | - return 1; |
1003 | - } |
1004 | -} |
1005 | - |
1006 | -ensure_iscsi_initramfs_support() { |
1007 | - local root="${1:-/}" |
1008 | - local mfile="${root%/}/etc/iscsi/iscsi.initramfs" |
1009 | - if [ ! -f "$mfile" ]; then |
1010 | - mkdir -p "${mfile%/*}" && touch "$mfile" || |
1011 | - { error "failed to create iscsi.initramfs"; return 1; } |
1012 | - fi |
1013 | -} |
1014 | - |
1015 | -clean_local_udev_rules() { |
1016 | - # in wily and later, /etc/udev/rules.d/*.rules will be copied |
1017 | - # into the initramfs. If there existed a '70-persistent-net.rules' |
1018 | - # then those would be clearly wrong (mac addresses and naming for |
1019 | - # the specific system that generated this). Clean those out. |
1020 | - local root="${1:-/}" |
1021 | - rm -f "${root%/}/etc/udev/rules.d/70-persistent-net.rules" |
1022 | -} |
1023 | - |
1024 | -insist_running_in_container() { |
1025 | - local root="${1:-/}" |
1026 | - ln -sf /bin/true "${root%/}/bin/running-in-container" |
1027 | - |
1028 | - local sdv="/usr/bin/systemd-detect-virt" |
1029 | - local fpsdv="${root%/}${sdv}" |
1030 | - if [ -x "${fpsdv}" ]; then |
1031 | - # make 'systemd-detect-virt X' exit true for any value of |
1032 | - # X in -c/--container -r/--chroot |
1033 | - mv "${fpsdv}" "$fpsdv.real" && cat > "$fpsdv" <<"EOF" |
1034 | -#!/bin/sh |
1035 | -args=" $* " |
1036 | -hasarg() { [ "${args#* $1 }" != "$args" -o "${args#* $2 }" != "$args" ]; } |
1037 | -hasarg -q --quiet && msg=: || msg=echo |
1038 | -hasarg -c --container && { $msg "lxc"; exit 0; } |
1039 | -hasarg -r --chroot && { $msg "chroot"; exit 0; } |
1040 | -exec "$0.real" "$@" |
1041 | -EOF |
1042 | - [ $? -eq 0 ] || { error "failed writing $sdv"; return 1; } |
1043 | - chmod 755 "$fpsdv" || { error "failed chmod $fpsdv"; return 1; } |
1044 | - fi |
1045 | -} |
1046 | - |
1047 | -vrun() { |
1048 | - local vlvl="$1" msg="$2" |
1049 | - shift 2 |
1050 | - debug $vlvl "$msg: $*" |
1051 | - "$@" |
1052 | -} |
1053 | - |
1054 | -chrooted() { |
1055 | - # this is expected to run chrooted inside the root |
1056 | - # installs all packages (arguments), writes kernel |
1057 | - # and initramfs and 'verflav' to /tmp/ |
1058 | - VERBOSITY=${CHROOTED_VERBOSITY:-${VERBOSITY}} |
1059 | - local pkgs="" kpkg="" copymods zzgrub emd="" out pkg rel arch |
1060 | - local skip_update=${KPACK_SKIP_APT_UPDATE:-false} |
1061 | - local proposed=${PROPOSED:-false} proposed_lfile="${PROPOSED_ARCHIVE_FILE}" |
1062 | - local verflav initrd kernel |
1063 | - export LANG=C |
1064 | - kpkg="$1" |
1065 | - outd="$2" |
1066 | - shift 2; |
1067 | - pkgs=( "$kpkg" "$@" ) |
1068 | - |
1069 | - mkdir -p "$outd" || { error "failed mkdir $outd"; return 1; } |
1070 | - local stamp="$outd/stamp" |
1071 | - touch "$stamp" |
1072 | - |
1073 | - rel=$(lsb_release -sc) || |
1074 | - { error "failed to read release"; return 1; } |
1075 | - arch=$(dpkg --print-architecture) || |
1076 | - { error "failed to get architecture from dpkg"; return 1; } |
1077 | - |
1078 | - # add proposed if necessary |
1079 | - if $proposed; then |
1080 | - local mirror="" |
1081 | - case "$arch" in |
1082 | - i?86|amd64) mirror="${UBUNTU_MIRROR}";; |
1083 | - *) mirror="${UBUNTU_MIRROR_PORTS}";; |
1084 | - esac |
1085 | - debug 1 "adding proposed ($mirror) to $proposed_lfile" |
1086 | - echo "deb $mirror ${rel}-proposed main universe multiverse" \ |
1087 | - > "$proposed_lfile" |
1088 | - $skip_update && |
1089 | - { skip_update=false; debug 1 "enabling update due to proposed"; } |
1090 | - fi |
1091 | - |
1092 | - # trusty and wily do not have mdadm or lvm2 installed in the image |
1093 | - # but we want those modules included (LP: #1519470) |
1094 | - # the packages are expected to be in xenial already |
1095 | - case "$rel" in |
1096 | - precise|trusty|wily) pkgs=( lvm2 mdadm "${pkgs[@]}" );; |
1097 | - esac |
1098 | - |
1099 | - $skip_update || apt-get update -q || |
1100 | - { error "apt-get update failed"; return 1; } |
1101 | - |
1102 | - copymods="cloud-initramfs-copymods" |
1103 | - if [ -f /usr/share/initramfs-tools/hooks/copymods ]; then |
1104 | - debug 1 "package '$copymods' already installed." |
1105 | - else |
1106 | - apt-cache show $copymods >/dev/null 2>&1 || |
1107 | - { error "package '$copymods' not available."; return 1; } |
1108 | - debug 1 "adding package '$copymods'." |
1109 | - pkgs=( "$copymods" "${pkgs[@]}" ) |
1110 | - fi |
1111 | - |
1112 | - local rooturl="cloud-initramfs-rooturl" |
1113 | - if [ -f /usr/share/initramfs-tools/hooks/rooturl ]; then |
1114 | - debug 1 "package '$rooturl' already installed." |
1115 | - else |
1116 | - if ! apt-cache show $rooturl >/dev/null 2>&1; then |
1117 | - case "$rel" in |
1118 | - precise) |
1119 | - debug 1 "package '$rooturl' not available on '$rel'";; |
1120 | - *) |
1121 | - error "package '$rooturl' not available."; |
1122 | - return 1;; |
1123 | - esac |
1124 | - else |
1125 | - debug 1 "adding package '$rooturl' (LP: #1688606)." |
1126 | - pkgs=( "$rooturl" "${pkgs[@]}" ) |
1127 | - fi |
1128 | - fi |
1129 | - |
1130 | - zzgrub=/etc/kernel/postinst.d/zz-update-grub |
1131 | - [ ! -x "$zzgrub" ] || chmod ugo-x $zzgrub |
1132 | - |
1133 | - which eatmydata >/dev/null 2>&1 && emd=eatmydata |
1134 | - |
1135 | - config_addl_modules / "$rel" || |
1136 | - { error "failed configuring additional modules!"; return 1; } |
1137 | - |
1138 | - config_add_zfs / "$rel" || |
1139 | - { error "failed adding zfs"; return 1; } |
1140 | - |
1141 | - ensure_iscsi_initramfs_support / || |
1142 | - { error "failed to enable iscsi initramfs support"; return 1; } |
1143 | - |
1144 | - clean_local_udev_rules / || |
1145 | - { error "failed configuring additional modules!"; return 1; } |
1146 | - |
1147 | - insist_running_in_container / || |
1148 | - { error "failed to set running-in-container to true"; return 1; } |
1149 | - |
1150 | - disable_services / || |
1151 | - { error "failed to disable services before apt installs"; return 1; } |
1152 | - |
1153 | - replace_newaliases / || |
1154 | - { error "failed to replace newaliases"; return 1; } |
1155 | - |
1156 | - vrun 1 "installing packages" \ |
1157 | - env DEBIAN_FRONTEND=noninteractive FLASH_KERNEL_SKIP=1 \ |
1158 | - $emd apt-get install --assume-yes --quiet \ |
1159 | - "${pkgs[@]}" </dev/null |
1160 | - [ $? -eq 0 ] || |
1161 | - { error "failed install of ${pkgs[*]}"; return 1; } |
1162 | - |
1163 | - undisable_services / || |
1164 | - { error "failed to re-enable services after apt installs"; return 1; } |
1165 | - |
1166 | - unreplace_newaliases / || |
1167 | - { error "failed to un-replace newaliases"; return 1; } |
1168 | - |
1169 | - $proposed && rm -f "$proposed_lfile" |
1170 | - |
1171 | - # here we look at all kernel files in /boot and get the package that |
1172 | - # owns it. if the package is the kernel that was supplied, then we |
1173 | - # found it. It supports 'kpkg' being a meta package by seeing |
1174 | - # if kpkg would be removed if we uninstalled the kernel package. |
1175 | - kernel="" |
1176 | - for f in /boot/vmlin*; do |
1177 | - [ -f "$f" ] || continue |
1178 | - out=$(dpkg -S "$f") |
1179 | - pkg=${out%%:*} |
1180 | - [ "$pkg" = "$kpkg" ] && kernel="$f" && break |
1181 | - if apt-get --dry-run remove $pkg | grep -q "Remv $kpkg "; then |
1182 | - kernel="$f" |
1183 | - break |
1184 | - fi |
1185 | - done |
1186 | - [ -z "$kernel" ] && { error "no kernel found!" 1>&2; return 1; } |
1187 | - verflav=${kernel#/boot/*-} |
1188 | - initrd="/boot/initrd.img-$verflav" |
1189 | - debug 2 "verflav is $verflav" |
1190 | - # LP: #1711203 - Prefer a signed kernel over an unsigned kernel. The signed |
1191 | - # kernel is created by combining the key in /usr/lib/linux and the kernel |
1192 | - # in /boot. As the kernel will not be in the dpkg database assume if it |
1193 | - # exists it's what we want. |
1194 | - if [ -f "$(ls $kernel*signed)" ]; then |
1195 | - kernel="$(ls $kernel*signed)" |
1196 | - debug 1 "Found signed kernel $kernel" |
1197 | - fi |
1198 | - if [ "$initrd" -ot "$stamp" ]; then |
1199 | - debug 1 "initramfs did not update by package install. regenerating." |
1200 | - update-initramfs -c -k "$verflav" |
1201 | - fi |
1202 | - |
1203 | - [ -f "$initrd" ] || { error "no initrd for $verflav" 1>&2; return 1; } |
1204 | - |
1205 | - local name="" t="" outf="" |
1206 | - for f in /boot/*-${verflav}*; do |
1207 | - # Skip unsigned kernel if a signed kernel is available. |
1208 | - [ -f "$f"*.signed ] && continue |
1209 | - t=$(basename "$f") |
1210 | - case "$t" in |
1211 | - vmlinu?*) name="kernel";; |
1212 | - initrd.img*) name="initrd";; |
1213 | - *) |
1214 | - # name is the basename with -${verfla} removed |
1215 | - name="${t%-${verflav}}" |
1216 | - esac |
1217 | - outf="$outd/$name" |
1218 | - debug 2 "$f -> $outf" |
1219 | - cp "$f" "$outf" && chmod ugo+r "$outf" || |
1220 | - { error "failed to copy '$name' from '$f'"; return 1; } |
1221 | - done |
1222 | - |
1223 | - local path="/lib/firmware/$verflav/device-tree" |
1224 | - if [ -d "$path" ]; then |
1225 | - for f in $(find "$path" -type f -name "*.dtb"); do |
1226 | - outf="$outd/dtb-${f##*/}" |
1227 | - debug 2 "$f -> $outf" |
1228 | - [ ! -f "$outf" ] || { |
1229 | - error "basename collision over '${outf##*/}'" |
1230 | - find "$path" -type f -name "${f##*/}" 1>&2 |
1231 | - return 1 |
1232 | - } |
1233 | - cp "$f" "$outf" && chmod ugo+r "$outf" || |
1234 | - { error "failed to copy '$outf' from '$f'"; return 1; } |
1235 | - done |
1236 | - else |
1237 | - debug 1 "dtb path '$path' did not exist. assume no dtb files" |
1238 | - fi |
1239 | - |
1240 | - echo "$verflav" > "$outd/verflav" || |
1241 | - { error "failed to write verflavor"; return 1; } |
1242 | - |
1243 | - rm -f "$stamp" |
1244 | -} |
1245 | - |
1246 | -main() { |
1247 | - local short_opts="hv" |
1248 | - local long_opts="help,kihelper:,copy:,proposed,verbose" |
1249 | - local getopt_out="" |
1250 | - getopt_out=$(getopt --name "${0##*/}" \ |
1251 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
1252 | - eval set -- "${getopt_out}" || |
1253 | - { bad_Usage; return; } |
1254 | - |
1255 | - local cur="" next="" vflags="" |
1256 | - local output="" copy=auto chown_to="" gid="" uid="" proposed_flag="" |
1257 | - |
1258 | - while [ $# -ne 0 ]; do |
1259 | - cur="$1"; next="$2"; |
1260 | - case "$cur" in |
1261 | - -h|--help) Usage ; exit 0;; |
1262 | - -v|--verbose) VERBOSITY=$((${VERBOSITY}+1)); vflags="${vflags}v";; |
1263 | - --kihelper) kihelper="$next"; shift;; |
1264 | - --copy) copy=$next; shift;; |
1265 | - --proposed) proposed_flag="--proposed";; |
1266 | - --) shift; break;; |
1267 | - esac |
1268 | - shift; |
1269 | - done |
1270 | - |
1271 | - [ $# -eq 3 ] || |
1272 | - { bad_Usage "expected 3 args, got $#"; return; } |
1273 | - local img="$1" kpkg="$2" outd=${3} |
1274 | - |
1275 | - [ -z "$vflags" ] || vflags="-${vflags}" |
1276 | - |
1277 | - TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || |
1278 | - fail "failed to make tempdir" |
1279 | - trap cleanup EXIT |
1280 | - |
1281 | - if [ "$copy" = "auto" ]; then |
1282 | - if mount-image-callback --help | grep -q -- --overlay; then |
1283 | - copy="overlay" |
1284 | - elif command -v qemu-img >/dev/null 2>&1; then |
1285 | - copy="qcow" |
1286 | - else |
1287 | - copy="cp" |
1288 | - fi |
1289 | - fi |
1290 | - |
1291 | - local imgfp myimg="${TEMP_D}/my.img" overlay_flags="" |
1292 | - imgfp=$(readlink -f "$img") || |
1293 | - { error "failed to get full path to $img"; return 1; } |
1294 | - debug 1 "copy mode = $copy" |
1295 | - case "$copy" in |
1296 | - none) ln -s "$imgfp" "$myimg" || |
1297 | - { error "failed link $imgfp -> $myimg"; return 1; };; |
1298 | - cp) cp --sparse=always "$img" "$myimg" || |
1299 | - { error "failed cp '$img' to tempdir"; return 1; };; |
1300 | - qcow) |
1301 | - qemu-img create -f qcow2 -b "$imgfp" "$myimg" || |
1302 | - { error "failed create qcow2 backed by $img"; return 1; };; |
1303 | - overlay) |
1304 | - overlay_flags="--overlay --read-only" |
1305 | - ln -s "$imgfp" "$myimg" || |
1306 | - { error "failed link $imgfp -> $myimg"; return 1; };; |
1307 | - *) error "bad copy type. one of: $COPY_TYPES"; return 1;; |
1308 | - esac |
1309 | - |
1310 | - gid=$(id -g) |
1311 | - uid=$(id -u) |
1312 | - chown_to="$uid:$gid" |
1313 | - |
1314 | - local mic="" |
1315 | - mic=$(which mount-image-callback) || |
1316 | - { error "mount-image-callback not in PATH"; return 1; } |
1317 | - sudo \ |
1318 | - "KPACK_SKIP_APT_UPDATE=${KPACK_SKIP_APT_UPDATE:-false}" \ |
1319 | - "http_proxy=$http_proxy" PACKAGES="$kpkg" \ |
1320 | - UBUNTU_MIRROR=${UBUNTU_MIRROR} \ |
1321 | - UBUNTU_MIRROR_PORTS=${UBUNTU_MIRROR_PORTS} \ |
1322 | - "$mic" --sys --proc $overlay_flags \ |
1323 | - --system-resolvconf "$myimg" -- "$0" "kernel_from_mp" $vflags \ |
1324 | - _MOUNTPOINT_ "--chown-to=$chown_to" \ |
1325 | - ${kihelper:+"--kihelper=$kihelper"} ${proposed_flag} \ |
1326 | - "$kpkg" "$outd" || |
1327 | - { error "failed"; return 1; } |
1328 | - |
1329 | - error "wrote to $outd" |
1330 | - error " " $(cd "$outd" && echo *) |
1331 | - return |
1332 | -} |
1333 | - |
1334 | -[ "$1" = "chrooted" ] && { shift; chrooted "$@"; exit; } |
1335 | -[ "$1" = "kernel_from_mp" ] && { shift; kernel_from_mp "$@"; exit; } |
1336 | -main "$@" |
1337 | -# vi: ts=4 expandtab |
1338 | |
1339 | === target is u'moved-to-git' |
1340 | === modified file 'bin/maas-cloudimg2eph2' |
1341 | --- bin/maas-cloudimg2eph2 2018-01-06 02:14:53 +0000 |
1342 | +++ bin/maas-cloudimg2eph2 1970-01-01 00:00:00 +0000 |
1343 | @@ -1,687 +0,0 @@ |
1344 | -#!/bin/bash |
1345 | - |
1346 | -VERBOSITY=1 |
1347 | -TEMP_D="" |
1348 | -VALID_FORMATS=( auto img-tar root-image root-image-gz root-tar squashfs-image ) |
1349 | -CLOUDIMG_LABEL="cloudimg-rootfs" |
1350 | - |
1351 | -error() { echo "$@" 1>&2; } |
1352 | -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } |
1353 | - |
1354 | -Usage() { |
1355 | - cat <<EOF |
1356 | -Usage: ${0##*/} [ options ] source-image output-image.gz |
1357 | - |
1358 | - convert 'source-image' into a ephemeral image and put |
1359 | - output into output-image.gz. |
1360 | - |
1361 | - source-image can be url or file path that is either .tar.gz or .img |
1362 | - or -root.tar.gz. or -root.tar.xz |
1363 | - |
1364 | - options: |
1365 | - --no-gzip do not gzip output image |
1366 | - -k | --kernel K keep/install the kernel package 'k' inside image |
1367 | - use 'none' to remove any existing kernels |
1368 | - -p | --krd-pack P create a kernel / ramdisk pack |
1369 | - P is ',' delimited: kernel-name,kernel,ramdisk[,flags] |
1370 | - --manifest M write the dpkg manifest to M |
1371 | - -v | --verbose increase verbosity |
1372 | - -f | --format F source-image is of format F. default: auto. |
1373 | - must be one of: |
1374 | - auto: determine based on file and name heuristics |
1375 | - img-tar: tarball of root image (image file named .img) |
1376 | - root-image: filesytem (ext[234] in a file) |
1377 | - root-image-gz: root-image that is compressed with gzip |
1378 | - root-tar: tarball of / (supports .tar.xz .tar.gz) |
1379 | - squashfs-image: a squahsfs image (.squashfs) |
1380 | - |
1381 | - Example: |
1382 | - ${0##*/} --kernel=linux-generic \\ |
1383 | - --krd-pack=linux-generic,output/kernel,output/initrd \\ |
1384 | - trusty-server-cloudimg-armhf.tar.gz \\ |
1385 | - output/root-image.gz |
1386 | -EOF |
1387 | -} |
1388 | - |
1389 | -bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return 1; } |
1390 | -cleanup() { |
1391 | - [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}" |
1392 | -} |
1393 | - |
1394 | -ddebug() { |
1395 | - local level="$1"; shift; |
1396 | - [ "${level}" -gt "${VERBOSITY}" ] && return |
1397 | - error "$(date -R):" "$@" |
1398 | -} |
1399 | - |
1400 | -debug() { |
1401 | - local level=${1}; shift; |
1402 | - [ "${level}" -gt "${VERBOSITY}" ] && return |
1403 | - error "${@}" |
1404 | -} |
1405 | - |
1406 | -mkfs_ext4() { |
1407 | - local out="" cmd="" feature_flags="" cfg="/etc/mke2fs.conf" fstype="ext4" |
1408 | - case "$1" in |
1409 | - --type=*) fstype=${1#--type=}; shift;; |
1410 | - --type) fstype="$2"; shift 2;; |
1411 | - esac |
1412 | - |
1413 | - local target="$1" label="$2" uuid="$3" |
1414 | - if grep -q metadata_csum "$cfg"; then |
1415 | - # disable metadata_csum as yakkety will create this by default |
1416 | - # but kernels on some buildd cannot mount such a filesystem. |
1417 | - feature_flags="^metadata_csum" |
1418 | - fi |
1419 | - cmd=( "mkfs.$fstype" |
1420 | - ${label:+-L "$label"} ${uuid:+-U "$uuid"} |
1421 | - ${feature_flags:+-O "$feature_flags"} |
1422 | - -F "$target" ) |
1423 | - debug 1 "creating $fstype fs in '$target'. label=$label" \ |
1424 | - " feature_flags='${feature_flags}'" |
1425 | - debug 2 "mkfs cmd: ${cmd[*]}" |
1426 | - |
1427 | - local ret=0 |
1428 | - out=$("${cmd[@]}" 2>&1) |
1429 | - ret=$? |
1430 | - if [ $ret -ne 0 ]; then |
1431 | - error "failed [$ret]: ${cmd[*]}"; |
1432 | - error "$out"; |
1433 | - fi |
1434 | - return $ret |
1435 | -} |
1436 | - |
1437 | -get_img_from_tar() { |
1438 | - local img="$1" out="$2" tempd="$3" |
1439 | - local mtmp=$(mktemp -d "${tempd}/img_from_tar.XXXXXX") |
1440 | - tar -C "$mtmp" -Sxf "$img" || |
1441 | - { error "failed to extract $img"; return 1; } |
1442 | - local f="" found="" |
1443 | - for f in "${mtmp}/"*; do |
1444 | - [ ! -f "$f" -o "${f%.img}" = "$f" ] && continue |
1445 | - [ -z "$found" ] || |
1446 | - { error "multiple .img found in $img"; return 1; } |
1447 | - found="$f" |
1448 | - done |
1449 | - [ -n "$found" ] || { error "no .img in $img"; return 1; } |
1450 | - mv "$found" "$out" && rm -Rf "$mtmp" |
1451 | -} |
1452 | - |
1453 | -squashfs_to_image() { |
1454 | - local squashimg="$1" output="$2" tempd="$3" size="4G" |
1455 | - local mtmp=$(mktemp -d "${tempd}/root_tar_to_image.XXXXXX") |
1456 | - local xout="" ret="" |
1457 | - local srcmp="$mtmp/src" trgmp="$mtmp/target" |
1458 | - command -v unsquashfs >/dev/null 2>&1 || { |
1459 | - error "unsquashfs is not available. apt-get install squashfs-tools". |
1460 | - return 1; |
1461 | - } |
1462 | - truncate "--size=$size" "$output" || { |
1463 | - error "failed to create file of $size in $output" |
1464 | - return 1 |
1465 | - } |
1466 | - mkdir "$srcmp" "$trgmp" || { |
1467 | - error "failed mkdir $srcmp $trgmp" |
1468 | - return 1; |
1469 | - } |
1470 | - |
1471 | - mkfs_ext4 "$output" "$CLOUDIMG_LABEL" || return |
1472 | - debug 1 "turning squahsfs image in $squashimg to ext4 image in $output" |
1473 | - sudo bash -ec 'src="$1"; img="$2"; trgmp="$3"; |
1474 | - mounts="" |
1475 | - cleanup() { for m in $mounts; do umount "$m"; done; } |
1476 | - trap cleanup EXIT |
1477 | - mount -o loop "$img" "$trgmp" |
1478 | - mounts="$trgmp" |
1479 | - unsquashfs -force -xattrs -dest "$trgmp" "$src"' \ |
1480 | - "squashimg-to-image" "$squashimg" "$output" "$trgmp" |
1481 | - ret=$? |
1482 | - rm -Rf "$mtmp" || return |
1483 | - return $ret |
1484 | -} |
1485 | - |
1486 | -root_tar_to_image() { |
1487 | - local tball="$1" output="$2" tempd="$3" size="4G" |
1488 | - local mtmp=$(mktemp -d "${tempd}/root_tar_to_image.XXXXXX") |
1489 | - local mp="$mtmp/mp" xout="" ret="" |
1490 | - truncate "--size=$size" "$output" || |
1491 | - return "failed to create file of $size in $output" |
1492 | - mkdir "$mp" |
1493 | - mkfs_ext4 "$output" "$CLOUDIMG_LABEL" || return |
1494 | - debug 1 "turning root tarball in $tball to image in $output" |
1495 | - sudo bash -ec 'tball="$1"; img="$2"; mp="$3"; |
1496 | - mount -o loop "$img" "$mp" |
1497 | - trap "umount $mp" EXIT |
1498 | - tar -C "$mp" -xpSf "$tball" --numeric-owner \ |
1499 | - --xattrs "--xattrs-include=*"' \ |
1500 | - "root-tar-to-image" "$tball" "$output" "$mp" |
1501 | - ret=$? |
1502 | - rm -Rf "$mtmp" || return |
1503 | - return $ret |
1504 | -} |
1505 | - |
1506 | -get_img_file() { |
1507 | - local fout="" fmt="$1" input="$2" output="$3" tempd="$4" ret="" |
1508 | - if [ "$fmt" = "auto" ]; then |
1509 | - fout=$(LANG=C file "$input") || |
1510 | - { error "failed: file $input"; return 1; } |
1511 | - case "${fout#$input: }" in |
1512 | - "gzip compressed"*) |
1513 | - fout=$(zcat "$input" | file -) |
1514 | - case "${fout#*: }" in |
1515 | - POSIX\ tar*) fmt="img-tar";; |
1516 | - *) fmt="root-image";; |
1517 | - esac |
1518 | - ;; |
1519 | - "POSIX tar"*) fmt="img-tar";; |
1520 | - *ext[234]\ filesystem*) fmt="root-image";; |
1521 | - *[Ss]quashfs*) fmt="squashfs-image";; |
1522 | - *) |
1523 | - # if the above failed (on trusty a .tar.gz file was reported |
1524 | - # as a Minux file system) then try filename based heuristics |
1525 | - case "$input" in |
1526 | - *-root.t??|*-root.tar|*-root.tar.??) fmt="root-tar";; |
1527 | - *.tar.gz|*.tgz|*.tar) fmt="img-tar";; |
1528 | - *.gz) fmt="root-image-gz";; |
1529 | - *.squashfs) fmt="squashfs-image";; |
1530 | - *) |
1531 | - error "WARN: file '$input' did not match name hueristics" |
1532 | - fmt="root-image";; |
1533 | - esac |
1534 | - debug 1 "guessing $input is $fmt based on name and 'file' [$fout]";; |
1535 | - esac |
1536 | - debug 1 "determined format is $fmt" |
1537 | - fi |
1538 | - case "$fmt" in |
1539 | - img-tar) |
1540 | - get_img_from_tar "$input" "$output" "$tempd";; |
1541 | - root-image-gz) |
1542 | - zcat -c "$input" > "$output";; |
1543 | - root-image) |
1544 | - ln -s "$(readlink -f "$input")" "$output";; |
1545 | - root-tar) |
1546 | - root_tar_to_image "$input" "$output" "$tempd";; |
1547 | - squashfs-image) |
1548 | - squashfs_to_image "$input" "$output" "$tempd";; |
1549 | - *) |
1550 | - error "Unknown format '$fmt'"; |
1551 | - return 1;; |
1552 | - esac |
1553 | - ret=$? |
1554 | - [ $ret -eq 0 ] || { |
1555 | - error "failed converting $fmt from $input to $output [$?]" |
1556 | - return $ret |
1557 | - } |
1558 | - _RET="$fmt" |
1559 | -} |
1560 | - |
1561 | -ensure_file_d() { |
1562 | - local f="" d="" |
1563 | - for f in "$@"; do |
1564 | - d=$(dirname "$f") |
1565 | - mkdir -p "$d" || return |
1566 | - done |
1567 | - return 0 |
1568 | -} |
1569 | - |
1570 | -human2bytes() { |
1571 | - # converts size suitable for input to resize2fs to bytes |
1572 | - # s:512 byte sectors, K:kilobytes, M:megabytes, G:gigabytes |
1573 | - # none: block size of the image |
1574 | - local input=${1} defunit=${2:-1024} |
1575 | - local unit count; |
1576 | - case "$input" in |
1577 | - *s) count=${input%s}; unit=512;; |
1578 | - *K) count=${input%K}; unit=1024;; |
1579 | - *M) count=${input%M}; unit=$((1024*1024));; |
1580 | - *G) count=${input%G}; unit=$((1024*1024*1024));; |
1581 | - *) count=${input} ; unit=${defunit};; |
1582 | - esac |
1583 | - _RET=$((${count}*${unit})) |
1584 | -} |
1585 | - |
1586 | -resize_image() { |
1587 | - # set image size to 'size' |
1588 | - # if size is '+<size>', it will be grown by that size |
1589 | - # if '--allow-padding' provided, then size will be |
1590 | - # the minimum of "minimum_size + padding" or size |
1591 | - local padding="" |
1592 | - case "$1" in |
1593 | - --allow-padding=*) padding="${1#--allow-padding=}"; shift;; |
1594 | - --allow-padding) padding="$2"; shift 2;; |
1595 | - esac |
1596 | - local img="$1" size="$2" ret="" tok=":" |
1597 | - local oimgsize="" oblocks="" out="" blksize="" |
1598 | - local tbytes="" minblocks="" |
1599 | - out=$(ls -l "$img") && oimgsize=$(echo "$out" | awk '{print $5}') && |
1600 | - [ -n "$oimgsize" ] || |
1601 | - { error "failed to get size of $img"; return 1; } |
1602 | - |
1603 | - case "$size" in |
1604 | - +*) human2bytes "${size#+}" || |
1605 | - { error "failed convert '${size#+}' to bytes"; return 1; } |
1606 | - tbytes=$(($oimgsize+$_RET)) |
1607 | - ;; |
1608 | - *) human2bytes "$size" || |
1609 | - { error "failed convert '$size' to bytes"; return 1; } |
1610 | - tbytes=${_RET} |
1611 | - ;; |
1612 | - esac |
1613 | - |
1614 | - if [ -n "$padding" ]; then |
1615 | - human2bytes "$padding" || { |
1616 | - error "failed convert '$padding' to bytes"; |
1617 | - return 1; |
1618 | - } |
1619 | - padbytes=$_RET |
1620 | - fi |
1621 | - |
1622 | - out=$(e2fsck -fy "$img" 2>&1) || |
1623 | - { error "failed to e2fsck -fy '$img'"; error "$out"; return 1; } |
1624 | - |
1625 | - out=$(LC_ALL=C dumpe2fs "$img" 2>/dev/null) || |
1626 | - { error "failed 'dumpe2fs $img'"; return 1; } |
1627 | - oblocks=$(printf "%s\n" "$out" | |
1628 | - awk '$0 ~ /^Block count:/ { print $3 }') && |
1629 | - [ -n "$oblocks" ] || { |
1630 | - error "failed to record blocks in $img" |
1631 | - return |
1632 | - } |
1633 | - |
1634 | - blksize=$(printf "%s\n" "$out" | |
1635 | - awk '$0 ~ /^Block size:/ { print $3 }') |
1636 | - |
1637 | - out=$(LC_ALL=C resize2fs -P "$img" 2>/dev/null) || |
1638 | - { error "failed to get min image size"; return 1; } |
1639 | - minblocks=$(printf "%s\n" "$out" | awk '$0 ~ /minimum/ { print $NF }') |
1640 | - [ -n "$minblocks" ] || |
1641 | - { error "failed to get min blocks in '$img'"; return 1; } |
1642 | - |
1643 | - local tblocks=$(($tbytes/$blksize)) |
1644 | - local des_blocks=$tblocks |
1645 | - if [ -n "$padding" ]; then |
1646 | - if [ $(($minblocks+($padbytes/$blksize))) -gt $tblocks ]; then |
1647 | - des_blocks=$((minblocks+($padbytes/$blksize))) |
1648 | - error "WARN: '--allow-padding=$padding'." |
1649 | - error " minblocks=$minblocks target=$tblocks desired=$des_blocks" |
1650 | - elif [ $((minblocks+$(($padbytes/$blksize)))) -lt $tblocks ]; then |
1651 | - ddebug 1 "do not need pad, target=$tblocks > $minblocks+$padding" |
1652 | - fi |
1653 | - fi |
1654 | - |
1655 | - if [ $des_blocks -lt $minblocks ]; then |
1656 | - error "target blocks '$tblocks' smaller than minblocks '$minblocks'" |
1657 | - error "fail: Could not resize to $size. ($tblocks * $blksize)" |
1658 | - error " minblocks=$minblocks target=$tblocks desired=$des_blocks" |
1659 | - return 1 |
1660 | - fi |
1661 | - tbytes=$(($des_blocks*$blksize)) |
1662 | - |
1663 | - ddebug 1 "targetting $tbytes ($des_blocks*$blksize) bytes." |
1664 | - ddebug 1 "fs is currently $oblocks * $blksize." |
1665 | - ddebug 1 "resize to $des_blocks. minblocks=$minblocks. target=$tblocks" |
1666 | - |
1667 | - if [ "$oimgsize" -lt "$tbytes" ]; then |
1668 | - truncate --size=$tbytes "$img" || |
1669 | - { error "failed to resize image to $tbytes"; return 1; } |
1670 | - fi |
1671 | - |
1672 | - out=$(e2fsck -fy "$img" 2>&1) || |
1673 | - { error "failed to e2fsck -fy '$img'"; error "$out"; return 1; } |
1674 | - |
1675 | - out=$(resize2fs "$img" "$des_blocks" 2>&1) || |
1676 | - { error "failed resize '$img'"; error "$out"; return 1; } |
1677 | - |
1678 | - if [ "$oimgsize" -gt "$tbytes" ]; then |
1679 | - truncate --size=$tbytes "$img" |
1680 | - fi |
1681 | - |
1682 | - out=$(e2fsck -fy "$img" 2>&1) || |
1683 | - { error "failed to e2fsck -fy '$img'"; error "$out"; return 1; } |
1684 | - |
1685 | - _RET="$oimgsize:$oblocks" |
1686 | -} |
1687 | - |
1688 | -copy_filesystem_image() { |
1689 | - local src_img="$1" target_img="$2" size="${3:-1400M}" |
1690 | - local fstype="" label="" uuid="" tmpf="" out="" |
1691 | - tmpf=$(mktemp "${TMPDIR:-/tmp}/${0##*/}-copyfs.XXXXXX") || |
1692 | - { error "mktemp failed"; return 1; } |
1693 | - blkid -o export "${src_img}" > "$tmpf" || |
1694 | - { rm -f "$tmpf"; error "blkid ${src_img} failed"; return 1; } |
1695 | - out=$(UUID=""; TYPE=""; LABEL=""; . "$tmpf" && echo "$TYPE $UUID $LABEL") |
1696 | - [ $? -eq 0 ] || fail "failed reading blkid information for $src_img" |
1697 | - set -- ${out} |
1698 | - fstype="$1" |
1699 | - uuid="$2" |
1700 | - label="$3" |
1701 | - rm -f "$tmpf" |
1702 | - |
1703 | - debug 1 "src image uuid=$uuid label=$label fstype=$fstype" |
1704 | - truncate "--size=$size" "$target_img" || |
1705 | - { error "truncate $target_img $size failed"; return 1; } |
1706 | - case "$fstype" in |
1707 | - ext*) mkfs_ext4 "--type=$fstype" "$target_img" "$label" "$uuid";; |
1708 | - *) error "unknown filesystem type '$fstype'";; |
1709 | - esac |
1710 | - |
1711 | - sudo bash -ec ' |
1712 | - s_img=$1 |
1713 | - t_img=$2 |
1714 | - s_mp="" |
1715 | - t_mp="" |
1716 | - fail() { echo "$@" 1>&2; exit 1; } |
1717 | - cleanup() { |
1718 | - for t in "$t_mp" "$s_mp"; do [ -z "$t" ] || umount "$t"; done; |
1719 | - rm -Rf "$tmpd"; |
1720 | - } |
1721 | - |
1722 | - tmpd=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") && |
1723 | - mkdir "$tmpd/src" "$tmpd/tgt" || |
1724 | - fail "failed making tmpdir" |
1725 | - trap cleanup EXIT |
1726 | - mount -o loop,ro "$s_img" "$tmpd/src" && s_mp="$tmpd/src" || |
1727 | - fail "failed mount $s_img"; |
1728 | - mount -o loop "$t_img" "$tmpd/tgt" && t_mp="$tmpd/tgt" || |
1729 | - fail "failed mount $t_img"; |
1730 | - rsync -aXHAS "${s_mp}/" "${t_mp}/" || |
1731 | - fail "failed copy data ${s_img} -> ${t_img}"' \ |
1732 | - copy-source-to-target "$src_img" "$target_img" || { |
1733 | - error "copy data from $src_img -> $target_img failed" |
1734 | - return 1; |
1735 | - } |
1736 | -} |
1737 | - |
1738 | -allow_resize_failure() { |
1739 | - local arch="$1" bdist="" barch="" |
1740 | - barch=${2:-$(uname -m)} |
1741 | - bdist=${3:-$(lsb_release -sc)} |
1742 | - |
1743 | - local info="arch=$arch build-system=$bdist/$barch" |
1744 | - if [ "$arch" = "arm64" ] && |
1745 | - [ "$barch" = "x86_64" -o -z "${barch#i?86}" ] && |
1746 | - [ "$bdist" != "trusty" ]; then |
1747 | - error "***************************" |
1748 | - error "WARN: resize2fs fail allowed for $info" |
1749 | - error "" |
1750 | - error "resize2fs is less aggresive in versions" |
1751 | - error "newer than trusty: http://pad.lv/1415077" |
1752 | - error "***************************" |
1753 | - return 0 |
1754 | - else |
1755 | - error "resize image failure not allowed for $info" |
1756 | - return 1 |
1757 | - fi |
1758 | -} |
1759 | - |
1760 | -handle_kpack() { |
1761 | - local short_opts="v" |
1762 | - local long_opts="dtb:,kihelper:,proposed" |
1763 | - local getopt_out="" |
1764 | - getopt_out=$(getopt --name "handle_kpack" \ |
1765 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
1766 | - eval set -- "${getopt_out}" || |
1767 | - { bad_Usage; return; } |
1768 | - |
1769 | - local dtbs pt img outd ckpkg tkout tiout |
1770 | - dtbs=( ) |
1771 | - pt=( ) |
1772 | - while [ $# -ne 0 ]; do |
1773 | - cur="$1"; next="$2"; |
1774 | - case "$cur" in |
1775 | - --proposed) pt[${#pt[@]}]="--proposed";; |
1776 | - --dtb) dtbs[${#dtbs[@]}]="$next"; shift;; |
1777 | - --kihelper) pt[${#pt[@]}]="$cur=$next"; shift;; |
1778 | - --) shift; break;; |
1779 | - esac |
1780 | - shift; |
1781 | - done |
1782 | - # tkout, tiout = target kernel out, target initrd out |
1783 | - img="$1"; ckpkg="$2"; tkout="$3"; tiout="$4" |
1784 | - shift 4 |
1785 | - outd="${TEMP_D}/$ckpkg" |
1786 | - mkdir -p "$outd" || |
1787 | - { error "failed tempdir for '$ckpkg'"; return 1; } |
1788 | - |
1789 | - local cmd="" |
1790 | - cmd=( env kpack-from-image \ |
1791 | - $vflags "${pt[@]}" "$imgfile" "$ckpkg" "$outd" ) |
1792 | - ddebug 1 "$(date -R): starting ${cmd[*]}" |
1793 | - "${cmd[@]}" || |
1794 | - { error "failed to get $ckpkg output"; return 1; } |
1795 | - ensure_file_d "$tkout" "$tiout" || |
1796 | - { error "failed to make dirs for $tkout or $tiout"; return 1; } |
1797 | - mv "$outd/kernel" "$tkout" && |
1798 | - mv "$outd/initrd" "$tiout" || |
1799 | - { error "failed copying files"; return 1; } |
1800 | - |
1801 | - local darg="" bname="" outf="" |
1802 | - for darg in "${dtbs[@]}"; do |
1803 | - # format is name=output. and kpack-from-image names |
1804 | - # files dtb-<name> |
1805 | - bname=${darg%%=*} |
1806 | - outf=${darg#*=} |
1807 | - ensure_file_d "$outf" || { error "failed mkdir for $outf"; return 1; } |
1808 | - if [ -f "$outd/dtb-$bname" ]; then |
1809 | - mv "$outd/dtb-$bname" "$outf" || |
1810 | - { error "failed moving dtb-$bname to $outf"; return 1; } |
1811 | - elif [ -f "$outd/dtb-$bname.dtb" ]; then |
1812 | - mv "$outd/dtb-$bname.dtb" "$outf" || |
1813 | - { error "failed moving dtb-$bname.dtb to $outf"; return 1; } |
1814 | - else |
1815 | - error "did not find dtb file $bname" |
1816 | - return 1; |
1817 | - fi |
1818 | - done |
1819 | -} |
1820 | - |
1821 | -inargs() { |
1822 | - #inargs(needle, [haystack]) |
1823 | - # return true if needle is in haystack |
1824 | - local needle="$1" i="" |
1825 | - shift |
1826 | - for i in "$@"; do |
1827 | - [ "$i" = "$needle" ] && return 0 |
1828 | - done |
1829 | - return 1 |
1830 | -} |
1831 | - |
1832 | -main() { |
1833 | - local short_opts="a:fhk:p:v" |
1834 | - local long_opts="arch:,help,format:,kernel:,krd-pack:,manifest:,no-gzip,proposed,verbose" |
1835 | - local getopt_out="" |
1836 | - getopt_out=$(getopt --name "${0##*/}" \ |
1837 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
1838 | - eval set -- "${getopt_out}" || |
1839 | - { bad_Usage; return; } |
1840 | - |
1841 | - local cur="" next="" output="" gzip=true kpkg="" |
1842 | - local kpacks="" src_in="" src="" arch="" vflags="" fmt="auto" |
1843 | - local working_space="1024M" zero_img="true" fs_img_size="1400M" |
1844 | - local manifest_out="" proposed_flag="" |
1845 | - kpacks=( ) |
1846 | - |
1847 | - while [ $# -ne 0 ]; do |
1848 | - cur="$1"; next="$2"; |
1849 | - case "$cur" in |
1850 | - -h|--help) Usage ; exit 0;; |
1851 | - -a|--arch) arch="$next"; shift;; |
1852 | - -f|--format) fmt="$next"; shift;; |
1853 | - -k|--kernel) kpkg=$next; shift;; |
1854 | - --manifest) manifest_out="$next";; |
1855 | - -p|--krd-pack) kpacks[${#kpacks[@]}]="$next"; shift;; |
1856 | - --no-gzip) gzip=false;; |
1857 | - --proposed) proposed_flag="--proposed";; |
1858 | - -v|--verbose) VERBOSITY=$((${VERBOSITY}+1)); vflags="${vflags}v";; |
1859 | - --) shift; break;; |
1860 | - esac |
1861 | - shift; |
1862 | - done |
1863 | - |
1864 | - [ $# -eq 2 ] || { bad_Usage "must provide source and target"; return; } |
1865 | - src_in="$1" |
1866 | - output="$2" |
1867 | - [ -z "$vflags" ] || vflags="-$vflags" |
1868 | - |
1869 | - PATH="$(dirname "$0"):$PATH" |
1870 | - command -v "maas-cloudimg2ephemeral" >/dev/null 2>&1 || |
1871 | - { error "do not have maas-cloudimg2ephemeral in path"; return 1; } |
1872 | - |
1873 | - inargs "$fmt" "${VALID_FORMATS[@]}" || { |
1874 | - error "provided '--format=$fmt' not a valid format:" \ |
1875 | - "${VALID_FORMATS[*]}" |
1876 | - return 1; |
1877 | - } |
1878 | - |
1879 | - [ -z "$kpkg" ] && { |
1880 | - error "no '--kernel' provided, choosing 'linux-generic'" |
1881 | - kpkg="linux-generic" |
1882 | - } |
1883 | - |
1884 | - TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || |
1885 | - { error "failed to make tempdir"; return 1; } |
1886 | - trap cleanup EXIT |
1887 | - |
1888 | - if [ -f "$src_in" ]; then |
1889 | - src="$src_in" |
1890 | - else |
1891 | - case "$src_in" in |
1892 | - http://*|https://*|ftp://*) |
1893 | - ddebug 1 "getting source $src_in" |
1894 | - src="${TEMP_D}/${src_in##*/}" |
1895 | - wget "$src_in" --dot-style=mega -O "$src" || |
1896 | - { error "failed download $src_in"; return 1; } |
1897 | - ;; |
1898 | - file://*) |
1899 | - [ -f "${src_in#file://}" ] || |
1900 | - { error "$src_in: not a file"; return 1; } |
1901 | - src="${src_in#file://}" |
1902 | - ;; |
1903 | - *) error "Unable to handle src: $src_in"; return 1;; |
1904 | - esac |
1905 | - fi |
1906 | - |
1907 | - # now src is either a .tar.gz file, a -root.tar.gz, or a .img file |
1908 | - local imgfile="${TEMP_D}/root.img" |
1909 | - ddebug 1 "getting .img from $src fmt=$fmt" |
1910 | - get_img_file "$fmt" "$src" "$imgfile" "${TEMP_D}" || |
1911 | - { error "failed to get image file from $src"; return 1; } |
1912 | - fmt=${_RET} |
1913 | - |
1914 | - if [ "$fmt" = "root-tar" ]; then |
1915 | - working_space="" |
1916 | - fi |
1917 | - |
1918 | - if [ "$src" -ef "$imgfile" ]; then |
1919 | - rm -f "$imgfile" |
1920 | - ddebug 1 "copying $src_in to $imgfile" |
1921 | - cp --sparse=always "$src" "$imgfile" || |
1922 | - { error "failed to copy $src_in to temp"; return 1; } |
1923 | - chmod u+w "$imgfile" || |
1924 | - { error "failed to give write perms to $imgfile"; return 1; } |
1925 | - fi |
1926 | - |
1927 | - ensure_file_d "$output" || |
1928 | - { error "failed to create dir for $output"; return 1; } |
1929 | - |
1930 | - local restore_img_info="" |
1931 | - if [ -n "$working_space" ]; then |
1932 | - ddebug 1 "getting '$working_space' in $imgfile" |
1933 | - resize_image "$imgfile" "+$working_space" || |
1934 | - { error "failed to grow $imgfile by $working_space"; return 1; } |
1935 | - restore_img_info="$_RET" |
1936 | - fi |
1937 | - |
1938 | - # now imgfile has the root filesystem image to adjust |
1939 | - local pkout="${TEMP_D}/$kpkg-kernel" piout="${TEMP_D}/$kpkg-initrd" |
1940 | - local manif="${TEMP_D}/manifest" |
1941 | - local mc2ephem="" |
1942 | - mc2ephem=( maas-cloudimg2ephemeral $vflags ${arch:+"--arch=$arch"} |
1943 | - $proposed_flag "$imgfile" "$kpkg" "$pkout" "$piout" "$manif" ) |
1944 | - ddebug 1 "starting ${mc2ephem[*]}" |
1945 | - "${mc2ephem[@]}" || |
1946 | - { error "failed to turn $imgfile to ephemeral"; return 1; } |
1947 | - [ -z "$manifest_out" ] || cp "$manif" "$manifest_out" || |
1948 | - { error "failed copying manifest to $manifest_out"; return 1; } |
1949 | - |
1950 | - local i="" oifs="$IFS" |
1951 | - ddebug 1 "starting kpacks: ${kpacks[*]}" |
1952 | - for i in "${kpacks[@]}"; do |
1953 | - IFS=","; set -- $i; IFS="$oifs" |
1954 | - # handle_kpack doesn't actually need $proposed_flag, because $imgfile |
1955 | - # will have it already enabled, but passing it is more obvious. |
1956 | - handle_kpack $proposed_flag "$imgfile" "$@" || |
1957 | - { error "handle_kpack '$imgfile' $* failed"; return 1; } |
1958 | - done |
1959 | - ddebug 1 "kpacks done" |
1960 | - |
1961 | - local pad="" tmp_img_size="$fs_img_size" |
1962 | - if [ "$arch" = "ppc64el" ]; then |
1963 | - ## ppc64el wily do not fit in 1400M. Instead of allowing this across |
1964 | - ## the board, we're going to keep the 1400M standard other places. |
1965 | - ## the 'pad' of 100M gives ~ 100M wiggle room in image. |
1966 | - tmp_img_size="1600M" |
1967 | - pad="100M" |
1968 | - fi |
1969 | - ddebug 1 "copying working img into new fs of $tmp_img_size (pad=$pad)" |
1970 | - local timg="$imgfile.fs_img_size" |
1971 | - copy_filesystem_image "$imgfile" "$timg" "$tmp_img_size" || |
1972 | - error "failed copying $imgfile to $timg" |
1973 | - |
1974 | - if [ -n "$pad" ]; then |
1975 | - ddebug 1 "adjusting image to fit $fs_img_size with pad=$pad" |
1976 | - resize_image "--allow-padding=$pad" "$timg" "$fs_img_size" |
1977 | - fi |
1978 | - |
1979 | - if $zero_img; then |
1980 | - ddebug 1 "zeroing img" |
1981 | - e2fsck -fy "$imgfile" || { error "failed to e2fsck $imgfile"; return 1; } |
1982 | - zerofree "$imgfile" || { error "failed zerofree $imgfile"; return 1; } |
1983 | - fi |
1984 | - |
1985 | - if [ "$fmt" = "squashfs-image" ]; then |
1986 | - local squash_out="" |
1987 | - squash_out=$(dirname "$output")/$(basename "$src") |
1988 | - |
1989 | - # This is not perfect, but if these things imply a change |
1990 | - # to the image rather than re-using the input. |
1991 | - if [ -n "${proposed_flag}" ] || |
1992 | - [ -n "${M2E_ADD_REPOS}" -o -n "${M2E_ADD_PACKAGES}" ]; then |
1993 | - debug 1 "creating a new squashfs in $squash_out from $imgfile" |
1994 | - sudo mount-image-callback "$imgfile" --read-only -- sh -ec ' |
1995 | - src="$1"; out="$2"; owner="$3"; tmp="$out.$$" |
1996 | - trap "rm -f \"$tmp\"" EXIT |
1997 | - mksquashfs "$src" "$tmp" -xattrs -comp xz |
1998 | - chown "$owner" "$tmp" |
1999 | - mv "$tmp" "$out" |
2000 | - ' newsquash-img _MOUNTPOINT_ \ |
2001 | - "${squash_out}" "$(id -u):$(id -g)" || { |
2002 | - error "Failed mksquashfs from $imgfile" |
2003 | - return 1 |
2004 | - } |
2005 | - else |
2006 | - cp "$src" "${squash_out}" || { |
2007 | - error "copy SquashFS image from $src -> $squash_out failed" |
2008 | - return 1; |
2009 | - } |
2010 | - fi |
2011 | - fi |
2012 | - |
2013 | - if $gzip; then |
2014 | - ddebug 1 "gzipping image file" |
2015 | - local stime=$SECONDS |
2016 | - gzip -9 --rsyncable "$timg" && |
2017 | - mv --force "$timg.gz" "$output" || |
2018 | - { error "failed gzip"; return 1; } |
2019 | - ddebug 1 "gzip took $(($SECONDS-$stime))s" |
2020 | - else |
2021 | - mv --force "$timg" "$output" || |
2022 | - { error "failed move to $output"; return 1; } |
2023 | - fi |
2024 | - |
2025 | - ddebug 1 "finished" |
2026 | - return 0 |
2027 | -} |
2028 | - |
2029 | -main "$@" |
2030 | -# vi: ts=4 expandtab |
2031 | |
2032 | === target is u'moved-to-git' |
2033 | === modified file 'bin/maas-cloudimg2ephemeral' |
2034 | --- bin/maas-cloudimg2ephemeral 2018-07-09 18:28:07 +0000 |
2035 | +++ bin/maas-cloudimg2ephemeral 1970-01-01 00:00:00 +0000 |
2036 | @@ -1,725 +0,0 @@ |
2037 | -#!/bin/bash |
2038 | -# |
2039 | -# maas-cloudimg2ephemeral - update a cloud image to make it sufficient |
2040 | -# for use as a maas ephemeral image |
2041 | -# |
2042 | -# Copyright (C) 2011-2012 Canonical |
2043 | -# |
2044 | -# Authors: |
2045 | -# Scott Moser <scott.moser@canonical.com> |
2046 | -# |
2047 | -# This program is free software: you can redistribute it and/or modify |
2048 | -# it under the terms of the GNU Affero General Public License as |
2049 | -# published by the Free Software Foundation, version 3 of the License. |
2050 | -# |
2051 | -# This program is distributed in the hope that it will be useful, |
2052 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2053 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2054 | -# GNU Affero General Public License for more details. |
2055 | -# |
2056 | -# You should have received a copy of the GNU Affero General Public License |
2057 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2058 | - |
2059 | -_APT_UPDATED=false |
2060 | -IMAGES_PPA_APT_KEY="-----BEGIN PGP PUBLIC KEY BLOCK----- |
2061 | -Version: SKS 1.0.10 |
2062 | - |
2063 | -mI0ETxf8lwEEAMAqtJVUnlCVzjTOsohaE/M4mGHFl4Py1cuE9ryOgmTWje+6BrNjtWLSfTQJ |
2064 | -Kp1V6hViUoxPBck1qkZoAz7VU5nDuBWDybCsolliUX4zzTYNiDnPS74fs4CDUWx9qpl5Sdb6 |
2065 | -7aygIid/mFXubhJnTPR6Bq9ptGmc0Ks6ttNs3WJ/ABEBAAG0IkxhdW5jaHBhZCBQUEEgZm9y |
2066 | -IE1hYVMgTWFpbnRhaW5lcnOIuAQTAQIAIgUCTxf8lwIbAwYLCQgHAwIGFQgCCQoLBBYCAwEC |
2067 | -HgECF4AACgkQXP8eqZPujMU2zQP/W9OCzaU7HvFrqEt6nHGej2PEanIunxo7J8D5OR+Yl578 |
2068 | -FpRkHRgvcdQnGuZUpdBnOFatDDFME7ClN9qUrD1wDN1r9ip2luaKiO2cZOW4Uu5Z0n/3Qc6J |
2069 | -eh9TNspyDMuHVVZ5GiAk+GXgF1m7ps5lCnOCZK/pXUEEUOS8AWnt3sM= |
2070 | -=1RpZ |
2071 | ------END PGP PUBLIC KEY BLOCK-----" |
2072 | -IMAGES_PPA_FILE="/etc/apt/sources.list.d/maas-ephemeral-images.list" |
2073 | -IMAGES_PPA_URL="http://ppa.launchpad.net/maas-maintainers/maas-ephemeral-images/ubuntu" |
2074 | - |
2075 | -UBUNTU_MIRROR=${UBUNTU_MIRROR:-"http://archive.ubuntu.com/ubuntu/"} |
2076 | -UBUNTU_MIRROR_PORTS=${UBUNTU_MIRROR_PORTS:-"http://ports.ubuntu.com/ubuntu-ports/"} |
2077 | -PROPOSED_ARCHIVE_FILE="/etc/apt/sources.list.d/proposed.list" |
2078 | - |
2079 | -VERBOSITY=0 |
2080 | -TOP_D="${0%/*}" |
2081 | -DISABLE_SUFFIX=".eph-temp-disabled" |
2082 | -command -v unshare-pidns >/dev/null 2>&1 || PATH="${0%/*}:$PATH" |
2083 | - |
2084 | -error() { echo "$@" 1>&2; } |
2085 | -errorp() { printf "$@" 1>&2; } |
2086 | -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } |
2087 | -failp() { [ $# -eq 0 ] || errorp "$@"; exit 1; } |
2088 | - |
2089 | -Usage() { |
2090 | - cat <<EOF |
2091 | -Usage: ${0##*/} [ options ] disk kpkg kernel initrd [manifest] |
2092 | - |
2093 | - Update the image 'disk', installing 'kpkg' |
2094 | - copy out kernel and initramfs tothe kernel 'kernel' and initrd 'initrd' |
2095 | - If manifest is given, a (dpkg --show) manifest will be written. |
2096 | - |
2097 | - Expects to receive in a cloudimg disk image with no partition |
2098 | - table, and will update it for maas ephemeral use. |
2099 | - |
2100 | - options: |
2101 | - -v | --verbose increase verbosity |
2102 | -EOF |
2103 | -} |
2104 | - |
2105 | -bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return; } |
2106 | - |
2107 | -debug() { |
2108 | - local level=${1}; shift; |
2109 | - [ "${level}" -gt "${VERBOSITY}" ] && return |
2110 | - error "$(date -R):" "${@}" |
2111 | -} |
2112 | - |
2113 | -disable_services() { |
2114 | - local dir="$1" |
2115 | - cat > "$dir/usr/sbin/policy-rc.d" <<"EOF" |
2116 | -#!/bin/sh |
2117 | -while true; do |
2118 | - case "$1" in |
2119 | - -*) shift ;; |
2120 | - makedev) exit 0 ;; |
2121 | - x11-common) exit 0 ;; |
2122 | - *) exit 101 ;; |
2123 | - esac |
2124 | -done |
2125 | -EOF |
2126 | - [ $? -eq 0 ] && chmod 755 "$dir/usr/sbin/policy-rc.d" || |
2127 | - { error "failed to write policy-rc.d"; return 1; } |
2128 | - |
2129 | - ( set -e; |
2130 | - cd "$dir" |
2131 | - for f in ./etc/kernel/*.d/*-grub; do |
2132 | - [ -x "$f" ] || continue |
2133 | - abs=${f#.} |
2134 | - debug 2 "Disabling $abs via dpkg-divert rename" |
2135 | - chroot "$dir" dpkg-divert --local --rename --divert \ |
2136 | - "${abs}${DISABLE_SUFFIX}" "${abs}" |
2137 | - done |
2138 | - ) |
2139 | -} |
2140 | - |
2141 | -undisable_services() { |
2142 | - local dir="$1" |
2143 | - rm -f "$dir/usr/sbin/policy-rc.d" |
2144 | - |
2145 | - ( set -e; |
2146 | - cd "$dir" |
2147 | - for f in ./etc/kernel/*.d/*${DISABLE_SUFFIX}; do |
2148 | - [ -e "$f" ] || continue |
2149 | - abs=${f#.} |
2150 | - orig=${abs%${DISABLE_SUFFIX}} |
2151 | - debug 2 "Re-enabling $orig via dpkg-divert removal." |
2152 | - chroot "$dir" dpkg-divert --local --remove --rename --divert \ |
2153 | - "${abs}" "${orig}" |
2154 | - done |
2155 | - ) |
2156 | -} |
2157 | - |
2158 | -check_required_vars() { |
2159 | - local req="" missing="" |
2160 | - for req in "$@"; do |
2161 | - [ -n "${!req}" ] || missing="${missing} ${req}" |
2162 | - done |
2163 | - missing=${missing# } |
2164 | - _RET="$missing" |
2165 | - [ -z "$_RET" ] |
2166 | -} |
2167 | - |
2168 | -show_vars() { |
2169 | - local var |
2170 | - for var in "$@"; do |
2171 | - printf "%s=%s\n" "$var" "${!var}" |
2172 | - done |
2173 | -} |
2174 | - |
2175 | -_apt_update() { |
2176 | - if [ "${_APT_UPDATED}" != "true" ]; then |
2177 | - log_change true "run apt-update${1:+ [$1]}." |
2178 | - _apt update |
2179 | - _APT_UPDATED=true |
2180 | - fi |
2181 | -} |
2182 | - |
2183 | -_apt() { |
2184 | - local emd=$(which eatmydata 2>/dev/null || :) |
2185 | - case "$1" in |
2186 | - upgrade|dist-upgrade|install) _apt_update "$1";; |
2187 | - esac |
2188 | - debug 1 "$emd apt-get ${apt_opts} --quiet --assume-yes $*" |
2189 | - $emd apt-get ${apt_opts} -q --assume-yes "$@" </dev/null; |
2190 | -} |
2191 | - |
2192 | -log_change() { |
2193 | - local change="$1" |
2194 | - shift |
2195 | - if $change; then |
2196 | - echo "CHANGE:" "$@" |
2197 | - else |
2198 | - echo "NO_CHANGE:" "$@" |
2199 | - fi |
2200 | -} |
2201 | - |
2202 | -filter_installed_packages() { |
2203 | - # write to stdout, a list of packages not installed locally |
2204 | - local fmt='${Package} ${Version}\n' |
2205 | - LC_ALL=C dpkg-query --show "--showformat=${fmt}" "$@" 2>&1 | awk ' |
2206 | - $0 ~ /[Nn]o packages/ { |
2207 | - sub("[.]$","",$NF); |
2208 | - pkgs[n]=$NF; |
2209 | - n=n+1; |
2210 | - } |
2211 | - $2 == "" { |
2212 | - pkgs[n]=$1; |
2213 | - n=n+1; |
2214 | - }; |
2215 | - END { for(p in pkgs) {printf("%s ",pkgs[p])}; printf("\n"); }' n=0 |
2216 | -} |
2217 | - |
2218 | -get_new_pkgs() { |
2219 | - # get_new_pkgs(manifest_in, manifest_out) |
2220 | - # return a list of packages in manifest_out that are not in manifest_in |
2221 | - _RET=$(set -o pipefail |
2222 | - cat "$1" "$1" "$2" | awk '-F\t' '{print $1}' | sort | uniq -u) && |
2223 | - (set -f; echo $_RET) |
2224 | -} |
2225 | -get_removed_pkgs() { |
2226 | - # get_removed_pkgs(manifest_in, manifest_out) |
2227 | - # return a list of packages manifest_in not in manifest_out |
2228 | - _RET=$(set -o pipefail |
2229 | - cat "$1" "$2" "$2" | awk '-F\t' '{print $1}' | sort | uniq -u) && |
2230 | - (set -f; echo $_RET) |
2231 | -} |
2232 | - |
2233 | -ensure_iscsi_initramfs_support() { |
2234 | - local root="${1:-/}" release="$2" |
2235 | - local fname="/etc/iscsi/iscsi.initramfs" |
2236 | - local mfile="${root%/}$fname" |
2237 | - local change="touch $fname for iscsi root shutdown (LP: #1536707)" |
2238 | - if [ -f "$mfile" ]; then |
2239 | - log_change false "$change" "[file existed]" |
2240 | - return 0 |
2241 | - fi |
2242 | - case "$release" in |
2243 | - precise|quantal|raring|saucy|trusty|utopic) :;; |
2244 | - *) |
2245 | - log_change false "$change" "[systemd]" |
2246 | - return 0 |
2247 | - ;; |
2248 | - esac |
2249 | - mkdir -p "${mfile%/*}" && touch "$mfile" || |
2250 | - { error "failed to create iscsi.initramfs"; return 1; } |
2251 | - log_change true "$change" |
2252 | -} |
2253 | - |
2254 | -add_repos() { |
2255 | - local repos="$1" |
2256 | - ( |
2257 | - # repos can be space or , delimited |
2258 | - oifs="$IFS" |
2259 | - set -f |
2260 | - set -e |
2261 | - case "$repos" in |
2262 | - *,*) IFS=","; set -- $repos; IFS="$oifs";; |
2263 | - *) set -- $repos; IFS="$oifs"; |
2264 | - esac |
2265 | - log_change true "$change: $repos" |
2266 | - for i in "$@"; do |
2267 | - debug 1 " $i" |
2268 | - add-apt-repository -y "$i" </dev/null |
2269 | - done |
2270 | - ) |
2271 | -} |
2272 | - |
2273 | -apply_updates_chrooted() { |
2274 | - # FIXME: remove this after no longer necessary |
2275 | - local required="" known="" |
2276 | - local release="" arch="" VERBOSITY=${_VERBOSITY:-1} |
2277 | - local ppa_clear=${PPA_CLEAR:-true} change="" dist_upgrade=${DIST_UPGRADE:-false} |
2278 | - local proposed=${proposed:-false} |
2279 | - local repos="${m2e_repos}" add_packages="${m2e_add_packages}" |
2280 | - required="kpkg pubd" |
2281 | - known="apt_opts PPA_CLEAR VERBOSITY DIST_UPGRADE" |
2282 | - |
2283 | - export LC_ALL=C FLASH_KERNEL_SKIP=1 |
2284 | - export DEBIAN_FRONTEND=noninteractive |
2285 | - |
2286 | - check_required_vars ${required} || |
2287 | - { error "$FUNCNAME: missing required vars: $_RET"; return 1; } |
2288 | - |
2289 | - if [ "$VERBOSITY" -ge 1 ]; then |
2290 | - show_vars $required $known 1>&2 |
2291 | - fi |
2292 | - |
2293 | - release=$(lsb_release -sc) || |
2294 | - { error "failed to get release"; return 1; } |
2295 | - |
2296 | - arch="$(dpkg --print-architecture)" || |
2297 | - { error "failed to get dpkg arch"; return 1; } |
2298 | - |
2299 | - |
2300 | - mkdir -p "$pubd" || { error "failed to create pubdir '$pubd'"; return 1; } |
2301 | - |
2302 | - dpkg-query --show > "$pubd/manifest.in" |
2303 | - |
2304 | - change="add additional repos." |
2305 | - if [ -n "$repos" ]; then |
2306 | - add_repos "$repos" || { |
2307 | - error "Failed to add repos: $repos" |
2308 | - return 1; |
2309 | - } |
2310 | - log_change true "$change [$repos]" |
2311 | - debug 1 "due to 'M2E_ADD_REPOS', setting dist-upgrade=true" |
2312 | - dist_upgrade=true |
2313 | - else |
2314 | - log_change false "$change" |
2315 | - fi |
2316 | - |
2317 | - change="images ppa for cloud-init and maas-enlist (LP: #1511482, 1515733)" |
2318 | - if [ "$release" = "precise" ]; then |
2319 | - # apt-add-repository failed when trying quantal amd64 with qemu-static. |
2320 | - # so instead do this manually. |
2321 | - log_change true "$change" |
2322 | - debug 1 "configuring PPA at $IMAGES_PPA_URL" |
2323 | - echo "deb $IMAGES_PPA_URL $release main" > "$IMAGES_PPA_FILE" || |
2324 | - { error "failed writing to $IMAGES_PPA_FILE"; return 1; } |
2325 | - printf "%s\n" "$IMAGES_PPA_APT_KEY" | apt-key add - || |
2326 | - { error "apt-key add failed!"; return 1; } |
2327 | - debug 1 "addition of PPA turns dist-upgrade on" |
2328 | - dist_upgrade=true |
2329 | - else |
2330 | - log_change false "$change" |
2331 | - debug 1 "not adding images ppa to release=$release" |
2332 | - fi |
2333 | - |
2334 | - change="enable proposed" |
2335 | - if $proposed; then |
2336 | - local mirror="" |
2337 | - case "$arch" in |
2338 | - i?86|amd64) mirror="${UBUNTU_MIRROR}";; |
2339 | - *) mirror="${UBUNTU_MIRROR_PORTS}";; |
2340 | - esac |
2341 | - log_change true "$change [$arch $mirror]" |
2342 | - debug 1 "enabling proposed for $release [$arch $mirror]" |
2343 | - echo "deb $mirror ${release}-proposed main universe multiverse" > "$PROPOSED_ARCHIVE_FILE" || |
2344 | - { error "failed writing to $PROPOSED_ARCHIVE_FILE"; return 1; } |
2345 | - debug 1 "addition of proposed turns dist-upgrade on" |
2346 | - dist_upgrade=true |
2347 | - else |
2348 | - log_change false "$change" |
2349 | - debug 1 "not enabling proposed for $release (proposed=$proposed)." |
2350 | - fi |
2351 | - |
2352 | - change="ensure mellanox mlx4_en gets loaded (LP: #1115710)" |
2353 | - if [ "$release" = "precise" -a ! -f "/etc/modprobe.d/mlx4.conf" ]; then |
2354 | - # packaged version would be mlx4.conf, to avoid conflict |
2355 | - # we install a different file here. |
2356 | - printf "%s\n%s; %s\n" \ |
2357 | - "# mlx4_core should load mlx4_en (LP: #1115710)." \ |
2358 | - "install mlx4_core /sbin/modprobe --ignore-install mlx4_core" \ |
2359 | - "/sbin/modprobe mlx4_en" \ |
2360 | - > "/etc/modprobe.d/mlx4.ephemeral.conf" |
2361 | - log_change true "$change" |
2362 | - else |
2363 | - log_change false "$change" |
2364 | - fi |
2365 | - |
2366 | - change="build-only: divert newaliases (LP: #1531299)" |
2367 | - local newaliases_hack=false |
2368 | - if [ "$cross" = "true" ] && [ -f /usr/bin/newaliases ]; then |
2369 | - log_change true "$change" |
2370 | - # work around LP: #1531299 |
2371 | - debug 1 "hacking around newaliases in cross root (LP: #1531299)" |
2372 | - dpkg-divert --local --rename --add /usr/bin/newaliases |
2373 | - ln -s /bin/true /usr/bin/newaliases |
2374 | - newaliases_hack=true |
2375 | - else |
2376 | - log_change false "$change" |
2377 | - fi |
2378 | - |
2379 | - local arch_pkgs="" toremove="" removed="" installed="" |
2380 | - local add_pkgs="" rel_pkgs="" kernel_pkg="" |
2381 | - if [ "$kpkg" != "none" ]; then |
2382 | - kernel_pkg="$kpkg" |
2383 | - fi |
2384 | - |
2385 | - # additional packages that we have to add |
2386 | - add_pkgs="cloud-initramfs-dyn-netconf" # LP: #1749019 |
2387 | - add_pkgs="${add_pkgs} open-iscsi overlayroot" |
2388 | - if [ -n "${add_packages}" ]; then |
2389 | - debug 1 "add_packages=$add_packages (from M2E_ADD_PACKAGES)" |
2390 | - add_pkgs="${add_pkgs} ${add_packages}" |
2391 | - fi |
2392 | - |
2393 | - # rel_pkgs: packages added only in some releases |
2394 | - case "$release" in |
2395 | - precise|quantal|raring|saucy|trusty|utopic|vivid) |
2396 | - rel_pkgs="${rel_pkgs} maas-enlist";; |
2397 | - esac |
2398 | - |
2399 | - change="add u-boot-tools to arch_pkgs for arch '$arch' (LP: #1640519)" |
2400 | - if [ "$arch" = "arm64" -o "$arch" = "armhf" ]; then |
2401 | - case "$release" in |
2402 | - precise|quantal|raring|saucy|trusty|utopic|vivid|wily|\ |
2403 | - xenial|yakkety) |
2404 | - arch_pkgs="${arch_pkgs} u-boot-tools" |
2405 | - debug 1 "release '$release' <= yakkety: $change" |
2406 | - ;; |
2407 | - *) debug 1 "release '$release' > yakkety: do not $change";; |
2408 | - esac |
2409 | - fi |
2410 | - |
2411 | - local removes="^linux-.*" keeps="^linux-base$" pkglist="" |
2412 | - pkglist=$(dpkg-query --show) || { error "failed dpkg-query"; return 1; } |
2413 | - toremove=$(echo "$pkglist" | |
2414 | - awk '$1 ~ rm && $1 !~ keeps { printf("%s ",$1); }' \ |
2415 | - "rm=$removes" "keeps=$keeps") && |
2416 | - toremove="${toremove% }" |
2417 | - [ $? -eq 0 ] || { error "failed getting list to remove"; return 1; } |
2418 | - |
2419 | - change="removing linux kernel packages." |
2420 | - if [ -z "$toremove" ]; then |
2421 | - error "nothing to remove: nothing match '$removes' and not '$keeps'." |
2422 | - log_change false "$change" |
2423 | - else |
2424 | - debug 1 "removing: $toremove" |
2425 | - ( set -f; _apt remove --purge $toremove ) || |
2426 | - { error "failed to remove $toremove"; return 1; } |
2427 | - log_change true "$change [$toremove]" |
2428 | - fi |
2429 | - removed="$toremove" |
2430 | - |
2431 | - change="apt-get dist-upgrade" |
2432 | - if [ "${dist_upgrade}" != "false" ]; then |
2433 | - log_change true "$change" |
2434 | - _apt dist-upgrade || |
2435 | - { error "failed apt-get dist-upgrade"; return 1; } |
2436 | - else |
2437 | - log_change false "$change" |
2438 | - fi |
2439 | - |
2440 | - local missing="" pkgs="$arch_pkgs $kernel_pkg $add_pkgs $rel_pkgs" |
2441 | - missing=$(filter_installed_packages $pkgs) |
2442 | - change="install missing packages" |
2443 | - if [ -n "$missing" ]; then |
2444 | - log_change true "$change [$missing]" |
2445 | - _apt install $missing || { |
2446 | - error "failed installing $missing"; |
2447 | - return 1; |
2448 | - } |
2449 | - else |
2450 | - log_change false "$change" |
2451 | - fi |
2452 | - installed="$missing" |
2453 | - |
2454 | - if ${ppa_clear} && [ -f "$IMAGES_PPA_FILE" ]; then |
2455 | - debug 1 "disabling ppa in $IMAGES_PPA_FILE." |
2456 | - sed -i "s,^,#," "$IMAGES_PPA_FILE" || |
2457 | - { error "failed to clear $IMAGES_PPA_FILE"; return 1; } |
2458 | - fi |
2459 | - |
2460 | - change="remove dpkg foreign architectures" |
2461 | - if dpkg --print-foreign-architectures | grep -q i386; then |
2462 | - log_change true "$change" |
2463 | - # precise used multiarch file |
2464 | - dpkg --remove-architecture i386 >/dev/null 2>&1 || |
2465 | - rm /etc/dpkg/dpkg.cfg.d/multiarch |
2466 | - dpkg --print-foreign-architectures | grep i386 && |
2467 | - { error "failed to remove i386 foreign arch"; return 1; } |
2468 | - debug 1 "removed foreign arch i386" |
2469 | - else |
2470 | - log_change false "$change" |
2471 | - fi |
2472 | - |
2473 | - change="run autoremove" |
2474 | - if [ -n "$removed" ]; then |
2475 | - log_change true "$change" |
2476 | - _apt autoremove || |
2477 | - { error "failed apt-get autoremove"; return 1; } |
2478 | - else |
2479 | - log_change false "$change" |
2480 | - fi |
2481 | - |
2482 | - log_change true "apt-get clean" |
2483 | - _apt clean || |
2484 | - { error "failed apt-get clean"; return 1; } |
2485 | - |
2486 | - if [ "$newaliases_hack" = "true" ]; then |
2487 | - debug 1 "restoring newaliases" |
2488 | - rm -f /usr/bin/newaliases |
2489 | - dpkg-divert --local --rename --remove /usr/bin/newaliases |
2490 | - ls -l /usr/bin/newaliases |
2491 | - fi |
2492 | - |
2493 | - # xenial should not need the symlink, but shipped GA with it |
2494 | - # so it is there for now. Releases pre-xenial do need it. |
2495 | - change="symlink ENI for cloud-initramfs-dyn-netconf (LP: #1534205)" |
2496 | - local f=/etc/network/interfaces |
2497 | - case "$release" in |
2498 | - precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial) |
2499 | - log_change true "$change" |
2500 | - mv "$f" "$f.dist" && ln -sf ../../run/network/dynamic-interfaces "$f" || |
2501 | - { error "failed to link dynamic interfaces"; return 1; } |
2502 | - ;; |
2503 | - *) log_change false "$change";; |
2504 | - esac |
2505 | - |
2506 | - ensure_iscsi_initramfs_support "/" "$release" || |
2507 | - { "ensure_iscsi_initramfs_support / $release failed"; return 1; } |
2508 | - |
2509 | - change="create /lib/modules (LP: #1543204)" |
2510 | - if [ ! -d "/lib/modules" ]; then |
2511 | - log_change true "$change" |
2512 | - mkdir /lib/modules || |
2513 | - { error "failed to create /lib/modules"; return 1; } |
2514 | - else |
2515 | - log_change false "$change" |
2516 | - fi |
2517 | - |
2518 | - change="update-initramfs" |
2519 | - if [ "$kpkg" != "none" ]; then |
2520 | - local k="" i="" |
2521 | - for i in /boot/vmlinu?-*; do |
2522 | - [ "${i%-virtual}" = "${i}" ] && k=${i}; |
2523 | - done |
2524 | - ver=${k##*/vmlinu?-} |
2525 | - log_change true "$change [$ver]" |
2526 | - debug 1 "updating kernel version '$ver'" |
2527 | - update-initramfs -u -k "$ver" || |
2528 | - { error "update-initramfs failed"; return 1; } |
2529 | - |
2530 | - cp /boot/initrd.img-$ver "$pubd/initrd.img" && |
2531 | - cp /boot/vmlinu?-$ver "$pubd/kernel.img" && |
2532 | - chmod ugo+r "$pubd/kernel.img" || |
2533 | - { error "failed to publish kernel files to $pubd"; return 1; } |
2534 | - else |
2535 | - log_change false "$change" |
2536 | - debug 1 "kernel package = 'none'. No kernels published." |
2537 | - fi |
2538 | - dpkg-query --show > "$pubd/manifest" || |
2539 | - { error "failed to publish manifest to $pubd"; return 1; } |
2540 | - |
2541 | - return 0 |
2542 | -} |
2543 | - |
2544 | -apply_updates() { |
2545 | - # apply_updates(dir, kernel_out, initramfs_out) |
2546 | - # update directory given, and pull out kernel and initramfs |
2547 | - # to given locations |
2548 | - short_opts="a:hv" |
2549 | - long_opts="arch:,fix-perms-ref:,help,proposed,verbose" |
2550 | - getopt_out=$(getopt --name "${0##*/}" \ |
2551 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
2552 | - eval set -- "${getopt_out}" || |
2553 | - { bad_Usage; return 1; } |
2554 | - local debian_arch="" perms_ref="" qemu_arch="" proposed=false |
2555 | - |
2556 | - while [ $# -ne 0 ]; do |
2557 | - cur=${1}; next=${2}; |
2558 | - case "$cur" in |
2559 | - -a|--arch) debian_arch="$next"; shift;; |
2560 | - --fix-perms-ref) perms_ref="$next"; shift;; |
2561 | - -h|--help) Usage ; exit 0;; |
2562 | - --proposed) proposed=true;; |
2563 | - -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));; |
2564 | - --) shift; break;; |
2565 | - esac |
2566 | - shift; |
2567 | - done |
2568 | - |
2569 | - [ $# -eq 4 -o $# -eq 5 ] || |
2570 | - { bad_Usage "expected image, kernel, ramdisk [,manifest]"; return 1; } |
2571 | - local dir=$1 kpkg=$2 kernel_out=$3 initrd_out=$4 manifest=$5 |
2572 | - local tab=" " |
2573 | - |
2574 | - disable_services "$dir" || return |
2575 | - |
2576 | - # we expect /etc/lsb-release to be shell syntax with DISTRIB_CODENAME |
2577 | - local rel="" fout host_arch |
2578 | - host_arch=$(uname -m) |
2579 | - rel=$(. "$dir/etc/lsb-release" && echo "${DISTRIB_CODENAME}") && |
2580 | - [ -n "$rel" ] || |
2581 | - fail "failed to read DISTRIB_CODENAME from $dir/etc/lsb-release" |
2582 | - |
2583 | - if [ -z "$debian_arch" ]; then |
2584 | - # not pretty, use 'file' to determine arch |
2585 | - fout=$(file -L "$dir/bin/sh") || |
2586 | - { error "'file' on $dir/bin/sh failed"; return 1; } |
2587 | - case "$fout" in |
2588 | - *\ x86-64,*) debian_arch="amd64";; |
2589 | - *\ 80386,*) debian_arch="i386";; |
2590 | - *\ ARM\ aarch64,*) debian_arch="arm64";; |
2591 | - *\ ARM,*) debian_arch="armhf";; |
2592 | - *\ 64-bit\ PowerPC*) debian_arch="ppc64el";; |
2593 | - *) fail "unknown arch for fileoutput: $fout"; return 1;; |
2594 | - esac |
2595 | - fi |
2596 | - |
2597 | - case "$debian_arch" in |
2598 | - x86_64|amd64) qemu_arch="x86_64";; |
2599 | - arm64) qemu_arch="aarch64";; |
2600 | - arm*) qemu_arch="arm";; |
2601 | - ppc64el) qemu_arch="ppc64le";; |
2602 | - powerpc) qemu_arch="ppc";; |
2603 | - *) qemu_arch="$debian_arch";; |
2604 | - esac |
2605 | - |
2606 | - local cross=true |
2607 | - case "$host_arch:$qemu_arch" in |
2608 | - $host_arch:$host_arch) cross=false;; |
2609 | - ppc64:ppc) cross=false;; |
2610 | - i?86:i386) cross=false;; |
2611 | - x86_64:i386) cross=false;; |
2612 | - aarm64:arm64) cross=false;; |
2613 | - arm*:arm*) cross=false;; |
2614 | - esac |
2615 | - |
2616 | - debug 1 "arch: $debian_arch rel: $rel host_arch: $host_arch" |
2617 | - debug 1 "qemu_arch=$qemu_arch cross=$cross" |
2618 | - if $cross; then |
2619 | - local fmt="${QEMU_STATIC_FMT:-/usr/bin/qemu-%a-static}" exe="" |
2620 | - exe=${fmt//%a/$qemu_arch} |
2621 | - cp "$exe" "$dir/usr/bin/qemu-${qemu_arch}-static" || { |
2622 | - error "failed to copy qemu-static [$exe] for ${qemu_arch}"; |
2623 | - error "install qemu-user-static or set QEMU_STATIC_FMT"; |
2624 | - return 1; |
2625 | - } |
2626 | - debug 1 "copied $exe into filesystem /usr/bin/qemu-${qemu_arch}-static" |
2627 | - else |
2628 | - debug 1 "no qemu-static needed to execute $debian_arch on ${host_arch}" |
2629 | - fi |
2630 | - |
2631 | - local prox="" apt_opts="" |
2632 | - out=$(apt-config shell prox Acquire::HTTP::Proxy) && |
2633 | - eval $out && [ -n "$prox" ] && |
2634 | - apt_opts="--option=Acquire::HTTP::Proxy=${prox}" |
2635 | - |
2636 | - apt_opts="${apt_opts} --option=Dpkg::Options::=--force-confold" |
2637 | - [ -n "${apt_opts}" ] && |
2638 | - debug 1 "using apt options ${apt_opts} for install" |
2639 | - |
2640 | - local me=$(readlink -f "$0") |
2641 | - local pubd="/tmp/results" fpubd="$dir/tmp/results" |
2642 | - |
2643 | - cross=$cross apt_opts="$apt_opts" kpkg="$kpkg" _VERBOSITY="$VERBOSITY" \ |
2644 | - proposed=$proposed \ |
2645 | - pubd="$pubd" \ |
2646 | - unshare-pidns \ |
2647 | - chroot "$dir" /bin/bash -s apply_updates_chrooted < "$me" || |
2648 | - { error "failed chroot and kernel install"; return 1; } |
2649 | - [ $? -eq 0 ] || { |
2650 | - error "failed to install packages or mkinitramfs in chroot"; |
2651 | - return 1; |
2652 | - } |
2653 | - |
2654 | - [ -n "$perms_ref" ] && |
2655 | - chown -R "--reference=$perms_ref" "${fpubd}" |
2656 | - |
2657 | - if [ "$kpkg" != "none" ]; then |
2658 | - mv "$fpubd/kernel.img" "$kernel_out" && |
2659 | - mv "$fpubd/initrd.img" "$initrd_out" || |
2660 | - { error "failed to copy kernels out"; return 1; } |
2661 | - fi |
2662 | - |
2663 | - # LP: #1034116: disable rescuevol and overlayroot's diskcfg |
2664 | - change="disable rescuevol (LP: #1034116)" |
2665 | - if grep -q "^cloud-initramfs-rescuevol${tab}" "$fpubd/manifest"; then |
2666 | - log_change true "$change" |
2667 | - # if cloud-initramfs-resuevol is installed, disable it |
2668 | - echo "# cloud-initramfs-rescuevol is disabled by ${0##*/}" \ |
2669 | - > "$dir/etc/rescuevol-ignore" || |
2670 | - { error "failed to disable rescuevol"; return 1; } |
2671 | - else |
2672 | - log_change false "$change" |
2673 | - fi |
2674 | - |
2675 | - change="disable overlayroot via /etc/overlayroot.local.conf (LP: #1533822)" |
2676 | - if grep -q "^overlayroot${tab}" "$fpubd/manifest"; then |
2677 | - printf "%s\n%s\n%s\n" "# overlayroot_cfgdisk disabled by ${0##*/}" \ |
2678 | - "overlayroot_cfgdisk=disabled" "overlayroot=tmpfs" \ |
2679 | - > "$dir/etc/overlayroot.local.conf" |
2680 | - fi |
2681 | - |
2682 | - local pkg_add="" pkg_remove="" |
2683 | - pkg_add=$(get_new_pkgs "$fpubd/manifest.in" "$fpubd/manifest") || |
2684 | - fail "failed to get new packages" |
2685 | - pkg_remove=$(get_removed_pkgs "$fpubd/manifest.in" "$fpubd/manifest") || |
2686 | - fail "failed to get removed packages" |
2687 | - if [ -z "$pkg_add" -a -z "$pkg_remove" ]; then |
2688 | - log_change false "package changes: add='' remove=''" |
2689 | - else |
2690 | - log_change true "package changes: add=$pkg_add remove=$pkg_remove" |
2691 | - fi |
2692 | - |
2693 | - if [ -n "$manifest" ]; then |
2694 | - mv "$fpubd/manifest" "$manifest" || fail "failed to move manifest" |
2695 | - fi |
2696 | - rm -Rf "$fpubd" || fail "failed to remove pubd" |
2697 | - |
2698 | - undisable_services "$dir" |
2699 | - |
2700 | - return 0 |
2701 | -} |
2702 | - |
2703 | -if [ "$1" = "apply_updates" ]; then |
2704 | - "$@" |
2705 | -elif [ "$1" = "apply_updates_chrooted" ]; then |
2706 | - "$@" |
2707 | -else |
2708 | - short_opts="a:hv" |
2709 | - long_opts="arch:,help,proposed,verbose,zero" |
2710 | - getopt_out=$(getopt --name "${0##*/}" \ |
2711 | - --options "${short_opts}" --long "${long_opts}" -- "$@") && |
2712 | - eval set -- "${getopt_out}" || |
2713 | - { bad_Usage; exit 1; } |
2714 | - arch="" |
2715 | - vargs="" |
2716 | - zero=false |
2717 | - proposed="" |
2718 | - |
2719 | - while [ $# -ne 0 ]; do |
2720 | - cur=${1}; next=${2}; |
2721 | - case "$cur" in |
2722 | - -a|--arch) arch="$next"; shift;; |
2723 | - -h|--help) Usage ; exit 0;; |
2724 | - --proposed) proposed="--proposed";; |
2725 | - -v|--verbose) vargs="${vargs}v";; |
2726 | - --zero) zero=true;; |
2727 | - --) shift; break;; |
2728 | - esac |
2729 | - shift; |
2730 | - done |
2731 | - |
2732 | - [ $# -eq 4 -o $# -eq 5 ] || |
2733 | - { bad_Usage "expected image, kernel, ramdisk [,manifest]"; exit 1; } |
2734 | - |
2735 | - img="$1" |
2736 | - kpkg="$2" |
2737 | - kernel="$3" |
2738 | - initrd="$4" |
2739 | - manifest="$5" |
2740 | - |
2741 | - sudo \ |
2742 | - m2e_repos="${M2E_ADD_REPOS}" \ |
2743 | - m2e_add_packages="${M2E_ADD_PACKAGES}" \ |
2744 | - mount-image-callback --sys --proc --system-resolvconf "$img" -- \ |
2745 | - "$0" apply_updates ${vargs:+-$vargs} \ |
2746 | - ${proposed} \ |
2747 | - "--fix-perms-ref=$img" \ |
2748 | - ${arch:+"--arch=$arch"} _MOUNTPOINT_ \ |
2749 | - "$kpkg" "$kernel" "$initrd" ${manifest:+"${manifest}"} || |
2750 | - fail "failed to apply updates to $img" |
2751 | - |
2752 | - if $zero; then |
2753 | - # this is optional as it will only work on a raw image |
2754 | - e2fsck -fy "$img" || { error "failed to e2fsck $img"; exit 1; } |
2755 | - zerofree "$img" || { error "failed zerofree $img"; exit 1; } |
2756 | - fi |
2757 | - |
2758 | - exit 0 |
2759 | - |
2760 | -fi |
2761 | -# vi: ts=4 expandtab |
2762 | |
2763 | === target is u'moved-to-git' |
2764 | === modified file 'bin/maas-qcow2targz' |
2765 | --- bin/maas-qcow2targz 2018-09-18 10:26:54 +0000 |
2766 | +++ bin/maas-qcow2targz 1970-01-01 00:00:00 +0000 |
2767 | @@ -1,235 +0,0 @@ |
2768 | -#!/bin/bash |
2769 | -# |
2770 | -# maas-qcowtargz - Take a qcow2 or qcow2.xz file from a given URL or |
2771 | -# file path and make it sufficient for use as a |
2772 | -# MAAS installable image |
2773 | -# |
2774 | -# Copyright (C) 2015-2018 Canonical |
2775 | -# |
2776 | -# Authors: |
2777 | -# Lee Trager <lee.trager@canonical.com> |
2778 | -# |
2779 | -# This program is free software: you can redistribute it and/or modify |
2780 | -# it under the terms of the GNU Affero General Public License as |
2781 | -# published by the Free Software Foundation, version 3 of the License. |
2782 | -# |
2783 | -# This program is distributed in the hope that it will be useful, |
2784 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2785 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2786 | -# GNU Affero General Public License for more details. |
2787 | -# |
2788 | -# You should have received a copy of the GNU Affero General Public License |
2789 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2790 | - |
2791 | -TEMP_D="" |
2792 | -command -v unshare-pidns >/dev/null 2>&1 || PATH="${0%/*}:$PATH" |
2793 | - |
2794 | -error() { echo "$@" 1>&2; } |
2795 | -fail() { [ $# -eq 0 ] || error "$@"; exit 1; } |
2796 | - |
2797 | -_dl() { |
2798 | - local url="$1" out="$2" ret=0 |
2799 | - local tmp="$out.$$" |
2800 | - wget "$url" --progress=dot:mega -O "$tmp" && mv "$tmp" "$out" || { |
2801 | - ret=$? |
2802 | - error "Failed downloading to $out: $url" |
2803 | - rm -f "$tmp" |
2804 | - } |
2805 | - return $ret |
2806 | -} |
2807 | - |
2808 | -dl() { |
2809 | - local url="$1" out="${2:-${1##*/}}" |
2810 | - if [ -n "${CACHE_D}" ]; then |
2811 | - local cfile="${CACHE_D}/${url##*/}" |
2812 | - if [ ! -f "$cfile" ]; then |
2813 | - _dl "$url" "$cfile" || return |
2814 | - fi |
2815 | - [ "$cfile" -ef "$out" ] && return |
2816 | - cp "$cfile" "$out" |
2817 | - return |
2818 | - fi |
2819 | - |
2820 | - _dl "$url" "$out" |
2821 | -} |
2822 | - |
2823 | -cleanup() { [ -d "${TEMP_D}" ] && rm -Rf "${TEMP_D}"; } |
2824 | - |
2825 | -function usage() { |
2826 | - echo "Usage $0 [options] <URL> <SHA256> <out file>" |
2827 | - echo "Options:" |
2828 | - echo " --curtin-path Path to any curtin files to include in the image." |
2829 | - echo " --packages Any extra packages to install into the image." |
2830 | - |
2831 | -} |
2832 | - |
2833 | -short_opts="c:p:h" |
2834 | -long_opts="curtin-path:,packages:,help" |
2835 | - |
2836 | -getopt_out=$(getopt --name "${##*/}" --options "${short_opts}" --long "${long_opts}" -- "$@") |
2837 | -if [ $? -ne 0 ]; then |
2838 | - usage |
2839 | - exit 1 |
2840 | -fi |
2841 | - |
2842 | -eval set -- "$getopt_out" |
2843 | -while true; do |
2844 | - case "$1" in |
2845 | - -c|--curtin-path) |
2846 | - curtin_path=$2 |
2847 | - shift 2 |
2848 | - ;; |
2849 | - -p|--packages) |
2850 | - packages=$2 |
2851 | - shift 2 |
2852 | - ;; |
2853 | - -h|--help) |
2854 | - usage |
2855 | - exit 0 |
2856 | - ;; |
2857 | - --) |
2858 | - shift |
2859 | - break |
2860 | - ;; |
2861 | - esac |
2862 | -done |
2863 | - |
2864 | -if [ "$1" == "maasify" ]; then |
2865 | - [ "$(id -u)" = "0" ] || { error "not root, sorry"; exit 1; } |
2866 | - root_d=$2 |
2867 | - out=$3 |
2868 | - if [ -n "$curtin_path" ]; then |
2869 | - mkdir -p "$root_d/curtin" || |
2870 | - { error "failed to create /curtin"; return 1; } |
2871 | - cp -r "$curtin_path/"* "$root_d/curtin/" || { |
2872 | - error "failed copying $CURTIN_PATH to $root_d/curtin"; |
2873 | - return 1; |
2874 | - } |
2875 | - chmod +x "$root_d/curtin/"* || |
2876 | - { error "failed chmod +x $root_d/curtin/*"; return 1; } |
2877 | - fi |
2878 | - |
2879 | - if [ -n "$packages" ]; then |
2880 | - # We need working DNS to pull packages from the repo |
2881 | - cp /etc/resolv.conf "${root_d}/etc/resolv.conf" |
2882 | - for package in $(echo $packages | sed 's/,/ /g'); do |
2883 | - LANG=C unshare-pidns chroot "$root_d" yum -y install $package || { |
2884 | - error "failed to install $package" |
2885 | - exit 1 |
2886 | - } |
2887 | - done |
2888 | - # Don't ship with yum cache |
2889 | - LANG=C unshare-pidns chroot "$root_d" yum clean all || { |
2890 | - error "failed to clear yum cache" |
2891 | - exit 1 |
2892 | - } |
2893 | - # Upstream ships with DNS information in /etc/resolv.conf, ship a |
2894 | - # clean version. |
2895 | - rm "${root_d}/etc/resolv.conf" |
2896 | - touch "${root_d}/etc/resolv.conf" |
2897 | - chown root:root "${root_d}/etc/resolv.conf" |
2898 | - chmod 644 "${root_d}/etc/resolv.conf" |
2899 | - fi |
2900 | - |
2901 | - error "Taring up image contents... into $out" |
2902 | - gzflag="--use-compress-program=gzip" |
2903 | - if command -v pigz >/dev/null 2>&1; then |
2904 | - gzflag="--use-compress-program=pigz" |
2905 | - fi |
2906 | - tar --directory "$root_d" --create --preserve-permissions \ |
2907 | - --one-file-system \ |
2908 | - --sparse --file "$out" $gzflag \ |
2909 | - --xattrs "--xattrs-include=*" . || { |
2910 | - error "failed tar command" |
2911 | - rm -f "$out" |
2912 | - exit 1 |
2913 | - } |
2914 | -else |
2915 | - if [ $# -ne 3 ]; then |
2916 | - usage |
2917 | - exit 1 |
2918 | - fi |
2919 | - url=$1 |
2920 | - sha256=$2 |
2921 | - if [ "$(dirname $3)" == "." ]; then |
2922 | - out="${PWD}/${3}" |
2923 | - else |
2924 | - out=$3 |
2925 | - fi |
2926 | - |
2927 | - error "final output will be in ${out}" |
2928 | - |
2929 | - mkdir -p $(dirname "$out") |
2930 | - |
2931 | - cache_d="${CACHE_D:-$PWD/cache}" |
2932 | - [ -d "$cache_d" ] || mkdir -p "$cache_d" || fail "failed mkdir $cache_d" |
2933 | - |
2934 | - TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") |
2935 | - trap cleanup EXIT |
2936 | - |
2937 | - if [ -f "$url" ]; then |
2938 | - img_path="$url" |
2939 | - else |
2940 | - img_path="${cache_d}/${url##*/}" |
2941 | - if [ ! -f "${img_path}" ]; then |
2942 | - dl "$url" "$img_path" || |
2943 | - fail "failed download $url" |
2944 | - else |
2945 | - error "using cached '${url##*/}' in ${cache_d}" |
2946 | - fi |
2947 | - |
2948 | - # We were given a SHA512 instead of a SHA256 |
2949 | - if [ ${#sha256} -eq 128 ]; then |
2950 | - error "Checking sha512sum for $img_path" |
2951 | - sha512_out=$(sha512sum "$img_path") || |
2952 | - fail "failed: sha512sum $img_path" |
2953 | - sha512_out=${sha512_out% *} |
2954 | - if [ "$sha512_out" != "$sha256" ]; then |
2955 | - fail "Error: unexpected sha512 of $img_path $sha512_out != $sha256" |
2956 | - fi |
2957 | - else |
2958 | - error "Checking sha256sum for $img_path" |
2959 | - sha256_out=$(sha256sum "$img_path") || |
2960 | - fail "failed: sha256sum $img_path" |
2961 | - sha256_out=${sha256_out% *} |
2962 | - if [ "$sha256_out" != "$sha256" ]; then |
2963 | - fail "Error: unexpected sha256 of $img_path $sha256_out != $sha256" |
2964 | - fi |
2965 | - fi |
2966 | - |
2967 | - fout=$(LANG=C file "$img_path") || |
2968 | - fail "failed file $img_path" |
2969 | - case "${fout#$img_path: }" in |
2970 | - "XZ compressed data"*) |
2971 | - new_img_path="${img_path%.xz}" |
2972 | - if [ -f "$new_img_path" ]; then |
2973 | - error "using cached uncompressed '$new_img_path'" |
2974 | - else |
2975 | - error "Decompressing XZ image..." |
2976 | - xzcat "$img_path" > "${new_img_path}" || |
2977 | - { rm -f "$new_img_path"; fail "failed xzcat"; } |
2978 | - fi |
2979 | - img_path="${new_img_path}" |
2980 | - ;; |
2981 | - esac |
2982 | - fi |
2983 | - working_img="${TEMP_D}/${img_path##*/}" |
2984 | - |
2985 | - error "copying $img_path to $working_img" |
2986 | - cp "$img_path" "$working_img" || |
2987 | - fail "failed copying image ${img_path} -> ${working_img}" |
2988 | - |
2989 | - cb_args="maasify _MOUNTPOINT_ $out" |
2990 | - [ -n "$curtin_path" ] && cb_args="$cb_args --curtin-path $curtin_path" |
2991 | - [ -n "$packages" ] && cb_args="$cb_args --packages $packages" |
2992 | - sudo \ |
2993 | - CACHE_D="${cache_d}" \ |
2994 | - ${http_proxy:+"http_proxy=${http_proxy}"} \ |
2995 | - ${https_proxy:+"https_proxy=${https_proxy}"} \ |
2996 | - mount-image-callback --proc --dev "$working_img" -- \ |
2997 | - "$0" $cb_args |
2998 | - |
2999 | - error "wrote $out" |
3000 | -fi |
3001 | - |
3002 | -# vi: ts=4 expandtab |
3003 | |
3004 | === target is u'moved-to-git' |
3005 | === modified file 'bin/meph2-build' |
3006 | --- bin/meph2-build 2016-01-12 21:50:59 +0000 |
3007 | +++ bin/meph2-build 1970-01-01 00:00:00 +0000 |
3008 | @@ -1,28 +0,0 @@ |
3009 | -#!/usr/bin/env python3 |
3010 | - |
3011 | -import os |
3012 | -import sys |
3013 | - |
3014 | - |
3015 | -def call_entry_point(name): |
3016 | - (istr, dot, ent) = name.rpartition('.') |
3017 | - try: |
3018 | - __import__(istr) |
3019 | - except ImportError: |
3020 | - # if that import failed, check dirname(__file__/..) |
3021 | - # to support ./bin/program with modules in . |
3022 | - _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
3023 | - sys.path.insert(0, _tdir) |
3024 | - try: |
3025 | - __import__(istr) |
3026 | - except ImportError as e: |
3027 | - sys.stderr.write("Unable to find %s: %s\n" % (name, e)) |
3028 | - sys.exit(2) |
3029 | - |
3030 | - sys.exit(getattr(sys.modules[istr], ent)()) |
3031 | - |
3032 | -if __name__ == '__main__': |
3033 | - call_entry_point("meph2.commands.build_image.main") |
3034 | - |
3035 | -# vi: ts=4 expandtab syntax=python |
3036 | - |
3037 | |
3038 | === target is u'moved-to-git' |
3039 | === modified file 'bin/meph2-cloudimg-sync' |
3040 | --- bin/meph2-cloudimg-sync 2015-09-11 19:10:40 +0000 |
3041 | +++ bin/meph2-cloudimg-sync 1970-01-01 00:00:00 +0000 |
3042 | @@ -1,27 +0,0 @@ |
3043 | -#!/usr/bin/env python3 |
3044 | - |
3045 | -import os |
3046 | -import sys |
3047 | - |
3048 | - |
3049 | -def call_entry_point(name): |
3050 | - (istr, dot, ent) = name.rpartition('.') |
3051 | - try: |
3052 | - __import__(istr) |
3053 | - except ImportError: |
3054 | - # if that import failed, check dirname(__file__/..) |
3055 | - # to support ./bin/program with modules in . |
3056 | - _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
3057 | - sys.path.insert(0, _tdir) |
3058 | - try: |
3059 | - __import__(istr) |
3060 | - except ImportError as e: |
3061 | - sys.stderr.write("Unable to find %s: %s\n" % (name, e)) |
3062 | - sys.exit(2) |
3063 | - |
3064 | - sys.exit(getattr(sys.modules[istr], ent)()) |
3065 | - |
3066 | -if __name__ == '__main__': |
3067 | - call_entry_point("meph2.commands.cloudimg_sync.main") |
3068 | - |
3069 | -# vi: ts=4 expandtab syntax=python |
3070 | |
3071 | === target is u'moved-to-git' |
3072 | === modified file 'bin/meph2-import' |
3073 | --- bin/meph2-import 2016-09-26 19:23:50 +0000 |
3074 | +++ bin/meph2-import 1970-01-01 00:00:00 +0000 |
3075 | @@ -1,27 +0,0 @@ |
3076 | -#!/usr/bin/env python3 |
3077 | - |
3078 | -import os |
3079 | -import sys |
3080 | - |
3081 | - |
3082 | -def call_entry_point(name): |
3083 | - (istr, dot, ent) = name.rpartition('.') |
3084 | - try: |
3085 | - __import__(istr) |
3086 | - except ImportError: |
3087 | - # if that import failed, check dirname(__file__/..) |
3088 | - # to support ./bin/program with modules in . |
3089 | - _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
3090 | - sys.path.insert(0, _tdir) |
3091 | - try: |
3092 | - __import__(istr) |
3093 | - except ImportError as e: |
3094 | - sys.stderr.write("Unable to find %s: %s\n" % (name, e)) |
3095 | - sys.exit(2) |
3096 | - |
3097 | - sys.exit(getattr(sys.modules[istr], ent)()) |
3098 | - |
3099 | -if __name__ == '__main__': |
3100 | - call_entry_point("meph2.commands.mimport.main") |
3101 | - |
3102 | -# vi: ts=4 expandtab syntax=python |
3103 | |
3104 | === target is u'moved-to-git' |
3105 | === modified file 'bin/meph2-util' |
3106 | --- bin/meph2-util 2015-09-11 19:10:40 +0000 |
3107 | +++ bin/meph2-util 1970-01-01 00:00:00 +0000 |
3108 | @@ -1,27 +0,0 @@ |
3109 | -#!/usr/bin/env python3 |
3110 | - |
3111 | -import os |
3112 | -import sys |
3113 | - |
3114 | - |
3115 | -def call_entry_point(name): |
3116 | - (istr, dot, ent) = name.rpartition('.') |
3117 | - try: |
3118 | - __import__(istr) |
3119 | - except ImportError: |
3120 | - # if that import failed, check dirname(__file__/..) |
3121 | - # to support ./bin/program with modules in . |
3122 | - _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
3123 | - sys.path.insert(0, _tdir) |
3124 | - try: |
3125 | - __import__(istr) |
3126 | - except ImportError as e: |
3127 | - sys.stderr.write("Unable to find %s: %s\n" % (name, e)) |
3128 | - sys.exit(2) |
3129 | - |
3130 | - sys.exit(getattr(sys.modules[istr], ent)()) |
3131 | - |
3132 | -if __name__ == '__main__': |
3133 | - call_entry_point("meph2.commands.meph2_util.main") |
3134 | - |
3135 | -# vi: ts=4 expandtab syntax=python |
3136 | |
3137 | === target is u'moved-to-git' |
3138 | === added file 'bin/moved-to-git' |
3139 | --- bin/moved-to-git 1970-01-01 00:00:00 +0000 |
3140 | +++ bin/moved-to-git 2018-09-21 12:24:04 +0000 |
3141 | @@ -0,0 +1,10 @@ |
3142 | +#!/bin/sh |
3143 | +me=$(readlink -f "$0") |
3144 | +mydir=${me%/*} |
3145 | +readme="$mydir/../README" |
3146 | +[ -f "$readme" ] || { |
3147 | + echo "ERROR: maas-images moved to git." 1>&2 |
3148 | + exit 1 |
3149 | +} |
3150 | +cat "$readme" 1>&2 |
3151 | +exit 1 |
3152 | |
3153 | === modified file 'bin/netboot-mirror' |
3154 | --- bin/netboot-mirror 2015-09-11 19:10:40 +0000 |
3155 | +++ bin/netboot-mirror 1970-01-01 00:00:00 +0000 |
3156 | @@ -1,27 +0,0 @@ |
3157 | -#!/usr/bin/env python3 |
3158 | - |
3159 | -import os |
3160 | -import sys |
3161 | - |
3162 | - |
3163 | -def call_entry_point(name): |
3164 | - (istr, dot, ent) = name.rpartition('.') |
3165 | - try: |
3166 | - __import__(istr) |
3167 | - except ImportError: |
3168 | - # if that import failed, check dirname(__file__/..) |
3169 | - # to support ./bin/program with modules in . |
3170 | - _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
3171 | - sys.path.insert(0, _tdir) |
3172 | - try: |
3173 | - __import__(istr) |
3174 | - except ImportError as e: |
3175 | - sys.stderr.write("Unable to find %s: %s\n" % (name, e)) |
3176 | - sys.exit(2) |
3177 | - |
3178 | - sys.exit(getattr(sys.modules[istr], ent)()) |
3179 | - |
3180 | -if __name__ == '__main__': |
3181 | - call_entry_point("meph2.commands.netboot_mirror.main") |
3182 | - |
3183 | -# vi: ts=4 expandtab syntax=python |
3184 | |
3185 | === target is u'moved-to-git' |
3186 | === modified file 'bin/unshare-pidns' |
3187 | --- bin/unshare-pidns 2017-05-03 11:27:18 +0000 |
3188 | +++ bin/unshare-pidns 1970-01-01 00:00:00 +0000 |
3189 | @@ -1,24 +0,0 @@ |
3190 | -#!/bin/sh |
3191 | -has_unshare_pid() { |
3192 | - command -v unshare >/dev/null 2>&1 || return 1 |
3193 | - local helpout="" |
3194 | - helpout=$(unshare --help) || return 1 |
3195 | - case "$helpout" in |
3196 | - *--fork*--pid*|*--pid*--fork*) :;; |
3197 | - *) return 1;; |
3198 | - esac |
3199 | - return 0 |
3200 | -} |
3201 | -if has_unshare_pid; then |
3202 | - exec unshare --fork --pid -- "$@" |
3203 | -else |
3204 | - rval=${M2E_REQUIRE_UNSHARE:-0} |
3205 | - case "$rval" in |
3206 | - 0) :;; |
3207 | - *) echo "unshare pid not available (M2E_REQUIRE_UNSHARE=$rval)." 1>&2; |
3208 | - exit 3;; |
3209 | - esac |
3210 | - exec "$@" |
3211 | -fi |
3212 | - |
3213 | -# vi: ts=4 expandtab |
3214 | |
3215 | === target is u'moved-to-git' |
3216 | === removed directory 'conf' |
3217 | === removed file 'conf/bootloaders.yaml' |
3218 | --- conf/bootloaders.yaml 2018-08-07 21:31:31 +0000 |
3219 | +++ conf/bootloaders.yaml 1970-01-01 00:00:00 +0000 |
3220 | @@ -1,67 +0,0 @@ |
3221 | -product_id: "com.ubuntu.maas.daily:1:{os}:{firmware_platform}:{arch}" |
3222 | -content_id: "com.ubuntu.maas:daily:1:bootloader-download" |
3223 | - |
3224 | -bootloaders: |
3225 | - - firmware-platform: pxe |
3226 | - packages: |
3227 | - - pxelinux |
3228 | - - syslinux-common |
3229 | - arch: i386 |
3230 | - arches: i386,amd64 |
3231 | - archive: http://archive.ubuntu.com/ubuntu |
3232 | - release: bionic |
3233 | - os: pxelinux |
3234 | - files: |
3235 | - - usr/lib/PXELINUX/pxelinux.0 |
3236 | - - usr/lib/PXELINUX/lpxelinux.0 |
3237 | - - usr/lib/syslinux/modules/bios/*.c32 |
3238 | - - firmware-platform: uefi |
3239 | - packages: |
3240 | - - shim-signed |
3241 | - - grub-efi-amd64-signed |
3242 | - arch: amd64 |
3243 | - arches: amd64 |
3244 | - archive: http://archive.ubuntu.com/ubuntu |
3245 | - release: bionic |
3246 | - os: grub-efi-signed |
3247 | - files: |
3248 | - - usr/lib/shim/shimx64.efi.signed, bootx64.efi |
3249 | - - usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed, grubx64.efi |
3250 | - - firmware-platform: uefi |
3251 | - packages: |
3252 | - - grub-efi-arm64-bin |
3253 | - arch: arm64 |
3254 | - arches: arm64 |
3255 | - archive: http://ports.ubuntu.com |
3256 | - release: bionic |
3257 | - os: grub-efi |
3258 | - files: |
3259 | - - usr/lib/grub/arm64-efi/ |
3260 | - grub_format: arm64-efi |
3261 | - grub_output: grubaa64.efi |
3262 | - grub_config: | |
3263 | - # MAAS GRUB2 pre-loader configuration file |
3264 | - |
3265 | - # Load based on MAC address first. |
3266 | - configfile (pxe)/grub/grub.cfg-${net_default_mac} |
3267 | - |
3268 | - # Failed to load based on MAC address. |
3269 | - # Load arm64 by default, UEFI only supported by 64-bit |
3270 | - configfile (pxe)/grub/grub.cfg-default-arm64 |
3271 | - - firmware-platform: open-firmware |
3272 | - packages: |
3273 | - - grub-ieee1275-bin |
3274 | - arch: ppc64el |
3275 | - arches: ppc64el,ppc64 |
3276 | - archive: http://ports.ubuntu.com |
3277 | - release: xenial |
3278 | - os: grub-ieee1275 |
3279 | - files: |
3280 | - - usr/lib/grub/powerpc-ieee1275/ |
3281 | - grub_format: powerpc-ieee1275 |
3282 | - grub_output: bootppc64.bin |
3283 | - grub_config: | |
3284 | - configfile (pxe)/grub/grub.cfg-${net_default_mac} |
3285 | - configfile (pxe)/grub/grub.cfg-default-ppc64el |
3286 | - |
3287 | -# vi: syntax=yaml nowrap |
3288 | |
3289 | === removed file 'conf/centos.yaml' |
3290 | --- conf/centos.yaml 2018-09-18 13:38:31 +0000 |
3291 | +++ conf/centos.yaml 1970-01-01 00:00:00 +0000 |
3292 | @@ -1,87 +0,0 @@ |
3293 | -image_index: http://cloud.centos.org/centos/{version}/images/image-index |
3294 | - |
3295 | -product_id: "com.ubuntu.maas.daily:centos-bases:{version}:{arch}" |
3296 | -content_id: "com.ubuntu.maas:daily:centos-bases-download" |
3297 | -os: centos |
3298 | -arch: amd64 |
3299 | - |
3300 | -versions: |
3301 | - centos70: |
3302 | - version: 7.0 |
3303 | - path_version: 7 |
3304 | - release_title: "CentOS 7.0" |
3305 | - curtin_files: "{curtin_path}/centos7" |
3306 | - # The upstream revision to create MAAS images for. All other versions |
3307 | - # are ignored if this is defined. |
3308 | - revision: 1808 |
3309 | - # The lp:maas-images release. This defaults to 01. Changing this will |
3310 | - # cause a new build of the revision to be imported. |
3311 | - release: 02 |
3312 | - packages: |
3313 | - # cloud-init depends on packages from EPEL |
3314 | - - epel-release |
3315 | - - bash-completion |
3316 | - - linux-firmware |
3317 | - # XXX ltrager 2017-07-28 - COPR doesn't provide a URL to the latest |
3318 | - # package build. Instead it expects you to first add the repo which |
3319 | - # is what is included in this package. |
3320 | - - https://copr-be.cloud.fedoraproject.org/results/%40cloud-init/el-stable/epel-7-x86_64/00581936-cloud-init-el-release/cloud-init-el-release-7-1.noarch.rpm |
3321 | - # The image most likely already has cloud-init, this pulls Canonical's |
3322 | - # version |
3323 | - - cloud-init |
3324 | - # bridge-utils is required by cloud-init to configure networking. |
3325 | - # Without it cloud-init will try to install it which will not work in |
3326 | - # isolated environments. |
3327 | - - bridge-utils |
3328 | - # Tools needed to allow custom storage to be deployed without |
3329 | - # accessing the Internet. |
3330 | - # grub2-efi-x64 contains the signed bootloader which currently does not |
3331 | - # chainboot - RHBZ #1623296 |
3332 | - # - grub2-efi-x64 |
3333 | - # - shim-x64 |
3334 | - # RHBZ #1101352 |
3335 | - - grub2-efi-x64-modules |
3336 | - - grub2-tools |
3337 | - - efibootmgr |
3338 | - - dosfstools |
3339 | - - lvm2 |
3340 | - - mdadm |
3341 | - - device-mapper-multipath |
3342 | - - iscsi-initiator-utils |
3343 | - centos66: |
3344 | - version: 6.6 |
3345 | - release_title: "CentOS 6.6" |
3346 | - curtin_files: "{curtin_path}/centos6" |
3347 | - # The upstream revision to create MAAS images for. All other versions |
3348 | - # are ignored if this is defined. |
3349 | - revision: 1808 |
3350 | - # The lp:maas-images release. This defaults to 01. Changing this will |
3351 | - # cause a new build of the revision to be imported. |
3352 | - release: 02 |
3353 | - packages: |
3354 | - # cloud-init depends on packages from EPEL |
3355 | - - epel-release |
3356 | - - bash-completion |
3357 | - # XXX ltrager 2017-07-28 - COPR doesn't provide a URL to the latest |
3358 | - # package build. Instead it expects you to first add the repo which |
3359 | - # is what is included in this package. |
3360 | - - https://copr-be.cloud.fedoraproject.org/results/%40cloud-init/el-stable/epel-6-x86_64/00581936-cloud-init-el-release/cloud-init-el-release-7-1.noarch.rpm |
3361 | - # The image most likely already has cloud-init, this pulls Canonical's |
3362 | - # version |
3363 | - - cloud-init |
3364 | - # bridge-utils is required by cloud-init to configure networking. |
3365 | - # Without it cloud-init will try to install it which will not work in |
3366 | - # isolated environments. |
3367 | - - bridge-utils |
3368 | - # Tools needed to allow custom storage to be deployed without |
3369 | - # accessing the Internet. |
3370 | - - efibootmgr |
3371 | - - btrfs-progs |
3372 | - - dosfstools |
3373 | - - lvm2 |
3374 | - - mdadm |
3375 | - - xfsprogs |
3376 | - - device-mapper-multipath |
3377 | - - iscsi-initiator-utils |
3378 | - |
3379 | -# vi: syntax=yaml nowrap |
3380 | |
3381 | === removed file 'conf/meph-v2.yaml' |
3382 | --- conf/meph-v2.yaml 2018-05-07 14:03:39 +0000 |
3383 | +++ conf/meph-v2.yaml 1970-01-01 00:00:00 +0000 |
3384 | @@ -1,226 +0,0 @@ |
3385 | -# kernel entries are a list of |
3386 | -# kernel-release, arch, primary-subarch, flavor, kernel-pkgname, subarches |
3387 | -# we use the anchors to make subarches more compact |
3388 | -# |
3389 | -# builtin_kernel is "builtin" kernel. |
3390 | -# default is 'linux-generic' |
3391 | -# |
3392 | -# kernel arrays are |
3393 | -# krel, karch, primary-subarch, flavor, kernel-package, [subarches], {khdata} |
3394 | -# |
3395 | -# 'khdata' is an optional dictionary used to tell which dtb files to pull or |
3396 | -# what kernel helper to run on the kernel and initramfs. |
3397 | - |
3398 | -subarches: |
3399 | - - &sa_hwe_p [generic, hwe-p] |
3400 | - - &sa_hwe_q [generic, hwe-p, hwe-q] |
3401 | - - &sa_hwe_r [generic, hwe-p, hwe-q, hwe-r] |
3402 | - - &sa_hwe_s [generic, hwe-p, hwe-q, hwe-r, hwe-s] |
3403 | - - &sa_hwe_t [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t] |
3404 | - - &sa_hwe_u [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u] |
3405 | - - &sa_hwe_v [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v] |
3406 | - - &sa_hwe_w [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w] |
3407 | - - &sa_hwe_x [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x] |
3408 | - - &sa_hwe_y [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y] |
3409 | - - &sa_hwe_z [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z] |
3410 | - - &sa_hwe_a [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z, hwe-a] |
3411 | - - &sa_hwe_b [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z, hwe-a, hwe-b] |
3412 | - - &sa_hwe_c [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z, hwe-a, hwe-b, hwe-c] |
3413 | - - &arm_hwe_t [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t] |
3414 | - - &arm_hwe_u [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u] |
3415 | - - &arm_hwe_v [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v] |
3416 | - - &arm_hwe_w [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w] |
3417 | - - &arm_hwe_x [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x] |
3418 | - - &arm_hwe_y [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y] |
3419 | - - &arm_hwe_z [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z] |
3420 | - - &arm_hwe_a [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z, hwe-a] |
3421 | - - &arm_hwe_b [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z, hwe-a, hwe-b] |
3422 | - - &arm_hwe_c [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x, hwe-y, hwe-z, hwe-a, hwe-b, hwe-c] |
3423 | - |
3424 | -misc: |
3425 | - - &glpae generic-lpae |
3426 | - - &xguboot xgene-uboot |
3427 | - - &mustang xgene-uboot-mustang |
3428 | - - &kh-mustang {suffix: .xgene-mustang, kihelper: kh-xgene, |
3429 | - di-format: 'xgene', dtb: 'apm-mustang.dtb'} |
3430 | - - &kh-xgene {suffix: .xgene, kihelper: "kh-xgene", di-format: 'xgene'} |
3431 | - |
3432 | -releases: |
3433 | - - version: "18.10" |
3434 | - release: cosmic |
3435 | - kernels: |
3436 | - - [cosmic, amd64, hwe-c, generic, linux-signed-generic, *sa_hwe_c] |
3437 | - - [cosmic, arm64, hwe-c, generic, linux-generic, *sa_hwe_c] |
3438 | - - [cosmic, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3439 | - - [cosmic, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3440 | - - [cosmic, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3441 | - - [cosmic, armhf, hwe-c, generic, linux-generic, *arm_hwe_c] |
3442 | - - [cosmic, i386, hwe-c, generic, linux-generic, *sa_hwe_c] |
3443 | - - [cosmic, ppc64el, hwe-c, generic, linux-generic, *sa_hwe_c] |
3444 | - - [cosmic, s390x, hwe-c, generic, linux-generic, *sa_hwe_c] |
3445 | - - version: "18.04" |
3446 | - release: bionic |
3447 | - kernels: |
3448 | - - [bionic, amd64, hwe-b, generic, linux-signed-generic, *sa_hwe_b] |
3449 | - - [bionic, arm64, hwe-b, generic, linux-generic, *sa_hwe_b] |
3450 | - - [bionic, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3451 | - - [bionic, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3452 | - - [bionic, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3453 | - - [bionic, armhf, hwe-b, generic, linux-generic, *arm_hwe_b] |
3454 | - - [bionic, i386, hwe-b, generic, linux-generic, *sa_hwe_b] |
3455 | - - [bionic, ppc64el, hwe-b, generic, linux-generic, *sa_hwe_b] |
3456 | - - [bionic, s390x, hwe-b, generic, linux-generic, *sa_hwe_b] |
3457 | - - version: "17.10" |
3458 | - release: artful |
3459 | - kernels: |
3460 | - - [artful, amd64, hwe-a, generic, linux-signed-generic, *sa_hwe_a] |
3461 | - - [artful, arm64, hwe-a, generic, linux-generic, *sa_hwe_a] |
3462 | - - [artful, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3463 | - - [artful, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3464 | - - [artful, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3465 | - - [artful, armhf, hwe-a, generic, linux-generic, *arm_hwe_a] |
3466 | - - [artful, i386, hwe-a, generic, linux-generic, *sa_hwe_a] |
3467 | - - [artful, ppc64el, hwe-a, generic, linux-generic, *sa_hwe_a] |
3468 | - - [artful, s390x, hwe-a, generic, linux-generic, *sa_hwe_a] |
3469 | - - version: "17.04" |
3470 | - release: zesty |
3471 | - kernels: |
3472 | - - [zesty, amd64, hwe-z, generic, linux-signed-generic, *sa_hwe_z] |
3473 | - - [zesty, arm64, hwe-z, generic, linux-generic, *sa_hwe_z] |
3474 | - - [zesty, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3475 | - - [zesty, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3476 | - - [zesty, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3477 | - - [zesty, armhf, hwe-z, generic, linux-generic, *arm_hwe_z] |
3478 | - - [zesty, i386, hwe-z, generic, linux-generic, *sa_hwe_z] |
3479 | - - [zesty, ppc64el, hwe-z, generic, linux-generic, *sa_hwe_z] |
3480 | - - [zesty, s390x, hwe-z, generic, linux-generic, *sa_hwe_z] |
3481 | - - version: "16.10" |
3482 | - release: yakkety |
3483 | - kernels: |
3484 | - - [yakkety, amd64, hwe-y, generic, linux-signed-generic, *sa_hwe_y] |
3485 | - - [yakkety, arm64, hwe-y, generic, linux-generic, *sa_hwe_y] |
3486 | - - [yakkety, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3487 | - - [yakkety, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3488 | - - [yakkety, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3489 | - - [yakkety, armhf, hwe-y, generic, linux-generic, *arm_hwe_y] |
3490 | - - [yakkety, i386, hwe-y, generic, linux-generic, *sa_hwe_y] |
3491 | - - [yakkety, ppc64el, hwe-y, generic, linux-generic, *sa_hwe_y] |
3492 | - - [yakkety, s390x, hwe-y, generic, linux-generic, *sa_hwe_y] |
3493 | - - version: "16.04" |
3494 | - release: xenial |
3495 | - kernels: |
3496 | - - [xenial, amd64, hwe-x, generic, linux-signed-generic, *sa_hwe_x] |
3497 | - - [xenial, arm64, hwe-x, generic, linux-generic, *sa_hwe_x] |
3498 | - - [xenial, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3499 | - - [xenial, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3500 | - - [xenial, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3501 | - - [xenial, armhf, hwe-x, generic, linux-generic, *arm_hwe_x] |
3502 | - - [xenial, i386, hwe-x, generic, linux-generic, *sa_hwe_x] |
3503 | - - [xenial, ppc64el, hwe-x, generic, linux-generic, *sa_hwe_x] |
3504 | - - [xenial, s390x, hwe-x, generic, linux-generic, *sa_hwe_x] |
3505 | - - version: "15.10" |
3506 | - builtin_kernel: linux-generic |
3507 | - release: wily |
3508 | - kernels: |
3509 | - - [wily, armhf, hwe-w, generic, linux-generic, *arm_hwe_w] |
3510 | - - [wily, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3511 | - - [wily, i386, hwe-w, generic, linux-generic, *sa_hwe_w] |
3512 | - - [wily, amd64, hwe-w, generic, linux-signed-generic, *sa_hwe_w] |
3513 | - - [wily, ppc64el, hwe-w, generic, linux-generic, *sa_hwe_w] |
3514 | - - [wily, arm64, hwe-w, generic, linux-generic, *sa_hwe_w] |
3515 | - - [wily, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3516 | - - [wily, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3517 | - - version: "15.04" |
3518 | - release: vivid |
3519 | - builtin_kernel: linux-generic |
3520 | - kernels: |
3521 | - - [vivid, armhf, hwe-v, generic, linux-generic, *arm_hwe_v] |
3522 | - - [vivid, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3523 | - - [vivid, i386, hwe-v, generic, linux-generic, *sa_hwe_v] |
3524 | - - [vivid, amd64, hwe-v, generic, linux-signed-generic, *sa_hwe_v] |
3525 | - - [vivid, ppc64el, hwe-v, generic, linux-generic, *sa_hwe_v] |
3526 | - - [vivid, arm64, hwe-v, generic, linux-generic, *sa_hwe_v] |
3527 | - - [vivid, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3528 | - - [vivid, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3529 | - - version: "14.10" |
3530 | - builtin_kernel: linux-generic |
3531 | - release: utopic |
3532 | - kernels: |
3533 | - - [utopic, armhf, hwe-u, generic, linux-generic, *arm_hwe_u] |
3534 | - - [utopic, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3535 | - - [utopic, i386, hwe-u, generic, linux-generic, *sa_hwe_u] |
3536 | - - [utopic, amd64, hwe-u, generic, linux-signed-generic, *sa_hwe_u] |
3537 | - - [utopic, ppc64el, hwe-u, generic, linux-generic, *sa_hwe_u] |
3538 | - - [utopic, arm64, hwe-u, generic, linux-generic, *sa_hwe_u] |
3539 | - - [utopic, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3540 | - - [utopic, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3541 | - - version: "14.04" |
3542 | - builtin_kernel: linux-generic |
3543 | - release: trusty |
3544 | - kernels: |
3545 | - - [trusty, armhf, hwe-t, generic, linux-generic, *arm_hwe_t] |
3546 | - - [trusty, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3547 | - - [trusty, i386, hwe-t, generic, linux-generic, *sa_hwe_t] |
3548 | - - [trusty, amd64, hwe-t, generic, linux-signed-generic, *sa_hwe_t] |
3549 | - - [trusty, ppc64el, hwe-t, generic, linux-generic, *sa_hwe_t] |
3550 | - - [trusty, arm64, hwe-t, generic, linux-generic, *sa_hwe_t] |
3551 | - - [trusty, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3552 | - - [trusty, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3553 | - - [utopic, amd64, hwe-u, generic, linux-signed-generic-lts-utopic, *sa_hwe_u] |
3554 | - - [utopic, arm64, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3555 | - - [utopic, armhf, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3556 | - - [utopic, i386, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3557 | - - [utopic, ppc64el, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3558 | - - [vivid, amd64, hwe-v, generic, linux-signed-generic-lts-vivid, *sa_hwe_v] |
3559 | - - [vivid, arm64, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3560 | - - [vivid, armhf, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3561 | - - [vivid, i386, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3562 | - - [vivid, ppc64el, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3563 | - - [wily, amd64, hwe-w, generic, linux-signed-generic-lts-wily, *sa_hwe_w] |
3564 | - - [wily, arm64, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3565 | - - [wily, armhf, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3566 | - - [wily, i386, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3567 | - - [wily, ppc64el, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3568 | - - [xenial, amd64, hwe-x, generic, linux-signed-generic-lts-xenial, *sa_hwe_x] |
3569 | - - [xenial, arm64, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x] |
3570 | - - [xenial, armhf, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x] |
3571 | - - [xenial, i386, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x] |
3572 | - - [xenial, ppc64el, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x] |
3573 | - - version: "13.10" |
3574 | - builtin_kernel: linux-generic |
3575 | - release: saucy |
3576 | - kernels: |
3577 | - - [saucy, armhf, hwe-s, generic, linux-generic, *sa_hwe_s] |
3578 | - - [saucy, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3579 | - - [saucy, i386, hwe-s, generic, linux-generic, *sa_hwe_t] |
3580 | - - [saucy, amd64, hwe-s, generic, linux-signed-generic, *sa_hwe_t] |
3581 | - - version: "12.04" |
3582 | - release: precise |
3583 | - builtin_kernel: {armhf: linux-highbank, default: 'linux-generic'} |
3584 | - kernels: |
3585 | - - [precise, i386, hwe-p, generic, linux-generic, *sa_hwe_p] |
3586 | - - [precise, amd64, hwe-p, generic, linux-signed-generic, *sa_hwe_p] |
3587 | - - [precise, armhf, highbank, highbank, linux-highbank, [highbank]] |
3588 | - - [quantal, i386, hwe-q, generic, linux-generic-lts-quantal, *sa_hwe_q] |
3589 | - - [quantal, amd64, hwe-q, generic, linux-signed-generic-lts-quantal, *sa_hwe_q] |
3590 | - - [raring, i386, hwe-r, generic, linux-generic-lts-raring, *sa_hwe_r] |
3591 | - - [raring, amd64, hwe-r, generic, linux-signed-generic-lts-raring, *sa_hwe_r] |
3592 | - - [saucy, i386, hwe-s, generic, linux-generic-lts-saucy, *sa_hwe_s] |
3593 | - - [saucy, amd64, hwe-s, generic, linux-signed-generic-lts-saucy, *sa_hwe_s] |
3594 | - - [trusty, i386, hwe-t, generic, linux-generic-lts-trusty, *sa_hwe_t] |
3595 | - - [trusty, amd64, hwe-t, generic, linux-signed-generic-lts-trusty, *sa_hwe_t] |
3596 | - |
3597 | -# enable_proposed: True |
3598 | - |
3599 | -## Notes: |
3600 | -## * there are no hwe installer kernels for armhf |
3601 | -## nothing named 'saucy-highbank' at |
3602 | -## http://ports.ubuntu.com/ubuntu-ports/dists/precise-updates/main/installer-armhf/current/images/MD5SUMS |
3603 | -## so for now, we just don't have a stream for that. |
3604 | -## * kernel meta package in all cases here is linux-image-<flavor> |
3605 | - |
3606 | -default_target: http://images.maas.io/ephemeral-v2/daily/streams/v1/com.ubuntu.maas:daily:v2:download.json |
3607 | -content_id: com.ubuntu.maas:daily:v2:download |
3608 | -product_id_pre: com.ubuntu.maas.daily:v2:boot |
3609 | - |
3610 | -# vi: syntax=yaml nowrap |
3611 | |
3612 | === removed file 'conf/meph-v3.yaml' |
3613 | --- conf/meph-v3.yaml 2018-05-04 17:21:27 +0000 |
3614 | +++ conf/meph-v3.yaml 1970-01-01 00:00:00 +0000 |
3615 | @@ -1,228 +0,0 @@ |
3616 | -# kernel entries are a list of |
3617 | -# kernel-release, arch, primary-subarch, flavor, kernel-pkgname, subarches |
3618 | -# we use the anchors to make subarches more compact |
3619 | -# |
3620 | -# builtin_kernel is "builtin" kernel. |
3621 | -# default is 'linux-generic' |
3622 | -# |
3623 | -# kernel arrays are |
3624 | -# krel, karch, primary-subarch, flavor, kernel-package, [subarches], {khdata} |
3625 | -# |
3626 | -# 'khdata' is an optional dictionary used to tell which dtb files to pull or |
3627 | -# what kernel helper to run on the kernel and initramfs. |
3628 | - |
3629 | -# Previous to 16.04 subarches were named using the format |
3630 | -# hwe-<first letter of release>. From 16.04 onwards kernels come in the format |
3631 | -# hwe-<release version>. Because the version has a '.' in it we keep the old |
3632 | -# naming format for the anchors. |
3633 | -subarches: |
3634 | - - &sa_hwe_p [generic, hwe-p] |
3635 | - - &sa_hwe_q [generic, hwe-p, hwe-q] |
3636 | - - &sa_hwe_r [generic, hwe-p, hwe-q, hwe-r] |
3637 | - - &sa_hwe_s [generic, hwe-p, hwe-q, hwe-r, hwe-s] |
3638 | - - &sa_hwe_t [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t] |
3639 | - - &sa_hwe_u [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u] |
3640 | - - &sa_hwe_v [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v] |
3641 | - - &sa_hwe_w [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w] |
3642 | - - &sa_hwe_x [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04] |
3643 | - - &sa_hwe_x_edge [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, hwe-16.04, hwe-16.10] |
3644 | - - &sa_hwe_x_legacy [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, hwe-x] |
3645 | - - &sa_hwe_y [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10] |
3646 | - - &sa_hwe_z [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04] |
3647 | - - &sa_hwe_a [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04, ga-17.10] |
3648 | - - &sa_hwe_b [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04, ga-17.10, ga-18.04] |
3649 | - - &sa_hwe_cc [generic, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04, ga-17.10, ga-18.04, ga-18.10] |
3650 | - - &arm_hwe_t [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t] |
3651 | - - &arm_hwe_u [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u] |
3652 | - - &arm_hwe_v [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v] |
3653 | - - &arm_hwe_w [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w] |
3654 | - - &arm_hwe_x [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04] |
3655 | - - &arm_hwe_x_edge [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, hwe-16.04, hwe-16.10] |
3656 | - - &arm_hwe_y [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10] |
3657 | - - &arm_hwe_z [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04] |
3658 | - - &arm_hwe_a [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04, ga-17.10] |
3659 | - - &arm_hwe_b [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04, ga-17.10, ga-18.04] |
3660 | - - &arm_hwe_cc [generic, highbank, hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u, hwe-v, hwe-w, ga-16.04, ga-16.10, ga-17.04, ga-17.10, ga-18.04, ga-18.10] |
3661 | - |
3662 | -misc: |
3663 | - - &glpae generic-lpae |
3664 | - - &xguboot xgene-uboot |
3665 | - - &mustang xgene-uboot-mustang |
3666 | - - &kh-mustang {suffix: .xgene-mustang, kihelper: kh-xgene, |
3667 | - di-format: 'xgene', dtb: 'apm-mustang.dtb'} |
3668 | - - &kh-xgene {suffix: .xgene, kihelper: "kh-xgene", di-format: 'xgene'} |
3669 | - |
3670 | -releases: |
3671 | - - version: "18.10" |
3672 | - release: cosmic |
3673 | - kernels: |
3674 | - - [cosmic, amd64, ga-18.10, generic, linux-signed-generic, *sa_hwe_cc] |
3675 | - - [cosmic, amd64, ga-18.10, lowlatency, linux-signed-image-lowlatency, *sa_hwe_cc] |
3676 | - - [cosmic, arm64, ga-18.10, generic, linux-generic, *sa_hwe_cc] |
3677 | - - [cosmic, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3678 | - - [cosmic, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3679 | - - [cosmic, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3680 | - - [cosmic, armhf, ga-18.10, generic, linux-generic, *arm_hwe_cc] |
3681 | - - [cosmic, i386, ga-18.10, generic, linux-generic, *sa_hwe_cc] |
3682 | - - [cosmic, i386, ga-18.10, lowlatency, linux-image-lowlatency, *sa_hwe_cc] |
3683 | - - [cosmic, ppc64el, ga-18.10, generic, linux-generic, *sa_hwe_cc] |
3684 | - - [cosmic, s390x, ga-18.10, generic, linux-generic, *sa_hwe_cc] |
3685 | - - version: "18.04" |
3686 | - release: bionic |
3687 | - kernels: |
3688 | - - [bionic, amd64, ga-18.04, generic, linux-signed-generic, *sa_hwe_b] |
3689 | - - [bionic, amd64, ga-18.04, lowlatency, linux-signed-image-lowlatency, *sa_hwe_b] |
3690 | - - [bionic, arm64, ga-18.04, generic, linux-generic, *sa_hwe_b] |
3691 | - - [bionic, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3692 | - - [bionic, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3693 | - - [bionic, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3694 | - - [bionic, armhf, ga-18.04, generic, linux-generic, *arm_hwe_b] |
3695 | - - [bionic, i386, ga-18.04, generic, linux-generic, *sa_hwe_b] |
3696 | - - [bionic, i386, ga-18.04, lowlatency, linux-image-lowlatency, *sa_hwe_b] |
3697 | - - [bionic, ppc64el, ga-18.04, generic, linux-generic, *sa_hwe_b] |
3698 | - - [bionic, s390x, ga-18.04, generic, linux-generic, *sa_hwe_b] |
3699 | - - version: "17.10" |
3700 | - release: artful |
3701 | - kernels: |
3702 | - - [artful, amd64, ga-17.10, generic, linux-signed-generic, *sa_hwe_a] |
3703 | - - [artful, amd64, ga-17.10, lowlatency, linux-signed-image-lowlatency, *sa_hwe_a] |
3704 | - - [artful, arm64, ga-17.10, generic, linux-generic, *sa_hwe_a] |
3705 | - - [artful, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3706 | - - [artful, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3707 | - - [artful, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3708 | - - [artful, armhf, ga-17.10, generic, linux-generic, *arm_hwe_a] |
3709 | - - [artful, i386, ga-17.10, generic, linux-generic, *sa_hwe_a] |
3710 | - - [artful, i386, ga-17.10, lowlatency, linux-image-lowlatency, *sa_hwe_a] |
3711 | - - [artful, ppc64el, ga-17.10, generic, linux-generic, *sa_hwe_a] |
3712 | - - [artful, s390x, ga-17.10, generic, linux-generic, *sa_hwe_a] |
3713 | - - version: "17.04" |
3714 | - release: zesty |
3715 | - kernels: |
3716 | - - [zesty, amd64, ga-17.04, generic, linux-signed-generic, *sa_hwe_z] |
3717 | - - [zesty, amd64, ga-17.04, lowlatency, linux-signed-image-lowlatency, *sa_hwe_z] |
3718 | - - [zesty, arm64, ga-17.04, generic, linux-generic, *sa_hwe_z] |
3719 | - - [zesty, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3720 | - - [zesty, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3721 | - - [zesty, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3722 | - - [zesty, armhf, ga-17.04, generic, linux-generic, *arm_hwe_z] |
3723 | - - [zesty, i386, ga-17.04, generic, linux-generic, *sa_hwe_z] |
3724 | - - [zesty, i386, ga-17.04, lowlatency, linux-image-lowlatency, *sa_hwe_z] |
3725 | - - [zesty, ppc64el, ga-17.04, generic, linux-generic, *sa_hwe_z] |
3726 | - - [zesty, s390x, ga-17.04, generic, linux-generic, *sa_hwe_z] |
3727 | - - version: "16.10" |
3728 | - release: yakkety |
3729 | - kernels: |
3730 | - - [yakkety, amd64, ga-16.10, generic, linux-signed-generic, *sa_hwe_y] |
3731 | - - [yakkety, amd64, ga-16.10, lowlatency, linux-signed-image-lowlatency, *sa_hwe_y] |
3732 | - - [yakkety, arm64, ga-16.10, generic, linux-generic, *sa_hwe_y] |
3733 | - - [yakkety, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3734 | - - [yakkety, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3735 | - - [yakkety, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3736 | - - [yakkety, armhf, ga-16.10, generic, linux-generic, *arm_hwe_y] |
3737 | - - [yakkety, i386, ga-16.10, generic, linux-generic, *sa_hwe_y] |
3738 | - - [yakkety, i386, ga-16.10, lowlatency, linux-image-lowlatency, *sa_hwe_y] |
3739 | - - [yakkety, ppc64el, ga-16.10, generic, linux-generic, *sa_hwe_y] |
3740 | - - [yakkety, s390x, ga-16.10, generic, linux-generic, *sa_hwe_y] |
3741 | - - version: "16.04" |
3742 | - release: xenial |
3743 | - kernels: |
3744 | - - [xenial, amd64, ga-16.04, generic, linux-signed-generic, *sa_hwe_x] |
3745 | - - [xenial, amd64, ga-16.04, lowlatency, linux-signed-lowlatency, *sa_hwe_x] |
3746 | - - [xenial, amd64, hwe-16.04, generic, linux-signed-generic-hwe-16.04, *sa_hwe_x] |
3747 | - - [xenial, amd64, hwe-16.04, lowlatency, linux-signed-lowlatency-hwe-16.04, *sa_hwe_x] |
3748 | - - [xenial, amd64, hwe-16.04-edge, generic, linux-signed-generic-hwe-16.04-edge, *sa_hwe_x_edge] |
3749 | - - [xenial, amd64, hwe-16.04-edge, lowlatency, linux-signed-lowlatency-hwe-16.04-edge, *sa_hwe_x_edge] |
3750 | - - [xenial, arm64, ga-16.04, generic, linux-generic, *sa_hwe_x] |
3751 | - - [xenial, arm64, hwe-16.04, generic, linux-generic-hwe-16.04, *sa_hwe_x] |
3752 | - - [xenial, arm64, hwe-16.04-edge, generic, linux-generic-hwe-16.04-edge, *sa_hwe_x_edge] |
3753 | - - [xenial, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3754 | - - [xenial, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3755 | - - [xenial, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3756 | - - [xenial, armhf, ga-16.04, generic, linux-generic, *arm_hwe_x] |
3757 | - - [xenial, armhf, hwe-16.04, generic, linux-generic-hwe-16.04, *arm_hwe_x] |
3758 | - - [xenial, armhf, hwe-16.04-edge, generic, linux-generic-hwe-16.04-edge, *arm_hwe_x_edge] |
3759 | - - [xenial, i386, ga-16.04, generic, linux-generic, *sa_hwe_x] |
3760 | - - [xenial, i386, ga-16.04, lowlatency, linux-lowlatency, *sa_hwe_x] |
3761 | - - [xenial, i386, hwe-16.04, generic, linux-generic-hwe-16.04, *sa_hwe_x] |
3762 | - - [xenial, i386, hwe-16.04, lowlatency, linux-lowlatency-hwe-16.04, *sa_hwe_x] |
3763 | - - [xenial, i386, hwe-16.04-edge, generic, linux-generic-hwe-16.04-edge, *sa_hwe_x_edge] |
3764 | - - [xenial, i386, hwe-16.04-edge, lowlatency, linux-lowlatency-hwe-16.04-edge, *sa_hwe_x_edge] |
3765 | - - [xenial, ppc64el, ga-16.04, generic, linux-generic, *sa_hwe_x] |
3766 | - - [xenial, ppc64el, hwe-16.04, generic, linux-generic-hwe-16.04, *sa_hwe_x] |
3767 | - - [xenial, ppc64el, hwe-16.04-edge, generic, linux-generic-hwe-16.04-edge, *sa_hwe_x_edge] |
3768 | - - [xenial, s390x, ga-16.04, generic, linux-generic, *sa_hwe_x] |
3769 | - - [xenial, s390x, hwe-16.04, generic, linux-generic-hwe-16.04, *sa_hwe_x] |
3770 | - - [xenial, s390x, hwe-16.04-edge, generic, linux-generic-hwe-16.04-edge, *sa_hwe_x_edge] |
3771 | - - version: "14.04" |
3772 | - builtin_kernel: linux-generic |
3773 | - release: trusty |
3774 | - kernels: |
3775 | - - [trusty, armhf, hwe-t, generic, linux-generic, *arm_hwe_t] |
3776 | - - [trusty, armhf, *glpae, *glpae, linux-generic-lpae, [*glpae]] |
3777 | - - [trusty, i386, hwe-t, generic, linux-generic, *sa_hwe_t] |
3778 | - - [trusty, amd64, hwe-t, generic, linux-signed-generic, *sa_hwe_t] |
3779 | - - [trusty, ppc64el, hwe-t, generic, linux-generic, *sa_hwe_t] |
3780 | - - [trusty, arm64, hwe-t, generic, linux-generic, *sa_hwe_t] |
3781 | - - [trusty, arm64, *xguboot, generic, linux-generic, [*xguboot], *kh-xgene] |
3782 | - - [trusty, arm64, *mustang, generic, linux-generic, [*mustang], *kh-mustang] |
3783 | - - [utopic, amd64, hwe-u, generic, linux-signed-generic-lts-utopic, *sa_hwe_u] |
3784 | - - [utopic, arm64, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3785 | - - [utopic, armhf, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3786 | - - [utopic, i386, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3787 | - - [utopic, ppc64el, hwe-u, generic, linux-generic-lts-utopic, *sa_hwe_u] |
3788 | - - [vivid, amd64, hwe-v, generic, linux-signed-generic-lts-vivid, *sa_hwe_v] |
3789 | - - [vivid, arm64, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3790 | - - [vivid, armhf, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3791 | - - [vivid, i386, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3792 | - - [vivid, ppc64el, hwe-v, generic, linux-generic-lts-vivid, *sa_hwe_v] |
3793 | - - [wily, amd64, hwe-w, generic, linux-signed-generic-lts-wily, *sa_hwe_w] |
3794 | - - [wily, arm64, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3795 | - - [wily, armhf, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3796 | - - [wily, i386, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3797 | - - [wily, ppc64el, hwe-w, generic, linux-generic-lts-wily, *sa_hwe_w] |
3798 | - - [xenial, amd64, hwe-x, generic, linux-signed-generic-lts-xenial, *sa_hwe_x_legacy] |
3799 | - - [xenial, amd64, hwe-x, lowlatency, linux-signed-lowlatency-lts-xenial, *sa_hwe_x_legacy] |
3800 | - - [xenial, arm64, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x_legacy] |
3801 | - - [xenial, armhf, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x_legacy] |
3802 | - - [xenial, i386, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x_legacy] |
3803 | - - [xenial, i386, hwe-x, lowlatency, linux-lowlatency, *sa_hwe_x_legacy] |
3804 | - - [xenial, ppc64el, hwe-x, generic, linux-generic-lts-xenial, *sa_hwe_x_legacy] |
3805 | - - version: "12.04" |
3806 | - release: precise |
3807 | - builtin_kernel: {armhf: linux-highbank, default: 'linux-generic'} |
3808 | - kernels: |
3809 | - - [precise, i386, hwe-p, generic, linux-generic, *sa_hwe_p] |
3810 | - - [precise, amd64, hwe-p, generic, linux-generic, *sa_hwe_p] |
3811 | - - [precise, armhf, highbank, highbank, linux-highbank, [highbank]] |
3812 | - - [quantal, i386, hwe-q, generic, linux-generic-lts-quantal, *sa_hwe_q] |
3813 | - - [quantal, amd64, hwe-q, generic, linux-signed-generic-lts-quantal, *sa_hwe_q] |
3814 | - - [raring, i386, hwe-r, generic, linux-generic-lts-raring, *sa_hwe_r] |
3815 | - - [raring, amd64, hwe-r, generic, linux-signed-generic-lts-raring, *sa_hwe_r] |
3816 | - - [saucy, i386, hwe-s, generic, linux-generic-lts-saucy, *sa_hwe_s] |
3817 | - - [saucy, amd64, hwe-s, generic, linux-signed-generic-lts-saucy, *sa_hwe_s] |
3818 | - - [trusty, i386, hwe-t, generic, linux-generic-lts-trusty, *sa_hwe_t] |
3819 | - - [trusty, amd64, hwe-t, generic, linux-signed-generic-lts-trusty, *sa_hwe_t] |
3820 | - |
3821 | -# enable_proposed: True |
3822 | - |
3823 | -# If available pull and publish SquashFS images from upstream |
3824 | -squashfs: True |
3825 | - |
3826 | -## Notes: |
3827 | -## * there are no hwe installer kernels for armhf |
3828 | -## nothing named 'saucy-highbank' at |
3829 | -## http://ports.ubuntu.com/ubuntu-ports/dists/precise-updates/main/installer-armhf/current/images/MD5SUMS |
3830 | -## so for now, we just don't have a stream for that. |
3831 | -## * kernel meta package in all cases here is linux-image-<flavor> |
3832 | - |
3833 | -default_target: http://images.maas.io/ephemeral-v3/daily/streams/v1/com.ubuntu.maas:daily:v3:download.json |
3834 | -content_id: com.ubuntu.maas:daily:v3:download |
3835 | -product_id_pre: com.ubuntu.maas.daily:v3:boot |
3836 | - |
3837 | -# By default maas-images uses the krel in the boot path. This worked for the v2 |
3838 | -# stream because there was only one kernel per release/arch/krel/kflavor. The |
3839 | -# v3 stream has multiple kernels per release/arch/krel/kflavor so use the |
3840 | -# subarch instead. |
3841 | -kname: '%(subarch)s' |
3842 | - |
3843 | -# vi: syntax=yaml nowrap |
3844 | |
3845 | === removed directory 'curtin' |
3846 | === removed directory 'curtin/centos6' |
3847 | === removed symlink 'curtin/centos6/curtin-hooks' |
3848 | === target was u'python_wrapper' |
3849 | === removed file 'curtin/centos6/curtin-hooks.py' |
3850 | --- curtin/centos6/curtin-hooks.py 2017-08-02 19:10:25 +0000 |
3851 | +++ curtin/centos6/curtin-hooks.py 1970-01-01 00:00:00 +0000 |
3852 | @@ -1,393 +0,0 @@ |
3853 | -#!/usr/bin/env python |
3854 | - |
3855 | -from __future__ import ( |
3856 | - absolute_import, |
3857 | - print_function, |
3858 | - unicode_literals, |
3859 | - ) |
3860 | - |
3861 | -import codecs |
3862 | -import os |
3863 | -import re |
3864 | -import sys |
3865 | - |
3866 | -from curtin import ( |
3867 | - block, |
3868 | - config, |
3869 | - util, |
3870 | - ) |
3871 | - |
3872 | -try: |
3873 | - from curtin import FEATURES as curtin_features |
3874 | -except ImportError: |
3875 | - curtin_features = [] |
3876 | - |
3877 | -write_files = None |
3878 | -try: |
3879 | - from curtin.futil import write_files |
3880 | -except ImportError: |
3881 | - pass |
3882 | - |
3883 | -centos_apply_network_config = None |
3884 | -try: |
3885 | - if 'CENTOS_APPLY_NETWORK_CONFIG' in curtin_features: |
3886 | - from curtin.commands.curthooks import centos_apply_network_config |
3887 | -except ImportError: |
3888 | - pass |
3889 | - |
3890 | -""" |
3891 | -CentOS 6 |
3892 | - |
3893 | -Currently Support: |
3894 | - |
3895 | -- Legacy boot |
3896 | -- DHCP of BOOTIF |
3897 | - |
3898 | -Not Supported: |
3899 | - |
3900 | -- UEFI boot (*Bad support, most likely wont support) |
3901 | -- Multiple network configration |
3902 | -- IPv6 |
3903 | -""" |
3904 | - |
3905 | -FSTAB_PREPEND = """\ |
3906 | -# |
3907 | -# /etc/fstab |
3908 | -# Created by MAAS fast-path installer. |
3909 | -# |
3910 | -# Accessible filesystems, by reference, are maintained under '/dev/disk' |
3911 | -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info |
3912 | -# |
3913 | -""" |
3914 | - |
3915 | -FSTAB_APPEND = """\ |
3916 | -tmpfs /dev/shm tmpfs defaults 0 0 |
3917 | -devpts /dev/pts devpts gid=5,mode=620 0 0 |
3918 | -sysfs /sys sysfs defaults 0 0 |
3919 | -proc /proc proc defaults 0 0 |
3920 | -""" |
3921 | - |
3922 | -GRUB_CONF = """\ |
3923 | -# |
3924 | -# /boot/grub/grub.conf |
3925 | -# Created by MAAS fast-path installer. |
3926 | -# |
3927 | -default 0 |
3928 | -timeout 0 |
3929 | -title MAAS |
3930 | - root {grub_root} |
3931 | - kernel /boot/{vmlinuz} root=UUID={root_uuid} {extra_opts} |
3932 | - initrd /boot/{initrd} |
3933 | -""" |
3934 | - |
3935 | - |
3936 | -def get_block_devices(target): |
3937 | - """Returns list of block devices for the given target.""" |
3938 | - devs = block.get_devices_for_mp(target) |
3939 | - blockdevs = set() |
3940 | - for maybepart in devs: |
3941 | - (blockdev, part) = block.get_blockdev_for_partition(maybepart) |
3942 | - blockdevs.add(blockdev) |
3943 | - return list(blockdevs) |
3944 | - |
3945 | - |
3946 | -def get_root_info(target): |
3947 | - """Returns the root partitions information.""" |
3948 | - rootpath = block.get_devices_for_mp(target)[0] |
3949 | - rootdev = os.path.basename(rootpath) |
3950 | - blocks = block._lsblock() |
3951 | - return blocks[rootdev] |
3952 | - |
3953 | - |
3954 | -def read_file(path): |
3955 | - """Returns content of a file.""" |
3956 | - with codecs.open(path, encoding='utf-8') as stream: |
3957 | - return stream.read() |
3958 | - |
3959 | - |
3960 | -def write_fstab(target, curtin_fstab): |
3961 | - """Writes the new fstab, using the fstab provided |
3962 | - from curtin.""" |
3963 | - fstab_path = os.path.join(target, 'etc', 'fstab') |
3964 | - fstab_data = read_file(curtin_fstab) |
3965 | - with open(fstab_path, 'w') as stream: |
3966 | - stream.write(FSTAB_PREPEND) |
3967 | - stream.write(fstab_data) |
3968 | - stream.write(FSTAB_APPEND) |
3969 | - |
3970 | - |
3971 | -def extract_kernel_params(data): |
3972 | - """Extracts the kernel parametes from the provided |
3973 | - grub config data.""" |
3974 | - match = re.search('^\s+kernel (.+?)$', data, re.MULTILINE) |
3975 | - return match.group(0) |
3976 | - |
3977 | - |
3978 | -def strip_kernel_params(params, strip_params=[]): |
3979 | - """Removes un-needed kernel parameters.""" |
3980 | - new_params = [] |
3981 | - for param in params: |
3982 | - remove = False |
3983 | - for strip in strip_params: |
3984 | - if param.startswith(strip): |
3985 | - remove = True |
3986 | - break |
3987 | - if remove is False: |
3988 | - new_params.append(param) |
3989 | - return new_params |
3990 | - |
3991 | - |
3992 | -def get_boot_file(target, filename): |
3993 | - """Return the full filename of file in /boot on target.""" |
3994 | - boot_dir = os.path.join(target, 'boot') |
3995 | - files = [ |
3996 | - fname |
3997 | - for fname in os.listdir(boot_dir) |
3998 | - if fname.startswith(filename) |
3999 | - ] |
4000 | - if not files: |
4001 | - return None |
4002 | - return files[0] |
4003 | - |
4004 | - |
4005 | -def write_grub_conf(target, grub_root, extra=[]): |
4006 | - """Writes a new /boot/grub/grub.conf with the correct |
4007 | - boot arguments.""" |
4008 | - root_info = get_root_info(target) |
4009 | - grub_path = os.path.join(target, 'boot', 'grub', 'grub.conf') |
4010 | - extra_opts = ' '.join(extra) |
4011 | - vmlinuz = get_boot_file(target, 'vmlinuz') |
4012 | - initrd = get_boot_file(target, 'initramfs') |
4013 | - with open(grub_path, 'w') as stream: |
4014 | - stream.write( |
4015 | - GRUB_CONF.format( |
4016 | - grub_root=grub_root, |
4017 | - vmlinuz=vmlinuz, |
4018 | - initrd=initrd, |
4019 | - root_uuid=root_info['UUID'], |
4020 | - extra_opts=extra_opts) + '\n') |
4021 | - |
4022 | - |
4023 | -def get_extra_kernel_parameters(): |
4024 | - """Extracts the extra kernel commands from /proc/cmdline |
4025 | - that should be placed onto the host. |
4026 | - |
4027 | - Any command following the '--' entry should be placed |
4028 | - onto the host. |
4029 | - """ |
4030 | - cmdline = read_file('/proc/cmdline') |
4031 | - cmdline = cmdline.split() |
4032 | - if '--' not in cmdline: |
4033 | - return [] |
4034 | - idx = cmdline.index('--') + 1 |
4035 | - if idx >= len(cmdline) + 1: |
4036 | - return [] |
4037 | - return strip_kernel_params( |
4038 | - cmdline[idx:], |
4039 | - strip_params=['initrd=', 'BOOT_IMAGE=', 'BOOTIF=']) |
4040 | - |
4041 | - |
4042 | -def get_grub_root(target): |
4043 | - """Extracts the grub root (hdX,X) from the grub command. |
4044 | - |
4045 | - This is used so the correct root device is used to install |
4046 | - stage1/stage2 boot loader. |
4047 | - |
4048 | - Note: grub-install normally does all of this for you, but |
4049 | - since the grub is older, it has an issue with the ISCSI |
4050 | - target as /dev/sda and cannot enumarate it with the BIOS. |
4051 | - """ |
4052 | - with util.RunInChroot(target) as in_chroot: |
4053 | - data = '\n'.join([ |
4054 | - 'find /boot/grub/stage1', |
4055 | - 'quit', |
4056 | - ]).encode('utf-8') |
4057 | - out, err = in_chroot(['grub', '--batch'], |
4058 | - data=data, capture=True) |
4059 | - regex = re.search('^\s+(\(.+?\))$', out, re.MULTILINE) |
4060 | - return regex.groups()[0] |
4061 | - |
4062 | - |
4063 | -def grub_install(target, root): |
4064 | - """Installs grub onto the root.""" |
4065 | - root_dev = root.split(',')[0] + ')' |
4066 | - with util.RunInChroot(target) as in_chroot: |
4067 | - data = '\n'.join([ |
4068 | - 'root %s' % root, |
4069 | - 'setup %s' % root_dev, |
4070 | - 'quit', |
4071 | - ]).encode('utf-8') |
4072 | - in_chroot(['grub', '--batch'], |
4073 | - data=data) |
4074 | - |
4075 | - |
4076 | -def set_autorelabel(target): |
4077 | - """Creates file /.autorelabel. |
4078 | - |
4079 | - This is used by SELinux to relabel all of the |
4080 | - files on the filesystem to have the correct |
4081 | - security context. Without this SSH login will |
4082 | - fail. |
4083 | - """ |
4084 | - path = os.path.join(target, '.autorelabel') |
4085 | - open(path, 'a').close() |
4086 | - |
4087 | - |
4088 | -def get_boot_mac(): |
4089 | - """Return the mac address of the booting interface.""" |
4090 | - cmdline = read_file('/proc/cmdline') |
4091 | - cmdline = cmdline.split() |
4092 | - try: |
4093 | - bootif = [ |
4094 | - option |
4095 | - for option in cmdline |
4096 | - if option.startswith('BOOTIF') |
4097 | - ][0] |
4098 | - except IndexError: |
4099 | - return None |
4100 | - _, mac = bootif.split('=') |
4101 | - mac = mac.split('-')[1:] |
4102 | - return ':'.join(mac) |
4103 | - |
4104 | - |
4105 | -def get_interface_names(): |
4106 | - """Return a dictionary mapping mac addresses to interface names.""" |
4107 | - sys_path = "/sys/class/net" |
4108 | - ifaces = {} |
4109 | - for iname in os.listdir(sys_path): |
4110 | - mac = read_file(os.path.join(sys_path, iname, "address")) |
4111 | - mac = mac.strip().lower() |
4112 | - ifaces[mac] = iname |
4113 | - return ifaces |
4114 | - |
4115 | - |
4116 | -def get_ipv4_config(iface, data): |
4117 | - """Returns the contents of the interface file for ipv4.""" |
4118 | - config = [ |
4119 | - 'TYPE="Ethernet"', |
4120 | - 'NM_CONTROLLED="no"', |
4121 | - 'USERCTL="yes"', |
4122 | - ] |
4123 | - if 'hwaddress' in data: |
4124 | - config.append('HWADDR="%s"' % data['hwaddress']) |
4125 | - else: |
4126 | - # Last ditch effort, use the device name, it probably won't match |
4127 | - # though! |
4128 | - config.append('DEVICE="%s"' % iface) |
4129 | - if data['auto']: |
4130 | - config.append('ONBOOT="yes"') |
4131 | - else: |
4132 | - config.append('ONBOOT="no"') |
4133 | - |
4134 | - method = data['method'] |
4135 | - if method == 'dhcp': |
4136 | - config.append('BOOTPROTO="dhcp"') |
4137 | - config.append('PEERDNS="yes"') |
4138 | - config.append('PERSISTENT_DHCLIENT="1"') |
4139 | - if 'hostname' in data: |
4140 | - config.append('DHCP_HOSTNAME="%s"' % data['hostname']) |
4141 | - elif method == 'static': |
4142 | - config.append('BOOTPROTO="none"') |
4143 | - config.append('IPADDR="%s"' % data['address']) |
4144 | - config.append('NETMASK="%s"' % data['netmask']) |
4145 | - if 'broadcast' in data: |
4146 | - config.append('BROADCAST="%s"' % data['broadcast']) |
4147 | - if 'gateway' in data: |
4148 | - config.append('GATEWAY="%s"' % data['gateway']) |
4149 | - elif method == 'manual': |
4150 | - config.append('BOOTPROTO="none"') |
4151 | - return '\n'.join(config) |
4152 | - |
4153 | - |
4154 | -def write_interface_config(target, iface, data): |
4155 | - """Writes config for interface.""" |
4156 | - family = data['family'] |
4157 | - if family != "inet": |
4158 | - # Only supporting ipv4 currently |
4159 | - print( |
4160 | - "WARN: unsupported family %s, " |
4161 | - "failed to configure interface: %s" (family, iface)) |
4162 | - return |
4163 | - config = get_ipv4_config(iface, data) |
4164 | - path = os.path.join( |
4165 | - target, 'etc', 'sysconfig', 'network-scripts', 'ifcfg-%s' % iface) |
4166 | - with open(path, 'w') as stream: |
4167 | - stream.write(config + '\n') |
4168 | - |
4169 | - |
4170 | -def write_network_config(target, mac): |
4171 | - """Write network configuration for the given MAC address.""" |
4172 | - inames = get_interface_names() |
4173 | - iname = inames[mac.lower()] |
4174 | - write_interface_config( |
4175 | - target, iname, { |
4176 | - 'family': 'inet', |
4177 | - 'hwaddress': mac.upper(), |
4178 | - 'auto': True, |
4179 | - 'method': 'dhcp' |
4180 | - }) |
4181 | - |
4182 | - |
4183 | -def apply_networking(cfg, target, bootmac): |
4184 | - if 'network' in cfg and centos_apply_network_config: |
4185 | - centos_apply_network_config(cfg['network'], target) |
4186 | - return |
4187 | - |
4188 | - if 'network' in cfg: |
4189 | - sys.stderr.write("WARN: network configuration provided, but " |
4190 | - "no support for applying. Using basic config.") |
4191 | - write_network_config(target, bootmac) |
4192 | - |
4193 | - |
4194 | -def handle_cloudconfig(cfg, target): |
4195 | - if not cfg.get('cloudconfig'): |
4196 | - return |
4197 | - if not write_files: |
4198 | - sys.stderr.write( |
4199 | - "WARN: Unable to handle 'cloudconfig' section in config." |
4200 | - "No 'write_files' found from curtin.\n") |
4201 | - return |
4202 | - |
4203 | - base_dir = os.path.join(target, 'etc/cloud/cloud.cfg.d') |
4204 | - write_files(cfg['cloudconfig'], base_dir) |
4205 | - |
4206 | - |
4207 | -def main(): |
4208 | - state = util.load_command_environment() |
4209 | - target = state['target'] |
4210 | - if target is None: |
4211 | - print("Target was not provided in the environment.") |
4212 | - sys.exit(1) |
4213 | - fstab = state['fstab'] |
4214 | - if fstab is None: |
4215 | - print("/etc/fstab output was not provided in the environment.") |
4216 | - sys.exit(1) |
4217 | - bootmac = get_boot_mac() |
4218 | - if bootmac is None: |
4219 | - print("Unable to determine boot interface.") |
4220 | - sys.exit(1) |
4221 | - devices = get_block_devices(target) |
4222 | - if not devices: |
4223 | - print("Unable to find block device for: %s" % target) |
4224 | - sys.exit(1) |
4225 | - |
4226 | - write_fstab(target, fstab) |
4227 | - |
4228 | - grub_root = get_grub_root(target) |
4229 | - write_grub_conf(target, grub_root, extra=get_extra_kernel_parameters()) |
4230 | - grub_install(target, grub_root) |
4231 | - |
4232 | - set_autorelabel(target) |
4233 | - |
4234 | - if state.get('config'): |
4235 | - cfg = config.load_config(state['config']) |
4236 | - else: |
4237 | - cfg = {} |
4238 | - |
4239 | - handle_cloudconfig(cfg, target) |
4240 | - |
4241 | - apply_networking(cfg, target, bootmac) |
4242 | - |
4243 | - |
4244 | -if __name__ == "__main__": |
4245 | - main() |
4246 | |
4247 | === removed symlink 'curtin/centos6/finalize' |
4248 | === target was u'python_wrapper' |
4249 | === removed file 'curtin/centos6/finalize.py' |
4250 | --- curtin/centos6/finalize.py 2016-05-11 18:47:46 +0000 |
4251 | +++ curtin/centos6/finalize.py 1970-01-01 00:00:00 +0000 |
4252 | @@ -1,99 +0,0 @@ |
4253 | -#!/usr/bin/env python |
4254 | - |
4255 | -from __future__ import ( |
4256 | - absolute_import, |
4257 | - print_function, |
4258 | - unicode_literals, |
4259 | - ) |
4260 | - |
4261 | -import json |
4262 | -import os |
4263 | -import sys |
4264 | - |
4265 | -from curtin import util |
4266 | - |
4267 | - |
4268 | -DATASOURCE_LIST = """\ |
4269 | -datasource_list: [ MAAS ] |
4270 | -""" |
4271 | - |
4272 | -DATASOURCE = """\ |
4273 | -datasource: |
4274 | - MAAS: {{consumer_key: {consumer_key}, metadata_url: '{url}', |
4275 | - token_key: {token_key}, token_secret: {token_secret}}} |
4276 | -""" |
4277 | - |
4278 | - |
4279 | -def get_datasource(**kwargs): |
4280 | - """Returns the format cloud-init datasource.""" |
4281 | - return DATASOURCE_LIST + DATASOURCE.format(**kwargs) |
4282 | - |
4283 | - |
4284 | -def load_config(path): |
4285 | - """Loads the curtin config.""" |
4286 | - with open(path, 'r') as stream: |
4287 | - return json.load(stream) |
4288 | - |
4289 | - |
4290 | -def extract_maas_parameters(config): |
4291 | - """Extracts the needed values from the debconf |
4292 | - entry.""" |
4293 | - params = {} |
4294 | - for line in config.splitlines(): |
4295 | - cloud, key, type, value = line.split()[:4] |
4296 | - if key == "cloud-init/maas-metadata-url": |
4297 | - params['url'] = value |
4298 | - elif key == "cloud-init/maas-metadata-credentials": |
4299 | - values = value.split("&") |
4300 | - for oauth in values: |
4301 | - key, value = oauth.split('=') |
4302 | - if key == 'oauth_token_key': |
4303 | - params['token_key'] = value |
4304 | - elif key == 'oauth_token_secret': |
4305 | - params['token_secret'] = value |
4306 | - elif key == 'oauth_consumer_key': |
4307 | - params['consumer_key'] = value |
4308 | - return params |
4309 | - |
4310 | - |
4311 | -def get_maas_debconf_selections(config): |
4312 | - """Gets the debconf selections from the curtin config.""" |
4313 | - try: |
4314 | - return config['debconf_selections']['maas'] |
4315 | - except KeyError: |
4316 | - return None |
4317 | - |
4318 | - |
4319 | -def write_datasource(target, data): |
4320 | - """Writes the cloudinit config into |
4321 | - /etc/cloud/cloud.cfg.d/90_datasource.cfg.""" |
4322 | - path = os.path.join( |
4323 | - target, 'etc', 'cloud', 'cloud.cfg.d', '90_datasource.cfg') |
4324 | - with open(path, 'w') as stream: |
4325 | - stream.write(data + '\n') |
4326 | - |
4327 | - |
4328 | -def main(): |
4329 | - state = util.load_command_environment() |
4330 | - target = state['target'] |
4331 | - if target is None: |
4332 | - print("Target was not provided in the environment.") |
4333 | - sys.exit(1) |
4334 | - config_f = state['config'] |
4335 | - if config_f is None: |
4336 | - print("Config was not provided in the environment.") |
4337 | - sys.exit(1) |
4338 | - config = load_config(config_f) |
4339 | - |
4340 | - debconf = get_maas_debconf_selections(config) |
4341 | - if debconf is None: |
4342 | - print("Failed to get the debconf_selections.") |
4343 | - sys.exit(1) |
4344 | - |
4345 | - params = extract_maas_parameters(debconf) |
4346 | - datasource = get_datasource(**params) |
4347 | - write_datasource(target, datasource) |
4348 | - |
4349 | - |
4350 | -if __name__ == "__main__": |
4351 | - main() |
4352 | |
4353 | === removed file 'curtin/centos6/python_wrapper' |
4354 | --- curtin/centos6/python_wrapper 2016-05-11 18:47:46 +0000 |
4355 | +++ curtin/centos6/python_wrapper 1970-01-01 00:00:00 +0000 |
4356 | @@ -1,11 +0,0 @@ |
4357 | -#!/bin/bash |
4358 | - |
4359 | -export PYTHONPATH='/curtin' |
4360 | - |
4361 | -# Ubuntu 16.04 only ships with Python 3 while previous versions only ship |
4362 | -# with Python 2. |
4363 | -if type -p python > /dev/null; then |
4364 | - exec python "$0.py" "$@" |
4365 | -else |
4366 | - exec python3 "$0.py" "$@" |
4367 | -fi |
4368 | |
4369 | === removed directory 'curtin/centos7' |
4370 | === removed symlink 'curtin/centos7/curtin-hooks' |
4371 | === target was u'python_wrapper' |
4372 | === removed file 'curtin/centos7/curtin-hooks.py' |
4373 | --- curtin/centos7/curtin-hooks.py 2018-08-17 20:11:27 +0000 |
4374 | +++ curtin/centos7/curtin-hooks.py 1970-01-01 00:00:00 +0000 |
4375 | @@ -1,396 +0,0 @@ |
4376 | -#!/usr/bin/env python |
4377 | - |
4378 | -from __future__ import ( |
4379 | - absolute_import, |
4380 | - print_function, |
4381 | - unicode_literals, |
4382 | - ) |
4383 | - |
4384 | -import codecs |
4385 | -import importlib |
4386 | -import os |
4387 | -import re |
4388 | -import sys |
4389 | - |
4390 | -from curtin import ( |
4391 | - block, |
4392 | - config, |
4393 | - log, |
4394 | - util, |
4395 | - ) |
4396 | - |
4397 | - |
4398 | -def try_import(path, unavailable=None, condition=True): |
4399 | - """Import path (module.submodule.attribute) and return it. |
4400 | - return unavailable if |
4401 | - - condition is not true |
4402 | - - import fails |
4403 | - - attribute does not exist in module.""" |
4404 | - if not condition: |
4405 | - return unavailable |
4406 | - modname, _, attrname = path.rpartition(".") |
4407 | - try: |
4408 | - mod = importlib.import_module(modname) |
4409 | - imported = getattr(mod, attrname, None) |
4410 | - except ImportError: |
4411 | - imported = None |
4412 | - return imported if imported else unavailable |
4413 | - |
4414 | - |
4415 | -curtin_features = try_import("curtin.FEATURES", []) |
4416 | -write_files = try_import("curtin.futil.write_files") |
4417 | -centos_apply_network_config = try_import( |
4418 | - "curtin.commands.curthooks.centos_apply_network_config", |
4419 | - condition='CENTOS_APPLY_NETWORK_CONFIG' in curtin_features) |
4420 | -centos_curthooks = try_import( |
4421 | - "curtin.commands.curthooks.builtin_curthooks", |
4422 | - condition='CENTOS_CURTHOOK_SUPPORT' in curtin_features) |
4423 | - |
4424 | - |
4425 | -FSTAB_PREPEND = """\ |
4426 | -# |
4427 | -# /etc/fstab |
4428 | -# Created by MAAS fast-path installer. |
4429 | -# |
4430 | -# Accessible filesystems, by reference, are maintained under '/dev/disk' |
4431 | -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info |
4432 | -# |
4433 | -""" |
4434 | - |
4435 | -FSTAB_UEFI = """\ |
4436 | -LABEL=uefi-boot /boot/efi vfat defaults 0 0 |
4437 | -""" |
4438 | - |
4439 | -GRUB_PREPEND = """\ |
4440 | -# Set by MAAS fast-path installer. |
4441 | -GRUB_TIMEOUT=0 |
4442 | -GRUB_TERMINAL_OUTPUT=console |
4443 | -GRUB_DISABLE_OS_PROBER=true |
4444 | -""" |
4445 | - |
4446 | - |
4447 | -def get_block_devices(target): |
4448 | - """Returns list of block devices for the given target.""" |
4449 | - devs = block.get_devices_for_mp(target) |
4450 | - blockdevs = set() |
4451 | - for maybepart in devs: |
4452 | - (blockdev, part) = block.get_blockdev_for_partition(maybepart) |
4453 | - blockdevs.add(blockdev) |
4454 | - return list(blockdevs) |
4455 | - |
4456 | - |
4457 | -def get_root_info(target): |
4458 | - """Returns the root partitions information.""" |
4459 | - rootpath = block.get_devices_for_mp(target)[0] |
4460 | - rootdev = os.path.basename(rootpath) |
4461 | - blocks = block._lsblock() |
4462 | - return blocks[rootdev] |
4463 | - |
4464 | - |
4465 | -def read_file(path): |
4466 | - """Returns content of a file.""" |
4467 | - with codecs.open(path, encoding='utf-8') as stream: |
4468 | - return stream.read() |
4469 | - |
4470 | - |
4471 | -def write_fstab(target, curtin_fstab): |
4472 | - """Writes the new fstab, using the fstab provided |
4473 | - from curtin.""" |
4474 | - fstab_path = os.path.join(target, 'etc', 'fstab') |
4475 | - fstab_data = read_file(curtin_fstab) |
4476 | - with open(fstab_path, 'w') as stream: |
4477 | - stream.write(FSTAB_PREPEND) |
4478 | - stream.write(fstab_data) |
4479 | - if util.is_uefi_bootable(): |
4480 | - stream.write(FSTAB_UEFI) |
4481 | - |
4482 | - |
4483 | -def strip_kernel_params(params, strip_params=[]): |
4484 | - """Removes un-needed kernel parameters.""" |
4485 | - new_params = [] |
4486 | - for param in params: |
4487 | - remove = False |
4488 | - for strip in strip_params: |
4489 | - if param.startswith(strip): |
4490 | - remove = True |
4491 | - break |
4492 | - if remove is False: |
4493 | - new_params.append(param) |
4494 | - return new_params |
4495 | - |
4496 | - |
4497 | -def get_extra_kernel_parameters(): |
4498 | - """Extracts the extra kernel commands from /proc/cmdline |
4499 | - that should be placed onto the host. |
4500 | - |
4501 | - Any command following the '--' entry should be placed |
4502 | - onto the host. |
4503 | - """ |
4504 | - cmdline = read_file('/proc/cmdline') |
4505 | - cmdline = cmdline.split() |
4506 | - if '--' not in cmdline: |
4507 | - return [] |
4508 | - idx = cmdline.index('--') + 1 |
4509 | - if idx >= len(cmdline) + 1: |
4510 | - return [] |
4511 | - return strip_kernel_params( |
4512 | - cmdline[idx:], |
4513 | - strip_params=['initrd=', 'BOOT_IMAGE=', 'BOOTIF=']) |
4514 | - |
4515 | - |
4516 | -def update_grub_default(target, extra=[]): |
4517 | - """Updates /etc/default/grub with the correct options.""" |
4518 | - grub_default_path = os.path.join(target, 'etc', 'default', 'grub') |
4519 | - kernel_cmdline = ' '.join(extra) |
4520 | - with open(grub_default_path, 'a') as stream: |
4521 | - stream.write(GRUB_PREPEND) |
4522 | - stream.write('GRUB_CMDLINE_LINUX=\"%s\"\n' % kernel_cmdline) |
4523 | - |
4524 | - |
4525 | -def grub2_install(target, root): |
4526 | - """Installs grub2 to the root.""" |
4527 | - with util.RunInChroot(target) as in_chroot: |
4528 | - in_chroot(['grub2-install', '--recheck', root]) |
4529 | - |
4530 | - |
4531 | -def grub2_mkconfig(target): |
4532 | - """Writes the new grub2 config.""" |
4533 | - with util.RunInChroot(target) as in_chroot: |
4534 | - in_chroot(['grub2-mkconfig', '-o', '/boot/grub2/grub.cfg']) |
4535 | - |
4536 | - |
4537 | -def get_efibootmgr_value(output, key): |
4538 | - """Parses the `output` from 'efibootmgr' to return value for `key`.""" |
4539 | - for line in output.splitlines(): |
4540 | - split = line.split(':') |
4541 | - if len(split) == 2: |
4542 | - curr_key = split[0].strip() |
4543 | - value = split[1].strip() |
4544 | - if curr_key == key: |
4545 | - return value |
4546 | - |
4547 | - |
4548 | -def get_file_efi_loaders(output): |
4549 | - """Parses the `output` from 'efibootmgr' to return all loaders that exist |
4550 | - in '\EFI' path.""" |
4551 | - return re.findall( |
4552 | - r"^Boot(?P<hex>[0-9a-fA-F]{4})\*?\s*\S+\s+.*File\(\\EFI.*$", |
4553 | - output, re.MULTILINE) |
4554 | - |
4555 | - |
4556 | -def grub2_install_efi(target): |
4557 | - """Configure for EFI. |
4558 | - |
4559 | - First capture the currently booted loader (normally a network device), |
4560 | - then perform grub installation (adds a new bootloader and adjusts the |
4561 | - boot order), finally re-adjust the boot order so that the currently booted |
4562 | - loader is set to boot first in the new order. |
4563 | - """ |
4564 | - with util.RunInChroot(target) as in_chroot: |
4565 | - stdout, _ = in_chroot(['efibootmgr', '-v'], capture=True) |
4566 | - currently_booted = get_efibootmgr_value(stdout, 'BootCurrent') |
4567 | - loaders = get_file_efi_loaders(stdout) |
4568 | - if currently_booted in loaders: |
4569 | - loaders.remove(currently_booted) |
4570 | - for loader in loaders: |
4571 | - in_chroot(['efibootmgr', '-B', '-b', loader], capture=True) |
4572 | - in_chroot([ |
4573 | - 'grub2-install', '--target=x86_64-efi', |
4574 | - '--efi-directory', '/boot/efi', |
4575 | - '--recheck']) |
4576 | - stdout, _ = in_chroot(['efibootmgr'], capture=True) |
4577 | - currently_booted = get_efibootmgr_value(stdout, 'BootCurrent') |
4578 | - boot_order = get_efibootmgr_value(stdout, 'BootOrder').split(',') |
4579 | - if currently_booted in boot_order: |
4580 | - boot_order.remove(currently_booted) |
4581 | - boot_order = [currently_booted] + boot_order |
4582 | - new_boot_order = ','.join(boot_order) |
4583 | - in_chroot(['efibootmgr', '-o', new_boot_order]) |
4584 | - |
4585 | - |
4586 | -def set_autorelabel(target): |
4587 | - """Creates file /.autorelabel. |
4588 | - |
4589 | - This is used by SELinux to relabel all of the |
4590 | - files on the filesystem to have the correct |
4591 | - security context. Without this SSH login will |
4592 | - fail. |
4593 | - """ |
4594 | - path = os.path.join(target, '.autorelabel') |
4595 | - open(path, 'a').close() |
4596 | - |
4597 | - |
4598 | -def get_boot_mac(): |
4599 | - """Return the mac address of the booting interface.""" |
4600 | - cmdline = read_file('/proc/cmdline') |
4601 | - cmdline = cmdline.split() |
4602 | - try: |
4603 | - bootif = [ |
4604 | - option |
4605 | - for option in cmdline |
4606 | - if option.startswith('BOOTIF') |
4607 | - ][0] |
4608 | - except IndexError: |
4609 | - return None |
4610 | - _, mac = bootif.split('=') |
4611 | - mac = mac.split('-')[1:] |
4612 | - return ':'.join(mac) |
4613 | - |
4614 | - |
4615 | -def get_interface_names(): |
4616 | - """Return a dictionary mapping mac addresses to interface names.""" |
4617 | - sys_path = "/sys/class/net" |
4618 | - ifaces = {} |
4619 | - for iname in os.listdir(sys_path): |
4620 | - mac = read_file(os.path.join(sys_path, iname, "address")) |
4621 | - mac = mac.strip().lower() |
4622 | - ifaces[mac] = iname |
4623 | - return ifaces |
4624 | - |
4625 | - |
4626 | -def get_ipv4_config(iface, data): |
4627 | - """Returns the contents of the interface file for ipv4.""" |
4628 | - config = [ |
4629 | - 'TYPE="Ethernet"', |
4630 | - 'NM_CONTROLLED="no"', |
4631 | - 'USERCTL="yes"', |
4632 | - ] |
4633 | - if 'hwaddress' in data: |
4634 | - config.append('HWADDR="%s"' % data['hwaddress']) |
4635 | - # Fallback to using device name |
4636 | - else: |
4637 | - config.append('DEVICE="%"' % iface) |
4638 | - if data['auto']: |
4639 | - config.append('ONBOOT="yes"') |
4640 | - else: |
4641 | - config.append('ONBOOT="no"') |
4642 | - |
4643 | - method = data['method'] |
4644 | - if method == 'dhcp': |
4645 | - config.append('BOOTPROTO="dhcp"') |
4646 | - config.append('PEERDNS="yes"') |
4647 | - config.append('PERSISTENT_DHCLIENT="1"') |
4648 | - if 'hostname' in data: |
4649 | - config.append('DHCP_HOSTNAME="%s"' % data['hostname']) |
4650 | - elif method == 'static': |
4651 | - config.append('BOOTPROTO="none"') |
4652 | - config.append('IPADDR="%s"' % data['address']) |
4653 | - config.append('NETMASK="%s"' % data['netmask']) |
4654 | - if 'broadcast' in data: |
4655 | - config.append('BROADCAST="%s"' % data['broadcast']) |
4656 | - if 'gateway' in data: |
4657 | - config.append('GATEWAY="%s"' % data['gateway']) |
4658 | - elif method == 'manual': |
4659 | - config.append('BOOTPROTO="none"') |
4660 | - return '\n'.join(config) |
4661 | - |
4662 | - |
4663 | -def write_interface_config(target, iface, data): |
4664 | - """Writes config for interface.""" |
4665 | - family = data['family'] |
4666 | - if family != "inet": |
4667 | - # Only supporting ipv4 currently |
4668 | - print( |
4669 | - "WARN: unsupported family %s, " |
4670 | - "failed to configure interface: %s" (family, iface)) |
4671 | - return |
4672 | - config = get_ipv4_config(iface, data) |
4673 | - path = os.path.join( |
4674 | - target, 'etc', 'sysconfig', 'network-scripts', 'ifcfg-%s' % iface) |
4675 | - with open(path, 'w') as stream: |
4676 | - stream.write(config + '\n') |
4677 | - |
4678 | - |
4679 | -def write_network_config(target, mac): |
4680 | - """Write network configuration for the given MAC address.""" |
4681 | - inames = get_interface_names() |
4682 | - iname = inames[mac.lower()] |
4683 | - write_interface_config( |
4684 | - target, iname, { |
4685 | - 'family': 'inet', |
4686 | - 'hwaddress': mac.upper(), |
4687 | - 'auto': True, |
4688 | - 'method': 'dhcp' |
4689 | - }) |
4690 | - |
4691 | - |
4692 | -def apply_networking(cfg, target, bootmac): |
4693 | - if 'network' in cfg and centos_apply_network_config: |
4694 | - centos_apply_network_config(cfg['network'], target) |
4695 | - return |
4696 | - |
4697 | - if 'network' in cfg: |
4698 | - sys.stderr.write("WARN: network configuration provided, but " |
4699 | - "no support for applying. Using basic config.") |
4700 | - write_network_config(target, bootmac) |
4701 | - |
4702 | - |
4703 | -def handle_cloudconfig(cfg, target): |
4704 | - if not cfg.get('cloudconfig'): |
4705 | - return |
4706 | - if not write_files: |
4707 | - sys.stderr.write( |
4708 | - "WARN: Unable to handle 'cloudconfig' section in config." |
4709 | - "No 'write_files' found from curtin.\n") |
4710 | - return |
4711 | - |
4712 | - base_dir = os.path.join(target, 'etc/cloud/cloud.cfg.d') |
4713 | - write_files(cfg['cloudconfig'], base_dir) |
4714 | - |
4715 | - |
4716 | -def main(): |
4717 | - # Enable logging to stdout for curtin functions |
4718 | - verbosity = int(os.environ.get("CURTIN_VERBOSITY", 1)) |
4719 | - log.basicConfig(stream=sys.stdout, verbosity=verbosity) |
4720 | - |
4721 | - state = util.load_command_environment() |
4722 | - target = state['target'] |
4723 | - if target is None: |
4724 | - print("Target was not provided in the environment.") |
4725 | - sys.exit(1) |
4726 | - fstab = state['fstab'] |
4727 | - if fstab is None: |
4728 | - print("/etc/fstab output was not provided in the environment.") |
4729 | - sys.exit(1) |
4730 | - bootmac = get_boot_mac() |
4731 | - if bootmac is None: |
4732 | - print("Unable to determine boot interface.") |
4733 | - sys.exit(1) |
4734 | - devices = get_block_devices(target) |
4735 | - if not devices: |
4736 | - print("Unable to find block device for: %s" % target) |
4737 | - sys.exit(1) |
4738 | - |
4739 | - if state.get('config'): |
4740 | - cfg = config.load_config(state['config']) |
4741 | - else: |
4742 | - cfg = {} |
4743 | - |
4744 | - # Run builtin hooks if curtin has the feature and maas sent storage cfg |
4745 | - if centos_curthooks and cfg.get('storage'): |
4746 | - # centos_curthooks will complete successfully or raise an exception. |
4747 | - # Not handling the exception here means we will exit this program with |
4748 | - # a non-zero value |
4749 | - centos_curthooks(cfg, target, state) |
4750 | - return |
4751 | - |
4752 | - write_fstab(target, fstab) |
4753 | - |
4754 | - update_grub_default( |
4755 | - target, extra=get_extra_kernel_parameters()) |
4756 | - grub2_mkconfig(target) |
4757 | - if util.is_uefi_bootable(): |
4758 | - grub2_install_efi(target) |
4759 | - else: |
4760 | - for dev in devices: |
4761 | - grub2_install(target, dev) |
4762 | - |
4763 | - set_autorelabel(target) |
4764 | - |
4765 | - handle_cloudconfig(cfg, target) |
4766 | - |
4767 | - apply_networking(cfg, target, bootmac) |
4768 | - |
4769 | - |
4770 | -if __name__ == "__main__": |
4771 | - main() |
4772 | |
4773 | === removed symlink 'curtin/centos7/finalize' |
4774 | === target was u'python_wrapper' |
4775 | === removed file 'curtin/centos7/finalize.py' |
4776 | --- curtin/centos7/finalize.py 2018-09-13 08:07:51 +0000 |
4777 | +++ curtin/centos7/finalize.py 1970-01-01 00:00:00 +0000 |
4778 | @@ -1,108 +0,0 @@ |
4779 | -#!/usr/bin/env python |
4780 | - |
4781 | -from __future__ import ( |
4782 | - absolute_import, |
4783 | - print_function, |
4784 | - unicode_literals, |
4785 | - ) |
4786 | - |
4787 | -import json |
4788 | -import os |
4789 | -import sys |
4790 | - |
4791 | -from curtin import util |
4792 | -try: |
4793 | - from curtin import FEATURES as curtin_features |
4794 | -except ImportError: |
4795 | - curtin_features = [] |
4796 | - |
4797 | - |
4798 | -DATASOURCE_LIST = """\ |
4799 | -datasource_list: [ MAAS ] |
4800 | -""" |
4801 | - |
4802 | -DATASOURCE = """\ |
4803 | -datasource: |
4804 | - MAAS: {{consumer_key: {consumer_key}, metadata_url: '{url}', |
4805 | - token_key: {token_key}, token_secret: {token_secret}}} |
4806 | -""" |
4807 | - |
4808 | - |
4809 | -def get_datasource(**kwargs): |
4810 | - """Returns the format cloud-init datasource.""" |
4811 | - return DATASOURCE_LIST + DATASOURCE.format(**kwargs) |
4812 | - |
4813 | - |
4814 | -def load_config(path): |
4815 | - """Loads the curtin config.""" |
4816 | - with open(path, 'r') as stream: |
4817 | - return json.load(stream) |
4818 | - |
4819 | - |
4820 | -def extract_maas_parameters(config): |
4821 | - """Extracts the needed values from the debconf |
4822 | - entry.""" |
4823 | - params = {} |
4824 | - for line in config.splitlines(): |
4825 | - cloud, key, type, value = line.split()[:4] |
4826 | - if key == "cloud-init/maas-metadata-url": |
4827 | - params['url'] = value |
4828 | - elif key == "cloud-init/maas-metadata-credentials": |
4829 | - values = value.split("&") |
4830 | - for oauth in values: |
4831 | - key, value = oauth.split('=') |
4832 | - if key == 'oauth_token_key': |
4833 | - params['token_key'] = value |
4834 | - elif key == 'oauth_token_secret': |
4835 | - params['token_secret'] = value |
4836 | - elif key == 'oauth_consumer_key': |
4837 | - params['consumer_key'] = value |
4838 | - return params |
4839 | - |
4840 | - |
4841 | -def get_maas_debconf_selections(config): |
4842 | - """Gets the debconf selections from the curtin config.""" |
4843 | - try: |
4844 | - return config['debconf_selections']['maas'] |
4845 | - except KeyError: |
4846 | - return None |
4847 | - |
4848 | - |
4849 | -def write_datasource(target, data): |
4850 | - """Writes the cloudinit config into |
4851 | - /etc/cloud/cloud.cfg.d/90_datasource.cfg.""" |
4852 | - path = os.path.join( |
4853 | - target, 'etc', 'cloud', 'cloud.cfg.d', '90_datasource.cfg') |
4854 | - with open(path, 'w') as stream: |
4855 | - stream.write(data + '\n') |
4856 | - |
4857 | - |
4858 | -def main(): |
4859 | - # The builtin Curtin hooks handle writing the datasource as |
4860 | - # 50-cloudconfig-maas-reporting.cfg. Running this creates duplicated data |
4861 | - # at 90_datasource.cfg. |
4862 | - if 'CENTOS_CURTHOOK_SUPPORT' in curtin_features: |
4863 | - return |
4864 | - state = util.load_command_environment() |
4865 | - target = state['target'] |
4866 | - if target is None: |
4867 | - print("Target was not provided in the environment.") |
4868 | - sys.exit(1) |
4869 | - config_f = state['config'] |
4870 | - if config_f is None: |
4871 | - print("Config was not provided in the environment.") |
4872 | - sys.exit(1) |
4873 | - config = load_config(config_f) |
4874 | - |
4875 | - debconf = get_maas_debconf_selections(config) |
4876 | - if debconf is None: |
4877 | - print("Failed to get the debconf_selections.") |
4878 | - sys.exit(1) |
4879 | - |
4880 | - params = extract_maas_parameters(debconf) |
4881 | - datasource = get_datasource(**params) |
4882 | - write_datasource(target, datasource) |
4883 | - |
4884 | - |
4885 | -if __name__ == "__main__": |
4886 | - main() |
4887 | |
4888 | === removed file 'curtin/centos7/python_wrapper' |
4889 | --- curtin/centos7/python_wrapper 2016-05-11 18:47:46 +0000 |
4890 | +++ curtin/centos7/python_wrapper 1970-01-01 00:00:00 +0000 |
4891 | @@ -1,11 +0,0 @@ |
4892 | -#!/bin/bash |
4893 | - |
4894 | -export PYTHONPATH='/curtin' |
4895 | - |
4896 | -# Ubuntu 16.04 only ships with Python 3 while previous versions only ship |
4897 | -# with Python 2. |
4898 | -if type -p python > /dev/null; then |
4899 | - exec python "$0.py" "$@" |
4900 | -else |
4901 | - exec python3 "$0.py" "$@" |
4902 | -fi |
4903 | |
4904 | === removed directory 'exdata' |
4905 | === removed file 'exdata/README' |
4906 | --- exdata/README 2014-03-07 22:06:52 +0000 |
4907 | +++ exdata/README 1970-01-01 00:00:00 +0000 |
4908 | @@ -1,19 +0,0 @@ |
4909 | -each directory under here is a disjoint source/site. |
4910 | - * muc/ (maas.ubuntu.com) |
4911 | - * hcc/ (hyperscale.canonica.com) |
4912 | - |
4913 | -files in those directories are products. |
4914 | -they contain the same basic layout as a product_id in a content_id. |
4915 | - |
4916 | -The intent is to build a tool that can do this: |
4917 | - |
4918 | - * mk-exdata --output=muc-output/ --content-id=maas.ubuntu.com:boot \ |
4919 | - muc/precise-* |
4920 | - this would create a index.json in muc-output with valid stream. |
4921 | - it would just create the files and insert checksums and sizes. |
4922 | - |
4923 | - Other parameters would be '--as-of-date=20140213' to only produce |
4924 | - output as of that date, and '--max=3' to limit the output to only |
4925 | - the latest 3 in each entry. |
4926 | - |
4927 | - mk-exdata would fill in the paths per the '_path'. |
4928 | |
4929 | === removed file 'exdata/dates.txt' |
4930 | --- exdata/dates.txt 2014-03-07 22:06:52 +0000 |
4931 | +++ exdata/dates.txt 1970-01-01 00:00:00 +0000 |
4932 | @@ -1,10 +0,0 @@ |
4933 | -20120426: 12.04 precise |
4934 | -20120824: 12.04.1 precise-polish |
4935 | -20121018: 12.10 quantal |
4936 | -20130214: 12.04.2 precise-hwe-q |
4937 | -20130425: 13.04 raring |
4938 | -20130823: 12.04.3 precise-hwe-r |
4939 | -20131017: 13.10 saucy |
4940 | -20140206: 12.04.4 precise-hwe-s |
4941 | -20140417: 14.04 trusty |
4942 | -20140828: 12.04.5 precise-hwe-t |
4943 | |
4944 | === removed directory 'exdata/hcc' |
4945 | === removed file 'exdata/hcc/info.txt' |
4946 | --- exdata/hcc/info.txt 2014-03-07 22:06:52 +0000 |
4947 | +++ exdata/hcc/info.txt 1970-01-01 00:00:00 +0000 |
4948 | @@ -1,1 +0,0 @@ |
4949 | -# this would be example data that would appear on hyperscale.canonical.com |
4950 | |
4951 | === removed directory 'exdata/muc' |
4952 | === removed file 'exdata/muc/precise-armhf-p.yaml' |
4953 | --- exdata/muc/precise-armhf-p.yaml 2014-03-07 22:06:52 +0000 |
4954 | +++ exdata/muc/precise-armhf-p.yaml 1970-01-01 00:00:00 +0000 |
4955 | @@ -1,55 +0,0 @@ |
4956 | -"com.ubuntu.maas:boot:12.04:armhf": |
4957 | - _path: "%(release)s/%(arch)s/hwe-p/%(version_id)s/%(item_id)s" |
4958 | - release: "precise" |
4959 | - version: "12.04" |
4960 | - arch: "armhf" |
4961 | - subarches: "generic,hwe-p" |
4962 | - versions: |
4963 | - "20120426": |
4964 | - items: |
4965 | - boot-kernel: {} |
4966 | - boot-initrd: {} |
4967 | - di-kernel: {} |
4968 | - di-initrd: {} |
4969 | - root-image: |
4970 | - path: "%(release)s/%(arch)s/20120425/root-image" |
4971 | - "20120824": |
4972 | - items: |
4973 | - boot-kernel: {} |
4974 | - boot-initrd: {} |
4975 | - di-kernel: {} |
4976 | - di-initrd: {} |
4977 | - root-image: |
4978 | - path: "%(release)s/%(arch)s/20120823/root-image" |
4979 | - "20130214": |
4980 | - items: |
4981 | - boot-kernel: {} |
4982 | - boot-initrd: {} |
4983 | - di-kernel: {} |
4984 | - di-initrd: {} |
4985 | - root-image: |
4986 | - path: "%(release)s/%(arch)s/20130213/root-image" |
4987 | - "20130823": |
4988 | - items: |
4989 | - boot-kernel: {} |
4990 | - boot-initrd: {} |
4991 | - di-kernel: {} |
4992 | - di-initrd: {} |
4993 | - root-image: |
4994 | - path: "%(release)s/%(arch)s/20130822/root-image" |
4995 | - "20140206": |
4996 | - items: |
4997 | - boot-kernel: {} |
4998 | - boot-initrd: {} |
4999 | - di-kernel: {} |
5000 | - di-initrd: {} |
+1 from my perspective. Our CI has now been updated to use git.