Skip to content

Commit 2eebaf9

Browse files
committed
Enhance coinbootmaker
* Added parameters for help and interactive mode * Wrote help
1 parent 1bd714d commit 2eebaf9

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

coinbootmaker

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -e
1+
#!/bin/bash
22

33
# Copyright (C) 2018 Gunter Miegel coinboot.io
44
#
@@ -8,8 +8,41 @@
88

99
# Helper script to convert initramfs archive into a Docker container.
1010

11-
INITRAMFS=$(readlink -f $1)
11+
display_help() {
12+
echo
13+
echo 'Coinbootmaker creates an environment for building Coinboot plugins from an'
14+
echo 'given Coinboot Initramfs.'
15+
echo
16+
echo 'When no arguments beside the path to a Coinboot Initramfs is supplied'
17+
echo 'Coinbootmaker automatically builds all plugins from the ./src directory.'
18+
echo 'Packaged Coinboot pluings are written to the ./builds directory'
19+
echo
20+
echo 'Usage: coinbootmaker [-i] <path to initramfs>'
21+
echo
22+
echo '-i Interactive mode - opens a shell in the build environment'
23+
echo '-h Display this help'
24+
echo
25+
}
26+
27+
while getopts "ih" opt; do
28+
case $opt in
29+
i)
30+
interactive=true
31+
;;
32+
h)
33+
display_help
34+
exit 1
35+
;;
36+
\?)
37+
echo "Invalid option: -$OPTARG" >&2
38+
;;
39+
esac
40+
done
41+
42+
shift $((OPTIND -1))
43+
1244
BASEDIR=$PWD
45+
INITRAMFS=$1
1346
WORKING_DIRECTORY=/tmp/$(basename $INITRAMFS)_extracted_by_-coinbootmaker
1447

1548
install -d cache
@@ -39,7 +72,11 @@ if ! grep -q '200000' /proc/sys/fs/inotify/max_user_watches; then
3972
echo '200000' | sudo tee /proc/sys/fs/inotify/max_user_watches
4073
fi
4174

42-
docker run --rm -it -v "$PWD":/mnt coinbootmaker bash -c 'cd /mnt/build/ && run-parts /mnt/src'
75+
if [ $interactive = 'true' ]; then
76+
docker run --rm -it -v "$PWD":/mnt coinbootmaker bash
77+
else
78+
docker run --rm -it -v "$PWD":/mnt coinbootmaker bash -c 'cd /mnt/build/ && run-parts /mnt/src'
79+
fi
4380

4481
echo "Cleaning up $WORKING_DIRECTORY"
4582
rm -rf $WORKING_DIRECTORY

0 commit comments

Comments
 (0)