-
Notifications
You must be signed in to change notification settings - Fork 2
/
man.docker
executable file
·161 lines (141 loc) · 3.9 KB
/
man.docker
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#! /usr/bin/env bash
set -eu
cd "$( dirname "$( readlink -e "${0}" )" )" || exit 1
# shellcheck disable=SC1091
[ ! -s common/vars.sh ] || . common/vars.sh
# shellcheck disable=SC2034 # Set from common/vars.sh
[[ -n "${__COMMON_VARS_INCLUDED:-}" ]] || {
echo >&2 "FATAL: Inclusion of common defaults failed"
exit 1
}
# shellcheck disable=SC2034
declare IMAGE="none"
# shellcheck disable=SC1091
[ -s common/run.sh ] && . common/run.sh >/dev/null
if (( EUID )); then
die "Please re-run '$( basename "${0}" )' as user 'root'"
fi
export PODMAN_MEMORY_RESERVATION='32m'
export PODMAN_MEMORY_LIMIT='64m'
export PODMAN_SWAP_LIMIT="${PODMAN_MEMORY_LIMIT}"
declare CATEGORY='sys-apps'
declare PN='man-db'
declare page_volume="${PN}-pages"
declare cache_volume="${PN}-cache"
_docker_resolve 'sys-apps/man-pages' >/dev/null
# ... sets package package_version package_name container_name
declare original_page_volume="${page_volume}"
# shellcheck disable=SC2154
page_volume="${page_volume}-${package_version}"
unset package package_version package_name container_name
if (( $( # <- Syntax
docker volume ls -n |
awk '{ print $2 }' |
grep -c -- "^${original_page_volume}"
) > 1 ))
then
print "Removing old '${original_page_volume}'* volumes ..."
# shellcheck disable=SC2154
docker volume ls -n |
awk '{ print $2 }' |
grep -- "^${original_page_volume}" |
xargs -r -- "${_command}" volume rm >/dev/null
fi
unset original_page_volume
# FIXME: shellcheck wants:
#
# docker_extra_mounts+=( $( add_mount ... ) )
#
# ... to be expressed in the form of:
#
# readarray -O "${#docker_extra_mounts[@]}" -t docker_extra_mounts < <(
# add_mount ...
# )
#
# shellcheck disable=SC2207
{
declare -a docker_extra_mounts=()
declare e=''
docker_extra_mounts+=( $( add_mount --print \
'/usr/share/man/' \
'/srv/host/...'
) ) || :
if [[ -n "${MANPATH:-}" ]]; then
# shellcheck disable=SC2116
for e in $( echo "${MANPATH//:/ }" ); do
if [[ -d "${e}" ]]; then
docker_extra_mounts+=( $( add_mount --print \
"${e}" \
'/srv/host/...'
) ) || :
fi
done
fi
export DOCKER_EXTRA_MOUNTS="${docker_extra_mounts[*]:-}"
unset docker_extra_mounts
}
if [ -s '/etc/man_db.conf' ]; then
DOCKER_VOLUMES+=" --volume /etc/man_db.conf:/etc/man_db.conf:ro"
fi
# Gather exported data from other created containers ...
id=''
for id in $( # <- Syntax
podman container ps \
--all \
--filter 'name=^openrc-' \
--filter 'name=^web-' \
--format '{{.ID}}'
); do
print "Including volumes from conainer '${id}' ..."
DOCKER_VOLUMES+=" --volumes-from ${id}:ro"
done
unset id
# Confusingly, if a volume is mounted from the host then the host contents are
# exposed in the container (even if there are none), but if a (new)
# named-volume is referenced then on first use the container contents are
# mirrored into the named-volume instead...
#
DOCKER_VOLUMES+=" --volume ${page_volume}:/srv/${PN}/usr/share/man"
DOCKER_VOLUMES+=" --volume ${cache_volume}:/var/cache/man"
export DOCKER_VOLUMES
declare -a docker_cmd_vars=()
declare lc=''
docker_cmd_vars=(
--env COLUMNS
--env LESS='-R -M --shift 5'
--env LESSOPEN='|lesspipe %s'
--env LINES
--env TERM
# Ordering from man(1)...
--env MANPATH
--env MANROFFOPT
--env MANROFFSEQ
--env MANSECT
#--env MANPAGER='less -s -M +Gg'
--env MANPAGER='manpager'
--env PAGER='less'
--env MANLESS
--env BROWSER
--env SYSTEM
--env MANOPT='-a'
--env MANWIDTH
--env MAN_KEEP_FORMATTING
--env MAN_KEEP_STDERR
--env MAN_DISABLE_SECCOMP
--env PIPELINE_DEBUG
#--env LANG
#--env LC_MESSAGES
--cap-add SYS_PTRACE
)
for lc in $( locale | cut -d'=' -f 1 ); do
docker_cmd_vars+=( --env "${lc}" )
done
unset lc
export docker_cmd_vars
export DOCKER_INTERACTIVE=1
export NO_BUILD_MOUNTS='no_build_mounts' # ... any value will do
_docker_resolve "${CATEGORY}/${PN}" 'service' >/dev/null
image="$( _docker_image_exists )"
export image
_docker_run ${@+"${@}"}
# vi: set colorcolumn=80 syntax=sh: