This repository was archived by the owner on May 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakepkg
More file actions
executable file
·121 lines (88 loc) · 2.21 KB
/
makepkg
File metadata and controls
executable file
·121 lines (88 loc) · 2.21 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
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
#!/bin/bash
#
# vim ft: shell
set -eu -o pipefail
[ "${DEBUG:=false}" = "true" ] && set -x
print_info() {
printf "[\033[1;35m+\033[0m] INFO: %s\n" "${1}"
}
print_usage() {
cat <<HEREDOC >&2
usage: $(basename "${0}") [-sqh]
-s, --source Only fetch sources and exit
-q, --quiet Do not output to stdout
-h, --help Print this help and exit
HEREDOC
}
checksum() {
echo "$1 $2" | sha256sum -c - 2>/dev/null
}
fetch_dist() {
print_info "Fetching sources for '$pkgname'"
dist_file="dist/${dist##*/}"
mkdir -p dist
if ! checksum "${dist_sha256}" "${dist_file}"; then
curl -sSfL -o "${dist_file}" "${dist}"
checksum "${dist_sha256}" "${dist_file}"
fi
if tar -tf "${dist_file}" >/dev/null 2>&1; then
tar -xf "${dist_file}" --strip 1 -C "${source_dir}"
else
cp "${dist_file}" "${source_dir}"/
fi
}
fetch_sources() {
(
# shellcheck source=example-package/hello-world/pkg.conf
source pkg.conf
source_dir="${pkgname}-${pkgver}"
rm -rf "${source_dir}"
mkdir "${source_dir}"
if [ -n "${dist:-}" ]; then
fetch_dist
else
print_info "No dist file for '$pkgname'"
fi
orig="${pkgname}_${pkgver}.orig.tar.gz"
tar -czf "$orig" --recursive "${source_dir}"
cp -r debian "${source_dir}"/
)
}
_makepkg() {(
fetch_sources
case "${1:-}" in
-s|-S|--source)
return
;;
esac
# Refresh package index for build dependencies
sudo apt-get update
# shellcheck source=example-package/hello-world/pkg.conf
source pkg.conf
pushd "${pkgname}-${pkgver}"
print_info "Building package '$pkgname'"
# Get build deps for package
sudo apt-get build-dep -y .
debuild -- clean 2>&1
# Source package
debuild --no-lintian -S -uc -us 2>&1
# Binary package
debuild --no-lintian -b -uc -us 2>&1
debuild -- clean 2>&1
)}
while true; do
shiftpos=2
case "${1:-}" in
-q|--quiet)
exec >> /dev/null
shiftpos=1
;;
-h|--help)
print_usage
exit 0
;;
*) break ;;
esac
shift "$shiftpos"
done
_makepkg "$@"