-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.sh
More file actions
executable file
·47 lines (37 loc) · 1.01 KB
/
control.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.01 KB
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
#!/bin/bash
set -e
if [[ $# -eq 0 ]]; then
echo "Usage: $0 file1.deb [file2.deb ...]"
exit 1
fi
for DEBFILE in "$@"; do
if [[ ! -f "$DEBFILE" ]]; then
echo "Skipping: $DEBFILE is not a regular file."
continue
fi
echo "Processing: $DEBFILE"
TMPDIR=$(mktemp -d /tmp/deb.XXXXXXXXXX) || exit 1
trap "rm -rf '$TMPDIR'" EXIT
dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR/DEBIAN"
CONTROL="$TMPDIR/DEBIAN/control"
if [[ ! -f "$CONTROL" ]]; then
echo "Error: control file not found in $DEBFILE."
continue
fi
OLD_HASH=$(sha256sum "$CONTROL" | cut -d ' ' -f1)
nano "$CONTROL"
NEW_HASH=$(sha256sum "$CONTROL" | cut -d ' ' -f1)
if [[ "$OLD_HASH" == "$NEW_HASH" ]]; then
echo "Not modified: $DEBFILE"
else
echo "Modified. Rebuilding: $DEBFILE"
dpkg-deb -b "$TMPDIR" "$DEBFILE"
echo "Updated: $DEBFILE"
fi
rm -rf "$TMPDIR"
done
echo "Generating Packages file..."
dpkg-scanpackages -m . /dev/null > Packages
bzip2 -fks Packages
echo "Done."