Skip to content
Newer
Older
100755 453 lines (368 sloc) 12 KB
75052c2 @falconindy initial commit
authored
1 #!/bin/bash
e5a8d5b @falconindy standardize file headers and add MIT licensee
authored
2 #
3 # geninit - modular initramfs creation tool
4 #
5 # Copyright (C) 2011 by Dave Reisner <d@falconindy.com>
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 # THE SOFTWARE.
24 #
75052c2 @falconindy initial commit
authored
25
26 shopt -s extglob
d51765f @falconindy fix linker resolution for i686 and multilib
authored
27 shopt -s nullglob
75052c2 @falconindy initial commit
authored
28
570ed43 @falconindy add -s option for saving the filelist. declare globals in an obvious …
authored
29 # tender vittles
cee912e @falconindy mark static variables as readonly
authored
30 declare -r _sysconfdir=/etc
31 declare -r _sharedir=.
32 declare -r builderdir=${_sharedir}/builders
33 declare -r baseconfig=${_sysconfdir}/geninit.conf
34 declare -r carch=$(uname -m)
ddb5e48 @falconindy use declare for all globals
authored
35 declare kernver=$(uname -r)
75052c2 @falconindy initial commit
authored
36
570ed43 @falconindy add -s option for saving the filelist. declare globals in an obvious …
authored
37 # error codes
cee912e @falconindy mark static variables as readonly
authored
38 declare -ri ENOENT=2
39 declare -ri EACCES=13
40 declare -ri EEXIST=17
41 declare -ri EINVAL=22
570ed43 @falconindy add -s option for saving the filelist. declare globals in an obvious …
authored
42
43 # globals
44 declare -i automods=0
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
45 declare -i savebuildroot=0
f1562ff @falconindy dryrun is an integer value
authored
46 declare -i dryrun=0
570ed43 @falconindy add -s option for saving the filelist. declare globals in an obvious …
authored
47 declare basedir=
48 declare config=
49 declare imagename=
50 declare preset=
51 declare skipbuilders=
52 declare ocompress=
53
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
54 # -------------------------- #
55 ## general util functions ##
56 # -------------------------- #
75052c2 @falconindy initial commit
authored
57
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
58 err() { # {{{
75052c2 @falconindy initial commit
authored
59 printf 'error: %s\n' "$*"
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
60 } >&2 # }}}
75052c2 @falconindy initial commit
authored
61
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
62 info() { # {{{
75052c2 @falconindy initial commit
authored
63 printf ':: %s\n' "$*"
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
64 } # }}}
75052c2 @falconindy initial commit
authored
65
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
66 die() { # {{{
75052c2 @falconindy initial commit
authored
67 err "$*"
68 cleanup 1
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
69 } # }}}
75052c2 @falconindy initial commit
authored
70
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
71 in_array() { # {{{
75052c2 @falconindy initial commit
authored
72 local item needle=$1; shift
73 [[ -z $1 ]] && return 1 # Not Found
74
75 for item; do
73b26ca @falconindy always use == for equality
authored
76 [[ $item == $needle ]] && return 0 # Found
75052c2 @falconindy initial commit
authored
77 done
78 return 1 # Not Found
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
79 } # }}}
75052c2 @falconindy initial commit
authored
80
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
81 cleanup() { # {{{
fd3a06c @falconindy dont save the build root if it was never created
authored
82 if (( savebuildroot )) && [[ -d $buildroot ]]; then
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
83 info "buildroot preserved at: $buildroot"
84 else
85 rm -rf "$tmpdir"
86 fi
75052c2 @falconindy initial commit
authored
87 exit $1
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
88 } # }}}
75052c2 @falconindy initial commit
authored
89
25a82f8 @falconindy add a usage function
authored
90 usage() { # {{{
91 cat<<USAGE
a113c0c @falconindy cleanup usage function
authored
92 usage: geninit [options]
25a82f8 @falconindy add a usage function
authored
93
94 Options:
95 -b <path> Use base directory (default: /)
96 -c <file> Specify a different config file (default: $_sysconfdir/geninit.conf)
97 -g <path> Path and name of generated image (dry-run if unspecified)
38f816a @falconindy add -H and -L options for getting help with builders
authored
98 -H <builder> Display help for a specified builder
25a82f8 @falconindy add a usage function
authored
99 -h Display this help message
a113c0c @falconindy cleanup usage function
authored
100 -k <kver> Specify a kernel version (default: $kernver)
38f816a @falconindy add -H and -L options for getting help with builders
authored
101 -L List available builders
a113c0c @falconindy cleanup usage function
authored
102 -p <preset> Build using a preset file (any of $_sysconfdir/geninit.d/*.preset)
25a82f8 @falconindy add a usage function
authored
103 -S <names> Skip the specified builders during the build process
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
104 -s Preserve buildroot after image creation
6dda899 @falconindy allow changing location of build dir
authored
105 -t <path> Specify an alternate location for temporary workspace
25a82f8 @falconindy add a usage function
authored
106 -z <method> Override compression method
107
108 USAGE
109 exit
110 } # }}}
111
38f816a @falconindy add -H and -L options for getting help with builders
authored
112 builderlist() { # {{{
113 local -a builders=("$_sharedir"/builders/*)
114
115 (( ${#builders[*]} )) || die "no builders found"
116
117 info "Available builders -- use -H <builder> for help with a specific builder"
118 printf '%s\n' "${builders[@]##*/}" | column -c$(tput cols)
119 cleanup 0
120 } # }}}
121
122 builderhelp() { # {{{
123 local builder=$1
124
125 [[ -f $_sharedir/builders/$builder ]] || die "no such builder: $builder"
126 . "$_sharedir/builders/$builder"
127 type -t helpmsg >/dev/null || die "no help for builder: $builder"
128 info "$builder"
129 helpmsg
130 cleanup 0
131 } # }}}
132
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
133 # --------------- #
134 ## private API ##
135 # --------------- #
75052c2 @falconindy initial commit
authored
136
137 __add_file() { # {{{
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
138 # add a file to $buildroot
75052c2 @falconindy initial commit
authored
139 # $1: pathname on initcpio
140 # $2: source on disk
141 # $3: mode
142
143 (( $# == 3 )) || return $EINVAL
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
144 [[ -e $buildroot$1 ]] && return $EEXIST
75052c2 @falconindy initial commit
authored
145
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
146 install -Dm$3 "$2" "$buildroot$1"
75052c2 @falconindy initial commit
authored
147 } # }}}
148
149 __add_dir() { # {{{
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
150 # add a directory (with parents) to $buildroot
75052c2 @falconindy initial commit
authored
151 # $1: pathname on initcpio
152 # $2: mode
153
154 (( $# == 2 )) || [[ $1 == /?* ]] || return $EINVAL
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
155 [[ -e $buildroot$1 ]] && return $EEXIST
75052c2 @falconindy initial commit
authored
156
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
157 install -dm$2 "$buildroot$1"
75052c2 @falconindy initial commit
authored
158 } # }}}
159
160 __add_pipe() { # {{{
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
161 # add a pipe to $buildroot
75052c2 @falconindy initial commit
authored
162 # $1: pathname on initcpio
163 # $2: mode
164
165 (( $# == 2 )) || return $EINVAL
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
166 [[ -e $buildroot$1 ]] && return $EEXIST
75052c2 @falconindy initial commit
authored
167
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
168 mkfifo -m$2 "$buildroot$1"
75052c2 @falconindy initial commit
authored
169 } # }}}
170
d1be2d7 @falconindy rename kmodinfo as __kmodinfo
authored
171 __add_slink() { # {{{
172 # add a symlink to $buildroot
173 # $1: name on initcpio
174 # $2: target of $1
175
176 (( $# == 2 )) || return $EINVAL
177 [[ -L $buildroot$1 ]] && return $EEXIST
178
179 ln -s "$2" "$buildroot$1"
180 } # }}}
181
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
182 __build_image() { # {{{
b6714ed @falconindy ARRRGH. always use local inside a function
authored
183 local -a zopts pipesave
184 local builder= module= line= mod= file=
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
185
f6f7761 @falconindy refactor depmod creation
authored
186 # this must be resolved to an absolute path
1d41e24 @falconindy be less strict about checking imagename resolution during build
authored
187 if [[ $imagename && ${imagename:0:1} != / ]]; then
f6f7761 @falconindy refactor depmod creation
authored
188 imagename=$(readlink -f "$imagename")
1d41e24 @falconindy be less strict about checking imagename resolution during build
authored
189 [[ $imagename ]] || die "Failed to resolve path to imagename"
f6f7761 @falconindy refactor depmod creation
authored
190 fi
191
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
192 # parse builder array
193 for builder in "${builders[@]}"; do
194 in_array "$builder" "${skipbuilders[@]}" && continue
195
196 if [[ ! -f $builderdir/$builder ]]; then
197 err "cannot find builder '$builder': No such file"
198 continue
199 fi
200
87b0e96 @falconindy add subshell as the comment says there ought to be
authored
201 ( # subshell to prevent namespace pollution
202 . "$builderdir/$builder"
203 if ! type -t build >/dev/null; then
204 err "no build function found in builder '$builder'"
205 continue
206 fi
207
208 info "Building: [$builder]"
209 build
210 )
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
211 done
212
213 # add extra modules from config
214 for mod in ${modules[@]}; do
69e7d7e @falconindy throw errors on user-specfied file/module not found
authored
215 add_module "$mod" || err "Module not found: $mod"
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
216 done
217
218 # add extra files from config
219 for file in "${files[@]}"; do
ff6854c @falconindy uphold geninit.conf's claim of multiple forms to files=()
authored
220 local src=${file%%::*}
221 local dest=${file##*::}
222 [[ $dest ]] || dest=$src
223 add_binary "$src" "$dest" || err "File not found: $file"
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
224 done
225
6f6f62b @falconindy resolved linker once, during image creation
authored
226 # we always need the linker
ebcbd8f @falconindy no need to check if the linker is there yet. it wont be. and it needs…
authored
227 file=$(readlink -e "$ld_so")
228 __add_slink "${ld_so#$basedir}" "${file#$basedir}"
229 __add_file "${file#$basedir}" "${file#$basedir}" 755
6f6f62b @falconindy resolved linker once, during image creation
authored
230
f6f7761 @falconindy refactor depmod creation
authored
231 # only create depmod files if there's modules added
e37a454 @falconindy avoid using public API from within the API itself
authored
232 if [[ -d $buildroot$moduledir ]]; then
f6f7761 @falconindy refactor depmod creation
authored
233 info "Generating module dependencies"
234 depmod -b "$buildroot" "$kernver"
77b1458 @falconindy trim excess depmod files. we dont need all of them
authored
235 # trim excess depmod files
e37a454 @falconindy avoid using public API from within the API itself
authored
236 rm "$buildroot$moduledir"/modules.!(dep|alias|symbols)
f6f7761 @falconindy refactor depmod creation
authored
237 fi
570ed43 @falconindy add -s option for saving the filelist. declare globals in an obvious …
authored
238
69e7d7e @falconindy throw errors on user-specfied file/module not found
authored
239 { # create delicious config
bac42f3 @falconindy move config creation to geninit
authored
240 printf '%s %d' '%MODULES%' "${#modules[*]}"
241 printf ' %s' "${modules[@]}"
242 printf '\n'
243
244 printf '%s' '%HOOKS%'
245 printf ' %s' "${builders[@]}"
246 printf '\n'
247 } > "$buildroot/config"
248
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
249 if (( dryrun )); then
250 info "Dry run complete. Use -g <path> to create an initramfs."
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
251 return
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
252 fi
253
254 if [[ $compress != cat ]]; then
255 zopts=('-9')
73b26ca @falconindy always use == for equality
authored
256 [[ $compress == xz ]] && zopts+=('--check=crc32')
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
257 fi
258
73b26ca @falconindy always use == for equality
authored
259 info "Creating$([[ $compress == cat ]] || printf " $compress") initramfs: $imagename"
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
260
261 pushd "$buildroot" &>/dev/null
262 find . -print0 | cpio -0oH newc | "$compress" "${zopts[@]}" > "$imagename"
7966d90 @falconindy fix stupid ordering bug that clobbered PIPESTATUS
authored
263 pipesave=("${PIPESTATUS[@]}") # save immediately
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
264 popd &>/dev/null
265
266 (( pipesave[0] )) && die "failed to create filelist (find reported error)"
267 (( pipesave[1] )) && die "failed to create cpio archive (cpio reported error)"
268 (( pipesave[2] )) && die "$compress reported error compressing image"
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
269
270 info "Image creation completed successfully"
271
272 } # }}}
273
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
274 __build_preset() { # {{{
b6714ed @falconindy ARRRGH. always use local inside a function
authored
275 local preset= presetfile=$_sysconfdir/geninit.d/$1.preset
276 local var= cfg= opts= imagename=
277 local -a presets
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
278
279 if [[ ! -f $basedir$presetfile ]]; then
280 err "preset not found: $1"
281 return $ENOENT
282 fi
283
284 if ! . "$basedir$presetfile"; then
285 err "failed to read preset: $1"
286 return $EACCES
287 fi
288
289 # preset pulls in a known array 'presets'
290 for preset in "${presets[@]}"; do
ba1417a @falconindy allow disabling presets with a prefixed !
authored
291 if [[ ${preset:0:1} == ! ]]; then # marked disabled
292 continue;
293 fi
294
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
295 # resolve kernel version
296 if [[ -z $ALL_kver ]]; then
297 err "No kernel version defined for preset \`$1'"
298 return $EINVAL
299 fi
300
301 # resolve image name
302 var=${preset}_image
639fcd1 @falconindy tighten up preset var parsing
authored
303 imagename=${!var}
304 if [[ -z $imagename ]]; then
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
305 err "No imagename defined for preset \`$1'"
306 return $EINVAL
307 fi
308
639fcd1 @falconindy tighten up preset var parsing
authored
309 # use extra config, falling back on ALL_config, falling back on the default
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
310 var=${preset}_config
639fcd1 @falconindy tighten up preset var parsing
authored
311 cfg=${!var:-${ALL_config:-$_sysconfigdir/geninit.conf}}
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
312
313 # extra options are optional
314 var=${preset}_options
315 opts=${!var}
316
317 # this should always resolve to something (i hope)
318 if [[ ! -f $basedir$cfg ]]; then
319 err "preset config file not found: \`$basedir$cfg'"
320 return $ENOENT
321 fi
322
323 # we've got enough to relaunch geninit now
324 info "Building image from preset: $1-$preset"
325 printf ' ==> %s\n' "-k $ALL_kver -c $cfg -g $basedir$imagename $opts"
326 "$0" -b "$basedir" -k "$ALL_kver" -c "$cfg" -g "$basedir$imagename" $opts || return 1
327 echo
328 done
329 } # }}}
330
d1be2d7 @falconindy rename kmodinfo as __kmodinfo
authored
331 __kmodinfo() { # {{{
332 modinfo -0k $kernver "$@"
333 } # }}}
334
335 __ldd() { # {{{
336 LD_TRACE_LOADED_OBJECTS=1 "$ld_so" "$@"
337 } # }}}
338
75052c2 @falconindy initial commit
authored
339 # its a trap!
340 trap 'cleanup 130' SIGINT
341 trap 'cleanup 143' SIGTERM
342
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
343 # source public API
5aad559 @falconindy cleanup commenting in main file, do a little reorg
authored
344 . "$_sharedir/geninit.api"
75052c2 @falconindy initial commit
authored
345
f2136d7 @falconindy add quirks file for quirky modules
authored
346 # source module quirks file
347 . "$_sharedir/geninit.quirks"
348
75052c2 @falconindy initial commit
authored
349 # ------------------ #
350 ## option parsing ##
351 # ------------------ #
352
6dda899 @falconindy allow changing location of build dir
authored
353 while getopts ':b:c:g:H:hk:LMp:S:st:z:' flag; do
75052c2 @falconindy initial commit
authored
354 case $flag in
355 b) basedir=$OPTARG ;;
356 c) config=$OPTARG ;;
357 g) imagename=$OPTARG ;;
38f816a @falconindy add -H and -L options for getting help with builders
authored
358 H) builderhelp $OPTARG ;;
25a82f8 @falconindy add a usage function
authored
359 h) usage ;;
75052c2 @falconindy initial commit
authored
360 k) kernver=$OPTARG ;;
38f816a @falconindy add -H and -L options for getting help with builders
authored
361 L) builderlist ;;
a7370a0 @falconindy add -M option for dumping autodetected modules
authored
362 M) automods=1 ;;
1f2aff1 @falconindy add support for kernel presets
authored
363 p) preset=$OPTARG ;;
364 S) skipbuilders=(${OPTARG//,/ }) ;;
61ed3b4 @falconindy use find|cpio instead of gen_init_cpio
authored
365 s) savebuildroot=1 ;;
54d2b38 @falconindy The -t option should set a base tmpdir, not the workdir itself
authored
366 t) otmpdir=$OPTARG ;;
75052c2 @falconindy initial commit
authored
367 z) ocompress=$OPTARG ;; # named differently to allow overriding
368 :) die "option requires an argument -- '$OPTARG'" ;;
369 \?) die "invalid option -- '$OPTARG'" ;;
370 esac
371 done
372
ddb5e48 @falconindy use declare for all globals
authored
373 # Alter PATH. We want to make sure that /bin and /sbin are favored, since
374 # we specifically rely on GNU coreutils
375 PATH=/sbin:/bin:$PATH
376
75052c2 @falconindy initial commit
authored
377 # ----------------- #
378 ## sanity checks ##
379 # ----------------- #
380
9c03a6d @falconindy fix linker resolution for multilib platforms
authored
381 # declared as an array to force expansion. we have to be careful that the wrong
382 # linker isn't picked for mulitlib systems, so we branch on $carch.
383 case $carch in
384 i686) ld_so=("$basedir"/lib/ld-linux.so.?*) ;;
385 x86_64) ld_so=("$basedir"/lib/ld-linux-${carch//_/-}.so.?*) ;;
386 *) die "unknown architecture: $carch" ;;
387 esac
388
75052c2 @falconindy initial commit
authored
389 if (( ${#ld_so[*]} != 1 )); then # uh oh...
390 die "failed to resolve the location of /lib/ld.so. Please report this bug."
391 fi
392
393 # make sure our config exists, and source it
394 config=${config:-$baseconfig}
395 [[ ! -f $config ]] && die "failed to find config file: \`$config'" || . "$config"
396
e17a205 @falconindy fix inaccurate comment wrt basedir
authored
397 # if specified, does the basedir exist? trim any trailing slash
75052c2 @falconindy initial commit
authored
398 if [[ $basedir ]]; then
399 basedir=${basedir%/}
929cb54 @falconindy make an unfortunate exception for passing -b /
authored
400 [[ $basedir ]] && { [[ -d $basedir ]] || die "basedir \`$basedir' not found"; }
75052c2 @falconindy initial commit
authored
401 fi
402
54d2b38 @falconindy The -t option should set a base tmpdir, not the workdir itself
authored
403 # mktemp takes care of our error handling here
0daef77 @falconindy oops. use the proper default value expansion
authored
404 tmpdir=$(readlink -e "$(mktemp -d "${otmpdir:-/tmp}"/${0##*/}.XXXXXX)") || cleanup 1
6dda899 @falconindy allow changing location of build dir
authored
405
75052c2 @falconindy initial commit
authored
406 # does the kernel exist inside the basedir?
407 [[ -d $basedir/lib/modules/$kernver ]] || die "kernel \`$kernver' not found"
408
409 # is our supplied compression method (if supplied) valid?
410 compress=${ocompress:-$compress}
73b26ca @falconindy always use == for equality
authored
411 if [[ -z $compress || $compress == none ]]; then
6048c99 @falconindy allow 'none' as a compression option
authored
412 compress=cat # NOOP compressor
413 else
73b26ca @falconindy always use == for equality
authored
414 [[ $compress == @(gzip|bzip2|lzma|xz) ]] || die "unknown compression method: $compress"
75052c2 @falconindy initial commit
authored
415 type -P "$compress" >/dev/null || die "failed to find \`$compress' binary in PATH"
416 fi
417
340a7c4 @falconindy add support for dry runs
authored
418 # if $imagename is provided, its path needs to be valid
419 if [[ $imagename ]]; then
aeea626 @falconindy fail when imagepath's dirname isn't writeable
authored
420 imagepath=$(readlink -f "$imagename")
421 [[ $imagepath ]] || die "invalid path to imagename: $imagename"
422 [[ -w ${imagepath%/*} ]] || die "no permission to write to specified path: \`${imagepath%/*}'"
340a7c4 @falconindy add support for dry runs
authored
423 else # no $imagename, so we're doing a dry run
424 dryrun=1
425 fi
75052c2 @falconindy initial commit
authored
426
427 # ------------ #
428 ## int main ##
429 # ------------ #
430
6dda899 @falconindy allow changing location of build dir
authored
431 # define a few more paths for convenience
cee912e @falconindy mark static variables as readonly
authored
432 declare -r buildroot=$tmpdir/root
433 declare -r autodetect_cache=$tmpdir/autodetect.cache
434 declare -r moduledir=/lib/modules/$kernver
75052c2 @falconindy initial commit
authored
435
a7370a0 @falconindy add -M option for dumping autodetected modules
authored
436 if (( automods )); then
437 . "$_sharedir/builders/autodetect" || die "unable to source autodetect builder"
438 build
439 info "Autodetected modules"
440 [[ -s $autodetect_cache ]] && cat "$autodetect_cache"
441 cleanup 0
442 fi
443
1f2aff1 @falconindy add support for kernel presets
authored
444 if [[ $preset ]]; then
04d836e @falconindy relocate build_preset. rename it to __build_preset and declare a "pri…
authored
445 __build_preset "$preset"
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
446 else
80edf1c @falconindy dont report dry run when using a preset
authored
447 (( dryrun )) && info "Starting dry run"
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
448 __build_image
75052c2 @falconindy initial commit
authored
449 fi
450
2fa6276 @falconindy move main loop logic into its own function. localize variables
authored
451 cleanup $?
75052c2 @falconindy initial commit
authored
452
Something went wrong with that request. Please try again.