forked from gardenlinux/gardenlinux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unbase_oci
executable file
·55 lines (47 loc) · 1.25 KB
/
unbase_oci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -eufo pipefail
container_image=ghcr.io/gardenlinux/unbase_oci:5eb999b96d0bee41b1821bba169bce6b64342d94
container_engine=podman
container_mount_opts=()
while [ $# -gt 0 ]; do
case "$1" in
--container-image)
container_image="$2"
shift 2
;;
--container-engine)
container_engine="$2"
shift 2
;;
--print-container-image)
printf '%s\n' "$container_image"
exit 0
;;
*)
break
;;
esac
done
args=()
while [ $# -gt 0 ]; do
case "$1" in
-i|--include|-x|--exclude|--dpkg-include)
container_mount_opts+=(-v "$(realpath "$2"):/mnt$(realpath "$2")")
args+=("$1" "/mnt$(realpath "$2")")
shift 2
;;
--no-default-include|--no-default-exclude|-d|--dpkg-dependencies|-l|--ldd-dependencies|--print-tree)
args+=("$1")
shift
;;
*)
break
;;
esac
done
container_mount_opts+=(-v "$(realpath "$1"):/mnt$(realpath "$1")")
[ "$1" = "$2" ] || container_mount_opts+=(-v "$(realpath "$2"):/mnt$(realpath "$2")")
[ -e "$3" ] || touch "$3"
container_mount_opts+=(-v "$(realpath "$3"):/mnt$(realpath "$3")")
args+=("/mnt$(realpath "$1")" "/mnt$(realpath "$2")" "/mnt$(realpath "$3")")
"$container_engine" run --rm --read-only --tmpfs /tmp:rw,exec "${container_mount_opts[@]}" "$container_image" "${args[@]}"