summaryrefslogtreecommitdiff
path: root/create_gcc-lib_shim.sh
blob: 70e4d9c381963faed6030f194a3e002f22ce11aa (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
#!/bin/sh

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

# the gcc-lib shim

if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/gcc-libs-shim-7.2.0-1-$TARGET_CPU.pkg.tar.xz; then

	cd $STAGE1_BUILD || exit 1
	sudo rm -rf gcc-libs-shim
	mkdir gcc-libs-shim
	cd gcc-libs-shim || exit 1
	mkdir -p pkg/gcc-libs-shim/usr/lib
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libgcc_s.so pkg/gcc-libs-shim/usr/lib/.
	cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/lib/libgcc_s.so.1 pkg/gcc-libs-shim/usr/lib/.
	cp -L $XTOOLS_ARCH/$TARGET_ARCH/lib/libatomic.so.1.2.0 pkg/gcc-libs-shim/usr/lib/.
	ln -s libatomic.so.1.2.0 pkg/gcc-libs-shim/usr/lib/libatomic.so.1
	ln -s libatomic.so.1.2.0 pkg/gcc-libs-shim/usr/lib/libatomic.so
	cp -L $XTOOLS_ARCH/$TARGET_ARCH/lib/libatomic.a pkg/gcc-libs-shim/usr/lib/.
	cp -L $XTOOLS_ARCH/$TARGET_ARCH/lib/libstdc++.so.6.0.24 pkg/gcc-libs-shim/usr/lib/.
	ln -s libstdc++.so.6.0.24 pkg/gcc-libs-shim/usr/lib/libstdc++.so.6
	ln -s libstdc++.so.6.0.24 pkg/gcc-libs-shim/usr/lib/libstdc++.so

	BUILDDATE=$(date '+%s')
	size=$(du -sk --apparent-size pkg/)
	size="$(( ${size%%[^0-9]*} * 1024 ))"
	cat > pkg/gcc-libs-shim/.PKGINFO <<EOF
pkgname = gcc-libs
pkgver = 4.9.4-1
pkgdesc = Runtime libraries shipped by GCC (from crosstool-ng sysroot)
url = http://gcc.gnu.org
builddate = $BUILDDATE
size = $size
arch = $TARGET_CPU
EOF

	cd pkg/gcc-libs-shim || exit 1
	# shellcheck disable=SC2035
	tar cJvf - .PKGINFO * | xz > ../../gcc-libs-shim-7.2.0-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 -R $STAGE1_CHROOT/packages/$TARGET_CPU/temp.db.tar.gz $STAGE1_CHROOT/packages/$TARGET_CPU/*pkg.tar.xz
	sudo pacman --noconfirm --config $STAGE1_CHROOT/etc/pacman.conf -r $STAGE1_CHROOT -Syy gcc-libs
fi

echo "gcc-lib shim exists."