Skip to content

Commit 7a2035b

Browse files
authored
Merge pull request #85 from learmj/flow_dev
Brave new world
2 parents bc3d223 + fa5b7e9 commit 7a2035b

File tree

383 files changed

+25477
-5080
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+25477
-5080
lines changed

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
deploy/*
21
work/*
3-
postrun.sh
4-
SKIP
5-
SKIP_IMAGES
6-
.pc
7-
*-pc
2+
site/__pycache__

.gitlab-ci.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.shellcheckrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Enable most checks but disable some overly pedantic ones
2+
enable=all
3+
4+
# Disable these checks as they're often impractical
5+
disable=SC2034 # Variable appears unused (often false positives)
6+
disable=SC2086 # Double quote to prevent globbing (sometimes we want word splitting)
7+
disable=SC2154 # Silence referenced but not assigned
8+
disable=SC2181 # Check exit code directly ([ $? -eq 0 ] instead of if command)
9+
disable=SC2207 # Prefer mapfile for arrays (mapfile isn't always available)
10+
disable=SC2249 # Case statements don't always need defaults
11+
12+
# Style issues are non-fatal
13+
severity=style
14+
disable=SC2250 # Don't always want braces around variables
15+
16+
shell=bash

README.adoc

Lines changed: 83 additions & 437 deletions
Large diffs are not rendered by default.

bin/idp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ if [ "${#FARGS[@]}" -eq 0 ]; then
7676
}
7777

7878

79-
ASSET_DIR=$(pmap -f $JSON --get-key IGmeta.IGconf_sys_outputdir)
79+
ASSET_DIR=$(pmap -f $JSON --get-key IGmeta.IGconf_image_outputdir)
8080
[[ -d $ASSET_DIR ]] || die "JSON specified asset dir $ASSET_DIR is invalid"
8181

8282
# Do it

bin/ig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import os
4+
5+
bindir = os.path.dirname(os.path.abspath(__file__))
6+
igroot = os.path.dirname(bindir)
7+
sitedir = os.path.join(igroot, 'site')
8+
sys.path.insert(0, sitedir)
9+
10+
import argparse
11+
from config_loader import ConfigLoader_register_parser
12+
from metadata_parser import Metadata_register_parser
13+
from layer_manager import LayerManager_register_parser
14+
15+
def main():
16+
parser = argparse.ArgumentParser(description="rpi-image-gen core engine helper")
17+
subparsers = parser.add_subparsers(title="subcommands", dest="command")
18+
subparsers.required = True
19+
20+
# Register subcommands
21+
ConfigLoader_register_parser(subparsers)
22+
Metadata_register_parser(subparsers)
23+
LayerManager_register_parser(subparsers,root=igroot)
24+
25+
args = parser.parse_args()
26+
args.func(args)
27+
28+
29+
if __name__ == "__main__":
30+
main()

bin/igconf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ igconf_isval()
8888
return 0
8989
}
9090

91+
igconf_getval()
92+
{
93+
igconf_isval "$@" || return 1
94+
local v values=()
95+
for v in $(igconf_tr "" "$@"); do
96+
values+=("${!v}")
97+
done
98+
printf '%s\n' "${values[*]}"
99+
}
91100

92101
if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
93102
set -u
@@ -98,7 +107,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
98107
shift 1
99108

100109
case "$op" in
101-
isy|isn|isset|isnset|isval)
110+
isy|isn|isset|isnset|isval|getval)
102111
igconf_"$op" "$@"
103112
exit $?
104113
;;

bin/image2json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import sys
99
import subprocess
1010

1111

12-
VERSION = "2.0.0"
12+
VERSION = "2.1.0"
1313

1414

1515
IMAGE_KEYS = {"IGconf_device_class",
1616
"IGconf_device_variant",
1717
"IGconf_device_storage_type",
1818
"IGconf_device_sector_size",
1919
"IGconf_image_version",
20-
"IGconf_sys_outputdir"}
20+
"IGconf_image_outputdir"}
2121

2222

2323
IMAGE_KEY_TYPES = {
@@ -216,7 +216,7 @@ def get_artefact_path(file, dir_evar):
216216

217217
# Returns the size of a build artefact file.
218218
def get_artefact_size(file):
219-
f = get_artefact_path(file, "IGconf_sys_outputdir")
219+
f = get_artefact_path(file, "IGconf_image_outputdir")
220220
if f:
221221
return os.stat(f).st_size
222222
return None
@@ -319,7 +319,7 @@ def parse_genimage_config(config_path):
319319
partitions[pname]["simage"] = sname
320320

321321
# Read the partition table from the image
322-
img_path = get_artefact_path(img_name, "IGconf_sys_outputdir")
322+
img_path = get_artefact_path(img_name, "IGconf_image_outputdir")
323323
try:
324324
res = subprocess.run(
325325
["sfdisk", "--verify", "--json", img_path],

bin/runner

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,35 @@ shift 1
77

88
# Execute scripts from within these dirs in this order
99
dirs=()
10-
dirs+=("${IGIMAGE}/bdebstrap")
11-
dirs+=("${IGDEVICE}/bdebstrap")
12-
[[ -n ${IGconf_ext_dir+x} ]] && dirs+=("${IGconf_ext_dir}/bdebstrap")
10+
[[ -n ${IGconf_device_assetdir+x} ]] && dirs+=("${IGconf_device_assetdir}/bdebstrap")
11+
[[ -n ${IGconf_image_assetdir+x} ]] && dirs+=("${IGconf_image_assetdir}/bdebstrap")
12+
dirs+=("${SRC_DIR}/bdebstrap")
1313
dirs+=("${IGTOP}/scripts/bdebstrap")
1414

1515
case "$op" in
1616
setup|extract|essential|customize|cleanup)
1717
for dir in "${dirs[@]}" ; do
1818
[[ -d "$dir" ]] || continue
19-
scripts=("${dir}/${op}"*)
20-
for script in "${scripts[@]}" ; do
21-
if [ -x "$script" ] ; then
19+
if compgen -G "${dir}/${op}*" >/dev/null; then
20+
for script in "${dir}/${op}"* ; do
2221
s=$(basename "$script")
23-
if [[ $s =~ ^[a-zA-Z0-9-]+$ ]] ; then
24-
env -C "$dir" bash "$s" "$@"
25-
err=$?
26-
if [ $err -ne 0 ] ; then
27-
>&2 echo "runner: $script error ($err)"
28-
exit $err
22+
if [ -x "$script" ] ; then
23+
if [[ $s =~ ^[a-zA-Z0-9-]+$ ]] ; then
24+
echo "runner: $dir [run $s]"
25+
env -C "$dir" bash "$s" "$@"
26+
err=$?
27+
if [ $err -ne 0 ] ; then
28+
>&2 echo "runner: $script error ($err)"
29+
exit $err
30+
fi
31+
else
32+
>&2 echo "runner: $dir [skipped $s]"
2933
fi
34+
else
35+
>&2 echo "runner: $dir [ignored $s]"
3036
fi
31-
fi
32-
done
37+
done
38+
fi
3339
done
3440
;;
3541
*)

bin/uchroot

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
# safe userspec chroot wrapper as local user IGconf_device_user1 with shell
4+
# command execution.
5+
# This user is created by rpi-user-credentials as a valid regular local user
6+
# with home dir. The command is
7+
set -u
8+
9+
if [ $# -eq 0 ]; then
10+
>&2 echo "uchroot <chroot_path> [command...]"
11+
exit 1
12+
fi
13+
14+
if [ -z "${IGconf_device_user1:-}" ]; then
15+
>&2 echo "uchroot: IGconf_device_user1 not set"
16+
exit 1
17+
fi
18+
19+
if [ ! -d "$1" ]; then
20+
>&2 echo "uchroot: dir '$1' is invalid"
21+
exit 1
22+
fi
23+
24+
dir="$1"
25+
shift
26+
27+
if [ -r "${dir}/etc/passwd" ]; then
28+
spec=$(grep "^$IGconf_device_user1:" "${dir}/etc/passwd" 2>/dev/null || true)
29+
if [ -n "$spec" ]; then
30+
# home is 6th field
31+
home_dir=$(echo "$spec" | cut -d: -f6)
32+
if [ -d "${dir}${home_dir}" ]; then
33+
# GID is 4th field
34+
user_gid=$(echo "$spec" | cut -d: -f4)
35+
userspec="${IGconf_device_user1}:${user_gid}"
36+
37+
USER="$IGconf_device_user1" \
38+
LOGNAME="$IGconf_device_user1" \
39+
HOME="$home_dir" \
40+
chroot --userspec "$userspec" "$dir" /bin/sh -c "$*"
41+
exit $?
42+
fi
43+
fi
44+
fi
45+
46+
>&2 echo "uchroot: User '$IGconf_device_user1' does not exist"
47+
exit 1

0 commit comments

Comments
 (0)