This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
systemd.SlackBuild
executable file
·932 lines (814 loc) · 29.6 KB
/
systemd.SlackBuild
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
#!/bin/sh
#-- systemd for Slackware --
# Build script by Phantom X <megaphantomx at bol.com.br>
# Suggested usage: $ systemd.SlackBuild 2>&1 | tee build.log
#--
# Copyright 2008-2016 Phantom X, Goiania, Brazil.
# Copyright 2006 Martijn Dekker, Groningen, Netherlands.
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# http://www.freedesktop.org/wiki/Software/systemd
PACKAGER_ID=${PACKAGER_ID:-$USER}
PACKAGER=${PACKAGER:-$USER@$HOSTNAME}
# Set YES for native build with gcc >= 4.2
SB_NATIVE=${SB_NATIVE:-NO}
# Set YES to remove libtool .la files
SB_RMLA=${SB_RMLA:-NO}
# Set to YES to replicate slackbuild and patches
SB_REP=${SB_REP:-YES}
CWD=$(pwd)
TMP=${TMP:-/tmp}
NAME=systemd
PKG=${PKG:-${TMP}/package-${NAME}}
VERSION=${VERSION:-232}
if [ "${SB_NATIVE}" = "YES" ] ;then
ARCH=${ARCH:-$(uname -m)}
else
ARCH=${ARCH:-x86_64}
fi
if [ "${ARCH}" = "x86_64" ] ;then
SLKTARGET=${SLKTARGET:-x86_64}
else
SLKTARGET=${SLKTARGET:-i586}
fi
SLKDTARGET=${SLKDTARGET:-slackware}
BUILD=${BUILD:-1}
SLKDIST=${SLKDIST:-Slackware}
NJOBS=${NJOBS:-$(( $(getconf _NPROCESSORS_ONLN) + 1 ))}
DOCDIR=${PKG}/usr/doc/${NAME}-${VERSION}
SBDIR=${PKG}/usr/src/slackbuilds/${NAME}
PKGDEST=${PKGDEST:-${CWD}}
PKGFORMAT=${PKGFORMAT:-txz}
PKGNAME=${NAME}-$(echo ${VERSION} | tr - . )-${ARCH}-${BUILD}${PACKAGER_ID}
# Set YES to have systemd as default init
SB_DEF=${SB_DEF:-NO}
# Set ntp pool
SB_NTPPOOL=${SB_NTPPOOL:-south-america}
SB_NTPPOOLLST=({0..3}.${SB_NTPPOOL}.pool.ntp.org)
# Set to YES to enable pam support (for logind)
SB_PAM=${SB_PAM:-YES}
# Set YES to enable QR support (qrencode)
SB_QR=${SB_QR:-NO}
grep --quiet '^systemd-journal:' /etc/group && SB_HGROUP=1
grep --quiet '^systemd-journal-upload:' /etc/group && SB_UHGROUP=1
grep --quiet '^systemd-journal-upload:' /etc/group && SB_UHUSER=1
if [ -d /etc/pki/tls ] ;then
SB_CABDIR=/etc/pki/tls
else
SB_CABDIR=/etc/ssl
fi
DATE=$(LC_ALL=C date +%d-%b-%Y)
DOWNDIR=${CWD}/patches/backports
SRCDIR=${NAME}-${VERSION}
SRCARCHIVE=v${VERSION}.tar.gz
PSRCARCHIVES=${NAME}-backports.lst
DL_PROG=${DL_PROG:-wget}
DL_TO=${DL_TO:-5}
DL_OPTS=${DL_OPTS:-"--timeout=${DL_TO}"}
DL_URL="https://github.com/${NAME}/${NAME}/archive/${SRCARCHIVE}"
PDL_URL="https://github.com/${NAME}/${NAME}/commit"
SRCARCHIVE=${SRCDIR}.tar.gz
# if source is not present, download in source rootdir if possible
test -r ${CWD}/${SRCARCHIVE} || ${DL_PROG} ${DL_OPTS} ${DL_URL} -O ${CWD}/${SRCARCHIVE} || exit 1
mkdir -p ${DOWNDIR}
( cd ${DOWNDIR} || exit 1
[ -f ${CWD}/${PSRCARCHIVES} ] || exit 0
cat ${CWD}/${PSRCARCHIVES} | while IFS= read -r source ;do
commit="$(echo "${source}" | awk '{print $1}')"
test -r ${commit}.patch || ${DL_PROG} ${DL_OPTS} ${PDL_URL}/${commit}.patch || exit 1
done
) || exit $?
if ! test -s ${CWD}/${SRCARCHIVE} ;then
echo "${CWD}/${SRCARCHIVE} is empty"
echo "Delete ${CWD}/${SRCARCHIVE}, check VERSION and try again."
exit 1
fi
[ "$1" = "--dlsrc" ] && exit 0
if [ "${SB_NATIVE}" = "YES" ] ;then
SLKCFLAGS="-O2 -march=native -mtune=native -pipe"
[ "${SB_ECFLAGS}" ] && SLKCFLAGS+=" ${SB_ECFLAGS}"
else
case "${ARCH}" in
i[3-6]86) SLKCFLAGS="-O2 -march=${ARCH} -mtune=i686"
;;
x86_64) SLKCFLAGS="-O2 -fPIC"
;;
s390|*) SLKCFLAGS="-O2"
;;
esac
fi
if [ "${ARCH}" = "x86_64" ] ;then
LIBDIRSUFFIX="64"
SLKCFLAGS="${SLKCFLAGS} -fPIC"
else
LIBDIRSUFFIX=""
fi
if [ ! -d ${TMP} ]; then
mkdir -p ${TMP}
fi
if [ -d ${PKG} ]; then
# Clean up a previous build
rm -rf ${PKG}
fi
mkdir -p ${PKG}
cd ${TMP}
rm -rf ${SRCDIR}
tar -xvf ${CWD}/${SRCARCHIVE} || exit 1
cd ${SRCDIR} || exit 1
chmod -R u+w,go+r-w,a-s .
unset SB_AUTOGEN
if [ -r ${CWD}/apply-patches.sh ]; then
. ${CWD}/apply-patches.sh
fi
# Force file regeneration
( cd units
for i in *.in ;do
rm -fv ${i%.in}
done
)
find src/ -name '*-name.gperf' -print -delete
find src/ \( -name '*-to-name.h' -o -name '*-from-name.h' \) -print -delete
sed -i \
-e '/^After=/s|$| local-fs.target|g' \
-e '/^ExecStart/s| start||g' \
units/rc-local.service.in || exit 1
sed -i -e '/^exec_prefix=/s|=.*$|=/|g' \
src/libudev/libudev.pc.in || exit 1
sed -i -e '/udevadm/s|@rootbindir@|/sbin|g' \
src/login/71-seat.rules.in \
units/systemd-udev-settle.service.in \
units/systemd-udev-trigger.service.in || exit 1
# Slackware file is upper case
sed -i -e 's|/etc/hostname|/etc/HOSTNAME|g' \
src/hostname/hostnamed.c src/core/hostname-setup.c src/firstboot/firstboot.c \
man/{hostname,machine-info}.xml man/hostnamectl.xml || exit 1
mkdir -p ${PKG}/lib/udev/rules.d
mkdir -p ${PKG}/run
find . -name "*.[1-8]" -exec touch '{}' ';'
cp -pf ${CWD}/systemd-user.m4 src/login/
if [ ! -r configure ] || [ "${SB_AUTOGEN}" = "YES" ] ;then
sh autogen.sh || exit $?
fi
unset SB_PAMOPTS SB_QROPTS
[ "${SB_PAM}" = "YES" ] || SB_PAMOPTS='--disable-pam'
[ "${SB_QR}" = "YES" ] || SB_QROPTS='--disable-qrencode'
CFLAGS="${SLKCFLAGS}" \
CXXFLAGS="${SLKCFLAGS}" \
CPPFLAGS+=" $(pkg-config --cflags-only-I liblz4)" \
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--libexecdir=/lib \
--with-rootprefix= \
--with-rootlibdir=/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--localstatedir=/var \
--infodir=/usr/info \
--mandir=/usr/man \
--docdir=/usr/doc/${NAME}-${VERSION} \
--disable-silent-rules \
--disable-dependency-tracking \
--enable-split-usr \
--enable-lz4 \
${SB_PAMOPTS} \
--disable-audit \
--disable-selinux \
--with-default-dnssec=no \
--without-kill-user-processes \
--with-sysvinit-path="" \
--with-sysvrcnd-path="" \
--with-rc-local-script-path-start=/etc/rc.d/rc.local \
--with-rc-local-script-path-stop=/etc/rc.d/rc.local_shutdown \
--with-certificate-root=${SB_CABDIR} \
--with-ntp-servers="${SB_NTPPOOLLST[*]}" \
${SB_QROPTS} \
--build=${SLKTARGET}-${SLKDTARGET}-linux || exit $?
export GCC_COLORS=""
make units/rc-local.service units/halt-local.service || exit $?
make -j${NJOBS} || make || exit $?
make install DESTDIR=${PKG} \
pkgconfigdatadir=/usr/lib${LIBDIRSUFFIX}/pkgconfig \
sharepkgconfigdir=/usr/lib${LIBDIRSUFFIX}/pkgconfig \
|| exit $?
[ "${SB_RMLA}" = "YES" ] && find ${PKG} -name '*.la' -exec rm {} ';'
rm -rf ${PKG}/etc/init.d
rm -rf ${PKG}/etc/rc.d/init.d
rmdir -p ${PKG}/lib${LIBDIRSUFFIX}/security
rmdir -p ${PKG}/usr/lib${LIBDIRSUFFIX}/security
# Good to have on path
mkdir -p ${PKG}/sbin
( cd ${PKG}/sbin
ln -s ../lib/udev/scsi_id scsi_id || exit 1
ln -s ../lib/systemd/systemd-udevd udevd || exit 1
) || exit 1
mv ${PKG}/bin/udevadm ${PKG}/sbin/ || exit 1
ln -s ../sbin/udevadm ${PKG}/bin/udevadm
ln -s ../systemd/systemd-udevd ${PKG}/lib/udev/udevd || exit 1
find ${PKG} | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
################################### systemd ####################################
# rc.local and rc.local_shutdown
install -pm0644 units/rc-local.service \
${PKG}/lib/systemd/system/rc-local.service || exit 1
install -pm0644 units/halt-local.service \
${PKG}/lib/systemd/system/halt-local.service || exit 1
ln -s ../rc-local.service \
${PKG}/lib/systemd/system/multi-user.target.wants/rc-local.service || exit 1
ln -s ../halt-local.service \
${PKG}/lib/systemd/system/multi-user.target.wants/halt-local.service || exit 1
install -pm0644 tmpfiles.d/legacy.conf ${PKG}/usr/lib/tmpfiles.d/ || exit 1
# Put this here for the time
mkdir -p ${PKG}/etc/rc.d
cat > ${PKG}/etc/rc.d/rc.local_shutdown.new <<'EOF'
#!/bin/sh
exit 0
EOF
chmod 0755 ${PKG}/etc/rc.d/rc.local_shutdown.new || exit 1
mv ${PKG}/lib/systemd/systemd ${PKG}/lib/systemd/systemd.new || exit 1
chmod 0755 ${PKG}/lib/systemd/systemd.new
ln -sf ../lib/systemd/systemd ${PKG}/bin/systemd || exit 1
if [ "${SB_DEF}" = "YES" ] ;then
mkdir -p ${PKG}/sbin
ln -s ../lib/systemd/systemd ${PKG}/sbin/init
ln -s ../bin/systemctl ${PKG}/sbin/reboot
ln -s ../bin/systemctl ${PKG}/sbin/halt
ln -s ../bin/systemctl ${PKG}/sbin/poweroff
ln -s ../bin/systemctl ${PKG}/sbin/shutdown
ln -s ../bin/systemctl ${PKG}/sbin/telinit
ln -s ../bin/systemctl ${PKG}/sbin/runlevel
else
for manpage in telinit halt reboot poweroff runlevel shutdown; do
mv ${PKG}/usr/man/man8/{,systemd.}"${manpage}.8" || exit 1
done
install -pm0644 ${CWD}/var-{lock,run}.mount ${PKG}/lib/systemd/system/ || exit 1
ln -sf ../var-lock.mount \
${PKG}/lib/systemd/system/local-fs.target.wants/var-lock.mount || exit 1
ln -sf ../var-run.mount \
${PKG}/lib/systemd/system/local-fs.target.wants/var-run.mount || exit 1
fi
if [ "${SB_PAM}" = "YES" ] ; then
mv ${PKG}/etc/pam.d/systemd-user ${PKG}/etc/pam.d/systemd-user.new || exit 1
else
rm -f ${PKG}/usr/man/man8/pam*
echo 'd /run/console 755 root root -' > ${PKG}/usr/lib/tmpfiles.d/console.conf || exit 1
fi
# We create all wants links manually at installation time to make sure
# they are not owned and hence overriden by package after the used deleted
# them.
rm -rf ${PKG}/etc/systemd/system/*.target.wants/*
#touch ${PKG}/etc/hostname.new
touch ${PKG}/etc/vconsole.conf.new
touch ${PKG}/etc/locale.conf.new
touch ${PKG}/etc/machine-id.new
touch ${PKG}/etc/machine-info.new
rm -f ${PKG}/etc/systemd/system/default.target
rm -f ${PKG}/lib/systemd/system/default.target
ln -sf multi-user.target ${PKG}/lib/systemd/system/default.target
mkdir -p ${PKG}/etc/X11/xorg.conf.d
touch ${PKG}/etc/X11/xorg.conf.d/00-keyboard.conf.new
mkdir -p ${PKG}/{etc,lib}/systemd/system-preset
mkdir -p ${PKG}/{etc,lib}/systemd/user-preset
mkdir -p ${PKG}/{etc,lib}/systemd/network
# Make sure the shutdown/sleep drop-in dirs exist
mkdir -p ${PKG}/lib/systemd/system-shutdown/
mkdir -p ${PKG}/lib/systemd/system-sleep/
# Make sure directories in /var exist
mkdir -p ${PKG}/var/lib/systemd/coredump
mkdir -p ${PKG}/var/lib/systemd/catalog
mkdir -p ${PKG}/var/log/journal/{remote,upload}
touch ${PKG}/var/lib/systemd/catalog/database.new
touch ${PKG}/etc/udev/hwdb.bin
# Make sure these directories are properly owned
mkdir -p ${PKG}/lib/systemd/system/basic.target.wants
mkdir -p ${PKG}/lib/systemd/system/default.target.wants
mkdir -p ${PKG}/lib/systemd/system/dbus.target.wants
mkdir -p ${PKG}/lib/systemd/system/syslog.target.wants
# Make sure the user generators dir exists too
mkdir -p ${PKG}/lib/systemd/system-generators
mkdir -p ${PKG}/lib/systemd/user-generators
# Make sure directories in /var exist
mkdir -p ${PKG}/var/lib/systemd/coredump
mkdir -p ${PKG}/var/lib/systemd/catalog
mkdir -p ${PKG}/var/lib/systemd/backlight
mkdir -p ${PKG}/var/lib/systemd/rfkill
mkdir -p ${PKG}/var/lib/systemd/journal-upload
mkdir -p ${PKG}/var/log/journal
touch ${PKG}/var/lib/systemd/catalog/database.new
touch ${PKG}/etc/udev/hwdb.bin.new
touch ${PKG}/var/lib/systemd/random-seed.new
touch ${PKG}/var/lib/systemd/clock.new
for file in journald journal-remote journal-upload logind resolved system timesyncd user ;do
mv ${PKG}/etc/systemd/${file}.conf ${PKG}/etc/systemd/${file}.conf.new || exit 1
done
rm -f ${PKG}/usr/lib/sysctl.d/50-coredump.conf
mkdir -p ${PKG}/usr/lib/firewalld/services
install -pm0644 ${CWD}/config/firewalld/*.xml \
${PKG}/usr/lib/firewalld/services/ || exit 1
mkdir -p ${PKG}/lib/systemd/system/systemd-udev-trigger.service.d
cat > ${PKG}/lib/systemd/system/systemd-udev-trigger.service.d/systemd-udev-trigger-no-reload.conf <<'EOF'
[Unit]
# https://bugzilla.redhat.com/show_bug.cgi?id=1378974#c17
RefuseManualStop=true
EOF
################################ End of systemd ################################
##################################### udev #####################################
mkdir -p ${PKG}/etc/udev/{keymaps,rules.d} \
${PKG}/lib/firmware \
${PKG}/lib/modprobe.d \
${PKG}/etc/modprobe.d \
${PKG}/etc/rc.d
rm -f ${PKG}/etc/udev/udev.conf
install -m0644 ${CWD}/config/udev.conf ${PKG}/etc/udev/udev.conf || exit 1
# Copy Slackware custom rules
install -m0644 ${CWD}/config/rules.d/* ${PKG}/lib/udev/rules.d/ || exit 1
install -m0755 ${CWD}/config/rc.d/rc.udev.new \
${PKG}/etc/rc.d/rc.udev.new || exit 1
for file in ${CWD}/config/modprobe.d/*.conf ;do
install -m0644 ${file} \
${PKG}/lib/modprobe.d/ || exit 1
done
install -pm0644 ${CWD}/config/modprobe.d/README ${PKG}/etc/modprobe.d/ || exit 1
# Add various helper scripts:
for file in ${CWD}/config/scripts/* ; do
install -m0755 ${file} ${PKG}/lib/udev/ || exit 1
done
chmod 755 ${PKG}/lib/udev/*
################################# End of udev ##################################
# Add a documentation directory:
mkdir -p ${DOCDIR}
cp -a \
AUTHORS COPYING LICENSE README NEWS THANKS TODO ${CWD}/ChangeLog.SB \
${CWD}/config/polkit/51-noshutdown.rules ${DOCDIR}/
[ -r ChangeLog ] && head -n 1000 ChangeLog > ${DOCDIR}/ChangeLog
find ${DOCDIR}/ -type d -print0 | xargs -0 chmod 0755
find ${DOCDIR}/ -type f -print0 | xargs -0 chmod 0644
find ${DOCDIR}/ -type f -size 0 -print0 | xargs -0 rm -f
# Compress and link manpages, if any:
if [ -d ${PKG}/usr/share/man ]; then
mv ${PKG}/usr/share/man ${PKG}/usr/man
rmdir ${PKG}/usr/share
fi
if [ -d ${PKG}/usr/man ]; then
( cd ${PKG}/usr/man
for manpagedir in $(find . -type d -name "man*") ; do
( cd ${manpagedir}
for eachpage in $( find . -type l -maxdepth 1) ; do
ln -s $( readlink ${eachpage} ).gz ${eachpage}.gz
rm -f ${eachpage}
done
gzip -9 *.?
# Prevent errors
rm -f *.gz.gz
)
done
)
fi
mkdir -p ${PKG}/install
cat ${CWD}/slack-desc > ${PKG}/install/slack-desc
cat ${CWD}/slack-required > ${PKG}/install/slack-required
cat > ${PKG}/install/doinst.sh <<EOF
# Figure out our root directory
ROOTDIR=\$(pwd)
unset CHROOT
if test "\${ROOTDIR}" != "/"; then
CHROOT="chroot \${ROOTDIR} "
ROOTDIR="\${ROOTDIR}/"
fi
config() {
NEW="\$1"
OLD="\$(dirname \$NEW)/\$(basename \$NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r \$OLD ]; then
mv \$NEW \$OLD
elif [ "\$(cat \$OLD | md5sum)" = "\$(cat \$NEW | md5sum)" ]; then
# toss the redundant copy
rm \$NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
# Keep same perms on rc.udev.new:
if [ -r etc/rc.d/rc.udev -a -r etc/rc.d/rc.udev.new ]; then
chmod --reference=etc/rc.d/rc.udev etc/rc.d/rc.udev.new
fi
## List of conf files to check. The conf files in your package should end in .new
EOF
( cd ${PKG}
find etc/ var/ -name '*.new' -exec echo config {} ';' | sort >> ${PKG}/install/doinst.sh
find etc/ var/ -name '*.new' -a -size 0 -exec echo rm -f {} ';' | sort >> ${PKG}/install/doinst.sh
echo >> ${PKG}/install/doinst.sh
)
cat >> ${PKG}/install/doinst.sh <<'EOF'
function free_user_id {
# Find a free user-ID >= 100 (should be < 1000 so it's not a normal user)
local FREE_USER_ID=100
while grep --quiet "^.*:.*:${FREE_USER_ID}:.*:.*:.*:" etc/passwd; do
let FREE_USER_ID++
done
echo ${FREE_USER_ID}
}
function free_group_id {
# Find a free group-ID >= 120 (should be < 1000 so it's not a normal group)
local FREE_GROUP_ID=120
while grep --quiet "^.*:.*:${FREE_GROUP_ID}:" etc/group; do
let FREE_GROUP_ID++
done
echo ${FREE_GROUP_ID}
}
# Set up groups.
if ! grep --quiet '^lock:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
lock 2> /dev/null
fi
if ! grep --quiet '^systemd-journal:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-journal 2> /dev/null
fi
if ! grep --quiet '^systemd-journal-gateway:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-journal-gateway 2> /dev/null
fi
if ! grep --quiet '^systemd-journal-remote:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-journal-remote 2> /dev/null
fi
if ! grep --quiet '^systemd-journal-upload:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-journal-upload 2> /dev/null
fi
if ! grep --quiet '^systemd-timesync:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-timesync 2> /dev/null
fi
if ! grep --quiet '^systemd-network:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-network 2> /dev/null
fi
if ! grep --quiet '^systemd-resolve:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-resolve 2> /dev/null
fi
if ! grep --quiet '^systemd-bus-proxy:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
systemd-bus-proxy 2> /dev/null
fi
if ! grep --quiet '^input:' etc/group ;then
${CHROOT} /usr/sbin/groupadd \
-g $(free_group_id) \
input 2> /dev/null
fi
# Set up user: add it if it doesn't exist, update it if it already does.
if OLD_ENTRY=$(grep --max-count=1 '^systemd-journal-gateway:' etc/passwd) \
|| OLD_ENTRY=$(grep --max-count=1 \
':/var/log/journal:[a-z/]*$' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-journal-gateway"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/log/journal' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-journal-gateway \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'Journal Gateway' \
-u $(free_user_id) \
-g systemd-journal-gateway \
-s /bin/false \
-d '/var/log/journal' \
systemd-journal-gateway 2> /dev/null
fi
# Set up user: add it if it doesn't exist, update it if it already does.
if OLD_ENTRY=$(grep --max-count=1 '^systemd-journal-remote:' etc/passwd) \
|| OLD_ENTRY=$(grep --max-count=1 \
':/var/log/journal/remote:[a-z/]*$' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-journal-remote"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/log/journal/remote' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-journal-remote \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'Journal Remote' \
-u $(free_user_id) \
-g systemd-journal-remote \
-s /bin/false \
-d '/var/log/journal/remote' \
systemd-journal-remote 2> /dev/null
fi
# Set up user: add it if it doesn't exist, update it if it already does.
if OLD_ENTRY=$(grep --max-count=1 '^systemd-journal-upload:' etc/passwd) \
|| OLD_ENTRY=$(grep --max-count=1 \
':/var/log/journal/upload:[a-z/]*$' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-journal-upload"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/log/journal/upload' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-journal-upload \
-a -G systemd-journal \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'Journal Upload' \
-u $(free_user_id) \
-g systemd-journal-upload \
-G systemd-journal \
-s /bin/false \
-d '/var/log/journal/upload' \
systemd-journal-upload 2> /dev/null
fi
if OLD_ENTRY=$(grep --max-count=1 '^systemd-timesync:' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-timesync"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/lib/systemd' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-timesync \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'systemd Time Synchronization' \
-u $(free_user_id) \
-g systemd-timesync \
-s /bin/false \
-d '/var/lib/systemd' \
systemd-timesync 2> /dev/null
fi
if OLD_ENTRY=$(grep --max-count=1 '^systemd-network:' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-network"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/lib/systemd' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-network \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'systemd Network Management' \
-u $(free_user_id) \
-g systemd-network \
-s /bin/false \
-d '/var/lib/systemd' \
systemd-network 2> /dev/null
fi
if OLD_ENTRY=$(grep --max-count=1 '^systemd-resolve:' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-resolve"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/lib/systemd' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-resolve \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'systemd Resolver' \
-u $(free_user_id) \
-g systemd-resolve \
-s /bin/false \
-d '/var/lib/systemd' \
systemd-resolve 2> /dev/null
fi
if OLD_ENTRY=$(grep --max-count=1 '^systemd-bus-proxy:' etc/passwd)
then
# Modify existing user
OLD_USER=$(echo ${OLD_ENTRY} | cut --fields=1 --delimiter=':')
USER_ID=$(echo ${OLD_ENTRY} | cut --fields=3 --delimiter=':')
test ${USER_ID} -ge 1000 && USER_ID=$(free_user_id)
if test "${OLD_USER}" = "systemd-bus-proxy"; then
echo -n "Updating unprivileged user" 1>&2
else
echo -ne "Changing unprivileged user \e[1m${OLD_USER}\e[0m to" 1>&2
fi
${CHROOT} /usr/sbin/usermod \
-d '/var/lib/systemd' \
-u ${USER_ID} \
-s /bin/false \
-g systemd-bus-proxy \
${OLD_USER}
else
# Add new user
echo -n "Creating unprivileged user" 1>&2
${CHROOT} /usr/sbin/useradd \
-c 'systemd Bus Proxy' \
-u $(free_user_id) \
-g systemd-bus-proxy \
-s /bin/false \
-d '/var/lib/systemd' \
systemd-bus-proxy 2> /dev/null
fi
enableservice () {
if ! ${CHROOT}/bin/systemctl is-enable "${1}" > /dev/null 2>&1 ;then
${CHROOT} /bin/systemctl enable "${1}" 2>&1
fi
}
if [ -r lib/systemd/systemd ]; then
mv -f lib/systemd/systemd lib/systemd/systemd.old
fi
mv -f lib/systemd/systemd.new lib/systemd/systemd
if [ -f lib/systemd/systemd.old ]; then
rm -f lib/systemd/systemd.old
fi
if [ ! -r etc/systemd/system/syslog.service ] ;then
${CHROOT} /bin/ln -s /lib/systemd/system/rsyslog.service /etc/systemd/system/syslog.service >/dev/null 2>&1 || :
fi
# Remove spurious /etc/fstab entries
sed -i.systemd.bak -r '/^devpts\s+\/dev\/pts\s+devpts\s+defaults\s+/s/^/#/g; /^tmpfs\s+\/dev\/shm\s+tmpfs\s+defaults\s+/s/^/#/g; /^sysfs\s+\/sys\s+sysfs\s+defaults\s+/s/^/#/g; /^proc\s+\/proc\s+proc\s+defaults\s+/s/^/#/g' /etc/fstab >/dev/null 2>&1 || :
enableservice getty@tty1.service || :
enableservice remote-fs.target || :
${CHROOT} /bin/systemd-machine-id-setup > /dev/null 2>&1 || :
${CHROOT} /lib/systemd/systemd-random-seed save >/dev/null 2>&1 || :
${CHROOT} /bin/systemctl daemon-reexec > /dev/null 2>&1 || :
sleep 1
${CHROOT} /bin/systemctl --system daemon-reload >/dev/null 2>&1 || :
${CHROOT} /sbin/udevadm hwdb --update >/dev/null 2>&1 || :
${CHROOT} /bin/journalctl --update-catalog >/dev/null 2>&1 || :
${CHROOT} /bin/systemd-tmpfiles --create >/dev/null 2>&1 || :
# sed-fu to add myhostanme to hosts line
if [ -f /etc/nsswitch.conf ] ; then
# sed-fu to add myhostanme to hosts line
${CHROOT} grep -v -E -q '^hosts:.* myhostname' /etc/nsswitch.conf &&
${CHROOT} sed -i.bak -e '
/^hosts:/ !b
/\<myhostname\>/ b
s/[[:blank:]]*$/ myhostname/
' /etc/nsswitch.conf &>/dev/null
# remove mymachines from passwd and group lines of /etc/nsswitch.conf
# https://bugzilla.redhat.com/show_bug.cgi?id=1284325
# https://meetbot.fedoraproject.org/fedora-meeting/2015-11-25/fesco.2015-11-25-18.00.html
# To avoid the removal, e.g. add a space at the end of the line.
${CHROOT} grep -E -q '^(passwd|group):.* mymachines$' /etc/nsswitch.conf &&
${CHROOT} sed -i.bak -r -e '
s/^(passwd:.*) mymachines$/\1/;
s/^(group:.*) mymachines$/\1/;
' /etc/nsswitch.conf &>/dev/null
# Add [!UNAVAIL=return] after resolve
${CHROOT} grep -E -q '^hosts:.*resolve[[:space:]]*($|[[:alpha:]])' /etc/nsswitch.conf &&
${CHROOT} sed -i.bak -e '
/^hosts:/ { s/resolve/& [!UNAVAIL=return]/}
' /etc/nsswitch.conf &>/dev/null
# Add nss-systemd to passwd and group
${CHROOT} grep -E -q '^(passwd|group):.* systemd' /etc/nsswitch.conf ||
${CHROOT} sed -i.bak -r -e '
s/^(passwd|group):(.*)/\1: \2 systemd/
' /etc/nsswitch.conf &>/dev/null
fi
# Make sure new journal files will be owned by the "systemd-journal" group
${CHROOT} /bin/chgrp systemd-journal /run/log/journal/ >/dev/null 2>&1 || :
${CHROOT} /bin/chgrp systemd-journal /run/log/journal/$(cat /etc/machine-id) >/dev/null 2>&1 || :
${CHROOT} /bin/chgrp systemd-journal /var/log/journal/ >/dev/null 2>&1 || :
${CHROOT} /bin/chgrp systemd-journal /var/log/journal/$(cat /etc/machine-id) >/dev/null 2>&1 || :
${CHROOT} /bin/chown systemd-journal-upload.systemd-journal-upload /var/lib/systemd/journal-upload >/dev/null 2>&1 || :
${CHROOT} /bin/chmod 2755 /var/log/journal/ >/dev/null 2>&1 || :
${CHROOT} /bin/chmod 2755 /var/log/journal/$(cat /etc/machine-id) >/dev/null 2>&1 || :
${CHROOT} /usr/bin/setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/ >/dev/null 2>&1 || :
# Move old stuff around in /var/lib
${CHROOT} mv /var/lib/random-seed /var/lib/systemd/random-seed >/dev/null 2>&1 || :
${CHROOT} mv /var/lib/backlight /var/lib/systemd/backlight >/dev/null 2>&1 || :
if [ -x sbin/update-dracut ] ;then
${CHROOT} /sbin/update-dracut >/dev/null 2>&1
fi
EOF
sed -i "s|_PACKAGER|${PACKAGER}|g; s|_BUILD_DATE|${DATE}|g" \
${PKG}/install/slack-desc
if [ "${SB_REP}" = "YES" ] ;then
# Replicate slackbuild and patches
mkdir -p ${SBDIR}/patches
install -m0644 ${CWD}/slack-desc ${CWD}/slack-required ${CWD}/ChangeLog.SB \
${CWD}/apply-patches.sh ${CWD}/var-*.mount ${CWD}/udev-fixed-devices.tar.gz \
${CWD}/*.m4 ${SBDIR}/
install -m0755 ${CWD}/${NAME}.SlackBuild \
${SBDIR}/${NAME}.SlackBuild
install -m0644 ${CWD}/config/*.conf ${SBDIR}/config/
for dir in firewalld modprobe.d polkit rc.d rules.d scripts ;do
mkdir -p ${SBDIR}/config/${dir}
install -m0644 ${CWD}/config/${dir}/* ${SBDIR}/config/${dir}/
done
install -m0644 ${CWD}/patches/*.* \
${SBDIR}/patches/
rmdir ${SBDIR}/patches
fi
# Build package:
set +o xtrace # no longer print commands upon execution
set -e
ROOTCOMMANDS="set -o errexit -o xtrace ; cd ${PKG} ;
tar xvf ${CWD}/udev-fixed-devices.tar.gz -C ./ ;
/bin/chown --recursive root:root . ;
[ \"${SB_HGROUP}\" = 1 ] && /bin/chgrp systemd-journal ./var/log/journal/ ;
[ \"${SB_HGROUP}\" = 1 ] && /bin/chmod 2755 ./var/log/journal/ ;
[ \"${SB_UHGROUP}\" = 1 ] && [ \"${SB_UHUSER}\" = 1 ] && /bin/chown systemd-journal-upload.systemd-journal-upload ./var/lib/systemd/journal-upload ; "
ROOTCOMMANDS="${ROOTCOMMANDS}
/sbin/makepkg --prepend --linkadd y --chown n ${PKGDEST}/${PKGNAME}.${PKGFORMAT} "
if test ${UID} = 0; then
eval ${ROOTCOMMANDS}
set +o xtrace
elif test "$(type -t fakeroot)" = 'file'; then
echo -e "\e[1mEntering fakeroot environment.\e[0m"
echo ${ROOTCOMMANDS} | fakeroot
else
echo -e "\e[1mPlease preferably install fakeroot or run as root.\e[0m"
exit 5
fi
# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
echo "Cleaning..."
if [ -d ${TMP}/${SRCDIR} ]; then
rm -rf ${TMP}/${SRCDIR} && echo "${TMP}/${SRCDIR} cleanup completed"
fi
if [ -d ${PKG} ]; then
rm -rf ${PKG} && echo "${PKG} cleanup completed"
fi
rmdir ${TMP} && echo "${TMP} cleanup completed"
fi
exit 0