-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-debian-package.sh
executable file
·51 lines (40 loc) · 2.38 KB
/
make-debian-package.sh
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
#!/bin/bash -e
# Check permissions to run.
if (($(id --user) != 0))
then
echo 'Permission denied. You must be superuser.';
exit 1;
fi;
# Get version of package.
readonly version="$(grep 'Version: ' DEBIAN/control | tail -1 | cut --delimiter=':' --fields=2 | xargs)"
# Get name of package.
readonly package="$(grep 'Package: ' DEBIAN/control | tail -1 | cut --delimiter=':' --fields=2 | xargs)"
# Set temporary package directory.
readonly build_path="/tmp/debian-${package}-${version}-build-$(date +%s%N)"
# Create package structure.
mkdir --verbose --parents ${build_path}/${package}-${version}/DEBIAN;
mkdir --verbose --parents ${build_path}/${package}-${version}/usr/bin;
mkdir --verbose --parents ${build_path}/${package}-${version}/usr/share/doc/${package};
mkdir --verbose --parents ${build_path}/${package}-${version}/usr/share/man/man8;
# Copy files
cp --verbose --recursive DEBIAN ${build_path}/${package}-${version};
cp --verbose cve-scan ${build_path}/${package}-${version}/usr/bin;
cp --verbose copyright ${build_path}/${package}-${version}/usr/share/doc/${package}/copyright;
cp --verbose changelog ${build_path}/${package}-${version}/usr/share/doc/${package}/changelog;
cp --verbose manpage ${build_path}/${package}-${version}/usr/share/man/man8/${package}.8;
# Compact files
gzip --verbose --no-name --best ${build_path}/${package}-${version}/usr/share/doc/${package}/changelog;
gzip --verbose --no-name --best ${build_path}/${package}-${version}/usr/share/man/man8/${package}.8;
# # Change ownner.
chown --verbose --recursive root:root ${build_path}/${package}-${version}/DEBIAN;
chown --verbose --recursive root:root ${build_path}/${package}-${version}/usr;
# # Change permissions.
chmod --verbose --recursive u=rwx,g=rx,o=rx ${build_path}/${package}-${version}/DEBIAN;
chmod --verbose --recursive u=rwx,g=rx,o=rx ${build_path}/${package}-${version}/usr;
chmod --verbose u=rw,g=r,o=r ${build_path}/${package}-${version}/usr/share/doc/${package}/copyright;
chmod --verbose u=rw,g=r,o=r ${build_path}/${package}-${version}/usr/share/doc/${package}/changelog.gz;
chmod --verbose u=rw,g=r,o=r ${build_path}/${package}-${version}/usr/share/man/man8/${package}.8.gz;
# Make package.
dpkg-deb --build ${build_path}/${package}-${version};
# Copy package to user directory.
cp --verbose ${build_path}/${package}-${version}.deb .;