Skip to content

Commit ebf45c8

Browse files
committed
feat: Update build process and scripts; enhance report format normalization
1 parent 521ca0c commit ebf45c8

File tree

11 files changed

+82
-37
lines changed

11 files changed

+82
-37
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@ MODE ?= nuke
44
RUN_FLAGS ?=
55

66
SH_SOURCES := $(shell find scripts data -type f -name '*.sh' -print) bin/camsniff
7-
DPKG_BUILD := dpkg-buildpackage -us -uc
7+
ifndef BUILD_SOURCE
8+
ifneq (,$(findstring /mnt/,$(ROOT_DIR)))
9+
BUILD_SOURCE := 0
10+
else
11+
BUILD_SOURCE := 1
12+
endif
13+
endif
14+
15+
DPKG_BUILD_FLAGS := -us -uc
16+
ifeq ($(BUILD_SOURCE),0)
17+
DPKG_BUILD_FLAGS += -b
18+
endif
19+
DPKG_BUILD := dpkg-buildpackage $(DPKG_BUILD_FLAGS)
820

921
.PHONY: help build clean run lint dev shellcheck install-deps distclean build-coap
1022

1123
help:
1224
@echo "Available targets:"
13-
@echo " make build # dpkg-buildpackage -us -uc"
25+
@echo " make build # dpkg-buildpackage -us -uc (adds -b on /mnt; set BUILD_SOURCE=1 for source)"
1426
@echo " make clean # remove build artefacts and temporary state"
1527
@echo " make run MODE=war # invoke sudo ./scripts/camsniff.sh --mode war"
1628
@echo " make lint # shellcheck + bash -n across project scripts"
@@ -57,4 +69,4 @@ shellcheck:
5769
shellcheck -x -P scripts -P data -P . $(SH_SOURCES)
5870

5971
dev: lint
60-
$(DPKG_BUILD) --dry-run
72+
$(DPKG_BUILD)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Python](https://img.shields.io/badge/language-python-black?logo=python\&style=flat-square)](#)
1111
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)
1212

13-
**Current version:** `2.2.2` ·
13+
**Current version:** `2.2.3` ·
1414

1515
<img src="docs/camsniff.png" alt="CamSniff logo" width="320" />
1616

debian/camsniff.docs

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
#!/bin/sh
2+
set -e
3+
4+
cat <<'EOF'
15
README.md
26
VERSION
37
LICENSE
48
data/vendors/README.md
59
docs/customisation.md
610
docs/dev-helpers.md
711
docs/camsniff.png
12+
EOF

debian/camsniff.install

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
4+
cat <<'EOF'
15
scripts/camsniff.sh usr/lib/camsniff/scripts
26
scripts/requirements.txt usr/lib/camsniff/scripts
37
scripts/core/* usr/lib/camsniff/scripts/core
@@ -25,5 +29,5 @@ docs/icons/camsniff-128.png usr/share/icons/hicolor/128x128/apps/
2529
docs/icons/camsniff-64.png usr/share/icons/hicolor/64x64/apps/
2630
docs/icons/camsniff-48.png usr/share/icons/hicolor/48x48/apps/
2731
docs/icons/camsniff-32.png usr/share/icons/hicolor/32x32/apps/
28-
32+
EOF
2933

debian/camsniff.lintian-overrides

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
#!/bin/sh
2+
set -e
3+
4+
cat <<'EOF'
15
# man-db 2.13.1 emits a false-positive "groff-message" when lintian runs
26
# man --warnings --ditroff -Tutf8 on this page with stdout captured.
37
# Remove once the upstream man-db/groff pipeline bug is fixed.
48
camsniff: groff-message *command exited with status 1: /usr/libexec/man-db/zsoelim | /usr/libexec/man-db/manconv*
59
610
# Desktop file uses sudo because CamSniff requires root privileges for packet capture and low-level scanning
7-
camsniff: desktop-command-not-in-package sudo [usr/share/applications/camsniff.desktop]
11+
camsniff: desktop-command-not-in-package sudo [usr/share/applications/camsniff.desktop]
12+
EOF

debian/camsniff.manpages

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
docs/camsniff.1
1+
#!/bin/sh
2+
set -e
3+
4+
cat <<'EOF'
5+
docs/camsniff.1
6+
EOF

debian/camsniff.substvars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
misc:Depends=
2-
misc:Pre-Depends=
2+
misc:Pre-Depends=

debian/clean

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tmp
2-
dev
3-
.venv
4-
venv
1+
#!/bin/sh
2+
set -e
3+
4+
rm -rf -- tmp dev .venv venv

debian/rules

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,17 @@ override_dh_auto_build:
1818

1919
override_dh_auto_test:
2020
# No automated test suite during package build
21+
22+
override_dh_builddeb:
23+
set -e; \
24+
for pkg in $$(dh_listpackages); do \
25+
build_dir="debian/$$pkg"; \
26+
tmp_dir=$$(mktemp -d); \
27+
cp -a "$$build_dir/." "$$tmp_dir/"; \
28+
if [ -d "$$tmp_dir/DEBIAN" ]; then \
29+
chmod 0755 "$$tmp_dir/DEBIAN"; \
30+
find "$$tmp_dir/DEBIAN" -type f -exec chmod 0644 {} +; \
31+
fi; \
32+
dpkg-deb --root-owner-group --build "$$tmp_dir" ..; \
33+
rm -rf "$$tmp_dir"; \
34+
done

scripts/camsniff.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,25 @@ run_ssdp_discovery() {
803803
rm -f "$ssdp_tmp"
804804
}
805805

806+
normalize_report_format() {
807+
local raw="$1"
808+
raw=$(printf '%s' "$raw" | tr '[:upper:]' '[:lower:]')
809+
case "$raw" in
810+
md|markdown)
811+
echo "markdown"
812+
;;
813+
html|htm)
814+
echo "html"
815+
;;
816+
both|all)
817+
echo "both"
818+
;;
819+
*)
820+
echo ""
821+
;;
822+
esac
823+
}
824+
806825
while [[ $# -gt 0 ]]; do
807826
case "$1" in
808827
-m|--mode)
@@ -1144,25 +1163,6 @@ apply_optional_tool_overrides() {
11441163
fi
11451164
}
11461165

1147-
normalize_report_format() {
1148-
local raw="$1"
1149-
raw=$(printf '%s' "$raw" | tr '[:upper:]' '[:lower:]')
1150-
case "$raw" in
1151-
md|markdown)
1152-
echo "markdown"
1153-
;;
1154-
html|htm)
1155-
echo "html"
1156-
;;
1157-
both|all)
1158-
echo "both"
1159-
;;
1160-
*)
1161-
echo ""
1162-
;;
1163-
esac
1164-
}
1165-
11661166
generate_reports() {
11671167
local format="$1"
11681168
[[ -z $format ]] && return 0
@@ -1481,10 +1481,10 @@ render_smart_summary() {
14811481
local ip
14821482
for ip in "${SMART_TARGETS[@]}"; do
14831483
local score=${ip_pre_score[$ip]:-0}
1484-
local reasons=${ip_pre_reasons[$ip]:-}
1484+
local reason_summary=${ip_pre_reasons[$ip]:-}
14851485
printf " %s%-15s%s score=%s" "$CYAN" "$ip" "$RESET" "$score"
1486-
if [[ -n $reasons ]]; then
1487-
printf " (%s)" "$reasons"
1486+
if [[ -n $reason_summary ]]; then
1487+
printf " (%s)" "$reason_summary"
14881488
fi
14891489
echo ""
14901490
shown=$((shown + 1))

0 commit comments

Comments
 (0)