Repository navigation
Expand file tree
/
Copy pathslacker.SlackBuild
More file actions
233 lines (195 loc) · 7.78 KB
/
Copy pathslacker.SlackBuild
File metadata and controls
233 lines (195 loc) · 7.78 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/bin/bash
# Slackware build script for slacker
# This SlackBuild builds the master branch.
# It is not suggested to use it; it is not a stable and proper SlackBuild.
#
cd $(dirname $0) ; CWD=$(pwd)
set -e
PRGNAM=slacker
VERSION=${VERSION:-0.12.3}
BUILD=${BUILD:-1}
TAG=${TAG:-_FRG}
PKGTYPE=${PKGTYPE:-txz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) export ARCH=i686 ;;
arm*) export ARCH=arm ;;
*) export ARCH=$( uname -m ) ;;
esac
fi
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/FORGE}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=pentium4 -mtune=generic"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -march=x86-64 -mtune=generic -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
# yes needed.
echo "=============================================================="
cat /etc/slackware-version
echo "---------------------"
cat /etc/os-release
echo "=============================================================="
while true; do
read -p "Keep going?; [Y/n]: " answer
case "$answer" in
""|y|Y|yes|Yes|YES)
echo "Continuing..."
break
;;
n|N|no|No|NO)
echo "STOP."
exit 1
;;
*)
echo "Answer: y/yes or n/no."
;;
esac
done
# Pick the right example configs for the running release (stable vs -current).
DIR=stable
grep -q '^VERSION_CODENAME=current$' /etc/os-release && DIR=current
set -e
rm -rf $PKG $TMP
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
# First build slacker-cli (the original slacker)
cp -R $CWD/slacker-cli/* .
rm -rf target || true
chown -R root:root .
# Normalize permissions in the freshly extracted source tree:
# directories -> 755
# executable files -> 755
# other files -> 644
#
# Only -type d and -type f are matched, so symlinks are never followed
# or modified (chmod follows symlinks, which could change files outside
# the tree), and device nodes, FIFOs and sockets are left alone.
#
# Directories use "\;" instead of "+" so each one is fixed immediately,
# before find descends into it. As a regular user, a directory without
# read/search permission would otherwise be skipped; as root this makes
# no difference. Only directories that need fixing are chmod'ed, so the
# extra cost is negligible.
#
# "00755" (extra leading zero) is required for directories: GNU chmod
# preserves setgid on directories with a plain "755"; "00755" clears
# setgid and the sticky bit as well.
#
# Numeric modes on regular files clear setuid/setgid, and "-perm 755"
# and "-perm 644" are exact matches including special bits, so any
# setuid/setgid file is caught and cleaned.
#
# Works the same as root or as a regular user, in a single pass.
find . \( -type d ! -perm 755 -exec chmod 00755 {} \; \) -o \
\( -type f -perm /111 ! -perm 755 -exec chmod -f 755 {} + \) -o \
\( -type f ! -perm /111 ! -perm 644 -exec chmod -f 644 {} + \)
# online + debug is what we need for developing.
# NOTE: SLKCFLAGS only affect any C built by build scripts; the Rust code itself
# is compiled by rustc for the host arch (i686 / x86_64) automatically.
# Build ONCE: cargo-auditable embeds an SBOM and is a superset of `cargo build`,
# so use it when present, otherwise fall back to a plain build (no double build).
if command -v cargo-auditable >/dev/null 2>&1; then
CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" cargo auditable build --release
else
CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" cargo build --release
fi
# run tests
cargo test
# completion must list exactly the binary's subcommands
sh contrib/check-completion-drift.sh target/release/slacker
# generated completions must match their JSON source
python3 contrib/gen-completions.py --check
# every mutating command must stay unattended under --yes (container safety)
bash contrib/check-yes-noninteractive.sh target/release/slacker
mkdir -p $PKG/usr/bin
install -m0755 target/release/slacker $PKG/usr/bin/slacker
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
# docs
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/CONF
install -m0644 $CWD/README.md $CWD/NEWS $PKG/usr/doc/$PRGNAM-$VERSION/
install -m0644 CONF/etc-slacker/"$DIR"/"$ARCH"/* $PKG/usr/doc/$PRGNAM-$VERSION/CONF/
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
# templates/ is not shipped: slacker creates it itself on first
# `generate-template` (template.rs: create_dir_all).
mkdir -p $PKG/etc/slacker/templates
echo "https://forge.slackware.nl/rizitis/slacker/wiki/Templates" > $PKG/etc/slacker/templates/Templates-howto.txt
for f in slacker.conf distro-upgrade.conf mirrors repos blacklist; do
install -m0644 CONF/etc-slacker/"$DIR"/"$ARCH"/$f $PKG/etc/slacker/$f.new
done
chmod 644 $PKG/etc/slacker/*.new
#
install -d -m 0700 $PKG/etc/slacker/credentials.d
cp CONF/README.credentials $PKG/etc/slacker/credentials.d/
chmod 0600 $PKG/etc/slacker/credentials.d/README.credentials
cat > $PKG/etc/slacker/credentials.cat.new <<'EOF'
# slacker repository credentials (HTTPS Basic) — OPTIONAL.
# Public Slackware mirrors need NONE of this for now...
#
# Per-URL catalog: any repo whose URL starts with a section prefix uses it.
# [https://forge.slackware.nl/rizitis]
# username = rizitis
# password = <token>
#
# Or a named set in credentials.d/<name>, referenced from the repos line with
# `credentials=<name>`. Either way: chmod 600, chown root:root.
EOF
chmod 600 $PKG/etc/slacker/credentials.cat.new
# man page
mkdir -p $PKG/usr/man/man8
install -m0644 man/slacker.8 $PKG/usr/man/man8/slacker.8
gzip -9 $PKG/usr/man/man8/slacker.8
# shell completions, generated from contrib/completions.json (see
# contrib/gen-completions.py). bash is lazy-loaded by command name; zsh and
# fish autoload from their standard vendor dirs.
mkdir -p $PKG/usr/share/bash-completion/completions
install -m0644 contrib/slacker-completion.bash \
$PKG/usr/share/bash-completion/completions/slacker
mkdir -p $PKG/usr/share/zsh/site-functions
install -m0644 contrib/slacker-completion.zsh \
$PKG/usr/share/zsh/site-functions/_slacker
mkdir -p $PKG/usr/share/fish/vendor_completions.d
install -m0644 contrib/slacker.fish \
$PKG/usr/share/fish/vendor_completions.d/slacker.fish
# Now we build slacker-gui on top of slacker
pushd $CWD/slacker-gui || exit 1
cargo auditable build --release
cargo test --release
install -Dm755 target/release/slacker-gui $PKG/usr/bin/slacker-gui
install -Dm644 data/nl.slackware.forge.rizitis.SlackerGui.desktop \
$PKG/usr/share/applications/nl.slackware.forge.rizitis.SlackerGui.desktop
install -Dm644 data/nl.slackware.forge.rizitis.slacker.policy \
$PKG/usr/share/polkit-1/actions/nl.slackware.forge.rizitis.slacker.policy
# install, not cp -a: cp -a would keep the owner of the source tree
# (the user who unpacked it) and sbopkglint rejects uid/gid >= 1000.
( cd data/icons && find hicolor -type f ) | while read -r f; do
install -Dm644 -o root -g root data/icons/"$f" $PKG/usr/share/icons/"$f"
done
popd || exit 1
# Whatever came from the source trees is owned by root.
chown -R root:root $PKG/usr
# Copy the slack-desc and a custom doinst.sh
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
sleep 1
if command -v sbopkglint >/dev/null 2>&1; then
sbopkglint $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
else
echo "skip cheks: sbopkglint not found."
fi
rm -rf /tmp/slacker_* /tmp/stockdb_test_*.db /tmp/stockdb_test_*.db.new /tmp/stockdb_test_*.txt
#sleep 1
#gpg --detach-sign --armor $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE