summaryrefslogtreecommitdiff
path: root/create_glibc_shim.sh
blob: ac0c7d9c6d3ff18bf92cca52449f1905681de8ca (plain)
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
#!/bin/sh

# shellcheck source=./default.conf
. "./default.conf"

# the glibc-shim shim

if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/glibc-shim-2.26-1-$TARGET_CPU.pkg.tar.xz; then

	cd $STAGE1_BUILD || exit 1
	sudo rm -rf glibc-shim
	mkdir glibc-shim
	cd glibc-shim || exit 1
	mkdir -p pkg/glibc-shim/usr/include
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/include/* pkg/glibc-shim/usr/include
	for dir in linux misc mtd rdma scsi sound video xen asm asm-generic; do
		sudo rm -rf pkg/glibc-shim/usr/include/$dir
	done
	mkdir -p pkg/glibc-shim/etc
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/etc/rpc pkg/glibc-shim/etc/.
	mkdir -p pkg/glibc-shim/usr/bin
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/bin/* pkg/glibc-shim/usr/bin/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/sbin/* pkg/glibc-shim/usr/bin/.
	mkdir -p pkg/glibc-shim/usr/lib
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/lib/*.o pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/lib/*.a pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/lib/*.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/ld-linux.so.2 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/ld-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libc.so.6 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libc-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libpthread.so.0 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libpthread-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/lib/gconv pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libutil.so* pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libutil-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libanl.so.1 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libanl-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libBrokenLocale.so.1 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libBrokenLocale-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libcrypt.so.1 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libcrypt-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libdl.so.2 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libdl-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libm.so.6 pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libm-2.26.so pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libnsl* pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libnss* pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libresolv* pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/librt* pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libthread_db* pkg/glibc-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/lib/audit pkg/glibc-shim/usr/lib/.
	mkdir -p pkg/glibc-shim/usr/share
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/share/i18n pkg/glibc-shim/usr/share/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/share/locale pkg/glibc-shim/usr/share/.

	BUILDDATE=$(date '+%s')
	size=$(du -sk --apparent-size pkg/)
	size="$(( ${size%%[^0-9]*} * 1024 ))"
	cat > pkg/glibc-shim/.PKGINFO <<EOF
pkgname = glibc
pkgver = 2.26-1
pkgdesc = GNU C Library (from crosstool-ng sysroot)
url = http://www.gnu.org/software/libc
builddate = $BUILDDATE
size = $size
arch = $TARGET_CPU
EOF

	cd pkg/glibc-shim || exit 1
	# shellcheck disable=SC2035	
	tar cJvf - .PKGINFO * | xz > ../../glibc-shim-2.26-1-$TARGET_CPU.pkg.tar.xz
	cd ../.. || exit 1

	cp -v ./*.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/.
	rm -rf $STAGE1_CHROOT/var/cache/pacman/pkg/*
	rm -rf  $STAGE1_CHROOT/packages/$TARGET_CPU/temp.db*
	rm -rf  $STAGE1_CHROOT/packages/$TARGET_CPU/temp.files*
	repo-add $STAGE1_CHROOT/packages/$TARGET_CPU/temp.db.tar.gz $STAGE1_CHROOT/packages/$TARGET_CPU/*pkg.tar.xz
	sudo pacman --force --noconfirm --config $STAGE1_CHROOT/etc/pacman.conf -r $STAGE1_CHROOT -Syy glibc

fi

echo "glibc shim exists."