-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2slackware2sb
77 lines (72 loc) · 3.63 KB
/
2slackware2sb
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
#!/bin/bash
#
# Author: simargl <https://github.com/simargl>
# License: GPL v3
STARTDIR="/tmp"
OUTPUTDIR="/tmp/output"
SCRIPTSDIR="$PWD/scripts/slackware"
fn_download_and_extract() {
install -Dm755 $SCRIPTSDIR/{crux2slack,fetch} /usr/bin/
cp $SCRIPTSDIR/{part1,part2,part3} $STARTDIR
if [[ $1 != "-c" ]]; then cp $SCRIPTSDIR/part4 $STARTDIR; fi
cd $STARTDIR
if [ -d root.x86_64 ]; then rm -r root.x86_64; fi
rm *.t?z 2>/dev/null
fetch up; fetch cc; fetch dl $(cat part1 | tr '\n' ' ')
mv /var/cache/slackware/* .; fetch xa; mv install root.x86_64
rm *.t?z 2>/dev/null
}
fn_build_rootfs() {
# prepare
cd $STARTDIR
cp /etc/resolv.conf root.x86_64/etc/
cp /usr/bin/{crux2slack,fetch} $STARTDIR/root.x86_64/usr/bin/
mknod -m 666 root.x86_64/dev/null c 1 3
chroot $STARTDIR/root.x86_64/ /bin/bash -c "fetch up"
chroot $STARTDIR/root.x86_64/ /bin/bash -c "fetch it $(cat $STARTDIR/part2 | tr '\n' ' '); fetch cc"
chroot $STARTDIR/root.x86_64/ /bin/bash -c "fetch it $(cat $STARTDIR/part3 | tr '\n' ' '); fetch cc"
if [[ $1 != "-c" ]]; then
chroot $STARTDIR/root.x86_64/ /bin/bash -c "fetch it $(cat $STARTDIR/part4 | tr '\n' ' '); fetch cc"
fi
chroot $STARTDIR/root.x86_64/ /bin/bash -c "update-ca-certificates -f"
# cache
rm -r $STARTDIR/root.x86_64/usr/share/mime/globs
rm -r $STARTDIR/root.x86_64/usr/share/icons/hicolor/icon-theme.cache
rm -r $STARTDIR/root.x86_64/usr/share/glib-2.0/schemas/gschemas.compiled
rm -r $STARTDIR/root.x86_64/usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders.cache
# other
rm -r $STARTDIR/root.x86_64/usr/{doc,info,man}
rm -r $STARTDIR/root.x86_64/usr/share/{gtk-doc,locale}
rm -r $STARTDIR/root.x86_64/etc/asound.conf
find $STARTDIR/root.x86_64/usr/share/applications -type f -not -name transmission-gtk.desktop | xargs rm
install -Dm644 $SCRIPTSDIR/fetch-gui.desktop $STARTDIR/root.x86_64/usr/share/applications/
install -Dm755 $SCRIPTSDIR/fetch-gui.py $STARTDIR/root.x86_64/usr/bin/
# static libs
find $STARTDIR/root.x86_64/usr/lib64 -maxdepth 2 -name *.a -not -name libanl.a \
-not -name libc.a -not -name libc_nonshared.a -not -name libcrypt.a -not -name libdl.a \
-not -name libg.a -not -name libm.a -not -name libpthread.a -not -name libresolv.a \
-not -name librt.a -not -name libutil.a -not -name libfltk* | xargs rm
# clang
rm -r $STARTDIR/root.x86_64/usr/bin/{c-index-test,clang*,llvm*,obj2yaml,mlir*}
rm -r $STARTDIR/root.x86_64/usr/include/clang*
rm -r $STARTDIR/root.x86_64/usr/lib64/{libclang*,libMLIR*,clang}
# more removal
rm -r $STARTDIR/root.x86_64/usr/share/{doc,libwacom,samba,vulkan}
rm -r $STARTDIR/root.x86_64/usr/lib64/{d3d,gallium-pipe,libdxcompiler.so,libRusticl*,libVkLayer*,liblldb*}
rm -r $STARTDIR/root.x86_64/usr/libexec/samba
rm -r $STARTDIR/root.x86_64/usr/bin/{smbtorture,gfxrecon*,dwp,gtk3-demo*}
chroot /tmp/root.x86_64 /bin/bash -c 'find /usr/bin -type f -exec sh -c '\''if ldd "$1" 2>&1 | grep -q "not found"; then rm "$1"; fi'\'' _ {} \;'
chroot /tmp/root.x86_64 /bin/bash -c 'find /usr/libexec -type f -exec sh -c '\''if ldd "$1" 2>&1 | grep -q "not found"; then rm "$1"; fi'\'' _ {} \;'
# python cleanup
find $STARTDIR/root.x86_64 -type f -name "*.pyc" -delete
find $STARTDIR/root.x86_64 -type f -name "*.pyo" -delete
}
fn_compress_rootfs() {
cd $STARTDIR
if [ ! -d $OUTPUTDIR ]; then mkdir -p $OUTPUTDIR; fi
if [ -f $OUTPUTDIR/fs-slackware.sb ]; then rm $OUTPUTDIR/fs-slackware.sb; fi
mksquashfs root.x86_64/ $OUTPUTDIR/fs-slackware.sb -comp gzip -b 1024k
}
fn_download_and_extract $@
fn_build_rootfs $@
fn_compress_rootfs