Skip to content

Commit b70d72f

Browse files
authored
Extract Debian metadata files from Dockerfile (#6)
* Pull static files out of Dockerfile Refactor the Debian package build so that static files live outside of the Dockerfile so we can lint them directly This makes the layout more like what we do in the core tinypilot repo. * Remove mkdir for DEBIAN folder * Add blank line after shebang line
1 parent 0134ba9 commit b70d72f

File tree

7 files changed

+56
-28
lines changed

7 files changed

+56
-28
lines changed

.circleci/config.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
version: 2.1
22
jobs:
3+
check_bash:
4+
docker:
5+
- image: koalaman/shellcheck-alpine:v0.7.1
6+
steps:
7+
- run:
8+
name: Install dependencies
9+
command: apk add bash git openssh-client grep
10+
- checkout
11+
- run:
12+
name: Run static analysis on bash scripts
13+
command: ./dev-scripts/check-bash
314
build_deb_pkg:
415
docker:
516
- image: cimg/base:stable
@@ -49,4 +60,7 @@ jobs:
4960
workflows:
5061
build:
5162
jobs:
52-
- build_deb_pkg
63+
- check_bash
64+
- build_deb_pkg:
65+
requires:
66+
- check_bash

Dockerfile

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ ARG LIBNICE_VERSION="0.1.18"
1515
ARG LIBSRTP_VERSION="2.2.0"
1616
ARG LIBWEBSOCKETS_VERSION="v3.2-stable"
1717

18-
COPY . /app
19-
2018
RUN set -x && \
2119
apt-get update && \
2220
DEBIAN_FRONTEND=noninteractive apt-get install -y \
@@ -140,6 +138,8 @@ EOF
140138

141139
RUN mkdir --parents "${PKG_DIR}"
142140

141+
COPY ./debian-pkg "${PKG_DIR}"
142+
143143
# Add Janus files to the Debian package.
144144
RUN cp --parents --recursive --no-dereference "${INSTALL_DIR}/etc/janus" \
145145
"${INSTALL_DIR}/bin/janus" \
@@ -160,8 +160,6 @@ RUN cp --parents --no-dereference /usr/lib/arm-linux-gnueabihf/libnice.so* \
160160
/usr/lib/libwebsockets.so* \
161161
"${PKG_DIR}/"
162162

163-
RUN mkdir "${PKG_DIR}/DEBIAN"
164-
165163
WORKDIR "${PKG_DIR}/DEBIAN"
166164

167165
RUN cat > control <<EOF
@@ -175,29 +173,6 @@ Homepage: https://janus.conf.meetecho.com/
175173
Description: An open source, general purpose, WebRTC server
176174
EOF
177175

178-
RUN cat > triggers <<EOF
179-
# Reindex shared libraries.
180-
activate-noawait ldconfig
181-
EOF
182-
183-
RUN cat > preinst <<EOF
184-
#!/bin/bash
185-
systemctl disable --now janus.service > /dev/null 2>&1 || true
186-
EOF
187-
RUN chmod 0555 preinst
188-
189-
RUN cat > postinst <<EOF
190-
#!/bin/bash
191-
systemctl enable --now janus.service > /dev/null 2>&1 || true
192-
EOF
193-
RUN chmod 0555 postinst
194-
195-
RUN cat > postrm <<EOF
196-
#!/bin/bash
197-
systemctl disable --now janus.service > /dev/null 2>&1 || true
198-
EOF
199-
RUN chmod 0555 postrm
200-
201176
RUN dpkg --build "${PKG_DIR}"
202177

203178
FROM scratch as artifact

debian-pkg/DEBIAN/postinst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
systemctl enable --now janus.service > /dev/null 2>&1 || true

debian-pkg/DEBIAN/postrm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
systemctl disable --now janus.service > /dev/null 2>&1 || true

debian-pkg/DEBIAN/preinst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
systemctl disable --now janus.service > /dev/null 2>&1 || true

debian-pkg/DEBIAN/triggers

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Reindex shared libraries.
4+
activate-noawait ldconfig

dev-scripts/check-bash

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#
3+
# Run static analysis on bash scripts.
4+
5+
# Exit on first failing command.
6+
set -e
7+
8+
# Exit on unset variable.
9+
set -u
10+
11+
BASH_SCRIPTS=()
12+
13+
while read -r filepath; do
14+
if head -n 1 "${filepath}" | grep --quiet \
15+
--regexp '#!/bin/bash' \
16+
--regexp '#!/usr/bin/env bash' \
17+
--regexp '#!/usr/sh' \
18+
--regexp '#!/usr/bin/env sh' \
19+
; then
20+
BASH_SCRIPTS+=("${filepath}")
21+
fi
22+
done < <(git ls-files)
23+
24+
readonly BASH_SCRIPTS
25+
26+
shellcheck "${BASH_SCRIPTS[@]}"

0 commit comments

Comments
 (0)