aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/APKBUILD
blob: 255c4fb75cf03eba7914efa40936014d639a58fb (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
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
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.16
pkgrel=3
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
license="MIT"
depends=""
depends_dev="!uclibc-dev"
options="toolchain"
makedepends="$depends_dev"
subpackages="$pkgname-dev $pkgname-dbg libc6-compat:compat:noarch"
case "$BOOTSTRAP" in
nocc)	pkgname="musl-dev"; subpackages="";;
nolibc) ;;
*)	subpackages="$subpackages $pkgname-utils";;
esac
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
	0001-fix-strftime-y-for-negative-years.patch
	0002-make-globfree-safe-after-failed-glob-from-over-lengt.patch
	0003-reduce-impact-of-REG_-namespace-pollution-in-x86-_64.patch
	0004-fix-getopt-_long-clobbering-of-optopt-on-success.patch
	0005-treat-base-1-as-an-error-in-strtol-family-functions.patch
	0006-fix-crash-from-corrupted-tls-module-list-after-faile.patch
	0007-add-s390x-dlsym.patch

	ldconfig
	__stack_chk_fail_local.c
	getconf.c
	getent.c
	iconv.c
	"

# secfixes:
#   1.1.15-r4:
#     - CVE-2016-8859

builddir="$srcdir"/musl-$pkgver

build() {
	cd "$builddir"

	[ "$BOOTSTRAP" == "nocc" ] && return 0

	# provide minimal libssp_nonshared.a so we don't need libssp from gcc
	${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS -c "$srcdir"/__stack_chk_fail_local.c -o __stack_chk_fail_local.o || return 1
	${CROSS_COMPILE}ar r libssp_nonshared.a __stack_chk_fail_local.o || return 1

	if [ "$BOOTSTRAP" != "nolibc" ]; then
		# getconf/getent/iconv
		local i
		for i in getconf getent iconv ; do
			${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS "$srcdir"/$i.c -o $i || return 1
		done
	fi

	# note: not autotools
	LDFLAGS="$LDFLAGS -Wl,-soname,libc.musl-${CARCH}.so.1" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		|| return 1
	make || return 1
}

package() {
	cd "$builddir"

	if [ "$BOOTSTRAP" == "nocc" ]; then
		case "$CARCH" in
		aarch64*)	ARCH="aarch64" ;;
		arm*)		ARCH="arm" ;;
		x86)		ARCH="i386" ;;
		x86_64)		ARCH="x86_64" ;;
		ppc)		ARCH="powerpc" ;;
		ppc64*)		ARCH="powerpc64" ;;
		s390*)		ARCH="s390x" ;;
		mips*)		ARCH="mips" ;;
		esac

		make ARCH="$ARCH" prefix=/usr DESTDIR="$pkgdir" install-headers || return 1
	else
		make DESTDIR="$pkgdir" install || return 1

		cp libssp_nonshared.a "$pkgdir"/usr/lib || return 1

		# make LDSO the be the real file, and libc the symlink
		local LDSO=$(make -f Makefile --eval "$(echo -e 'print-ldso:\n\t@echo $$(basename $(LDSO_PATHNAME))')" print-ldso)
		mv -f "$pkgdir"/usr/lib/libc.so "$pkgdir"/lib/"$LDSO" || return 1
		ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-${CARCH}.so.1 || return 1
		ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/lib/libc.so || return 1
		mkdir -p "$pkgdir"/usr/bin || return 1
		ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/bin/ldd || return 1
	fi

	# remove libintl.h, currently we don't want by default any NLS
	# and use GNU gettext where needed. the plan is to migrate to
	# musl gettext() later on as fully as possible.
	rm "$pkgdir"/usr/include/libintl.h || return 1
}

utils() {
	depends="!uclibc-utils scanelf"
	replaces="libiconv uclibc-utils"
	license="MIT BSD GPL2+"

	mkdir -p "$subpkgdir"/usr "$subpkgdir"/sbin
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/ || return 1

	install -D \
		"$builddir"/getent \
		"$builddir"/getconf \
		"$builddir"/iconv \
		"$subpkgdir"/usr/bin

	install -D -m755 "$srcdir"/ldconfig "$subpkgdir"/sbin
}

compat() {
	pkgdesc="compatibility libraries for glibc"

	mkdir -p "$subpkgdir"/lib
	case "$CARCH" in
	arm*) _ld="ld-linux-armhf.so.3" ;;
	x86) _ld="ld-linux.so.2" ;;
	x86_64) _ld="ld-linux-x86-64.so.2"
		# go precompiled binary uses /lib64/ld-linux-x86-64.so.2
		# so we add a symlink
		ln -s lib "$subpkgdir"/lib64
		;;
	mips* | s390*) _ld="ld.so.1" ;;
	esac
	ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/lib/$_ld"

	for i in libc.so.6 libcrypt.so.1 libm.so.6 libpthread.so.0 librt.so.1 libutil.so.1; do
		ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/lib/$i"
	done
}

sha512sums="47c00e50b7605102fb4aebe1f9ba9db94d26fac64805f6d744c9c557a05b8a58dff7f9558ff7c8d66b5d7c43740cdc2dd79448bacac47f1414e6ada99c210140  musl-1.1.16.tar.gz
74e95ab3a74513e7a0513e004c376d4055eca0e21162e717dfcab249302a9060d3ac3eb88b562dea14b71b475b4dd2f703e355e2f5050b58891a848c5093c5f6  0001-fix-strftime-y-for-negative-years.patch
04805970e7dc11f84a86df49688f3b7670933860192e99637e189494c261e49b3cce1d80019d69341452062df03d5a349450015076c947296ac4a0d40e5789f4  0002-make-globfree-safe-after-failed-glob-from-over-lengt.patch
61a4f48055aa88cb5f40dd1ea9cc032e372896d7be530f25f17edba3d01706c233bf58a79bddf8952fb6b5d1481f04fac6dd619f4609251874f5a2e1f668f4a0  0003-reduce-impact-of-REG_-namespace-pollution-in-x86-_64.patch
ea103de2721926111510116dedb10e2320715fd20563a342c1dd30f3d1e68049990924b2cf4d03fd9d481ae9488f0e49da5373a79bcec4a8d8c357c64a24751b  0004-fix-getopt-_long-clobbering-of-optopt-on-success.patch
df96c4bd5ff9c197c8aa599948b69716587837de0f298d3adec56077b073e71a49a3c3345e0508cf8a4ed636e3171495bbbdc35435bd8e343c546436f6348359  0005-treat-base-1-as-an-error-in-strtol-family-functions.patch
4dc5cdcab11dee6b62fcb81401a816341e1d802a99e46b072c51575a2c25933354540fe22ae06dcdc85eb9a3cbf7256e7c43aab0e75843846551f9e18bfc39c2  0006-fix-crash-from-corrupted-tls-module-list-after-faile.patch
39eaf56fe30c7098c75c09567a0d990b90c1017c1c2c160017b2d5f41e6503a23d21c7b20bad0186cf3e6fec9fa28ab4f7d655a8382140186c96302f262379fe  0007-add-s390x-dlsym.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f  ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b  __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d  getconf.c
378d70e65bcc65bb4e1415354cecfa54b0c1146dfb24474b69e418cdbf7ad730472cd09f6f103e1c99ba6c324c9560bccdf287f5889bbc3ef0bdf0e08da47413  getent.c
9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf  iconv.c"