summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-08 02:02:24 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-08 02:02:24 -0500
commitfd2bb2f751c13b3c0c002b8e012810902b9da364 (patch)
tree17b2e38c966c9f96cfa568c1f572261a289590e6 /system
parentb0a5136bf3326ba38b360be288d06f9a27f2a4d2 (diff)
downloadpackages-fd2bb2f751c13b3c0c002b8e012810902b9da364.tar.gz
packages-fd2bb2f751c13b3c0c002b8e012810902b9da364.tar.bz2
packages-fd2bb2f751c13b3c0c002b8e012810902b9da364.tar.xz
packages-fd2bb2f751c13b3c0c002b8e012810902b9da364.zip
harmony -> system
Diffstat (limited to 'system')
-rw-r--r--system/apr-util/APKBUILD64
-rw-r--r--system/attr/APKBUILD75
-rw-r--r--system/attr/fix-decls.patch35
-rw-r--r--system/attr/fix-throw.patch33
-rw-r--r--system/attr/test-runner-musl.patch11
-rw-r--r--system/attr/test-runner-perl.patch11
-rw-r--r--system/autoconf/APKBUILD45
-rw-r--r--system/autoconf/autoconf-2.69-fix-perl-regex.patch11
-rw-r--r--system/boost/APKBUILD145
-rw-r--r--system/boost/boost-1.57.0-python-abi_letters.patch62
-rw-r--r--system/boost/boost-1.57.0-python-libpython_dep.patch13
-rw-r--r--system/boost/dual-python.patch27
-rw-r--r--system/boost/libressl.patch146
-rw-r--r--system/busybox/0001-ash-add-support-for-command_not_found_handle-hook-fu.patch63
-rw-r--r--system/busybox/0001-ash-exec-busybox.static.patch25
-rw-r--r--system/busybox/0002-app-location-for-cpio-vi-and-lspci.patch54
-rw-r--r--system/busybox/0003-udhcpc-set-default-discover-retries-to-5.patch35
-rw-r--r--system/busybox/0004-ping-make-ping-work-without-root-privileges.patch197
-rw-r--r--system/busybox/0005-fbsplash-support-console-switching.patch187
-rw-r--r--system/busybox/0006-fbsplash-support-image-and-bar-alignment-and-positio.patch185
-rw-r--r--system/busybox/0007-depmod-support-generating-kmod-binary-index-files.patch516
-rw-r--r--system/busybox/0008-diff-add-support-for-no-dereference.patch63
-rw-r--r--system/busybox/0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch104
-rw-r--r--system/busybox/0010-udhcpc-Don-t-background-if-n-is-given.patch45
-rw-r--r--system/busybox/0011-testsuite-fix-cpio-tests.patch82
-rw-r--r--system/busybox/0012-microcom-segfault.patch31
-rw-r--r--system/busybox/APKBUILD202
-rw-r--r--system/busybox/acpid.logrotate8
-rw-r--r--system/busybox/bbsuid.c106
-rw-r--r--system/busybox/busybox-extras.post-install4
-rw-r--r--system/busybox/busybox-extras.pre-deinstall9
-rw-r--r--system/busybox/busybox.post-install4
-rw-r--r--system/busybox/busybox.post-upgrade26
-rw-r--r--system/busybox/busybox.trigger20
-rw-r--r--system/busybox/busyboxconfig1138
-rw-r--r--system/busybox/busyboxconfig-extras1114
-rw-r--r--system/busybox/dad.if-up8
-rw-r--r--system/busybox/nologin.c38
-rw-r--r--system/busybox/top-buffer-overflow.patch20
-rw-r--r--system/c-ares/APKBUILD46
-rw-r--r--system/ca-certificates/APKBUILD54
-rw-r--r--system/ca-certificates/ca-certificates.post-deinstall7
-rw-r--r--system/ca-certificates/ca-certificates.trigger3
-rw-r--r--system/check/APKBUILD42
-rw-r--r--system/cmake/APKBUILD59
-rw-r--r--system/coreutils/051_all_coreutils-mangen.patch120
-rw-r--r--system/coreutils/APKBUILD79
-rw-r--r--system/coreutils/coreutils.post-deinstall4
-rw-r--r--system/coreutils/disable-mbrtowc-test.patch10
-rw-r--r--system/coreutils/localename-test-fix.patch34
-rw-r--r--system/coreutils/no-doc.patch22
-rw-r--r--system/coreutils/printf-musl.patch53
-rw-r--r--system/coreutils/seq-write-error.patch45
-rw-r--r--system/coreutils/sort-debug-locale.patch79
-rw-r--r--system/curl/APKBUILD93
-rw-r--r--system/curl/curl-do-bounds-check-using-a-double-comparison.patch32
-rw-r--r--system/diffutils/APKBUILD50
-rw-r--r--system/diffutils/disable-mbrtowc-test.patch10
-rw-r--r--system/ffmpeg/0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch55
-rw-r--r--system/ffmpeg/APKBUILD104
-rw-r--r--system/freetype/0001-Enable-table-validation-modules.patch34
-rw-r--r--system/freetype/0002-Enable-subpixel-rendering.patch25
-rw-r--r--system/freetype/0003-Enable-infinality-subpixel-hinting.patch27
-rw-r--r--system/freetype/0004-Enable-long-PCF-family-names.patch25
-rw-r--r--system/freetype/40-memcpy-fix.patch14
-rw-r--r--system/freetype/APKBUILD59
-rw-r--r--system/freetype/freetype-profile.sh12
-rw-r--r--system/gamin/APKBUILD58
-rw-r--r--system/gamin/fix-deprecated-const.patch56
-rw-r--r--system/gamin/fix-pthread-mutex.patch11
-rw-r--r--system/git/0001-gc-use-s-type-character-for-fscanf.patch33
-rw-r--r--system/git/APKBUILD255
-rw-r--r--system/git/bb-tar.patch8
-rw-r--r--system/git/dont-test-other-encodings.patch193
-rw-r--r--system/git/git-daemon.confd19
-rw-r--r--system/git/git-daemon.initd13
-rw-r--r--system/glib-networking/APKBUILD43
-rw-r--r--system/glib-networking/proxy-test.patch13
-rw-r--r--system/glib/0001-gquark-fix-initialization-with-c-constructors.patch47
-rw-r--r--system/glib/APKBUILD103
-rw-r--r--system/glib/broken-gio-tests.patch100
-rw-r--r--system/glib/fix-spawn.patch22
-rw-r--r--system/glib/glib.trigger16
-rw-r--r--system/glib/i386-fpu-test.patch13
-rw-r--r--system/glib/musl-no-locale.patch55
-rw-r--r--system/glib/ridiculous-strerror-nonconformance.patch11
-rw-r--r--system/glib/thread-test-fix.patch11
-rw-r--r--system/gnutls/APKBUILD74
-rw-r--r--system/gnutls/tests-date-compat.patch12
-rw-r--r--system/gpgme/APKBUILD59
-rw-r--r--system/gpgme/fix-bashism.patch10
-rw-r--r--system/graphviz/0001-clone-nameclash.patch87
-rw-r--r--system/graphviz/APKBUILD120
-rw-r--r--system/graphviz/graphviz.pre-deinstall5
-rw-r--r--system/graphviz/graphviz.trigger3
-rw-r--r--system/gsl/APKBUILD42
-rw-r--r--system/gsl/aarch64-test-failure.patch13
-rw-r--r--system/gsl/dont-disable-deprecated.patch24
-rw-r--r--system/hexchat/APKBUILD61
-rw-r--r--system/hexchat/libressl.patch105
-rw-r--r--system/hexchat/pixdata.patch56
-rw-r--r--system/i3lock/APKBUILD43
-rw-r--r--system/iproute2/APKBUILD59
-rw-r--r--system/iproute2/iproute2.post-install6
-rw-r--r--system/iproute2/musl-fixes.patch214
-rw-r--r--system/jasper/APKBUILD49
-rw-r--r--system/kyua/APKBUILD41
-rw-r--r--system/libbluray/APKBUILD36
-rw-r--r--system/libcanberra/APKBUILD95
-rw-r--r--system/libevent/APKBUILD65
-rw-r--r--system/libevent/dont-test-fallback.patch16
-rw-r--r--system/libevent/fix-test-on-32bit.patch11
-rw-r--r--system/libevent/libressl.patch97
-rw-r--r--system/libevent/py3_dumpevents.patch30
-rw-r--r--system/libevent/py3_rpcgen.patch423
-rw-r--r--system/libexecinfo/10-execinfo.patch64
-rw-r--r--system/libexecinfo/20-define-gnu-source.patch24
-rw-r--r--system/libexecinfo/30-linux-makefile.patch44
-rw-r--r--system/libexecinfo/APKBUILD46
-rw-r--r--system/libffi/APKBUILD57
-rw-r--r--system/libffi/disable-ppc-ldvariant.patch11
-rw-r--r--system/libffi/fix-testsuite-longdouble.patch44
-rw-r--r--system/libffi/gnu-linux-define.patch15
-rw-r--r--system/libffi/pax-dlmmap.patch120
-rw-r--r--system/libgit2/APKBUILD52
-rw-r--r--system/libgit2/build-both-static-dynamic.patch53
-rw-r--r--system/libgit2/libressl.patch12
-rw-r--r--system/libgit2/pkgconfig-do-not-quote-Libs.patch26
-rw-r--r--system/libnih/APKBUILD57
-rw-r--r--system/libnih/disable-broken-test.patch11
-rw-r--r--system/libnih/musl-enomem-message.patch489
-rw-r--r--system/libnih/musl-fix-signals.patch12
-rw-r--r--system/libnih/parse-test-fix.patch11
-rw-r--r--system/libnotify/APKBUILD34
-rw-r--r--system/libsndfile/APKBUILD61
-rw-r--r--system/libsndfile/CVE-2017-12562.patch88
-rw-r--r--system/libsndfile/CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch64
-rw-r--r--system/libsndfile/CVE-2017-8362.patch50
-rw-r--r--system/libsndfile/varargs-32bit.patch11
-rw-r--r--system/libssh2/APKBUILD41
-rw-r--r--system/libtool/APKBUILD55
-rw-r--r--system/libtool/libtool-fix-cross-compile.patch36
-rw-r--r--system/libtool/libtool.patch41
-rw-r--r--system/libvpx/APKBUILD52
-rw-r--r--system/libvpx/libm-pc.patch11
-rw-r--r--system/libxml2/APKBUILD77
-rw-r--r--system/libxml2/libxml2-2.9.4-remove-pyverify_fd.patch12
-rw-r--r--system/libxml2/python-segfault-fix.patch36
-rw-r--r--system/libxslt/APKBUILD40
-rw-r--r--system/lighttpd/APKBUILD116
-rw-r--r--system/lighttpd/char-signedness.patch46
-rw-r--r--system/lighttpd/lighttpd.conf261
-rw-r--r--system/lighttpd/lighttpd.confd12
-rw-r--r--system/lighttpd/lighttpd.initd75
-rw-r--r--system/lighttpd/lighttpd.logrotate15
-rw-r--r--system/lighttpd/lighttpd.pre-install8
l---------system/lighttpd/lighttpd.pre-upgrade1
-rw-r--r--system/lighttpd/mime-types.conf79
-rw-r--r--system/lighttpd/mod_cgi.conf33
-rw-r--r--system/lighttpd/mod_fastcgi.conf17
-rw-r--r--system/lighttpd/mod_fastcgi_fpm.conf16
-rw-r--r--system/linux-pam/APKBUILD91
-rw-r--r--system/linux-pam/base-account.pamd3
-rw-r--r--system/linux-pam/base-auth.pamd5
-rw-r--r--system/linux-pam/base-password.pamd3
-rw-r--r--system/linux-pam/base-session-noninteractive.pamd4
-rw-r--r--system/linux-pam/base-session.pamd4
-rw-r--r--system/linux-pam/fix-compat.patch21
-rw-r--r--system/linux-pam/libpam-fix-build-with-eglibc-2.16.patch10
-rw-r--r--system/linux-pam/musl-fix-pam_exec.patch31
-rw-r--r--system/linux-pam/other.pamd6
-rw-r--r--system/linux-pam/su.pamd6
-rw-r--r--system/lm_sensors/APKBUILD85
-rw-r--r--system/lm_sensors/fancontrol.initd33
-rw-r--r--system/lm_sensors/musl-fix-includes.patch62
-rw-r--r--system/lm_sensors/sensord.confd3
-rw-r--r--system/lm_sensors/sensord.initd33
-rw-r--r--system/lm_sensors/sensors-detect-alpine.patch47
-rw-r--r--system/lm_sensors/sensors.install12
-rw-r--r--system/ltrace/APKBUILD44
-rw-r--r--system/ltrace/aarch-part2.patch1982
-rw-r--r--system/ltrace/aarch64.patch2155
-rw-r--r--system/ltrace/add_ppc64le.patch54
-rw-r--r--system/ltrace/musl.patch153
-rw-r--r--system/mlt/APKBUILD43
-rw-r--r--system/mlt/mlt-6.8.0-locale-header.patch18
-rw-r--r--system/mutt/APKBUILD61
-rw-r--r--system/neon/APKBUILD41
-rw-r--r--system/openldap/APKBUILD212
-rw-r--r--system/openldap/CVE-2017-9287.patch28
-rw-r--r--system/openldap/configs.patch117
-rw-r--r--system/openldap/fix-manpages.patch75
-rw-r--r--system/openldap/libressl.patch65
-rw-r--r--system/openldap/openldap-2.4-ppolicy.patch13
-rw-r--r--system/openldap/openldap-2.4.11-libldap_r.patch11
-rw-r--r--system/openldap/openldap-mqtt-overlay.patch447
-rw-r--r--system/openldap/openldap.post-install11
-rw-r--r--system/openldap/openldap.post-upgrade31
-rw-r--r--system/openldap/openldap.pre-install7
-rw-r--r--system/openldap/slapd.confd12
-rw-r--r--system/openldap/slapd.initd34
-rw-r--r--system/orbit2/APKBUILD45
-rw-r--r--system/orbit2/glib-2.36.patch15
-rw-r--r--system/parted/APKBUILD60
-rw-r--r--system/parted/disable-two-tests.patch16
-rw-r--r--system/parted/fix-includes.patch10
-rw-r--r--system/parted/fix-libintl-header-s390x.patch58
-rw-r--r--system/parted/tests-call-name-correctly.patch42
-rw-r--r--system/parted/tests-python3.patch68
-rw-r--r--system/pcre/APKBUILD90
-rw-r--r--system/pcre2/APKBUILD88
-rw-r--r--system/postgresql/APKBUILD259
-rw-r--r--system/postgresql/conf-unix_socket_directories.patch14
-rw-r--r--system/postgresql/disable-broken-tests.patch119
-rw-r--r--system/postgresql/initdb.patch14
-rw-r--r--system/postgresql/perl-rpath.patch22
-rw-r--r--system/postgresql/pg-restore.confd16
-rw-r--r--system/postgresql/pg-restore.initd36
-rw-r--r--system/postgresql/pltcl_create_tables.sql13
-rw-r--r--system/postgresql/postgresql.confd59
-rw-r--r--system/postgresql/postgresql.initd220
-rw-r--r--system/postgresql/postgresql.pre-upgrade32
-rw-r--r--system/py-dbus/APKBUILD44
-rw-r--r--system/py-mako/APKBUILD51
-rw-r--r--system/qca/APKBUILD35
-rw-r--r--system/redis/APKBUILD87
-rw-r--r--system/redis/fix-ppc-atomics.patch13
-rw-r--r--system/redis/posix-runtest.patch33
-rw-r--r--system/redis/redis.confd9
-rwxr-xr-xsystem/redis/redis.initd52
-rw-r--r--system/redis/redis.logrotate4
-rw-r--r--system/redis/redis.pre-install6
-rw-r--r--system/rsync/APKBUILD65
-rw-r--r--system/rsync/rsyncd.conf7
-rw-r--r--system/rsync/rsyncd.confd8
-rw-r--r--system/rsync/rsyncd.initd16
-rw-r--r--system/rsync/rsyncd.logrotate9
-rw-r--r--system/sed/APKBUILD49
-rw-r--r--system/sed/disable-mbrtowc-test.patch10
-rw-r--r--system/sed/localename-test-fix.patch34
-rw-r--r--system/sed/sed.post-deinstall6
-rw-r--r--system/snappy/APKBUILD43
-rw-r--r--system/ssmtp/APKBUILD52
-rw-r--r--system/ssmtp/generate_config.patch49
-rw-r--r--system/ssmtp/inet6-getaddrinfo.patch12
-rw-r--r--system/ssmtp/libcrypto-underlinking.patch11
-rw-r--r--system/strace/APKBUILD65
-rw-r--r--system/strace/disable-fortify.patch39
-rw-r--r--system/strace/fix-ppc-pt-regs-collision.patch19
-rw-r--r--system/strace/nlattr-fix.patch21
-rw-r--r--system/tzdata/0001-posixtz-fix-up-lseek.patch27
-rw-r--r--system/tzdata/APKBUILD66
-rw-r--r--system/upower/APKBUILD40
-rw-r--r--system/upower/daemon-fix-get_critical_action.patch28
-rw-r--r--system/upower/lib-add-propererror-and-cancellable-handling-to-UpClient.patch184
-rw-r--r--system/valgrind/APKBUILD76
-rw-r--r--system/valgrind/arm.patch11
-rw-r--r--system/valgrind/coregrind-elfv2.patch443
-rw-r--r--system/valgrind/uclibc.patch10
-rw-r--r--system/wayland/APKBUILD59
-rw-r--r--system/weechat/APKBUILD66
-rw-r--r--system/weechat/fix-python-linking.patch11
-rw-r--r--system/weechat/libintl-fix.patch12
-rw-r--r--system/wget/APKBUILD50
-rw-r--r--system/wpa_supplicant/APKBUILD104
-rw-r--r--system/wpa_supplicant/config550
-rw-r--r--system/wpa_supplicant/eloop.patch16
-rw-r--r--system/wpa_supplicant/libressl.patch49
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch174
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch250
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch184
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch79
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch64
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch132
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch43
-rw-r--r--system/wpa_supplicant/rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch82
-rw-r--r--system/wpa_supplicant/wpa_cli.sh33
-rw-r--r--system/wpa_supplicant/wpa_supplicant.confd6
-rw-r--r--system/wpa_supplicant/wpa_supplicant.initd53
-rw-r--r--system/xf86-video-ati/APKBUILD36
-rw-r--r--system/zsh/APKBUILD160
-rw-r--r--system/zsh/zprofile24
-rw-r--r--system/zsh/zsh.post-install3
-rw-r--r--system/zsh/zsh.post-upgrade19
-rw-r--r--system/zsh/zsh.pre-deinstall3
285 files changed, 22996 insertions, 0 deletions
diff --git a/system/apr-util/APKBUILD b/system/apr-util/APKBUILD
new file mode 100644
index 000000000..415c3e9cd
--- /dev/null
+++ b/system/apr-util/APKBUILD
@@ -0,0 +1,64 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=apr-util
+pkgver=1.6.1
+pkgrel=0
+pkgdesc="The Apache Portable Runtime Utility Library"
+url="http://apr.apache.org/"
+arch="all"
+license="ASL 2.0"
+depends=
+subpackages="$pkgname-dev $pkgname-dbm_db $pkgname-dbd_pgsql
+ $pkgname-dbd_sqlite3 $pkgname-ldap"
+
+depends_dev="expat-dev apr-dev openldap-dev sqlite-dev postgresql-dev
+ db-dev openssl-dev"
+makedepends="$depends_dev bash chrpath openssl"
+source="http://www.apache.org/dist/apr/$pkgname-$pkgver.tar.bz2"
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --with-apr=/usr \
+ --with-ldap \
+ --with-pgsql \
+ --with-sqlite3 \
+ --with-berkeley-db \
+ --with-crypto \
+ --with-openssl \
+ --without-sqlite2 \
+ --without-gdbm
+ make
+}
+
+check() {
+ cd "$builddir"
+ # testxlate fails because UTF-7 is unsupported
+ make check || return 0
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ rm "$pkgdir"/usr/lib/*.exp
+ chrpath -d "$pkgdir"/usr/lib/*.so.*
+}
+
+_mv_mod() {
+ pkgdesc="The Apache Portable Runtime Utility Library - $2 driver"
+ depends=
+ local _moddir="usr/lib/apr-util-1"
+ mkdir -p "$subpkgdir"/$_moddir
+ mv "$pkgdir"/$_moddir/apr_$1*.so "$subpkgdir"/$_moddir/
+}
+
+dbm_db() { _mv_mod dbm_db "Berkley DB"; }
+dbd_pgsql() { _mv_mod dbd_pgsql "PostgreSQL"; }
+dbd_mysql() { _mv_mod dbd_mysql "MySQL"; }
+dbd_sqlite3() { _mv_mod dbd_sqlite "SQLite3"; }
+ldap() { _mv_mod ldap "LDAP"; }
+
+sha512sums="40eff8a37c0634f7fdddd6ca5e596b38de15fd10767a34c30bbe49c632816e8f3e1e230678034f578dd5816a94f246fb5dfdf48d644829af13bf28de3225205d apr-util-1.6.1.tar.bz2"
diff --git a/system/attr/APKBUILD b/system/attr/APKBUILD
new file mode 100644
index 000000000..1a05e8d7b
--- /dev/null
+++ b/system/attr/APKBUILD
@@ -0,0 +1,75 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=attr
+pkgver=2.4.47
+pkgrel=7
+pkgdesc="Utilities for managing filesystem extended attributes"
+url="https://savannah.nongnu.org/projects/attr"
+arch="all"
+license="GPL2+ LGPL2+"
+depends=""
+options="!checkroot"
+makedepends="libtool autoconf automake bash gzip"
+checkdepends="perl"
+subpackages="$pkgname-dev $pkgname-doc libattr"
+source="http://download.savannah.nongnu.org/releases/attr/attr-$pkgver.src.tar.gz
+ fix-decls.patch
+ fix-throw.patch
+ test-runner-musl.patch
+ test-runner-perl.patch
+ "
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+ update_config_sub
+
+ sed -i -e '/HAVE_ZIPPED_MANPAGES/s:=.*:=false:' \
+ include/builddefs.in
+}
+
+build() {
+ cd "$builddir"
+
+ OPTIMIZER="${CFLAGS}" DEBUG=-DNDEBUG INSTALL_USER=root INSTALL_GROUP=root ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/ \
+ --exec-prefix=/ \
+ --sbindir=/bin \
+ --bindir=/usr/bin \
+ --libdir=/lib \
+ --libexecdir=/usr/lib \
+ --includedir=/usr/include \
+ --mandir=/usr/share/man \
+ --datadir=/usr/share \
+ --disable-gettext
+ make
+}
+
+check() {
+ cd "$builddir"
+ make tests
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" \
+ install install-lib install-dev
+
+ # provided by man-pages
+ rm -r "$pkgdir"/usr/share/man/man2 \
+ "$pkgdir"/usr/share/man/man5/attr.5
+}
+
+libattr() {
+ pkgdesc="Dynamic library for extended attribute support"
+ replaces="attr"
+ mkdir -p "$subpkgdir"/lib
+ mv "$pkgdir"/lib/lib*.so.* "$subpkgdir"/lib/
+}
+
+sha512sums="2a333f63655758298650cf8f89c175efdc0112dcc4013e8d023e2a9a69f177e4bcb1f1d10b6666d6f2027dca4dec0833d54749952ab153d28367e1a72e6e2831 attr-2.4.47.src.tar.gz
+fa7925f63c611e39b28adbf8fa3838bd91c245e4694957c1a8e212cb8f289eb62e04f50806227f6c1947d432ddf7633a471c13dd08d513d1e2b8a9ac1906cb33 fix-decls.patch
+d758b864bac9bdbc3360df2e7a3bc7d04e06789975cf539b8e2b98b1d874744b55c80f0502e283f7233d6ec41f8a39624fe07b512a7fdc6af8d19dd3af5f9f5a fix-throw.patch
+da4b903ae0ba1c72bae60405745c1135d1c3c1cefd7525fca296f8dc7dac1e60e48eeba0ba80fddb035b24b847b00c5a9926d0d586c5d7989d0428e458d977d3 test-runner-musl.patch
+d10821cc73751171c6b9cc4172cf4c85be9b6e154782090a262a16fd69172a291c5d5c94587aebcf5b5d1e02c27769245d88f0aa86478193cf1a277ac7f4f18e test-runner-perl.patch"
diff --git a/system/attr/fix-decls.patch b/system/attr/fix-decls.patch
new file mode 100644
index 000000000..0de70a93d
--- /dev/null
+++ b/system/attr/fix-decls.patch
@@ -0,0 +1,35 @@
+From 667137acaffb8d0cc62b47821a67a52ba0637d5c Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Fri, 10 Jan 2014 13:56:37 +0000
+Subject: avoid glibc-specific DECLS defines
+
+This matches what we do in all the other headers.
+---
+diff --git a/include/xattr.h b/include/xattr.h
+index 70a84be..070d7c5 100644
+--- a/include/xattr.h
++++ b/include/xattr.h
+@@ -30,8 +30,9 @@
+ #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
+ #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
+
+-
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+
+ extern int setxattr (const char *__path, const char *__name,
+ const void *__value, size_t __size, int __flags) __THROW;
+@@ -58,6 +59,8 @@ extern int removexattr (const char *__path, const char *__name) __THROW;
+ extern int lremovexattr (const char *__path, const char *__name) __THROW;
+ extern int fremovexattr (int __filedes, const char *__name) __THROW;
+
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+
+ #endif /* __XATTR_H__ */
+--
+cgit v0.9.0.2
diff --git a/system/attr/fix-throw.patch b/system/attr/fix-throw.patch
new file mode 100644
index 000000000..220e3ad28
--- /dev/null
+++ b/system/attr/fix-throw.patch
@@ -0,0 +1,33 @@
+From 92247401984dd9a80d9d0c8c030692323f980678 Mon Sep 17 00:00:00 2001
+From: Emmanuel Dreyfus <manu@netbsd.org>
+Date: Mon, 30 Jun 2014 13:06:05 +0000
+Subject: Portability fixes
+
+- <features.h> is Linux specific
+- Define __THROW for non glibc based systems
+---
+diff --git a/include/xattr.h b/include/xattr.h
+index 070d7c5..fd1f268 100644
+--- a/include/xattr.h
++++ b/include/xattr.h
+@@ -20,7 +20,18 @@
+ #ifndef __XATTR_H__
+ #define __XATTR_H__
+
++#if defined(linux)
+ #include <features.h>
++#endif
++
++/* Portability non glibc c++ build systems */
++#ifndef __THROW
++# if defined __cplusplus
++# define __THROW throw ()
++# else
++# define __THROW
++# endif
++#endif
+
+ #include <errno.h>
+ #ifndef ENOATTR
+--
+cgit v0.9.0.2
diff --git a/system/attr/test-runner-musl.patch b/system/attr/test-runner-musl.patch
new file mode 100644
index 000000000..082217477
--- /dev/null
+++ b/system/attr/test-runner-musl.patch
@@ -0,0 +1,11 @@
+--- attr-2.4.47/test/attr.test.old 2013-05-19 04:53:54.000000000 +0000
++++ attr-2.4.47/test/attr.test 2017-07-01 22:44:23.620785074 +0000
+@@ -11,7 +11,7 @@
+
+ $ touch f
+ $ setfattr -n user -v value f
+- > setfattr: f: Operation not supported
++ > setfattr: f: Not supported
+
+ $ setfattr -n user. -v value f
+ > setfattr: f: Invalid argument
diff --git a/system/attr/test-runner-perl.patch b/system/attr/test-runner-perl.patch
new file mode 100644
index 000000000..67e117034
--- /dev/null
+++ b/system/attr/test-runner-perl.patch
@@ -0,0 +1,11 @@
+--- attr-2.4.47/test/run.old 2013-05-19 04:53:54.000000000 +0000
++++ attr-2.4.47/test/run 2017-07-01 22:43:09.541515814 +0000
+@@ -84,7 +84,7 @@
+ if (defined $line) {
+ # Substitute %VAR and %{VAR} with environment variables.
+ $line =~ s[%(\w+)][$ENV{$1}]eg;
+- $line =~ s[%{(\w+)}][$ENV{$1}]eg;
++ $line =~ s[%\{(\w+)\}][$ENV{$1}]eg;
+ }
+ if (defined $line) {
+ if ($line =~ s/^\s*< ?//) {
diff --git a/system/autoconf/APKBUILD b/system/autoconf/APKBUILD
new file mode 100644
index 000000000..deceea9f9
--- /dev/null
+++ b/system/autoconf/APKBUILD
@@ -0,0 +1,45 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=autoconf
+pkgver=2.69
+pkgrel=1
+pkgdesc="A GNU tool for automatically configuring source code"
+arch="noarch"
+license="GPL2+"
+url="http://www.gnu.org/software/autoconf"
+depends="m4 perl"
+subpackages="$pkgname-doc"
+source="ftp://ftp.gnu.org/pub/gnu/$pkgname/$pkgname-$pkgver.tar.gz
+ autoconf-2.69-fix-perl-regex.patch
+ "
+
+builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ M4=/usr/bin/m4 ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr
+ make
+}
+
+check() {
+ cd "$builddir"
+ # 38 fails with new perl; 501 fails with new libtool
+ make check TESTSUITEFLAGS="1-37 39-500 502-503"
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ rm -f "$pkgdir"/usr/share/info/dir
+ # conflict with bintuils
+ rm -f "$pkgdir"/usr/share/info/standards.info
+}
+
+sha512sums="e34c7818bcde14d2cb13cdd293ed17d70740d4d1fd7c67a07b415491ef85d42f450d4fe5f8f80cc330bf75c40a62774c51a4336e06e8da07a4cbc49922d975ee autoconf-2.69.tar.gz
+8b779ecec178091c899b75df4471fb72334a062d6b413502d414e8827fe0c9e2f335a8bef6878ae261e1af1568e3fe71fe82d6b5e53cb54e6585ffd91f069d8d autoconf-2.69-fix-perl-regex.patch"
diff --git a/system/autoconf/autoconf-2.69-fix-perl-regex.patch b/system/autoconf/autoconf-2.69-fix-perl-regex.patch
new file mode 100644
index 000000000..9cccf912b
--- /dev/null
+++ b/system/autoconf/autoconf-2.69-fix-perl-regex.patch
@@ -0,0 +1,11 @@
+--- autoconf-2.69/bin/autoscan.in.old 2012-04-25 02:37:26.000000000 +0000
++++ autoconf-2.69/bin/autoscan.in 2017-08-03 23:59:38.720214631 +0000
+@@ -358,7 +358,7 @@
+ {
+ # Strip out comments and variable references.
+ s/#.*//;
+- s/\${[^\}]*}//g;
++ s/\$\{[^\}]*\}//g;
+ s/@[^@]*@//g;
+
+ # Tokens in the code.
diff --git a/system/boost/APKBUILD b/system/boost/APKBUILD
new file mode 100644
index 000000000..9024cb9fe
--- /dev/null
+++ b/system/boost/APKBUILD
@@ -0,0 +1,145 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=boost
+pkgver=1.62.0
+_pkgver="${pkgver//./_}"
+pkgrel=6
+pkgdesc="Free peer-reviewed portable C++ source libraries"
+url="http://www.boost.org/"
+arch="all"
+license="custom"
+options="!check" # No test suite.
+depends=""
+depends_dev="linux-headers"
+makedepends="$depends_dev python3-dev flex bison bzip2-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/${pkgname}_$_pkgver.tar.bz2
+ libressl.patch
+ boost-1.57.0-python-abi_letters.patch
+ boost-1.57.0-python-libpython_dep.patch
+ "
+builddir="$srcdir/${pkgname}_${_pkgver}"
+
+_libs="date_time
+ filesystem
+ graph
+ iostreams
+ math
+ prg_exec_monitor
+ program_options
+ python3
+ random
+ regex
+ serialization
+ signals
+ system
+ thread
+ unit_test_framework
+ wave
+ wserialization
+ "
+for _lib in $_libs; do
+ subpackages="$subpackages $pkgname-$_lib:_boostlib"
+done
+
+prepare() {
+ default_prepare || return 1
+
+ cd "$builddir"
+
+ PY3_VERSION="$(_pyversion python3)"
+ abiflags=$(python3-config --abiflags)
+
+
+ # create user-config.jam
+ cat > user-config.jam <<-__EOF__
+
+ using gcc : : $CC : <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;
+ using python : ${PY3_VERSION} : /usr/bin/python3 : /usr/include/python${PY3_VERSION}m : : : : $abiflags ;
+
+ __EOF__
+}
+
+case "$CARCH" in
+ armhf|aarch64) _boostarch=arm ;;
+ ppc64*) _boostarch=ppc ;;
+ s390x) _boostarch=s390 ;;
+ pmmx) _boostarch=x86 ;;
+ *) _boostarch=$CARCH ;;
+esac
+_enginedir=tools/build/src/engine
+_bjam="${builddir}/$_enginedir/bin.linux${_boostarch}/bjam"
+[ "$_boostarch" = "s390" ] && _bjam="${builddir}/$_enginedir/bin.linux390/bjam" && \
+ _options_s390="--without-context --without-coroutine --without-coroutine2"
+
+_options="--user-config=\"$builddir/user-config.jam\"
+ --prefix=\"$pkgdir/usr\"
+ release
+ debug-symbols=off
+ threading=single,multi
+ runtime-link=shared
+ link=shared,static
+ cflags=-fno-strict-aliasing
+ -sPYTHON_ROOT=/usr
+ -sTOOLS=gcc
+ --layout=tagged
+ -q
+ -j${JOBS:-2}
+ ${_options_s390}
+ "
+
+build() {
+ export BOOST_ROOT="$builddir"
+
+ msg "Building bjam"
+ cd "$builddir"/$_enginedir
+ CC= ./build.sh cc || return 1
+
+ msg "Building bcp"
+ cd "$builddir"/tools/bcp
+ "$_bjam" -j${JOBS:-2} || return 1
+
+ msg "Building boost"
+ cd "$builddir"
+ "$_bjam" $_options
+}
+
+package() {
+ export BOOST_ROOT="$builddir"
+ cd "$builddir"
+
+ install -Dm755 $_bjam \
+ "$pkgdir"/usr/bin/bjam || return 1
+
+ install -Dm755 dist/bin/bcp "$pkgdir"/usr/bin/bcp || return 1
+
+ install -Dm644 LICENSE_1_0.txt \
+ "$pkgdir"/usr/share/licenses/$pkgname/LICENSE_1_0.txt || return 1
+
+ "$pkgdir"/usr/bin/bjam $_options \
+ --includedir="$pkgdir"/usr/include \
+ --libdir="$pkgdir"/usr/lib \
+ install || return 1
+
+ cd libs/python/pyste/install
+ python3 setup.py install --root="$pkgdir" || return 1
+}
+
+_boostlib() {
+ local name="${subpkgname#$pkgname-}"
+ pkgdesc="Boost $name library"
+ case "$name" in
+ python*) depends="$depends $name"
+ esac
+
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libboost_$name* "$subpkgdir"/usr/lib/
+}
+
+_pyversion() {
+ $1 -c 'import sys; print("%i.%i" % (sys.version_info.major, sys.version_info.minor))'
+}
+
+sha512sums="5385ae3d5255a433a704169ad454d8dc2b0b5bcae3fb23defd6570df4ff7d845cf9fcbeebccdc1c5db0eec9f82ee3d90040de9507c8167467c635d3b215463be boost_1_62_0.tar.bz2
+5804c344b5e5ece17811e744f1965c58840b6695a084dd09c23c9db380f3cbfbca201d6c595b5379bc12ff6f285794509799d28864df6037db6212c63adb2207 libressl.patch
+d96d4d37394a31764ed817d0bc4a99cffa68a75ff1ecfd4417b9e1e5ae2c31a96ed24f948c6f2758ffdac01328d2402c4cf0d33a37107e4f5f721e636daebd66 boost-1.57.0-python-abi_letters.patch
+132c4b62815d605c2d3c9038427fa4f422612a33711d47b2862f2311516af8a371d6b75bf078a7bffe20be863f8d21fb9fe74dc1a1bac3a10d061e9768ec3e02 boost-1.57.0-python-libpython_dep.patch"
diff --git a/system/boost/boost-1.57.0-python-abi_letters.patch b/system/boost/boost-1.57.0-python-abi_letters.patch
new file mode 100644
index 000000000..7df3ee704
--- /dev/null
+++ b/system/boost/boost-1.57.0-python-abi_letters.patch
@@ -0,0 +1,62 @@
+--- boost_1_57_0/tools/build/src/tools/python.jam 2013-05-21 06:14:18.000000000 +0200
++++ boost_1_55_0/tools/build/src/tools/python.jam 2014-05-29 19:09:12.115413877 +0200
+@@ -94,7 +94,7 @@ feature.feature pythonpath : : free opti
+ # using python : 2.3 : /usr/local/bin/python ;
+ #
+ rule init ( version ? : cmd-or-prefix ? : includes * : libraries ?
+- : condition * : extension-suffix ? )
++ : condition * : extension-suffix ? : abi-letters ? )
+ {
+ project.push-current $(.project) ;
+
+@@ -107,7 +107,7 @@ rule init ( version ? : cmd-or-prefix ?
+ }
+ }
+
+- configure $(version) : $(cmd-or-prefix) : $(includes) : $(libraries) : $(condition) : $(extension-suffix) ;
++ configure $(version) : $(cmd-or-prefix) : $(includes) : $(libraries) : $(condition) : $(extension-suffix) : $(abi-letters) ;
+
+ project.pop-current ;
+ }
+@@ -653,7 +653,7 @@ local rule system-library-dependencies (
+
+ # Declare a target to represent Python's library.
+ #
+-local rule declare-libpython-target ( version ? : requirements * )
++local rule declare-libpython-target ( version ? : requirements * : abi-letters ? )
+ {
+ # Compute the representation of Python version in the name of Python's
+ # library file.
+@@ -677,13 +677,13 @@ local rule declare-libpython-target ( ve
+ }
+
+ # Declare it.
+- lib python.lib : : <name>python$(lib-version) $(requirements) ;
++ lib python.lib : : <name>python$(lib-version)$(abi-letters) $(requirements) ;
+ }
+
+
+ # Implementation of init.
+ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
+- condition * : extension-suffix ? )
++ condition * : extension-suffix ? : abi-letters ? )
+ {
+ local prefix ;
+ local exec-prefix ;
+@@ -699,6 +699,7 @@ local rule configure ( version ? : cmd-o
+ extension-suffix ?= _d ;
+ }
+ extension-suffix ?= "" ;
++ abi-letters ?= "" ;
+
+ # Normalize and dissect any version number.
+ local major-minor ;
+@@ -922,7 +923,7 @@ local rule configure ( version ? : cmd-o
+ }
+ else
+ {
+- declare-libpython-target $(version) : $(target-requirements) ;
++ declare-libpython-target $(version) : $(target-requirements) : $(abi-letters) ;
+
+ # This is an evil hack. On, Windows, when Python is embedded, nothing
+ # seems to set up sys.path to include Python's standard library
diff --git a/system/boost/boost-1.57.0-python-libpython_dep.patch b/system/boost/boost-1.57.0-python-libpython_dep.patch
new file mode 100644
index 000000000..57bfc2677
--- /dev/null
+++ b/system/boost/boost-1.57.0-python-libpython_dep.patch
@@ -0,0 +1,13 @@
+Index: boost_1_57_0/tools/build/src/tools/python.jam
+===================================================================
+--- boost_1_57_0/tools/build/src/tools/python.jam (revision 50406)
++++ boost_1_57_0/tools/build/src/tools/python.jam (working copy)
+@@ -994,7 +994,7 @@
+ else
+ {
+ alias python_for_extensions
+- :
++ : python
+ : $(target-requirements)
+ :
+ : $(usage-requirements)
diff --git a/system/boost/dual-python.patch b/system/boost/dual-python.patch
new file mode 100644
index 000000000..6a0647888
--- /dev/null
+++ b/system/boost/dual-python.patch
@@ -0,0 +1,27 @@
+diff --git a/tools/build/src/tools/python.jam b/tools/build/src/tools/python.jam
+index cbd6419..0c29df6 100644
+--- a/tools/build/src/tools/python.jam
++++ b/tools/build/src/tools/python.jam
+@@ -907,14 +907,14 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
+ # for a particular target OS as the default. This makes it so that we can
+ # select a python interpreter with only knowledge of the target OS. And hence
+ # can configure different Pythons based on the target OS only.
+- local toolset-requirements = [ toolset.requirements ] ;
+- local toolset-target-os-requirements
+- = [ property.evaluate-conditionals-in-context
+- [ $(toolset-requirements).raw ] : <target-os>$(target-os) ] ;
+- if ! <python> in $(toolset-target-os-requirements:G)
+- {
+- toolset.add-requirements <target-os>$(target-os):<python>$(version:E=default) ;
+- }
++# local toolset-requirements = [ toolset.requirements ] ;
++# local toolset-target-os-requirements
++# = [ property.evaluate-conditionals-in-context
++# [ $(toolset-requirements).raw ] : <target-os>$(target-os) ] ;
++# if ! <python> in $(toolset-target-os-requirements:G)
++# {
++# toolset.add-requirements <target-os>$(target-os):<python>$(version:E=default) ;
++# }
+
+ # Register the right suffix for extensions.
+ register-extension-suffix $(extension-suffix) : $(target-requirements) ;
diff --git a/system/boost/libressl.patch b/system/boost/libressl.patch
new file mode 100644
index 000000000..30c13bfcc
--- /dev/null
+++ b/system/boost/libressl.patch
@@ -0,0 +1,146 @@
+diff --git a/boost/asio/ssl/detail/impl/engine.ipp b/boost/asio/ssl/detail/impl/engine.ipp
+index f15f2e3..d33935f 100644
+--- a/boost/asio/ssl/detail/impl/engine.ipp
++++ b/boost/asio/ssl/detail/impl/engine.ipp
+@@ -209,7 +209,7 @@ const boost::system::error_code& engine::map_error_code(
+
+ // SSL v2 doesn't provide a protocol-level shutdown, so an eof on the
+ // underlying transport is passed through.
+-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ if (ssl_->version == SSL2_VERSION)
+ return ec;
+ #endif // (OPENSSL_VERSION_NUMBER < 0x10100000L)
+diff --git a/boost/asio/ssl/detail/impl/openssl_init.ipp b/boost/asio/ssl/detail/impl/openssl_init.ipp
+index 94b67f3..acbd926 100644
+--- a/boost/asio/ssl/detail/impl/openssl_init.ipp
++++ b/boost/asio/ssl/detail/impl/openssl_init.ipp
+@@ -40,7 +40,7 @@ public:
+ ::SSL_load_error_strings();
+ ::OpenSSL_add_all_algorithms();
+
+-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+ mutexes_.resize(::CRYPTO_num_locks());
+ for (size_t i = 0; i < mutexes_.size(); ++i)
+ mutexes_[i].reset(new boost::asio::detail::mutex);
+@@ -68,7 +68,7 @@ public:
+ #if (OPENSSL_VERSION_NUMBER < 0x10000000L)
+ ::CRYPTO_set_id_callback(0);
+ #endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
+-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+ ::CRYPTO_set_locking_callback(0);
+ ::ERR_free_strings();
+ ::EVP_cleanup();
+@@ -76,7 +76,7 @@ public:
+ #endif // (OPENSSL_VERSION_NUMBER < 0x10100000L)
+ #if (OPENSSL_VERSION_NUMBER < 0x10000000L)
+ ::ERR_remove_state(0);
+-#elif (OPENSSL_VERSION_NUMBER < 0x10100000L)
++#elif (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+ ::ERR_remove_thread_state(NULL);
+ #endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
+ #if (OPENSSL_VERSION_NUMBER >= 0x10002000L) \
+@@ -117,7 +117,7 @@ private:
+ }
+ #endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
+
+-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+ static void openssl_locking_func(int mode, int n,
+ const char* /*file*/, int /*line*/)
+ {
+diff --git a/boost/asio/ssl/error.hpp b/boost/asio/ssl/error.hpp
+index 7f85fbd..7e07e65 100644
+--- a/boost/asio/ssl/error.hpp
++++ b/boost/asio/ssl/error.hpp
+@@ -44,7 +44,7 @@ enum stream_errors
+ #if defined(GENERATING_DOCUMENTATION)
+ /// The underlying stream closed before the ssl stream gracefully shut down.
+ stream_truncated
+-#elif (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)
++#elif ((OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)) || defined(LIBRESSL_VERSION_NUMBER)
+ stream_truncated = ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ)
+ #else
+ stream_truncated = 1
+diff --git a/boost/asio/ssl/impl/context.ipp b/boost/asio/ssl/impl/context.ipp
+index aea2cbd..3ef8c86 100644
+--- a/boost/asio/ssl/impl/context.ipp
++++ b/boost/asio/ssl/impl/context.ipp
+@@ -130,7 +130,7 @@ context::context(context::method m)
+ case context::sslv23_server:
+ handle_ = ::SSL_CTX_new(::SSLv23_server_method());
+ break;
+-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+ #if defined(SSL_TXT_TLSV1_1)
+ case context::tlsv11:
+ handle_ = ::SSL_CTX_new(::TLSv1_1_method());
+@@ -228,7 +228,7 @@ context::~context()
+ {
+ if (handle_)
+ {
+-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ void* cb_userdata = ::SSL_CTX_get_default_passwd_cb_userdata(handle_);
+ #else // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+ void* cb_userdata = handle_->default_passwd_callback_userdata;
+@@ -239,7 +239,7 @@ context::~context()
+ static_cast<detail::password_callback_base*>(
+ cb_userdata);
+ delete callback;
+-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ ::SSL_CTX_set_default_passwd_cb_userdata(handle_, 0);
+ #else // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+ handle_->default_passwd_callback_userdata = 0;
+@@ -578,7 +578,7 @@ boost::system::error_code context::use_certificate_chain(
+ bio_cleanup bio = { make_buffer_bio(chain) };
+ if (bio.p)
+ {
+-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ pem_password_cb* callback = ::SSL_CTX_get_default_passwd_cb(handle_);
+ void* cb_userdata = ::SSL_CTX_get_default_passwd_cb_userdata(handle_);
+ #else // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+@@ -682,7 +682,7 @@ boost::system::error_code context::use_private_key(
+ {
+ ::ERR_clear_error();
+
+-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ pem_password_cb* callback = ::SSL_CTX_get_default_passwd_cb(handle_);
+ void* cb_userdata = ::SSL_CTX_get_default_passwd_cb_userdata(handle_);
+ #else // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+@@ -749,7 +749,7 @@ boost::system::error_code context::use_rsa_private_key(
+ {
+ ::ERR_clear_error();
+
+-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ pem_password_cb* callback = ::SSL_CTX_get_default_passwd_cb(handle_);
+ void* cb_userdata = ::SSL_CTX_get_default_passwd_cb_userdata(handle_);
+ #else // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+@@ -988,7 +988,7 @@ int context::verify_callback_function(int preverified, X509_STORE_CTX* ctx)
+ boost::system::error_code context::do_set_password_callback(
+ detail::password_callback_base* callback, boost::system::error_code& ec)
+ {
+-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+ void* old_callback = ::SSL_CTX_get_default_passwd_cb_userdata(handle_);
+ ::SSL_CTX_set_default_passwd_cb_userdata(handle_, callback);
+ #else // (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+diff --git a/boost/asio/ssl/impl/error.ipp b/boost/asio/ssl/impl/error.ipp
+index e82afba..1629794 100644
+--- a/boost/asio/ssl/impl/error.ipp
++++ b/boost/asio/ssl/impl/error.ipp
+@@ -53,7 +53,7 @@ const boost::system::error_category& get_ssl_category()
+ namespace ssl {
+ namespace error {
+
+-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)
++#if ((OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)) || defined(LIBRESSL_VERSION_NUMBER)
+
+ const boost::system::error_category& get_stream_category()
+ {
diff --git a/system/busybox/0001-ash-add-support-for-command_not_found_handle-hook-fu.patch b/system/busybox/0001-ash-add-support-for-command_not_found_handle-hook-fu.patch
new file mode 100644
index 000000000..e4ba6ece5
--- /dev/null
+++ b/system/busybox/0001-ash-add-support-for-command_not_found_handle-hook-fu.patch
@@ -0,0 +1,63 @@
+From f76c1ddd625b3d9912d9e6df2e90fcb94d08be99 Mon Sep 17 00:00:00 2001
+From: William Pitcock <nenolod@dereferenced.org>
+Date: Thu, 19 Oct 2017 17:24:40 +0000
+Subject: [PATCH] ash: add support for command_not_found_handle hook function,
+ like bash
+
+This implements support for the command_not_found_handle hook function, which is
+useful for allowing package managers to suggest packages which could provide the
+command.
+
+Unlike bash, however, we ignore exit codes from the hook function and always return
+the correct POSIX error code (EX_NOTFOUND).
+
+Signed-off-by: William Pitcock <nenolod@dereferenced.org>
+---
+ shell/ash.c | 24 ++++++++++++++++++++++--
+ 1 file changed, 22 insertions(+), 2 deletions(-)
+
+diff --git a/shell/ash.c b/shell/ash.c
+index 88e607f08..c3c4f4e93 100644
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -132,6 +132,15 @@
+ //config: you to run the specified command or builtin,
+ //config: even when there is a function with the same name.
+ //config:
++//config:config ASH_COMMAND_NOT_FOUND_HOOK
++//config: bool "command_not_found_handle hook support"
++//config: default y
++//config: depends on ASH || SH_IS_ASH || BASH_IS_ASH
++//config: help
++//config: Enable support for the 'command_not_found_handle' hook function,
++//config: from GNU bash, which allows for alternative command not found
++//config: handling.
++//config:
+ //config:endif # ash options
+
+ //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP))
+@@ -13123,8 +13132,19 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
+ /* We failed. If there was an entry for this command, delete it */
+ if (cmdp && updatetbl)
+ delete_cmd_entry();
+- if (act & DO_ERR)
+- ash_msg("%s: %s", name, errmsg(e, "not found"));
++ if (act & DO_ERR) {
++#ifdef CONFIG_ASH_COMMAND_NOT_FOUND_HOOK
++#define HOOKFN_NAME "command_not_found_handle"
++ char hookfn_name[] = HOOKFN_NAME;
++ struct tblentry *hookp = cmdlookup(hookfn_name, 0);
++ if (hookp != NULL && hookp->cmdtype == CMDFUNCTION) {
++ evalfun(hookp->param.func, 2, (char *[]){ hookfn_name, name }, 0);
++ entry->cmdtype = CMDUNKNOWN;
++ return;
++ } else
++#endif
++ ash_msg("%s: %s", name, errmsg(e, "not found"));
++ }
+ entry->cmdtype = CMDUNKNOWN;
+ return;
+
+--
+2.14.2
+
diff --git a/system/busybox/0001-ash-exec-busybox.static.patch b/system/busybox/0001-ash-exec-busybox.static.patch
new file mode 100644
index 000000000..fdf134960
--- /dev/null
+++ b/system/busybox/0001-ash-exec-busybox.static.patch
@@ -0,0 +1,25 @@
+From 134582e8dd1c85cbcf1fc047956a57fcd642e46a Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 4 Aug 2016 11:03:07 +0200
+Subject: [PATCH 01/11] ash: exec busybox.static
+
+---
+ shell/ash.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/shell/ash.c b/shell/ash.c
+index b7635a823..e613ee6bb 100644
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -7721,6 +7721,8 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char **
+ }
+ /* re-exec ourselves with the new arguments */
+ execve(bb_busybox_exec_path, argv, envp);
++ execve("/bin/busybox.static",argv,envp);
++ execve("/bin/busybox",argv,envp);
+ /* If they called chroot or otherwise made the binary no longer
+ * executable, fall through */
+ }
+--
+2.13.2
+
diff --git a/system/busybox/0002-app-location-for-cpio-vi-and-lspci.patch b/system/busybox/0002-app-location-for-cpio-vi-and-lspci.patch
new file mode 100644
index 000000000..8c8e4ee7a
--- /dev/null
+++ b/system/busybox/0002-app-location-for-cpio-vi-and-lspci.patch
@@ -0,0 +1,54 @@
+From 8937e2dfb3dbfa23597853e9605f930b3607fa63 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 27 Dec 2016 20:46:59 +0100
+Subject: [PATCH 02/11] app location for cpio, vi and lspci
+
+Adjust location to where alpine linux installs them
+---
+ archival/cpio.c | 2 +-
+ editors/vi.c | 2 +-
+ util-linux/lspci.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/archival/cpio.c b/archival/cpio.c
+index 683f0bb1f..45362b6bc 100644
+--- a/archival/cpio.c
++++ b/archival/cpio.c
+@@ -43,7 +43,7 @@
+ //config: help
+ //config: Passthrough mode. Rarely used.
+
+-//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))
++//applet:IF_CPIO(APPLET(cpio, BB_DIR_USR_BIN, BB_SUID_DROP))
+ //kbuild:lib-$(CONFIG_CPIO) += cpio.o
+
+ //usage:#define cpio_trivial_usage
+diff --git a/editors/vi.c b/editors/vi.c
+index 76d1f261b..73d0a67a9 100644
+--- a/editors/vi.c
++++ b/editors/vi.c
+@@ -163,7 +163,7 @@
+ //config: Unless you want more (or less) frequent "undo points" while typing,
+ //config: you should probably leave this unchanged.
+
+-//applet:IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP))
++//applet:IF_VI(APPLET(vi, BB_DIR_USR_BIN, BB_SUID_DROP))
+
+ //kbuild:lib-$(CONFIG_VI) += vi.o
+
+diff --git a/util-linux/lspci.c b/util-linux/lspci.c
+index 8b38a2366..f918f0972 100644
+--- a/util-linux/lspci.c
++++ b/util-linux/lspci.c
+@@ -16,7 +16,7 @@
+ //config:
+ //config: This version uses sysfs (/sys/bus/pci/devices) only.
+
+-//applet:IF_LSPCI(APPLET(lspci, BB_DIR_USR_BIN, BB_SUID_DROP))
++//applet:IF_LSPCI(APPLET(lspci, BB_DIR_USR_SBIN, BB_SUID_DROP))
+
+ //kbuild:lib-$(CONFIG_LSPCI) += lspci.o
+
+--
+2.13.2
+
diff --git a/system/busybox/0003-udhcpc-set-default-discover-retries-to-5.patch b/system/busybox/0003-udhcpc-set-default-discover-retries-to-5.patch
new file mode 100644
index 000000000..5671ee1b0
--- /dev/null
+++ b/system/busybox/0003-udhcpc-set-default-discover-retries-to-5.patch
@@ -0,0 +1,35 @@
+From 18415adc1cd9993a95d100dd773daf69b8ec819e Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 4 Aug 2016 11:08:35 +0200
+Subject: [PATCH 03/11] udhcpc: set default discover retries to 5
+
+Some slower nics needs more attempts to get a lease
+---
+ networking/udhcp/dhcpc.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
+index 1a66c610e..43aac1b85 100644
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1191,7 +1191,7 @@ static void client_background(void)
+ //usage: "\n -s,--script PROG Run PROG at DHCP events (default "CONFIG_UDHCPC_DEFAULT_SCRIPT")"
+ //usage: "\n -p,--pidfile FILE Create pidfile"
+ //usage: "\n -B,--broadcast Request broadcast replies"
+-//usage: "\n -t,--retries N Send up to N discover packets (default 3)"
++//usage: "\n -t,--retries N Send up to N discover packets (default 5)"
+ //usage: "\n -T,--timeout SEC Pause between packets (default 3)"
+ //usage: "\n -A,--tryagain SEC Wait if lease is not obtained (default 20)"
+ //usage: "\n -n,--now Exit if lease is not obtained"
+@@ -1274,7 +1274,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
+ llist_t *list_x = NULL;
+ int tryagain_timeout = 20;
+ int discover_timeout = 3;
+- int discover_retries = 3;
++ int discover_retries = 5;
+ uint32_t server_addr = server_addr; /* for compiler */
+ uint32_t requested_ip = 0;
+ uint32_t xid = xid; /* for compiler */
+--
+2.13.2
+
diff --git a/system/busybox/0004-ping-make-ping-work-without-root-privileges.patch b/system/busybox/0004-ping-make-ping-work-without-root-privileges.patch
new file mode 100644
index 000000000..77fa5ed76
--- /dev/null
+++ b/system/busybox/0004-ping-make-ping-work-without-root-privileges.patch
@@ -0,0 +1,197 @@
+From bef770d1ee4179e380dff24305d9b6d899147add Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 29 Mar 2016 18:59:22 +0200
+Subject: [PATCH 04/11] ping: make ping work without root privileges
+
+---
+ networking/ping.c | 103 +++++++++++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 87 insertions(+), 16 deletions(-)
+
+diff --git a/networking/ping.c b/networking/ping.c
+index 94fb007f5..26e40e1fc 100644
+--- a/networking/ping.c
++++ b/networking/ping.c
+@@ -155,6 +155,7 @@ enum {
+ pingsock = 0,
+ };
+
++static int using_dgram;
+ static void
+ #if ENABLE_PING6
+ create_icmp_socket(len_and_sockaddr *lsa)
+@@ -171,9 +172,23 @@ create_icmp_socket(void)
+ #endif
+ sock = socket(AF_INET, SOCK_RAW, 1); /* 1 == ICMP */
+ if (sock < 0) {
+- if (errno == EPERM)
+- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
+- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
++ if (errno != EPERM)
++ bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
++#if defined(__linux__) || defined(__APPLE__)
++ /* We don't have root privileges. Try SOCK_DGRAM instead.
++ * Linux needs net.ipv4.ping_group_range for this to work.
++ * MacOSX allows ICMP_ECHO, ICMP_TSTAMP or ICMP_MASKREQ
++ */
++#if ENABLE_PING6
++ if (lsa->u.sa.sa_family == AF_INET6)
++ sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6);
++ else
++#endif
++ sock = socket(AF_INET, SOCK_DGRAM, 1); /* 1 == ICMP */
++ if (sock < 0)
++#endif
++ bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
++ using_dgram = 1;
+ }
+
+ xmove_fd(sock, pingsock);
+@@ -226,10 +241,12 @@ static void ping4(len_and_sockaddr *lsa)
+ bb_perror_msg("recvfrom");
+ continue;
+ }
+- if (c >= 76) { /* ip + icmp */
+- struct iphdr *iphdr = (struct iphdr *) G.packet;
++ if (c >= 76 || using_dgram && (c == 64)) { /* ip + icmp */
++ if(!using_dgram) {
++ struct iphdr *iphdr = (struct iphdr *) G.packet;
+
+- pkt = (struct icmp *) (G.packet + (iphdr->ihl << 2)); /* skip ip hdr */
++ pkt = (struct icmp *) (G.packet + (iphdr->ihl << 2)); /* skip ip hdr */
++ } else pkt = (struct icmp *) G.packet;
+ if (pkt->icmp_id != G.myid)
+ continue; /* not our ping */
+ if (pkt->icmp_type == ICMP_ECHOREPLY)
+@@ -627,19 +644,21 @@ static void unpack_tail(int sz, uint32_t *tp,
+ }
+ static void unpack4(char *buf, int sz, struct sockaddr_in *from)
+ {
+- struct icmp *icmppkt;
+ struct iphdr *iphdr;
++ struct icmp *icmppkt;
+ int hlen;
+
+ /* discard if too short */
+ if (sz < (datalen + ICMP_MINLEN))
+ return;
++ if(!using_dgram) {
++ /* check IP header */
++ iphdr = (struct iphdr *) buf;
++ hlen = iphdr->ihl << 2;
++ sz -= hlen;
++ icmppkt = (struct icmp *) (buf + hlen);
++ } else icmppkt = (struct icmp *) buf;
+
+- /* check IP header */
+- iphdr = (struct iphdr *) buf;
+- hlen = iphdr->ihl << 2;
+- sz -= hlen;
+- icmppkt = (struct icmp *) (buf + hlen);
+ if (icmppkt->icmp_id != myid)
+ return; /* not our ping */
+
+@@ -651,7 +670,7 @@ static void unpack4(char *buf, int sz, struct sockaddr_in *from)
+ tp = (uint32_t *) icmppkt->icmp_data;
+ unpack_tail(sz, tp,
+ inet_ntoa(*(struct in_addr *) &from->sin_addr.s_addr),
+- recv_seq, iphdr->ttl);
++ recv_seq, using_dgram ? 42 : iphdr->ttl);
+ } else if (icmppkt->icmp_type != ICMP_ECHO) {
+ bb_error_msg("warning: got ICMP %d (%s)",
+ icmppkt->icmp_type,
+@@ -695,11 +714,31 @@ static void ping4(len_and_sockaddr *lsa)
+ int sockopt;
+
+ pingaddr.sin = lsa->u.sin;
+- if (source_lsa) {
++ if (source_lsa && !using_dgram) {
+ if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF,
+ &source_lsa->u.sa, source_lsa->len))
+ bb_error_msg_and_die("can't set multicast source interface");
+ xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
++ } else if(using_dgram) {
++ struct sockaddr_in sa;
++ socklen_t sl;
++
++ sa.sin_family = AF_INET;
++ sa.sin_port = 0;
++ sa.sin_addr.s_addr = source_lsa ?
++ source_lsa->u.sin.sin_addr.s_addr : 0;
++ sl = sizeof(sa);
++
++ if (bind(pingsock, (struct sockaddr *) &sa, sl) == -1) {
++ perror("bind");
++ exit(2);
++ }
++
++ if (getsockname(pingsock, (struct sockaddr *) &sa, &sl) == -1) {
++ perror("getsockname");
++ exit(2);
++ }
++ myid = sa.sin_port;
+ }
+
+ /* enable broadcast pings */
+@@ -716,6 +755,15 @@ static void ping4(len_and_sockaddr *lsa)
+ setsockopt_int(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, opt_ttl);
+ }
+
++ if(using_dgram) {
++ int hold = 65536;
++ if (setsockopt(pingsock, SOL_IP, IP_RECVTTL, (char *)&hold, sizeof(hold)))
++ perror("WARNING: setsockopt(IP_RECVTTL)");
++ if (setsockopt(pingsock, SOL_IP, IP_RETOPTS, (char *)&hold, sizeof(hold)))
++ perror("WARNING: setsockopt(IP_RETOPTS)");
++
++ }
++
+ signal(SIGINT, print_stats_and_exit);
+
+ /* start the ping's going ... */
+@@ -749,10 +797,33 @@ static void ping6(len_and_sockaddr *lsa)
+ char control_buf[CMSG_SPACE(36)];
+
+ pingaddr.sin6 = lsa->u.sin6;
+- if (source_lsa)
++ if (source_lsa && !using_dgram)
+ xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
++ else if(using_dgram) {
++ struct sockaddr_in6 sa = {0};
++ socklen_t sl;
++
++ sa.sin6_family = AF_INET6;
++ sa.sin6_port = 0;
++ if(source_lsa) {
++ memcpy(&sa.sin6_addr, &source_lsa->u.sin6.sin6_addr, sizeof(struct in6_addr));
++ }
++ sl = sizeof(sa);
++
++ if (bind(pingsock, (struct sockaddr *) &sa, sl) == -1) {
++ perror("bind");
++ exit(2);
++ }
++
++ if (getsockname(pingsock, (struct sockaddr *) &sa, &sl) == -1) {
++ perror("getsockname");
++ exit(2);
++ }
++ myid = sa.sin6_port;
++ }
+
+ #ifdef ICMP6_FILTER
++ if(!using_dgram)
+ {
+ struct icmp6_filter filt;
+ if (!(option_mask32 & OPT_VERBOSE)) {
+@@ -880,7 +951,7 @@ static int common_ping_main(int opt, char **argv)
+ if (opt & OPT_p)
+ G.pattern = xstrtou_range(str_p, 16, 0, 255);
+
+- myid = (uint16_t) getpid();
++ if (!using_dgram) myid = (uint16_t) getpid();
+ hostname = argv[optind];
+ #if ENABLE_PING6
+ {
+--
+2.13.2
+
diff --git a/system/busybox/0005-fbsplash-support-console-switching.patch b/system/busybox/0005-fbsplash-support-console-switching.patch
new file mode 100644
index 000000000..792c2d6c8
--- /dev/null
+++ b/system/busybox/0005-fbsplash-support-console-switching.patch
@@ -0,0 +1,187 @@
+From a8f7d33f47cc28732cd04573ae1fb6a1ca6e9617 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Mon, 24 Sep 2012 07:58:29 +0300
+Subject: [PATCH 05/11] fbsplash: support console switching
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Timo Teräs <timo.teras@iki.fi>
+---
+ miscutils/fbsplash.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 76 insertions(+), 7 deletions(-)
+
+diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
+index fc6c9b953..ec5947314 100644
+--- a/miscutils/fbsplash.c
++++ b/miscutils/fbsplash.c
+@@ -47,7 +47,7 @@
+ //kbuild:lib-$(CONFIG_FBSPLASH) += fbsplash.o
+
+ //usage:#define fbsplash_trivial_usage
+-//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]"
++//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD] [-T tty]"
+ //usage:#define fbsplash_full_usage "\n\n"
+ //usage: " -s Image"
+ //usage: "\n -c Hide cursor"
+@@ -57,11 +57,17 @@
+ //usage: "\n BAR_R,BAR_G,BAR_B"
+ //usage: "\n -f Control pipe (else exit after drawing image)"
+ //usage: "\n commands: 'NN' (% for progress bar) or 'exit'"
++//usage: "\n -T Switch to TTY to hide all console messages"
+
+ #include "libbb.h"
+ #include "common_bufsiz.h"
+ #include <linux/fb.h>
+
++#include <sys/vt.h>
++#include <sys/ioctl.h>
++#include <linux/tiocl.h>
++#include <linux/kd.h>
++
+ /* If you want logging messages on /tmp/fbsplash.log... */
+ #define DEBUG 0
+
+@@ -73,6 +79,8 @@ struct globals {
+ unsigned char *addr; // pointer to framebuffer memory
+ unsigned ns[7]; // n-parameters
+ const char *image_filename;
++ int silent_tty, fd_tty_s;
++ bool do_not_draw;
+ struct fb_var_screeninfo scr_var;
+ struct fb_fix_screeninfo scr_fix;
+ unsigned bytes_per_pixel;
+@@ -483,6 +491,11 @@ static void init(const char *cfg_filename)
+ config_close(parser);
+ }
+
++static void sighandler(int sig)
++{
++ ioctl(G.fd_tty_s, VT_RELDISP, sig == SIGUSR1 ? 1 : 2);
++ G.do_not_draw = (sig != SIGUSR2);
++}
+
+ int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+@@ -492,6 +505,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+ char *num_buf;
+ unsigned num;
+ bool bCursorOff;
++ int fd_tty0, active_vt;
++ struct vt_stat vtstat;
++ struct vt_mode vt;
+
+ INIT_G();
+
+@@ -499,8 +515,10 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+ fb_device = "/dev/fb0";
+ cfg_filename = NULL;
+ fifo_filename = NULL;
+- bCursorOff = 1 & getopt32(argv, "cs:d:i:f:",
+- &G.image_filename, &fb_device, &cfg_filename, &fifo_filename);
++ opt_complementary = "T+"; // numeric params
++ bCursorOff = 1 & getopt32(argv, "cs:d:i:f:T:",
++ &G.image_filename, &fb_device, &cfg_filename, &fifo_filename,
++ &G.silent_tty);
+
+ // parse configuration file
+ if (cfg_filename)
+@@ -510,11 +528,43 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+ if (!G.image_filename)
+ bb_show_usage();
+
++ fd_tty0 = get_console_fd_or_die();
++ if (G.silent_tty) {
++ char buf[16];
++
++ /* Initialize TTY */
++ bb_signals((1LL << SIGUSR1) | (1LL << SIGUSR2), sighandler);
++ snprintf(buf, sizeof(buf), "/dev/tty%d", G.silent_tty);
++ G.fd_tty_s = xopen(buf, O_RDWR | O_NOCTTY);
++
++ /* Activate TTY */
++ xioctl(fd_tty0, VT_GETSTATE, &vtstat);
++ active_vt = vtstat.v_active;
++ console_make_active(fd_tty0, G.silent_tty);
++
++ /* Get notifications on console changes */
++ vt.mode = VT_PROCESS;
++ vt.waitv = 0;
++ vt.relsig = SIGUSR1;
++ vt.acqsig = SIGUSR2;
++ ioctl(G.fd_tty_s, VT_SETMODE, &vt);
++
++ /* Redirect all kernel messages to tty1 so that they don't get
++ * printed over our silent splash image. And clear it. */
++ buf[0] = TIOCL_SETKMSGREDIRECT;
++ buf[1] = 1;
++ ioctl(G.fd_tty_s, TIOCLINUX, buf);
++ full_write(G.fd_tty_s, "\e[H\e[2J" "\e[?17;0c", 7+8);
++ ioctl(G.fd_tty_s, KDSETMODE, KD_GRAPHICS);
++ } else {
++ G.fd_tty_s = STDOUT_FILENO;
++ }
++
+ fb_open(fb_device);
+
+ if (fifo_filename && bCursorOff) {
+ // hide cursor (BEFORE any fb ops)
+- full_write(STDOUT_FILENO, "\033[?25l", 6);
++ full_write(G.fd_tty_s, "\033[?25l", 6);
+ }
+
+ fb_drawimage();
+@@ -522,6 +572,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+ if (!fifo_filename)
+ return EXIT_SUCCESS;
+
++ sig_block(SIGUSR1);
+ fp = xfopen_stdin(fifo_filename);
+ if (fp != stdin) {
+ // For named pipes, we want to support this:
+@@ -537,8 +588,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+ // and become an additional writer :)
+ open(fifo_filename, O_WRONLY); // errors are ignored
+ }
+-
+ fb_drawprogressbar(0);
++ sig_unblock(SIGUSR1);
++
+ // Block on read, waiting for some input.
+ // Use of <stdio.h> style I/O allows to correctly
+ // handle a case when we have many buffered lines
+@@ -553,12 +605,29 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
+ #if DEBUG
+ DEBUG_MESSAGE(itoa(num));
+ #endif
+- fb_drawprogressbar(num);
++ sig_block(SIGUSR1);
++ if (!G.do_not_draw)
++ fb_drawprogressbar(num);
++ sig_unblock(SIGUSR1);
+ }
+ free(num_buf);
+ }
+
+- if (bCursorOff) // restore cursor
++ if (G.silent_tty) {
++ usleep(100*1000);
++
++ ioctl(G.fd_tty_s, VT_RELDISP, 1);
++ ioctl(G.fd_tty_s, KDSETMODE, KD_TEXT);
++ vt.mode = VT_AUTO;
++ vt.waitv = 0;
++ ioctl(G.fd_tty_s, VT_SETMODE, &vt);
++ close(G.fd_tty_s);
++
++ xioctl(fd_tty0, VT_GETSTATE, &vtstat);
++ if (vtstat.v_active == G.silent_tty)
++ console_make_active(fd_tty0, active_vt);
++ ioctl(fd_tty0, VT_DISALLOCATE, (void *)(ptrdiff_t)G.silent_tty);
++ } else if (bCursorOff) // restore cursor
+ full_write(STDOUT_FILENO, "\033[?25h", 6);
+
+ return EXIT_SUCCESS;
+--
+2.13.2
+
diff --git a/system/busybox/0006-fbsplash-support-image-and-bar-alignment-and-positio.patch b/system/busybox/0006-fbsplash-support-image-and-bar-alignment-and-positio.patch
new file mode 100644
index 000000000..65c423178
--- /dev/null
+++ b/system/busybox/0006-fbsplash-support-image-and-bar-alignment-and-positio.patch
@@ -0,0 +1,185 @@
+From 64e2d2e495f82ef7ccc952bfa4216d1ff8ab3481 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Fri, 21 Nov 2014 16:06:34 +0200
+Subject: [PATCH 06/11] fbsplash: support image and bar alignment and
+ positioning
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Timo Teräs <timo.teras@iki.fi>
+---
+ miscutils/fbsplash.c | 91 +++++++++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 76 insertions(+), 15 deletions(-)
+
+diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
+index ec5947314..34bbf81f5 100644
+--- a/miscutils/fbsplash.c
++++ b/miscutils/fbsplash.c
+@@ -53,6 +53,7 @@
+ //usage: "\n -c Hide cursor"
+ //usage: "\n -d Framebuffer device (default /dev/fb0)"
+ //usage: "\n -i Config file (var=value):"
++//usage: "\n IMAGE_ALIGN"
+ //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT"
+ //usage: "\n BAR_R,BAR_G,BAR_B"
+ //usage: "\n -f Control pipe (else exit after drawing image)"
+@@ -71,13 +72,38 @@
+ /* If you want logging messages on /tmp/fbsplash.log... */
+ #define DEBUG 0
+
++enum {
++ image_align,
++
++ image_posx,
++ image_posy,
++ bar_width,
++ bar_height,
++ bar_posx,
++ bar_posy,
++ bar_colr,
++ bar_colg,
++ bar_colb,
++
++ debug
++};
++
++#define nimage_align ns[image_align]
++#define nbar_width ns[bar_width]
++#define nbar_height ns[bar_height]
++#define nbar_posx ns[bar_posx]
++#define nbar_posy ns[bar_posy]
++#define nbar_colr ns[bar_colr]
++#define nbar_colg ns[bar_colg]
++#define nbar_colb ns[bar_colb]
++
+ struct globals {
+ #if DEBUG
+ bool bdebug_messages; // enable/disable logging
+ FILE *logfile_fd; // log file
+ #endif
+ unsigned char *addr; // pointer to framebuffer memory
+- unsigned ns[7]; // n-parameters
++ unsigned ns[debug+1]; // n-parameters
+ const char *image_filename;
+ int silent_tty, fd_tty_s;
+ bool do_not_draw;
+@@ -94,14 +120,6 @@ struct globals {
+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ } while (0)
+
+-#define nbar_width ns[0] // progress bar width
+-#define nbar_height ns[1] // progress bar height
+-#define nbar_posx ns[2] // progress bar horizontal position
+-#define nbar_posy ns[3] // progress bar vertical position
+-#define nbar_colr ns[4] // progress bar color red component
+-#define nbar_colg ns[5] // progress bar color green component
+-#define nbar_colb ns[6] // progress bar color blue component
+-
+ #if DEBUG
+ #define DEBUG_MESSAGE(strMessage, args...) \
+ if (G.bdebug_messages) { \
+@@ -382,7 +400,7 @@ static void fb_drawimage(void)
+ FILE *theme_file;
+ char *read_ptr;
+ unsigned char *pixline;
+- unsigned i, j, width, height, line_size;
++ int i, j, width, height, line_size, xoffs, yoffs, xstart;
+
+ if (LONE_DASH(G.image_filename)) {
+ theme_file = stdin;
+@@ -432,18 +450,46 @@ static void fb_drawimage(void)
+ line_size = width*3;
+ pixline = xmalloc(line_size);
+
++#if 0
+ if (width > G.scr_var.xres)
+ width = G.scr_var.xres;
+ if (height > G.scr_var.yres)
+ height = G.scr_var.yres;
+- for (j = 0; j < height; j++) {
++#endif
++
++ xoffs = yoffs = 0;
++ switch (G.nimage_align % 3) {
++ case 1: xoffs = (G.scr_var.xres - width) / 2; break;
++ case 2: xoffs = G.scr_var.xres - width; break;
++ }
++ xstart = 0;
++ if (xoffs < 0) {
++ xstart = -xoffs;
++ width -= xstart;
++ xoffs = 0;
++ }
++ xoffs *= G.bytes_per_pixel;
++ if (width > G.scr_var.xres)
++ width = G.scr_var.xres;
++
++ switch (G.nimage_align / 3) {
++ case 1: yoffs = (G.scr_var.yres - height) / 2; break;
++ case 2: yoffs = G.scr_var.yres - height; break;
++ }
++
++ for (j = 0; j < height && yoffs < G.scr_var.yres; j++, yoffs++) {
+ unsigned char *pixel;
+ unsigned char *src;
+
+ if (fread(pixline, 1, line_size, theme_file) != line_size)
+ bb_error_msg_and_die("bad PPM file '%s'", G.image_filename);
++
++ if (yoffs < 0)
++ continue;
++
+ pixel = pixline;
+- src = G.addr + j * G.scr_fix.line_length;
++ src = G.addr + yoffs * G.scr_fix.line_length + xoffs;
++
+ for (i = 0; i < width; i++) {
+ unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]);
+ fb_write_pixel(src, thispix);
+@@ -462,9 +508,17 @@ static void fb_drawimage(void)
+ */
+ static void init(const char *cfg_filename)
+ {
++ static const char align_names[] ALIGN1 =
++ "LT\0" "CT\0" "RT\0"
++ "LM\0" "CM\0" "RM\0"
++ "LB\0" "CB\0" "RB\0";
+ static const char param_names[] ALIGN1 =
++ "IMAGE_ALIGN\0"
++
++ "IMAGE_X\0" "IMAGE_Y\0"
+ "BAR_WIDTH\0" "BAR_HEIGHT\0"
+ "BAR_LEFT\0" "BAR_TOP\0"
++
+ "BAR_R\0" "BAR_G\0" "BAR_B\0"
+ #if DEBUG
+ "DEBUG\0"
+@@ -474,14 +528,21 @@ static void init(const char *cfg_filename)
+ parser_t *parser = config_open2(cfg_filename, xfopen_stdin);
+ while (config_read(parser, token, 2, 2, "#=",
+ (PARSE_NORMAL | PARSE_MIN_DIE) & ~(PARSE_TRIM | PARSE_COLLAPSE))) {
+- unsigned val = xatoi_positive(token[1]);
++ unsigned val;
+ int i = index_in_strings(param_names, token[0]);
++
+ if (i < 0)
+ bb_error_msg_and_die("syntax error: %s", token[0]);
+- if (i >= 0 && i < 7)
++
++ if (i <= image_align)
++ val = index_in_strings(align_names, token[1]);
++ else
++ val = xatoi_positive(token[1]);
++
++ if (i < debug)
+ G.ns[i] = val;
+ #if DEBUG
+- if (i == 7) {
++ if (i == debug) {
+ G.bdebug_messages = val;
+ if (G.bdebug_messages)
+ G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");
+--
+2.13.2
+
diff --git a/system/busybox/0007-depmod-support-generating-kmod-binary-index-files.patch b/system/busybox/0007-depmod-support-generating-kmod-binary-index-files.patch
new file mode 100644
index 000000000..8b89902de
--- /dev/null
+++ b/system/busybox/0007-depmod-support-generating-kmod-binary-index-files.patch
@@ -0,0 +1,516 @@
+From ab4df89615fc2c5726b4ce55546e4dc098211a0b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Sun, 25 Oct 2015 22:21:41 +0200
+Subject: [PATCH 07/11] depmod: support generating kmod binary index files
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This allows to use busybox depmod, and run daemons
+using libkmod (or even kmod modprobe if needed).
+
+About +1500 bytes when enabled. This patch merges some
+depmod code paths, so when this is disabled it shrinks
+the code size a little bit.
+
+Signed-off-by: Timo Teräs <timo.teras@iki.fi>
+---
+ modutils/Config.src | 9 ++
+ modutils/depmod.c | 281 ++++++++++++++++++++++++++++++++++++++++++----------
+ modutils/modprobe.c | 15 ---
+ modutils/modutils.c | 31 ++++++
+ modutils/modutils.h | 16 +++
+ 5 files changed, 286 insertions(+), 66 deletions(-)
+
+diff --git a/modutils/Config.src b/modutils/Config.src
+index 9b76c83d2..9e3b9b71e 100644
+--- a/modutils/Config.src
++++ b/modutils/Config.src
+@@ -152,6 +152,15 @@ config FEATURE_MODUTILS_ALIAS
+
+ Say Y if unsure.
+
++config FEATURE_MODUTILS_BIN
++ bool "Support for the kmod .bin file format"
++ default n
++ depends on DEPMOD && !MODPROBE_SMALL
++ help
++ Generate kmod compatible binary index files for .dep, .alias,
++ .symbols and .builtin files. Allows mixing use of busybox
++ modutils and kmod (binaries and library).
++
+ config FEATURE_MODUTILS_SYMBOLS
+ bool "Support module.symbols file"
+ default y
+diff --git a/modutils/depmod.c b/modutils/depmod.c
+index b7965ebd2..73ba7d0f4 100644
+--- a/modutils/depmod.c
++++ b/modutils/depmod.c
+@@ -2,7 +2,7 @@
+ /*
+ * depmod - generate modules.dep
+ * Copyright (c) 2008 Bernhard Reutner-Fischer
+- * Copyrihgt (c) 2008 Timo Teras <timo.teras@iki.fi>
++ * Copyrihgt (c) 2008-2015 Timo Teras <timo.teras@iki.fi>
+ * Copyright (c) 2008 Vladimir Dronnikov
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+@@ -26,6 +26,24 @@
+ #include "modutils.h"
+ #include <sys/utsname.h> /* uname() */
+
++#define INDEX_MINCHAR 32
++#define INDEX_MAXCHAR 128
++
++typedef struct index_node {
++ char *prefix;
++ llist_t *values;
++ struct index_node *children[INDEX_MAXCHAR-INDEX_MINCHAR];
++} index_node;
++
++struct globals {
++ module_db db;
++ index_node *root_node;
++} FIX_ALIASING;
++#define G (*ptr_to_globals)
++#define INIT_G() do { \
++ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
++} while (0)
++
+ /*
+ * Theory of operation:
+ * - iterate over all modules and record their full path
+@@ -53,18 +71,12 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
+
+ for (ptr = image; ptr < image + len - 10; ptr++) {
+ if (is_prefixed_with(ptr, "depends=")) {
+- char *u;
+-
+ ptr += 8;
+- for (u = ptr; *u; u++)
+- if (*u == '-')
+- *u = '_';
+- ptr += string_to_llist(ptr, &e->deps, ",");
++ string_to_llist(replace_underscores(ptr), &e->deps, ",");
+ } else if (ENABLE_FEATURE_MODUTILS_ALIAS
+ && is_prefixed_with(ptr, "alias=")
+ ) {
+- llist_add_to(&e->aliases, xstrdup(ptr + 6));
+- ptr += strlen(ptr);
++ llist_add_to(&e->aliases, replace_underscores(xstrdup(ptr + 6)));
+ } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS
+ && is_prefixed_with(ptr, "__ksymtab_")
+ ) {
+@@ -74,9 +86,10 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
+ ) {
+ continue;
+ }
+- llist_add_to(&e->symbols, xstrdup(ptr));
+- ptr += strlen(ptr);
+- }
++ llist_add_to(&e->symbols, xasprintf("symbol:%s", ptr));
++ } else
++ continue;
++ ptr += strlen(ptr);
+ }
+ free(image);
+
+@@ -108,12 +121,6 @@ static void order_dep_list(module_db *modules, module_entry *start, llist_t *add
+ }
+ }
+
+-static void xfreopen_write(const char *file, FILE *f)
+-{
+- if (freopen(file, "w", f) == NULL)
+- bb_perror_msg_and_die("can't open '%s'", file);
+-}
+-
+ //usage:#if !ENABLE_MODPROBE_SMALL
+ //usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..."
+ //usage:#define depmod_full_usage "\n\n"
+@@ -167,6 +174,169 @@ enum {
+ OPT_C = (1 << 9), /* -C,--config etc_modules_conf: ignored */
+ };
+
++/* Support for the mod binary index generation */
++
++static void index_init(const char *filename)
++{
++ if (ENABLE_FEATURE_MODUTILS_BIN) {
++ index_node *n;
++
++ n = xzalloc(sizeof(index_node));
++ n->prefix = xstrdup("");
++ G.root_node = n;
++ }
++
++ if (filename && !(option_mask32 & OPT_n)) {
++ if (freopen(filename, "w", stdout) == NULL)
++ bb_perror_msg_and_die("can't open '%s'", filename);
++ }
++}
++
++static void index_add(const char *key, char *value, const char *prefix)
++{
++ if (prefix && *prefix)
++ printf("%s%s %s\n", prefix, key, value);
++ else if (prefix)
++ printf("%s\n", value);
++
++ if (ENABLE_FEATURE_MODUTILS_BIN) {
++ index_node *cur = G.root_node, *n;
++ unsigned i = 0, j, ch;
++
++ while (1) {
++ /* Ensure node->prefix is a prefix of &str[i].
++ * If it is not already, then we must split node. */
++ for (j = 0; cur->prefix[j]; j++) {
++ ch = cur->prefix[j];
++ if (ch != key[i+j]) {
++ /* New child is copy of node with prefix[j+1..N] */
++ n = xzalloc(sizeof(index_node));
++ n->prefix = xstrdup(&cur->prefix[j+1]);
++ n->values = cur->values;
++ memcpy(n->children, cur->children, sizeof(n->children));
++
++ /* Parent has prefix[0..j], child at prefix[j] */
++ cur->prefix[j] = '\0';
++ cur->values = NULL;
++ memset(cur->children, 0, sizeof(cur->children));
++ cur->children[ch-INDEX_MINCHAR] = n;
++ break;
++ }
++ }
++ i += j;
++
++ ch = key[i];
++ if (ch == 0)
++ break;
++
++ if (ch < INDEX_MINCHAR || ch >= INDEX_MAXCHAR)
++ bb_error_msg_and_die("bad module name");
++
++ ch -= INDEX_MINCHAR;
++ if (!cur->children[ch]) {
++ n = xzalloc(sizeof(index_node));
++ cur->children[ch] = n;
++ n->prefix = xstrdup(&key[i+1]);
++ cur = n;
++ break;
++ }
++
++ /* Descend into child node and continue */
++ cur = cur->children[ch];
++ i++;
++ }
++
++ llist_add_to(&cur->values, value);
++ }
++}
++
++static uint32_t index_write_node(FILE *out, index_node *n, void (*freeit)(void *data))
++{
++ uint32_t child_offs[INDEX_MAXCHAR-INDEX_MINCHAR];
++ uint32_t offset;
++ uint8_t first = 255, last = 0;
++ unsigned i;
++
++ for (i = 0; i < INDEX_MAXCHAR-INDEX_MINCHAR; i++) {
++ child_offs[i] = 0;
++ if (!n->children[i])
++ continue;
++ child_offs[i] = index_write_node(out, n->children[i], freeit);
++ if (first > INDEX_MAXCHAR)
++ first = i;
++ last = i;
++ }
++
++ offset = ftell(out);
++
++ if (n->prefix[0]) {
++ fputs(n->prefix, out);
++ fputc('\0', out);
++ offset |= INDEX_NODE_PREFIX;
++ }
++
++ if (first < INDEX_MAXCHAR) {
++ fputc(first + INDEX_MINCHAR, out);
++ fputc(last + INDEX_MINCHAR, out);
++ fwrite(child_offs + first, sizeof(uint32_t), last - first + 1, out);
++ offset |= INDEX_NODE_CHILDS;
++ }
++
++ if (n->values) {
++ const llist_t *v;
++ unsigned int cnt;
++ uint32_t u;
++
++ n->values = llist_rev(n->values);
++ for (v = n->values, cnt = 0; v != NULL; v = v->link, cnt++);
++ u = htonl(cnt);
++ fwrite(&u, sizeof(u), 1, out);
++ for (v = n->values, cnt = 0; v != NULL; v = v->link, cnt++) {
++ u = htonl(cnt);
++ fwrite(&u, sizeof(u), 1, out);
++ fputs(v->data, out);
++ fputc('\0', out);
++ }
++ offset |= INDEX_NODE_VALUES;
++ }
++
++ llist_free(n->values, freeit);
++ free(n->prefix);
++ free(n);
++
++ return htonl(offset);
++}
++
++static void index_dump(const char *filename, int deps_file)
++{
++ if (ENABLE_FEATURE_MODUTILS_BIN) {
++ FILE *out;
++ uint32_t header[3] = {
++ htonl(INDEX_MAGIC),
++ htonl(INDEX_VERSION),
++ };
++
++ if (option_mask32 & OPT_n)
++ filename = "/dev/null";
++ else
++ filename = xasprintf("tmp.%s.bin", filename);
++
++ out = xfopen_for_write(filename);
++ fwrite(header, sizeof(uint32_t), 3, out);
++ header[2] = index_write_node(out, G.root_node, deps_file ? free : 0);
++ rewind(out);
++ G.root_node = NULL;
++ fwrite(header, sizeof(uint32_t), 3, out);
++ if (fclose(out)) {
++ remove(filename);
++ bb_error_msg_and_die(bb_msg_write_error);
++ }
++ /* .bin files are mmap'ed; not renaming it may crash
++ * long standing daemon using libkmod */
++ rename_or_warn(filename, filename + 4);
++ }
++}
++
+ int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+ int depmod_main(int argc UNUSED_PARAM, char **argv)
+ {
+@@ -178,6 +348,8 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
+ unsigned i;
+ int tmp;
+
++ INIT_G();
++
+ getopt32(argv, "aAb:eF:nruqC:", &moddir_base, NULL, NULL);
+ argv += optind;
+
+@@ -210,53 +382,60 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
+ }
+
+ /* Generate dependency and alias files */
+- if (!(option_mask32 & OPT_n))
+- xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
+-
++ index_init(CONFIG_DEFAULT_DEPMOD_FILE);
+ moddb_foreach_module(&modules, m, i) {
+- printf("%s:", m->name);
+-
++ char *buf = xasprintf("%s:", m->name);
+ order_dep_list(&modules, m, m->deps);
++
+ while (m->dnext != m) {
+ dep = m->dnext;
+- printf(" %s", dep->name);
+-
++ buf = gather_options_str(buf, dep->name);
+ /* unlink current entry */
+ dep->dnext->dprev = dep->dprev;
+ dep->dprev->dnext = dep->dnext;
+ dep->dnext = dep->dprev = dep;
+ }
+- bb_putchar('\n');
++ index_add(m->modname, buf, "");
+ }
+-
+-#if ENABLE_FEATURE_MODUTILS_ALIAS
+- if (!(option_mask32 & OPT_n))
+- xfreopen_write("modules.alias", stdout);
+- moddb_foreach_module(&modules, m, i) {
+- while (m->aliases) {
+- /*
+- * Last word used to be a basename
+- * (filename with path and .ko.* stripped)
+- * at the time of module-init-tools 3.4.
+- * kmod v.12 uses module name, i.e., s/-/_/g.
+- */
+- printf("alias %s %s\n",
+- (char*)llist_pop(&m->aliases),
+- m->modname);
++ index_dump(CONFIG_DEFAULT_DEPMOD_FILE, 1);
++
++ if (ENABLE_FEATURE_MODUTILS_ALIAS) {
++ index_init("modules.alias");
++ moddb_foreach_module(&modules, m, i) {
++ while (m->aliases) {
++ /*
++ * Last word used to be a basename
++ * (filename with path and .ko.* stripped)
++ * at the time of module-init-tools 3.4.
++ * kmod v.12 uses module name, i.e., s/-/_/g.
++ */
++ index_add((char*)llist_pop(&m->aliases), m->modname, "alias ");
++ }
+ }
++ index_dump("modules.alias", 0);
+ }
+-#endif
+-#if ENABLE_FEATURE_MODUTILS_SYMBOLS
+- if (!(option_mask32 & OPT_n))
+- xfreopen_write("modules.symbols", stdout);
+- moddb_foreach_module(&modules, m, i) {
+- while (m->symbols) {
+- printf("alias symbol:%s %s\n",
+- (char*)llist_pop(&m->symbols),
+- m->modname);
++ if (ENABLE_FEATURE_MODUTILS_SYMBOLS) {
++ index_init("modules.symbols");
++ moddb_foreach_module(&modules, m, i) {
++ while (m->symbols) {
++ index_add((char*)llist_pop(&m->symbols), m->modname, "alias ");
++ }
++ }
++ index_dump("modules.symbols", 0);
++ }
++ if (ENABLE_FEATURE_MODUTILS_BIN) {
++ char line[PATH_MAX], modname[MODULE_NAME_LEN];
++ FILE *in;
++
++ index_init(NULL);
++ in = xfopen_for_read("modules.builtin");
++ while (fgets(line, sizeof(line), in) != NULL) {
++ filename2modname(line, modname);
++ index_add(modname, (char *) "", 0);
+ }
++ fclose(in);
++ index_dump("modules.builtin", 0);
+ }
+-#endif
+
+ if (ENABLE_FEATURE_CLEAN_UP)
+ moddb_free(&modules);
+diff --git a/modutils/modprobe.c b/modutils/modprobe.c
+index 51ede9204..d1fcc0b7f 100644
+--- a/modutils/modprobe.c
++++ b/modutils/modprobe.c
+@@ -192,21 +192,6 @@ struct globals {
+
+ static int read_config(const char *path);
+
+-static char *gather_options_str(char *opts, const char *append)
+-{
+- /* Speed-optimized. We call gather_options_str many times. */
+- if (append) {
+- if (opts == NULL) {
+- opts = xstrdup(append);
+- } else {
+- int optlen = strlen(opts);
+- opts = xrealloc(opts, optlen + strlen(append) + 2);
+- sprintf(opts + optlen, " %s", append);
+- }
+- }
+- return opts;
+-}
+-
+ static struct module_entry *get_or_add_modentry(const char *module)
+ {
+ return moddb_get_or_create(&G.db, module);
+diff --git a/modutils/modutils.c b/modutils/modutils.c
+index 6f7cd9721..257089af4 100644
+--- a/modutils/modutils.c
++++ b/modutils/modutils.c
+@@ -66,6 +66,21 @@ void FAST_FUNC moddb_free(module_db *db)
+ }
+ }
+
++char * FAST_FUNC gather_options_str(char *opts, const char *append)
++{
++ /* Speed-optimized. We call gather_options_str many times. */
++ if (append) {
++ if (opts == NULL) {
++ opts = xstrdup(append);
++ } else {
++ int optlen = strlen(opts);
++ opts = xrealloc(opts, optlen + strlen(append) + 2);
++ sprintf(opts + optlen, " %s", append);
++ }
++ }
++ return opts;
++}
++
+ void FAST_FUNC replace(char *s, char what, char with)
+ {
+ while (*s) {
+@@ -75,6 +90,22 @@ void FAST_FUNC replace(char *s, char what, char with)
+ }
+ }
+
++char* FAST_FUNC replace_underscores(char *s)
++{
++ int i;
++ for (i = 0; s[i]; i++) {
++ switch (s[i]) {
++ case '-':
++ s[i] = '_';
++ break;
++ case '[':
++ i += strcspn(&s[i], "]");
++ break;
++ }
++ }
++ return s;
++}
++
+ int FAST_FUNC string_to_llist(char *string, llist_t **llist, const char *delim)
+ {
+ char *tok;
+diff --git a/modutils/modutils.h b/modutils/modutils.h
+index 4a702e97c..73e816028 100644
+--- a/modutils/modutils.h
++++ b/modutils/modutils.h
+@@ -18,6 +18,20 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+ #define MODULE_NAME_LEN 256
+ #define MODULE_HASH_SIZE 256
+
++/* .bin index format definitions */
++#define INDEX_MAGIC 0xB007F457
++#define INDEX_VERSION_MAJOR 0x0002
++#define INDEX_VERSION_MINOR 0x0001
++#define INDEX_VERSION ((INDEX_VERSION_MAJOR<<16)|INDEX_VERSION_MINOR)
++
++enum node_offset {
++ INDEX_NODE_FLAGS = 0xF0000000, /* Flags in high nibble */
++ INDEX_NODE_PREFIX = 0x80000000,
++ INDEX_NODE_VALUES = 0x40000000,
++ INDEX_NODE_CHILDS = 0x20000000,
++ INDEX_NODE_MASK = 0x0FFFFFFF, /* Offset value */
++};
++
+ typedef struct module_entry {
+ struct module_entry *next;
+ char *name, *modname;
+@@ -47,7 +61,9 @@ module_entry *moddb_get(module_db *db, const char *s) FAST_FUNC;
+ module_entry *moddb_get_or_create(module_db *db, const char *s) FAST_FUNC;
+ void moddb_free(module_db *db) FAST_FUNC;
+
++char *gather_options_str(char *opts, const char *append) FAST_FUNC;
+ void replace(char *s, char what, char with) FAST_FUNC;
++char *replace_underscores(char *s) FAST_FUNC;
+ int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
+ char *filename2modname(const char *filename, char *modname) FAST_FUNC;
+ #if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
+--
+2.13.2
+
diff --git a/system/busybox/0008-diff-add-support-for-no-dereference.patch b/system/busybox/0008-diff-add-support-for-no-dereference.patch
new file mode 100644
index 000000000..95063a863
--- /dev/null
+++ b/system/busybox/0008-diff-add-support-for-no-dereference.patch
@@ -0,0 +1,63 @@
+From d70be9891718ffb94ea9946cc3540b1b62eced77 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 25 Jul 2014 15:28:33 +0200
+Subject: [PATCH 08/11] diff: add support for --no-dereference
+
+Add flag for not following symlinks when recursing
+
+function old new delta
+.rodata 7934 7967 +33
+diff_longopts 253 270 +17
+packed_usage 1704 1720 +16
+diff_main 1665 1662 -3
+------------------------------------------------------------------------------
+(add/remove: 0/0 grow/shrink: 3/1 up/down: 66/-3) Total: 63 bytes
+
+Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
+---
+ editors/diff.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/editors/diff.c b/editors/diff.c
+index 7687518f3..f07cafb19 100644
+--- a/editors/diff.c
++++ b/editors/diff.c
+@@ -115,6 +115,9 @@
+ //usage: "\n -N Treat absent files as empty"
+ //usage: "\n -q Output only whether files differ"
+ //usage: "\n -r Recurse"
++//usage: IF_LONG_OPTS(
++//usage: "\n --no-dereference Don't follow symlinks"
++//usage: )
+ //usage: "\n -S Start with FILE when comparing directories"
+ //usage: "\n -T Make tabs line up by prefixing a tab when necessary"
+ //usage: "\n -s Report when two files are the same"
+@@ -156,6 +159,7 @@ enum { /* Commandline flags */
+ FLAG_p, /* not implemented */
+ FLAG_B,
+ FLAG_E, /* not implemented */
++ FLAG_no_deref,
+ };
+ #define FLAG(x) (1 << FLAG_##x)
+
+@@ -869,7 +873,8 @@ static void diffdir(char *p[2], const char *s_start)
+ * Using list.len to specify its length,
+ * add_to_dirlist will remove it. */
+ list[i].len = strlen(p[i]);
+- recursive_action(p[i], ACTION_RECURSE | ACTION_FOLLOWLINKS,
++ recursive_action(p[i], ACTION_RECURSE |
++ ((option_mask32 & FLAG(no_deref)) ? 0 : ACTION_FOLLOWLINKS),
+ add_to_dirlist, skip_dir, &list[i], 0);
+ /* Sort dl alphabetically.
+ * GNU diff does this ignoring any number of trailing dots.
+@@ -966,6 +971,7 @@ static const char diff_longopts[] ALIGN1 =
+ "report-identical-files\0" No_argument "s"
+ "starting-file\0" Required_argument "S"
+ "minimal\0" No_argument "d"
++ "no-dereference\0" No_argument "\xff"
+ ;
+ #endif
+
+--
+2.13.2
+
diff --git a/system/busybox/0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch b/system/busybox/0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch
new file mode 100644
index 000000000..2624675c4
--- /dev/null
+++ b/system/busybox/0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch
@@ -0,0 +1,104 @@
+From 1cb2e911c47f1b798ee610deabbea21ba6fb6961 Mon Sep 17 00:00:00 2001
+From: Shiz <hi@shiz.me>
+Date: Mon, 8 May 2017 23:09:13 +0200
+Subject: [PATCH 09/11] sysklogd: add -Z option to adjust message timezones
+
+Some syslog() implementations like musl's[1] always send timestamps in UTC.
+This change adds a new option to syslogd, -Z, to assume incoming timestamps
+are always UTC and adjust them to the local timezone (of the syslogd) before
+logging.
+
+[1]: http://www.openwall.com/lists/musl/2014/01/29/1
+
+Signed-off-by: Shiz <hi@shiz.me>
+---
+ sysklogd/syslogd.c | 23 +++++++++++++++++++----
+ 1 file changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
+index d64ff278f..159336ed7 100644
+--- a/sysklogd/syslogd.c
++++ b/sysklogd/syslogd.c
+@@ -122,6 +122,7 @@
+ //usage: "(this version of syslogd ignores /etc/syslog.conf)\n"
+ //usage: )
+ //usage: "\n -n Run in foreground"
++//usage: "\n -Z Adjust incoming UTC times to local time"
+ //usage: IF_FEATURE_REMOTE_LOG(
+ //usage: "\n -R HOST[:PORT] Log to HOST:PORT (default PORT:514)"
+ //usage: "\n -L Log locally and via network (default is network only if -R)"
+@@ -233,6 +234,8 @@ typedef struct logRule_t {
+ /*int markInterval;*/ \
+ /* level of messages to be logged */ \
+ int logLevel; \
++ /* whether to adjust message timezone */\
++ int adjustTimezone; \
+ IF_FEATURE_ROTATE_LOGFILE( \
+ /* max size of file before rotation */ \
+ unsigned logFileSize; \
+@@ -316,6 +319,7 @@ enum {
+ OPTBIT_outfile, // -O
+ OPTBIT_loglevel, // -l
+ OPTBIT_small, // -S
++ OPTBIT_adjusttz, // -Z
+ IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize ,) // -s
+ IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt ,) // -b
+ IF_FEATURE_REMOTE_LOG( OPTBIT_remotelog ,) // -R
+@@ -330,6 +334,7 @@ enum {
+ OPT_outfile = 1 << OPTBIT_outfile ,
+ OPT_loglevel = 1 << OPTBIT_loglevel,
+ OPT_small = 1 << OPTBIT_small ,
++ OPT_adjusttz = 1 << OPTBIT_adjusttz,
+ OPT_filesize = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize )) + 0,
+ OPT_rotatecnt = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt )) + 0,
+ OPT_remotelog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_remotelog )) + 0,
+@@ -339,7 +344,7 @@ enum {
+ OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0,
+ OPT_kmsg = IF_FEATURE_KMSG_SYSLOG( (1 << OPTBIT_kmsg )) + 0,
+ };
+-#define OPTION_STR "m:nO:l:S" \
++#define OPTION_STR "m:nO:l:SZ" \
+ IF_FEATURE_ROTATE_LOGFILE("s:" ) \
+ IF_FEATURE_ROTATE_LOGFILE("b:" ) \
+ IF_FEATURE_REMOTE_LOG( "R:*") \
+@@ -815,17 +820,23 @@ static void timestamp_and_log(int pri, char *msg, int len)
+ {
+ char *timestamp;
+ time_t now;
++ struct tm nowtm = { .tm_isdst = 0 };
+
+ /* Jan 18 00:11:22 msg... */
+ /* 01234567890123456 */
+ if (len < 16 || msg[3] != ' ' || msg[6] != ' '
+ || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
+ ) {
+- time(&now);
++ now = time(NULL);
+ timestamp = ctime(&now) + 4; /* skip day of week */
+ } else {
+- now = 0;
+- timestamp = msg;
++ if (G.adjustTimezone && strptime(msg, "%b %e %T", &nowtm)) {
++ now = mktime(&nowtm) - timezone;
++ timestamp = ctime(&now) + 4; /* skip day of week */
++ } else {
++ now = 0;
++ timestamp = msg;
++ }
+ msg += 16;
+ }
+ timestamp[15] = '\0';
+@@ -1130,6 +1141,10 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv)
+ if (opts & OPT_loglevel) // -l
+ G.logLevel = xatou_range(opt_l, 1, 8);
+ //if (opts & OPT_small) // -S
++ if (opts & OPT_adjusttz) { // -Z
++ G.adjustTimezone = 1;
++ tzset();
++ }
+ #if ENABLE_FEATURE_ROTATE_LOGFILE
+ if (opts & OPT_filesize) // -s
+ G.logFileSize = xatou_range(opt_s, 0, INT_MAX/1024) * 1024;
+--
+2.13.2
+
diff --git a/system/busybox/0010-udhcpc-Don-t-background-if-n-is-given.patch b/system/busybox/0010-udhcpc-Don-t-background-if-n-is-given.patch
new file mode 100644
index 000000000..75fe62dfd
--- /dev/null
+++ b/system/busybox/0010-udhcpc-Don-t-background-if-n-is-given.patch
@@ -0,0 +1,45 @@
+From a663349a9ae6d62bfad1243a8781fb254065b480 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 6 Jul 2017 13:39:15 +0200
+Subject: [PATCH 10/11] udhcpc: Don't background if -n is given
+
+we need add -b to our udhcpc options to prevent boot forever if there are no
+dhcp server. We also need a way for users to disable this behavior by making
+it possible to set -n option at runtime.
+---
+ networking/udhcp/dhcpc.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
+index 43aac1b85..bf53dd559 100644
+--- a/networking/udhcp/dhcpc.c
++++ b/networking/udhcp/dhcpc.c
+@@ -1504,19 +1504,19 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
+ }
+ leasefail:
+ udhcp_run_script(NULL, "leasefail");
++ if (opt & OPT_n) { /* abort if no lease */
++ bb_error_msg("no lease, failing");
++ retval = 1;
++ goto ret;
++ }
+ #if BB_MMU /* -b is not supported on NOMMU */
+ if (opt & OPT_b) { /* background if no lease */
+ bb_error_msg("no lease, forking to background");
+ client_background();
+ /* do not background again! */
+ opt = ((opt & ~OPT_b) | OPT_f);
+- } else
+-#endif
+- if (opt & OPT_n) { /* abort if no lease */
+- bb_error_msg("no lease, failing");
+- retval = 1;
+- goto ret;
+ }
++#endif
+ /* wait before trying again */
+ timeout = tryagain_timeout;
+ packet_num = 0;
+--
+2.13.2
+
diff --git a/system/busybox/0011-testsuite-fix-cpio-tests.patch b/system/busybox/0011-testsuite-fix-cpio-tests.patch
new file mode 100644
index 000000000..a6eb803de
--- /dev/null
+++ b/system/busybox/0011-testsuite-fix-cpio-tests.patch
@@ -0,0 +1,82 @@
+From 9a522cf388e321b47f9462bbbd7726323095f8db Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 6 Jul 2017 13:41:32 +0200
+Subject: [PATCH 11/11] testsuite: fix cpio tests
+
+The cpio tests don't search for the right output line correctly,
+using a hardcoded tail offset. Instead, grep for the file entry
+just added.
+
+The reverse-hunk patch tests seem to get the output order wrong,
+and the tests pass when this is corrected.
+---
+ testsuite/cpio.tests | 6 +++---
+ testsuite/patch.tests | 4 ++--
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests
+index 88ec086b6..40f72c363 100755
+--- a/testsuite/cpio.tests
++++ b/testsuite/cpio.tests
+@@ -129,7 +129,7 @@ SKIP=
+
+ optional FEATURE_CPIO_O
+ testing "cpio uses by default uid/gid" \
+-"echo $0 | cpio -o -H newc | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \
++"echo $0 | cpio -o -H newc | cpio -tv 2>&1 | grep -F $(basename $0) | awk ' { print \$2 } '; echo \$?" \
+ "\
+ $user/$group
+ 0
+@@ -138,7 +138,7 @@ SKIP=
+
+ optional FEATURE_CPIO_O
+ testing "cpio -R with create" \
+-"echo $0 | cpio -o -H newc -R 1234:5678 | cpio -tv 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \
++"echo $0 | cpio -o -H newc -R 1234:5678 | cpio -tv 2>&1 | grep -F $(basename $0) | awk ' { print \$2 } '; echo \$?" \
+ "\
+ 1234/5678
+ 0
+@@ -147,7 +147,7 @@ SKIP=
+
+ optional FEATURE_CPIO_O
+ testing "cpio -R with extract" \
+-"echo $0 | cpio -o -H newc | cpio -tv -R 8765:4321 2>&1 | tail -n +2 | awk ' { print \$2 } '; echo \$?" \
++"echo $0 | cpio -o -H newc | cpio -tv -R 8765:4321 2>&1 | grep -F $(basename $0) | awk ' { print \$2 } '; echo \$?" \
+ "\
+ 8765/4321
+ 0
+diff --git a/testsuite/patch.tests b/testsuite/patch.tests
+index 39205242c..1d48e90be 100755
+--- a/testsuite/patch.tests
++++ b/testsuite/patch.tests
+@@ -75,12 +75,12 @@ zxc
+ testing "patch detects already applied hunk" \
+ 'patch 2>&1; echo $?; cat input' \
+ "\
++patching file input
+ Possibly reversed hunk 1 at 4
+ Hunk 1 FAILED 1/1.
+ abc
+ +def
+ 123
+-patching file input
+ 1
+ abc
+ def
+@@ -103,12 +103,12 @@ def
+ testing "patch detects already applied hunk at the EOF" \
+ 'patch 2>&1; echo $?; cat input' \
+ "\
++patching file input
+ Possibly reversed hunk 1 at 4
+ Hunk 1 FAILED 1/1.
+ abc
+ 123
+ +456
+-patching file input
+ 1
+ abc
+ 123
+--
+2.13.2
+
diff --git a/system/busybox/0012-microcom-segfault.patch b/system/busybox/0012-microcom-segfault.patch
new file mode 100644
index 000000000..4789079b3
--- /dev/null
+++ b/system/busybox/0012-microcom-segfault.patch
@@ -0,0 +1,31 @@
+From fd8a0116a29ea4014fac7fbdba2636fc7b51ffc2 Mon Sep 17 00:00:00 2001
+From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
+Date: Wed, 2 Aug 2017 23:36:08 +0200
+Subject: [PATCH] miscutils/microcom: Fixed segfault
+
+microcom did not check if required parameter TTY is present. Thus,
+bb_basename() was called with a NULL pointer if TTY was missing.
+This commit adds the missing check.
+---
+ miscutils/microcom.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/miscutils/microcom.c b/miscutils/microcom.c
+index 14b9f3baf..38f6425c1 100644
+--- a/miscutils/microcom.c
++++ b/miscutils/microcom.c
+@@ -78,6 +78,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
+ // argc -= optind;
+ argv += optind;
+
++ if (*argv == NULL){
++ bb_show_usage();
++ return EXIT_FAILURE;
++ }
++
+ // try to create lock file in /var/lock
+ device_lock_file = (char *)bb_basename(argv[0]);
+ device_lock_file = xasprintf("/var/lock/LCK..%s", device_lock_file);
+--
+2.13.3
+
diff --git a/system/busybox/APKBUILD b/system/busybox/APKBUILD
new file mode 100644
index 000000000..0c09b1126
--- /dev/null
+++ b/system/busybox/APKBUILD
@@ -0,0 +1,202 @@
+# Contributor: Łukasz Jendrysik <scadu@yandex.com>
+# Contributor: Oliver Smith <ollieparanoid@bitmessage.ch>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=busybox
+pkgver=1.27.2
+pkgrel=4
+pkgdesc="Size optimized toolbox of many common UNIX utilities"
+url=http://busybox.net
+arch="all"
+license="GPL2"
+makedepends_build=""
+makedepends_host="linux-headers"
+makedepends="$makedepends_build $makedepends_host"
+checkdepends="zip"
+provides="/bin/sh /sbin/init"
+install="$pkgname.post-install $pkgname.post-upgrade
+ $pkgname-extras.post-install $pkgname-extras.pre-deinstall"
+subpackages="$pkgname-static $pkgname-suid $pkgname-extras $pkgname-binsh"
+options="suid !check"
+triggers="busybox.trigger=/bin:/usr/bin:/sbin:/usr/sbin:/lib/modules/*"
+source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
+ 0001-ash-add-support-for-command_not_found_handle-hook-fu.patch
+
+ 0001-ash-exec-busybox.static.patch
+ 0002-app-location-for-cpio-vi-and-lspci.patch
+ 0003-udhcpc-set-default-discover-retries-to-5.patch
+ 0004-ping-make-ping-work-without-root-privileges.patch
+ 0005-fbsplash-support-console-switching.patch
+ 0006-fbsplash-support-image-and-bar-alignment-and-positio.patch
+ 0007-depmod-support-generating-kmod-binary-index-files.patch
+ 0008-diff-add-support-for-no-dereference.patch
+ 0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch
+ 0010-udhcpc-Don-t-background-if-n-is-given.patch
+ 0011-testsuite-fix-cpio-tests.patch
+ 0012-microcom-segfault.patch
+
+ top-buffer-overflow.patch
+
+ acpid.logrotate
+ busyboxconfig
+ busyboxconfig-extras
+ bbsuid.c
+ dad.if-up
+ nologin.c
+ "
+builddir="$srcdir"/$pkgname-$pkgver
+
+_staticdir="$srcdir"/build-static
+_dyndir="$srcdir"/build-dynamic
+_dyndir_extras="$srcdir"/build-dynamic-extras
+_config="$srcdir"/busyboxconfig
+_config_extras="$srcdir"/busyboxconfig-extras
+
+prepare() {
+ default_prepare
+
+ cd "$builddir"
+ mkdir -p "$_staticdir" "$_dyndir" "$_dyndir_extras"
+ cp "$srcdir"/nologin.c loginutils/
+}
+
+build() {
+ # build bbsuid
+ msg "Building bbsuid"
+ ${CC:-${CROSS_COMPILE}gcc} ${CPPFLAGS} ${CFLAGS} \
+ ${LDFLAGS} "$srcdir"/bbsuid.c -o "$_dyndir"/bbsuid
+
+ # build dynamic
+ cd "$_dyndir"
+ msg "Building dynamic busybox"
+ cp "$_config" .config
+ [ "$CLIBC" = musl ] && sed -i \
+ -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \
+ .config
+ make -C "$builddir" O="$PWD" silentoldconfig
+ make
+
+ # build dynamic (extras)
+ cd "$_dyndir_extras"
+ msg "Building dynamic busybox-extras"
+ cp "$_config_extras" .config
+ [ "$CLIBC" = musl ] && sed -i \
+ -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \
+ .config
+ make -C "$builddir" O="$PWD" silentoldconfig
+ make
+
+ # build static
+ cd "$_staticdir"
+ msg "Building static busybox"
+ sed -e "s/.*CONFIG_PIE.*/\# CONFIG_PIE is not set/" \
+ -e "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" \
+ "$_config" > .config
+ # musl does not support GNU regex
+ [ "$CLIBC" = musl ] && sed -i \
+ -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \
+ .config
+ make -C "$builddir" O="$PWD" silentoldconfig
+ make
+ mv busybox busybox.static
+}
+
+check() {
+ cd "$_dyndir"
+ SKIP_KNOWN_BUGS=1 make -C "$builddir" O="$PWD" V=1 check
+
+ cd "$_dyndir_extras"
+ SKIP_KNOWN_BUGS=1 make -C "$builddir" O="$PWD" V=1 check
+}
+
+package() {
+ cd "$_dyndir"
+ mkdir -p "$pkgdir"/usr/sbin "$pkgdir"/usr/bin "$pkgdir"/tmp \
+ "$pkgdir"/var/cache/misc "$pkgdir"/bin "$pkgdir"/sbin
+ chmod 1777 "$pkgdir"/tmp
+ install -m755 busybox "$pkgdir"/bin/busybox || return 1
+ # we need /bin/sh to be able to execute post-install
+ ln -s /bin/busybox "$pkgdir"/bin/sh
+
+ #ifupdown needs those dirs to be present
+ mkdir -p \
+ "$pkgdir"/etc/network/if-down.d \
+ "$pkgdir"/etc/network/if-post-down.d \
+ "$pkgdir"/etc/network/if-post-up.d \
+ "$pkgdir"/etc/network/if-pre-down.d \
+ "$pkgdir"/etc/network/if-pre-up.d \
+ "$pkgdir"/etc/network/if-up.d
+ install -m775 "$srcdir"/dad.if-up "$pkgdir"/etc/network/if-up.d/dad
+
+ install -Dm644 "$srcdir"/acpid.logrotate \
+ "$pkgdir/etc/logrotate.d/acpid"
+
+ mkdir -p "$pkgdir"/var/lib/udhcpd
+ install -Dm644 "$builddir"/examples/udhcp/udhcpd.conf \
+ "$pkgdir"/etc/udhcpd.conf
+ cat >"$pkgdir"/etc/securetty <<EOF
+console
+tty1
+tty2
+tty3
+tty4
+tty5
+tty6
+tty7
+tty8
+tty9
+tty10
+tty11
+EOF
+}
+
+extras() {
+ pkgdesc="Additional binaries of Busybox"
+ depends="${pkgname}"
+ install -Dm755 "$_dyndir_extras"/busybox "$subpkgdir"/bin/busybox-extras
+}
+
+suid() {
+ pkgdesc="suid binaries of Busybox"
+ depends="${pkgname}"
+
+ cd "$_dyndir"
+ mkdir -p "$subpkgdir"/bin
+ install -m4111 bbsuid "$subpkgdir"/bin/bbsuid
+}
+
+binsh() {
+ pkgdesc="Provide /bin/sh with BusyBox ash"
+ depends="${pkgname}"
+
+ mkdir -p "$subpkgdir"/bin
+ mv "$pkgdir"/bin/sh "$subpkgdir"/bin
+}
+
+static() {
+ pkgdesc="Statically linked Busybox"
+ mkdir -p "$subpkgdir"/bin
+ install -m755 "$_staticdir"/busybox.static \
+ "$subpkgdir"/bin/busybox.static
+}
+
+sha512sums="d99e86b652562ebe1a5d50e1ba3877a1d1612997c17cb8d8e4212da181211a9b741a881cb051f14cb3ee8aea40226cf2cde80a076baed265d3bc0a4e96a5031c busybox-1.27.2.tar.bz2
+dc08288c8e9e29d36be7174d58f3bee2d0508465977fb40d39807aa0b03149f7814f8cfed113d0a7589ef49890beb1805ef00f0d37b563447fe875e3cff08d1c 0001-ash-add-support-for-command_not_found_handle-hook-fu.patch
+1930775839354a63c30970f0d52d00cfd3a8f6b9f48d6de45ea7d2478d080bde7193c1c2cce026dc7337d9ecf0b65f5ff1dd4351c1eb195e6f0c0c5126f10511 0001-ash-exec-busybox.static.patch
+a756aa89c4602cd091df0052e2e3d7b45a359fbfe953b70aa3029e3eeb8e5d1772cbf1525bb62df6ce6547f1e5605617195ddae336e1ffe41f5c58d524af6ba6 0002-app-location-for-cpio-vi-and-lspci.patch
+fc17ce9b12726e3449518692bf0d4906c36f091534706b5b91c910866bd8cd50d8f7d4b449d54eeed24ee656012a6ef04612bf092874e4b83b0723f852fdce0e 0003-udhcpc-set-default-discover-retries-to-5.patch
+dc0b660b60ef3028a4cc86f712e7f6d08ad7c00d27056f9978a2a103434f45edc7385d2c48eca5ee83efab8fc81735674bf1c40e78fb07a1b5d07ca9da37811a 0004-ping-make-ping-work-without-root-privileges.patch
+63838512679586eb6d83e7b7d3b1e318bb693b91dfb9675a48480e6623e03472b1aa7f86fb7e2ab9e8d6db7a9609b2bcf1c3c1de64fc7d73b65b4794cab87cbf 0005-fbsplash-support-console-switching.patch
+1afe261da507ca13869923033a4adbb3c22e512136cc4b771a2d14d0c25d8de6514cec1dd0363b0684410f0e6a274c3250c1ca8a8a839111f3ed16f800b1d403 0006-fbsplash-support-image-and-bar-alignment-and-positio.patch
+16804d38000bf4395ed2657c19ddf0a1414214db8d2e43541034d5a6db29f74c53c6d8fd28c4c865c7e87fa4a9b914d414e5a00430a261aeaa69ec86bf865780 0007-depmod-support-generating-kmod-binary-index-files.patch
+baac796f8aa96fbeab19f96eea7787ace5737b182f49e02f1b1e911d0a927ae14f3c334daad4241858617dc79607541b9ce66b367d0379b2cb32f67a1e9efc5b 0008-diff-add-support-for-no-dereference.patch
+d1c375184f806f7550bac5c82ab5471bdb8085d845172c973724b22af05ab3759b3ce982e088b4c45815ade56b9adfb7a677d0c180e077545ac7ec003c8aa7c4 0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch
+9b5143d0be615b1604d82007628d59a62721f1e61a63cca7a4ffa5e60fa8da102bfc21fa20cc35c2f5a0a24bc8013598f8eff5888f9d0f3bcfa796343b5f5a91 0010-udhcpc-Don-t-background-if-n-is-given.patch
+f4e00eb13fda752df13f300a7ed9b1320ca9f573c4309247f292c8710464d7be8740148f42e4aff16312335eadabce5a629dce4af58334b9199faf2fd658e4f9 0011-testsuite-fix-cpio-tests.patch
+a09a64b3bce8048c58a68dcd2dd9e63c911009c06195d6bb4e5aecfb5700e479c25b34635c60899127975fae32275ad51846ee75f840d612e00668ce9aba8322 0012-microcom-segfault.patch
+524e858b52cb31fb8d24e8c7f18606fff349aeab6a14da9cca3902641f6127980daed73c53586c6e8b41eecda06cdb29c40ff1dde2dc82a318c2649680458921 top-buffer-overflow.patch
+a9b1403c844c51934637215307dd9e2adb9458921047acff0d86dcf229b6e0027f4b2c6cdaa25a58407aad9d098fb5685d58eb5ff8d2aa3de4912cdea21fe54c acpid.logrotate
+02102f0764ffbec86e97ccab99b3a1e55ffa5b25aa2cdc1fe270d5b575610bdb50568574c7cbd05aba91b13151f84f536b44320c180051cbd77cf258e4fc89a4 busyboxconfig
+7759d1611ce72f7aa9e4afbd48f410806b3bd59701fe8a570675898c504c0e15f85bacbc1578f87345197844ee6175117d348acc4fe29a742b7ac96b84fe7386 busyboxconfig-extras
+e84087a453f8c9814951c9ad496cce19f8280b80a8ab6a1c8e21385f1facb17e987adc8d1d72c7cb463c04eb0cadd2bd6fb9b6f6c0067ddd21eeacf91ca42f32 bbsuid.c
+a1127c8a384294135e11500fde7ead33b73d24b11c21911b08447a4c4ef71d7a9965d6466f60f2da64e3b877213b0a3e924a5add3c5333ee3ecde8c2a91c5e02 dad.if-up
+4e7c291a70e879b74c0fc07c54a73ef50537d8be68fee6b2d409425c07afd2d67f9b6afcd8c33a7971014913cc5de85e45079681c9e77200c6cc2f34acfba6d2 nologin.c"
diff --git a/system/busybox/acpid.logrotate b/system/busybox/acpid.logrotate
new file mode 100644
index 000000000..a37763540
--- /dev/null
+++ b/system/busybox/acpid.logrotate
@@ -0,0 +1,8 @@
+/var/log/acpid.log {
+ missingok
+ notifempty
+ sharedscripts
+ postrotate
+ /etc/init.d/acpid --ifstarted restart || true
+ endscript
+}
diff --git a/system/busybox/bbsuid.c b/system/busybox/bbsuid.c
new file mode 100644
index 000000000..8be2671b1
--- /dev/null
+++ b/system/busybox/bbsuid.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2008 Natanael Copa <natanael.copa@gmail.com>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation. See http://www.gnu.org/ for details.
+ *
+ */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define BBSUID_PATH "/bin/bbsuid"
+
+const static char * applets[] = {
+ "/bin/mount",
+ "/bin/umount",
+ "/bin/su",
+ "/usr/bin/crontab",
+ "/usr/bin/passwd",
+ "/usr/bin/traceroute",
+ "/usr/bin/traceroute6",
+ "/usr/bin/vlock",
+ NULL
+};
+
+
+static const char *applet_from_path(const char *str)
+{
+ const char *p = strrchr(str, '/');
+ if (p == NULL)
+ p = str;
+ else
+ p++;
+ return p;
+}
+
+static int is_valid_applet(const char *str)
+{
+ int i;
+ for (i = 0; applets[i] != NULL; i++) {
+ const char *a = applet_from_path(applets[i]);
+ if (strcmp(applet_from_path(str), a) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+int exec_busybox(const char *app, int argc, char **argv)
+{
+ char **newargv = malloc((argc + 2) * sizeof(char *));
+ int i;
+ newargv[0] = "/bin/busybox";
+ newargv[1] = (char *)app;
+ for (i = 1; i < argc; i++)
+ newargv[i+1] = argv[i];
+ newargv[argc+1] = NULL;
+ execv(newargv[0], newargv);
+ perror(newargv[0]);
+ free(newargv);
+ return 1;
+}
+
+static int install_links(void)
+{
+ int i, r = 0;
+ /* we don't want others than root to install the symlinks */
+ if (getuid() != 0)
+ errx(1, "Only root can install symlinks");
+
+ for (i = 0; applets[i] != NULL; i++) {
+ const char *a = applets[i];
+ struct stat st;
+ if (lstat(a, &st) == 0 && S_ISLNK(st.st_mode))
+ unlink(a);
+ if (symlink(BBSUID_PATH, a) < 0)
+ r++;
+ }
+
+ return r;
+}
+
+int main(int argc, char **argv)
+{
+ const char *app = applet_from_path(argv[0]);
+
+ if (strcmp(app, "bbsuid") == 0) {
+ if (argc == 2 && strcmp(argv[1], "--install") == 0)
+ return install_links();
+ errx(1, "Use --install to install symlinks");
+ }
+
+ if (is_valid_applet(app))
+ return exec_busybox(app, argc, argv);
+
+ errx(1, "%s is not a valid applet", app);
+ return 1;
+}
+
diff --git a/system/busybox/busybox-extras.post-install b/system/busybox/busybox-extras.post-install
new file mode 100644
index 000000000..a0327a691
--- /dev/null
+++ b/system/busybox/busybox-extras.post-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Create all symlinks
+exec /bin/busybox-extras --install -s
diff --git a/system/busybox/busybox-extras.pre-deinstall b/system/busybox/busybox-extras.pre-deinstall
new file mode 100644
index 000000000..15461302c
--- /dev/null
+++ b/system/busybox/busybox-extras.pre-deinstall
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Remove all symlinks to busybox-extras
+cd /
+for link in $(busybox-extras --list --full); do
+ if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox-extras" ]; then
+ rm "$link"
+ fi
+done
diff --git a/system/busybox/busybox.post-install b/system/busybox/busybox.post-install
new file mode 100644
index 000000000..a986b2f76
--- /dev/null
+++ b/system/busybox/busybox.post-install
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# We need the symlinks early
+exec /bin/busybox --install -s
diff --git a/system/busybox/busybox.post-upgrade b/system/busybox/busybox.post-upgrade
new file mode 100644
index 000000000..291ed7a6d
--- /dev/null
+++ b/system/busybox/busybox.post-upgrade
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# remove links that has been relocated
+for link in /bin/install /bin/ip /bin/vi /usr/bin/lspci; do
+ if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
+ rm "$link"
+ fi
+done
+for link in /bin/ping /bin/ping6; do
+ if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/bbsuid" ]; then
+ rm "$link"
+ fi
+done
+
+# remove links of programs moved to busybox-extras
+for link in /usr/bin/telnet /usr/sbin/httpd /usr/bin/ftpget /usr/bin/ftpput \
+ /usr/sbin/ftpd /usr/bin/tftp /usr/sbin/fakeidentd /usr/sbin/dnsd \
+ /usr/sbin/inetd /usr/sbin/udhcpd; do
+ if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
+ rm "$link"
+ echo "NOTE: $link has been moved to the package 'busybox-extras'"
+ fi
+done
+
+# We need the symlinks early
+exec /bin/busybox --install -s
diff --git a/system/busybox/busybox.trigger b/system/busybox/busybox.trigger
new file mode 100644
index 000000000..e531a45b8
--- /dev/null
+++ b/system/busybox/busybox.trigger
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+do_bb_install=
+
+for i in "$@"; do
+ case "$i" in
+ /lib/modules/*)
+ if [ -d "$i" ]; then
+ /bin/busybox depmod ${i#/lib/modules/}
+ fi
+ ;;
+ *) do_bb_install=yes;;
+ esac
+done
+
+if [ -n "$do_bb_install" ]; then
+ [ -e /bin/bbsuid ] && /bin/bbsuid --install
+ [ -e /bin/busybox-extras ] && /bin/busybox-extras --install -s
+ /bin/busybox --install -s
+fi
diff --git a/system/busybox/busyboxconfig b/system/busybox/busyboxconfig
new file mode 100644
index 000000000..979646071
--- /dev/null
+++ b/system/busybox/busyboxconfig
@@ -0,0 +1,1138 @@
+#
+# Automatically generated make config: don't edit
+# Busybox version: 1.27.2
+# Fri Oct 27 21:22:08 2017
+#
+CONFIG_HAVE_DOT_CONFIG=y
+
+#
+# Busybox Settings
+#
+CONFIG_DESKTOP=y
+# CONFIG_EXTRA_COMPAT is not set
+# CONFIG_FEDORA_COMPAT is not set
+# CONFIG_INCLUDE_SUSv2 is not set
+# CONFIG_USE_PORTABLE_CODE is not set
+CONFIG_SHOW_USAGE=y
+CONFIG_FEATURE_VERBOSE_USAGE=y
+CONFIG_FEATURE_COMPRESS_USAGE=y
+CONFIG_BUSYBOX=y
+CONFIG_FEATURE_INSTALLER=y
+# CONFIG_INSTALL_NO_USR is not set
+# CONFIG_PAM is not set
+CONFIG_LONG_OPTS=y
+CONFIG_FEATURE_DEVPTS=y
+# CONFIG_FEATURE_CLEAN_UP is not set
+# CONFIG_FEATURE_UTMP is not set
+# CONFIG_FEATURE_WTMP is not set
+CONFIG_FEATURE_PIDFILE=y
+CONFIG_PID_FILE_PATH="/var/run"
+CONFIG_FEATURE_SUID=y
+# CONFIG_FEATURE_SUID_CONFIG is not set
+# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
+# CONFIG_SELINUX is not set
+# CONFIG_FEATURE_PREFER_APPLETS is not set
+CONFIG_BUSYBOX_EXEC_PATH="/bin/busybox"
+CONFIG_FEATURE_SYSLOG=y
+# CONFIG_FEATURE_HAVE_RPC is not set
+CONFIG_PLATFORM_LINUX=y
+
+#
+# Build Options
+#
+# CONFIG_STATIC is not set
+CONFIG_PIE=y
+# CONFIG_NOMMU is not set
+# CONFIG_BUILD_LIBBUSYBOX is not set
+# CONFIG_FEATURE_INDIVIDUAL is not set
+# CONFIG_FEATURE_SHARED_BUSYBOX is not set
+CONFIG_LFS=y
+CONFIG_CROSS_COMPILER_PREFIX=""
+CONFIG_SYSROOT=""
+CONFIG_EXTRA_CFLAGS=""
+CONFIG_EXTRA_LDFLAGS=""
+CONFIG_EXTRA_LDLIBS=""
+
+#
+# Installation Options ("make install" behavior)
+#
+# CONFIG_INSTALL_APPLET_SYMLINKS is not set
+# CONFIG_INSTALL_APPLET_HARDLINKS is not set
+# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
+CONFIG_INSTALL_APPLET_DONT=y
+# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
+# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set
+# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
+CONFIG_PREFIX="/home/ncopa/aports/main/busybox/pkg/busybox"
+
+#
+# Debugging Options
+#
+# CONFIG_DEBUG is not set
+# CONFIG_DEBUG_PESSIMIZE is not set
+# CONFIG_DEBUG_SANITIZE is not set
+# CONFIG_UNIT_TEST is not set
+# CONFIG_WERROR is not set
+CONFIG_NO_DEBUG_LIB=y
+# CONFIG_DMALLOC is not set
+# CONFIG_EFENCE is not set
+
+#
+# Busybox Library Tuning
+#
+# CONFIG_FEATURE_USE_BSS_TAIL is not set
+CONFIG_FEATURE_RTMINMAX=y
+CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
+# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
+# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
+CONFIG_PASSWORD_MINLEN=6
+CONFIG_MD5_SMALL=0
+CONFIG_SHA3_SMALL=0
+CONFIG_FEATURE_FAST_TOP=y
+# CONFIG_FEATURE_ETC_NETWORKS is not set
+CONFIG_FEATURE_EDITING=y
+CONFIG_FEATURE_EDITING_MAX_LEN=1024
+CONFIG_FEATURE_EDITING_VI=y
+CONFIG_FEATURE_EDITING_HISTORY=8192
+CONFIG_FEATURE_EDITING_SAVEHISTORY=y
+# CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set
+CONFIG_FEATURE_REVERSE_SEARCH=y
+CONFIG_FEATURE_TAB_COMPLETION=y
+CONFIG_FEATURE_USERNAME_COMPLETION=y
+CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
+CONFIG_FEATURE_EDITING_ASK_TERMINAL=y
+CONFIG_LOCALE_SUPPORT=y
+CONFIG_UNICODE_SUPPORT=y
+CONFIG_UNICODE_USING_LOCALE=y
+# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
+CONFIG_SUBST_WCHAR=63
+CONFIG_LAST_SUPPORTED_WCHAR=1114111
+CONFIG_UNICODE_COMBINING_WCHARS=y
+CONFIG_UNICODE_WIDE_WCHARS=y
+# CONFIG_UNICODE_BIDI_SUPPORT is not set
+# CONFIG_UNICODE_NEUTRAL_TABLE is not set
+CONFIG_UNICODE_PRESERVE_BROKEN=y
+CONFIG_FEATURE_NON_POSIX_CP=y
+# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
+CONFIG_FEATURE_USE_SENDFILE=y
+CONFIG_FEATURE_COPYBUF_KB=16
+CONFIG_FEATURE_SKIP_ROOTFS=y
+CONFIG_MONOTONIC_SYSCALL=y
+# CONFIG_IOCTL_HEX2STR_ERROR is not set
+CONFIG_FEATURE_HWIB=y
+
+#
+# Applets
+#
+
+#
+# Archival Utilities
+#
+CONFIG_FEATURE_SEAMLESS_XZ=y
+CONFIG_FEATURE_SEAMLESS_LZMA=y
+CONFIG_FEATURE_SEAMLESS_BZ2=y
+CONFIG_FEATURE_SEAMLESS_GZ=y
+CONFIG_FEATURE_SEAMLESS_Z=y
+# CONFIG_AR is not set
+# CONFIG_FEATURE_AR_LONG_FILENAMES is not set
+# CONFIG_FEATURE_AR_CREATE is not set
+# CONFIG_UNCOMPRESS is not set
+CONFIG_GUNZIP=y
+CONFIG_ZCAT=y
+CONFIG_FEATURE_GUNZIP_LONG_OPTIONS=y
+CONFIG_BUNZIP2=y
+CONFIG_BZCAT=y
+CONFIG_UNLZMA=y
+CONFIG_LZCAT=y
+CONFIG_LZMA=y
+CONFIG_FEATURE_LZMA_FAST=y
+CONFIG_UNXZ=y
+CONFIG_XZCAT=y
+# CONFIG_XZ is not set
+CONFIG_BZIP2=y
+CONFIG_FEATURE_BZIP2_DECOMPRESS=y
+CONFIG_CPIO=y
+CONFIG_FEATURE_CPIO_O=y
+CONFIG_FEATURE_CPIO_P=y
+# CONFIG_DPKG is not set
+# CONFIG_DPKG_DEB is not set
+CONFIG_GZIP=y
+# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
+CONFIG_GZIP_FAST=2
+CONFIG_FEATURE_GZIP_LEVELS=y
+CONFIG_FEATURE_GZIP_DECOMPRESS=y
+CONFIG_LZOP=y
+CONFIG_UNLZOP=y
+CONFIG_LZOPCAT=y
+# CONFIG_LZOP_COMPR_HIGH is not set
+# CONFIG_RPM is not set
+# CONFIG_RPM2CPIO is not set
+CONFIG_TAR=y
+CONFIG_FEATURE_TAR_LONG_OPTIONS=y
+CONFIG_FEATURE_TAR_CREATE=y
+CONFIG_FEATURE_TAR_AUTODETECT=y
+CONFIG_FEATURE_TAR_FROM=y
+CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
+CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
+CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
+# CONFIG_FEATURE_TAR_TO_COMMAND is not set
+CONFIG_FEATURE_TAR_UNAME_GNAME=y
+CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
+# CONFIG_FEATURE_TAR_SELINUX is not set
+CONFIG_UNZIP=y
+CONFIG_FEATURE_UNZIP_CDF=y
+CONFIG_FEATURE_UNZIP_BZIP2=y
+CONFIG_FEATURE_UNZIP_LZMA=y
+CONFIG_FEATURE_UNZIP_XZ=y
+
+#
+# Coreutils
+#
+CONFIG_BASENAME=y
+CONFIG_CAT=y
+CONFIG_FEATURE_CATV=y
+CONFIG_CHGRP=y
+CONFIG_CHMOD=y
+CONFIG_CHOWN=y
+CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y
+CONFIG_CHROOT=y
+CONFIG_CKSUM=y
+CONFIG_COMM=y
+CONFIG_CP=y
+CONFIG_FEATURE_CP_LONG_OPTIONS=y
+CONFIG_CUT=y
+CONFIG_DATE=y
+CONFIG_FEATURE_DATE_ISOFMT=y
+# CONFIG_FEATURE_DATE_NANO is not set
+CONFIG_FEATURE_DATE_COMPAT=y
+CONFIG_DD=y
+CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
+# CONFIG_FEATURE_DD_THIRD_STATUS_LINE is not set
+CONFIG_FEATURE_DD_IBS_OBS=y
+CONFIG_FEATURE_DD_STATUS=y
+CONFIG_DF=y
+CONFIG_FEATURE_DF_FANCY=y
+CONFIG_DIRNAME=y
+CONFIG_DOS2UNIX=y
+CONFIG_UNIX2DOS=y
+CONFIG_DU=y
+CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
+CONFIG_ECHO=y
+CONFIG_FEATURE_FANCY_ECHO=y
+CONFIG_ENV=y
+# CONFIG_FEATURE_ENV_LONG_OPTIONS is not set
+CONFIG_EXPAND=y
+# CONFIG_FEATURE_EXPAND_LONG_OPTIONS is not set
+CONFIG_UNEXPAND=y
+# CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS is not set
+CONFIG_EXPR=y
+CONFIG_EXPR_MATH_SUPPORT_64=y
+CONFIG_FACTOR=y
+CONFIG_FALSE=y
+CONFIG_FOLD=y
+CONFIG_FSYNC=y
+CONFIG_HEAD=y
+CONFIG_FEATURE_FANCY_HEAD=y
+CONFIG_HOSTID=y
+CONFIG_ID=y
+CONFIG_GROUPS=y
+CONFIG_INSTALL=y
+# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set
+CONFIG_LINK=y
+CONFIG_LN=y
+# CONFIG_LOGNAME is not set
+CONFIG_LS=y
+CONFIG_FEATURE_LS_FILETYPES=y
+CONFIG_FEATURE_LS_FOLLOWLINKS=y
+CONFIG_FEATURE_LS_RECURSIVE=y
+CONFIG_FEATURE_LS_WIDTH=y
+CONFIG_FEATURE_LS_SORTFILES=y
+CONFIG_FEATURE_LS_TIMESTAMPS=y
+CONFIG_FEATURE_LS_USERNAME=y
+CONFIG_FEATURE_LS_COLOR=y
+CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y
+CONFIG_MD5SUM=y
+CONFIG_SHA1SUM=y
+CONFIG_SHA256SUM=y
+CONFIG_SHA512SUM=y
+CONFIG_SHA3SUM=y
+
+#
+# Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum
+#
+CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
+CONFIG_MKDIR=y
+# CONFIG_FEATURE_MKDIR_LONG_OPTIONS is not set
+CONFIG_MKFIFO=y
+CONFIG_MKNOD=y
+CONFIG_MKTEMP=y
+CONFIG_MV=y
+# CONFIG_FEATURE_MV_LONG_OPTIONS is not set
+CONFIG_NICE=y
+CONFIG_NL=y
+CONFIG_NOHUP=y
+CONFIG_NPROC=y
+CONFIG_OD=y
+CONFIG_PASTE=y
+CONFIG_PRINTENV=y
+CONFIG_PRINTF=y
+CONFIG_PWD=y
+CONFIG_READLINK=y
+CONFIG_FEATURE_READLINK_FOLLOW=y
+CONFIG_REALPATH=y
+CONFIG_RM=y
+CONFIG_RMDIR=y
+# CONFIG_FEATURE_RMDIR_LONG_OPTIONS is not set
+CONFIG_SEQ=y
+CONFIG_SHRED=y
+CONFIG_SHUF=y
+CONFIG_SLEEP=y
+CONFIG_FEATURE_FANCY_SLEEP=y
+CONFIG_FEATURE_FLOAT_SLEEP=y
+CONFIG_SORT=y
+CONFIG_FEATURE_SORT_BIG=y
+CONFIG_SPLIT=y
+# CONFIG_FEATURE_SPLIT_FANCY is not set
+CONFIG_STAT=y
+CONFIG_FEATURE_STAT_FORMAT=y
+CONFIG_FEATURE_STAT_FILESYSTEM=y
+CONFIG_STTY=y
+CONFIG_SUM=y
+CONFIG_SYNC=y
+CONFIG_FEATURE_SYNC_FANCY=y
+CONFIG_TAC=y
+CONFIG_TAIL=y
+CONFIG_FEATURE_FANCY_TAIL=y
+CONFIG_TEE=y
+CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
+CONFIG_TEST=y
+CONFIG_TEST1=y
+CONFIG_TEST2=y
+CONFIG_FEATURE_TEST_64=y
+CONFIG_TIMEOUT=y
+CONFIG_TOUCH=y
+CONFIG_FEATURE_TOUCH_NODEREF=y
+CONFIG_FEATURE_TOUCH_SUSV3=y
+CONFIG_TR=y
+CONFIG_FEATURE_TR_CLASSES=y
+CONFIG_FEATURE_TR_EQUIV=y
+CONFIG_TRUE=y
+CONFIG_TRUNCATE=y
+CONFIG_TTY=y
+CONFIG_UNAME=y
+CONFIG_UNAME_OSNAME="Linux"
+CONFIG_UNIQ=y
+CONFIG_UNLINK=y
+CONFIG_USLEEP=y
+CONFIG_UUDECODE=y
+CONFIG_BASE64=y
+CONFIG_UUENCODE=y
+CONFIG_WC=y
+# CONFIG_FEATURE_WC_LARGE is not set
+# CONFIG_WHO is not set
+# CONFIG_W is not set
+# CONFIG_USERS is not set
+CONFIG_WHOAMI=y
+CONFIG_YES=y
+
+#
+# Common options
+#
+CONFIG_FEATURE_VERBOSE=y
+
+#
+# Common options for cp and mv
+#
+CONFIG_FEATURE_PRESERVE_HARDLINKS=y
+
+#
+# Common options for df, du, ls
+#
+CONFIG_FEATURE_HUMAN_READABLE=y
+
+#
+# Console Utilities
+#
+CONFIG_CHVT=y
+CONFIG_CLEAR=y
+CONFIG_DEALLOCVT=y
+CONFIG_DUMPKMAP=y
+# CONFIG_FGCONSOLE is not set
+CONFIG_KBD_MODE=y
+CONFIG_LOADFONT=y
+CONFIG_SETFONT=y
+CONFIG_FEATURE_SETFONT_TEXTUAL_MAP=y
+CONFIG_DEFAULT_SETFONT_DIR="/usr/share"
+
+#
+# Common options for loadfont and setfont
+#
+CONFIG_FEATURE_LOADFONT_PSF2=y
+CONFIG_FEATURE_LOADFONT_RAW=y
+CONFIG_LOADKMAP=y
+CONFIG_OPENVT=y
+CONFIG_RESET=y
+CONFIG_RESIZE=y
+CONFIG_FEATURE_RESIZE_PRINT=y
+CONFIG_SETCONSOLE=y
+# CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set
+CONFIG_SETKEYCODES=y
+CONFIG_SETLOGCONS=y
+CONFIG_SHOWKEY=y
+
+#
+# Debian Utilities
+#
+CONFIG_PIPE_PROGRESS=y
+CONFIG_RUN_PARTS=y
+CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
+# CONFIG_FEATURE_RUN_PARTS_FANCY is not set
+# CONFIG_START_STOP_DAEMON is not set
+# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
+# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
+CONFIG_WHICH=y
+
+#
+# Editors
+#
+CONFIG_AWK=y
+CONFIG_FEATURE_AWK_LIBM=y
+CONFIG_FEATURE_AWK_GNU_EXTENSIONS=y
+CONFIG_CMP=y
+CONFIG_DIFF=y
+CONFIG_FEATURE_DIFF_LONG_OPTIONS=y
+CONFIG_FEATURE_DIFF_DIR=y
+CONFIG_ED=y
+CONFIG_PATCH=y
+CONFIG_SED=y
+CONFIG_VI=y
+CONFIG_FEATURE_VI_MAX_LEN=1024
+CONFIG_FEATURE_VI_8BIT=y
+CONFIG_FEATURE_VI_COLON=y
+CONFIG_FEATURE_VI_YANKMARK=y
+CONFIG_FEATURE_VI_SEARCH=y
+# CONFIG_FEATURE_VI_REGEX_SEARCH is not set
+CONFIG_FEATURE_VI_USE_SIGNALS=y
+CONFIG_FEATURE_VI_DOT_CMD=y
+CONFIG_FEATURE_VI_READONLY=y
+CONFIG_FEATURE_VI_SETOPTS=y
+CONFIG_FEATURE_VI_SET=y
+CONFIG_FEATURE_VI_WIN_RESIZE=y
+CONFIG_FEATURE_VI_ASK_TERMINAL=y
+CONFIG_FEATURE_VI_UNDO=y
+CONFIG_FEATURE_VI_UNDO_QUEUE=y
+CONFIG_FEATURE_VI_UNDO_QUEUE_MAX=256
+CONFIG_FEATURE_ALLOW_EXEC=y
+
+#
+# Finding Utilities
+#
+CONFIG_FIND=y
+CONFIG_FEATURE_FIND_PRINT0=y
+CONFIG_FEATURE_FIND_MTIME=y
+CONFIG_FEATURE_FIND_MMIN=y
+CONFIG_FEATURE_FIND_PERM=y
+CONFIG_FEATURE_FIND_TYPE=y
+CONFIG_FEATURE_FIND_XDEV=y
+CONFIG_FEATURE_FIND_MAXDEPTH=y
+CONFIG_FEATURE_FIND_NEWER=y
+CONFIG_FEATURE_FIND_INUM=y
+CONFIG_FEATURE_FIND_EXEC=y
+CONFIG_FEATURE_FIND_EXEC_PLUS=y
+CONFIG_FEATURE_FIND_USER=y
+CONFIG_FEATURE_FIND_GROUP=y
+CONFIG_FEATURE_FIND_NOT=y
+CONFIG_FEATURE_FIND_DEPTH=y
+CONFIG_FEATURE_FIND_PAREN=y
+CONFIG_FEATURE_FIND_SIZE=y
+CONFIG_FEATURE_FIND_PRUNE=y
+CONFIG_FEATURE_FIND_DELETE=y
+CONFIG_FEATURE_FIND_PATH=y
+CONFIG_FEATURE_FIND_REGEX=y
+# CONFIG_FEATURE_FIND_CONTEXT is not set
+CONFIG_FEATURE_FIND_LINKS=y
+CONFIG_GREP=y
+CONFIG_EGREP=y
+CONFIG_FGREP=y
+CONFIG_FEATURE_GREP_CONTEXT=y
+CONFIG_XARGS=y
+CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
+CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
+CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
+CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
+CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR=y
+
+#
+# Init Utilities
+#
+# CONFIG_BOOTCHARTD is not set
+# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
+# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
+CONFIG_HALT=y
+CONFIG_POWEROFF=y
+CONFIG_REBOOT=y
+# CONFIG_FEATURE_CALL_TELINIT is not set
+CONFIG_TELINIT_PATH=""
+CONFIG_INIT=y
+# CONFIG_LINUXRC is not set
+CONFIG_FEATURE_USE_INITTAB=y
+CONFIG_FEATURE_KILL_REMOVED=y
+CONFIG_FEATURE_KILL_DELAY=0
+CONFIG_FEATURE_INIT_SCTTY=y
+CONFIG_FEATURE_INIT_SYSLOG=y
+CONFIG_FEATURE_INIT_QUIET=y
+# CONFIG_FEATURE_INIT_COREDUMPS is not set
+CONFIG_INIT_TERMINAL_TYPE="linux"
+# CONFIG_FEATURE_INIT_MODIFY_CMDLINE is not set
+
+#
+# Login/Password Management Utilities
+#
+CONFIG_FEATURE_SHADOWPASSWDS=y
+# CONFIG_USE_BB_PWD_GRP is not set
+# CONFIG_USE_BB_SHADOW is not set
+# CONFIG_USE_BB_CRYPT is not set
+# CONFIG_USE_BB_CRYPT_SHA is not set
+CONFIG_ADD_SHELL=y
+CONFIG_REMOVE_SHELL=y
+CONFIG_ADDGROUP=y
+# CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS is not set
+CONFIG_FEATURE_ADDUSER_TO_GROUP=y
+CONFIG_ADDUSER=y
+# CONFIG_FEATURE_ADDUSER_LONG_OPTIONS is not set
+CONFIG_FEATURE_CHECK_NAMES=y
+CONFIG_LAST_ID=256000
+CONFIG_FIRST_SYSTEM_ID=100
+CONFIG_LAST_SYSTEM_ID=999
+CONFIG_CHPASSWD=y
+CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="sha512"
+CONFIG_CRYPTPW=y
+CONFIG_MKPASSWD=y
+CONFIG_DELUSER=y
+CONFIG_DELGROUP=y
+CONFIG_FEATURE_DEL_USER_FROM_GROUP=y
+CONFIG_GETTY=y
+CONFIG_LOGIN=y
+CONFIG_LOGIN_SESSION_AS_CHILD=y
+CONFIG_LOGIN_SCRIPTS=y
+CONFIG_FEATURE_NOLOGIN=y
+CONFIG_FEATURE_SECURETTY=y
+CONFIG_NOLOGIN=y
+CONFIG_PASSWD=y
+CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
+CONFIG_SU=y
+CONFIG_FEATURE_SU_SYSLOG=y
+CONFIG_FEATURE_SU_CHECKS_SHELLS=y
+CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY=y
+# CONFIG_SULOGIN is not set
+CONFIG_VLOCK=y
+
+#
+# Linux Ext2 FS Progs
+#
+# CONFIG_CHATTR is not set
+CONFIG_FSCK=y
+# CONFIG_LSATTR is not set
+# CONFIG_TUNE2FS is not set
+
+#
+# Linux Module Utilities
+#
+# CONFIG_MODPROBE_SMALL is not set
+CONFIG_DEPMOD=y
+CONFIG_INSMOD=y
+CONFIG_LSMOD=y
+CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
+CONFIG_MODINFO=y
+CONFIG_MODPROBE=y
+CONFIG_FEATURE_MODPROBE_BLACKLIST=y
+CONFIG_RMMOD=y
+
+#
+# Options common to multiple modutils
+#
+CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+# CONFIG_FEATURE_2_4_MODULES is not set
+# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
+# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
+# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
+# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
+# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
+CONFIG_FEATURE_MODUTILS_ALIAS=y
+CONFIG_FEATURE_MODUTILS_BIN=y
+CONFIG_FEATURE_MODUTILS_SYMBOLS=y
+CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
+CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
+
+#
+# Linux System Utilities
+#
+CONFIG_ACPID=y
+CONFIG_FEATURE_ACPID_COMPAT=y
+CONFIG_BLKDISCARD=y
+CONFIG_BLKID=y
+CONFIG_FEATURE_BLKID_TYPE=y
+CONFIG_BLOCKDEV=y
+CONFIG_CAL=y
+# CONFIG_CHRT is not set
+CONFIG_DMESG=y
+CONFIG_FEATURE_DMESG_PRETTY=y
+CONFIG_EJECT=y
+CONFIG_FEATURE_EJECT_SCSI=y
+CONFIG_FALLOCATE=y
+CONFIG_FATATTR=y
+CONFIG_FBSET=y
+CONFIG_FEATURE_FBSET_FANCY=y
+CONFIG_FEATURE_FBSET_READMODE=y
+CONFIG_FDFORMAT=y
+CONFIG_FDISK=y
+# CONFIG_FDISK_SUPPORT_LARGE_DISKS is not set
+CONFIG_FEATURE_FDISK_WRITABLE=y
+CONFIG_FEATURE_AIX_LABEL=y
+CONFIG_FEATURE_SGI_LABEL=y
+CONFIG_FEATURE_SUN_LABEL=y
+CONFIG_FEATURE_OSF_LABEL=y
+CONFIG_FEATURE_GPT_LABEL=y
+CONFIG_FEATURE_FDISK_ADVANCED=y
+CONFIG_FINDFS=y
+CONFIG_FLOCK=y
+CONFIG_FDFLUSH=y
+# CONFIG_FREERAMDISK is not set
+# CONFIG_FSCK_MINIX is not set
+# CONFIG_FSFREEZE is not set
+CONFIG_FSTRIM=y
+CONFIG_GETOPT=y
+CONFIG_FEATURE_GETOPT_LONG=y
+CONFIG_HEXDUMP=y
+CONFIG_FEATURE_HEXDUMP_REVERSE=y
+CONFIG_HD=y
+CONFIG_XXD=y
+CONFIG_HWCLOCK=y
+CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
+CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
+CONFIG_IONICE=y
+CONFIG_IPCRM=y
+CONFIG_IPCS=y
+# CONFIG_LAST is not set
+# CONFIG_FEATURE_LAST_FANCY is not set
+CONFIG_LOSETUP=y
+CONFIG_LSPCI=y
+CONFIG_LSUSB=y
+CONFIG_MDEV=y
+CONFIG_FEATURE_MDEV_CONF=y
+CONFIG_FEATURE_MDEV_RENAME=y
+CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
+CONFIG_FEATURE_MDEV_EXEC=y
+CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
+CONFIG_MESG=y
+CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
+# CONFIG_MKE2FS is not set
+# CONFIG_MKFS_EXT2 is not set
+# CONFIG_MKFS_MINIX is not set
+# CONFIG_FEATURE_MINIX2 is not set
+# CONFIG_MKFS_REISER is not set
+CONFIG_MKDOSFS=y
+CONFIG_MKFS_VFAT=y
+CONFIG_MKSWAP=y
+CONFIG_FEATURE_MKSWAP_UUID=y
+CONFIG_MORE=y
+CONFIG_MOUNT=y
+CONFIG_FEATURE_MOUNT_FAKE=y
+CONFIG_FEATURE_MOUNT_VERBOSE=y
+CONFIG_FEATURE_MOUNT_HELPERS=y
+CONFIG_FEATURE_MOUNT_LABEL=y
+# CONFIG_FEATURE_MOUNT_NFS is not set
+CONFIG_FEATURE_MOUNT_CIFS=y
+CONFIG_FEATURE_MOUNT_FLAGS=y
+CONFIG_FEATURE_MOUNT_FSTAB=y
+# CONFIG_FEATURE_MOUNT_OTHERTAB is not set
+CONFIG_MOUNTPOINT=y
+CONFIG_NSENTER=y
+CONFIG_FEATURE_NSENTER_LONG_OPTS=y
+# CONFIG_PIVOT_ROOT is not set
+CONFIG_RDATE=y
+CONFIG_RDEV=y
+CONFIG_READPROFILE=y
+CONFIG_RENICE=y
+CONFIG_REV=y
+# CONFIG_RTCWAKE is not set
+# CONFIG_SCRIPT is not set
+# CONFIG_SCRIPTREPLAY is not set
+# CONFIG_SETARCH is not set
+CONFIG_LINUX32=y
+CONFIG_LINUX64=y
+CONFIG_SETPRIV=y
+CONFIG_SETSID=y
+CONFIG_SWAPON=y
+CONFIG_FEATURE_SWAPON_DISCARD=y
+CONFIG_FEATURE_SWAPON_PRI=y
+CONFIG_SWAPOFF=y
+CONFIG_SWITCH_ROOT=y
+# CONFIG_TASKSET is not set
+# CONFIG_FEATURE_TASKSET_FANCY is not set
+# CONFIG_UEVENT is not set
+CONFIG_UMOUNT=y
+CONFIG_FEATURE_UMOUNT_ALL=y
+CONFIG_UNSHARE=y
+# CONFIG_WALL is not set
+
+#
+# Common options for mount/umount
+#
+CONFIG_FEATURE_MOUNT_LOOP=y
+CONFIG_FEATURE_MOUNT_LOOP_CREATE=y
+# CONFIG_FEATURE_MTAB_SUPPORT is not set
+CONFIG_VOLUMEID=y
+
+#
+# Filesystem/Volume identification
+#
+CONFIG_FEATURE_VOLUMEID_BCACHE=y
+CONFIG_FEATURE_VOLUMEID_BTRFS=y
+CONFIG_FEATURE_VOLUMEID_CRAMFS=y
+CONFIG_FEATURE_VOLUMEID_EXFAT=y
+CONFIG_FEATURE_VOLUMEID_EXT=y
+CONFIG_FEATURE_VOLUMEID_F2FS=y
+CONFIG_FEATURE_VOLUMEID_FAT=y
+# CONFIG_FEATURE_VOLUMEID_HFS is not set
+CONFIG_FEATURE_VOLUMEID_ISO9660=y
+CONFIG_FEATURE_VOLUMEID_JFS=y
+CONFIG_FEATURE_VOLUMEID_LINUXRAID=y
+CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
+CONFIG_FEATURE_VOLUMEID_LUKS=y
+CONFIG_FEATURE_VOLUMEID_NILFS=y
+CONFIG_FEATURE_VOLUMEID_NTFS=y
+CONFIG_FEATURE_VOLUMEID_OCFS2=y
+CONFIG_FEATURE_VOLUMEID_REISERFS=y
+# CONFIG_FEATURE_VOLUMEID_ROMFS is not set
+CONFIG_FEATURE_VOLUMEID_SQUASHFS=y
+# CONFIG_FEATURE_VOLUMEID_SYSV is not set
+CONFIG_FEATURE_VOLUMEID_UBIFS=y
+CONFIG_FEATURE_VOLUMEID_UDF=y
+CONFIG_FEATURE_VOLUMEID_XFS=y
+
+#
+# Miscellaneous Utilities
+#
+CONFIG_ADJTIMEX=y
+CONFIG_BBCONFIG=y
+CONFIG_FEATURE_COMPRESS_BBCONFIG=y
+CONFIG_BEEP=y
+CONFIG_FEATURE_BEEP_FREQ=440
+CONFIG_FEATURE_BEEP_LENGTH_MS=30
+# CONFIG_CHAT is not set
+# CONFIG_FEATURE_CHAT_NOFAIL is not set
+# CONFIG_FEATURE_CHAT_TTY_HIFI is not set
+# CONFIG_FEATURE_CHAT_IMPLICIT_CR is not set
+# CONFIG_FEATURE_CHAT_SWALLOW_OPTS is not set
+# CONFIG_FEATURE_CHAT_SEND_ESCAPES is not set
+# CONFIG_FEATURE_CHAT_VAR_ABORT_LEN is not set
+# CONFIG_FEATURE_CHAT_CLR_ABORT is not set
+CONFIG_CONSPY=y
+CONFIG_CROND=y
+CONFIG_FEATURE_CROND_D=y
+CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
+CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
+CONFIG_CRONTAB=y
+CONFIG_DC=y
+CONFIG_FEATURE_DC_LIBM=y
+# CONFIG_DEVFSD is not set
+# CONFIG_DEVFSD_MODLOAD is not set
+# CONFIG_DEVFSD_FG_NP is not set
+# CONFIG_DEVFSD_VERBOSE is not set
+# CONFIG_FEATURE_DEVFS is not set
+# CONFIG_DEVMEM is not set
+CONFIG_FBSPLASH=y
+# CONFIG_FLASH_ERASEALL is not set
+# CONFIG_FLASH_LOCK is not set
+# CONFIG_FLASH_UNLOCK is not set
+# CONFIG_FLASHCP is not set
+CONFIG_HDPARM=y
+# CONFIG_FEATURE_HDPARM_GET_IDENTITY is not set
+# CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set
+# CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set
+# CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set
+# CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set
+# CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA is not set
+# CONFIG_I2CGET is not set
+# CONFIG_I2CSET is not set
+# CONFIG_I2CDUMP is not set
+# CONFIG_I2CDETECT is not set
+CONFIG_INOTIFYD=y
+CONFIG_LESS=y
+CONFIG_FEATURE_LESS_MAXLINES=9999999
+CONFIG_FEATURE_LESS_BRACKETS=y
+CONFIG_FEATURE_LESS_FLAGS=y
+CONFIG_FEATURE_LESS_TRUNCATE=y
+CONFIG_FEATURE_LESS_MARKS=y
+CONFIG_FEATURE_LESS_REGEXP=y
+CONFIG_FEATURE_LESS_WINCH=y
+CONFIG_FEATURE_LESS_ASK_TERMINAL=y
+CONFIG_FEATURE_LESS_DASHCMD=y
+CONFIG_FEATURE_LESS_LINENUMS=y
+# CONFIG_LSSCSI is not set
+# CONFIG_MAKEDEVS is not set
+# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
+# CONFIG_FEATURE_MAKEDEVS_TABLE is not set
+# CONFIG_MAN is not set
+CONFIG_MICROCOM=y
+# CONFIG_MT is not set
+CONFIG_NANDWRITE=y
+CONFIG_NANDDUMP=y
+CONFIG_PARTPROBE=y
+CONFIG_RAIDAUTORUN=y
+CONFIG_READAHEAD=y
+CONFIG_RFKILL=y
+# CONFIG_RUNLEVEL is not set
+# CONFIG_RX is not set
+CONFIG_SETSERIAL=y
+CONFIG_STRINGS=y
+CONFIG_TIME=y
+CONFIG_TTYSIZE=y
+# CONFIG_UBIATTACH is not set
+# CONFIG_UBIDETACH is not set
+# CONFIG_UBIMKVOL is not set
+# CONFIG_UBIRMVOL is not set
+# CONFIG_UBIRSVOL is not set
+# CONFIG_UBIUPDATEVOL is not set
+# CONFIG_UBIRENAME is not set
+CONFIG_VOLNAME=y
+CONFIG_WATCHDOG=y
+
+#
+# Networking Utilities
+#
+CONFIG_FEATURE_IPV6=y
+CONFIG_FEATURE_UNIX_LOCAL=y
+CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
+CONFIG_VERBOSE_RESOLUTION_ERRORS=y
+CONFIG_ARP=y
+CONFIG_ARPING=y
+CONFIG_BRCTL=y
+CONFIG_FEATURE_BRCTL_FANCY=y
+CONFIG_FEATURE_BRCTL_SHOW=y
+# CONFIG_DNSD is not set
+CONFIG_ETHER_WAKE=y
+# CONFIG_FTPD is not set
+# CONFIG_FEATURE_FTPD_WRITE is not set
+# CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST is not set
+# CONFIG_FEATURE_FTPD_AUTHENTICATION is not set
+# CONFIG_FTPGET is not set
+# CONFIG_FTPPUT is not set
+# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
+CONFIG_HOSTNAME=y
+CONFIG_DNSDOMAINNAME=y
+# CONFIG_HTTPD is not set
+# CONFIG_FEATURE_HTTPD_RANGES is not set
+# CONFIG_FEATURE_HTTPD_SETUID is not set
+# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
+# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
+# CONFIG_FEATURE_HTTPD_CGI is not set
+# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
+# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
+# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
+# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set
+# CONFIG_FEATURE_HTTPD_PROXY is not set
+# CONFIG_FEATURE_HTTPD_GZIP is not set
+CONFIG_IFCONFIG=y
+CONFIG_FEATURE_IFCONFIG_STATUS=y
+CONFIG_FEATURE_IFCONFIG_SLIP=y
+CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
+CONFIG_FEATURE_IFCONFIG_HW=y
+CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
+CONFIG_IFENSLAVE=y
+# CONFIG_IFPLUGD is not set
+CONFIG_IFUP=y
+CONFIG_IFDOWN=y
+CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
+CONFIG_FEATURE_IFUPDOWN_IP=y
+CONFIG_FEATURE_IFUPDOWN_IPV4=y
+CONFIG_FEATURE_IFUPDOWN_IPV6=y
+# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
+CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y
+# CONFIG_INETD is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
+# CONFIG_FEATURE_INETD_RPC is not set
+CONFIG_IP=y
+CONFIG_IPADDR=y
+CONFIG_IPLINK=y
+CONFIG_IPROUTE=y
+CONFIG_IPTUNNEL=y
+CONFIG_IPRULE=y
+CONFIG_IPNEIGH=y
+CONFIG_FEATURE_IP_ADDRESS=y
+CONFIG_FEATURE_IP_LINK=y
+CONFIG_FEATURE_IP_ROUTE=y
+CONFIG_FEATURE_IP_ROUTE_DIR="/etc/iproute2"
+CONFIG_FEATURE_IP_TUNNEL=y
+CONFIG_FEATURE_IP_RULE=y
+CONFIG_FEATURE_IP_NEIGH=y
+CONFIG_FEATURE_IP_RARE_PROTOCOLS=y
+CONFIG_IPCALC=y
+# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set
+CONFIG_FEATURE_IPCALC_FANCY=y
+# CONFIG_FAKEIDENTD is not set
+CONFIG_NAMEIF=y
+CONFIG_FEATURE_NAMEIF_EXTENDED=y
+CONFIG_NBDCLIENT=y
+CONFIG_NC=y
+CONFIG_NC_SERVER=y
+CONFIG_NC_EXTRA=y
+CONFIG_NC_110_COMPAT=y
+CONFIG_NETSTAT=y
+CONFIG_FEATURE_NETSTAT_WIDE=y
+CONFIG_FEATURE_NETSTAT_PRG=y
+CONFIG_NSLOOKUP=y
+CONFIG_NTPD=y
+CONFIG_FEATURE_NTPD_SERVER=y
+CONFIG_FEATURE_NTPD_CONF=y
+CONFIG_PING=y
+CONFIG_PING6=y
+CONFIG_FEATURE_FANCY_PING=y
+CONFIG_PSCAN=y
+CONFIG_ROUTE=y
+CONFIG_SLATTACH=y
+CONFIG_SSL_CLIENT=y
+# CONFIG_TCPSVD is not set
+# CONFIG_UDPSVD is not set
+# CONFIG_TELNET is not set
+# CONFIG_FEATURE_TELNET_TTYPE is not set
+# CONFIG_FEATURE_TELNET_AUTOLOGIN is not set
+# CONFIG_FEATURE_TELNET_WIDTH is not set
+# CONFIG_TELNETD is not set
+# CONFIG_FEATURE_TELNETD_STANDALONE is not set
+# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
+# CONFIG_TFTP is not set
+# CONFIG_TFTPD is not set
+# CONFIG_FEATURE_TFTP_GET is not set
+# CONFIG_FEATURE_TFTP_PUT is not set
+# CONFIG_FEATURE_TFTP_BLOCKSIZE is not set
+# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set
+# CONFIG_TFTP_DEBUG is not set
+CONFIG_TLS=y
+CONFIG_TRACEROUTE=y
+CONFIG_TRACEROUTE6=y
+CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
+CONFIG_FEATURE_TRACEROUTE_USE_ICMP=y
+CONFIG_TUNCTL=y
+CONFIG_FEATURE_TUNCTL_UG=y
+CONFIG_VCONFIG=y
+CONFIG_WGET=y
+CONFIG_FEATURE_WGET_LONG_OPTIONS=y
+CONFIG_FEATURE_WGET_STATUSBAR=y
+CONFIG_FEATURE_WGET_AUTHENTICATION=y
+CONFIG_FEATURE_WGET_TIMEOUT=y
+CONFIG_FEATURE_WGET_HTTPS=y
+CONFIG_FEATURE_WGET_OPENSSL=y
+CONFIG_WHOIS=y
+# CONFIG_ZCIP is not set
+CONFIG_UDHCPC6=y
+CONFIG_FEATURE_UDHCPC6_RFC3646=y
+CONFIG_FEATURE_UDHCPC6_RFC4704=y
+CONFIG_FEATURE_UDHCPC6_RFC4833=y
+# CONFIG_UDHCPD is not set
+# CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set
+# CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set
+CONFIG_DHCPD_LEASES_FILE=""
+CONFIG_DUMPLEASES=y
+# CONFIG_DHCPRELAY is not set
+CONFIG_UDHCPC=y
+CONFIG_FEATURE_UDHCPC_ARPING=y
+CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y
+CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
+# CONFIG_FEATURE_UDHCP_PORT is not set
+CONFIG_UDHCP_DEBUG=0
+CONFIG_FEATURE_UDHCP_RFC3397=y
+CONFIG_FEATURE_UDHCP_8021Q=y
+CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
+CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-b"
+
+#
+# Print Utilities
+#
+# CONFIG_LPD is not set
+# CONFIG_LPR is not set
+# CONFIG_LPQ is not set
+
+#
+# Mail Utilities
+#
+CONFIG_MAKEMIME=y
+# CONFIG_POPMAILDIR is not set
+# CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set
+CONFIG_REFORMIME=y
+CONFIG_FEATURE_REFORMIME_COMPAT=y
+CONFIG_SENDMAIL=y
+CONFIG_FEATURE_MIME_CHARSET="us-ascii"
+
+#
+# Process Utilities
+#
+CONFIG_FREE=y
+CONFIG_FUSER=y
+CONFIG_IOSTAT=y
+CONFIG_KILL=y
+CONFIG_KILLALL=y
+CONFIG_KILLALL5=y
+CONFIG_LSOF=y
+CONFIG_MPSTAT=y
+CONFIG_NMETER=y
+CONFIG_PGREP=y
+CONFIG_PKILL=y
+CONFIG_PIDOF=y
+CONFIG_FEATURE_PIDOF_SINGLE=y
+CONFIG_FEATURE_PIDOF_OMIT=y
+CONFIG_PMAP=y
+CONFIG_POWERTOP=y
+CONFIG_FEATURE_POWERTOP_INTERACTIVE=y
+CONFIG_PS=y
+# CONFIG_FEATURE_PS_WIDE is not set
+# CONFIG_FEATURE_PS_LONG is not set
+CONFIG_FEATURE_PS_TIME=y
+# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
+CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y
+CONFIG_PSTREE=y
+CONFIG_PWDX=y
+CONFIG_SMEMCAP=y
+CONFIG_BB_SYSCTL=y
+CONFIG_TOP=y
+CONFIG_FEATURE_TOP_INTERACTIVE=y
+CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
+CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
+CONFIG_FEATURE_TOP_SMP_CPU=y
+# CONFIG_FEATURE_TOP_DECIMALS is not set
+CONFIG_FEATURE_TOP_SMP_PROCESS=y
+CONFIG_FEATURE_TOPMEM=y
+CONFIG_UPTIME=y
+# CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set
+CONFIG_WATCH=y
+# CONFIG_FEATURE_SHOW_THREADS is not set
+
+#
+# Runit Utilities
+#
+# CONFIG_CHPST is not set
+# CONFIG_SETUIDGID is not set
+# CONFIG_ENVUIDGID is not set
+# CONFIG_ENVDIR is not set
+# CONFIG_SOFTLIMIT is not set
+# CONFIG_RUNSV is not set
+# CONFIG_RUNSVDIR is not set
+# CONFIG_FEATURE_RUNSVDIR_LOG is not set
+# CONFIG_SV is not set
+CONFIG_SV_DEFAULT_SERVICE_DIR=""
+# CONFIG_SVC is not set
+# CONFIG_SVLOGD is not set
+# CONFIG_CHCON is not set
+# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
+# CONFIG_GETENFORCE is not set
+# CONFIG_GETSEBOOL is not set
+# CONFIG_LOAD_POLICY is not set
+# CONFIG_MATCHPATHCON is not set
+# CONFIG_RUNCON is not set
+# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
+# CONFIG_SELINUXENABLED is not set
+# CONFIG_SESTATUS is not set
+# CONFIG_SETENFORCE is not set
+# CONFIG_SETFILES is not set
+# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
+# CONFIG_RESTORECON is not set
+# CONFIG_SETSEBOOL is not set
+
+#
+# Shells
+#
+CONFIG_SH_IS_ASH=y
+# CONFIG_SH_IS_HUSH is not set
+# CONFIG_SH_IS_NONE is not set
+# CONFIG_BASH_IS_ASH is not set
+# CONFIG_BASH_IS_HUSH is not set
+CONFIG_BASH_IS_NONE=y
+CONFIG_ASH=y
+CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
+CONFIG_ASH_INTERNAL_GLOB=y
+CONFIG_ASH_BASH_COMPAT=y
+CONFIG_ASH_JOB_CONTROL=y
+CONFIG_ASH_ALIAS=y
+CONFIG_ASH_RANDOM_SUPPORT=y
+CONFIG_ASH_EXPAND_PRMT=y
+CONFIG_ASH_IDLE_TIMEOUT=y
+CONFIG_ASH_MAIL=y
+CONFIG_ASH_ECHO=y
+CONFIG_ASH_PRINTF=y
+CONFIG_ASH_TEST=y
+CONFIG_ASH_HELP=y
+CONFIG_ASH_GETOPTS=y
+CONFIG_ASH_CMDCMD=y
+CONFIG_ASH_COMMAND_NOT_FOUND_HOOK=y
+# CONFIG_CTTYHACK is not set
+# CONFIG_HUSH is not set
+# CONFIG_HUSH_BASH_COMPAT is not set
+# CONFIG_HUSH_BRACE_EXPANSION is not set
+# CONFIG_HUSH_INTERACTIVE is not set
+# CONFIG_HUSH_SAVEHISTORY is not set
+# CONFIG_HUSH_JOB is not set
+# CONFIG_HUSH_TICK is not set
+# CONFIG_HUSH_IF is not set
+# CONFIG_HUSH_LOOPS is not set
+# CONFIG_HUSH_CASE is not set
+# CONFIG_HUSH_FUNCTIONS is not set
+# CONFIG_HUSH_LOCAL is not set
+# CONFIG_HUSH_RANDOM_SUPPORT is not set
+# CONFIG_HUSH_MODE_X is not set
+# CONFIG_HUSH_ECHO is not set
+# CONFIG_HUSH_PRINTF is not set
+# CONFIG_HUSH_TEST is not set
+# CONFIG_HUSH_HELP is not set
+# CONFIG_HUSH_EXPORT is not set
+# CONFIG_HUSH_EXPORT_N is not set
+# CONFIG_HUSH_KILL is not set
+# CONFIG_HUSH_WAIT is not set
+# CONFIG_HUSH_TRAP is not set
+# CONFIG_HUSH_TYPE is not set
+# CONFIG_HUSH_READ is not set
+# CONFIG_HUSH_SET is not set
+# CONFIG_HUSH_UNSET is not set
+# CONFIG_HUSH_ULIMIT is not set
+# CONFIG_HUSH_UMASK is not set
+# CONFIG_HUSH_MEMLEAK is not set
+# CONFIG_MSH is not set
+
+#
+# Options common to all shells
+#
+CONFIG_FEATURE_SH_MATH=y
+CONFIG_FEATURE_SH_MATH_64=y
+CONFIG_FEATURE_SH_EXTRA_QUIET=y
+# CONFIG_FEATURE_SH_STANDALONE is not set
+# CONFIG_FEATURE_SH_NOFORK is not set
+CONFIG_FEATURE_SH_HISTFILESIZE=y
+
+#
+# System Logging Utilities
+#
+CONFIG_KLOGD=y
+
+#
+# klogd should not be used together with syslog to kernel printk buffer
+#
+CONFIG_FEATURE_KLOGD_KLOGCTL=y
+CONFIG_LOGGER=y
+CONFIG_LOGREAD=y
+CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
+CONFIG_SYSLOGD=y
+CONFIG_FEATURE_ROTATE_LOGFILE=y
+CONFIG_FEATURE_REMOTE_LOG=y
+CONFIG_FEATURE_SYSLOGD_DUP=y
+CONFIG_FEATURE_SYSLOGD_CFG=y
+CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256
+CONFIG_FEATURE_IPC_SYSLOG=y
+CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
+CONFIG_FEATURE_KMSG_SYSLOG=y
diff --git a/system/busybox/busyboxconfig-extras b/system/busybox/busyboxconfig-extras
new file mode 100644
index 000000000..c460d0144
--- /dev/null
+++ b/system/busybox/busyboxconfig-extras
@@ -0,0 +1,1114 @@
+#
+# Automatically generated make config: don't edit
+# Busybox version: 1.27.2
+# Fri Oct 27 21:23:19 2017
+#
+CONFIG_HAVE_DOT_CONFIG=y
+
+#
+# Busybox Settings
+#
+# CONFIG_DESKTOP is not set
+# CONFIG_EXTRA_COMPAT is not set
+# CONFIG_FEDORA_COMPAT is not set
+# CONFIG_INCLUDE_SUSv2 is not set
+# CONFIG_USE_PORTABLE_CODE is not set
+CONFIG_SHOW_USAGE=y
+CONFIG_FEATURE_VERBOSE_USAGE=y
+CONFIG_FEATURE_COMPRESS_USAGE=y
+CONFIG_BUSYBOX=y
+CONFIG_FEATURE_INSTALLER=y
+# CONFIG_INSTALL_NO_USR is not set
+# CONFIG_PAM is not set
+# CONFIG_LONG_OPTS is not set
+CONFIG_FEATURE_DEVPTS=y
+# CONFIG_FEATURE_CLEAN_UP is not set
+# CONFIG_FEATURE_UTMP is not set
+# CONFIG_FEATURE_WTMP is not set
+# CONFIG_FEATURE_PIDFILE is not set
+CONFIG_PID_FILE_PATH=""
+# CONFIG_FEATURE_SUID is not set
+# CONFIG_FEATURE_SUID_CONFIG is not set
+# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
+# CONFIG_SELINUX is not set
+# CONFIG_FEATURE_PREFER_APPLETS is not set
+CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
+CONFIG_FEATURE_SYSLOG=y
+# CONFIG_FEATURE_HAVE_RPC is not set
+CONFIG_PLATFORM_LINUX=y
+
+#
+# Build Options
+#
+# CONFIG_STATIC is not set
+CONFIG_PIE=y
+# CONFIG_NOMMU is not set
+# CONFIG_BUILD_LIBBUSYBOX is not set
+# CONFIG_FEATURE_INDIVIDUAL is not set
+# CONFIG_FEATURE_SHARED_BUSYBOX is not set
+CONFIG_LFS=y
+CONFIG_CROSS_COMPILER_PREFIX=""
+CONFIG_SYSROOT=""
+CONFIG_EXTRA_CFLAGS=""
+CONFIG_EXTRA_LDFLAGS=""
+CONFIG_EXTRA_LDLIBS=""
+
+#
+# Installation Options ("make install" behavior)
+#
+CONFIG_INSTALL_APPLET_SYMLINKS=y
+# CONFIG_INSTALL_APPLET_HARDLINKS is not set
+# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
+# CONFIG_INSTALL_APPLET_DONT is not set
+# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
+# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set
+# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
+CONFIG_PREFIX="./_install"
+
+#
+# Debugging Options
+#
+# CONFIG_DEBUG is not set
+# CONFIG_DEBUG_PESSIMIZE is not set
+# CONFIG_DEBUG_SANITIZE is not set
+# CONFIG_UNIT_TEST is not set
+# CONFIG_WERROR is not set
+CONFIG_NO_DEBUG_LIB=y
+# CONFIG_DMALLOC is not set
+# CONFIG_EFENCE is not set
+
+#
+# Busybox Library Tuning
+#
+# CONFIG_FEATURE_USE_BSS_TAIL is not set
+# CONFIG_FEATURE_RTMINMAX is not set
+CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
+# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
+# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
+CONFIG_PASSWORD_MINLEN=6
+CONFIG_MD5_SMALL=1
+CONFIG_SHA3_SMALL=1
+# CONFIG_FEATURE_FAST_TOP is not set
+# CONFIG_FEATURE_ETC_NETWORKS is not set
+# CONFIG_FEATURE_EDITING is not set
+CONFIG_FEATURE_EDITING_MAX_LEN=0
+# CONFIG_FEATURE_EDITING_VI is not set
+CONFIG_FEATURE_EDITING_HISTORY=0
+# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
+# CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set
+# CONFIG_FEATURE_REVERSE_SEARCH is not set
+# CONFIG_FEATURE_TAB_COMPLETION is not set
+# CONFIG_FEATURE_USERNAME_COMPLETION is not set
+# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
+# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set
+# CONFIG_LOCALE_SUPPORT is not set
+# CONFIG_UNICODE_SUPPORT is not set
+# CONFIG_UNICODE_USING_LOCALE is not set
+# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
+CONFIG_SUBST_WCHAR=0
+CONFIG_LAST_SUPPORTED_WCHAR=0
+# CONFIG_UNICODE_COMBINING_WCHARS is not set
+# CONFIG_UNICODE_WIDE_WCHARS is not set
+# CONFIG_UNICODE_BIDI_SUPPORT is not set
+# CONFIG_UNICODE_NEUTRAL_TABLE is not set
+# CONFIG_UNICODE_PRESERVE_BROKEN is not set
+# CONFIG_FEATURE_NON_POSIX_CP is not set
+# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
+# CONFIG_FEATURE_USE_SENDFILE is not set
+CONFIG_FEATURE_COPYBUF_KB=4
+# CONFIG_FEATURE_SKIP_ROOTFS is not set
+# CONFIG_MONOTONIC_SYSCALL is not set
+# CONFIG_IOCTL_HEX2STR_ERROR is not set
+# CONFIG_FEATURE_HWIB is not set
+
+#
+# Applets
+#
+
+#
+# Archival Utilities
+#
+# CONFIG_FEATURE_SEAMLESS_XZ is not set
+# CONFIG_FEATURE_SEAMLESS_LZMA is not set
+# CONFIG_FEATURE_SEAMLESS_BZ2 is not set
+CONFIG_FEATURE_SEAMLESS_GZ=y
+# CONFIG_FEATURE_SEAMLESS_Z is not set
+# CONFIG_AR is not set
+# CONFIG_FEATURE_AR_LONG_FILENAMES is not set
+# CONFIG_FEATURE_AR_CREATE is not set
+# CONFIG_UNCOMPRESS is not set
+# CONFIG_GUNZIP is not set
+# CONFIG_ZCAT is not set
+# CONFIG_FEATURE_GUNZIP_LONG_OPTIONS is not set
+# CONFIG_BUNZIP2 is not set
+# CONFIG_BZCAT is not set
+# CONFIG_UNLZMA is not set
+# CONFIG_LZCAT is not set
+# CONFIG_LZMA is not set
+# CONFIG_FEATURE_LZMA_FAST is not set
+# CONFIG_UNXZ is not set
+# CONFIG_XZCAT is not set
+# CONFIG_XZ is not set
+# CONFIG_BZIP2 is not set
+# CONFIG_FEATURE_BZIP2_DECOMPRESS is not set
+# CONFIG_CPIO is not set
+# CONFIG_FEATURE_CPIO_O is not set
+# CONFIG_FEATURE_CPIO_P is not set
+# CONFIG_DPKG is not set
+# CONFIG_DPKG_DEB is not set
+# CONFIG_GZIP is not set
+# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
+CONFIG_GZIP_FAST=0
+# CONFIG_FEATURE_GZIP_LEVELS is not set
+# CONFIG_FEATURE_GZIP_DECOMPRESS is not set
+# CONFIG_LZOP is not set
+# CONFIG_UNLZOP is not set
+# CONFIG_LZOPCAT is not set
+# CONFIG_LZOP_COMPR_HIGH is not set
+# CONFIG_RPM is not set
+# CONFIG_RPM2CPIO is not set
+# CONFIG_TAR is not set
+# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set
+# CONFIG_FEATURE_TAR_CREATE is not set
+# CONFIG_FEATURE_TAR_AUTODETECT is not set
+# CONFIG_FEATURE_TAR_FROM is not set
+# CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY is not set
+# CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY is not set
+# CONFIG_FEATURE_TAR_GNU_EXTENSIONS is not set
+# CONFIG_FEATURE_TAR_TO_COMMAND is not set
+# CONFIG_FEATURE_TAR_UNAME_GNAME is not set
+# CONFIG_FEATURE_TAR_NOPRESERVE_TIME is not set
+# CONFIG_FEATURE_TAR_SELINUX is not set
+# CONFIG_UNZIP is not set
+# CONFIG_FEATURE_UNZIP_CDF is not set
+# CONFIG_FEATURE_UNZIP_BZIP2 is not set
+# CONFIG_FEATURE_UNZIP_LZMA is not set
+# CONFIG_FEATURE_UNZIP_XZ is not set
+
+#
+# Coreutils
+#
+# CONFIG_BASENAME is not set
+# CONFIG_CAT is not set
+# CONFIG_FEATURE_CATV is not set
+# CONFIG_CHGRP is not set
+# CONFIG_CHMOD is not set
+# CONFIG_CHOWN is not set
+# CONFIG_FEATURE_CHOWN_LONG_OPTIONS is not set
+# CONFIG_CHROOT is not set
+# CONFIG_CKSUM is not set
+# CONFIG_COMM is not set
+# CONFIG_CP is not set
+# CONFIG_FEATURE_CP_LONG_OPTIONS is not set
+# CONFIG_CUT is not set
+# CONFIG_DATE is not set
+# CONFIG_FEATURE_DATE_ISOFMT is not set
+# CONFIG_FEATURE_DATE_NANO is not set
+# CONFIG_FEATURE_DATE_COMPAT is not set
+# CONFIG_DD is not set
+# CONFIG_FEATURE_DD_SIGNAL_HANDLING is not set
+# CONFIG_FEATURE_DD_THIRD_STATUS_LINE is not set
+# CONFIG_FEATURE_DD_IBS_OBS is not set
+# CONFIG_FEATURE_DD_STATUS is not set
+# CONFIG_DF is not set
+# CONFIG_FEATURE_DF_FANCY is not set
+# CONFIG_DIRNAME is not set
+# CONFIG_DOS2UNIX is not set
+# CONFIG_UNIX2DOS is not set
+# CONFIG_DU is not set
+# CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K is not set
+# CONFIG_ECHO is not set
+# CONFIG_FEATURE_FANCY_ECHO is not set
+# CONFIG_ENV is not set
+# CONFIG_FEATURE_ENV_LONG_OPTIONS is not set
+# CONFIG_EXPAND is not set
+# CONFIG_FEATURE_EXPAND_LONG_OPTIONS is not set
+# CONFIG_UNEXPAND is not set
+# CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS is not set
+# CONFIG_EXPR is not set
+# CONFIG_EXPR_MATH_SUPPORT_64 is not set
+# CONFIG_FACTOR is not set
+# CONFIG_FALSE is not set
+# CONFIG_FOLD is not set
+# CONFIG_FSYNC is not set
+# CONFIG_HEAD is not set
+# CONFIG_FEATURE_FANCY_HEAD is not set
+# CONFIG_HOSTID is not set
+# CONFIG_ID is not set
+# CONFIG_GROUPS is not set
+# CONFIG_INSTALL is not set
+# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set
+# CONFIG_LINK is not set
+# CONFIG_LN is not set
+# CONFIG_LOGNAME is not set
+# CONFIG_LS is not set
+# CONFIG_FEATURE_LS_FILETYPES is not set
+# CONFIG_FEATURE_LS_FOLLOWLINKS is not set
+# CONFIG_FEATURE_LS_RECURSIVE is not set
+# CONFIG_FEATURE_LS_WIDTH is not set
+# CONFIG_FEATURE_LS_SORTFILES is not set
+# CONFIG_FEATURE_LS_TIMESTAMPS is not set
+# CONFIG_FEATURE_LS_USERNAME is not set
+# CONFIG_FEATURE_LS_COLOR is not set
+# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set
+# CONFIG_MD5SUM is not set
+# CONFIG_SHA1SUM is not set
+# CONFIG_SHA256SUM is not set
+# CONFIG_SHA512SUM is not set
+# CONFIG_SHA3SUM is not set
+# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set
+# CONFIG_MKDIR is not set
+# CONFIG_FEATURE_MKDIR_LONG_OPTIONS is not set
+# CONFIG_MKFIFO is not set
+# CONFIG_MKNOD is not set
+# CONFIG_MKTEMP is not set
+# CONFIG_MV is not set
+# CONFIG_FEATURE_MV_LONG_OPTIONS is not set
+# CONFIG_NICE is not set
+# CONFIG_NL is not set
+# CONFIG_NOHUP is not set
+# CONFIG_NPROC is not set
+# CONFIG_OD is not set
+# CONFIG_PASTE is not set
+# CONFIG_PRINTENV is not set
+# CONFIG_PRINTF is not set
+# CONFIG_PWD is not set
+# CONFIG_READLINK is not set
+# CONFIG_FEATURE_READLINK_FOLLOW is not set
+# CONFIG_REALPATH is not set
+# CONFIG_RM is not set
+# CONFIG_RMDIR is not set
+# CONFIG_FEATURE_RMDIR_LONG_OPTIONS is not set
+# CONFIG_SEQ is not set
+# CONFIG_SHRED is not set
+# CONFIG_SHUF is not set
+# CONFIG_SLEEP is not set
+# CONFIG_FEATURE_FANCY_SLEEP is not set
+# CONFIG_FEATURE_FLOAT_SLEEP is not set
+# CONFIG_SORT is not set
+# CONFIG_FEATURE_SORT_BIG is not set
+# CONFIG_SPLIT is not set
+# CONFIG_FEATURE_SPLIT_FANCY is not set
+# CONFIG_STAT is not set
+# CONFIG_FEATURE_STAT_FORMAT is not set
+# CONFIG_FEATURE_STAT_FILESYSTEM is not set
+# CONFIG_STTY is not set
+# CONFIG_SUM is not set
+# CONFIG_SYNC is not set
+# CONFIG_FEATURE_SYNC_FANCY is not set
+# CONFIG_TAC is not set
+# CONFIG_TAIL is not set
+# CONFIG_FEATURE_FANCY_TAIL is not set
+# CONFIG_TEE is not set
+# CONFIG_FEATURE_TEE_USE_BLOCK_IO is not set
+# CONFIG_TEST is not set
+# CONFIG_TEST1 is not set
+# CONFIG_TEST2 is not set
+# CONFIG_FEATURE_TEST_64 is not set
+# CONFIG_TIMEOUT is not set
+# CONFIG_TOUCH is not set
+# CONFIG_FEATURE_TOUCH_NODEREF is not set
+# CONFIG_FEATURE_TOUCH_SUSV3 is not set
+# CONFIG_TR is not set
+# CONFIG_FEATURE_TR_CLASSES is not set
+# CONFIG_FEATURE_TR_EQUIV is not set
+# CONFIG_TRUE is not set
+# CONFIG_TRUNCATE is not set
+# CONFIG_TTY is not set
+# CONFIG_UNAME is not set
+CONFIG_UNAME_OSNAME=""
+# CONFIG_UNIQ is not set
+# CONFIG_UNLINK is not set
+# CONFIG_USLEEP is not set
+# CONFIG_UUDECODE is not set
+# CONFIG_BASE64 is not set
+# CONFIG_UUENCODE is not set
+# CONFIG_WC is not set
+# CONFIG_FEATURE_WC_LARGE is not set
+# CONFIG_WHO is not set
+# CONFIG_W is not set
+# CONFIG_USERS is not set
+# CONFIG_WHOAMI is not set
+# CONFIG_YES is not set
+
+#
+# Common options
+#
+# CONFIG_FEATURE_VERBOSE is not set
+# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set
+# CONFIG_FEATURE_HUMAN_READABLE is not set
+
+#
+# Console Utilities
+#
+# CONFIG_CHVT is not set
+# CONFIG_CLEAR is not set
+# CONFIG_DEALLOCVT is not set
+# CONFIG_DUMPKMAP is not set
+# CONFIG_FGCONSOLE is not set
+# CONFIG_KBD_MODE is not set
+# CONFIG_LOADFONT is not set
+# CONFIG_SETFONT is not set
+# CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set
+CONFIG_DEFAULT_SETFONT_DIR=""
+# CONFIG_FEATURE_LOADFONT_PSF2 is not set
+# CONFIG_FEATURE_LOADFONT_RAW is not set
+# CONFIG_LOADKMAP is not set
+# CONFIG_OPENVT is not set
+# CONFIG_RESET is not set
+# CONFIG_RESIZE is not set
+# CONFIG_FEATURE_RESIZE_PRINT is not set
+# CONFIG_SETCONSOLE is not set
+# CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set
+# CONFIG_SETKEYCODES is not set
+# CONFIG_SETLOGCONS is not set
+# CONFIG_SHOWKEY is not set
+
+#
+# Debian Utilities
+#
+# CONFIG_PIPE_PROGRESS is not set
+# CONFIG_RUN_PARTS is not set
+# CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS is not set
+# CONFIG_FEATURE_RUN_PARTS_FANCY is not set
+# CONFIG_START_STOP_DAEMON is not set
+# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
+# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
+# CONFIG_WHICH is not set
+
+#
+# Editors
+#
+# CONFIG_AWK is not set
+# CONFIG_FEATURE_AWK_LIBM is not set
+# CONFIG_FEATURE_AWK_GNU_EXTENSIONS is not set
+# CONFIG_CMP is not set
+# CONFIG_DIFF is not set
+# CONFIG_FEATURE_DIFF_LONG_OPTIONS is not set
+# CONFIG_FEATURE_DIFF_DIR is not set
+# CONFIG_ED is not set
+# CONFIG_PATCH is not set
+# CONFIG_SED is not set
+# CONFIG_VI is not set
+CONFIG_FEATURE_VI_MAX_LEN=0
+# CONFIG_FEATURE_VI_8BIT is not set
+# CONFIG_FEATURE_VI_COLON is not set
+# CONFIG_FEATURE_VI_YANKMARK is not set
+# CONFIG_FEATURE_VI_SEARCH is not set
+# CONFIG_FEATURE_VI_REGEX_SEARCH is not set
+# CONFIG_FEATURE_VI_USE_SIGNALS is not set
+# CONFIG_FEATURE_VI_DOT_CMD is not set
+# CONFIG_FEATURE_VI_READONLY is not set
+# CONFIG_FEATURE_VI_SETOPTS is not set
+# CONFIG_FEATURE_VI_SET is not set
+# CONFIG_FEATURE_VI_WIN_RESIZE is not set
+# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
+# CONFIG_FEATURE_VI_UNDO is not set
+# CONFIG_FEATURE_VI_UNDO_QUEUE is not set
+CONFIG_FEATURE_VI_UNDO_QUEUE_MAX=0
+# CONFIG_FEATURE_ALLOW_EXEC is not set
+
+#
+# Finding Utilities
+#
+# CONFIG_FIND is not set
+# CONFIG_FEATURE_FIND_PRINT0 is not set
+# CONFIG_FEATURE_FIND_MTIME is not set
+# CONFIG_FEATURE_FIND_MMIN is not set
+# CONFIG_FEATURE_FIND_PERM is not set
+# CONFIG_FEATURE_FIND_TYPE is not set
+# CONFIG_FEATURE_FIND_XDEV is not set
+# CONFIG_FEATURE_FIND_MAXDEPTH is not set
+# CONFIG_FEATURE_FIND_NEWER is not set
+# CONFIG_FEATURE_FIND_INUM is not set
+# CONFIG_FEATURE_FIND_EXEC is not set
+# CONFIG_FEATURE_FIND_EXEC_PLUS is not set
+# CONFIG_FEATURE_FIND_USER is not set
+# CONFIG_FEATURE_FIND_GROUP is not set
+# CONFIG_FEATURE_FIND_NOT is not set
+# CONFIG_FEATURE_FIND_DEPTH is not set
+# CONFIG_FEATURE_FIND_PAREN is not set
+# CONFIG_FEATURE_FIND_SIZE is not set
+# CONFIG_FEATURE_FIND_PRUNE is not set
+# CONFIG_FEATURE_FIND_DELETE is not set
+# CONFIG_FEATURE_FIND_PATH is not set
+# CONFIG_FEATURE_FIND_REGEX is not set
+# CONFIG_FEATURE_FIND_CONTEXT is not set
+# CONFIG_FEATURE_FIND_LINKS is not set
+# CONFIG_GREP is not set
+# CONFIG_EGREP is not set
+# CONFIG_FGREP is not set
+# CONFIG_FEATURE_GREP_CONTEXT is not set
+# CONFIG_XARGS is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_QUOTES is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR is not set
+
+#
+# Init Utilities
+#
+# CONFIG_BOOTCHARTD is not set
+# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
+# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
+# CONFIG_HALT is not set
+# CONFIG_POWEROFF is not set
+# CONFIG_REBOOT is not set
+# CONFIG_FEATURE_CALL_TELINIT is not set
+CONFIG_TELINIT_PATH=""
+# CONFIG_INIT is not set
+# CONFIG_LINUXRC is not set
+# CONFIG_FEATURE_USE_INITTAB is not set
+# CONFIG_FEATURE_KILL_REMOVED is not set
+CONFIG_FEATURE_KILL_DELAY=0
+# CONFIG_FEATURE_INIT_SCTTY is not set
+# CONFIG_FEATURE_INIT_SYSLOG is not set
+# CONFIG_FEATURE_INIT_QUIET is not set
+# CONFIG_FEATURE_INIT_COREDUMPS is not set
+CONFIG_INIT_TERMINAL_TYPE=""
+# CONFIG_FEATURE_INIT_MODIFY_CMDLINE is not set
+
+#
+# Login/Password Management Utilities
+#
+# CONFIG_FEATURE_SHADOWPASSWDS is not set
+# CONFIG_USE_BB_PWD_GRP is not set
+# CONFIG_USE_BB_SHADOW is not set
+# CONFIG_USE_BB_CRYPT is not set
+# CONFIG_USE_BB_CRYPT_SHA is not set
+# CONFIG_ADD_SHELL is not set
+# CONFIG_REMOVE_SHELL is not set
+# CONFIG_ADDGROUP is not set
+# CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS is not set
+# CONFIG_FEATURE_ADDUSER_TO_GROUP is not set
+# CONFIG_ADDUSER is not set
+# CONFIG_FEATURE_ADDUSER_LONG_OPTIONS is not set
+# CONFIG_FEATURE_CHECK_NAMES is not set
+CONFIG_LAST_ID=0
+CONFIG_FIRST_SYSTEM_ID=0
+CONFIG_LAST_SYSTEM_ID=0
+# CONFIG_CHPASSWD is not set
+CONFIG_FEATURE_DEFAULT_PASSWD_ALGO=""
+# CONFIG_CRYPTPW is not set
+# CONFIG_MKPASSWD is not set
+# CONFIG_DELUSER is not set
+# CONFIG_DELGROUP is not set
+# CONFIG_FEATURE_DEL_USER_FROM_GROUP is not set
+# CONFIG_GETTY is not set
+# CONFIG_LOGIN is not set
+# CONFIG_LOGIN_SESSION_AS_CHILD is not set
+# CONFIG_LOGIN_SCRIPTS is not set
+# CONFIG_FEATURE_NOLOGIN is not set
+# CONFIG_FEATURE_SECURETTY is not set
+# CONFIG_NOLOGIN is not set
+# CONFIG_PASSWD is not set
+# CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set
+# CONFIG_SU is not set
+# CONFIG_FEATURE_SU_SYSLOG is not set
+# CONFIG_FEATURE_SU_CHECKS_SHELLS is not set
+# CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set
+# CONFIG_SULOGIN is not set
+# CONFIG_VLOCK is not set
+
+#
+# Linux Ext2 FS Progs
+#
+# CONFIG_CHATTR is not set
+# CONFIG_FSCK is not set
+# CONFIG_LSATTR is not set
+# CONFIG_TUNE2FS is not set
+
+#
+# Linux Module Utilities
+#
+# CONFIG_MODPROBE_SMALL is not set
+# CONFIG_DEPMOD is not set
+# CONFIG_INSMOD is not set
+# CONFIG_LSMOD is not set
+# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
+# CONFIG_MODINFO is not set
+# CONFIG_MODPROBE is not set
+# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
+# CONFIG_RMMOD is not set
+
+#
+# Options common to multiple modutils
+#
+# CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS is not set
+# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
+# CONFIG_FEATURE_2_4_MODULES is not set
+# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
+# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
+# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
+# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
+# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
+# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
+# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
+# CONFIG_FEATURE_MODUTILS_ALIAS is not set
+# CONFIG_FEATURE_MODUTILS_BIN is not set
+# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
+CONFIG_DEFAULT_MODULES_DIR=""
+CONFIG_DEFAULT_DEPMOD_FILE=""
+
+#
+# Linux System Utilities
+#
+# CONFIG_ACPID is not set
+# CONFIG_FEATURE_ACPID_COMPAT is not set
+# CONFIG_BLKDISCARD is not set
+# CONFIG_BLKID is not set
+# CONFIG_FEATURE_BLKID_TYPE is not set
+# CONFIG_BLOCKDEV is not set
+# CONFIG_CAL is not set
+# CONFIG_CHRT is not set
+# CONFIG_DMESG is not set
+# CONFIG_FEATURE_DMESG_PRETTY is not set
+# CONFIG_EJECT is not set
+# CONFIG_FEATURE_EJECT_SCSI is not set
+# CONFIG_FALLOCATE is not set
+# CONFIG_FATATTR is not set
+# CONFIG_FBSET is not set
+# CONFIG_FEATURE_FBSET_FANCY is not set
+# CONFIG_FEATURE_FBSET_READMODE is not set
+# CONFIG_FDFORMAT is not set
+# CONFIG_FDISK is not set
+# CONFIG_FDISK_SUPPORT_LARGE_DISKS is not set
+# CONFIG_FEATURE_FDISK_WRITABLE is not set
+# CONFIG_FEATURE_AIX_LABEL is not set
+# CONFIG_FEATURE_SGI_LABEL is not set
+# CONFIG_FEATURE_SUN_LABEL is not set
+# CONFIG_FEATURE_OSF_LABEL is not set
+# CONFIG_FEATURE_GPT_LABEL is not set
+# CONFIG_FEATURE_FDISK_ADVANCED is not set
+# CONFIG_FINDFS is not set
+# CONFIG_FLOCK is not set
+# CONFIG_FDFLUSH is not set
+# CONFIG_FREERAMDISK is not set
+# CONFIG_FSCK_MINIX is not set
+# CONFIG_FSFREEZE is not set
+# CONFIG_FSTRIM is not set
+# CONFIG_GETOPT is not set
+# CONFIG_FEATURE_GETOPT_LONG is not set
+# CONFIG_HEXDUMP is not set
+# CONFIG_FEATURE_HEXDUMP_REVERSE is not set
+# CONFIG_HD is not set
+# CONFIG_XXD is not set
+# CONFIG_HWCLOCK is not set
+# CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS is not set
+# CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS is not set
+# CONFIG_IONICE is not set
+# CONFIG_IPCRM is not set
+# CONFIG_IPCS is not set
+# CONFIG_LAST is not set
+# CONFIG_FEATURE_LAST_FANCY is not set
+# CONFIG_LOSETUP is not set
+# CONFIG_LSPCI is not set
+# CONFIG_LSUSB is not set
+# CONFIG_MDEV is not set
+# CONFIG_FEATURE_MDEV_CONF is not set
+# CONFIG_FEATURE_MDEV_RENAME is not set
+# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set
+# CONFIG_FEATURE_MDEV_EXEC is not set
+# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set
+# CONFIG_MESG is not set
+# CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP is not set
+# CONFIG_MKE2FS is not set
+# CONFIG_MKFS_EXT2 is not set
+# CONFIG_MKFS_MINIX is not set
+# CONFIG_FEATURE_MINIX2 is not set
+# CONFIG_MKFS_REISER is not set
+# CONFIG_MKDOSFS is not set
+# CONFIG_MKFS_VFAT is not set
+# CONFIG_MKSWAP is not set
+# CONFIG_FEATURE_MKSWAP_UUID is not set
+# CONFIG_MORE is not set
+# CONFIG_MOUNT is not set
+# CONFIG_FEATURE_MOUNT_FAKE is not set
+# CONFIG_FEATURE_MOUNT_VERBOSE is not set
+# CONFIG_FEATURE_MOUNT_HELPERS is not set
+# CONFIG_FEATURE_MOUNT_LABEL is not set
+# CONFIG_FEATURE_MOUNT_NFS is not set
+# CONFIG_FEATURE_MOUNT_CIFS is not set
+# CONFIG_FEATURE_MOUNT_FLAGS is not set
+# CONFIG_FEATURE_MOUNT_FSTAB is not set
+# CONFIG_FEATURE_MOUNT_OTHERTAB is not set
+# CONFIG_MOUNTPOINT is not set
+# CONFIG_NSENTER is not set
+# CONFIG_FEATURE_NSENTER_LONG_OPTS is not set
+# CONFIG_PIVOT_ROOT is not set
+# CONFIG_RDATE is not set
+# CONFIG_RDEV is not set
+# CONFIG_READPROFILE is not set
+# CONFIG_RENICE is not set
+# CONFIG_REV is not set
+# CONFIG_RTCWAKE is not set
+# CONFIG_SCRIPT is not set
+# CONFIG_SCRIPTREPLAY is not set
+# CONFIG_SETARCH is not set
+# CONFIG_LINUX32 is not set
+# CONFIG_LINUX64 is not set
+# CONFIG_SETPRIV is not set
+# CONFIG_SETSID is not set
+# CONFIG_SWAPON is not set
+# CONFIG_FEATURE_SWAPON_DISCARD is not set
+# CONFIG_FEATURE_SWAPON_PRI is not set
+# CONFIG_SWAPOFF is not set
+# CONFIG_SWITCH_ROOT is not set
+# CONFIG_TASKSET is not set
+# CONFIG_FEATURE_TASKSET_FANCY is not set
+# CONFIG_UEVENT is not set
+# CONFIG_UMOUNT is not set
+# CONFIG_FEATURE_UMOUNT_ALL is not set
+# CONFIG_UNSHARE is not set
+# CONFIG_WALL is not set
+# CONFIG_FEATURE_MOUNT_LOOP is not set
+# CONFIG_FEATURE_MOUNT_LOOP_CREATE is not set
+# CONFIG_FEATURE_MTAB_SUPPORT is not set
+# CONFIG_VOLUMEID is not set
+# CONFIG_FEATURE_VOLUMEID_BCACHE is not set
+# CONFIG_FEATURE_VOLUMEID_BTRFS is not set
+# CONFIG_FEATURE_VOLUMEID_CRAMFS is not set
+# CONFIG_FEATURE_VOLUMEID_EXFAT is not set
+# CONFIG_FEATURE_VOLUMEID_EXT is not set
+# CONFIG_FEATURE_VOLUMEID_F2FS is not set
+# CONFIG_FEATURE_VOLUMEID_FAT is not set
+# CONFIG_FEATURE_VOLUMEID_HFS is not set
+# CONFIG_FEATURE_VOLUMEID_ISO9660 is not set
+# CONFIG_FEATURE_VOLUMEID_JFS is not set
+# CONFIG_FEATURE_VOLUMEID_LINUXRAID is not set
+# CONFIG_FEATURE_VOLUMEID_LINUXSWAP is not set
+# CONFIG_FEATURE_VOLUMEID_LUKS is not set
+# CONFIG_FEATURE_VOLUMEID_NILFS is not set
+# CONFIG_FEATURE_VOLUMEID_NTFS is not set
+# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set
+# CONFIG_FEATURE_VOLUMEID_REISERFS is not set
+# CONFIG_FEATURE_VOLUMEID_ROMFS is not set
+# CONFIG_FEATURE_VOLUMEID_SQUASHFS is not set
+# CONFIG_FEATURE_VOLUMEID_SYSV is not set
+# CONFIG_FEATURE_VOLUMEID_UBIFS is not set
+# CONFIG_FEATURE_VOLUMEID_UDF is not set
+# CONFIG_FEATURE_VOLUMEID_XFS is not set
+
+#
+# Miscellaneous Utilities
+#
+# CONFIG_ADJTIMEX is not set
+# CONFIG_BBCONFIG is not set
+# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set
+# CONFIG_BEEP is not set
+CONFIG_FEATURE_BEEP_FREQ=0
+CONFIG_FEATURE_BEEP_LENGTH_MS=0
+# CONFIG_CHAT is not set
+# CONFIG_FEATURE_CHAT_NOFAIL is not set
+# CONFIG_FEATURE_CHAT_TTY_HIFI is not set
+# CONFIG_FEATURE_CHAT_IMPLICIT_CR is not set
+# CONFIG_FEATURE_CHAT_SWALLOW_OPTS is not set
+# CONFIG_FEATURE_CHAT_SEND_ESCAPES is not set
+# CONFIG_FEATURE_CHAT_VAR_ABORT_LEN is not set
+# CONFIG_FEATURE_CHAT_CLR_ABORT is not set
+# CONFIG_CONSPY is not set
+# CONFIG_CROND is not set
+# CONFIG_FEATURE_CROND_D is not set
+# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
+CONFIG_FEATURE_CROND_DIR=""
+# CONFIG_CRONTAB is not set
+# CONFIG_DC is not set
+# CONFIG_FEATURE_DC_LIBM is not set
+# CONFIG_DEVFSD is not set
+# CONFIG_DEVFSD_MODLOAD is not set
+# CONFIG_DEVFSD_FG_NP is not set
+# CONFIG_DEVFSD_VERBOSE is not set
+# CONFIG_FEATURE_DEVFS is not set
+# CONFIG_DEVMEM is not set
+# CONFIG_FBSPLASH is not set
+# CONFIG_FLASH_ERASEALL is not set
+# CONFIG_FLASH_LOCK is not set
+# CONFIG_FLASH_UNLOCK is not set
+# CONFIG_FLASHCP is not set
+# CONFIG_HDPARM is not set
+# CONFIG_FEATURE_HDPARM_GET_IDENTITY is not set
+# CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set
+# CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set
+# CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set
+# CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set
+# CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA is not set
+# CONFIG_I2CGET is not set
+# CONFIG_I2CSET is not set
+# CONFIG_I2CDUMP is not set
+# CONFIG_I2CDETECT is not set
+# CONFIG_INOTIFYD is not set
+# CONFIG_LESS is not set
+CONFIG_FEATURE_LESS_MAXLINES=0
+# CONFIG_FEATURE_LESS_BRACKETS is not set
+# CONFIG_FEATURE_LESS_FLAGS is not set
+# CONFIG_FEATURE_LESS_TRUNCATE is not set
+# CONFIG_FEATURE_LESS_MARKS is not set
+# CONFIG_FEATURE_LESS_REGEXP is not set
+# CONFIG_FEATURE_LESS_WINCH is not set
+# CONFIG_FEATURE_LESS_ASK_TERMINAL is not set
+# CONFIG_FEATURE_LESS_DASHCMD is not set
+# CONFIG_FEATURE_LESS_LINENUMS is not set
+# CONFIG_LSSCSI is not set
+# CONFIG_MAKEDEVS is not set
+# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
+# CONFIG_FEATURE_MAKEDEVS_TABLE is not set
+# CONFIG_MAN is not set
+# CONFIG_MICROCOM is not set
+# CONFIG_MT is not set
+# CONFIG_NANDWRITE is not set
+# CONFIG_NANDDUMP is not set
+# CONFIG_PARTPROBE is not set
+# CONFIG_RAIDAUTORUN is not set
+CONFIG_READAHEAD=y
+# CONFIG_RFKILL is not set
+# CONFIG_RUNLEVEL is not set
+# CONFIG_RX is not set
+# CONFIG_SETSERIAL is not set
+# CONFIG_STRINGS is not set
+# CONFIG_TIME is not set
+# CONFIG_TTYSIZE is not set
+# CONFIG_UBIATTACH is not set
+# CONFIG_UBIDETACH is not set
+# CONFIG_UBIMKVOL is not set
+# CONFIG_UBIRMVOL is not set
+# CONFIG_UBIRSVOL is not set
+# CONFIG_UBIUPDATEVOL is not set
+# CONFIG_UBIRENAME is not set
+# CONFIG_VOLNAME is not set
+# CONFIG_WATCHDOG is not set
+
+#
+# Networking Utilities
+#
+# CONFIG_FEATURE_IPV6 is not set
+# CONFIG_FEATURE_UNIX_LOCAL is not set
+# CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set
+# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
+# CONFIG_ARP is not set
+# CONFIG_ARPING is not set
+# CONFIG_BRCTL is not set
+# CONFIG_FEATURE_BRCTL_FANCY is not set
+# CONFIG_FEATURE_BRCTL_SHOW is not set
+CONFIG_DNSD=y
+# CONFIG_ETHER_WAKE is not set
+CONFIG_FTPD=y
+CONFIG_FEATURE_FTPD_WRITE=y
+CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y
+CONFIG_FEATURE_FTPD_AUTHENTICATION=y
+CONFIG_FTPGET=y
+CONFIG_FTPPUT=y
+# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
+# CONFIG_HOSTNAME is not set
+# CONFIG_DNSDOMAINNAME is not set
+CONFIG_HTTPD=y
+CONFIG_FEATURE_HTTPD_RANGES=y
+CONFIG_FEATURE_HTTPD_SETUID=y
+CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
+CONFIG_FEATURE_HTTPD_AUTH_MD5=y
+CONFIG_FEATURE_HTTPD_CGI=y
+CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
+CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
+CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y
+CONFIG_FEATURE_HTTPD_ERROR_PAGES=y
+CONFIG_FEATURE_HTTPD_PROXY=y
+CONFIG_FEATURE_HTTPD_GZIP=y
+# CONFIG_IFCONFIG is not set
+# CONFIG_FEATURE_IFCONFIG_STATUS is not set
+# CONFIG_FEATURE_IFCONFIG_SLIP is not set
+# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
+# CONFIG_FEATURE_IFCONFIG_HW is not set
+# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
+# CONFIG_IFENSLAVE is not set
+# CONFIG_IFPLUGD is not set
+# CONFIG_IFUP is not set
+# CONFIG_IFDOWN is not set
+CONFIG_IFUPDOWN_IFSTATE_PATH=""
+# CONFIG_FEATURE_IFUPDOWN_IP is not set
+# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
+# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
+# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
+# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
+CONFIG_INETD=y
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
+# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
+# CONFIG_FEATURE_INETD_RPC is not set
+# CONFIG_IP is not set
+# CONFIG_IPADDR is not set
+# CONFIG_IPLINK is not set
+# CONFIG_IPROUTE is not set
+# CONFIG_IPTUNNEL is not set
+# CONFIG_IPRULE is not set
+# CONFIG_IPNEIGH is not set
+# CONFIG_FEATURE_IP_ADDRESS is not set
+# CONFIG_FEATURE_IP_LINK is not set
+# CONFIG_FEATURE_IP_ROUTE is not set
+CONFIG_FEATURE_IP_ROUTE_DIR=""
+# CONFIG_FEATURE_IP_TUNNEL is not set
+# CONFIG_FEATURE_IP_RULE is not set
+# CONFIG_FEATURE_IP_NEIGH is not set
+# CONFIG_FEATURE_IP_RARE_PROTOCOLS is not set
+# CONFIG_IPCALC is not set
+# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set
+# CONFIG_FEATURE_IPCALC_FANCY is not set
+CONFIG_FAKEIDENTD=y
+# CONFIG_NAMEIF is not set
+# CONFIG_FEATURE_NAMEIF_EXTENDED is not set
+# CONFIG_NBDCLIENT is not set
+# CONFIG_NC is not set
+# CONFIG_NC_SERVER is not set
+# CONFIG_NC_EXTRA is not set
+# CONFIG_NC_110_COMPAT is not set
+# CONFIG_NETSTAT is not set
+# CONFIG_FEATURE_NETSTAT_WIDE is not set
+# CONFIG_FEATURE_NETSTAT_PRG is not set
+# CONFIG_NSLOOKUP is not set
+# CONFIG_NTPD is not set
+# CONFIG_FEATURE_NTPD_SERVER is not set
+# CONFIG_FEATURE_NTPD_CONF is not set
+# CONFIG_PING is not set
+# CONFIG_PING6 is not set
+# CONFIG_FEATURE_FANCY_PING is not set
+# CONFIG_PSCAN is not set
+# CONFIG_ROUTE is not set
+# CONFIG_SLATTACH is not set
+# CONFIG_SSL_CLIENT is not set
+# CONFIG_TCPSVD is not set
+# CONFIG_UDPSVD is not set
+CONFIG_TELNET=y
+CONFIG_FEATURE_TELNET_TTYPE=y
+CONFIG_FEATURE_TELNET_AUTOLOGIN=y
+CONFIG_FEATURE_TELNET_WIDTH=y
+CONFIG_TELNETD=y
+CONFIG_FEATURE_TELNETD_STANDALONE=y
+CONFIG_FEATURE_TELNETD_INETD_WAIT=y
+CONFIG_TFTP=y
+CONFIG_TFTPD=y
+
+#
+# Common options for tftp/tftpd
+#
+CONFIG_FEATURE_TFTP_GET=y
+CONFIG_FEATURE_TFTP_PUT=y
+CONFIG_FEATURE_TFTP_BLOCKSIZE=y
+CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
+# CONFIG_TFTP_DEBUG is not set
+# CONFIG_TLS is not set
+# CONFIG_TRACEROUTE is not set
+# CONFIG_TRACEROUTE6 is not set
+# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
+# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
+# CONFIG_TUNCTL is not set
+# CONFIG_FEATURE_TUNCTL_UG is not set
+# CONFIG_VCONFIG is not set
+# CONFIG_WGET is not set
+# CONFIG_FEATURE_WGET_LONG_OPTIONS is not set
+# CONFIG_FEATURE_WGET_STATUSBAR is not set
+# CONFIG_FEATURE_WGET_AUTHENTICATION is not set
+# CONFIG_FEATURE_WGET_TIMEOUT is not set
+# CONFIG_FEATURE_WGET_HTTPS is not set
+# CONFIG_FEATURE_WGET_OPENSSL is not set
+# CONFIG_WHOIS is not set
+# CONFIG_ZCIP is not set
+# CONFIG_UDHCPC6 is not set
+# CONFIG_FEATURE_UDHCPC6_RFC3646 is not set
+# CONFIG_FEATURE_UDHCPC6_RFC4704 is not set
+# CONFIG_FEATURE_UDHCPC6_RFC4833 is not set
+CONFIG_UDHCPD=y
+CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY=y
+CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC=y
+CONFIG_DHCPD_LEASES_FILE="/var/lib/udhcpd/udhcpd.leases"
+# CONFIG_DUMPLEASES is not set
+# CONFIG_DHCPRELAY is not set
+# CONFIG_UDHCPC is not set
+# CONFIG_FEATURE_UDHCPC_ARPING is not set
+# CONFIG_FEATURE_UDHCPC_SANITIZEOPT is not set
+CONFIG_UDHCPC_DEFAULT_SCRIPT=""
+# CONFIG_FEATURE_UDHCP_PORT is not set
+CONFIG_UDHCP_DEBUG=0
+CONFIG_FEATURE_UDHCP_RFC3397=y
+CONFIG_FEATURE_UDHCP_8021Q=y
+CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
+CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS=""
+
+#
+# Print Utilities
+#
+# CONFIG_LPD is not set
+# CONFIG_LPR is not set
+# CONFIG_LPQ is not set
+
+#
+# Mail Utilities
+#
+# CONFIG_MAKEMIME is not set
+# CONFIG_POPMAILDIR is not set
+# CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set
+# CONFIG_REFORMIME is not set
+# CONFIG_FEATURE_REFORMIME_COMPAT is not set
+# CONFIG_SENDMAIL is not set
+CONFIG_FEATURE_MIME_CHARSET=""
+
+#
+# Process Utilities
+#
+# CONFIG_FREE is not set
+# CONFIG_FUSER is not set
+# CONFIG_IOSTAT is not set
+# CONFIG_KILL is not set
+# CONFIG_KILLALL is not set
+# CONFIG_KILLALL5 is not set
+# CONFIG_LSOF is not set
+# CONFIG_MPSTAT is not set
+# CONFIG_NMETER is not set
+# CONFIG_PGREP is not set
+# CONFIG_PKILL is not set
+# CONFIG_PIDOF is not set
+# CONFIG_FEATURE_PIDOF_SINGLE is not set
+# CONFIG_FEATURE_PIDOF_OMIT is not set
+# CONFIG_PMAP is not set
+# CONFIG_POWERTOP is not set
+# CONFIG_FEATURE_POWERTOP_INTERACTIVE is not set
+# CONFIG_PS is not set
+# CONFIG_FEATURE_PS_WIDE is not set
+# CONFIG_FEATURE_PS_LONG is not set
+# CONFIG_FEATURE_PS_TIME is not set
+# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
+# CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
+# CONFIG_PSTREE is not set
+# CONFIG_PWDX is not set
+# CONFIG_SMEMCAP is not set
+# CONFIG_BB_SYSCTL is not set
+# CONFIG_TOP is not set
+# CONFIG_FEATURE_TOP_INTERACTIVE is not set
+# CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set
+# CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set
+# CONFIG_FEATURE_TOP_SMP_CPU is not set
+# CONFIG_FEATURE_TOP_DECIMALS is not set
+# CONFIG_FEATURE_TOP_SMP_PROCESS is not set
+# CONFIG_FEATURE_TOPMEM is not set
+# CONFIG_UPTIME is not set
+# CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set
+# CONFIG_WATCH is not set
+# CONFIG_FEATURE_SHOW_THREADS is not set
+
+#
+# Runit Utilities
+#
+# CONFIG_CHPST is not set
+# CONFIG_SETUIDGID is not set
+# CONFIG_ENVUIDGID is not set
+# CONFIG_ENVDIR is not set
+# CONFIG_SOFTLIMIT is not set
+# CONFIG_RUNSV is not set
+# CONFIG_RUNSVDIR is not set
+# CONFIG_FEATURE_RUNSVDIR_LOG is not set
+# CONFIG_SV is not set
+CONFIG_SV_DEFAULT_SERVICE_DIR=""
+# CONFIG_SVC is not set
+# CONFIG_SVLOGD is not set
+# CONFIG_CHCON is not set
+# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
+# CONFIG_GETENFORCE is not set
+# CONFIG_GETSEBOOL is not set
+# CONFIG_LOAD_POLICY is not set
+# CONFIG_MATCHPATHCON is not set
+# CONFIG_RUNCON is not set
+# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
+# CONFIG_SELINUXENABLED is not set
+# CONFIG_SESTATUS is not set
+# CONFIG_SETENFORCE is not set
+# CONFIG_SETFILES is not set
+# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
+# CONFIG_RESTORECON is not set
+# CONFIG_SETSEBOOL is not set
+
+#
+# Shells
+#
+# CONFIG_SH_IS_ASH is not set
+# CONFIG_SH_IS_HUSH is not set
+CONFIG_SH_IS_NONE=y
+# CONFIG_BASH_IS_ASH is not set
+# CONFIG_BASH_IS_HUSH is not set
+CONFIG_BASH_IS_NONE=y
+# CONFIG_ASH is not set
+# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
+# CONFIG_ASH_INTERNAL_GLOB is not set
+# CONFIG_ASH_BASH_COMPAT is not set
+# CONFIG_ASH_JOB_CONTROL is not set
+# CONFIG_ASH_ALIAS is not set
+# CONFIG_ASH_RANDOM_SUPPORT is not set
+# CONFIG_ASH_EXPAND_PRMT is not set
+# CONFIG_ASH_IDLE_TIMEOUT is not set
+# CONFIG_ASH_MAIL is not set
+# CONFIG_ASH_ECHO is not set
+# CONFIG_ASH_PRINTF is not set
+# CONFIG_ASH_TEST is not set
+# CONFIG_ASH_HELP is not set
+# CONFIG_ASH_GETOPTS is not set
+# CONFIG_ASH_CMDCMD is not set
+# CONFIG_ASH_COMMAND_NOT_FOUND_HOOK is not set
+# CONFIG_CTTYHACK is not set
+# CONFIG_HUSH is not set
+# CONFIG_HUSH_BASH_COMPAT is not set
+# CONFIG_HUSH_BRACE_EXPANSION is not set
+# CONFIG_HUSH_INTERACTIVE is not set
+# CONFIG_HUSH_SAVEHISTORY is not set
+# CONFIG_HUSH_JOB is not set
+# CONFIG_HUSH_TICK is not set
+# CONFIG_HUSH_IF is not set
+# CONFIG_HUSH_LOOPS is not set
+# CONFIG_HUSH_CASE is not set
+# CONFIG_HUSH_FUNCTIONS is not set
+# CONFIG_HUSH_LOCAL is not set
+# CONFIG_HUSH_RANDOM_SUPPORT is not set
+# CONFIG_HUSH_MODE_X is not set
+# CONFIG_HUSH_ECHO is not set
+# CONFIG_HUSH_PRINTF is not set
+# CONFIG_HUSH_TEST is not set
+# CONFIG_HUSH_HELP is not set
+# CONFIG_HUSH_EXPORT is not set
+# CONFIG_HUSH_EXPORT_N is not set
+# CONFIG_HUSH_KILL is not set
+# CONFIG_HUSH_WAIT is not set
+# CONFIG_HUSH_TRAP is not set
+# CONFIG_HUSH_TYPE is not set
+# CONFIG_HUSH_READ is not set
+# CONFIG_HUSH_SET is not set
+# CONFIG_HUSH_UNSET is not set
+# CONFIG_HUSH_ULIMIT is not set
+# CONFIG_HUSH_UMASK is not set
+# CONFIG_HUSH_MEMLEAK is not set
+# CONFIG_MSH is not set
+
+#
+# Options common to all shells
+#
+# CONFIG_FEATURE_SH_MATH is not set
+# CONFIG_FEATURE_SH_MATH_64 is not set
+# CONFIG_FEATURE_SH_EXTRA_QUIET is not set
+# CONFIG_FEATURE_SH_STANDALONE is not set
+# CONFIG_FEATURE_SH_NOFORK is not set
+# CONFIG_FEATURE_SH_HISTFILESIZE is not set
+
+#
+# System Logging Utilities
+#
+# CONFIG_KLOGD is not set
+# CONFIG_FEATURE_KLOGD_KLOGCTL is not set
+# CONFIG_LOGGER is not set
+# CONFIG_LOGREAD is not set
+# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set
+# CONFIG_SYSLOGD is not set
+# CONFIG_FEATURE_ROTATE_LOGFILE is not set
+# CONFIG_FEATURE_REMOTE_LOG is not set
+# CONFIG_FEATURE_SYSLOGD_DUP is not set
+# CONFIG_FEATURE_SYSLOGD_CFG is not set
+CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0
+# CONFIG_FEATURE_IPC_SYSLOG is not set
+CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
+# CONFIG_FEATURE_KMSG_SYSLOG is not set
diff --git a/system/busybox/dad.if-up b/system/busybox/dad.if-up
new file mode 100644
index 000000000..e76bb60bf
--- /dev/null
+++ b/system/busybox/dad.if-up
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Block ifup until DAD completion
+# Copyright (c) 2016 Kaarle Ritvanen
+
+while ip address show dev $IFACE | grep -q " tentative "; do
+ sleep 0.2
+done
diff --git a/system/busybox/nologin.c b/system/busybox/nologin.c
new file mode 100644
index 000000000..e0a4c56c7
--- /dev/null
+++ b/system/busybox/nologin.c
@@ -0,0 +1,38 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * nologin implementation for busybox
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+//config:config NOLOGIN
+//config: bool "nologin"
+//config: default n
+//config: help
+//config: nologin is a tool that is supposed to be the shell for user accounts
+//config: that are not supposed to login.
+
+//applet:IF_NOLOGIN(APPLET(nologin, BB_DIR_SBIN, BB_SUID_DROP))
+//kbuild:lib-$(CONFIG_NOLOGIN) += nologin.o
+
+//usage:#define nologin_trivial_usage
+//usage: ""
+//usage:#define nologin_full_usage "\n\n"
+//usage: "politely refuse a login\n"
+
+#include "libbb.h"
+#include <syslog.h>
+
+#define _NOLOGIN_TXT "/etc/nologin.txt"
+
+int nologin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int nologin_main(int argc UNUSED_PARAM, char **argv)
+{
+ int fd;
+ fd = open(_NOLOGIN_TXT, O_RDONLY);
+ if (bb_copyfd_eof(fd, STDOUT_FILENO) == -1)
+ bb_error_msg_and_die("this account is not available");
+ close(fd);
+ return 1;
+}
+
diff --git a/system/busybox/top-buffer-overflow.patch b/system/busybox/top-buffer-overflow.patch
new file mode 100644
index 000000000..14b23c648
--- /dev/null
+++ b/system/busybox/top-buffer-overflow.patch
@@ -0,0 +1,20 @@
+--- busybox-1.27.0.orig/procps/top.c
++++ busybox-1.27.0/procps/top.c
+@@ -694,10 +694,14 @@
+ CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift);
+ #endif
+
+- if (s->vsz >= 100000)
+- sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
++ if ((s->vsz / (1024 * 1024)) >= 100000)
++ snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldt", s->vsz/(1024 * 1024 * 1024));
++ else if ((s->vsz / 1024) >= 100000)
++ snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldg", s->vsz/(1024 * 1024));
++ else if (s->vsz >= 100000)
++ snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldm", s->vsz/1024);
+ else
+- sprintf(vsz_str_buf, "%7lu", s->vsz);
++ snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%7lu", s->vsz);
+ /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
+ col = snprintf(line_buf, scr_width,
+ "\n" "%5u%6u %-8.8s %s%s" FMT
diff --git a/system/c-ares/APKBUILD b/system/c-ares/APKBUILD
new file mode 100644
index 000000000..98fbe2eb1
--- /dev/null
+++ b/system/c-ares/APKBUILD
@@ -0,0 +1,46 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=c-ares
+pkgver=1.13.0
+pkgrel=0
+pkgdesc="An asynchronously DNS/names resolver library"
+url="http://c-ares.haxx.se/"
+arch="all"
+license="MIT"
+depends=""
+makedepends=""
+subpackages="$pkgname-doc $pkgname-dev"
+options="!checkroot"
+source="http://c-ares.haxx.se/download/$pkgname-$pkgver.tar.gz"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$_builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-shared
+ make
+}
+
+check() {
+ cd "$_builddir"
+
+ # This is only needed for < 1.14.0, where the .sh file was not
+ # distributed properly - see https://da.gd/carestest
+ echo "#!/bin/true" > test/fuzzcheck.sh
+ chmod a+x test/fuzzcheck.sh
+
+ make -C test check
+}
+
+package() {
+ cd "$_builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+sha512sums="4a7942e754673f5b8d55a7471e31b0f390e8324b14c12077580c956147fad4d165c7fe8a3190199b1add95c710ceeb1a7957706d4f0d6299d39c5dddc719bd9d c-ares-1.13.0.tar.gz"
diff --git a/system/ca-certificates/APKBUILD b/system/ca-certificates/APKBUILD
new file mode 100644
index 000000000..81194471e
--- /dev/null
+++ b/system/ca-certificates/APKBUILD
@@ -0,0 +1,54 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ca-certificates
+pkgver=20170801
+pkgrel=0
+pkgdesc="Common CA certificates PEM files"
+url="https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/"
+arch="all"
+license="MPL 2.0 GPL2+"
+depends=""
+makedepends_build="python3"
+makedepends_host="openssl-dev"
+subpackages="$pkgname-doc"
+# c_rehash is either in libcrypto1.0 or openssl depending on package, grr. replace both of them
+replaces="libcrypto1.0 openssl"
+options="!fhs !check"
+triggers="ca-certificates.trigger=/usr/share/ca-certificates:/usr/local/share/ca-certificates:/etc/ssl/certs:/etc/ca-certificates/update.d"
+install="$pkgname.post-deinstall"
+source="https://git.alpinelinux.org/cgit/ca-certificates/snapshot/ca-certificates-$pkgver.tar.bz2"
+builddir="$srcdir/ca-certificates-$pkgver"
+
+build() {
+ cd "$builddir"
+ make
+}
+
+package() {
+ cd "$builddir"
+ make install DESTDIR="$pkgdir"
+
+ (
+ echo "# Automatically generated by ${pkgname}-${pkgver}-${pkgrel}"
+ echo "# $(date -u)"
+ echo "# Do not edit."
+ cd "$pkgdir"/usr/share/ca-certificates
+ find . -name '*.crt' | sort | cut -b3-
+ ) > "$pkgdir"/etc/ca-certificates.conf
+
+ mkdir -p "$pkgdir"/etc/apk/protected_paths.d
+ cat > "$pkgdir"/etc/apk/protected_paths.d/ca-certificates.list <<-EOF
+ -etc/ssl/certs/ca-certificates.crt
+ -etc/ssl/certs/ca-cert-*.pem
+ -etc/ssl/certs/[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[r0-9]*
+ EOF
+
+ cat > "$pkgdir"/etc/ca-certificates/update.d/certhash <<-EOF
+ #!/bin/sh
+ exec /usr/bin/c_rehash /etc/ssl/certs
+ EOF
+ chmod +x "$pkgdir"/etc/ca-certificates/update.d/certhash
+}
+
+sha512sums="2b3de9f4ed1ae2ee66d428598f5878e3c773a7475102a234332c1430e202fa1d23889365a725a1aef3531c8c56718d206f95e02284af994d2330b3fc92f96ea2 ca-certificates-20170801.tar.bz2"
diff --git a/system/ca-certificates/ca-certificates.post-deinstall b/system/ca-certificates/ca-certificates.post-deinstall
new file mode 100644
index 000000000..ead634716
--- /dev/null
+++ b/system/ca-certificates/ca-certificates.post-deinstall
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# clean up broken symlinks and ca-certificates.crt store
+find -L /etc/ssl/certs -maxdepth 1 \( -type l -o -name ca-certificates.crt \) \
+ -delete
+rmdir /etc/ssl/certs 2>/dev/null || true
+
diff --git a/system/ca-certificates/ca-certificates.trigger b/system/ca-certificates/ca-certificates.trigger
new file mode 100644
index 000000000..eff198163
--- /dev/null
+++ b/system/ca-certificates/ca-certificates.trigger
@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/sbin/update-ca-certificates --fresh &> /dev/null
+exit 0
diff --git a/system/check/APKBUILD b/system/check/APKBUILD
new file mode 100644
index 000000000..09af1b010
--- /dev/null
+++ b/system/check/APKBUILD
@@ -0,0 +1,42 @@
+# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
+# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
+pkgname=check
+pkgver=0.12.0
+pkgrel=1
+pkgdesc="A unit test framework for C"
+url="https://libcheck.github.io/check/"
+arch="all"
+license="LGPL2+"
+makedepends="pkgconfig"
+checkdepends="diffutils"
+subpackages="$pkgname-doc $pkgname-dev"
+source="https://github.com/libcheck/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.gz"
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ # NOTE: disabled forking due to hardened
+ # https://github.com/libcheck/check/issues/138
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var \
+ --disable-fork
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="403454d166ddd4e25f96d6c52028f4173f4a5ad4a249dd782e3a8d5db1ad0178956d74577cf0d4c963a5a7d09077a59042a74f74d6b528b7212e18ab5def1dd9 check-0.12.0.tar.gz"
diff --git a/system/cmake/APKBUILD b/system/cmake/APKBUILD
new file mode 100644
index 000000000..b89114090
--- /dev/null
+++ b/system/cmake/APKBUILD
@@ -0,0 +1,59 @@
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=cmake
+pkgver=3.9.5
+pkgrel=0
+pkgdesc="CMake is a cross-platform open-source make system"
+url="http://www.cmake.org"
+arch="all"
+license="CMake"
+makedepends="ncurses-dev curl-dev expat-dev zlib-dev bzip2-dev libarchive-dev
+ libuv-dev xz-dev rhash-dev"
+options="!checkroot"
+checkdepends="musl-utils file"
+subpackages="$pkgname-doc"
+
+case $pkgver in
+*.*.*.*) _v=v${pkgver%.*.*};;
+*.*.*) _v=v${pkgver%.*};;
+esac
+
+source="http://www.cmake.org/files/$_v/cmake-${pkgver}.tar.gz"
+builddir="$srcdir/$pkgname-$pkgver"
+
+_parallel_opt() {
+ local i n
+ for i in $MAKEOPTS; do
+ case "$i" in
+ -j*) n=${i#-j};;
+ esac;
+ done
+ [ -n "$n" ] && echo "--parallel $n"
+}
+
+build() {
+ cd "$builddir"
+ # jsoncpp needs cmake to build so to avoid recursive build
+ # dependency, we use the bundled version of jsoncpp
+ ./bootstrap \
+ --prefix=/usr \
+ --mandir=/share/man \
+ --datadir=/share/$pkgname \
+ --docdir=/share/doc/$pkgname \
+ --system-libs \
+ --no-system-jsoncpp \
+ $(_parallel_opt)
+ make
+}
+
+check() {
+ cd "$builddir"
+ CTEST_OUTPUT_ON_FAILURE=TRUE bin/ctest
+}
+
+package() {
+ cd $startdir/src/$pkgname-$pkgver
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="71a0848a0c7048c210fe16fbd2b0c2870bd4c2140098225e94fac13a53059f4ae610139115ab8c153989886baa087d506b9ffbc7b91ddc157b0c85e3223828a0 cmake-3.9.5.tar.gz"
diff --git a/system/coreutils/051_all_coreutils-mangen.patch b/system/coreutils/051_all_coreutils-mangen.patch
new file mode 100644
index 000000000..388924d06
--- /dev/null
+++ b/system/coreutils/051_all_coreutils-mangen.patch
@@ -0,0 +1,120 @@
+--- coreutils-8.27/Makefile.in.old 2017-03-08 23:24:51.000000000 -0600
++++ coreutils-8.27/Makefile.in 2017-08-24 23:01:09.582964705 -0500
+@@ -14647,117 +14647,6 @@
+ distclean-local:
+ test x$(srcdir) = x$(builddir) || rm -f $(ALL_MANS)
+
+-$(ALL_MANS): $(mandeps)
+-# Most prog.1 man pages depend on src/prog. List the exceptions:
+-@SINGLE_BINARY_FALSE@man/install.1: src/ginstall$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/test.1: src/[$(EXEEXT)
+-
+-@SINGLE_BINARY_FALSE@man/arch.1: src/arch$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/b2sum.1: src/b2sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/base32.1: src/base32$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/base64.1: src/base64$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/basename.1: src/basename$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/cat.1: src/cat$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/chcon.1: src/chcon$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/chgrp.1: src/chgrp$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/chmod.1: src/chmod$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/chown.1: src/chown$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/chroot.1: src/chroot$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/cksum.1: src/cksum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/comm.1: src/comm$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/coreutils.1: src/coreutils$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/cp.1: src/cp$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/csplit.1: src/csplit$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/cut.1: src/cut$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/date.1: src/date$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/dd.1: src/dd$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/df.1: src/df$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/dir.1: src/dir$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/dircolors.1: src/dircolors$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/dirname.1: src/dirname$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/du.1: src/du$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/echo.1: src/echo$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/env.1: src/env$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/expand.1: src/expand$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/expr.1: src/expr$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/factor.1: src/factor$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/false.1: src/false$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/fmt.1: src/fmt$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/fold.1: src/fold$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/groups.1: src/groups$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/head.1: src/head$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/hostid.1: src/hostid$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/hostname.1: src/hostname$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/id.1: src/id$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/join.1: src/join$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/kill.1: src/kill$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/link.1: src/link$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/ln.1: src/ln$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/logname.1: src/logname$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/ls.1: src/ls$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/md5sum.1: src/md5sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/mkdir.1: src/mkdir$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/mkfifo.1: src/mkfifo$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/mknod.1: src/mknod$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/mktemp.1: src/mktemp$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/mv.1: src/mv$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/nice.1: src/nice$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/nl.1: src/nl$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/nohup.1: src/nohup$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/nproc.1: src/nproc$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/numfmt.1: src/numfmt$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/od.1: src/od$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/paste.1: src/paste$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/pathchk.1: src/pathchk$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/pinky.1: src/pinky$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/pr.1: src/pr$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/printenv.1: src/printenv$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/printf.1: src/printf$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/ptx.1: src/ptx$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/pwd.1: src/pwd$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/readlink.1: src/readlink$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/realpath.1: src/realpath$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/rm.1: src/rm$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/rmdir.1: src/rmdir$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/runcon.1: src/runcon$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/seq.1: src/seq$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sha1sum.1: src/sha1sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sha224sum.1: src/sha224sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sha256sum.1: src/sha256sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sha384sum.1: src/sha384sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sha512sum.1: src/sha512sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/shred.1: src/shred$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/shuf.1: src/shuf$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sleep.1: src/sleep$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sort.1: src/sort$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/split.1: src/split$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/stat.1: src/stat$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/stdbuf.1: src/stdbuf$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/stty.1: src/stty$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sum.1: src/sum$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/sync.1: src/sync$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/tac.1: src/tac$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/tail.1: src/tail$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/tee.1: src/tee$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/timeout.1: src/timeout$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/touch.1: src/touch$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/tr.1: src/tr$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/true.1: src/true$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/truncate.1: src/truncate$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/tsort.1: src/tsort$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/tty.1: src/tty$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/uname.1: src/uname$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/unexpand.1: src/unexpand$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/uniq.1: src/uniq$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/unlink.1: src/unlink$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/uptime.1: src/uptime$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/users.1: src/users$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/vdir.1: src/vdir$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/wc.1: src/wc$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/who.1: src/who$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/whoami.1: src/whoami$(EXEEXT)
+-@SINGLE_BINARY_FALSE@man/yes.1: src/yes$(EXEEXT)
+-
+ .x.1:
+ $(AM_V_GEN)name=`echo $@ | sed 's|.*/||; s|\.1$$||'` || exit 1; \
+ case $$name in \
diff --git a/system/coreutils/APKBUILD b/system/coreutils/APKBUILD
new file mode 100644
index 000000000..c92568720
--- /dev/null
+++ b/system/coreutils/APKBUILD
@@ -0,0 +1,79 @@
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=coreutils
+pkgver=8.28
+pkgrel=0
+pkgdesc="The basic file, shell and text manipulation utilities"
+url="http://www.gnu.org/software/coreutils/"
+arch="all"
+license="GPL3+"
+options="!checkroot"
+makedepends="bash acl-dev attr-dev gettext-dev"
+[ ${CBUILD} == ${CHOST} ] && makedepends="$makedepends perl"
+subpackages="$pkgname-doc"
+[ ${CBUILD} == ${CHOST} ] && subpackages="$subpackages $pkgname-lang"
+install="$pkgname.post-deinstall"
+source="http://ftp.gnu.org/gnu/coreutils/$pkgname-$pkgver.tar.xz
+ disable-mbrtowc-test.patch
+ localename-test-fix.patch
+ "
+[ ${CBUILD} != ${CHOST} ] && source="$source
+ 051_all_coreutils-mangen.patch
+ "
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ LIBS="-lrt" ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-nls \
+ --without-gmp \
+ --enable-no-install-program=hostname,su,kill,uptime \
+ --with-packager="Adélie" \
+ --with-packager-bug-reports="https://bts.adelielinux.org/"
+ if [ ${CBUILD} != ${CHOST} ]; then
+ set -- man/*.x
+ touch ${@/%x/1}
+ fi
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ rm -rf "$pkgdir"/usr/lib/charset.alias
+ rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
+
+ install -d "$pkgdir"/bin "$pkgdir"/usr/sbin
+ cd "$pkgdir"/usr/bin/
+
+ # binaries that busybox puts in /bin
+ mv base64 cat chgrp chmod chown cp date dd df 'echo' false ln ls \
+ mkdir mknod mktemp mv nice printenv pwd rm rmdir sleep stat \
+ stty sync touch true uname \
+ "$pkgdir"/bin
+
+ mv chroot "$pkgdir"/usr/sbin/
+}
+
+sha512sums="1e592d0dd03b9227bf92af9a82bed6dc3bcbee46e984c7fb09833dea0962e86b309aa34d5e43823b73d4522c066bfa5cdc8ec694aa190910fb246ff32ceb63a1 coreutils-8.28.tar.xz
+532ef8210261437855ba3e2fc72ec57b0e0252b2b0f7817990c9629613ece2cdd86cf30aa049f3cff6fbda12ed3bb9a0db3a3642475378ae44ce319bdf005d9b disable-mbrtowc-test.patch
+00a517c7e3e2206ba7a60f9126d28ae1d549e86da62b48f32250d49c2caf896c53fc3d803729b544a1cfb1609dd8cb7cb4b3473defef5d1e2c154ed1de6bc5de localename-test-fix.patch"
+
+[ ${CBUILD} != ${CHOST} ] && sha512sums="$sha512sums
+bae804f057252c25452ac178c545dc2c4b4775cbfbdcfd4775edd1a4ed6507882bfac39e2b11ad01b74230ca48d761bf62f11bde5bcbc35a6e5a61cbe4a46e36 051_all_coreutils-mangen.patch
+"
+return 0
diff --git a/system/coreutils/coreutils.post-deinstall b/system/coreutils/coreutils.post-deinstall
new file mode 100644
index 000000000..24e0bdf25
--- /dev/null
+++ b/system/coreutils/coreutils.post-deinstall
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# other post scripts might need rm so we don't wait for the trigger
+exec /bin/busybox --install -s
diff --git a/system/coreutils/disable-mbrtowc-test.patch b/system/coreutils/disable-mbrtowc-test.patch
new file mode 100644
index 000000000..d338e0324
--- /dev/null
+++ b/system/coreutils/disable-mbrtowc-test.patch
@@ -0,0 +1,10 @@
+--- coreutils-8.27/gnulib-tests/test-mbrtowc5.sh.old 2016-12-31 13:54:43.000000000 +0000
++++ coreutils-8.27/gnulib-tests/test-mbrtowc5.sh 2017-07-30 17:29:50.879924130 +0000
+@@ -1,6 +1,2 @@
+ #!/bin/sh
+-# Test whether the POSIX locale has encoding errors.
+-LC_ALL=C \
+-./test-mbrtowc${EXEEXT} 5 || exit
+-LC_ALL=POSIX \
+-./test-mbrtowc${EXEEXT} 5
++exit 77
diff --git a/system/coreutils/localename-test-fix.patch b/system/coreutils/localename-test-fix.patch
new file mode 100644
index 000000000..f90d11866
--- /dev/null
+++ b/system/coreutils/localename-test-fix.patch
@@ -0,0 +1,34 @@
+--- coreutils-8.27/gnulib-tests/localename.c.old 2016-12-31 13:54:43.000000000 +0000
++++ coreutils-8.27/gnulib-tests/localename.c 2017-07-30 16:40:47.098541270 +0000
+@@ -40,7 +40,7 @@
+ # if defined __APPLE__ && defined __MACH__
+ # include <xlocale.h>
+ # endif
+-# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || defined __CYGWIN__
++# if (defined __linux__ && !defined __UCLIBC__) || defined __CYGWIN__
+ # include <langinfo.h>
+ # endif
+ # if !defined IN_LIBINTL
+@@ -2692,16 +2692,19 @@
+ locale_t thread_locale = uselocale (NULL);
+ if (thread_locale != LC_GLOBAL_LOCALE)
+ {
+-# if __GLIBC__ >= 2 && !defined __UCLIBC__
++# if defined(_NL_LOCALE_NAME)
++ const char *name = nl_langinfo(_NL_LOCALE_NAME(category));
++# if __GLIBC__ >= 2 && !defined __UCLIBC__
+ /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+ glibc < 2.12.
+ See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
+- const char *name =
+- nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
++ if (name[0] == '\0')
++ name = nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
+ if (name[0] == '\0')
+ /* Fallback code for glibc < 2.4, which did not implement
+ nl_langinfo (_NL_LOCALE_NAME (category)). */
+ name = thread_locale->__names[category];
++# endif
+ return name;
+ # elif defined __FreeBSD__ || (defined __APPLE__ && defined __MACH__)
+ /* FreeBSD, Mac OS X */
diff --git a/system/coreutils/no-doc.patch b/system/coreutils/no-doc.patch
new file mode 100644
index 000000000..a1d74623b
--- /dev/null
+++ b/system/coreutils/no-doc.patch
@@ -0,0 +1,22 @@
+--- coreutils-8.27/Makefile.in.old 2017-03-09 05:24:51.000000000 +0000
++++ coreutils-8.27/Makefile.in 2017-06-22 03:07:59.568716258 +0000
+@@ -2363,7 +2363,7 @@
+ }
+ man1dir = $(mandir)/man1
+ NROFF = nroff
+-MANS = $(man1_MANS)
++MANS =
+ HEADERS = $(noinst_HEADERS)
+ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+--- coreutils-8.27/Makefile.in.old 2017-06-22 03:08:55.821951666 +0000
++++ coreutils-8.27/Makefile.in 2017-06-22 03:19:51.770820411 +0000
+@@ -12192,7 +12192,7 @@
+
+ info-am: $(INFO_DEPS)
+
+-install-data-am: install-info-am install-man
++install-data-am: install-info-am
+
+ install-dvi: install-dvi-recursive
+
diff --git a/system/coreutils/printf-musl.patch b/system/coreutils/printf-musl.patch
new file mode 100644
index 000000000..28a951635
--- /dev/null
+++ b/system/coreutils/printf-musl.patch
@@ -0,0 +1,53 @@
+From ad5c14dcadd4603363e68da960ed0101b61439bd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
+Date: Sat, 12 Aug 2017 23:53:33 -0700
+Subject: [PATCH] tests: fix false failure with large printf formats
+
+* tests/misc/printf-surprise.sh: With musl libc the
+large printf format does succeed, outputting data.
+To avoid SIGPIPE being generated we ignore that signal
+and then handle the subsequent EPIPE error.
+Reported by A. Wilcox
+---
+ tests/misc/printf-surprise.sh | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/tests/misc/printf-surprise.sh b/tests/misc/printf-surprise.sh
+index 2edd34c..46c0d8f 100755
+--- a/tests/misc/printf-surprise.sh
++++ b/tests/misc/printf-surprise.sh
+@@ -50,6 +50,9 @@ vm=$(get_min_ulimit_v_ env $prog %20f 0) \
+
+ mkfifo_or_skip_ fifo
+
++(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
++ skip_ 'trapping SIGPIPE is not supported'
++
+ # Disable MALLOC_PERTURB_, to avoid triggering this bug
+ # https://bugs.debian.org/481543#77
+ export MALLOC_PERTURB_=0
+@@ -60,11 +63,11 @@ cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+ head -c 10 fifo > out & pid=$!
+
+ # Trigger large mem allocation failure
+-( ulimit -v $vm && env $prog %20000000f 0 2>err-msg > fifo )
++( trap '' PIPE && ulimit -v $vm && env $prog %20000000f 0 2>err-msg > fifo )
+ exit=$?
+
+ # Map this longer, and rarer, diagnostic to the common one.
+-# printf: cannot perform formatted output: Cannot allocate memory" \
++# printf: cannot perform formatted output: Cannot allocate memory"
+ sed 's/cannot perform .*/write error/' err-msg > k && mv k err-msg
+ err_msg=$(tr '\n' : < err-msg)
+
+@@ -81,6 +84,7 @@ n_out=$(wc -c < out)
+
+ case $n_out:$diagnostic:$exit in
+ 10:n:0) ;; # ok, succeeds w/no diagnostic: FreeBSD 6.1
++ 10:y:1) ;; # ok, fails with EPIPE diagnostic: musl libc
+ 0:y:1) ;; # ok, glibc-2.8 and newer, when printf(3) fails with ENOMEM
+
+ # With MALLOC_PERTURB_=0, this no longer happens.
+--
+2.9.3
+
diff --git a/system/coreutils/seq-write-error.patch b/system/coreutils/seq-write-error.patch
new file mode 100644
index 000000000..4892a82ec
--- /dev/null
+++ b/system/coreutils/seq-write-error.patch
@@ -0,0 +1,45 @@
+From 1e1dbbe0f95c7170009f3ba4d8380c1b98ff53c8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
+Date: Sun, 13 Aug 2017 00:18:43 -0700
+Subject: [PATCH] seq: produce consistent error messages upon write error
+
+* src/seq.c (io_error): Use the same error message as would
+be generated at exit time when closing the stdout stream.
+The inconsistency was added with commit v8.25-26-gc92585b.
+This was noticed due to an inconsistency in the expected
+error message generated by seq on musl libc.
+Reported by A. Wilcox.
+---
+ src/seq.c | 2 +-
+ tests/misc/seq-epipe.sh | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/seq.c b/src/seq.c
+index bb191ba..5e5b381 100644
+--- a/src/seq.c
++++ b/src/seq.c
+@@ -284,7 +284,7 @@ io_error (void)
+ {
+ /* FIXME: consider option to silently ignore errno=EPIPE */
+ clearerr (stdout);
+- die (EXIT_FAILURE, errno, _("standard output"));
++ die (EXIT_FAILURE, errno, _("write error"));
+ }
+
+ /* Actually print the sequence of numbers in the specified range, with the
+diff --git a/tests/misc/seq-epipe.sh b/tests/misc/seq-epipe.sh
+index edbd563..69dd75d 100755
+--- a/tests/misc/seq-epipe.sh
++++ b/tests/misc/seq-epipe.sh
+@@ -33,7 +33,7 @@ compare exp code || fail=1
+
+ # The error message must begin with "standard output:"
+ # (but don't hard-code the strerror text)
+-grep '^seq: standard output: ' err \
++grep '^seq: write error: ' err \
+ || { warn_ "seq emitted incorrect error on EPIPE"; \
+ cat err;\
+ fail=1; }
+--
+2.9.3
+
diff --git a/system/coreutils/sort-debug-locale.patch b/system/coreutils/sort-debug-locale.patch
new file mode 100644
index 000000000..27921abbd
--- /dev/null
+++ b/system/coreutils/sort-debug-locale.patch
@@ -0,0 +1,79 @@
+From b938d8966c3d1afec9730d403fd6a6eb4d856b85 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
+Date: Sun, 13 Aug 2017 00:45:32 -0700
+Subject: [PATCH] sort: handle musl locale differences in --debug reporting
+
+* src/sort.c (main): Don't assume hard_LC_COLLATE implies
+a successful setting of the locale as musl defaults to
+UTF8 when failing to set the specified locale.
+* tests/misc/sort-debug-warn.sh: Adjust for the now
+separated locale debug info and map the musl specific
+message back to the common case.
+Reported by A. Wilcox.
+---
+ src/sort.c | 17 +++++++++--------
+ tests/misc/sort-debug-warn.sh | 9 +++++++--
+ 2 files changed, 16 insertions(+), 10 deletions(-)
+
+diff --git a/src/sort.c b/src/sort.c
+index 015e40e..ba6ceac 100644
+--- a/src/sort.c
++++ b/src/sort.c
+@@ -4675,18 +4675,19 @@ main (int argc, char **argv)
+
+ /* Always output the locale in debug mode, since this
+ is such a common source of confusion. */
++
++ /* OpenBSD can only set some categories with LC_ALL above,
++ so set LC_COLLATE explicitly to flag errors. */
++ if (locale_ok)
++ locale_ok = !! setlocale (LC_COLLATE, "");
++ if (! locale_ok)
++ error (0, 0, "%s", _("failed to set locale"));
+ if (hard_LC_COLLATE)
+ error (0, 0, _("using %s sorting rules"),
+ quote (setlocale (LC_COLLATE, NULL)));
+ else
+- {
+- /* OpenBSD can only set some categories with LC_ALL above,
+- so set LC_COLLATE explicitly to flag errors. */
+- if (locale_ok)
+- locale_ok = !! setlocale (LC_COLLATE, "");
+- error (0, 0, "%s%s", locale_ok ? "" : _("failed to set locale; "),
+- _("using simple byte comparison"));
+- }
++ error (0, 0, "%s", _("using simple byte comparison"));
++
+ key_warnings (&gkey, gkey_only);
+ }
+
+diff --git a/tests/misc/sort-debug-warn.sh b/tests/misc/sort-debug-warn.sh
+index 3602c84..8119693 100755
+--- a/tests/misc/sort-debug-warn.sh
++++ b/tests/misc/sort-debug-warn.sh
+@@ -71,7 +71,8 @@ sort: using simple byte comparison
+ 17
+ sort: using simple byte comparison
+ 18
+-sort: failed to set locale; using simple byte comparison
++sort: failed to set locale
++sort: using simple byte comparison
+ EOF
+
+ echo 1 >> out
+@@ -109,7 +110,11 @@ sort -rM --debug /dev/null 2>>out #no warning
+ echo 17 >> out
+ sort -rM -k1,1 --debug /dev/null 2>>out #no warning
+ echo 18 >> out
+-LC_ALL=missing sort --debug /dev/null 2>>out
++LC_ALL=missing sort --debug /dev/null 2>>out.t
++# musl libc accepts "missing" and implicitly uses UTF8,
++# so adjust the expected message accordingly.
++sed 's/using .*missing.* sorting rules/using simple byte comparison/' \
++ out.t >>out
+
+ compare exp out || fail=1
+
+--
+2.9.3
+
diff --git a/system/curl/APKBUILD b/system/curl/APKBUILD
new file mode 100644
index 000000000..fd20e55dd
--- /dev/null
+++ b/system/curl/APKBUILD
@@ -0,0 +1,93 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Contributor: Łukasz Jendrysik <scadu@yandex.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=curl
+pkgver=7.56.1
+pkgrel=0
+pkgdesc="An URL retrival utility and library"
+url="http://curl.haxx.se"
+arch="all"
+license="MIT"
+depends="ca-certificates"
+makedepends_build="groff perl"
+makedepends_host="zlib-dev openssl-dev libssh2-dev"
+makedepends="$makedepends_build $makedepends_host"
+source="http://curl.haxx.se/download/$pkgname-$pkgver.tar.bz2
+ "
+subpackages="$pkgname-dbg $pkgname-doc $pkgname-dev libcurl"
+
+# secfixes:
+# 7.56.1-r0:
+# - CVE-2017-1000257
+# 7.55.0-r0:
+# - CVE-2017-1000099
+# - CVE-2017-1000100
+# - CVE-2017-1000101
+# 7.54.0-r0:
+# - CVE-2017-7468
+# 7.53.1-r2:
+# - CVE-2017-7407
+# 7.53.0:
+# - CVE-2017-2629
+# 7.52.1:
+# - CVE-2016-9594
+# 7.51.0:
+# - CVE-2016-8615
+# - CVE-2016-8616
+# - CVE-2016-8617
+# - CVE-2016-8618
+# - CVE-2016-8619
+# - CVE-2016-8620
+# - CVE-2016-8621
+# - CVE-2016-8622
+# - CVE-2016-8623
+# - CVE-2016-8624
+# - CVE-2016-8625
+# 7.50.3:
+# - CVE-2016-7167
+# 7.50.2:
+# - CVE-2016-7141
+# 7.50.1:
+# - CVE-2016-5419
+# - CVE-2016-5420
+# - CVE-2016-5421
+# 7.36.0:
+# - CVE-2014-0138
+# - CVE-2014-0139
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --enable-ipv6 \
+ --enable-unix-sockets \
+ --without-libidn \
+ --without-libidn2 \
+ --disable-ldap \
+ --with-pic \
+ || return 1
+ make || return 1
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ make DESTDIR="$pkgdir" \
+ -C "$builddir" install || return 1
+}
+
+libcurl() {
+ pkgdesc="The multiprotocol file transfer library"
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/lib "$subpkgdir"/usr
+}
+
+sha512sums="f8a602e6890b2791ea9199c80801ffd027980de3733d4ab001ee80b5167f840cc821c6fe7852087c88a471edc9d3f328cf660af3e2c6f7139d6c8de62b0ade68 curl-7.56.1.tar.bz2"
diff --git a/system/curl/curl-do-bounds-check-using-a-double-comparison.patch b/system/curl/curl-do-bounds-check-using-a-double-comparison.patch
new file mode 100644
index 000000000..34e2b6c71
--- /dev/null
+++ b/system/curl/curl-do-bounds-check-using-a-double-comparison.patch
@@ -0,0 +1,32 @@
+From 45a560390c4356bcb81d933bbbb229c8ea2acb63 Mon Sep 17 00:00:00 2001
+From: Adam Sampson <ats@offog.org>
+Date: Wed, 9 Aug 2017 14:11:17 +0100
+Subject: [PATCH] curl: do bounds check using a double comparison
+
+The fix for this in 8661a0aacc01492e0436275ff36a21734f2541bb wasn't
+complete: if the parsed number in num is larger than will fit in a long,
+the conversion is undefined behaviour (causing test1427 to fail for me
+on IA32 with GCC 7.1, although it passes on AMD64 and ARMv7). Getting
+rid of the cast means the comparison will be done using doubles.
+
+It might make more sense for the max argument to also be a double...
+
+Fixes #1750
+Closes #1749
+---
+ src/tool_paramhlp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
+index b9dedc989e..85c5e79a7e 100644
+--- a/src/tool_paramhlp.c
++++ b/src/tool_paramhlp.c
+@@ -218,7 +218,7 @@ static ParameterError str2double(double *val, const char *str, long max)
+ num = strtod(str, &endptr);
+ if(errno == ERANGE)
+ return PARAM_NUMBER_TOO_LARGE;
+- if((long)num > max) {
++ if(num > max) {
+ /* too large */
+ return PARAM_NUMBER_TOO_LARGE;
+ }
diff --git a/system/diffutils/APKBUILD b/system/diffutils/APKBUILD
new file mode 100644
index 000000000..19331ecd8
--- /dev/null
+++ b/system/diffutils/APKBUILD
@@ -0,0 +1,50 @@
+# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
+pkgname=diffutils
+pkgver=3.6
+pkgrel=1
+pkgdesc="Show differences among files"
+subpackages="$pkgname-doc"
+url="http://www.gnu.org/software/diffutils/"
+arch="all"
+license="GPL3+"
+source="http://ftp.gnu.org/pub/gnu/$pkgname/$pkgname-$pkgver.tar.xz
+ disable-mbrtowc-test.patch
+ "
+builddir=$srcdir/$pkgname-$pkgver
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+
+ # fix eglibc-2.16 build issue
+ sed -i -e '/gets is a/d' \
+ lib/stdio.in.h
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-nls
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make install DESTDIR=$pkgdir
+
+ rm -rf "$pkgdir"/usr/lib/charset.alias
+ rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
+}
+
+sha512sums="3c159ff1cb7c901b0a57518483566b5740ca3c45aeb8d3004089f052975481db52994cc18592c502c68b0d2a1e22f1f7830f0d8dd9a9ed86de96e28cce9f70c1 diffutils-3.6.tar.xz
+2602dabf0ac52a273b84160032416613da7ad111541fe25466cf9d4ce1eb2630f0ba0cb0b3013967965d8359a11a5f390f0486b4526b35516d9de1c8975f720d disable-mbrtowc-test.patch"
diff --git a/system/diffutils/disable-mbrtowc-test.patch b/system/diffutils/disable-mbrtowc-test.patch
new file mode 100644
index 000000000..1461a4093
--- /dev/null
+++ b/system/diffutils/disable-mbrtowc-test.patch
@@ -0,0 +1,10 @@
+--- diffutils-3.6/gnulib-tests/test-mbrtowc5.sh.old 2016-12-31 13:54:43.000000000 +0000
++++ diffutils-3.6/gnulib-tests/test-mbrtowc5.sh 2017-07-30 17:29:50.879924130 +0000
+@@ -1,6 +1,2 @@
+ #!/bin/sh
+-# Test whether the POSIX locale has encoding errors.
+-LC_ALL=C \
+-./test-mbrtowc${EXEEXT} 5 || exit
+-LC_ALL=POSIX \
+-./test-mbrtowc${EXEEXT} 5
++exit 77
diff --git a/system/ffmpeg/0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch b/system/ffmpeg/0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch
new file mode 100644
index 000000000..93e3ac995
--- /dev/null
+++ b/system/ffmpeg/0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch
@@ -0,0 +1,55 @@
+From ab11be0becb90542f10d5713659b559842c53af2 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 29 Mar 2016 15:15:17 +0200
+Subject: [PATCH] libavutil: clean up unused FF_SYMVER macro
+
+There is nothing using it since commit d63443b9 (lavc: drop the
+av_fast_{re,m}alloc compatibility wrappers).
+
+Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
+---
+ libavutil/internal.h | 28 ----------------------------
+ 1 file changed, 28 deletions(-)
+
+diff --git a/libavutil/internal.h b/libavutil/internal.h
+index 61784b5..69d63d5 100644
+--- a/libavutil/internal.h
++++ b/libavutil/internal.h
+@@ -177,34 +177,6 @@
+ #endif
+
+ /**
+- * Define a function with only the non-default version specified.
+- *
+- * On systems with ELF shared libraries, all symbols exported from
+- * FFmpeg libraries are tagged with the name and major version of the
+- * library to which they belong. If a function is moved from one
+- * library to another, a wrapper must be retained in the original
+- * location to preserve binary compatibility.
+- *
+- * Functions defined with this macro will never be used to resolve
+- * symbols by the build-time linker.
+- *
+- * @param type return type of function
+- * @param name name of function
+- * @param args argument list of function
+- * @param ver version tag to assign function
+- */
+-#if HAVE_SYMVER_ASM_LABEL
+-# define FF_SYMVER(type, name, args, ver) \
+- type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \
+- type ff_##name args
+-#elif HAVE_SYMVER_GNU_ASM
+-# define FF_SYMVER(type, name, args, ver) \
+- __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \
+- type ff_##name args; \
+- type ff_##name args
+-#endif
+-
+-/**
+ * Return NULL if a threading library has not been enabled.
+ * Used to disable threading functions in AVCodec definitions
+ * when not needed.
+--
+2.7.4
+
diff --git a/system/ffmpeg/APKBUILD b/system/ffmpeg/APKBUILD
new file mode 100644
index 000000000..a963e33f8
--- /dev/null
+++ b/system/ffmpeg/APKBUILD
@@ -0,0 +1,104 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Contributor: Łukasz Jendrysik <scadu@yandex.com>
+# Contributor: Jakub Skrzypnik <j.skrzypnik@openmailbox.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ffmpeg
+pkgver=3.4
+pkgrel=1
+pkgdesc="Complete and free Internet live audio and video broadcasting solution for Linux/Unix"
+url="http://ffmpeg.org/"
+arch="all"
+license="GPL"
+options="!check textrels" # Test suite requires proper licensing headers on all files,
+ # which upstream does not provide.
+subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
+makedepends="gnutls-dev lame-dev libvorbis-dev xvidcore-dev zlib-dev libvdpau-dev
+ imlib2-dev libtheora-dev coreutils bzip2-dev perl-dev libvpx-dev
+ pulseaudio-dev sdl2-dev libxfixes-dev libva-dev alsa-lib-dev rtmpdump-dev
+ v4l-utils-dev yasm opus-dev x265-dev xz-dev freetype-dev speex-dev
+ ladspa-dev libcdio-dev libcdio-paranoia-dev wavpack-dev libwebp-dev"
+source="http://ffmpeg.org/releases/ffmpeg-$pkgver.tar.xz
+ 0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+
+# secfixes:
+# 3.3.4-r0:
+# - CVE-2017-14054
+# - CVE-2017-14055
+# - CVE-2017-14056
+# - CVE-2017-14057
+# - CVE-2017-14058
+# - CVE-2017-14059
+# - CVE-2017-14169
+# - CVE-2017-14170
+# - CVE-2017-14171
+# - CVE-2017-14222
+# - CVE-2017-14223
+# - CVE-2017-14225
+
+build() {
+ local _dbg="--disable-debug"
+ local _asm=""
+ [ -n "$DEBUG" ] && _dbg="--enable-debug"
+
+ case "$CARCH" in
+ x86 | arm*) _asm="--disable-asm" ;;
+ ppc64) _asm="--cpu=G5" ;;
+ esac
+
+ cd "$builddir"
+ ./configure \
+ --prefix=/usr \
+ --enable-avresample \
+ --enable-avfilter \
+ --enable-gnutls \
+ --enable-gpl \
+ --enable-libmp3lame \
+ --enable-librtmp \
+ --enable-libvorbis \
+ --enable-libvpx \
+ --enable-libxvid \
+ --enable-libx265 \
+ --enable-libtheora \
+ --enable-libv4l2 \
+ --enable-postproc \
+ --enable-pic \
+ --enable-pthreads \
+ --enable-shared \
+ --enable-libxcb \
+ --disable-stripping \
+ --disable-static \
+ --enable-vaapi \
+ --enable-vdpau \
+ --enable-libopus \
+ --enable-libcdio \
+ --enable-ladspa \
+ --enable-lzma \
+ --enable-libspeex \
+ --enable-libfreetype \
+ --enable-libwavpack \
+ --enable-libwebp \
+ --enable-libpulse \
+ $_asm $_dbg
+ make
+ ${CC:-gcc} -o tools/qt-faststart $CFLAGS tools/qt-faststart.c
+ make doc/ffmpeg.1 doc/ffplay.1 doc/ffserver.1
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install install-man
+ install -D -m755 tools/qt-faststart "$pkgdir/usr/bin/qt-faststart"
+# strip --strip-debug "$pkgdir"/usr/lib/*.a
+}
+
+libs() {
+ pkgdesc="Libraries for ffmpeg"
+ replaces="ffmpeg"
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/lib "$subpkgdir"/usr
+}
+
+sha512sums="357445f0152848d43f8a22f1078825bc44adacff9194e12cc78e8b5edac8e826bbdf73dc8b37e0f2a3036125b76b6b9190153760c761e63ebd2452a39e39536f ffmpeg-3.4.tar.xz
+32652e18d4eb231a2e32ad1cacffdf33264aac9d459e0e2e6dd91484fced4e1ca5a62886057b1f0b4b1589c014bbe793d17c78adbaffec195f9a75733b5b18cb 0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch"
diff --git a/system/freetype/0001-Enable-table-validation-modules.patch b/system/freetype/0001-Enable-table-validation-modules.patch
new file mode 100644
index 000000000..3e9451fa8
--- /dev/null
+++ b/system/freetype/0001-Enable-table-validation-modules.patch
@@ -0,0 +1,34 @@
+From c3680bf8d38cf759c1e33dcc2d2d51e0a4fea2f9 Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Tue, 23 Jun 2015 08:40:29 +0200
+Subject: [PATCH 1/3] Enable table validation modules
+
+---
+ modules.cfg | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/modules.cfg b/modules.cfg
+index f30049c38cc45159..7b8e50fe1b34584a 100644
+--- a/modules.cfg
++++ b/modules.cfg
+@@ -120,7 +120,7 @@ AUX_MODULES += cache
+ # TrueType GX/AAT table validation. Needs ftgxval.c below.
+ #
+ # No FT_CONFIG_OPTION_PIC support.
+-# AUX_MODULES += gxvalid
++AUX_MODULES += gxvalid
+
+ # Support for streams compressed with gzip (files with suffix .gz).
+ #
+@@ -143,7 +143,7 @@ AUX_MODULES += bzip2
+ # OpenType table validation. Needs ftotval.c below.
+ #
+ # No FT_CONFIG_OPTION_PIC support.
+-# AUX_MODULES += otvalid
++AUX_MODULES += otvalid
+
+ # Auxiliary PostScript driver component to share common code.
+ #
+--
+2.9.3
+
diff --git a/system/freetype/0002-Enable-subpixel-rendering.patch b/system/freetype/0002-Enable-subpixel-rendering.patch
new file mode 100644
index 000000000..dfb57966e
--- /dev/null
+++ b/system/freetype/0002-Enable-subpixel-rendering.patch
@@ -0,0 +1,25 @@
+From 96f09f08417887b2618c177bccfb6da2906568d9 Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Tue, 23 Jun 2015 08:43:07 +0200
+Subject: [PATCH 2/3] Enable subpixel rendering
+
+---
+ include/freetype/config/ftoption.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index 90c123ef93e9ea04..67a361dd41e0b026 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -122,7 +122,7 @@ FT_BEGIN_HEADER
+ /* This is done to allow FreeType clients to run unmodified, forcing */
+ /* them to display normal gray-level anti-aliased glyphs. */
+ /* */
+-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
++#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+
+
+ /*************************************************************************/
+--
+2.9.3
+
diff --git a/system/freetype/0003-Enable-infinality-subpixel-hinting.patch b/system/freetype/0003-Enable-infinality-subpixel-hinting.patch
new file mode 100644
index 000000000..bbfa2a2cd
--- /dev/null
+++ b/system/freetype/0003-Enable-infinality-subpixel-hinting.patch
@@ -0,0 +1,27 @@
+From 220e96a9a8d7aff6ad0f0f1aa12c79cdb563331c Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Mon, 29 Aug 2016 08:43:10 +0200
+Subject: [PATCH 3/3] Enable infinality subpixel hinting
+
+---
+ include/freetype/config/ftoption.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index 67a361dd41e0b026..c4812862518b66a6 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -675,8 +675,8 @@ FT_BEGIN_HEADER
+ /* [1] http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
+ /* */
+ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */
+-#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2
+-/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */
++/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 */
++#define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 )
+
+
+ /*************************************************************************/
+--
+2.9.3
+
diff --git a/system/freetype/0004-Enable-long-PCF-family-names.patch b/system/freetype/0004-Enable-long-PCF-family-names.patch
new file mode 100644
index 000000000..675423a7c
--- /dev/null
+++ b/system/freetype/0004-Enable-long-PCF-family-names.patch
@@ -0,0 +1,25 @@
+From 62da6a0f7f5cb77859a793863c386c452411e2a6 Mon Sep 17 00:00:00 2001
+From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
+Date: Sun, 14 May 2017 18:09:31 +0200
+Subject: [PATCH 4/4] Enable long PCF family names
+
+---
+ include/freetype/config/ftoption.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
+index ebb44acdbbef9a47..0b39b417162707e4 100644
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -865,7 +865,7 @@ FT_BEGIN_HEADER
+ /* If this option is activated, it can be controlled with the */
+ /* `no-long-family-names' property of the pcf driver module. */
+ /* */
+-/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
++#define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
+
+
+ /*************************************************************************/
+--
+2.13.0
+
diff --git a/system/freetype/40-memcpy-fix.patch b/system/freetype/40-memcpy-fix.patch
new file mode 100644
index 000000000..89e61cd0b
--- /dev/null
+++ b/system/freetype/40-memcpy-fix.patch
@@ -0,0 +1,14 @@
+--- ./src/psaux/psobjs.c~ 2006-04-26 16:38:17.000000000 +0200
++++ ./src/psaux/psobjs.c 2006-09-10 15:01:13.000000000 +0200
+@@ -165,6 +165,11 @@
+ return PSaux_Err_Invalid_Argument;
+ }
+
++ if ( length < 0 ) {
++ FT_ERROR(( "ps_table_add: invalid length\n" ));
++ return PSaux_Err_Invalid_Argument;
++ }
++
+ /* grow the base block if needed */
+ if ( table->cursor + length > table->capacity )
+ {
diff --git a/system/freetype/APKBUILD b/system/freetype/APKBUILD
new file mode 100644
index 000000000..fbb4e0103
--- /dev/null
+++ b/system/freetype/APKBUILD
@@ -0,0 +1,59 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=freetype
+pkgver=2.8.1
+pkgrel=2
+pkgdesc="TrueType font rendering library"
+url="https://www.freetype.org/"
+arch="all"
+license="GPL"
+options="!check"
+depends=""
+depends_dev=""
+makedepends="$depends_dev zlib-dev libpng-dev bzip2-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://download.savannah.gnu.org/releases/freetype/freetype-$pkgver.tar.bz2
+ 40-memcpy-fix.patch
+ 0001-Enable-table-validation-modules.patch
+ 0003-Enable-infinality-subpixel-hinting.patch
+ 0004-Enable-long-PCF-family-names.patch
+
+ freetype-profile.sh
+ "
+
+# secfixes:
+# 2.7.1-r1:
+# - CVE-2017-8105
+# - CVE-2017-8287
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-static \
+ --with-bzip2 \
+ --with-png
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ install -Dm644 "$srcdir"/freetype-profile.sh \
+ "$pkgdir"/etc/profile.d/freetype.sh
+}
+
+sha512sums="ca59e47f0fceeeb9b8032be2671072604d0c79094675df24187829c05e99757d0a48a0f8062d4d688e056f783aa8f6090d732ad116562e94784fccf1339eb823 freetype-2.8.1.tar.bz2
+9981be8a3ea6f2cf856860b87a4e895e4610c9d5ea4beb611815e757e6080e060f6853ace02dd8ea55e5888cdf4bae5ad5eadd2d8a123754bb3c0bfe7ef41dea 40-memcpy-fix.patch
+41a84be2631b53072a76b78c582575aa48b650ee7b00017d018381002bc25df10cf33da4954c95ef50db39f1fa566678e3b4ae9bfee1dfd705423fb53e53e494 0001-Enable-table-validation-modules.patch
+7b52a3d67750d59b2c98e83dab4e0a0ab263142c2ca7bd5f8be5f8fe9cd1dc1f4debad44111c7886665329d8d2a3163756455618a6615df8f85d82bb0372d4dd 0003-Enable-infinality-subpixel-hinting.patch
+64c20fbcbf48372ea35fe2e0dae8fec4be8c601c899a4a71913060c6ea4082a2f41d69701da511e09fee126bf198d560986469e2356bd088d2dd5961f437df63 0004-Enable-long-PCF-family-names.patch
+7100cde5b2ca16bfbe968fce3e2eba5ba49e6ed53792d5db889c8d89e572d7d80da1338ccc9eeb9b243664ca2337467e9f73c1074bee0b34c417f6c7832ed390 freetype-profile.sh"
diff --git a/system/freetype/freetype-profile.sh b/system/freetype/freetype-profile.sh
new file mode 100644
index 000000000..a4cc6423b
--- /dev/null
+++ b/system/freetype/freetype-profile.sh
@@ -0,0 +1,12 @@
+# Subpixel hinting mode can be chosen by setting the right TrueType interpreter
+# version. The available settings are:
+#
+# truetype:interpreter-version=35 # Classic mode (default in 2.6)
+# truetype:interpreter-version=38 # Infinality mode
+# truetype:interpreter-version=40 # Minimal mode (default in 2.7)
+#
+# There are more properties that can be set, separated by whitespace. Please
+# refer to the FreeType documentation for details.
+
+# Uncomment and configure below
+export FREETYPE_PROPERTIES="truetype:interpreter-version=38"
diff --git a/system/gamin/APKBUILD b/system/gamin/APKBUILD
new file mode 100644
index 000000000..360161d27
--- /dev/null
+++ b/system/gamin/APKBUILD
@@ -0,0 +1,58 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gamin
+pkgver=0.1.10
+pkgrel=11
+pkgdesc="Gamin is a file and directory monitoring system defined to be a subset of the FAM (File Alteration Monitor) system."
+url="http://www.gnome.org/~veillard/gamin"
+arch="all"
+license="GPL"
+subpackages="$pkgname-dev"
+depends=
+makedepends="glib-dev"
+source="http://www.gnome.org/~veillard/$pkgname/sources/$pkgname-$pkgver.tar.gz
+ fix-deprecated-const.patch
+ fix-pthread-mutex.patch"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+ cd "$_builddir"
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ cd "$_builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-static \
+ --with-threads \
+ --without-python \
+ --disable-debug-api \
+ --disable-debug \
+ --libexecdir=/usr/lib/gamin
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$_builddir"
+ # some kinde of race in the make install which is not solved with -j
+ export MKDIRPROG="mkdir -p"
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="b4ec549e57da470c04edd5ec2876a028 gamin-0.1.10.tar.gz
+f679aeb48fe9dd376c8828cc9b6941ab fix-deprecated-const.patch
+f05a8d9fe30b6ce2871795c06d74edc4 fix-pthread-mutex.patch"
+sha256sums="28085f0ae8be10eab582ff186af4fb0be92cc6c62b5cc19cd09b295c7c2899a1 gamin-0.1.10.tar.gz
+33af6c9a94b459506fc48892c169d89cb4ad7c68e160f0c4bc74475f19ce5a2f fix-deprecated-const.patch
+bfd5ee42e385367718a4dac8ab318f9a5881ab8b669e4020f87aacaef16a2f8e fix-pthread-mutex.patch"
+sha512sums="21bfe6fcf8fb3117cd5a08c8ce3b8d0d1dd23e478e60a95b76c20d02cc29b050dde086578d81037990484ff891c3e104d2cbbf3d294b4a79346b14a0cae075bb gamin-0.1.10.tar.gz
+c4c10bee70c7231db395cbfe5bdf513ade6be599a11a9d35888ddfaca42d619fe2b5e87c2b2bab469ea98ba718bc01711252313ba5f53c392379b669f5b2902b fix-deprecated-const.patch
+70628fc39521ea8bc4a40b009d0881f6ee540334a31b2f0cb67dde0f75808c69feb78088ad24c3c4a0dec9fa59e87960fd81d1a2e56963ce9268d0a5e14f88e8 fix-pthread-mutex.patch"
diff --git a/system/gamin/fix-deprecated-const.patch b/system/gamin/fix-deprecated-const.patch
new file mode 100644
index 000000000..3d5f6133f
--- /dev/null
+++ b/system/gamin/fix-deprecated-const.patch
@@ -0,0 +1,56 @@
+Description: Don't use deprecated G_CONST_RETURN. Fixes building with newer glib versions.
+Author: Matthias Klose <doko@ubuntu.com>
+Bug-Ubuntu: https://launchpad.net/bugs/829504
+
+Index: gamin/server/gam_node.c
+===================================================================
+--- gamin.orig/server/gam_node.c 2011-10-18 16:09:04.873780685 +0200
++++ gamin/server/gam_node.c 2011-10-18 16:09:01.965780543 +0200
+@@ -122,7 +122,7 @@
+ * it has finished with the string. If it must keep it longer, it
+ * should makes its own copy. The returned string must not be freed.
+ */
+-G_CONST_RETURN char *
++const char *
+ gam_node_get_path(GamNode * node)
+ {
+ g_assert(node);
+Index: gamin/server/gam_node.h
+===================================================================
+--- gamin.orig/server/gam_node.h 2011-10-18 16:09:04.729780677 +0200
++++ gamin/server/gam_node.h 2011-10-18 16:09:01.961780544 +0200
+@@ -58,7 +58,7 @@
+ void gam_node_set_is_dir (GamNode *node,
+ gboolean is_dir);
+
+-G_CONST_RETURN char *gam_node_get_path (GamNode *node);
++const char *gam_node_get_path (GamNode *node);
+
+ GList *gam_node_get_subscriptions (GamNode *node);
+
+Index: gamin/server/gam_subscription.c
+===================================================================
+--- gamin.orig/server/gam_subscription.c 2011-10-18 16:09:04.817780682 +0200
++++ gamin/server/gam_subscription.c 2011-10-18 16:09:01.965780543 +0200
+@@ -141,7 +141,7 @@
+ * @param sub the GamSubscription
+ * @returns The path being monitored. It should not be freed.
+ */
+-G_CONST_RETURN char *
++const char *
+ gam_subscription_get_path(GamSubscription * sub)
+ {
+ if (sub == NULL)
+Index: gamin/server/gam_subscription.h
+===================================================================
+--- gamin.orig/server/gam_subscription.h 2011-10-18 16:09:04.929780687 +0200
++++ gamin/server/gam_subscription.h 2011-10-18 16:09:01.965780543 +0200
+@@ -21,7 +21,7 @@
+
+ int gam_subscription_get_reqno (GamSubscription *sub);
+
+-G_CONST_RETURN char *gam_subscription_get_path (GamSubscription *sub);
++const char *gam_subscription_get_path (GamSubscription *sub);
+
+ GamListener *gam_subscription_get_listener (GamSubscription *sub);
+
diff --git a/system/gamin/fix-pthread-mutex.patch b/system/gamin/fix-pthread-mutex.patch
new file mode 100644
index 000000000..c8c5b0005
--- /dev/null
+++ b/system/gamin/fix-pthread-mutex.patch
@@ -0,0 +1,11 @@
+--- gamin-0.1.10.orig/libgamin/gam_data.c
++++ gamin-0.1.10/libgamin/gam_data.c
+@@ -470,7 +470,7 @@
+ }
+ if (is_threaded > 0) {
+ pthread_mutexattr_init(&attr);
+-#if defined(linux) || defined(PTHREAD_MUTEX_RECURSIVE_NP)
++#if defined(linux) && defined(PTHREAD_MUTEX_RECURSIVE_NP)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+ #else
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
diff --git a/system/git/0001-gc-use-s-type-character-for-fscanf.patch b/system/git/0001-gc-use-s-type-character-for-fscanf.patch
new file mode 100644
index 000000000..e3fe78cf6
--- /dev/null
+++ b/system/git/0001-gc-use-s-type-character-for-fscanf.patch
@@ -0,0 +1,33 @@
+From afceb0f7755a87d0dd2194e95f26c9dc8f4bc688 Mon Sep 17 00:00:00 2001
+From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
+Date: Fri, 15 Sep 2017 23:55:57 -0500
+Subject: [PATCH] gc: use 's' type character for fscanf
+
+The ISO C standard states that using a field width together with the 'c'
+type character will read the exact amount specified; if that amount of
+bytes is not available, a match error occurs.
+
+This patch allows the t6500 test to pass on the musl libc, and `git gc`
+to behave correctly on systems utilising musl.
+
+Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
+---
+ builtin/gc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/builtin/gc.c b/builtin/gc.c
+index 3c78fcb..bb2d6c1 100644
+--- a/builtin/gc.c
++++ b/builtin/gc.c
+@@ -258,7 +258,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
+ int should_exit;
+
+ if (!scan_fmt)
+- scan_fmt = xstrfmt("%s %%%dc", "%"SCNuMAX, HOST_NAME_MAX);
++ scan_fmt = xstrfmt("%s %%%ds", "%"SCNuMAX, HOST_NAME_MAX);
+ fp = fopen(pidfile_path, "r");
+ memset(locking_host, 0, sizeof(locking_host));
+ should_exit =
+--
+2.10.0
+
diff --git a/system/git/APKBUILD b/system/git/APKBUILD
new file mode 100644
index 000000000..0a400b851
--- /dev/null
+++ b/system/git/APKBUILD
@@ -0,0 +1,255 @@
+# Contributor: Łukasz Jendrysik <scadu@yandex.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=git
+pkgver=2.15.0
+pkgrel=0
+pkgdesc="A distributed version control system"
+url="https://www.git-scm.com/"
+arch="all"
+license="GPL2+"
+depends=
+replaces="git-perl"
+
+# secfixes:
+# 2.14.1:
+# - CVE-2017-1000117
+
+# note that order matters
+subpackages="$pkgname-doc
+ $pkgname-bash-completion:completion:noarch
+ perl-$pkgname-svn:_perl_git_svn:noarch
+ perl-$pkgname:_perl_git:noarch
+ $pkgname-svn
+ $pkgname-email
+ $pkgname-fast-import:_fast_import
+ $pkgname-cvs::noarch
+ $pkgname-p4::noarch
+ $pkgname-daemon
+ $pkgname-gitweb
+ $pkgname-subtree::noarch
+ $pkgname-subtree-doc:subtree_doc:noarch
+ $pkgname-perl:_git_perl:noarch
+ $pkgname-gui::noarch
+ $pkgname-gitk::noarch
+ "
+# we need tcl and tk to be built before git due to git-gui and gitk
+makedepends="zlib-dev openssl-dev curl-dev expat-dev perl-dev
+ pcre2-dev asciidoctor xmlto perl-error tcl tk"
+checkdepends="python3"
+source="https://www.kernel.org/pub/software/scm/git/git-$pkgver.tar.xz
+ bb-tar.patch
+ dont-test-other-encodings.patch
+ git-daemon.initd
+ git-daemon.confd
+ "
+
+_gitcoredir=/usr/libexec/git-core
+builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ default_prepare
+ cat >> config.mak <<-EOF
+ NO_GETTEXT=YesPlease
+ NO_SVN_TESTS=YesPlease
+ NO_REGEX=YesPlease
+ USE_ASCIIDOCTOR=1
+ USE_LIBPCRE2=YesPlease
+ NO_NSEC=YesPlease
+ NO_SYS_POLL_H=1
+ CFLAGS=$CFLAGS
+ EOF
+}
+
+build() {
+ cd "$builddir"
+ make -j1 prefix=/usr DESTDIR="$pkgdir" perl/perl.mak
+ make prefix=/usr DESTDIR="$pkgdir"
+}
+
+check() {
+ cd "$builddir"
+ make prefix=/usr DESTDIR="$pkgdir" test
+}
+
+package() {
+ cd "$builddir"
+ make -j1 prefix=/usr \
+ DESTDIR="$pkgdir" \
+ INSTALLDIRS=vendor \
+ install
+ mkdir -p "$pkgdir"/var/git
+ install -Dm755 "$srcdir"/git-daemon.initd \
+ "$pkgdir"/etc/init.d/git-daemon
+ install -Dm644 "$srcdir"/git-daemon.confd \
+ "$pkgdir"/etc/conf.d/git-daemon
+
+ make prefix=/usr DESTDIR="$pkgdir" install-man
+}
+
+_perl_git_svn() {
+ pkgdesc="Perl interface to Git::SVN"
+ depends="git=$pkgver-r$pkgrel"
+ replaces="git-perl"
+ eval local `perl -V:vendorlib`
+ mkdir -p "$subpkgdir"/$vendorlib/Git
+ mv "$pkgdir"/$vendorlib/Git/SVN* "$subpkgdir"/$vendorlib/Git/
+}
+
+_perl_git() {
+ pkgdesc="Perl interface to Git"
+ depends="git=$pkgver-r$pkgrel perl-error"
+ replaces="git-perl"
+ eval local `perl -V:vendorlib`
+ eval local `perl -V:vendorarch`
+ for i in $vendorlib $vendorarch; do
+ mkdir -p "$subpkgdir"/${i%/*}
+ mv "$pkgdir"/$i "$subpkgdir"/$i
+ done
+}
+
+email() {
+ depends="perl perl-git=$pkgver-r$pkgrel perl-net-smtp-ssl
+ perl-authen-sasl"
+ pkgdesc="Git tools for sending email"
+ replaces="git"
+ mkdir -p "$subpkgdir"/$_gitcoredir
+ mv "$pkgdir"/$_gitcoredir/*email* "$pkgdir"/$_gitcoredir/*imap* \
+ "$subpkgdir"/$_gitcoredir
+}
+
+svn() {
+ depends="perl perl-git-svn=$pkgver-r$pkgrel perl-subversion
+ perl-term-readkey"
+ pkgdesc="Subversion support for git"
+ replaces=""
+
+ mkdir -p "$subpkgdir"/$_gitcoredir
+ mv "$pkgdir"/$_gitcoredir/git-svn \
+ "$pkgdir"$_gitcoredir/git-remote-testsvn \
+ "$subpkgdir"/$_gitcoredir/
+}
+
+cvs() {
+ pkgdesc="Git tools for importing CVS repositories"
+ depends="perl perl-git=$pkgver-r$pkgrel cvs perl-dbd-sqlite"
+ replaces="git-perl"
+ mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/$_gitcoredir
+ mv "$pkgdir"/usr/bin/git-cvs* "$subpkgdir"/usr/bin/
+ mv "$pkgdir"/$_gitcoredir/*cvs* "$subpkgdir"/$_gitcoredir \
+
+}
+
+_fast_import() {
+ pkgdesc="Git backend for fast Git data importers"
+ depends="git=$pkgver-r$pkgrel"
+ mkdir -p "$subpkgdir"/$_gitcoredir
+ mv "$pkgdir"/$_gitcoredir/git-fast-import "$subpkgdir"/$_gitcoredir/
+}
+
+p4() {
+ pkgdesc="Git tools for working with Perforce depots"
+ depends="git=$pkgver-r$pkgrel git-fast-import=$pkgver-r$pkgrel"
+ replaces="git"
+ mkdir -p "$subpkgdir"/$_gitcoredir/mergetools
+ mv "$pkgdir"/$_gitcoredir/*p4* "$subpkgdir"/$_gitcoredir/
+ mv "$pkgdir"/$_gitcoredir/mergetools/*p4* \
+ "$subpkgdir"/$_gitcoredir/mergetools/
+}
+
+daemon() {
+ pkgdesc="Git protocol daemon"
+ depends="git=$pkgver-r$pkgrel"
+ replaces="git"
+ mkdir -p "$subpkgdir"/$_gitcoredir
+ mv "$pkgdir"/$_gitcoredir/git-daemon \
+ "$pkgdir"/$_gitcoredir/git-http-backend \
+ "$pkgdir"/$_gitcoredir/git-shell \
+ "$subpkgdir"/$_gitcoredir \
+
+ mv "$pkgdir"/etc "$subpkgdir"/
+}
+
+gitweb() {
+ pkgdesc="Simple web interface to git repositories"
+ depends="git=$pkgver-r$pkgrel perl"
+ replaces="git"
+ mkdir -p "$subpkgdir"/usr/share "$subpkgdir"$_gitcoredir
+ mv "$pkgdir"/usr/share/gitweb "$subpkgdir"/usr/share/
+ mv "$pkgdir"/$_gitcoredir/git-instaweb "$subpkgdir"$_gitcoredir
+}
+
+completion() {
+ pkgdesc="Bash completion for $pkgname"
+ depends=""
+ replaces=""
+ install_if="$pkgname=$pkgver-r$pkgrel bash-completion"
+
+ install -Dm644 "$builddir"/contrib/completion/git-completion.bash \
+ "$subpkgdir"/usr/share/bash-completion/completions/git
+}
+
+subtree() {
+ depends="git=$pkgver-r$pkgrel"
+ pkgdesc="Split git repository into subtrees"
+ replaces=""
+
+ cd "$builddir"/contrib/subtree
+ make prefix=/usr DESTDIR="$pkgdir"
+ make install prefix=/usr DESTDIR="$subpkgdir"
+}
+
+subtree_doc() {
+ depends=""
+ pkgdesc="Split git repository into subtrees (documentation)"
+ replaces=""
+
+ cd "$builddir"/contrib/subtree
+ make install-man prefix=/usr DESTDIR="$subpkgdir"
+ gzip -9 "$subpkgdir"/usr/share/man/man1/git-subtree.1
+}
+
+gui() {
+ depends="git=$pkgver-r$pkgrel tcl tk"
+ pkgdesc="GUI interface for git"
+ replaces=""
+
+ mkdir -p "$subpkgdir"/usr/share "$subpkgdir"/usr/libexec/git-core
+ mv "$pkgdir"/usr/share/git-gui "$subpkgdir"/usr/share/
+ mv "$pkgdir"/usr/libexec/git-core/git-citool \
+ "$pkgdir"/usr/libexec/git-core/git-gui \
+ "$pkgdir"/usr/libexec/git-core/git-gui--askpass \
+ "$subpkgdir"/usr/libexec/git-core/
+}
+
+gitk() {
+ depends="git=$pkgver-r$pkgrel tcl tk"
+ pkgdesc="Gitk interface for git"
+ replaces=""
+
+ mkdir -p "$subpkgdir"/usr/share "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/share/gitk "$subpkgdir"/usr/share/
+ mv "$pkgdir"/usr/bin/gitk "$subpkgdir"/usr/bin/
+}
+
+# catch-the-rest of stuff that needs perl
+_git_perl() {
+ depends="git=$pkgver-r$pkgrel perl-git=$pkgver-r$pkgrel perl"
+ pkgdesc="Additional Git commands that requires perl"
+ replaces=""
+
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/perl* "$subpkgdir"/usr/lib/
+ cd "$pkgdir"
+ find -type f | xargs file --mime-type | grep perl | cut -d: -f1| while read f; do
+ mkdir -p "$subpkgdir"/${f%/*}
+ mv "$f" "$subpkgdir"/${f%/*}
+ done
+ find "$subpkgdir" -name perllocal.pod -delete
+}
+
+
+sha512sums="994704b440ebce104a99d815dd713af3173f29e70646d7135c3fcd1ac4694a26e499f0732843606c397cbf6108809eb397546c837623a4adbe1ccb2fc825cb64 git-2.15.0.tar.xz
+85767b5e03137008d6a96199e769e3979f75d83603ac8cb13a3481a915005637409a4fd94e0720da2ec6cd1124f35eba7cf20109a94816c4b4898a81fbc46bd2 bb-tar.patch
+135645fa57c41c50bec6d09f7d3c92f26d30334b5f342d50942c24e0dd11106e40c36b11346c9e6cd69e98b7a9ebeec80e4e4f1506ef689f39d7ef4539727dae dont-test-other-encodings.patch
+89528cdd14c51fd568aa61cf6c5eae08ea0844e59f9af9292da5fc6c268261f4166017d002d494400945e248df6b844e2f9f9cd2d9345d516983f5a110e4c42a git-daemon.initd
+fbf1f425206a76e2a8f82342537ed939ff7e623d644c086ca2ced5f69b36734695f9f80ebda1728f75a94d6cd2fcb71bf845b64239368caab418e4d368c141ec git-daemon.confd"
diff --git a/system/git/bb-tar.patch b/system/git/bb-tar.patch
new file mode 100644
index 000000000..d9433ef12
--- /dev/null
+++ b/system/git/bb-tar.patch
@@ -0,0 +1,8 @@
+--- a/templates/Makefile Mon Oct 26 02:57:33 2009
++++ b/templates/Makefile Mon Nov 9 14:56:27 2009
+@@ -63,4 +63,4 @@
+ install: all
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
+ (cd blt && $(TAR) cf - .) | \
+- (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)
++ (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xf -)
diff --git a/system/git/dont-test-other-encodings.patch b/system/git/dont-test-other-encodings.patch
new file mode 100644
index 000000000..98949bc1b
--- /dev/null
+++ b/system/git/dont-test-other-encodings.patch
@@ -0,0 +1,193 @@
+We can't support Japanese people using musl
+
+--- git-2.14.1/t/t3900-i18n-commit.sh.old 2017-08-09 14:54:31.000000000 -0500
++++ git-2.14.1/t/t3900-i18n-commit.sh 2017-09-10 21:10:09.269860087 -0500
+@@ -76,132 +76,4 @@
+ test_i18ngrep "did not conform" "$HOME"/stderr
+ '
+
+-for H in ISO8859-1 eucJP ISO-2022-JP
+-do
+- test_expect_success "$H setup" '
+- git config i18n.commitencoding $H &&
+- git checkout -b $H C0 &&
+- echo $H >F &&
+- git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt
+- '
+-done
+-
+-for H in ISO8859-1 eucJP ISO-2022-JP
+-do
+- test_expect_success "check encoding header for $H" '
+- E=$(git cat-file commit '$H' | sed -ne "s/^encoding //p") &&
+- test "z$E" = "z'$H'"
+- '
+-done
+-
+-test_expect_success 'config to remove customization' '
+- git config --unset-all i18n.commitencoding &&
+- if Z=$(git config --get-all i18n.commitencoding)
+- then
+- echo Oops, should have failed.
+- false
+- else
+- test z = "z$Z"
+- fi &&
+- git config i18n.commitencoding UTF-8
+-'
+-
+-test_expect_success 'ISO8859-1 should be shown in UTF-8 now' '
+- compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
+-'
+-
+-for H in eucJP ISO-2022-JP
+-do
+- test_expect_success "$H should be shown in UTF-8 now" '
+- compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
+- '
+-done
+-
+-test_expect_success 'config to add customization' '
+- git config --unset-all i18n.commitencoding &&
+- if Z=$(git config --get-all i18n.commitencoding)
+- then
+- echo Oops, should have failed.
+- false
+- else
+- test z = "z$Z"
+- fi
+-'
+-
+-for H in ISO8859-1 eucJP ISO-2022-JP
+-do
+- test_expect_success "$H should be shown in itself now" '
+- git config i18n.commitencoding '$H' &&
+- compare_with '$H' "$TEST_DIRECTORY"/t3900/'$H'.txt
+- '
+-done
+-
+-test_expect_success 'config to tweak customization' '
+- git config i18n.logoutputencoding UTF-8
+-'
+-
+-test_expect_success 'ISO8859-1 should be shown in UTF-8 now' '
+- compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
+-'
+-
+-for H in eucJP ISO-2022-JP
+-do
+- test_expect_success "$H should be shown in UTF-8 now" '
+- compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
+- '
+-done
+-
+-for J in eucJP ISO-2022-JP
+-do
+- if test "$J" = ISO-2022-JP
+- then
+- ICONV=$J
+- else
+- ICONV=
+- fi
+- git config i18n.logoutputencoding $J
+- for H in eucJP ISO-2022-JP
+- do
+- test_expect_success "$H should be shown in $J now" '
+- compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt $ICONV
+- '
+- done
+-done
+-
+-for H in ISO8859-1 eucJP ISO-2022-JP
+-do
+- test_expect_success "No conversion with $H" '
+- compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt
+- '
+-done
+-
+-test_commit_autosquash_flags () {
+- H=$1
+- flag=$2
+- test_expect_success "commit --$flag with $H encoding" '
+- git config i18n.commitencoding $H &&
+- git checkout -b $H-$flag C0 &&
+- echo $H >>F &&
+- git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt &&
+- test_tick &&
+- echo intermediate stuff >>G &&
+- git add G &&
+- git commit -a -m "intermediate commit" &&
+- test_tick &&
+- echo $H $flag >>F &&
+- git commit -a --$flag HEAD~1 &&
+- E=$(git cat-file commit '$H-$flag' |
+- sed -ne "s/^encoding //p") &&
+- test "z$E" = "z$H" &&
+- git config --unset-all i18n.commitencoding &&
+- git rebase --autosquash -i HEAD^^^ &&
+- git log --oneline >actual &&
+- test_line_count = 3 actual
+- '
+-}
+-
+-test_commit_autosquash_flags eucJP fixup
+-
+-test_commit_autosquash_flags ISO-2022-JP squash
+-
+ test_done
+--- git-2.14.1/t/t5100-mailinfo.sh.old 2017-08-09 14:54:31.000000000 -0500
++++ git-2.14.1/t/t5100-mailinfo.sh 2017-09-10 23:26:39.206126739 -0500
+@@ -27,6 +27,7 @@
+
+ for mail in 00*
+ do
++ if [ $mail == 0004 ]; then continue; fi
+ test_expect_success "mailinfo $mail" '
+ check_mailinfo "$mail" "" &&
+ if test -f "$DATA/msg$mail--scissors"
+--- git-2.14.1/t/t8005-blame-i18n.sh.old 2017-08-09 14:54:31.000000000 -0500
++++ git-2.14.1/t/t8005-blame-i18n.sh 2017-09-16 00:42:35.123728809 -0500
+@@ -24,43 +24,10 @@
+ git commit --author "$SJIS_NAME <sjis@localhost>" -m "$SJIS_MSG"
+ '
+
+-cat >expected <<EOF
+-author $SJIS_NAME
+-summary $SJIS_MSG
+-author $SJIS_NAME
+-summary $SJIS_MSG
+-author $SJIS_NAME
+-summary $SJIS_MSG
+-EOF
+-
+ filter_author_summary () {
+ sed -n -e '/^author /p' -e '/^summary /p' "$@"
+ }
+
+-test_expect_success !MINGW \
+- 'blame respects i18n.commitencoding' '
+- git blame --incremental file >output &&
+- filter_author_summary output >actual &&
+- test_cmp expected actual
+-'
+-
+-cat >expected <<EOF
+-author $EUC_JAPAN_NAME
+-summary $EUC_JAPAN_MSG
+-author $EUC_JAPAN_NAME
+-summary $EUC_JAPAN_MSG
+-author $EUC_JAPAN_NAME
+-summary $EUC_JAPAN_MSG
+-EOF
+-
+-test_expect_success !MINGW \
+- 'blame respects i18n.logoutputencoding' '
+- git config i18n.logoutputencoding eucJP &&
+- git blame --incremental file >output &&
+- filter_author_summary output >actual &&
+- test_cmp expected actual
+-'
+-
+ cat >expected <<EOF
+ author $UTF8_NAME
+ summary $UTF8_MSG
diff --git a/system/git/git-daemon.confd b/system/git/git-daemon.confd
new file mode 100644
index 000000000..69b209ff1
--- /dev/null
+++ b/system/git/git-daemon.confd
@@ -0,0 +1,19 @@
+# conf.d file for git-daemon
+#
+# Please check man 1 git-daemon for more information about the options
+# git-daemon accepts. You MUST edit this to include your repositories you wish
+# to serve.
+#
+# Some of the meaningful options are:
+# --syslog --- Enables syslog logging
+# --verbose --- Enables verbose logging
+# --export-all --- Exports all repositories
+# --port=XXXX --- Starts in port XXXX instead of 9418
+#
+GITDAEMON_OPTS="--syslog --base-path=/var/git"
+
+# To run an anonymous git safely, the following user should be able to only
+# read your Git repositories. It should not be able to write to anywhere on
+# your system, esp. not the repositories.
+GIT_USER="nobody"
+GIT_GROUP="nobody"
diff --git a/system/git/git-daemon.initd b/system/git/git-daemon.initd
new file mode 100644
index 000000000..394feb97e
--- /dev/null
+++ b/system/git/git-daemon.initd
@@ -0,0 +1,13 @@
+#!/sbin/openrc-run
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+pidfile="/var/run/git-daemon.pid"
+command="/usr/bin/git"
+command_args="daemon ${GITDAEMON_OPTS}"
+start_stop_daemon_args="-e HOME= -e XDG_CONFIG_HOME= -b -m -p ${pidfile} -u ${GIT_USER:-nobody}:${GIT_GROUP:-nobody}"
+
+depend() {
+ use logger
+}
diff --git a/system/glib-networking/APKBUILD b/system/glib-networking/APKBUILD
new file mode 100644
index 000000000..65ae109a0
--- /dev/null
+++ b/system/glib-networking/APKBUILD
@@ -0,0 +1,43 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=glib-networking
+pkgver=2.54.1
+_maj=${pkgver%%.*}
+_min=${pkgver#${_maj}.}
+_min=${_min%%.*}
+_ver=$_maj.$_min
+pkgrel=1
+pkgdesc="Networking support for GLib"
+url="http://www.gnome.org"
+arch="all"
+license="LGPL-2.1+"
+depends="ca-certificates"
+makedepends="glib-dev gnutls-dev libproxy-dev intltool libgcrypt-dev bash p11-kit-dev"
+install=
+subpackages="$pkgname-lang"
+source="http://download.gnome.org/sources/glib-networking/$_ver/glib-networking-$pkgver.tar.xz"
+
+build() {
+ cd "$builddir"
+ CONFIG_SHELL=/bin/bash ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-more-warnings \
+ --with-libproxy \
+ --with-gnutls
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ rm -f "$pkgdir"/usr/lib/gio/modules/*.a
+}
+
+sha512sums="8356d835914e33df43f4f2bb6a915ddcd48dd0565e4d5bc1f1d692e9c3124ee4421b99f87f2586f74e9fed24ef7421159f3242fd1eb7bd74950bd25e860896ec glib-networking-2.54.1.tar.xz"
diff --git a/system/glib-networking/proxy-test.patch b/system/glib-networking/proxy-test.patch
new file mode 100644
index 000000000..2cab5d9f6
--- /dev/null
+++ b/system/glib-networking/proxy-test.patch
@@ -0,0 +1,13 @@
+--- ./Makefile.am.orig
++++ ./Makefile.am
+@@ -11,9 +11,9 @@
+
+ if HAVE_GNOME_PROXY
+ SUBDIRS += proxy/gnome
++SUBDIRS += proxy/tests
+ endif
+
+-SUBDIRS += proxy/tests
+
+ if HAVE_GNUTLS
+ SUBDIRS += tls/gnutls
diff --git a/system/glib/0001-gquark-fix-initialization-with-c-constructors.patch b/system/glib/0001-gquark-fix-initialization-with-c-constructors.patch
new file mode 100644
index 000000000..50a9a8c28
--- /dev/null
+++ b/system/glib/0001-gquark-fix-initialization-with-c-constructors.patch
@@ -0,0 +1,47 @@
+From e4216dee57f5156e192b2910f13eb855a104cb18 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 6 Jul 2016 12:38:40 +0200
+Subject: [PATCH] gquark: fix initialization with c++ constructors
+
+C++ constructors may want create new quarks, but we can not guarantee
+that the glib library ctor is executed first. Therefore we make sure
+that quarks are always initialized from g_quark_from_string and
+g_quark_from_static_string
+
+This fixes crashes in glibmm with musl which likely happens on AIX too.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=768215
+https://bugzilla.gnome.org/show_bug.cgi?id=756139#c14
+---
+ glib/gquark.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/glib/gquark.c b/glib/gquark.c
+index 9e51a92..17ecd7f 100644
+--- a/glib/gquark.c
++++ b/glib/gquark.c
+@@ -57,6 +57,11 @@ static gint quark_block_offset = 0;
+ void
+ g_quark_init (void)
+ {
++ /* we may be initialized from c++ constructor or the glib ctor, but we
++ cannot guarantee in what order. So we check if we have been initialized */
++ if (quark_ht != NULL)
++ return;
++
+ g_assert (quark_seq_id == 0);
+ quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
+ quarks = g_new (gchar*, QUARK_BLOCK_SIZE);
+@@ -179,6 +184,9 @@ quark_from_string (const gchar *string,
+ {
+ GQuark quark = 0;
+
++ if (G_UNLIKELY (quark_ht == NULL))
++ g_quark_init();
++
+ quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string));
+
+ if (!quark)
+--
+2.9.0
+
diff --git a/system/glib/APKBUILD b/system/glib/APKBUILD
new file mode 100644
index 000000000..89a98754f
--- /dev/null
+++ b/system/glib/APKBUILD
@@ -0,0 +1,103 @@
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=glib
+pkgver=2.54.2
+pkgrel=1
+pkgdesc="Common C routines used by Gtk+ and other libs"
+url="https://developer.gnome.org/glib/"
+arch="all"
+license="GPL"
+depends=
+triggers="$pkgname.trigger=/usr/share/glib-2.0/schemas:/usr/lib/gio/modules"
+depends_dev="perl python3 attr-dev gettext-dev zlib-dev bzip2-dev libffi-dev
+ util-linux-dev"
+makedepends="$depends_dev pcre-dev xmlto"
+checkdepends="tzdata"
+options="!checkroot"
+source="https://download.gnome.org/sources/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.xz
+ 0001-gquark-fix-initialization-with-c-constructors.patch
+ broken-gio-tests.patch
+ fix-spawn.patch
+ i386-fpu-test.patch
+ musl-no-locale.patch
+ ridiculous-strerror-nonconformance.patch
+ thread-test-fix.patch
+ "
+subpackages="$pkgname-dbg $pkgname-doc $pkgname-static $pkgname-dev $pkgname-lang $pkgname-bash-completion:bashcomp:noarch"
+builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+
+ # workaround packaging issue. gtk-doc.make timestamp was newer than
+ # Makefile.am, which triggers automake re-run
+ touch -r docs/reference/glib/Makefile.am gtk-doc.make
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --mandir=/usr/share/man \
+ --disable-gtk-doc \
+ --disable-compile-warnings \
+ --disable-selinux \
+ --with-pcre=system \
+ --with-python=python3 \
+ --with-pic \
+ --enable-static
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ rm -rf "$pkgdir"/usr/lib/charset.alias
+}
+
+dev() {
+ default_dev
+ mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/share
+ find "$pkgdir"/usr/bin ! -name "glib-compile-schemas" -a \( \
+ -name "gdbus-codegen" -o \
+ -name "gobject-query" -o \
+ -name "gresource" -o \
+ -name "gtester*" -o \
+ -name "glib-*" \) \
+ -exec mv {} "$subpkgdir"/usr/bin \;
+ mv "$pkgdir"/usr/share/gdb "$pkgdir"/usr/share/glib-2.0 \
+ "$subpkgdir"/usr/share
+}
+
+static() {
+ pkgdesc="glib static libraries"
+ depends="gettext-static"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/
+}
+
+bashcomp() {
+ pkgdesc="Bash completion for $pkgname"
+ depends=
+ install_if="$pkgname=$pkgver-r$pkgrel bash-completion"
+ mkdir -p "$subpkgdir"/usr/share
+ mv "$pkgdir"/usr/share/bash-completion "$subpkgdir"/usr/share
+ [ "$(ls -A "$pkgdir"/usr/share)" ] || rmdir "$pkgdir"/usr/share
+}
+
+sha512sums="09ee6fa3a6f3f15af229bd789bef536e3570f36d1e4ce624a57e97c4040577f6baccd6ab5746257863ccf7173b558cfa753951d562a278f854e52604104ba7ee glib-2.54.2.tar.xz
+32e5aca9a315fb985fafa0b4355e4498c1f877fc1f0b58ad4ac261fb9fbced9f026c7756a5f2af7d61ce756b55c8cd02811bb08df397040e93510056f073756b 0001-gquark-fix-initialization-with-c-constructors.patch
+9bf99de4672765704759098c883cfc4d2747cf10d9d568ae97134806a089e4bebae57886bae45dcc53694e0190248abe6ae52cc38dc742cd754d352406ac0680 broken-gio-tests.patch
+0f0a98784aeed92f33cd9239d2f668bdc6c09b84ed020825ae88f6aacf6a922152dc3e1384c40d9f30f54c5ab78fe17e0ee5c42b268b297b595d2a6cde5b8998 fix-spawn.patch
+aa7444bbdf7b88798adc67c15cdb8b7459450c0b7357caea16b74462c5c9179ba80d4018b1e656e90a5e3be5b2e3c14e9b8c0ccbb2ee4d8c92dc8fa627518b84 i386-fpu-test.patch
+10d23961072e3d8c8bbe5ee9a6b6ad709734690485c7148f1f8a2081a3ecc06cc3e3ff02ea870e1b429cd8464df6ef6e9f266148010d889fd187f4e411f65bab musl-no-locale.patch
+56c10a0f64cbd8ce584d428f818e7e678fdeb40a32df792843208ddfa3135d362cc2077bc9fe3bfebe13ee6af0ecf6403a593ad727e0a92276074a17a9c7029c ridiculous-strerror-nonconformance.patch
+0cebf9cbf87a92c3160054eb30189a827847f5820a8b90f4842b4ad5ab5cc343ba06e5f55214864bd0f0d5a21e55ec5e7f35c66207e77b1496142b7ee0c75567 thread-test-fix.patch"
diff --git a/system/glib/broken-gio-tests.patch b/system/glib/broken-gio-tests.patch
new file mode 100644
index 000000000..d7006db87
--- /dev/null
+++ b/system/glib/broken-gio-tests.patch
@@ -0,0 +1,100 @@
+Requires update-desktop-database
+--- glib-2.52.1/gio/tests/appinfo.c.old 2016-10-22 00:17:49.000000000 -0500
++++ glib-2.52.1/gio/tests/appinfo.c 2017-08-20 23:23:32.581229536 -0500
+@@ -486,7 +486,7 @@
+ g_test_add_func ("/appinfo/launch-context", test_launch_context);
+ g_test_add_func ("/appinfo/launch-context-signals", test_launch_context_signals);
+ g_test_add_func ("/appinfo/tryexec", test_tryexec);
+- g_test_add_func ("/appinfo/associations", test_associations);
++ //g_test_add_func ("/appinfo/associations", test_associations);
+ g_test_add_func ("/appinfo/environment", test_environment);
+ g_test_add_func ("/appinfo/startup-wm-class", test_startup_wm_class);
+ g_test_add_func ("/appinfo/supported-types", test_supported_types);
+
+
+Requires shared-mime-info
+--- glib-2.53.7/gio/tests/contenttype.c.old 2017-07-13 18:03:39.000000000 -0500
++++ glib-2.53.7/gio/tests/contenttype.c 2017-09-05 21:41:46.312547646 -0500
+@@ -345,9 +345,9 @@
+
+ g_test_bug_base ("http://bugzilla.gnome.org/");
+
+- g_test_add_func ("/contenttype/guess", test_guess);
++ //g_test_add_func ("/contenttype/guess", test_guess);
+ g_test_add_func ("/contenttype/unknown", test_unknown);
+- g_test_add_func ("/contenttype/subtype", test_subtype);
++ /*g_test_add_func ("/contenttype/subtype", test_subtype);
+ g_test_add_func ("/contenttype/list", test_list);
+ g_test_add_func ("/contenttype/executable", test_executable);
+ g_test_add_func ("/contenttype/description", test_description);
+@@ -355,7 +355,7 @@
+ g_test_add_func ("/contenttype/symbolic-icon", test_symbolic_icon);
+ g_test_add_func ("/contenttype/tree", test_tree);
+ g_test_add_func ("/contenttype/test_type_is_a_special_case",
+- test_type_is_a_special_case);
++ test_type_is_a_special_case);*/
+
+ return g_test_run ();
+ }
+
+
+Requires working iconv
+--- glib-2.52.1/gio/tests/converter-stream.c.old 2016-10-22 00:18:11.000000000 -0500
++++ glib-2.52.1/gio/tests/converter-stream.c 2017-08-20 23:21:31.711358101 -0500
+@@ -1203,7 +1203,7 @@
+ };
+ CharsetTest charset_tests[] = {
+ { "/converter-input-stream/charset/utf8->latin1", "UTF-8", "\303\205rr Sant\303\251", "ISO-8859-1", "\305rr Sant\351", 0 },
+- { "/converter-input-stream/charset/latin1->utf8", "ISO-8859-1", "\305rr Sant\351", "UTF-8", "\303\205rr Sant\303\251", 0 },
++ //{ "/converter-input-stream/charset/latin1->utf8", "ISO-8859-1", "\305rr Sant\351", "UTF-8", "\303\205rr Sant\303\251", 0 },
+- { "/converter-input-stream/charset/fallbacks", "UTF-8", "Some characters just don't fit into latin1: πא", "ISO-8859-1", "Some characters just don't fit into latin1: \\CF\\80\\D7\\90", 4 },
++ //{ "/converter-input-stream/charset/fallbacks", "UTF-8", "Some characters just don't fit into latin1: πא", "ISO-8859-1", "Some characters just don't fit into latin1: \\CF\\80\\D7\\90", 4 },
+ };
+
+
+
+Requires dconf
+--- glib-2.52.1/gio/tests/gsettings.c.old 2017-08-20 23:26:31.284378974 -0500
++++ glib-2.52.1/gio/tests/gsettings.c 2017-08-20 23:26:46.637699607 -0500
+@@ -2603,6 +2603,8 @@
+ gchar *schema_text;
+ gchar *enums;
+ gint result;
++ printf("1..0\n");
++ return 0;
+
+ setlocale (LC_ALL, "");
+
+
+Requires update-desktop-database
+--- glib-2.52.1/gio/tests/desktop-app-info.c.old 2016-10-22 00:17:55.000000000 -0500
++++ glib-2.52.1/gio/tests/desktop-app-info.c 2017-08-20 23:38:16.840439686 -0500
+@@ -761,6 +761,8 @@
+ {
+ gint result;
+
++ printf("1..0\n");
++ return 0;
+ g_test_init (&argc, &argv, NULL);
+
+ basedir = g_get_current_dir ();
+
+
+--- glib-2.52.1/gio/tests/resources.c.old 2016-10-22 00:18:12.000000000 -0500
++++ glib-2.52.1/gio/tests/resources.c 2017-08-20 23:39:47.127025718 -0500
+@@ -426,6 +426,7 @@
+ g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
+ g_bytes_unref (data);
+
++#if 0 // dlclose is noop on musl
+ g_type_module_unuse (G_TYPE_MODULE (module));
+
+ found = g_resources_get_info ("/resourceplugin/test1.txt",
+@@ -434,6 +435,7 @@
+ g_assert (!found);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
+ g_clear_error (&error);
++#endif
+ }
+ }
+
diff --git a/system/glib/fix-spawn.patch b/system/glib/fix-spawn.patch
new file mode 100644
index 000000000..df352fdc3
--- /dev/null
+++ b/system/glib/fix-spawn.patch
@@ -0,0 +1,22 @@
+--- glib-2.52.1/glib/tests/spawn-singlethread.c.old 2016-10-22 00:21:35.000000000 -0500
++++ glib-2.52.1/glib/tests/spawn-singlethread.c 2017-08-20 22:31:52.548311424 -0500
+@@ -210,7 +210,7 @@
+ g_test_init (&argc, &argv, NULL);
+
+ dirname = g_path_get_dirname (argv[0]);
+- echo_prog_path = g_build_filename (dirname, "test-spawn-echo" EXEEXT, NULL);
++ echo_prog_path = g_build_filename (dirname, "../test-spawn-echo" EXEEXT, NULL);
+ if (!g_file_test (echo_prog_path, G_FILE_TEST_EXISTS))
+ {
+ g_free (echo_prog_path);
+--- glib-2.52.1/glib/tests/spawn-multithreaded.c.old 2016-10-22 00:21:44.000000000 -0500
++++ glib-2.52.1/glib/tests/spawn-multithreaded.c 2017-08-20 22:32:15.981614460 -0500
+@@ -222,7 +222,7 @@
+ g_test_init (&argc, &argv, NULL);
+
+ dirname = g_path_get_dirname (argv[0]);
+- echo_prog_path = g_build_filename (dirname, "test-spawn-echo" EXEEXT, NULL);
++ echo_prog_path = g_build_filename (dirname, "../test-spawn-echo" EXEEXT, NULL);
+ if (!g_file_test (echo_prog_path, G_FILE_TEST_EXISTS))
+ {
+ g_free (echo_prog_path);
diff --git a/system/glib/glib.trigger b/system/glib/glib.trigger
new file mode 100644
index 000000000..cf23eff7d
--- /dev/null
+++ b/system/glib/glib.trigger
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+for i in "$@"; do
+ if ! [ -e "$i" ]; then
+ continue
+ fi
+ case "$i" in
+ */modules)
+ /usr/bin/gio-querymodules "$i"
+ ;;
+ */schemas)
+ /usr/bin/glib-compile-schemas "$i"
+ ;;
+ esac
+done
+
diff --git a/system/glib/i386-fpu-test.patch b/system/glib/i386-fpu-test.patch
new file mode 100644
index 000000000..986c33164
--- /dev/null
+++ b/system/glib/i386-fpu-test.patch
@@ -0,0 +1,13 @@
+--- glib-2.54.2/glib/tests/timer.c.old 2016-10-22 00:21:30.000000000 -0500
++++ glib-2.54.2/glib/tests/timer.c 2018-03-03 18:39:40.424741042 -0600
+@@ -203,7 +203,10 @@
+ {
+ g_test_init (&argc, &argv, NULL);
+
++ /* This test fails on the i386 because of crappy FPU */
++#ifndef __i386__
+ g_test_add_func ("/timer/basic", test_timer_basic);
++#endif
+ g_test_add_func ("/timer/stop", test_timer_stop);
+ g_test_add_func ("/timer/continue", test_timer_continue);
+ g_test_add_func ("/timer/reset", test_timer_reset);
diff --git a/system/glib/musl-no-locale.patch b/system/glib/musl-no-locale.patch
new file mode 100644
index 000000000..4b36b0b2e
--- /dev/null
+++ b/system/glib/musl-no-locale.patch
@@ -0,0 +1,55 @@
+--- glib-2.52.1/glib/tests/option-context.c.old 2016-10-22 05:21:34.000000000 +0000
++++ glib-2.52.1/glib/tests/option-context.c 2017-08-20 23:14:46.364133517 +0000
+@@ -638,7 +638,7 @@
+
+ old_locale = g_strdup (setlocale (LC_NUMERIC, locale));
+ current_locale = setlocale (LC_NUMERIC, NULL);
+- if (strcmp (current_locale, locale) != 0)
++ //if (strcmp (current_locale, locale) != 0)
+ {
+ fprintf (stderr, "Cannot set locale to %s, skipping\n", locale);
+ goto cleanup;
+--- glib-2.52.1/glib/tests/gdatetime.c.old 2017-03-16 20:12:05.000000000 -0500
++++ glib-2.52.1/glib/tests/gdatetime.c 2017-08-20 22:20:37.805908983 -0500
+@@ -1068,7 +1068,7 @@
+
+ oldlocale = g_strdup (setlocale (LC_ALL, NULL));
+ setlocale (LC_ALL, "fa_IR.utf-8");
+- if (strstr (setlocale (LC_ALL, NULL), "fa_IR") != NULL)
++ if ((1 == 0) && strstr (setlocale (LC_ALL, NULL), "fa_IR") != NULL)
+ {
+ TEST_PRINTF_TIME (23, 0, 0, "%OH", "\333\262\333\263"); /* '23' */
+ TEST_PRINTF_TIME (23, 0, 0, "%OI", "\333\261\333\261"); /* '11' */
+--- glib-2.52.1/glib/tests/convert.c.old 2016-10-22 00:21:34.000000000 -0500
++++ glib-2.52.1/glib/tests/convert.c 2017-08-20 22:51:48.363430954 -0500
+@@ -707,7 +707,7 @@
+
+ g_test_add_func ("/conversion/no-conv", test_no_conv);
+ g_test_add_func ("/conversion/iconv-state", test_iconv_state);
+- g_test_add_func ("/conversion/illegal-sequence", test_one_half);
++ //g_test_add_func ("/conversion/illegal-sequence", test_one_half);
+- g_test_add_func ("/conversion/byte-order", test_byte_order);
++ //g_test_add_func ("/conversion/byte-order", test_byte_order);
+ g_test_add_func ("/conversion/unicode", test_unicode_conversions);
+ g_test_add_func ("/conversion/filename-utf8", test_filename_utf8);
+--- glib-2.54.2/glib/tests/collate.c.old 2017-03-08 21:37:21.000000000 -0600
++++ glib-2.54.2/glib/tests/collate.c 2018-03-01 01:07:56.957714447 -0600
+@@ -279,7 +279,7 @@
+
+ g_setenv ("LC_ALL", "en_US", TRUE);
+ locale = setlocale (LC_ALL, "");
+- if (locale == NULL || strcmp (locale, "en_US") != 0)
++ //if (locale == NULL || strcmp (locale, "en_US") != 0)
+ {
+ g_test_message ("No suitable locale, skipping tests");
+ missing_locale = TRUE;
+--- glib-2.54.2/tests/run-collate-tests.sh.old 2016-10-22 00:17:10.000000000 -0500
++++ glib-2.54.2/tests/run-collate-tests.sh 2018-03-01 01:22:01.107722429 -0600
+@@ -1,5 +1,7 @@
+ #! /bin/sh
+
++exit 77
++
+ fail ()
+ {
+ echo "Test failed: $*"
diff --git a/system/glib/ridiculous-strerror-nonconformance.patch b/system/glib/ridiculous-strerror-nonconformance.patch
new file mode 100644
index 000000000..3ffc0aafa
--- /dev/null
+++ b/system/glib/ridiculous-strerror-nonconformance.patch
@@ -0,0 +1,11 @@
+--- glib-2.52.1/glib/tests/strfuncs.c.old 2016-10-22 00:21:44.000000000 -0500
++++ glib-2.52.1/glib/tests/strfuncs.c 2017-08-20 22:48:18.233702952 -0500
+@@ -1335,7 +1335,7 @@
+ setlocale (LC_ALL, "C");
+
+ strs = g_hash_table_new (g_str_hash, g_str_equal);
+- for (i = 1; i < 200; i++)
++ for (i = 1; i < 40; i++)
+ {
+ str = g_strerror (i);
+ g_assert (str != NULL);
diff --git a/system/glib/thread-test-fix.patch b/system/glib/thread-test-fix.patch
new file mode 100644
index 000000000..bcfcfc441
--- /dev/null
+++ b/system/glib/thread-test-fix.patch
@@ -0,0 +1,11 @@
+--- glib-2.52.1/glib/tests/thread.c.old 2016-10-22 05:21:37.000000000 +0000
++++ glib-2.52.1/glib/tests/thread.c 2017-08-20 04:51:46.756496035 +0000
+@@ -174,7 +174,7 @@
+ static gpointer
+ thread6_func (gpointer data)
+ {
+-#ifdef HAVE_PTHREAD_SETNAME_NP_WITH_TID
++#if 0
+ char name[16];
+
+ pthread_getname_np (pthread_self(), name, 16);
diff --git a/system/gnutls/APKBUILD b/system/gnutls/APKBUILD
new file mode 100644
index 000000000..b64faaa64
--- /dev/null
+++ b/system/gnutls/APKBUILD
@@ -0,0 +1,74 @@
+# Contriburo: Łukasz Jendrysik <scadu@yandex.com>
+# Contributor: Michael Mason <ms13sp@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gnutls
+pkgver=3.6.1
+pkgrel=0
+pkgdesc="A TLS protocol implementation"
+url="http://www.gnutls.org/"
+arch="all"
+license="GPL"
+checkdepends="diffutils"
+makedepends="nettle-dev zlib-dev libtasn1-dev p11-kit-dev libunistring-dev texinfo"
+subpackages="$pkgname-dbg $pkgname-doc $pkgname-dev $pkgname-utils $pkgname-c++:xx"
+_v=${pkgver%.*}
+case $pkgver in
+*.*.*.*) _v=${_v%.*};;
+esac
+source="https://www.gnupg.org/ftp/gcrypt/gnutls/v${_v}/$pkgname-$pkgver.tar.xz
+ tests-date-compat.patch"
+builddir="$srcdir/$pkgname-$pkgver"
+
+# secfixes:
+# 3.5.13-r0:
+# - CVE-2017-7507
+
+build() {
+ cd "$builddir"
+ LIBS="-lgmp" ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-openssl-compatibility \
+ --disable-rpath \
+ --disable-static \
+ --disable-guile \
+ --disable-valgrind-tests \
+ --without-included-libtasn1 \
+ --enable-cxx \
+ --enable-manpages \
+ --enable-tests \
+ --disable-full-test-suite \
+ --disable-sslv2-support \
+ --with-zlib \
+ --with-p11-kit
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+utils() {
+ pkgdesc="Command line tools for TLS protocol"
+ mkdir -p "$subpkgdir"/usr/
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+xx() {
+ pkgdesc="The C++ interface to GnuTLS"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/lib*xx.so.* "$subpkgdir"/usr/lib/
+}
+
+sha512sums="1f2bd3203ea96844c531be700b44623b79f46743143edf97011aab07895ca18d62f1659c7fafc5e1c4b0686fde490836f00358bdd60d6ac0b842526db002da23 gnutls-3.6.1.tar.xz
+14b1be86a0180c914aaaada261ccf01914d48df9510b57572e4f32683d1dd984a907ecf2c848cc4773b1c139059de26383a2c617f509f8c75b985668a23fd28d tests-date-compat.patch"
diff --git a/system/gnutls/tests-date-compat.patch b/system/gnutls/tests-date-compat.patch
new file mode 100644
index 000000000..2717ab230
--- /dev/null
+++ b/system/gnutls/tests-date-compat.patch
@@ -0,0 +1,12 @@
+Busybox date does not support %N, this is GNU extension.
+--- a/tests/scripts/common.sh
++++ b/tests/scripts/common.sh
+@@ -59,7 +59,7 @@
+ }
+
+ # Find a port number not currently in use.
+-GETPORT='rc=0; myrandom=$(date +%N | sed s/^0*//)
++GETPORT='rc=0; myrandom=$(date +%s | sed s/^0*//)
+ while test $rc = 0;do
+ PORT="$(((($$<<15)|$myrandom) % 63001 + 2000))"
+ check_if_port_in_use $PORT;rc=$?
diff --git a/system/gpgme/APKBUILD b/system/gpgme/APKBUILD
new file mode 100644
index 000000000..10ffc83de
--- /dev/null
+++ b/system/gpgme/APKBUILD
@@ -0,0 +1,59 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=gpgme
+pkgver=1.9.0
+pkgrel=2
+pkgdesc="GnuPG Made Easy"
+url="http://www.gnupg.org/related_software/gpgme/"
+arch="all"
+license="GPL"
+depends="gnupg"
+depends_dev="libgpg-error-dev libassuan-dev qt5-qtbase-dev"
+makedepends="$depends_dev doxygen"
+subpackages="$pkgname-dev $pkgname-doc gpgmepp qgpgme"
+source="ftp://ftp.gnupg.org/gcrypt/$pkgname/$pkgname-$pkgver.tar.bz2
+ fix-bashism.patch"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+qgpgme() {
+ pkgdesc="$pkgdesc (Qt 5 library)"
+ mkdir -p "$subpkgdir"/usr/lib/
+ mv "$pkgdir"/usr/lib/libqgpgme.so* "$subpkgdir"/usr/lib/
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+gpgmepp() {
+ pkgdesc="C++ bindings for GPGME"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libgpgmepp.so.* "$subpkgdir"/usr/lib/
+}
+
+
+sha512sums="2a33343e907d9d70cc57dc1ef4e1c01995e1030bb0db937f44435643d6abfbb1bd55d52ba241701fa702783ebf035c09941131604fd8a811474b8bee41afccc8 gpgme-1.9.0.tar.bz2
+6d83139277026d280fa08827623196c90c6158ecb9a39b58f58f3b4211d8d1e9694aa255eb71a08e40028776f6cc9df9b8f6a71d918065479504de14619a11bd fix-bashism.patch"
diff --git a/system/gpgme/fix-bashism.patch b/system/gpgme/fix-bashism.patch
new file mode 100644
index 000000000..19508c96e
--- /dev/null
+++ b/system/gpgme/fix-bashism.patch
@@ -0,0 +1,10 @@
+diff --git a/tests/gpg/pinentry b/tests/gpg/pinentry
+index 3b99726..b12caae 100755
+--- a/tests/gpg/pinentry
++++ b/tests/gpg/pinentry
+@@ -1,4 +1,4 @@
+-#! /bin/bash
++#! /bin/sh
+ # Dummy pinentry
+ #
+ # Copyright 2008 g10 Code GmbH
diff --git a/system/graphviz/0001-clone-nameclash.patch b/system/graphviz/0001-clone-nameclash.patch
new file mode 100644
index 000000000..6222238d8
--- /dev/null
+++ b/system/graphviz/0001-clone-nameclash.patch
@@ -0,0 +1,87 @@
+From cb8bbbd3a48fa1f41965617852d11e02eb20b1f0 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Tue, 26 Jul 2011 12:41:21 +0000
+Subject: [PATCH] clone nameclash
+
+---
+ lib/gvpr/actions.c | 6 +++---
+ lib/gvpr/actions.h | 2 +-
+ lib/gvpr/compile.c | 2 +-
+ lib/gvpr/gvpr.c | 4 ++--
+ 4 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/lib/gvpr/actions.c b/lib/gvpr/actions.c
+index 05bfcd1..b3b4a60 100644
+--- a/lib/gvpr/actions.c
++++ b/lib/gvpr/actions.c
+@@ -380,7 +380,7 @@ Agraph_t *cloneG(Agraph_t * g, char* name)
+ * graph. Otherwise, create a clone subgraph of g.
+ * Assume obj != NULL.
+ */
+-Agobj_t *clone(Agraph_t * g, Agobj_t * obj)
++Agobj_t *cloneO(Agraph_t * g, Agobj_t * obj)
+ {
+ Agobj_t *nobj = 0;
+ Agedge_t *e;
+@@ -415,8 +415,8 @@ Agobj_t *clone(Agraph_t * g, Agobj_t * obj)
+ case AGINEDGE:
+ case AGOUTEDGE:
+ e = (Agedge_t *) obj;
+- t = (Agnode_t *) clone(g, OBJ(agtail(e)));
+- h = (Agnode_t *) clone(g, OBJ(aghead(e)));
++ t = (Agnode_t *) cloneO(g, OBJ(agtail(e)));
++ h = (Agnode_t *) cloneO(g, OBJ(aghead(e)));
+ name = agnameof (AGMKOUT(e));
+ nobj = (Agobj_t *) openEdge(g, t, h, name);
+ if (nobj)
+diff --git a/lib/gvpr/actions.h b/lib/gvpr/actions.h
+index 5c62a3b..4223c52 100644
+--- a/lib/gvpr/actions.h
++++ b/lib/gvpr/actions.h
+@@ -22,7 +22,7 @@ extern "C" {
+ #include "expr.h"
+
+ extern void nodeInduce(Agraph_t * selected);
+- extern Agobj_t *clone(Agraph_t * g, Agobj_t * obj);
++ extern Agobj_t *cloneO(Agraph_t * g, Agobj_t * obj);
+ extern Agraph_t *cloneG(Agraph_t * g, char* name);
+ extern Agobj_t *copy(Agraph_t * g, Agobj_t * obj);
+ extern int copyAttr(Agobj_t * obj, Agobj_t * obj1);
+diff --git a/lib/gvpr/compile.c b/lib/gvpr/compile.c
+index c157572..0914210 100644
+--- a/lib/gvpr/compile.c
++++ b/lib/gvpr/compile.c
+@@ -1087,7 +1087,7 @@ getval(Expr_t * pgm, Exnode_t * node, Exid_t * sym, Exref_t * ref,
+ error(ERROR_WARNING, "NULL object passed to clone()");
+ v.integer = 0;
+ } else
+- v.integer = PTR2INT(clone(gp, objp));
++ v.integer = PTR2INT(cloneO(gp, objp));
+ break;
+ case F_cloneG:
+ gp = INT2PTR(Agraph_t *, args[0].integer);
+diff --git a/lib/gvpr/gvpr.c b/lib/gvpr/gvpr.c
+index 0d47d70..9a1bfd1 100644
+--- a/lib/gvpr/gvpr.c
++++ b/lib/gvpr/gvpr.c
+@@ -803,7 +803,7 @@ addOutputGraph (Gpr_t* state, gvpropts* uopts)
+ Agraph_t* g = state->outgraph;
+
+ if ((agroot(g) == state->curgraph) && !uopts->ingraphs)
+- g = (Agraph_t*)clone (0, (Agobj_t *)g);
++ g = (Agraph_t*)cloneO (0, (Agobj_t *)g);
+
+ uopts->n_outgraphs++;
+ uopts->outgraphs = oldof(uopts->outgraphs,Agraph_t*,uopts->n_outgraphs,0);
+@@ -988,7 +988,7 @@ int gvpr (int argc, char *argv[], gvpropts * uopts)
+
+ /* begin graph */
+ if (incoreGraphs && (opts->compflags & CLONE))
+- state->curgraph = (Agraph_t*)clone (0, (Agobj_t*)(state->curgraph));
++ state->curgraph = (Agraph_t*)cloneO (0, (Agobj_t*)(state->curgraph));
+ state->curobj = (Agobj_t *) state->curgraph;
+ state->tvroot = 0;
+ if (bp->begg_stmt)
+--
+1.7.6
+
diff --git a/system/graphviz/APKBUILD b/system/graphviz/APKBUILD
new file mode 100644
index 000000000..7f5b34c1f
--- /dev/null
+++ b/system/graphviz/APKBUILD
@@ -0,0 +1,120 @@
+# Contributor: Sören Tempel <soeren/alpine@soeren-tempel.net>
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=graphviz
+pkgver=2.40.1
+pkgrel=1
+pkgdesc="Graph Visualization Tools"
+url="http://www.graphviz.org/"
+arch="all"
+license="EPL"
+options="!check" # Requires unpackaged Criterion test framework
+depends=""
+depends_dev="zlib-dev libpng-dev libjpeg-turbo-dev expat-dev
+ fontconfig-dev libsm-dev libxext-dev cairo-dev pango-dev
+ librsvg-dev gmp-dev freetype-dev"
+makedepends="$depends_dev flex swig guile-dev m4 libtool
+ bison gtk+2.0-dev lua5.2-dev libltdl tcl"
+install="$pkgname.pre-deinstall"
+triggers="$pkgname.trigger=/usr/lib/graphviz"
+subpackages="$pkgname-dev $pkgname-doc lua-$pkgname:_lua
+ $pkgname-gtk $pkgname-graphs guile-$pkgname:guile"
+source="http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-$pkgver.tar.bz2
+ $pkgname.trigger
+ 0001-clone-nameclash.patch
+ "
+
+prepare() {
+ # Rename unpacked directory with hash in the name to something sane...
+ mv "$srcdir"/$pkgname-stable_release_$pkgver-* "$builddir"
+
+ default_prepare
+
+ cd "$builddir"
+ ./autogen.sh NOCONFIG
+}
+
+build() {
+ cd "$builddir"
+
+ LIBPOSTFIX=/ \
+ LUA=lua5.2 \
+ LUA_CFLAGS="$(pkg-config --cflags lua5.2)" \
+ LUA_LIBS="$(pkg-config --libs lua5.2)" \
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --without-included-ltdl \
+ --disable-ltdl-install \
+ --disable-silent-rules \
+ --enable-ltdl \
+ --with-x \
+ --disable-static \
+ --disable-dependency-tracking \
+ --enable-java=no \
+ --enable-lua=yes \
+ --enable-python34=yes \
+ --enable-tcl=no \
+ --without-mylibgd \
+ --with-ipsepcola \
+ --with-pangocairo \
+ --with-gdk-pixbuf \
+ --with-png \
+ --with-jpeg \
+ --with-rsvg
+
+ if [ "$CARCH" = "x86_64" ]; then
+ # the configure script thinks we have sincos. we dont.
+ sed -i -e '/HAVE_SINCOS/d' config.h
+ fi
+
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" \
+ pkgconfigdir=/usr/lib/pkgconfig \
+ install
+
+ mkdir -p "$pkgdir"/usr/share/doc
+ mv "$pkgdir"/usr/share/graphviz/doc \
+ "$pkgdir"/usr/share/doc/graphviz
+}
+
+guile() {
+ pkgdesc="Guile bindings for graphviz"
+ mkdir -p "$subpkgdir"/usr/lib/graphviz
+ mv "$pkgdir"/usr/lib/graphviz/guile* \
+ "$subpkgdir"/usr/lib/graphviz/
+}
+
+_lua() {
+ pkgdesc="Lua extension for graphviz"
+ mkdir -p "$subpkgdir"/usr/lib/graphviz \
+ "$subpkgdir"/usr/lib/lua
+ mv "$pkgdir"/usr/lib/graphviz/lua \
+ "$subpkgdir"/usr/lib/graphviz
+ mv "$pkgdir"/usr/lib/lua "$subpkgdir"/usr/lib/
+}
+
+gtk() {
+ pkgdesc="Gtk extension for graphviz"
+ mkdir -p "$subpkgdir"/usr/lib/graphviz
+ mv "$pkgdir"/usr/lib/graphviz/libgvplugin_g?k* \
+ "$pkgdir"/usr/lib/graphviz/libgvplugin_rsvg* \
+ "$subpkgdir"/usr/lib/graphviz
+}
+
+graphs() {
+ pkgdesc="Demo graphs for graphviz"
+ mkdir -p "$subpkgdir"/usr/share/graphviz
+ mv "$pkgdir"/usr/share/graphviz/graphs \
+ "$subpkgdir"/usr/share/graphviz/
+}
+
+sha512sums="4e819b3906f3b8e31245a021acd6fae4a1bc55df0a4df6b57a3578a62017e9db0b474a38f3f54682b9e9136d332f2374feee308af489e2848f8bc303ffab58ac graphviz-2.40.1.tar.bz2
+50947e6a11929f724759266f7716d52d10923eba6d59704ab39e4bdf18f8471d548c2b11ab051dd4b67cb82742aaf54d6358890d049d5b5982f3383b65f7ae8c graphviz.trigger
+aa4cbc341906a949a6bf78cadd96c437d6bcc90369941fe03519aa4447731ecbf6063a0dd0366d3e7aaadf22b69e4bcab3f8632a7da7a01f8e08a3be05c2bc5d 0001-clone-nameclash.patch"
diff --git a/system/graphviz/graphviz.pre-deinstall b/system/graphviz/graphviz.pre-deinstall
new file mode 100644
index 000000000..cfc43bf6a
--- /dev/null
+++ b/system/graphviz/graphviz.pre-deinstall
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ -e /usr/lib/graphviz/config6 ]; then
+ rm /usr/lib/graphviz/config6
+fi
diff --git a/system/graphviz/graphviz.trigger b/system/graphviz/graphviz.trigger
new file mode 100644
index 000000000..99d447b9b
--- /dev/null
+++ b/system/graphviz/graphviz.trigger
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec /usr/bin/dot -c
diff --git a/system/gsl/APKBUILD b/system/gsl/APKBUILD
new file mode 100644
index 000000000..2820f36d6
--- /dev/null
+++ b/system/gsl/APKBUILD
@@ -0,0 +1,42 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: A. Wilcox <awilfox@adelielinux.org>
+pkgname=gsl
+pkgver=2.4
+pkgrel=2
+pkgdesc="The GNU Scientific Library (GSL) is a modern numerical library for C and C++ programmers"
+url="http://www.gnu.org/software/gsl/gsl.html"
+arch="all"
+license="GPL-3.0+"
+depends=
+makedepends=
+install=
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://ftp.gnu.org/gnu/gsl/gsl-$pkgver.tar.gz
+ dont-disable-deprecated.patch
+ aarch64-test-failure.patch"
+
+# dont-disable-deprecated.patch is workaround for:
+# https://github.com/SciRuby/rb-gsl/issues/40
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="12442b023dd959e8b22a9c486646b5cedec7fdba0daf2604cda365cf96d10d99aefdec2b42e59c536cc071da1525373454e5ed6f4b15293b305ca9b1dc6db130 gsl-2.4.tar.gz
+88d40e599a9e619d8968f9848a91c54492d99032734371ee23072c8dae9d9920da445c1f8a880baa613479facec4afca3d3dec1070c240e5dfd5a662a41c92e8 dont-disable-deprecated.patch
+68b685270a377341b3c3ce566ae6eff4ebfc27b75a73f3c7915c57446798bdcca7c1d9f0fa4ce8a50118b371bfe3e2947f9bf33590c86e85db8e807b3b0deae6 aarch64-test-failure.patch"
diff --git a/system/gsl/aarch64-test-failure.patch b/system/gsl/aarch64-test-failure.patch
new file mode 100644
index 000000000..0b6e80380
--- /dev/null
+++ b/system/gsl/aarch64-test-failure.patch
@@ -0,0 +1,13 @@
+https://lists.gnu.org/archive/html/help-gsl/2017-02/msg00002.html
+
+--- gsl-2.4/linalg/test_cholesky.c.old 2017-06-19 10:00:43.000000000 +0000
++++ gsl-2.4/linalg/test_cholesky.c 2018-05-30 07:37:04.835628069 +0000
+@@ -551,7 +551,7 @@
+ if (N <= 4)
+ {
+ create_hilbert_matrix2(m);
+- test_mcholesky_invert_eps(m, 256.0 * N * GSL_DBL_EPSILON, "mcholesky_invert unscaled hilbert");
++ test_mcholesky_invert_eps(m, 512.0 * N * GSL_DBL_EPSILON, "mcholesky_invert unscaled hilbert");
+ }
+
+ gsl_matrix_free(m);
diff --git a/system/gsl/dont-disable-deprecated.patch b/system/gsl/dont-disable-deprecated.patch
new file mode 100644
index 000000000..40a7c3bce
--- /dev/null
+++ b/system/gsl/dont-disable-deprecated.patch
@@ -0,0 +1,24 @@
+diff -urp gsl-2.2.1/configure.ac patched/configure.ac
+--- gsl-2.2.1/configure.ac 2016-08-31 15:54:07.000000000 +0100
++++ patched/configure.ac 2017-01-31 14:52:10.000000000 +0000
+@@ -575,10 +575,6 @@ AH_BOTTOM([#if defined(GSL_RANGE_CHECK_O
+ AH_BOTTOM([#define RETURN_IF_NULL(x) if (!x) { return ; }
+ ])
+
+-AH_VERBATIM([GSL_DISABLE_DEPRECATED],
+-[/* Disable deprecated functions and enums while building */
+-#define GSL_DISABLE_DEPRECATED 1])
+-
+ dnl
+ AC_CONFIG_FILES([ \
+ Makefile \
+--- gsl-2.2.1/config.h.in 2016-08-31 15:54:51.000000000 +0100
++++ patched/config.h.in 2017-01-31 16:01:17.000000000 +0000
+@@ -1,8 +1,5 @@
+ /* config.h.in. Generated from configure.ac by autoheader. */
+
+-/* Disable deprecated functions and enums while building */
+-#define GSL_DISABLE_DEPRECATED 1
+-
+ /* Define if you have inline with C99 behavior */
+ #undef HAVE_C99_INLINE
diff --git a/system/hexchat/APKBUILD b/system/hexchat/APKBUILD
new file mode 100644
index 000000000..5f43c168d
--- /dev/null
+++ b/system/hexchat/APKBUILD
@@ -0,0 +1,61 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=hexchat
+pkgver=2.12.4
+pkgrel=1
+pkgdesc="A popular and easy to use graphical IRC (chat) client"
+url="https://hexchat.github.io"
+arch="all"
+license="GPL2+"
+depends=""
+makedepends="gtk+2.0-dev openssl-dev dbus-glib-dev perl-dev libsexy-dev
+ libnotify-dev libproxy-dev bash libtool autoconf automake"
+install=""
+subpackages="$pkgname-doc $pkgname-lang $pkgname-perl:_perl"
+source="https://dl.hexchat.net/hexchat/hexchat-$pkgver-repack.tar.xz
+ pixdata.patch
+ "
+
+builddir="$srcdir"/hexchat-$pkgver
+prepare() {
+ cd "$builddir"
+ default_prepare
+ autoreconf -vif
+}
+
+build() {
+ cd "$builddir"
+ LUA=lua5.3 \
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --enable-openssl \
+ --enable-dbus \
+ --disable-textfe \
+ --enable-perl \
+ --disable-python \
+ --disable-lua
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ # not worth a -dev pkg
+ rm -r "$pkgdir"/usr/include
+}
+
+_perl() {
+ pkgdesc="Perl plugin for Hexchat"
+ depends="$pkgname=$pkgver-r$pkgrel"
+ install_if="$pkgname=$pkgver-r$pkgrel perl"
+ mkdir -p "$subpkgdir"/usr/lib/hexchat/plugins
+ mv "$pkgdir"/usr/lib/hexchat/plugins/perl.so \
+ "$subpkgdir"/usr/lib/hexchat/plugins
+}
+
+sha512sums="30d42f5b488abec3fa457254720a39f62619338a5a2c3fe2e5a255aafe1b19817451b01cd260eab90868df1ebf9f663c60b78b6db974ca3c777272327c0b8a25 hexchat-2.12.4-repack.tar.xz
+5cb7ac95e6d53d677d7ec82485636f2c36003ba7fa0c4d4d353095dc6207c51abdc7a2230d43616895fef8ce2c7c2096bec21ac47117d0adbc7416ff3d4ba2c3 pixdata.patch"
diff --git a/system/hexchat/libressl.patch b/system/hexchat/libressl.patch
new file mode 100644
index 000000000..d829dee39
--- /dev/null
+++ b/system/hexchat/libressl.patch
@@ -0,0 +1,105 @@
+From d583ca7d922e5ac6ff466df2e4411b1303a3a2a3 Mon Sep 17 00:00:00 2001
+From: Florian Stinglmayr <florian@n0la.org>
+Date: Tue, 13 Dec 2016 18:41:43 +0100
+Subject: [PATCH] Use AC_CHECK_FUNCS to find functions not in LibreSSL
+
+LibreSSL might not have all functions of OpenSSL 1.1.0 so use
+AC_CHECK_FUNCS to find them first before using them.
+
+Closes #1899
+Fixes #1898
+---
+ configure.ac | 2 ++
+ src/common/ssl.c | 4 ++--
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 34e6def..1f442c5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -374,6 +374,8 @@ AS_IF([test "$openssl" != no], [
+ openssl=yes
+ COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS"
+ COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS"
++ dnl Test for various functions that are not available in LibreSSL
++ AC_CHECK_FUNCS([SSL_CTX_get_ssl_method X509_get_signature_nid])
+ ], [
+ unset openssl_path ac_cv_lib_ssl_SSL_new ac_cv_header_openssl_ssl_h
+ AS_IF([test "$openssl" != yes], [
+diff --git a/src/common/ssl.c b/src/common/ssl.c
+index cb58ce2..76fea7b 100644
+--- a/src/common/ssl.c
++++ b/src/common/ssl.c
+@@ -176,7 +176,7 @@ _SSL_get_cert_info (struct cert_info *cert_info, SSL * ssl)
+ return 1;
+
+ alg = OBJ_obj2nid (algor->algorithm);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#ifndef HAVE_X509_GET_SIGNATURE_NID
+ sign_alg = OBJ_obj2nid (peer_cert->sig_alg->algorithm);
+ #else
+ sign_alg = X509_get_signature_nid (peer_cert);
+@@ -306,7 +306,7 @@ _SSL_socket (SSL_CTX *ctx, int sd)
+
+ SSL_set_fd (ssl, sd);
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#ifndef HAVE_SSL_CTX_GET_SSL_METHOD
+ method = ctx->method;
+ #else
+ method = SSL_CTX_get_ssl_method (ctx);
+From aa7080f8fe63939d7ff4a0d0b1ec60f0c3eb31be Mon Sep 17 00:00:00 2001
+From: Patrick Griffis <tingping@tingping.se>
+Date: Tue, 13 Dec 2016 17:29:26 -0500
+Subject: [PATCH] Fix building fishlim against libressl also
+
+Also part of #1898
+---
+ configure.ac | 2 +-
+ plugins/fishlim/dh1080.c | 6 +++---
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 1f442c5..10a1550 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -375,7 +375,7 @@ AS_IF([test "$openssl" != no], [
+ COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS"
+ COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS"
+ dnl Test for various functions that are not available in LibreSSL
+- AC_CHECK_FUNCS([SSL_CTX_get_ssl_method X509_get_signature_nid])
++ AC_CHECK_FUNCS([SSL_CTX_get_ssl_method X509_get_signature_nid DH_set0_pqg DH_get0_key DH_set0_key])
+ ], [
+ unset openssl_path ac_cv_lib_ssl_SSL_new ac_cv_header_openssl_ssl_h
+ AS_IF([test "$openssl" != yes], [
+diff --git a/plugins/fishlim/dh1080.c b/plugins/fishlim/dh1080.c
+index ff6e579..3611758 100644
+--- a/plugins/fishlim/dh1080.c
++++ b/plugins/fishlim/dh1080.c
+@@ -74,7 +74,7 @@ dh1080_init (void)
+
+ BN_set_word (g, 2);
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#ifndef HAVE_DH_SET0_PQG
+ g_dh->p = p;
+ g_dh->g = g;
+ #else
+@@ -162,7 +162,7 @@ dh1080_generate_key (char **priv_key, char **pub_key)
+ return 0;
+ }
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#ifndef HAVE_DH_GET0_KEY
+ dh_pub_key = dh->pub_key;
+ dh_priv_key = dh->priv_key;
+ #else
+@@ -213,7 +213,7 @@ dh1080_compute_key (const char *priv_key, const char *pub_key, char **secret_key
+
+ priv_key_data = dh1080_decode_b64 (priv_key, &priv_key_len);
+ priv_key_num = BN_bin2bn(priv_key_data, priv_key_len, NULL);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#ifndef HAVE_DH_SET0_KEY
+ dh->priv_key = priv_key_num;
+ #else
+ DH_set0_key (dh, NULL, priv_key_num);
diff --git a/system/hexchat/pixdata.patch b/system/hexchat/pixdata.patch
new file mode 100644
index 000000000..4e720a848
--- /dev/null
+++ b/system/hexchat/pixdata.patch
@@ -0,0 +1,56 @@
+From 4c178782a779f013fafab476506f7d4dae372b8a Mon Sep 17 00:00:00 2001
+From: Patrick Griffis <tingping@tingping.se>
+Date: Sat, 17 Dec 2016 19:55:06 -0500
+Subject: [PATCH] Don't combine compression with pixdata option for icon
+ resources
+
+This made minimal difference and is not recommended by upstream.
+It also is affected by a regression in the latest gdk-pixbuf release.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=776105
+---
+ data/hexchat.gresource.xml | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/data/hexchat.gresource.xml b/data/hexchat.gresource.xml
+index c125da2..5845da5 100644
+--- a/data/hexchat.gresource.xml
++++ b/data/hexchat.gresource.xml
+@@ -1,23 +1,23 @@
+ <?xml version="1.0" encoding="UTF-8"?>
+ <gresources>
+ <gresource prefix="/icons">
+- <file alias="hexchat.png" preprocess="to-pixdata" compressed="true">icons/hexchat.png</file>
+- <file alias="book.png" preprocess="to-pixdata" compressed="true">icons/book.png</file>
++ <file alias="hexchat.png" preprocess="to-pixdata">icons/hexchat.png</file>
++ <file alias="book.png" preprocess="to-pixdata">icons/book.png</file>
+
+- <file alias="ulist_voice.png" preprocess="to-pixdata" compressed="true">icons/ulist_voice.png</file>
+- <file alias="ulist_halfop.png" preprocess="to-pixdata" compressed="true">icons/ulist_halfop.png</file>
+- <file alias="ulist_op.png" preprocess="to-pixdata" compressed="true">icons/ulist_op.png</file>
+- <file alias="ulist_owner.png" preprocess="to-pixdata" compressed="true">icons/ulist_owner.png</file>
+- <file alias="ulist_founder.png" preprocess="to-pixdata" compressed="true">icons/ulist_founder.png</file>
+- <file alias="ulist_netop.png" preprocess="to-pixdata" compressed="true">icons/ulist_netop.png</file>
++ <file alias="ulist_voice.png" preprocess="to-pixdata">icons/ulist_voice.png</file>
++ <file alias="ulist_halfop.png" preprocess="to-pixdata">icons/ulist_halfop.png</file>
++ <file alias="ulist_op.png" preprocess="to-pixdata">icons/ulist_op.png</file>
++ <file alias="ulist_owner.png" preprocess="to-pixdata">icons/ulist_owner.png</file>
++ <file alias="ulist_founder.png" preprocess="to-pixdata">icons/ulist_founder.png</file>
++ <file alias="ulist_netop.png" preprocess="to-pixdata">icons/ulist_netop.png</file>
+
+- <file alias="tray_fileoffer.png" preprocess="to-pixdata" compressed="true">icons/tray_fileoffer.png</file>
+- <file alias="tray_highlight.png" preprocess="to-pixdata" compressed="true">icons/tray_highlight.png</file>
+- <file alias="tray_message.png" preprocess="to-pixdata" compressed="true">icons/tray_message.png</file>
++ <file alias="tray_fileoffer.png" preprocess="to-pixdata">icons/tray_fileoffer.png</file>
++ <file alias="tray_highlight.png" preprocess="to-pixdata">icons/tray_highlight.png</file>
++ <file alias="tray_message.png" preprocess="to-pixdata">icons/tray_message.png</file>
+
+ <file alias="tree_channel.png" preprocess="to-pixdata">icons/tree_channel.png</file>
+- <file alias="tree_dialog.png" preprocess="to-pixdata" compressed="true">icons/tree_dialog.png</file>
+- <file alias="tree_server.png" preprocess="to-pixdata" compressed="true">icons/tree_server.png</file>
+- <file alias="tree_util.png" preprocess="to-pixdata" compressed="true">icons/tree_util.png</file>
++ <file alias="tree_dialog.png" preprocess="to-pixdata">icons/tree_dialog.png</file>
++ <file alias="tree_server.png" preprocess="to-pixdata">icons/tree_server.png</file>
++ <file alias="tree_util.png" preprocess="to-pixdata">icons/tree_util.png</file>
+ </gresource>
+ </gresources>
diff --git a/system/i3lock/APKBUILD b/system/i3lock/APKBUILD
new file mode 100644
index 000000000..c11e9bca8
--- /dev/null
+++ b/system/i3lock/APKBUILD
@@ -0,0 +1,43 @@
+# Contributor: Johannes Matheis <jomat+alpinebuild@jmt.gr>
+# Maintainer: Johannes Matheis <jomat+alpinebuild@jmt.gr>
+pkgname=i3lock
+pkgver=2.10
+pkgrel=0
+pkgdesc="An improved screenlocker based upon XCB and PAM"
+url="https://i3wm.org/i3lock/"
+arch="all"
+license="MIT"
+depends="xkeyboard-config"
+makedepends="libev-dev cairo-dev linux-pam-dev libxkbcommon-dev
+ xcb-util-image-dev which"
+subpackages="$pkgname-doc"
+source="$url/$pkgname-$pkgver.tar.bz2"
+builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+ default_prepare
+
+ cd "$builddir"
+
+ # Fix ticket FS#31544, sed line taken from gentoo
+ sed -i -e 's:login:base-auth:g' i3lock.pam
+}
+
+build() {
+ cd "$builddir"
+ make
+}
+
+check() {
+ cd "$builddir"
+ ./i3lock -v
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ install -m755 -d "$pkgdir/usr/share/man/man1/"
+ install -m644 $pkgname.1 "$pkgdir/usr/share/man/man1/"
+}
+
+sha512sums="ea865b202668212b58d0b97d0263171847e1bd0c529e2fd3d26c15ef253861b9a8357ff2efaa6a4f342c4d0d1ab03bc00f95f4d4008760ec8e0767ac29195517 i3lock-2.10.tar.bz2"
diff --git a/system/iproute2/APKBUILD b/system/iproute2/APKBUILD
new file mode 100644
index 000000000..755d5e21a
--- /dev/null
+++ b/system/iproute2/APKBUILD
@@ -0,0 +1,59 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=iproute2
+pkgver=4.13.0
+pkgrel=0
+pkgdesc="IP Routing Utilities"
+url="http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2"
+arch="all"
+license="GPL2"
+depends=""
+install="$pkgname.post-install"
+makedepends="bison flex bash libelf-dev"
+options="!check"
+subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch"
+source="http://kernel.org/pub/linux/utils/net/iproute2/iproute2-$pkgver.tar.xz
+ musl-fixes.patch"
+builddir="$srcdir"/$pkgname-$pkgver
+patch_args="-p0"
+
+prepare() {
+ default_prepare
+ cd "$builddir"
+
+ sed -i '/^TARGETS=/s: arpd : :' misc/Makefile
+ sed -i 's:/usr/local:/usr:' tc/m_ipt.c include/iptables.h
+ sed -i -e 's:=/share:=/usr/share:' \
+ -e 's:-Werror::' Makefile
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var
+ make CCOPTS="-D_GNU_SOURCE $CFLAGS" LIBDIR=/lib
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+bashcomp() {
+ depends=""
+ pkgdesc="Bash completions for $pkgname"
+ install_if="$pkgname=$pkgver-r$pkgrel bash-completion"
+
+ mkdir -p "$subpkgdir"/usr/share/
+ mv "$pkgdir"/usr/share/bash-completion \
+ "$subpkgdir"/usr/share
+
+ rmdir -p "$pkgdir"/usr/share 2>/dev/null || true
+}
+
+sha512sums="f96d2839aec1f439bfac504c8e3881c063dacbf4c67b15f0e3da9882d2fa013cba33c23602de3eab624e0eecbb911a13967d60bddcdf097f47a580a5a77b5e3a iproute2-4.13.0.tar.xz
+03f41867cc728d3fbf372ef00d8e90debd03671cff052f5e75dcfbeffbdb6e2c4b10d16e0737cdf473b063b710e8e2938a8f64cfa1be93da2c7878ce6ca51583 musl-fixes.patch"
diff --git a/system/iproute2/iproute2.post-install b/system/iproute2/iproute2.post-install
new file mode 100644
index 000000000..36d567ea2
--- /dev/null
+++ b/system/iproute2/iproute2.post-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+if [ "$(readlink /bin/ip)" = "/bin/busybox" ]; then
+ rm -f /bin/ip
+fi
+exit 0
diff --git a/system/iproute2/musl-fixes.patch b/system/iproute2/musl-fixes.patch
new file mode 100644
index 000000000..0149f6dae
--- /dev/null
+++ b/system/iproute2/musl-fixes.patch
@@ -0,0 +1,214 @@
+--- include/linux/if_ether.h 2017-07-06 11:09:53.305214044 -0700
++++ include/linux/if_ether.h 2017-07-06 16:30:06.651369931 -0700
+@@ -22,6 +22,7 @@
+ #define _LINUX_IF_ETHER_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+
+ /*
+ * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
+@@ -142,11 +143,13 @@
+ * This is an Ethernet frame header.
+ */
+
++#if __UAPI_DEF_ETHHDR
+ struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ __be16 h_proto; /* packet type ID field */
+ } __attribute__((packed));
++#endif
+
+
+ #endif /* _LINUX_IF_ETHER_H */
+--- include/linux/if_tunnel.h 2017-07-06 11:09:53.305214044 -0700
++++ include/linux/if_tunnel.h 2017-07-06 16:32:23.814172660 -0700
+@@ -2,7 +2,6 @@
+ #define _IF_TUNNEL_H_
+
+ #include <linux/types.h>
+-#include <linux/if.h>
+ #include <linux/ip.h>
+ #include <linux/in6.h>
+ #include <asm/byteorder.h>
+--- include/linux/ip6_tunnel.h 2017-07-06 11:09:53.303214021 -0700
++++ include/linux/ip6_tunnel.h 2017-07-06 16:33:41.630158864 -0700
+@@ -2,7 +2,6 @@
+ #define _IP6_TUNNEL_H
+
+ #include <linux/types.h>
+-#include <linux/if.h> /* For IFNAMSIZ. */
+ #include <linux/in6.h> /* For struct in6_addr. */
+
+ #define IPV6_TLV_TNL_ENCAP_LIMIT 4
+--- include/linux/kernel.h 2017-07-06 11:09:53.303214021 -0700
++++ include/linux/kernel.h 2017-07-06 16:30:06.650369918 -0700
+@@ -1,7 +1,9 @@
+ #ifndef _LINUX_KERNEL_H
+ #define _LINUX_KERNEL_H
+
++#ifdef __GLIBC__
+ #include <linux/sysinfo.h>
++#endif
+
+ /*
+ * 'kernel.h' contains some often-used function prototypes etc
+--- include/linux/libc-compat.h 2017-07-06 11:09:53.302214010 -0700
++++ include/linux/libc-compat.h 2017-07-06 16:30:06.650369918 -0700
+@@ -48,47 +48,57 @@
+ #ifndef _LIBC_COMPAT_H
+ #define _LIBC_COMPAT_H
+
+-/* We have included glibc headers... */
+-#if defined(__GLIBC__)
++/* We're used from userspace... */
++#if !defined(__KERNEL__)
+
+-/* Coordinate with glibc net/if.h header. */
++/* Coordinate with libc net/if.h header. */
+ #if defined(_NET_IF_H) && defined(__USE_MISC)
+
+-/* GLIBC headers included first so don't define anything
++/* libc headers included first so don't define anything
+ * that would already be defined. */
+
+ #define __UAPI_DEF_IF_IFCONF 0
+ #define __UAPI_DEF_IF_IFMAP 0
+ #define __UAPI_DEF_IF_IFNAMSIZ 0
+ #define __UAPI_DEF_IF_IFREQ 0
+-/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
+-/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
++/* If libc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
++#if !defined(__GLIBC__)
++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
++#else
+ #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+ #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
++#endif /* !defined(__GLIBC__) */
+
+ #else /* _NET_IF_H */
+
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that libc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
+
+ #define __UAPI_DEF_IF_IFCONF 1
+ #define __UAPI_DEF_IF_IFMAP 1
+ #define __UAPI_DEF_IF_IFNAMSIZ 1
+ #define __UAPI_DEF_IF_IFREQ 1
+-/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+-/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
++/* If libc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+
+ #endif /* _NET_IF_H */
+
+-/* Coordinate with glibc netinet/in.h header. */
++/* Coordinate with libc netinet/if_ether.h */
++#ifdef _NETINET_IF_ETHER_H
++#define __UAPI_DEF_ETHHDR 0
++#else
++/* glibc uses __NETINET_IF_ETHER_H and uses the uapi header */
++#define __UAPI_DEF_ETHHDR 1
++#endif /* _NETINET_IF_ETHER_H */
++
++/* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+-/* GLIBC headers included first so don't define anything
++/* libc headers included first so don't define anything
+ * that would already be defined. */
+ #define __UAPI_DEF_IN_ADDR 0
+ #define __UAPI_DEF_IN_IPPROTO 0
+@@ -98,15 +108,7 @@
+ #define __UAPI_DEF_IN_CLASS 0
+
+ #define __UAPI_DEF_IN6_ADDR 0
+-/* The exception is the in6_addr macros which must be defined
+- * if the glibc code didn't define them. This guard matches
+- * the guard in glibc/inet/netinet/in.h which defines the
+- * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
+-#if defined(__USE_MISC) || defined (__USE_GNU)
+ #define __UAPI_DEF_IN6_ADDR_ALT 0
+-#else
+-#define __UAPI_DEF_IN6_ADDR_ALT 1
+-#endif
+ #define __UAPI_DEF_SOCKADDR_IN6 0
+ #define __UAPI_DEF_IPV6_MREQ 0
+ #define __UAPI_DEF_IPPROTO_V6 0
+@@ -117,7 +119,7 @@
+ #else
+
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that libc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
+@@ -127,7 +129,7 @@
+ #define __UAPI_DEF_IN_CLASS 1
+
+ #define __UAPI_DEF_IN6_ADDR 1
+-/* We unconditionally define the in6_addr macros and glibc must
++/* We unconditionally define the in6_addr macros and libc must
+ * coordinate. */
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+ #define __UAPI_DEF_SOCKADDR_IN6 1
+@@ -168,18 +170,20 @@
+ /* If we did not see any headers from any supported C libraries,
+ * or we are being included in the kernel, then define everything
+ * that we need. */
+-#else /* !defined(__GLIBC__) */
++#else /* defined(__KERNEL__) */
+
+ /* Definitions for if.h */
+ #define __UAPI_DEF_IF_IFCONF 1
+ #define __UAPI_DEF_IF_IFMAP 1
+ #define __UAPI_DEF_IF_IFNAMSIZ 1
+ #define __UAPI_DEF_IF_IFREQ 1
+-/* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+-/* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
++/* If libc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+
++/* Definitions for if/ether.h */
++#define __UAPI_DEF_ETHHDR 1
++
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
+@@ -208,6 +212,6 @@
+ /* Definitions for xattr.h */
+ #define __UAPI_DEF_XATTR 1
+
+-#endif /* __GLIBC__ */
++#endif /* defined(__KERNEL__) */
+
+ #endif /* _LIBC_COMPAT_H */
+--- include/linux/netfilter_ipv4/ip_tables.h 2017-07-06 11:09:53.310214100 -0700
++++ include/linux/netfilter_ipv4/ip_tables.h 2017-07-06 16:38:57.526211238 -0700
+@@ -17,7 +17,6 @@
+
+ #include <linux/types.h>
+
+-#include <linux/if.h>
+ #include <linux/netfilter_ipv4.h>
+
+ #include <linux/netfilter/x_tables.h>
+--- tc/f_flower.c 2017-07-06 11:09:53.289213865 -0700
++++ tc/f_flower.c 2017-07-06 16:36:04.967030780 -0700
+@@ -15,7 +15,7 @@
+ #include <syslog.h>
+ #include <string.h>
+ #include <net/if.h>
+-#include <linux/if_arp.h>
++#include <net/if_arp.h>
+ #include <linux/if_ether.h>
+ #include <linux/ip.h>
+ #include <linux/tc_act/tc_vlan.h>
diff --git a/system/jasper/APKBUILD b/system/jasper/APKBUILD
new file mode 100644
index 000000000..74504d503
--- /dev/null
+++ b/system/jasper/APKBUILD
@@ -0,0 +1,49 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=jasper
+pkgver=2.0.14
+pkgrel=0
+pkgdesc="A software-based implementation of the codec specified in the emerging JPEG-2000 Part-1 standard"
+url="http://www.ece.uvic.ca/~mdadams/jasper/"
+arch="all"
+license="custom:JasPer2.0"
+depends= #"libjpeg>=8 freeglut libxi libxmu mesa"
+makedepends="libjpeg-turbo-dev cmake"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
+source="http://www.ece.uvic.ca/~frodo/jasper/software/jasper-$pkgver.tar.gz
+ "
+builddir="$srcdir"/$pkgname-$pkgver
+
+# secfixes:
+# 2.0.12-r1:
+# - CVE-2017-1000050
+
+build() {
+ mkdir "$builddir"/obj
+ cd "$builddir"/obj
+ # default of 16 causes stack overflow
+ export CFLAGS="${CFLAGS} -DJPC_QMFB_COLGRPSIZE=6"
+ cmake .. \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_INSTALL_LIBDIR=/usr/lib
+
+ make
+}
+
+check() {
+ cd "$builddir"/obj
+ make test
+}
+
+package() {
+ cd "$builddir"/obj
+ make DESTDIR="$pkgdir" install
+}
+
+libs() {
+ pkgdesc="JPEG-2000 library"
+ install -d "$subpkgdir"/usr/
+ mv "$pkgdir"/usr/lib "$subpkgdir"/usr
+}
+
+sha512sums="9e5cffd2e899e37ba08890e2377ddfc3c2fb13d9fe00dea6b4612e4d241a6f4327de6835809b415c41ae4bf44208cf7871c1982ff5fc04ae6bc09fd376b0afc8 jasper-2.0.14.tar.gz"
diff --git a/system/kyua/APKBUILD b/system/kyua/APKBUILD
new file mode 100644
index 000000000..588e4bfcf
--- /dev/null
+++ b/system/kyua/APKBUILD
@@ -0,0 +1,41 @@
+# Maintainer: William Pitcock <nenolod@dereferenced.org>
+pkgname=kyua
+pkgver=0.13
+pkgrel=1
+pkgdesc="testing framework for infrastructure software"
+url="https://github.com/jmmv/kyua"
+arch="all"
+license="BSD"
+depends=""
+makedepends="atf-dev lutok-dev sqlite-dev"
+install=""
+options="!checkroot"
+subpackages="$pkgname-doc"
+source="https://github.com/jmmv/kyua/releases/download/kyua-$pkgver/kyua-$pkgver.tar.gz"
+builddir="$srcdir/kyua-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+md5sums="475203c0877ebe739edf8b8dff4606ec kyua-0.13.tar.gz"
+sha256sums="db6e5d341d5cf7e49e50aa361243e19087a00ba33742b0855d2685c0b8e721d6 kyua-0.13.tar.gz"
+sha512sums="80ecf4fd888d4759122f3c1d1d5b06a19135e06f7bca1ef8458c7a5e78c1b6baff54969c863c93f11c40611ca256fc0334402531397b16788fb3ec701dd278ae kyua-0.13.tar.gz"
diff --git a/system/libbluray/APKBUILD b/system/libbluray/APKBUILD
new file mode 100644
index 000000000..925ad2cfd
--- /dev/null
+++ b/system/libbluray/APKBUILD
@@ -0,0 +1,36 @@
+# Contributor: Timo Teräs <timo.teras@iki.fi>
+# Maintainer: Timo Teräs <timo.teras@iki.fi>
+pkgname=libbluray
+pkgver=1.0.0
+pkgrel=1
+pkgdesc="a library designed for Blu-Ray Discs playback"
+url="http://www.videolan.org/developers/libbluray.html"
+arch="all"
+license="LGPL"
+options="!check" # Test requires an actual BD-ROM to play
+makedepends="fontconfig-dev libxml2-dev"
+subpackages="$pkgname-dev"
+source="http://download.videolan.org/pub/videolan/libbluray/$pkgver/libbluray-$pkgver.tar.bz2"
+builddir="$srcdir"/libbluray-$pkgver
+
+build() {
+ cd "$builddir"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --disable-bdjava
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="fcf2193c3b76f3436bc88ce8853cac16f29c3bb6c66447109c14202a41ea938cb6814502a8f724fb1b31add6bd36b42d3aed3eb4a8010c123537e073bd7a0be1 libbluray-1.0.0.tar.bz2"
diff --git a/system/libcanberra/APKBUILD b/system/libcanberra/APKBUILD
new file mode 100644
index 000000000..31cae167b
--- /dev/null
+++ b/system/libcanberra/APKBUILD
@@ -0,0 +1,95 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: William Pitcock <nenolod@dereferenced.org>
+pkgname=libcanberra
+pkgver=0.30
+pkgrel=2
+pkgdesc="simple audio library for GTK applications"
+url="http://0pointer.de/lennart/projects/libcanberra/"
+license="LGPL"
+options="!check" # No test suite.
+depends=
+makedepends="gtk+-dev libogg-dev libvorbis-dev alsa-lib-dev libtool gtk+3.0-dev
+ pulseaudio-dev gstreamer-dev"
+install=
+subpackages="$pkgname-dev $pkgname-doc $pkgname-gtk2 $pkgname-gtk3
+ $pkgname-gstreamer $pkgname-pulse"
+source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.xz"
+arch="all"
+
+depends_dev="$makedepends"
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ cd "$builddir"
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-oss
+ make
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+gtk2() {
+ pkgdesc="Gtk+ 2.x Bindings for libcanberra"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libcanberra-gtk.so.* \
+ "$subpkgdir"/usr/lib/
+ mv "$pkgdir"/usr/lib/gtk-2.0 \
+ "$subpkgdir"/usr/lib/
+}
+
+gtk3() {
+ pkgdesc="Gtk+ 3.x Bindings for libcanberra"
+ mkdir -p "$subpkgdir"/usr/lib/gnome-settings-daemon-3.0/gtk-modules \
+ "$subpkgdir"/usr/bin \
+ "$subpkgdir"/usr/share/gnome/autostart \
+ "$subpkgdir"/usr/share/gnome/shutdown \
+ "$subpkgdir"/usr/share/gdm/autostart/LoginWindow
+ mv "$pkgdir"/usr/lib/gtk-3.0 \
+ "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libcanberra-gtk3.so.* \
+ "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/bin/canberra-gtk-play \
+ "$subpkgdir"/usr/bin/
+ mv "$pkgdir"/usr/share/gnome/autostart/libcanberra-login-sound.desktop \
+ "$subpkgdir"/usr/share/gnome/autostart
+ mv "$pkgdir"/usr/share/gnome/shutdown/libcanberra-logout-sound.sh \
+ "$subpkgdir"/usr/share/gnome/autostart/
+ mv "$pkgdir"/usr/share/gdm/autostart/LoginWindow/libcanberra-ready-sound.desktop \
+ "$subpkgdir"/usr/share/gdm/autostart/LoginWindow/
+ mv "$pkgdir"/usr/lib/gnome-settings-daemon-3.0/gtk-modules/canberra-gtk-module.desktop \
+ "$subpkgdir"/usr/lib/gnome-settings-daemon-3.0/gtk-modules/
+}
+
+gstreamer() {
+ pkgdesc="GStreamer backend for libcanberra"
+ install_if="$pkgname=$pkgver-$pkgrel gstreamer"
+ mkdir -p "$subpkgdir"/usr/lib/libcanberra-$pkgver
+ mv "$pkgdir"/usr/lib/libcanberra-$pkgver/libcanberra-gstreamer.so \
+ "$subpkgdir"/usr/lib/libcanberra-$pkgver/
+}
+
+pulse() {
+ pkgdesc="PulseAudio backend for libcanberra"
+ install_if="$pkgname=$pkgver-$pkgrel pulseaudio"
+ mkdir -p "$subpkgdir"/usr/lib/libcanberra-$pkgver
+ mv "$pkgdir"/usr/lib/libcanberra-$pkgver/libcanberra-pulse.so \
+ "$subpkgdir"/usr/lib/libcanberra-$pkgver/
+}
+
+sha512sums="f7543582122256826cd01d0f5673e1e58d979941a93906400182305463d6166855cb51f35c56d807a56dc20b7a64f7ce4391368d24990c1b70782a7d0b4429c2 libcanberra-0.30.tar.xz"
diff --git a/system/libevent/APKBUILD b/system/libevent/APKBUILD
new file mode 100644
index 000000000..d49dfa5e1
--- /dev/null
+++ b/system/libevent/APKBUILD
@@ -0,0 +1,65 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libevent
+pkgver=2.1.8
+pkgrel=3
+pkgdesc="An event notification library"
+url="http://libevent.org/"
+arch="all"
+license="BSD"
+depends=""
+depends_dev="python3"
+makedepends="$depends_dev openssl-dev"
+subpackages="$pkgname-dev"
+source="https://github.com/$pkgname/$pkgname/releases/download/release-${pkgver}-stable/$pkgname-${pkgver}-stable.tar.gz
+ dont-test-fallback.patch
+ fix-test-on-32bit.patch
+ py3_dumpevents.patch
+ py3_rpcgen.patch
+ "
+
+# secfixes:
+# 2.1.8-r0:
+# - CVE-2016-10195
+# - CVE-2016-10196
+# - CVE-2016-10197
+
+builddir="$srcdir"/$pkgname-$pkgver-stable
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --disable-static
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR=$pkgdir install
+}
+
+dev() {
+ replaces="libevent"
+ default_dev
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+sha512sums="a2fd3dd111e73634e4aeb1b29d06e420b15c024d7b47778883b5f8a4ff320b5057a8164c6d50b53bd196c79d572ce2639fe6265e03a93304b09c22b41e4c2a17 libevent-2.1.8-stable.tar.gz
+d059a592252f83a918f0b6237e2dbee1d05822c83372bcd0f658a25428cce109fd088c5dec8320fef4c1aa7a713ada53aae9b7c04d7ca9b039ed4a483ba84146 dont-test-fallback.patch
+7898a00eeab4af7ff3b7c1ee3b90e0d718beba435dfadf015f62084524b2b0f4049c8dd9e16926c61017c01faabf7a51c2f19be7f9532e01278d691acb98465d fix-test-on-32bit.patch
+1f51788db3797870392997d0314fb744ee54d3b1a326d1b67f522fc7af65d50210cb137e8213d35a788bbf3c97aac18cd9860de8af3cb8c82f25e3ae07d662ae py3_dumpevents.patch
+00d0b09425835638a5e29d96d70c855a5c57efb188157b80a3885a2dcbe88709b49ae57aeb6b8b590458a934116cf59934e6e32fbf684b2b3b8333c0dcac837e py3_rpcgen.patch"
diff --git a/system/libevent/dont-test-fallback.patch b/system/libevent/dont-test-fallback.patch
new file mode 100644
index 000000000..42a40094a
--- /dev/null
+++ b/system/libevent/dont-test-fallback.patch
@@ -0,0 +1,16 @@
+The libevent fallback monotonic clock is broken, but it should never be used
+anyway on musl, so disable testing it.
+
+(the brokenness involves gettimeofday, you don't want to know)
+
+--- libevent-2.1.8-stable/test/regress_util.c.old 2017-01-15 03:04:34.000000000 -0600
++++ libevent-2.1.8-stable/test/regress_util.c 2017-09-14 16:25:58.887687965 -0500
+@@ -1482,7 +1482,7 @@
+ { "monotonic_res_fallback", test_evutil_monotonic_res, TT_OFF_BY_DEFAULT, &basic_setup, (void*)"fallback" },
+ { "monotonic_prc", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"" },
+ { "monotonic_prc_precise", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"precise" },
+- { "monotonic_prc_fallback", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"fallback" },
++ /* { "monotonic_prc_fallback", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"fallback" }, */
+ { "date_rfc1123", test_evutil_date_rfc1123, 0, NULL, NULL },
+ END_OF_TESTCASES,
+ };
diff --git a/system/libevent/fix-test-on-32bit.patch b/system/libevent/fix-test-on-32bit.patch
new file mode 100644
index 000000000..ec120a78c
--- /dev/null
+++ b/system/libevent/fix-test-on-32bit.patch
@@ -0,0 +1,11 @@
+--- libevent-2.1.8-stable/test/regress_util.c.old 2018-03-04 21:14:24.344542520 -0600
++++ libevent-2.1.8-stable/test/regress_util.c 2018-03-04 21:24:23.788814572 -0600
+@@ -1411,7 +1411,7 @@
+ { 1255132800, "Sat, 10 Oct 2009 00:00:00 GMT"},
+ { 1289433600, "Thu, 11 Nov 2010 00:00:00 GMT"},
+ { 1323648000, "Mon, 12 Dec 2011 00:00:00 GMT"},
+-#ifndef _WIN32
++#if !defined(_WIN32) && (!defined(__SIZEOF_LONG__) || __SIZEOF_LONG__ > 4)
+ /** In win32 case we have max "23:59:59 January 18, 2038, UTC" for time32 */
+ { 4294967296, "Sun, 07 Feb 2106 06:28:16 GMT"} /* 2^32 */,
+ /** In win32 case we have max "23:59:59, December 31, 3000, UTC" for time64 */
diff --git a/system/libevent/libressl.patch b/system/libevent/libressl.patch
new file mode 100644
index 000000000..21a750c2c
--- /dev/null
+++ b/system/libevent/libressl.patch
@@ -0,0 +1,97 @@
+diff -ru a/openssl-compat.h b/openssl-compat.h
+--- a/openssl-compat.h
++++ b/openssl-compat.h
+@@ -1,7 +1,7 @@
+ #ifndef OPENSSL_COMPAT_H
+ #define OPENSSL_COMPAT_H
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+
+ static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
+ {
+@@ -30,6 +30,6 @@
+
+ #define TLS_method SSLv23_method
+
+-#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
++#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) */
+
+ #endif /* OPENSSL_COMPAT_H */
+diff -ru a/sample/https-client.c b/sample/https-client.c
+--- a/sample/https-client.c
++++ b/sample/https-client.c
+@@ -312,7 +312,7 @@
+ }
+ uri[sizeof(uri) - 1] = '\0';
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ // Initialize OpenSSL
+ SSL_library_init();
+ ERR_load_crypto_strings();
+@@ -480,7 +480,7 @@
+ SSL_CTX_free(ssl_ctx);
+ if (type == HTTP && ssl)
+ SSL_free(ssl);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ EVP_cleanup();
+ ERR_free_strings();
+
+@@ -492,7 +492,7 @@
+ CRYPTO_cleanup_all_ex_data();
+
+ sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
+-#endif /*OPENSSL_VERSION_NUMBER < 0x10100000L */
++#endif /*OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) */
+
+ #ifdef _WIN32
+ WSACleanup();
+diff -ru a/sample/le-proxy.c b/sample/le-proxy.c
+--- a/sample/le-proxy.c
++++ b/sample/le-proxy.c
+@@ -259,7 +259,7 @@
+
+ if (use_ssl) {
+ int r;
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ SSL_library_init();
+ ERR_load_crypto_strings();
+ SSL_load_error_strings();
+diff -ru a/sample/openssl_hostname_validation.c b/sample/openssl_hostname_validation.c
+--- a/sample/openssl_hostname_validation.c
++++ b/sample/openssl_hostname_validation.c
+@@ -48,7 +48,7 @@
+
+ #define HOSTNAME_MAX_SIZE 255
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ #define ASN1_STRING_get0_data ASN1_STRING_data
+ #endif
+
+diff -ru a/test/regress_ssl.c b/test/regress_ssl.c
+--- a/test/regress_ssl.c
++++ b/test/regress_ssl.c
+@@ -186,7 +186,7 @@
+ void
+ init_ssl(void)
+ {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ SSL_library_init();
+ ERR_load_crypto_strings();
+ SSL_load_error_strings();
+@@ -194,6 +194,10 @@
+ if (SSLeay() != OPENSSL_VERSION_NUMBER) {
+ TT_DECLARE("WARN", ("Version mismatch for openssl: compiled with %lx but running with %lx", (unsigned long)OPENSSL_VERSION_NUMBER, (unsigned long) SSLeay()));
+ }
++ if (SSLeay() != LIBRESSL_VERSION_NUMBER) {
++ TT_DECLARE("WARN", ("Version mismatch for libressl: compiled with %lx but running with %lx", (unsigned long)LIBRESSL_VERSION_NUMBER, (unsigned long) SSLeay()));
++ }
++
+ #endif
+ }
+
diff --git a/system/libevent/py3_dumpevents.patch b/system/libevent/py3_dumpevents.patch
new file mode 100644
index 000000000..3c012ef89
--- /dev/null
+++ b/system/libevent/py3_dumpevents.patch
@@ -0,0 +1,30 @@
+--- libevent-2.1.8-stable/test/check-dumpevents.py 2016-10-04 14:55:31.000000000 -0500
++++ libevent-2.1.8-py3-rpcgen/test/check-dumpevents.py 2017-09-14 15:51:16.000000000 -0500
+@@ -15,12 +15,12 @@
+ got_inserted_pos = text.index("Inserted events:\n")
+ got_active_pos = text.index("Active events:\n")
+ except ValueError:
+- print >>sys.stderr, "Missing expected dividing line in dumpevents output"
++ sys.stderr.write("Missing expected dividing line in dumpevents output\n")
+ sys.exit(1)
+
+ if not (expect_inserted_pos < expect_active_pos <
+ got_inserted_pos < got_active_pos):
+- print >>sys.stderr, "Sections out of order in dumpevents output"
++ sys.stderr.write("Sections out of order in dumpevents output\n")
+ sys.exit(1)
+
+ now,T= text[1].split()
+@@ -45,10 +45,10 @@
+ if "Internal" not in s)
+
+ if cleaned_inserted != want_inserted:
+- print >>sys.stderr, "Inserted event lists were not as expected!"
++ sys.stderr.write("Inserted event lists were not as expected!\n")
+ sys.exit(1)
+
+ if set(got_active) != set(want_active):
+- print >>sys.stderr, "Active event lists were not as expected!"
++ sys.stderr.write("Active event lists were not as expected!\n")
+ sys.exit(1)
+
diff --git a/system/libevent/py3_rpcgen.patch b/system/libevent/py3_rpcgen.patch
new file mode 100644
index 000000000..2ebe974a6
--- /dev/null
+++ b/system/libevent/py3_rpcgen.patch
@@ -0,0 +1,423 @@
+--- libevent-2.1.8-stable/event_rpcgen.py 2016-12-06 03:44:11.000000000 -0600
++++ libevent-2.1.8-py3-rpcgen/event_rpcgen.py 2017-09-14 15:17:51.000000000 -0500
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python2
++#!/usr/bin/env python3
+ #
+ # Copyright (c) 2005-2007 Niels Provos <provos@citi.umich.edu>
+ # Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
+@@ -36,10 +36,10 @@
+
+ def declare(s):
+ if not QUIETLY:
+- print s
++ print(s)
+
+ def TranslateList(mylist, mydict):
+- return map(lambda x: x % mydict, mylist)
++ return [x % mydict for x in mylist]
+
+ # Exception class for parse errors
+ class RpcGenError(Exception):
+@@ -57,7 +57,7 @@
+ declare(' Created struct: %s' % name)
+
+ def AddEntry(self, entry):
+- if self._tags.has_key(entry.Tag()):
++ if entry.Tag() in self._tags:
+ raise RpcGenError(
+ 'Entry "%s" duplicates tag number %d from "%s" '
+ 'around line %d' % (entry.Name(), entry.Tag(),
+@@ -78,7 +78,8 @@
+ def PrintIndented(self, file, ident, code):
+ """Takes an array, add indentation to each entry and prints it."""
+ for entry in code:
+- print >>file, '%s%s' % (ident, entry)
++ file.write('{}{}\n'.format(ident, entry))
++ #file.write('%s%s' % (ident, entry))
+
+ class StructCCode(Struct):
+ """ Knows how to generate C code for a struct """
+@@ -88,20 +89,19 @@
+
+ def PrintTags(self, file):
+ """Prints the tag definitions for a structure."""
+- print >>file, '/* Tag definition for %s */' % self._name
+- print >>file, 'enum %s_ {' % self._name.lower()
++ file.write('/* Tag definition for %s */\n' % self._name)
++ file.write('enum %s_ {\n' % self._name.lower())
+ for entry in self._entries:
+- print >>file, ' %s=%d,' % (self.EntryTagName(entry),
+- entry.Tag())
+- print >>file, ' %s_MAX_TAGS' % (self._name.upper())
+- print >>file, '};\n'
++ file.write(' %s=%d,\n' % (self.EntryTagName(entry), entry.Tag()))
++ file.write(' %s_MAX_TAGS\n' % (self._name.upper()))
++ file.write('};\n\n')
+
+ def PrintForwardDeclaration(self, file):
+- print >>file, 'struct %s;' % self._name
++ file.write('struct %s;\n' % self._name)
+
+ def PrintDeclaration(self, file):
+- print >>file, '/* Structure declaration for %s */' % self._name
+- print >>file, 'struct %s_access_ {' % self._name
++ file.write('/* Structure declaration for %s */\n' % self._name)
++ file.write('struct %s_access_ {\n' % self._name)
+ for entry in self._entries:
+ dcl = entry.AssignDeclaration('(*%s_assign)' % entry.Name())
+ dcl.extend(
+@@ -110,20 +110,19 @@
+ dcl.extend(
+ entry.AddDeclaration('(*%s_add)' % entry.Name()))
+ self.PrintIndented(file, ' ', dcl)
+- print >>file, '};\n'
++ file.write('};\n\n')
+
+- print >>file, 'struct %s {' % self._name
+- print >>file, ' struct %s_access_ *base;\n' % self._name
++ file.write('struct %s {\n' % self._name)
++ file.write(' struct %s_access_ *base;\n\n' % self._name)
+ for entry in self._entries:
+ dcl = entry.Declaration()
+ self.PrintIndented(file, ' ', dcl)
+- print >>file, ''
++ file.write('\n')
+ for entry in self._entries:
+- print >>file, ' ev_uint8_t %s_set;' % entry.Name()
+- print >>file, '};\n'
++ file.write(' ev_uint8_t %s_set;\n' % entry.Name())
++ file.write('};\n\n')
+
+- print >>file, \
+-"""struct %(name)s *%(name)s_new(void);
++ file.write("""struct %(name)s *%(name)s_new(void);
+ struct %(name)s *%(name)s_new_with_arg(void *);
+ void %(name)s_free(struct %(name)s *);
+ void %(name)s_clear(struct %(name)s *);
+@@ -133,7 +132,7 @@
+ void evtag_marshal_%(name)s(struct evbuffer *, ev_uint32_t,
+ const struct %(name)s *);
+ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
+- struct %(name)s *);""" % { 'name' : self._name }
++ struct %(name)s *);\n""" % { 'name' : self._name })
+
+
+ # Write a setting function of every variable
+@@ -146,22 +145,21 @@
+ self.PrintIndented(file, '', entry.AddDeclaration(
+ entry.AddFuncName()))
+
+- print >>file, '/* --- %s done --- */\n' % self._name
++ file.write('/* --- %s done --- */\n\n' % self._name)
+
+ def PrintCode(self, file):
+- print >>file, ('/*\n'
++ file.write(('/*\n'
+ ' * Implementation of %s\n'
+- ' */\n') % self._name
++ ' */\n\n') % self._name)
+
+- print >>file, \
+- 'static struct %(name)s_access_ %(name)s_base__ = {' % \
+- { 'name' : self._name }
++ file.write('static struct %(name)s_access_ %(name)s_base__ = {\n' % \
++ { 'name' : self._name })
+ for entry in self._entries:
+ self.PrintIndented(file, ' ', entry.CodeBase())
+- print >>file, '};\n'
++ file.write('};\n\n')
+
+ # Creation
+- print >>file, (
++ file.write((
+ 'struct %(name)s *\n'
+ '%(name)s_new(void)\n'
+ '{\n'
+@@ -176,77 +174,77 @@
+ ' event_warn("%%s: malloc", __func__);\n'
+ ' return (NULL);\n'
+ ' }\n'
+- ' tmp->base = &%(name)s_base__;\n') % { 'name' : self._name }
++ ' tmp->base = &%(name)s_base__;\n\n') % { 'name' : self._name })
+
+ for entry in self._entries:
+ self.PrintIndented(file, ' ', entry.CodeInitialize('tmp'))
+- print >>file, ' tmp->%s_set = 0;\n' % entry.Name()
++ file.write(' tmp->%s_set = 0;\n\n' % entry.Name())
+
+- print >>file, (
++ file.write((
+ ' return (tmp);\n'
+- '}\n')
++ '}\n\n'))
+
+ # Adding
+ for entry in self._entries:
+ if entry.Array():
+ self.PrintIndented(file, '', entry.CodeAdd())
+- print >>file, ''
++ file.write('\n')
+
+ # Assigning
+ for entry in self._entries:
+ self.PrintIndented(file, '', entry.CodeAssign())
+- print >>file, ''
++ file.write('\n')
+
+ # Getting
+ for entry in self._entries:
+ self.PrintIndented(file, '', entry.CodeGet())
+- print >>file, ''
++ file.write('\n')
+
+ # Clearing
+- print >>file, ( 'void\n'
++ file.write(( 'void\n'
+ '%(name)s_clear(struct %(name)s *tmp)\n'
+ '{'
+- ) % { 'name' : self._name }
++ '\n') % { 'name' : self._name })
+ for entry in self._entries:
+ self.PrintIndented(file, ' ', entry.CodeClear('tmp'))
+
+- print >>file, '}\n'
++ file.write('}\n\n')
+
+ # Freeing
+- print >>file, ( 'void\n'
++ file.write(( 'void\n'
+ '%(name)s_free(struct %(name)s *tmp)\n'
+ '{'
+- ) % { 'name' : self._name }
++ '\n') % { 'name' : self._name })
+
+ for entry in self._entries:
+ self.PrintIndented(file, ' ', entry.CodeFree('tmp'))
+
+- print >>file, (' free(tmp);\n'
+- '}\n')
++ file.write((' free(tmp);\n'
++ '}\n\n'))
+
+ # Marshaling
+- print >>file, ('void\n'
++ file.write(('void\n'
+ '%(name)s_marshal(struct evbuffer *evbuf, '
+ 'const struct %(name)s *tmp)'
+- '{') % { 'name' : self._name }
++ '{\n') % { 'name' : self._name })
+ for entry in self._entries:
+ indent = ' '
+ # Optional entries do not have to be set
+ if entry.Optional():
+ indent += ' '
+- print >>file, ' if (tmp->%s_set) {' % entry.Name()
++ file.write(' if (tmp->%s_set) {\n' % entry.Name())
+ self.PrintIndented(
+ file, indent,
+ entry.CodeMarshal('evbuf', self.EntryTagName(entry),
+ entry.GetVarName('tmp'),
+ entry.GetVarLen('tmp')))
+ if entry.Optional():
+- print >>file, ' }'
++ file.write(' }\n')
+
+- print >>file, '}\n'
++ file.write('}\n\n')
+
+ # Unmarshaling
+- print >>file, ('int\n'
++ file.write(('int\n'
+ '%(name)s_unmarshal(struct %(name)s *tmp, '
+ ' struct evbuffer *evbuf)\n'
+ '{\n'
+@@ -255,14 +253,14 @@
+ ' if (evtag_peek(evbuf, &tag) == -1)\n'
+ ' return (-1);\n'
+ ' switch (tag) {\n'
+- ) % { 'name' : self._name }
++ '\n') % { 'name' : self._name })
+ for entry in self._entries:
+- print >>file, ' case %s:\n' % self.EntryTagName(entry)
++ file.write(' case %s:\n' % self.EntryTagName(entry))
+ if not entry.Array():
+- print >>file, (
++ file.write((
+ ' if (tmp->%s_set)\n'
+ ' return (-1);'
+- ) % (entry.Name())
++ '\n') % (entry.Name()))
+
+ self.PrintIndented(
+ file, ' ',
+@@ -271,26 +269,26 @@
+ entry.GetVarName('tmp'),
+ entry.GetVarLen('tmp')))
+
+- print >>file, ( ' tmp->%s_set = 1;\n' % entry.Name() +
+- ' break;\n' )
+- print >>file, ( ' default:\n'
++ file.write(( ' tmp->%s_set = 1;\n' % entry.Name() +
++ ' break;\n' ))
++ file.write(( ' default:\n'
+ ' return -1;\n'
+ ' }\n'
+- ' }\n' )
++ ' }\n\n' ))
+ # Check if it was decoded completely
+- print >>file, ( ' if (%(name)s_complete(tmp) == -1)\n'
++ file.write(( ' if (%(name)s_complete(tmp) == -1)\n'
+ ' return (-1);'
+- ) % { 'name' : self._name }
++ '\n') % { 'name' : self._name })
+
+ # Successfully decoded
+- print >>file, ( ' return (0);\n'
+- '}\n')
++ file.write(( ' return (0);\n'
++ '}\n\n'))
+
+ # Checking if a structure has all the required data
+- print >>file, (
++ file.write((
+ 'int\n'
+ '%(name)s_complete(struct %(name)s *msg)\n'
+- '{' ) % { 'name' : self._name }
++ '{\n' ) % { 'name' : self._name })
+ for entry in self._entries:
+ if not entry.Optional():
+ code = [
+@@ -303,12 +301,12 @@
+ self.PrintIndented(
+ file, ' ',
+ entry.CodeComplete('msg', entry.GetVarName('msg')))
+- print >>file, (
++ file.write((
+ ' return (0);\n'
+- '}\n' )
++ '}\n\n' ))
+
+ # Complete message unmarshaling
+- print >>file, (
++ file.write((
+ 'int\n'
+ 'evtag_unmarshal_%(name)s(struct evbuffer *evbuf, '
+ 'ev_uint32_t need_tag, struct %(name)s *msg)\n'
+@@ -330,10 +328,10 @@
+ ' error:\n'
+ ' evbuffer_free(tmp);\n'
+ ' return (res);\n'
+- '}\n' ) % { 'name' : self._name }
++ '}\n\n' ) % { 'name' : self._name })
+
+ # Complete message marshaling
+- print >>file, (
++ file.write((
+ 'void\n'
+ 'evtag_marshal_%(name)s(struct evbuffer *evbuf, ev_uint32_t tag, '
+ 'const struct %(name)s *msg)\n'
+@@ -343,7 +341,7 @@
+ ' %(name)s_marshal(buf_, msg);\n'
+ ' evtag_marshal_buffer(evbuf, tag, buf_);\n '
+ ' evbuffer_free(buf_);\n'
+- '}\n' ) % { 'name' : self._name }
++ '}\n\n' ) % { 'name' : self._name })
+
+ class Entry:
+ def __init__(self, type, name, tag):
+@@ -420,7 +418,7 @@
+ "optaddarg" :
+ self._optaddarg and ", const %s value" % self._ctype or ""
+ }
+- for (k, v) in extradict.items():
++ for (k, v) in list(extradict.items()):
+ mapping[k] = v
+
+ return mapping
+@@ -1127,7 +1125,7 @@
+
+ codearrayassign = self._entry.CodeArrayAssign(
+ 'msg->%(name)s_data[off]' % self.GetTranslation(), 'value')
+- code += map(lambda x: ' ' + x, codearrayassign)
++ code += [' ' + x for x in codearrayassign]
+
+ code += TranslateList([
+ ' }',
+@@ -1168,7 +1166,7 @@
+
+ code = TranslateList(code, self.GetTranslation())
+
+- code += map(lambda x: ' ' + x, codearrayadd)
++ code += [' ' + x for x in codearrayadd]
+
+ code += TranslateList([
+ ' msg->%(name)s_set = 1;',
+@@ -1196,7 +1194,7 @@
+
+ code = TranslateList(code, translate)
+
+- code += map(lambda x: ' ' + x, tmp)
++ code += [' ' + x for x in tmp]
+
+ code += [
+ ' }',
+@@ -1261,7 +1259,7 @@
+ code = TranslateList(code, translate)
+
+ if codearrayfree:
+- code += map(lambda x: ' ' + x, codearrayfree)
++ code += [' ' + x for x in codearrayfree]
+ code += [
+ ' }' ]
+
+@@ -1687,23 +1685,23 @@
+
+ declare('... creating "%s"' % header_file)
+ header_fp = open(header_file, 'w')
+- print >>header_fp, factory.HeaderPreamble(filename)
++ header_fp.write(factory.HeaderPreamble(filename))
+
+ # Create forward declarations: allows other structs to reference
+ # each other
+ for entry in entities:
+ entry.PrintForwardDeclaration(header_fp)
+- print >>header_fp, ''
++ header_fp.write('\n')
+
+ for entry in entities:
+ entry.PrintTags(header_fp)
+ entry.PrintDeclaration(header_fp)
+- print >>header_fp, factory.HeaderPostamble(filename)
++ header_fp.write(factory.HeaderPostamble(filename))
+ header_fp.close()
+
+ declare('... creating "%s"' % impl_file)
+ impl_fp = open(impl_file, 'w')
+- print >>impl_fp, factory.BodyPreamble(filename, header_file)
++ impl_fp.write(factory.BodyPreamble(filename, header_file))
+ for entry in entities:
+ entry.PrintCode(impl_fp)
+ impl_fp.close()
+@@ -1713,16 +1711,16 @@
+ CommandLine(sys.argv).run()
+ sys.exit(0)
+
+- except RpcGenError, e:
+- print >>sys.stderr, e
++ except RpcGenError as e:
++ sys.stderr.write(e)
+ sys.exit(1)
+
+- except EnvironmentError, e:
++ except EnvironmentError as e:
+ if e.filename and e.strerror:
+- print >>sys.stderr, "%s: %s" % (e.filename, e.strerror)
++ sys.stderr.write("%s: %s" % (e.filename, e.strerror))
+ sys.exit(1)
+ elif e.strerror:
+- print >> sys.stderr, e.strerror
++ sys.stderr.write(e.strerror)
+ sys.exit(1)
+ else:
+ raise
diff --git a/system/libexecinfo/10-execinfo.patch b/system/libexecinfo/10-execinfo.patch
new file mode 100644
index 000000000..97bd8cd5d
--- /dev/null
+++ b/system/libexecinfo/10-execinfo.patch
@@ -0,0 +1,64 @@
+--- a/execinfo.c
++++ b/execinfo.c
+@@ -69,7 +69,8 @@
+ char **
+ backtrace_symbols(void *const *buffer, int size)
+ {
+- int i, clen, alen, offset;
++ size_t clen, alen;
++ int i, offset;
+ char **rval;
+ char *cp;
+ Dl_info info;
+@@ -78,7 +79,6 @@
+ rval = malloc(clen);
+ if (rval == NULL)
+ return NULL;
+- (char **)cp = &(rval[size]);
+ for (i = 0; i < size; i++) {
+ if (dladdr(buffer[i], &info) != 0) {
+ if (info.dli_sname == NULL)
+@@ -92,14 +92,14 @@
+ 2 + /* " <" */
+ strlen(info.dli_sname) + /* "function" */
+ 1 + /* "+" */
+- D10(offset) + /* "offset */
++ 10 + /* "offset */
+ 5 + /* "> at " */
+ strlen(info.dli_fname) + /* "filename" */
+ 1; /* "\0" */
+ rval = realloc_safe(rval, clen + alen);
+ if (rval == NULL)
+ return NULL;
+- snprintf(cp, alen, "%p <%s+%d> at %s",
++ snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s",
+ buffer[i], info.dli_sname, offset, info.dli_fname);
+ } else {
+ alen = 2 + /* "0x" */
+@@ -108,12 +108,15 @@
+ rval = realloc_safe(rval, clen + alen);
+ if (rval == NULL)
+ return NULL;
+- snprintf(cp, alen, "%p", buffer[i]);
++ snprintf((char *) rval + clen, alen, "%p", buffer[i]);
+ }
+- rval[i] = cp;
+- cp += alen;
++ rval[i] = (char *) clen;
++ clen += alen;
+ }
+
++ for (i = 0; i < size; i++)
++ rval[i] += (long) rval;
++
+ return rval;
+ }
+
+@@ -155,6 +158,6 @@
+ return;
+ snprintf(buf, len, "%p\n", buffer[i]);
+ }
+- write(fd, buf, len - 1);
++ write(fd, buf, strlen(buf));
+ }
+ }
diff --git a/system/libexecinfo/20-define-gnu-source.patch b/system/libexecinfo/20-define-gnu-source.patch
new file mode 100644
index 000000000..ac18f6eeb
--- /dev/null
+++ b/system/libexecinfo/20-define-gnu-source.patch
@@ -0,0 +1,24 @@
+--- a/execinfo.c
++++ b/execinfo.c
+@@ -26,6 +26,7 @@
+ * $Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $
+ */
+
++#define _GNU_SOURCE
+ #include <sys/types.h>
+ #include <sys/uio.h>
+ #include <dlfcn.h>
+--- a/stacktraverse.c
++++ b/stacktraverse.c
+@@ -1,3 +1,4 @@
++#define _GNU_SOURCE
+ #include <stddef.h>
+
+ #include "stacktraverse.h"
+--- a/test.c
++++ b/test.c
+@@ -1,3 +1,4 @@
++#define _GNU_SOURCE
+ #include <stdio.h>
+ #include <stdlib.h>
+
diff --git a/system/libexecinfo/30-linux-makefile.patch b/system/libexecinfo/30-linux-makefile.patch
new file mode 100644
index 000000000..f832adce7
--- /dev/null
+++ b/system/libexecinfo/30-linux-makefile.patch
@@ -0,0 +1,44 @@
+--- a/Makefile
++++ b/Makefile
+@@ -23,24 +23,25 @@
+ # SUCH DAMAGE.
+ #
+ # $Id: Makefile,v 1.3 2004/07/19 05:19:55 sobomax Exp $
++#
++# Linux Makefile by Matt Smith <mcs@darkregion.net>, 2011/01/04
+
+-LIB= execinfo
++CC=cc
++AR=ar
++EXECINFO_CFLAGS=$(CFLAGS) -O2 -pipe -fno-strict-aliasing -std=gnu99 -fstack-protector -c
++EXECINFO_LDFLAGS=$(LDFLAGS)
+
+-SRCS= stacktraverse.c stacktraverse.h execinfo.c execinfo.h
++all: static dynamic
+
+-INCS= execinfo.h
++static:
++ $(CC) $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) stacktraverse.c
++ $(CC) $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) execinfo.c
++ $(AR) rcs libexecinfo.a stacktraverse.o execinfo.o
+
+-SHLIB_MAJOR= 1
+-SHLIB_MINOR= 0
++dynamic:
++ $(CC) -fpic -DPIC $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) stacktraverse.c -o stacktraverse.So
++ $(CC) -fpic -DPIC $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) execinfo.c -o execinfo.So
++ $(CC) -shared -Wl,-soname,libexecinfo.so.1 -o libexecinfo.so.1 stacktraverse.So execinfo.So
+
+-NOPROFILE= yes
+-
+-DPADD= ${LIBM}
+-LDADD= -lm
+-
+-#WARNS?= 4
+-
+-#stacktraverse.c: gen.py
+-# ./gen.py > stacktraverse.c
+-
+-.include <bsd.lib.mk>
++clean:
++ rm -rf *.o *.So *.a *.so
diff --git a/system/libexecinfo/APKBUILD b/system/libexecinfo/APKBUILD
new file mode 100644
index 000000000..bdc921c11
--- /dev/null
+++ b/system/libexecinfo/APKBUILD
@@ -0,0 +1,46 @@
+# Contributor: Philipp Andronov <filipp.andronov@gmail.com>
+# Maintainer: Matt Smith <mcs@darkregion.net>
+
+pkgname=libexecinfo
+pkgver=1.1
+pkgrel=1
+pkgdesc="Experimental BSD clone of the GNU libc backtrace facility"
+url="https://www.freshports.org/devel/libexecinfo"
+arch="all"
+license="BSD-2-Clause"
+options="!check" # Test file would require manual inspection of output.
+depends=
+makedepends=
+install=
+subpackages="${pkgname}-dev"
+source="http://distcache.freebsd.org/local-distfiles/itetcu/$pkgname-$pkgver.tar.bz2
+ 10-execinfo.patch
+ 20-define-gnu-source.patch
+ 30-linux-makefile.patch
+ "
+
+build() {
+ cd "$builddir"
+ export CFLAGS="${CFLAGS} -fno-omit-frame-pointer"
+ make
+}
+
+package() {
+ cd "$builddir"
+
+ install -D -m755 "$builddir"/execinfo.h \
+ "$pkgdir"/usr/include/execinfo.h
+ install -D -m755 "$builddir"/stacktraverse.h \
+ "$pkgdir"/usr/include/stacktraverse.h
+ install -D -m755 "$builddir"/libexecinfo.a \
+ "$pkgdir"/usr/lib/libexecinfo.a
+ install -D -m755 "$builddir"/libexecinfo.so.1 \
+ "$pkgdir"/usr/lib/libexecinfo.so.1
+ ln -s /usr/lib/libexecinfo.so.1 \
+ "$pkgdir"/usr/lib/libexecinfo.so
+}
+
+sha512sums="51fea7910ef6873061a25c22434ce4da724e9d8e37616a069ad0a58c0463755be4c6c7da88cd747484c2f3373909d7be4678b32a4bd91b6d9e0f74526094e92c libexecinfo-1.1.tar.bz2
+97dab43979f6bc07deb11b20cc134c7d95619536b108058388856bcc48dc5a7de4ebceebe88e79d92ccbb9307975bb91a630cc569a5ed35a37a0f92f2d7f83d0 10-execinfo.patch
+6b1d5ba0a2765fcbcde2d88e85c6ee9fb49ef1878284fd7da15afebed17b8415959233c735574661b0a5e77d4d40c132552477dbbf4432512a32629727ebdbbc 20-define-gnu-source.patch
+7d83e3113b93ed9d54a2077d6b9381aa69c6a5d2066dd3cd7c5ec3ce0c93eb7b86fd47481151117f9c8f3790bde6125498a49e32e81d3ff6630b6d8e0ec391d0 30-linux-makefile.patch"
diff --git a/system/libffi/APKBUILD b/system/libffi/APKBUILD
new file mode 100644
index 000000000..4f4923b38
--- /dev/null
+++ b/system/libffi/APKBUILD
@@ -0,0 +1,57 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libffi
+pkgver=3.2.1
+pkgrel=4
+pkgdesc="A portable, high level programming interface to various calling conventions."
+url="http://sourceware.org/libffi"
+arch="all"
+license="MIT"
+depends=
+makedepends="texinfo"
+checkdepends="dejagnu"
+install=
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://sourceware.org/pub/$pkgname/$pkgname-$pkgver.tar.gz
+ disable-ppc-ldvariant.patch
+ fix-testsuite-longdouble.patch
+ gnu-linux-define.patch
+ pax-dlmmap.patch
+ "
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+build () {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --enable-pax_emutramp
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR=""$pkgdir"" install
+ install -m755 -d ""$pkgdir"/usr/share/licenses/$pkgname"
+ install -m644 LICENSE ""$pkgdir"/usr/share/licenses/$pkgname/"
+ # fix location for headers
+ # see also: https://github.com/libffi/libffi/issues/24
+ mkdir -p "$pkgdir"/usr/include/
+ mv "$pkgdir"/usr/lib/libffi-$pkgver/include/*.h \
+ "$pkgdir"/usr/include/
+ rmdir "$pkgdir"/usr/lib/libffi-$pkgver/include || true
+ sed -i -e '/^includedir=/{s,=.*,=/usr/include,g}' \
+ "$pkgdir"/usr/lib/pkgconfig/libffi.pc
+}
+
+sha512sums="980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483 libffi-3.2.1.tar.gz
+cfd3b11a0e168fd74da0a6219c95610df3466b0769966351b2a5076c93a75996daf9aed41644bebb80e28793bbe18d62272385afd7813c472104cc6c93dcba41 disable-ppc-ldvariant.patch
+de92cb20ded7bfefc3e469ba2ac2d9d869d67dc172ec7e2d1222f8530944eb6d5016ae913baf01ac2e26bee1624c682ae9dd08d0e45d5532d59298dbe7e417eb fix-testsuite-longdouble.patch
+264af568ae5388d50f647f891a406945c73cc358692266f65ad341787c0bf5f6bf31203b86c39fa1b338101c1a6d2f4fec60f95a90d379951ff5153f8f9e178f gnu-linux-define.patch
+72486b389db16055ae4d7d33ba0cb05840537e28fe7a86aa89e2cb922592125d99c18c26c5df7ffde6282742e79f2b9126353e58b58f091f0486589e14dd6474 pax-dlmmap.patch"
diff --git a/system/libffi/disable-ppc-ldvariant.patch b/system/libffi/disable-ppc-ldvariant.patch
new file mode 100644
index 000000000..8b3f9cea0
--- /dev/null
+++ b/system/libffi/disable-ppc-ldvariant.patch
@@ -0,0 +1,11 @@
+--- libffi-3.2.1/configure.old 2014-11-12 06:59:57.000000000 -0500
++++ libffi-3.2.1/configure 2017-10-10 05:44:12.732989967 -0400
+@@ -17237,7 +17237,7 @@
+
+ powerpc*-*-linux* | powerpc-*-sysv*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+- HAVE_LONG_DOUBLE_VARIANT=1
++ #HAVE_LONG_DOUBLE_VARIANT=1
+ ;;
+ powerpc-*-amigaos*)
+ TARGET=POWERPC; TARGETDIR=powerpc
diff --git a/system/libffi/fix-testsuite-longdouble.patch b/system/libffi/fix-testsuite-longdouble.patch
new file mode 100644
index 000000000..20fe4b8c6
--- /dev/null
+++ b/system/libffi/fix-testsuite-longdouble.patch
@@ -0,0 +1,44 @@
+--- libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c 2017-10-10 06:04:26.293045176 -0400
+@@ -6,7 +6,7 @@
+
+ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+ #include "ffitest.h"
+--- libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c 2017-10-10 06:04:54.283046103 -0400
+@@ -7,7 +7,7 @@
+
+ /* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+ /* { dg-do run { xfail strongarm*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+ #include "ffitest.h"
+--- libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c 2017-10-10 06:05:19.683046965 -0400
+@@ -8,7 +8,7 @@
+ /* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have
+ remove the xfail for arm*-*-* below, until we know more. */
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+ #include "ffitest.h"
+--- libffi-3.2.1/testsuite/libffi.call/huge_struct.c.old 2014-11-08 07:47:24.000000000 -0500
++++ libffi-3.2.1/testsuite/libffi.call/huge_struct.c 2017-10-10 06:05:39.383047674 -0400
+@@ -7,7 +7,7 @@
+
+ /* { dg-excess-errors "" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
+ /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+-/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
++/* { dg-options -mlong-double-64 { target powerpc64*-*-linux* } } */
+ /* { dg-options -Wformat=0 { target moxie*-*-elf } } */
+ /* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
diff --git a/system/libffi/gnu-linux-define.patch b/system/libffi/gnu-linux-define.patch
new file mode 100644
index 000000000..8dcae738b
--- /dev/null
+++ b/system/libffi/gnu-linux-define.patch
@@ -0,0 +1,15 @@
+http://bugs.alpinelinux.org/issues/4275
+
+diff --git a/closures.c.orig b/closures.c
+index 721ff00..22a699c 100644
+--- a/src/closures.c.orig
++++ b/src/closures.c
+@@ -34,7 +34,7 @@
+ #include <ffi_common.h>
+
+ #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
+-# if __gnu_linux__ && !defined(__ANDROID__)
++# if __linux__ && !defined(__ANDROID__)
+ /* This macro indicates it may be forbidden to map anonymous memory
+ with both write and execute permission. Code compiled when this
+ option is defined will attempt to map such pages once, but if it
diff --git a/system/libffi/pax-dlmmap.patch b/system/libffi/pax-dlmmap.patch
new file mode 100644
index 000000000..ec4150410
--- /dev/null
+++ b/system/libffi/pax-dlmmap.patch
@@ -0,0 +1,120 @@
+From 48d2e46528fb6e621d95a7fa194069fd136b712d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20B=C3=BChler?= <buehler@cert.uni-stuttgart.de>
+Date: Wed, 7 Sep 2016 15:49:48 +0200
+Subject: [PATCH 1/2] dlmmap_locked always needs locking as it always modifies
+ execsize
+
+---
+ src/closures.c | 13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+diff --git a/src/closures.c b/src/closures.c
+index 2e0ffb45..04d6e27f 100644
+--- a/src/closures.c
++++ b/src/closures.c
+@@ -769,16 +769,11 @@ dlmmap (void *start, size_t length, int prot,
+ MREMAP_DUP and prot at this point. */
+ }
+
+- if (execsize == 0 || execfd == -1)
+- {
+- pthread_mutex_lock (&open_temp_exec_file_mutex);
+- ptr = dlmmap_locked (start, length, prot, flags, offset);
+- pthread_mutex_unlock (&open_temp_exec_file_mutex);
++ pthread_mutex_lock (&open_temp_exec_file_mutex);
++ ptr = dlmmap_locked (start, length, prot, flags, offset);
++ pthread_mutex_unlock (&open_temp_exec_file_mutex);
+
+- return ptr;
+- }
+-
+- return dlmmap_locked (start, length, prot, flags, offset);
++ return ptr;
+ }
+
+ /* Release memory at the given address, as well as the corresponding
+
+From 7aad5f895e2dfdb79d2ef67e1b231d21063e6511 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20B=C3=BChler?= <buehler@cert.uni-stuttgart.de>
+Date: Wed, 7 Sep 2016 15:50:54 +0200
+Subject: [PATCH 2/2] ignore PaX EMUTRAMP flag; instead check for MPROTECT
+
+- code using ffi_closure_alloc doesn't necessarily generate gcc compatible trampolines; only those are allowed by PaX
+- if MPROTECT is enabled use the same workaround as is used for SELinux (double mmap())
+---
+ src/closures.c | 29 +++++++++++++----------------
+ 1 file changed, 13 insertions(+), 16 deletions(-)
+
+diff --git a/src/closures.c b/src/closures.c
+index 04d6e27f..babecc1a 100644
+--- a/src/closures.c
++++ b/src/closures.c
+@@ -401,14 +401,15 @@ selinux_enabled_check (void)
+
+ #endif /* !FFI_MMAP_EXEC_SELINUX */
+
+-/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
++/* On PaX enable kernels that have MPROTECT enabled we can't use PROT_EXEC. */
+ #ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
+ #include <stdlib.h>
+
+-static int emutramp_enabled = -1;
++/* -1: not read yet; 0: no PaX or MPROTECT disabled; 1: MPROTECT enabled. */
++static int mprotect_enabled = -1;
+
+ static int
+-emutramp_enabled_check (void)
++mprotect_enabled_check (void)
+ {
+ char *buf = NULL;
+ size_t len = 0;
+@@ -422,9 +423,7 @@ emutramp_enabled_check (void)
+ while (getline (&buf, &len, f) != -1)
+ if (!strncmp (buf, "PaX:", 4))
+ {
+- char emutramp;
+- if (sscanf (buf, "%*s %*c%c", &emutramp) == 1)
+- ret = (emutramp == 'E');
++ ret = (NULL != strchr (buf + 4, 'M'));
+ break;
+ }
+ free (buf);
+@@ -432,8 +431,9 @@ emutramp_enabled_check (void)
+ return ret;
+ }
+
+-#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
+- : (emutramp_enabled = emutramp_enabled_check ()))
++#define is_mprotect_enabled() (mprotect_enabled >= 0 ? mprotect_enabled \
++ : (mprotect_enabled = mprotect_enabled_check ()))
++
+ #endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
+ #elif defined (__CYGWIN__) || defined(__INTERIX)
+@@ -446,7 +446,7 @@ emutramp_enabled_check (void)
+ #endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
+
+ #ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
+-#define is_emutramp_enabled() 0
++#define is_mprotect_enabled() 0
+ #endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
+ /* Declare all functions defined in dlmalloc.c as static. */
+@@ -750,13 +750,10 @@ dlmmap (void *start, size_t length, int prot,
+ && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
+ && fd == -1 && offset == 0);
+
+- if (execfd == -1 && is_emutramp_enabled ())
+- {
+- ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
+- return ptr;
+- }
+-
+- if (execfd == -1 && !is_selinux_enabled ())
++ /* -1 != execfd hints that we already decided to use dlmmap_locked
++ last time. If PaX MPROTECT or SELinux is active fallback to
++ dlmmap_locked. */
++ if (execfd == -1 && !is_mprotect_enabled () && !is_selinux_enabled ())
+ {
+ ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
+
diff --git a/system/libgit2/APKBUILD b/system/libgit2/APKBUILD
new file mode 100644
index 000000000..e7e4bbfad
--- /dev/null
+++ b/system/libgit2/APKBUILD
@@ -0,0 +1,52 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Contributor: Pierre-Gilas MILLON <pgmillon@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libgit2
+pkgver=0.26.0
+pkgrel=0
+pkgdesc="A linkable library for Git"
+url="https://libgit2.github.com/"
+arch="all"
+license="GPL-2.0"
+depends=""
+depends_dev="curl-dev libssh2-dev"
+makedepends="$depends_dev python3 cmake zlib-dev openssl-dev"
+subpackages="$pkgname-dev"
+source="$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz
+ build-both-static-dynamic.patch
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+
+# secfixes:
+# 0.25.1-r0:
+# - CVE-2016-10128
+# - CVE-2016-10129
+# - CVE-2016-10130
+# 0.24.3-r0:
+# - CVE-2016-8568
+# - CVE-2016-8569
+
+build() {
+ cd "$builddir"
+ cmake \
+ -DCMAKE_BUILD_TYPE=RelWithDebugInfo \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
+ -DCMAKE_C_FLAGS="$CFLAGS"
+ make
+}
+
+check() {
+ cd "$builddir"
+ CTEST_OUTPUT_ON_FAILURE=TRUE ctest
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="b6e51f2216c7c23f352572b780ea1325a25a517396709f036bb573295c2bd02aa505ba616846ac7e07863e99e640e7d47fefc5727478a257b283da99060ee47c libgit2-0.26.0.tar.gz
+39534d10f38f394446f93df810233464807fca3b0e903ee40067971ecbe1d78102bbe04283435032f757f970e6846ecf279eb727ab137c01e84427bd16913ee6 build-both-static-dynamic.patch"
diff --git a/system/libgit2/build-both-static-dynamic.patch b/system/libgit2/build-both-static-dynamic.patch
new file mode 100644
index 000000000..eeb179a1e
--- /dev/null
+++ b/system/libgit2/build-both-static-dynamic.patch
@@ -0,0 +1,53 @@
+From: Jakub Jirutka <jakub@jirutka.cz>
+Date: Mon, 11 Apr 2017 3:23:00 +0200
+Subject: [PATCH] Build both static and dynamic library
+
+This is very hack-ish, it makes option BUILD_SHARED_LIBS unusable.
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -28,7 +28,6 @@
+ # Build options
+ #
+ OPTION( SONAME "Set the (SO)VERSION of the target" ON )
+-OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON )
+ OPTION( THREADSAFE "Build libgit2 as threadsafe" ON )
+ OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON )
+ OPTION( BUILD_EXAMPLES "Build library usage example apps" OFF )
+@@ -44,6 +43,8 @@
+ OPTION( CURL "Use curl for HTTP if available" ON)
+ OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
+
++SET( BUILD_SHARED_LIBS ON )
++
+ IF(DEBUG_POOL)
+ ADD_DEFINITIONS(-DGIT_DEBUG_POOL)
+ ENDIF()
+@@ -602,7 +603,8 @@
+ ENDIF()
+
+ # Compile and link libgit2
+-ADD_LIBRARY(git2 ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1} ${WIN_RC})
++ADD_LIBRARY(objlib OBJECT ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SSH} ${SRC_SHA1} ${WIN_RC})
++ADD_LIBRARY(git2 SHARED $<TARGET_OBJECTS:objlib>)
+ TARGET_LINK_LIBRARIES(git2 ${SECURITY_DIRS})
+ TARGET_LINK_LIBRARIES(git2 ${COREFOUNDATION_DIRS})
+ TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
+@@ -611,6 +613,9 @@
+ TARGET_LINK_LIBRARIES(git2 ${ICONV_LIBRARIES})
+ TARGET_OS_LIBRARIES(git2)
+
++ADD_LIBRARY(git2_static STATIC $<TARGET_OBJECTS:objlib>)
++SET_TARGET_PROPERTIES(git2_static PROPERTIES OUTPUT_NAME git2 CLEAN_DIRECT_OUTPUT 1)
++
+ # Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
+ # Win64+MSVC+static libs = linker error
+ IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
+@@ -639,7 +644,7 @@
+ ENDIF ()
+
+ # Install
+-INSTALL(TARGETS git2
++INSTALL(TARGETS git2 git2_static
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
diff --git a/system/libgit2/libressl.patch b/system/libgit2/libressl.patch
new file mode 100644
index 000000000..967cdc498
--- /dev/null
+++ b/system/libgit2/libressl.patch
@@ -0,0 +1,12 @@
+diff -ru src.orig/libgit2-0.25.1/src/openssl_stream.h src/libgit2-0.25.1/src/openssl_stream.h
+--- libgit2-0.25.1/src/copenssl_stream.h.orig
++++ libgit2-0.25.1/src/openssl_stream.h
+@@ -27,7 +27,7 @@
+
+
+
+-# if OPENSSL_VERSION_NUMBER < 0x10100000L
++# if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+
+ GIT_INLINE(BIO_METHOD*) BIO_meth_new(int type, const char *name)
+ {
diff --git a/system/libgit2/pkgconfig-do-not-quote-Libs.patch b/system/libgit2/pkgconfig-do-not-quote-Libs.patch
new file mode 100644
index 000000000..86133612e
--- /dev/null
+++ b/system/libgit2/pkgconfig-do-not-quote-Libs.patch
@@ -0,0 +1,26 @@
+From 452ba68cde25423d13ebb36f0a54559f07aa53a2 Mon Sep 17 00:00:00 2001
+From: Igor Gnatenko <ignatenko@redhat.com>
+Date: Tue, 7 Feb 2017 16:37:47 +0100
+Subject: [PATCH] pkgconfig: do not quote Libs
+
+It doesn't make sense at all.
+---
+ libgit2.pc.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libgit2.pc.in b/libgit2.pc.in
+index 329a560a7..880266a30 100644
+--- a/libgit2.pc.in
++++ b/libgit2.pc.in
+@@ -6,7 +6,7 @@ Name: libgit2
+ Description: The git library, take 2
+ Version: @LIBGIT2_VERSION_STRING@
+
+-Libs: -L"${libdir}" -lgit2
++Libs: -L${libdir} -lgit2
+ Libs.private: @LIBGIT2_PC_LIBS@
+ Requires.private: @LIBGIT2_PC_REQUIRES@
+
+--
+2.11.0
+
diff --git a/system/libnih/APKBUILD b/system/libnih/APKBUILD
new file mode 100644
index 000000000..f12895d65
--- /dev/null
+++ b/system/libnih/APKBUILD
@@ -0,0 +1,57 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: William Pitcock <nenolod@dereferenced.org>
+pkgname=libnih
+pkgver=1.0.3
+pkgrel=5
+pkgdesc="glib-like library for embedded use"
+url="http://launchpad.net/libnih"
+arch="all"
+license="LGPL"
+options="!checkroot"
+depends=
+depends_dev="dbus-dev expat-dev"
+makedepends="$depends_dev gettext-dev"
+checkdepends="dbus-x11 linux-headers"
+install=""
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://launchpad.net/libnih/${pkgver%.*}/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz
+ musl-fix-signals.patch
+ disable-broken-test.patch
+ musl-enomem-message.patch
+ parse-test-fix.patch
+ "
+
+builddir="${srcdir}/${pkgname}-${pkgver}"
+prepare() {
+ cd "$builddir"
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ LIBS="-lintl" ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --libdir=/lib \
+ --sysconfdir=/etc \
+ --localstatedir=/var
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="fce40d2445b28c27b8838631681ca3206a4f053b2dd4fc488fc9ef98bbd3d933e3d62b82cf346be2ef1677f6457f692cf5544cd915a6bb1e5c618f98ffa101b4 libnih-1.0.3.tar.gz
+77a979b3076c4e4229359f28c2e9d4fb66d799a66d60391ab6fd7e0dfe2a615b88330a979877b105293a95ed147546596eca174f52b75beca0457c49a017d040 musl-fix-signals.patch
+b5b77b1f18d7aa5d603a0d312b785c28200c38b7bbe5c384ee576c762bd9e3163682c29dd5410baf18c5c3734f0b719602caa1de096f1758d624d94b7753066a disable-broken-test.patch
+b800c99153ad66c9d7399bc7544a0237de0c7a4ddac129509f13eb1c31805fcac31c93bbf2945da557dfc900c9ec837ec0fded1c3f9887095dae52ff6fc046ec musl-enomem-message.patch
+3f24f648c27e9b5a6872859fe97b34055b0f43b11f0321508852b20b6dd94de5c8d24a6dbaab9d49e7004bf0c571c11ebf520d49630d8a89bceeb7783de7dcd2 parse-test-fix.patch"
diff --git a/system/libnih/disable-broken-test.patch b/system/libnih/disable-broken-test.patch
new file mode 100644
index 000000000..15027945a
--- /dev/null
+++ b/system/libnih/disable-broken-test.patch
@@ -0,0 +1,11 @@
+--- libnih-1.0.3/nih/tests/test_child.c.old 2010-09-20 18:17:01.000000000 -0500
++++ libnih-1.0.3/nih/tests/test_child.c 2017-09-27 20:22:23.576368549 -0500
+@@ -652,7 +652,7 @@
+ char *argv[])
+ {
+ test_add_watch ();
+- test_poll ();
++ // test_poll ();
+
+ return 0;
+ }
diff --git a/system/libnih/musl-enomem-message.patch b/system/libnih/musl-enomem-message.patch
new file mode 100644
index 000000000..2adeff852
--- /dev/null
+++ b/system/libnih/musl-enomem-message.patch
@@ -0,0 +1,489 @@
+--- libnih-1.0.3/nih-dbus-tool/tests/test_parse.c.old 2010-09-20 18:17:01.000000000 -0500
++++ libnih-1.0.3/nih-dbus-tool/tests/test_parse.c 2017-09-27 20:40:32.998734677 -0500
+@@ -1583,11 +1583,16 @@
+ Signal * signal;
+ Property * property;
+ Argument * argument;
++ char mem_error[280] = "test:foo:[0-9]*:[0-9]*: ";
+
+ TEST_FUNCTION ("parse_xml");
+ fp = tmpfile ();
+ output = tmpfile ();
+
++
++ strerror_r(ENOMEM, mem_error+24, 254);
++ mem_error[strlen(mem_error)] = '\n';
++
+ /* Check that a file containing a single node entity is parsed
+ * successfully, returning a Node structure with no information
+ * attached.
+@@ -1608,8 +1613,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1645,8 +1649,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1686,8 +1689,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1743,8 +1745,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1800,8 +1801,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1857,8 +1857,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1916,8 +1915,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -1973,8 +1971,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2047,8 +2044,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2121,8 +2117,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2195,8 +2190,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2271,8 +2265,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2345,8 +2338,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2419,8 +2411,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2493,8 +2484,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2567,8 +2557,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2641,8 +2630,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2729,8 +2717,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2817,8 +2804,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2904,8 +2890,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -2992,8 +2977,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3107,8 +3091,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3199,8 +3182,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3291,8 +3273,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3417,8 +3398,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3575,8 +3555,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3647,8 +3626,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3719,8 +3697,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3791,8 +3768,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3865,8 +3841,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -3937,8 +3912,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4023,8 +3997,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4108,8 +4081,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4194,8 +4166,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4306,8 +4277,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4426,8 +4396,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4579,8 +4548,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4652,8 +4620,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4725,8 +4692,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4800,8 +4766,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4875,8 +4840,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -4950,8 +4914,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -5027,8 +4990,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -5104,8 +5066,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -5233,8 +5194,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -5570,8 +5530,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
+@@ -5996,8 +5955,7 @@
+ if (test_alloc_failed) {
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_MATCH (output, ("test:foo:[0-9]*:[0-9]*: "
+- "Cannot allocate memory\n"));
++ TEST_FILE_MATCH (output, mem_error);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+ continue;
diff --git a/system/libnih/musl-fix-signals.patch b/system/libnih/musl-fix-signals.patch
new file mode 100644
index 000000000..97ef8196d
--- /dev/null
+++ b/system/libnih/musl-fix-signals.patch
@@ -0,0 +1,12 @@
+--- libnih-1.0.3.orig/nih/signal.c
++++ libnih-1.0.3/nih/signal.c
+@@ -87,7 +87,9 @@
+ { SIGSTKFLT, "STKFLT" },
+ #endif
+ { SIGCHLD, "CHLD" },
++#ifdef SIGCLD
+ { SIGCLD, "CLD" },
++#endif
+ { SIGCONT, "CONT" },
+ { SIGSTOP, "STOP" },
+ { SIGTSTP, "TSTP" },
diff --git a/system/libnih/parse-test-fix.patch b/system/libnih/parse-test-fix.patch
new file mode 100644
index 000000000..e993bf324
--- /dev/null
+++ b/system/libnih/parse-test-fix.patch
@@ -0,0 +1,11 @@
+--- libnih-1.0.3/nih-dbus-tool/tests/test_parse.c.old 2018-03-02 16:54:29.969068332 -0600
++++ libnih-1.0.3/nih-dbus-tool/tests/test_parse.c 2018-03-02 17:05:41.629074683 -0600
+@@ -7908,7 +7908,7 @@
+
+ TEST_EQ_P (node, NULL);
+
+- TEST_FILE_EQ (output, ("test:foo:2:0: "
++ TEST_FILE_EQ (output, ("test:foo:1:36: "
+ "Invalid object path in <node> name attribute\n"));
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
diff --git a/system/libnotify/APKBUILD b/system/libnotify/APKBUILD
new file mode 100644
index 000000000..a59730e1b
--- /dev/null
+++ b/system/libnotify/APKBUILD
@@ -0,0 +1,34 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libnotify
+pkgver=0.7.7
+pkgrel=1
+pkgdesc="Desktop notification library"
+url="http://library.gnome.org/devel/notification-spec/"
+arch="all"
+license="LGPL"
+options="!check" # Test suite requires running X11
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+depends_dev="dbus-dev"
+makedepends="$depends_dev gdk-pixbuf-dev glib-dev autoconf automake
+ gobject-introspection-dev"
+source="https://download.gnome.org/sources/${pkgname}/${pkgver%.*}/${pkgname}-${pkgver}.tar.xz"
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-static \
+ --disable-tests
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+sha512sums="133874114407bf12267ef609f5941657181760bc7cf115c5973b1810cb72bf55072b621c143e32be1e7e8b49f244851925d14bc3f9f26457747b8a8695ee9954 libnotify-0.7.7.tar.xz"
diff --git a/system/libsndfile/APKBUILD b/system/libsndfile/APKBUILD
new file mode 100644
index 000000000..66abef4f7
--- /dev/null
+++ b/system/libsndfile/APKBUILD
@@ -0,0 +1,61 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libsndfile
+pkgver=1.0.28
+pkgrel=3
+pkgdesc="A C library for reading and writing files containing sampled sound"
+url="http://www.mega-nerd.com/libsndfile"
+arch="all"
+license="LGPL2+"
+subpackages="$pkgname-dev $pkgname-doc"
+depends=
+depends_dev="flac-dev libvorbis-dev libogg-dev"
+makedepends="linux-headers alsa-lib-dev $depends_dev"
+source="http://www.mega-nerd.com/$pkgname/files/$pkgname-$pkgver.tar.gz
+ CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch
+ CVE-2017-8362.patch
+ CVE-2017-12562.patch
+ varargs-32bit.patch
+ "
+
+# secfixes:
+# 1.0.28-r2:
+# - CVE-2017-12562
+# 1.0.28-r0:
+# - CVE-2017-7585
+# - CVE-2017-7741
+# - CVE-2017-7742
+# 1.0.28-r1:
+# - CVE-2017-8361
+# - CVE-2017-8362
+# - CVE-2017-8363
+# - CVE-2017-8365
+
+builddir="$srcdir/$pkgname-$pkgver"
+build () {
+ cd "$builddir"
+ ac_cv_sys_largefile_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-sqlite \
+ --enable-largefile
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="890731a6b8173f714155ce05eaf6d991b31632c8ab207fbae860968861a107552df26fcf85602df2e7f65502c7256c1b41735e1122485a3a07ddb580aa83b57f libsndfile-1.0.28.tar.gz
+f98c40696fca3e7bca867df993de55bb4145c23428e65d1a669182eb2293046478ac727ae7f94bb77123ef0355c3c53be4f9d6a432665c90c74687d8d3afd9e3 CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch
+dfd4b5f1c7471fc416eed5c6040580a020543f145de9103751adaad6ce1c5c6a22abc1cf0ffd381aed3072644cd5ee03ba3598265aa7d202d63167da251cb595 CVE-2017-8362.patch
+814139567d90fb07908014e858c341fe933e04dca69b88ad66078910888237bbeba94f85d9e1489883c424f35fca312eb98c21ae2b122d9289bb6418725cd02e CVE-2017-12562.patch
+2b83bacec23665cd31a596a1ce1fb543f935c7609dfff93a85822f81d66b3483cd547cd043eefb901d543276c270a17add70bf0db6348b5279220a7ecbd8b339 varargs-32bit.patch"
diff --git a/system/libsndfile/CVE-2017-12562.patch b/system/libsndfile/CVE-2017-12562.patch
new file mode 100644
index 000000000..f195e87e4
--- /dev/null
+++ b/system/libsndfile/CVE-2017-12562.patch
@@ -0,0 +1,88 @@
+From cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= <osmanx@problemloesungsmaschine.de>
+Date: Wed, 14 Jun 2017 12:25:40 +0200
+Subject: [PATCH] src/common.c: Fix heap buffer overflows when writing strings
+ in binheader
+
+Fixes the following problems:
+ 1. Case 's' only enlarges the buffer by 16 bytes instead of size bytes.
+ 2. psf_binheader_writef() enlarges the header buffer (if needed) prior to the
+ big switch statement by an amount (16 bytes) which is enough for all cases
+ where only a single value gets added. Cases 's', 'S', 'p' however
+ additionally write an arbitrary length block of data and again enlarge the
+ buffer to the required amount. However, the required space calculation does
+ not take into account the size of the length field which gets output before
+ the data.
+ 3. Buffer size requirement calculation in case 'S' does not account for the
+ padding byte ("size += (size & 1) ;" happens after the calculation which
+ uses "size").
+ 4. Case 'S' can overrun the header buffer by 1 byte when no padding is
+ involved
+ ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;" while
+ the buffer is only guaranteed to have "size" space available).
+ 5. "psf->header.ptr [psf->header.indx] = 0 ;" in case 'S' always writes 1 byte
+ beyond the space which is guaranteed to be allocated in the header buffer.
+ 6. Case 's' can overrun the provided source string by 1 byte if padding is
+ involved ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;"
+ where "size" is "strlen (strptr) + 1" (which includes the 0 terminator,
+ plus optionally another 1 which is padding and not guaranteed to be
+ readable via the source string pointer).
+
+Closes: https://github.com/erikd/libsndfile/issues/292
+---
+ src/common.c | 15 +++++++--------
+ 1 file changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/src/common.c b/src/common.c
+index 1a6204ca..6b2a2ee9 100644
+--- a/src/common.c
++++ b/src/common.c
+@@ -681,16 +681,16 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
+ /* Write a C string (guaranteed to have a zero terminator). */
+ strptr = va_arg (argptr, char *) ;
+ size = strlen (strptr) + 1 ;
+- size += (size & 1) ;
+
+- if (psf->header.indx + (sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, 16))
++ if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
+ return count ;
+
+ if (psf->rwf_endian == SF_ENDIAN_BIG)
+- header_put_be_int (psf, size) ;
++ header_put_be_int (psf, size + (size & 1)) ;
+ else
+- header_put_le_int (psf, size) ;
++ header_put_le_int (psf, size + (size & 1)) ;
+ memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
++ size += (size & 1) ;
+ psf->header.indx += size ;
+ psf->header.ptr [psf->header.indx - 1] = 0 ;
+ count += 4 + size ;
+@@ -703,16 +703,15 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
+ */
+ strptr = va_arg (argptr, char *) ;
+ size = strlen (strptr) ;
+- if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
++ if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
+ return count ;
+ if (psf->rwf_endian == SF_ENDIAN_BIG)
+ header_put_be_int (psf, size) ;
+ else
+ header_put_le_int (psf, size) ;
+- memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;
++ memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ;
+ size += (size & 1) ;
+ psf->header.indx += size ;
+- psf->header.ptr [psf->header.indx] = 0 ;
+ count += 4 + size ;
+ break ;
+
+@@ -724,7 +723,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
+ size = (size & 1) ? size : size + 1 ;
+ size = (size > 254) ? 254 : size ;
+
+- if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
++ if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
+ return count ;
+
+ header_put_byte (psf, size) ;
diff --git a/system/libsndfile/CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch b/system/libsndfile/CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch
new file mode 100644
index 000000000..1dc5b57f1
--- /dev/null
+++ b/system/libsndfile/CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch
@@ -0,0 +1,64 @@
+From fd0484aba8e51d16af1e3a880f9b8b857b385eb3 Mon Sep 17 00:00:00 2001
+From: Erik de Castro Lopo <erikd@mega-nerd.com>
+Date: Wed, 12 Apr 2017 19:45:30 +1000
+Subject: [PATCH] FLAC: Fix a buffer read overrun
+
+Buffer read overrun occurs when reading a FLAC file that switches
+from 2 channels to one channel mid-stream. Only option is to
+abort the read.
+
+Closes: https://github.com/erikd/libsndfile/issues/230
+---
+ src/common.h | 1 +
+ src/flac.c | 13 +++++++++++++
+ src/sndfile.c | 1 +
+ 3 files changed, 15 insertions(+)
+
+diff --git a/src/common.h b/src/common.h
+index 0bd810c3..e2669b6a 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -725,6 +725,7 @@ enum
+ SFE_FLAC_INIT_DECODER,
+ SFE_FLAC_LOST_SYNC,
+ SFE_FLAC_BAD_SAMPLE_RATE,
++ SFE_FLAC_CHANNEL_COUNT_CHANGED,
+ SFE_FLAC_UNKOWN_ERROR,
+
+ SFE_WVE_NOT_WVE,
+diff --git a/src/flac.c b/src/flac.c
+index 84de0e26..986a7b8f 100644
+--- a/src/flac.c
++++ b/src/flac.c
+@@ -434,6 +434,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
+
+ switch (metadata->type)
+ { case FLAC__METADATA_TYPE_STREAMINFO :
++ if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
++ { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
++ "Nothing to be but to error out.\n" ,
++ psf->sf.channels, metadata->data.stream_info.channels) ;
++ psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
++ return ;
++ } ;
++
++ if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate)
++ { psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n"
++ "Carrying on as if nothing happened.",
++ psf->sf.samplerate, metadata->data.stream_info.sample_rate) ;
++ } ;
+ psf->sf.channels = metadata->data.stream_info.channels ;
+ psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
+ psf->sf.frames = metadata->data.stream_info.total_samples ;
+diff --git a/src/sndfile.c b/src/sndfile.c
+index 41875610..e2a87be8 100644
+--- a/src/sndfile.c
++++ b/src/sndfile.c
+@@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] =
+ { SFE_FLAC_INIT_DECODER , "Error : problem with initialization of the flac decoder." },
+ { SFE_FLAC_LOST_SYNC , "Error : flac decoder lost sync." },
+ { SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
++ { SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." },
+ { SFE_FLAC_UNKOWN_ERROR , "Error : unknown error in flac decoder." },
+
+ { SFE_WVE_NOT_WVE , "Error : not a WVE file." },
diff --git a/system/libsndfile/CVE-2017-8362.patch b/system/libsndfile/CVE-2017-8362.patch
new file mode 100644
index 000000000..54fbfb44c
--- /dev/null
+++ b/system/libsndfile/CVE-2017-8362.patch
@@ -0,0 +1,50 @@
+From ef1dbb2df1c0e741486646de40bd638a9c4cd808 Mon Sep 17 00:00:00 2001
+From: Erik de Castro Lopo <erikd@mega-nerd.com>
+Date: Fri, 14 Apr 2017 15:19:16 +1000
+Subject: [PATCH] src/flac.c: Fix a buffer read overflow
+
+A file (generated by a fuzzer) which increased the number of channels
+from one frame to the next could cause a read beyond the end of the
+buffer provided by libFLAC. Only option is to abort the read.
+
+Closes: https://github.com/erikd/libsndfile/issues/231
+---
+ src/flac.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/flac.c b/src/flac.c
+index 5a4f8c21..e4f9aaa0 100644
+--- a/src/flac.c
++++ b/src/flac.c
+@@ -169,6 +169,14 @@ flac_buffer_copy (SF_PRIVATE *psf)
+ const int32_t* const *buffer = pflac->wbuffer ;
+ unsigned i = 0, j, offset, channels, len ;
+
++ if (psf->sf.channels != (int) frame->header.channels)
++ { psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n"
++ "Nothing to do but to error out.\n" ,
++ psf->sf.channels, frame->header.channels) ;
++ psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
++ return 0 ;
++ } ;
++
+ /*
+ ** frame->header.blocksize is variable and we're using a constant blocksize
+ ** of FLAC__MAX_BLOCK_SIZE.
+@@ -202,7 +210,6 @@ flac_buffer_copy (SF_PRIVATE *psf)
+ return 0 ;
+ } ;
+
+-
+ len = SF_MIN (pflac->len, frame->header.blocksize) ;
+
+ if (pflac->remain % channels != 0)
+@@ -436,7 +443,7 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
+ { case FLAC__METADATA_TYPE_STREAMINFO :
+ if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
+ { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
+- "Nothing to be but to error out.\n" ,
++ "Nothing to do but to error out.\n" ,
+ psf->sf.channels, metadata->data.stream_info.channels) ;
+ psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
+ return ;
diff --git a/system/libsndfile/varargs-32bit.patch b/system/libsndfile/varargs-32bit.patch
new file mode 100644
index 000000000..81f149add
--- /dev/null
+++ b/system/libsndfile/varargs-32bit.patch
@@ -0,0 +1,11 @@
+--- libsndfile-1.0.28/src/rf64.c.old 2017-04-02 02:43:22.000000000 -0500
++++ libsndfile-1.0.28/src/rf64.c 2018-03-04 22:35:31.072461118 -0600
+@@ -737,7 +737,7 @@
+
+ pad_size = psf->dataoffset - 16 - psf->header.indx ;
+ if (pad_size >= 0)
+- psf_binheader_writef (psf, "m4z", PAD_MARKER, pad_size, make_size_t (pad_size)) ;
++ psf_binheader_writef (psf, "m4z", PAD_MARKER, (unsigned int) pad_size, make_size_t (pad_size)) ;
+
+ if (wpriv->rf64_downgrade && (psf->filelength < RIFF_DOWNGRADE_BYTES))
+ psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;
diff --git a/system/libssh2/APKBUILD b/system/libssh2/APKBUILD
new file mode 100644
index 000000000..1bfdfdef9
--- /dev/null
+++ b/system/libssh2/APKBUILD
@@ -0,0 +1,41 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libssh2
+pkgver=1.8.0
+pkgrel=1
+pkgdesc="library for accessing ssh1/ssh2 protocol servers"
+url="http://libssh2.org/"
+arch="all"
+license="BSD"
+makedepends_host="openssl-dev zlib-dev"
+options="!check"
+subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc"
+source="http://www.libssh2.org/download/libssh2-$pkgver.tar.gz"
+builddir="$srcdir"/libssh2-$pkgver
+
+prepare() {
+ cd "$builddir"
+ update_config_sub
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --with-libssl-prefix="${CBUILDROOT}"/usr \
+ --disable-rpath
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="289aa45c4f99653bebf5f99565fe9c519abc204feb2084b47b7cc3badc8bf4ecdedd49ea6acdce8eb902b3c00995d5f92a3ca77b2508b92f04ae0e7de7287558 libssh2-1.8.0.tar.gz"
diff --git a/system/libtool/APKBUILD b/system/libtool/APKBUILD
new file mode 100644
index 000000000..518d33a0a
--- /dev/null
+++ b/system/libtool/APKBUILD
@@ -0,0 +1,55 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libtool
+pkgver=2.4.6
+pkgrel=5
+pkgdesc="A generic library support script"
+arch="all"
+license="GPL"
+url="http://www.gnu.org/software/libtool"
+source="ftp://ftp.gnu.org/pub/gnu/libtool/${pkgname}-${pkgver}.tar.gz
+ libtool-fix-cross-compile.patch
+ "
+depends="bash libltdl"
+makedepends="m4 help2man"
+checkdepends="mawk autoconf automake gzip"
+subpackages="libltdl $pkgname-doc"
+options="libtool"
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-static \
+ lt_cv_shlibpath_overrides_runpath=yes
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+check() {
+ cd "$builddir"
+ # Test 70 and 117 are known to fail
+ # Test 170 repeats the entire test suite with shorter max_cmd_len
+ make check TESTSUITEFLAGS="1-69 71-116 118-169"
+}
+
+libltdl() {
+ pkgdesc="Runtime libraries for GNU Libtool Dynamic Module Loader"
+ depends=
+ mkdir -p "$subpkgdir/usr/lib"
+ mv "$pkgdir/usr/lib/libltdl.so"* "$subpkgdir/usr/lib/"
+}
+
+md5sums="addf44b646ddb4e3919805aa88fa7c5e libtool-2.4.6.tar.gz
+3657a65e226879586c29360eac6ae41b libtool-fix-cross-compile.patch"
+sha256sums="e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3 libtool-2.4.6.tar.gz
+c98362e9b1efd90618813a6901144452dc03f51e6300686bb07e068ac851c245 libtool-fix-cross-compile.patch"
+sha512sums="3233d81cb2739a54b840a0a82064eebbfaa4fb442fb993a35d6bd41d8395c51f038c90ae048b9252f172d0a5bbfb4b36e2b13d4477001f9ff7d4124237819a18 libtool-2.4.6.tar.gz
+aa14cadd70a633520249fa3a6a4c45b309a980380e62dd5982b3ae842c478a77401ad809297fceebd167c167b0a19f380e6a6c295bc75d1029d56d3bf262b209 libtool-fix-cross-compile.patch"
diff --git a/system/libtool/libtool-fix-cross-compile.patch b/system/libtool/libtool-fix-cross-compile.patch
new file mode 100644
index 000000000..585897e0d
--- /dev/null
+++ b/system/libtool/libtool-fix-cross-compile.patch
@@ -0,0 +1,36 @@
+--- libtool-2.4.6.orig/build-aux/ltmain.in
++++ libtool-2.4.6/build-aux/ltmain.in
+@@ -6449,7 +6449,7 @@
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+- add_dir=-L$libdir
++ add_dir="-L$lt_sysroot$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+@@ -7628,9 +7628,11 @@
+ test relink = "$opt_mode" || rpath=$compile_rpath$rpath
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
++ func_replace_sysroot "$libdir"
++ libdir=$func_replace_sysroot_result
++ func_stripname '=' '' "$libdir"
++ libdir=$func_stripname_result
+ if test -n "$hardcode_libdir_separator"; then
+- func_replace_sysroot "$libdir"
+- libdir=$func_replace_sysroot_result
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs=$libdir
+ else
+@@ -8360,6 +8362,10 @@
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
++ func_replace_sysroot "$libdir"
++ libdir=$func_replace_sysroot_result
++ func_stripname '=' '' "$libdir"
++ libdir=$func_stripname_result
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs=$libdir
diff --git a/system/libtool/libtool.patch b/system/libtool/libtool.patch
new file mode 100644
index 000000000..4302b7e07
--- /dev/null
+++ b/system/libtool/libtool.patch
@@ -0,0 +1,41 @@
+diff --git a/main/libtool/APKBUILD b/main/libtool/APKBUILD
+index de86f2aeb7..3a7d137533 100644
+--- a/main/libtool/APKBUILD
++++ b/main/libtool/APKBUILD
+@@ -4,13 +4,14 @@ pkgver=2.4.6
+ pkgrel=1
+ pkgdesc="A generic library support script"
+ arch="all"
+-license='GPL'
++license="GPL"
+ url="http://www.gnu.org/software/libtool"
+ source="ftp://ftp.gnu.org/pub/gnu/libtool/${pkgname}-${pkgver}.tar.gz
+ libtool-fix-cross-compile.patch
+ "
+ depends="bash libltdl"
+ makedepends="m4 help2man"
++checkdepends="mawk autoconf automake gzip"
+ subpackages="libltdl $pkgname-doc"
+ options="libtool"
+
+@@ -23,7 +24,7 @@ build() {
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-static \
+- || return 1
++ lt_cv_shlibpath_overrides_runpath=yes
+ make
+ }
+
+@@ -32,6 +33,11 @@ package() {
+ make DESTDIR="$pkgdir" install
+ }
+
++check() {
++ cd "$builddir"
++ make check
++}
++
+ libltdl() {
+ pkgdesc="Runtime libraries for GNU Libtool Dynamic Module Loader"
+ depends=
diff --git a/system/libvpx/APKBUILD b/system/libvpx/APKBUILD
new file mode 100644
index 000000000..27de30e06
--- /dev/null
+++ b/system/libvpx/APKBUILD
@@ -0,0 +1,52 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=libvpx
+pkgver=1.6.1
+pkgrel=1
+pkgdesc="Library for the vp8 codec"
+url="http://www.webmproject.org/"
+arch="all"
+license="GPL"
+options="!check"
+depends=""
+makedepends="coreutils yasm bash perl which"
+subpackages="$pkgname-dev $pkgname-utils"
+source="https://storage.googleapis.com/downloads.webmproject.org/releases/webm/$pkgname-$pkgver.tar.bz2"
+
+builddir="$srcdir"/$pkgname-$pkgver
+build() {
+ cd "$builddir"
+ # build fix for arm
+ export CROSS=" "
+ bash ./configure \
+ --enable-pic \
+ --enable-libs \
+ --enable-runtime-cpu-detect \
+ --enable-vp8 \
+ --enable-vp9 \
+ --enable-shared \
+ --disable-install-srcs \
+ --enable-postproc
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DIST_DIR="$pkgdir"/usr install
+ chmod 644 "$pkgdir"/usr/include/vpx/*.h \
+ "$pkgdir"/usr/lib/pkgconfig/*
+ chown root:root -R "$pkgdir"
+ chmod 755 "$pkgdir"/usr/lib/*
+}
+
+utils() {
+ pkgdesc="VP8 utilities and tools"
+ install -d "$subpkgdir"/usr
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+sha512sums="1a4b009fe1737715c6563a79848126a5859394a5074b1e9cca9bc2e213df90890c15e708040d5f2c96c7c21e268f51e1352ac6911514bf891a4bf3eea154159d libvpx-1.6.1.tar.bz2"
diff --git a/system/libvpx/libm-pc.patch b/system/libvpx/libm-pc.patch
new file mode 100644
index 000000000..87f07a398
--- /dev/null
+++ b/system/libvpx/libm-pc.patch
@@ -0,0 +1,11 @@
+--- ./libs.mk.orig
++++ ./libs.mk
+@@ -241,7 +241,7 @@
+ $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
+ $(qexec)echo 'Requires:' >> $@
+ $(qexec)echo 'Conflicts:' >> $@
+- $(qexec)echo 'Libs: -L$${libdir} -lvpx' >> $@
++ $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
+ $(qexec)echo 'Cflags: -I$${includedir}' >> $@
+ INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
+ INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
diff --git a/system/libxml2/APKBUILD b/system/libxml2/APKBUILD
new file mode 100644
index 000000000..8f7207c16
--- /dev/null
+++ b/system/libxml2/APKBUILD
@@ -0,0 +1,77 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=libxml2
+pkgver=2.9.7
+pkgrel=2
+pkgdesc="XML parsing library, version 2"
+url="http://www.xmlsoft.org/"
+arch="all"
+license="MIT"
+depends=
+depends_dev="zlib-dev icu-dev"
+checkdepends="perl tar"
+makedepends="$depends_dev python3-dev"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-utils py-libxml2:py"
+options="!check !strip" # Impossible to run on Python 3
+source="ftp://ftp.xmlsoft.org/${pkgname}/${pkgname}-${pkgver}.tar.gz
+ libxml2-2.9.4-remove-pyverify_fd.patch
+ python-segfault-fix.patch
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+
+# secfixes:
+# 2.9.4-r1:
+# - CVE-2016-5131
+# 2.9.4-r2:
+# - CVE-2016-9318
+# 2.9.4-r4:
+# - CVE-2017-5969
+
+prepare() {
+ default_prepare
+ # setup.py is generated
+ rm python/setup.py
+}
+
+build() {
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-icu \
+ --with-python=/usr/bin/python3
+ make
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+dev() {
+ default_dev
+ mv "$pkgdir"/usr/lib/*.sh "$subpkgdir"/usr/lib/
+}
+
+py() {
+ cd "$builddir"
+
+ pkgdesc="$pkgname Python bindings"
+ provides="py3-libxml2=$pkgver-r$pkgrel"
+ install -d "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/python3* "$subpkgdir"/usr/lib/
+}
+
+utils() {
+ pkgdesc="XML utilities"
+ replaces="libxml2"
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+sha512sums="da06cb7c5032ef4b7c8e902fabb9d2c74634c42c161be07a7c66a00d53a68029f89b0d4de32a6b9d4ff338c2d1d9c4e53aefb9cf50cb1c2d6c6b06b442ef42d5 libxml2-2.9.7.tar.gz
+271e701daf08f10a8b591c5128f596105901a29ecc9ee72f088afab266eaec7932a4a7d2194baa07c69e1aa93f3e9dc01a4a890456f53416c45d490598be41d9 libxml2-2.9.4-remove-pyverify_fd.patch
+384b3d2031cd8f77528190bbb7652faa9ccb22bc604bcf4927e59046d38830dac38010828fe1568b6514976f725981a6d3ac1aa595d31477a36db2afe491452c python-segfault-fix.patch"
diff --git a/system/libxml2/libxml2-2.9.4-remove-pyverify_fd.patch b/system/libxml2/libxml2-2.9.4-remove-pyverify_fd.patch
new file mode 100644
index 000000000..d05d4cb60
--- /dev/null
+++ b/system/libxml2/libxml2-2.9.4-remove-pyverify_fd.patch
@@ -0,0 +1,12 @@
+diff -Nur libxml2-2.9.4.orig/python/types.c libxml2-2.9.4/python/types.c
+--- libxml2-2.9.4.orig/python/types.c 2016-02-09 03:17:33.000000000 -0700
++++ libxml2-2.9.4/python/types.c 2016-12-21 12:34:06.755650986 -0700
+@@ -31,8 +31,6 @@
+ const char *mode;
+
+ fd = PyObject_AsFileDescriptor(f);
+- if (!_PyVerify_fd(fd))
+- return(NULL);
+ /*
+ * Get the flags on the fd to understand how it was opened
+ */
diff --git a/system/libxml2/python-segfault-fix.patch b/system/libxml2/python-segfault-fix.patch
new file mode 100644
index 000000000..f1f7554eb
--- /dev/null
+++ b/system/libxml2/python-segfault-fix.patch
@@ -0,0 +1,36 @@
+Upstream: https://bugzilla.gnome.org/show_bug.cgi?id=791691
+
+From d1ea6250dd00a3b7a92b52a743ec53f7751196e5 Mon Sep 17 00:00:00 2001
+From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
+Date: Sat, 16 Dec 2017 19:22:23 -0600
+Subject: [PATCH] Python: if message is NULL, use Py_None instead
+
+If the error message is malformed / invalid UTF-8, and the Python 3
+binding is being used, then message may be NULL. This will cause the
+Python interpreter to crash (Segmentation fault) trying to unpack the
+argument list into local variables.
+
+This uses Py_None for message if message is NULL, so that the
+interpreter does not crash.
+---
+ python/libxml.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/python/libxml.c b/python/libxml.c
+index 5b1ff6e8..dae77b88 100644
+--- a/python/libxml.c
++++ b/python/libxml.c
+@@ -1640,6 +1640,10 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
+ PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
+ Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
+ message = libxml_charPtrConstWrap(str);
++ if (message == NULL) {
++ Py_INCREF(Py_None);
++ message = Py_None;
++ }
+ PyTuple_SetItem(list, 1, message);
+ result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
+ Py_XDECREF(list);
+--
+2.14.1
+
diff --git a/system/libxslt/APKBUILD b/system/libxslt/APKBUILD
new file mode 100644
index 000000000..a43c0ffd3
--- /dev/null
+++ b/system/libxslt/APKBUILD
@@ -0,0 +1,40 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+# Contributor: Francesco Colista <fcolista@alpinelinux.org>
+pkgname=libxslt
+pkgver=1.1.31
+pkgrel=0
+pkgdesc="XML stylesheet transformation library"
+url="http://xmlsoft.org/XSLT/"
+arch="all"
+license="custom"
+makedepends="libxml2-dev libgcrypt-dev libgpg-error-dev python3-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://xmlsoft.org/$pkgname/$pkgname-$pkgver.tar.gz"
+
+# secfixes:
+# 1.1.29-r1:
+# - CVE-2017-5029
+
+build() {
+ cd "$builddir"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+
+ make DESTDIR="$pkgdir" install
+ install -D -m644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+sha512sums="9012d643625d827b131c825a103f2e2a5f3cbd45d3cdf3318378e8f046da8d084db51c6b0078b5850a26adc81ba3bf357101d65ef510eff54c8b416a71efed92 libxslt-1.1.31.tar.gz"
diff --git a/system/lighttpd/APKBUILD b/system/lighttpd/APKBUILD
new file mode 100644
index 000000000..356bce93e
--- /dev/null
+++ b/system/lighttpd/APKBUILD
@@ -0,0 +1,116 @@
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lighttpd
+pkgver=1.4.48
+pkgrel=0
+pkgdesc="A secure, fast, compliant and very flexible web-server"
+url="http://www.lighttpd.net/"
+arch="all"
+license="custom"
+install="$pkgname.pre-install $pkgname.pre-upgrade"
+pkgusers="lighttpd"
+pkggroups="lighttpd"
+makedepends="flex pcre-dev openssl-dev zlib-dev bzip2-dev lua5.2-dev
+ automake autoconf openldap-dev libxml2-dev sqlite-dev libev-dev
+ gamin-dev attr-dev"
+subpackages="$pkgname-doc $pkgname-dbg $pkgname-mod_auth $pkgname-openrc
+ $pkgname-mod_webdav"
+source="http://download.lighttpd.net/lighttpd/releases-1.4.x/$pkgname-$pkgver.tar.xz
+ $pkgname.initd
+ $pkgname.confd
+ $pkgname.logrotate
+ lighttpd.conf
+ mime-types.conf
+ mod_cgi.conf
+ mod_fastcgi.conf
+ mod_fastcgi_fpm.conf
+ char-signedness.patch"
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-dependency-tracking \
+ --enable-lfs \
+ --libdir=/usr/lib/lighttpd \
+ --without-mysql \
+ --with-attr \
+ --without-kerberos5 \
+ --with-fam \
+ --with-webdav-props \
+ --with-webdav-locks \
+ --without-gdbm \
+ --with-bzip2 \
+ --with-ldap \
+ --with-openssl \
+ --with-libev \
+ --with-lua
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+
+ make DESTDIR="$pkgdir" install
+
+ # create dirs
+ install -d -m755 -o lighttpd -g lighttpd \
+ "$pkgdir"/var/log/lighttpd/
+ install -d -m755 \
+ "$pkgdir"/etc/lighttpd/ \
+ "$pkgdir"/var/www/localhost/htdocs
+
+ # lighttpd
+ install -D -m755 "$srcdir"/lighttpd.initd \
+ "$pkgdir"/etc/init.d/lighttpd
+ install -D -m644 "$srcdir"/lighttpd.confd \
+ "$pkgdir"/etc/conf.d/lighttpd
+ install -D -m644 "$srcdir"/lighttpd.logrotate \
+ "$pkgdir"/etc/logrotate.d/lighttpd
+
+ # config files
+ local i; for i in lighttpd.conf mime-types.conf mod_cgi.conf \
+ mod_fastcgi.conf mod_fastcgi_fpm.conf
+ do
+ install -m644 "$srcdir"/$i "$pkgdir"/etc/lighttpd/$i
+ done
+}
+
+_mv_mod() {
+ mkdir -p "$subpkgdir"/usr/lib/lighttpd
+ while [ $# -gt 0 ]; do
+ mv "$pkgdir"/usr/lib/lighttpd/$1.so \
+ "$subpkgdir"/usr/lib/lighttpd/
+ shift
+ done
+}
+
+mod_auth() {
+ pkgdesc="Authentication module for lighttpd"
+ _mv_mod mod_auth
+}
+
+mod_webdav() {
+ pkgdesc="WebDAV module for lighttpd"
+ _mv_mod mod_webdav
+}
+
+sha512sums="361dbf07b280aa7345f3026cce6d12d0aeaa3bb535b5a5b2a894a568395f46a9c7ce723dfd1948225117495f3e63ec207b72d5e4b680da7cd56419e23cf8bae4 lighttpd-1.4.48.tar.xz
+f2f3c5c7731550237fd75a8de66275f427eaf897cffff7ac7ef44178328ad8fad6c4ec6654759bfc665cbaf7991ddcdf0aaa916831c8b6aa440192d57b242038 lighttpd.initd
+9d2ab5deb7353ebf290e90936b511941df440859c78589d0bcf130ef69a5e9c79e4d318548b6b118df002083c46f7476230a28954b7a10a9dbd05040e02b1291 lighttpd.confd
+0536b4f21d2e8659f7831b45998c13d9f6051ae7ecde13be01f372f837d255bfc4e211de48a7686cc743d53aa9c08ab3f10ec19788896dcf8356b90053ca7a16 lighttpd.logrotate
+b0fd7500ea7f7f7f9fbf04bb66eb06050cfed57bdc1730900b4c559598176442e4504395f1d406e037e7cffeaa1451d40a6cad408570f7f7e1dd6cc26c968912 lighttpd.conf
+a3f2f5763885d7e4f510491b24164e34aaf62bb02daa12991575dc64335c12668355af5bb8d6ce191eb4e9cce95324b1f7c9ba61b323b4e7b50a1e03e021afcf mime-types.conf
+27cc638d8068dcf47bd9db44943d1db6c6f4e8e6abd6b42af7cea004b1c093440068541d98c68f8bea70b956713adaf8ed59a4b642dea826ee8620a05f8cfde5 mod_cgi.conf
+1d15b84c03fb648a0e67ab5c5411b85478b4454c44bc2959cc96d1700eeadd7ff429520a5f1550db6527267646622dccd3d47d3fd1258869fccaf5c22d4ad4b2 mod_fastcgi.conf
+f9efc4b70d825600f5356c30e57d0b6cac11c01739337f7192c09c2cfd96cb76c8328b11d818ea4c2addc1a6d253975b84700106ae75854d55d0df73e220bd2b mod_fastcgi_fpm.conf
+ce35c1d65d7b4fedd1fcfadd8a5e906d5efa8dcda318a4fa69958b708c2df329f708591f43b12adaaac4da6a2913d0cc8f9745e636e7f2016c1075bcd52c6bb2 char-signedness.patch"
diff --git a/system/lighttpd/char-signedness.patch b/system/lighttpd/char-signedness.patch
new file mode 100644
index 000000000..43f7f5faf
--- /dev/null
+++ b/system/lighttpd/char-signedness.patch
@@ -0,0 +1,46 @@
+
+Added by gstrauss 16 days ago
+
+ ID d4083effab0f9bf76528d5c47198b17e7471ed13
+ Parent 0c95ed37
+ Child 37f9b60d
+
+[core] fix base64 decode when char is unsigned (fixes #2848)
+
+thx, codehero
+
+x-ref:
+"buffer_append_base64_decode() broken on compilers where char is assumed unsigned"
+https://redmine.lighttpd.net/issues/2848
+
+diff --git a/src/base64.c b/src/base64.c
+index f39dbaa2..3034181a 100644
+--- a/src/base64.c
++++ b/src/base64.c
+@@ -11,7 +11,7 @@
+
+ /* BASE64_STANDARD: "A-Z a-z 0-9 + /" maps to 0-63, pad with "=" */
+ static const char base64_standard_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+-static const char base64_standard_reverse_table[] = {
++static const signed char base64_standard_reverse_table[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+ -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x00 - 0x0F */
+ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x10 - 0x1F */
+@@ -25,7 +25,7 @@ static const char base64_standard_reverse_table[] = {
+
+ /* BASE64_URL: "A-Z a-z 0-9 - _" maps to 0-63, pad with "." */
+ static const char base64_url_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
+-static const char base64_url_reverse_table[] = {
++static const signed char base64_url_reverse_table[] = {
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+ -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x00 - 0x0F */
+ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x10 - 0x1F */
+@@ -42,7 +42,7 @@ unsigned char* buffer_append_base64_decode(buffer *out, const char* in, size_t i
+ size_t out_pos = 0; /* current output character (position) that is decoded. can contain partial result */
+ unsigned int group = 0; /* how many base64 digits in the current group were decoded already. each group has up to 4 digits */
+ size_t i;
+- const char *base64_reverse_table;
++ const signed char *base64_reverse_table;
+
+ switch (charset) {
+ case BASE64_STANDARD:
diff --git a/system/lighttpd/lighttpd.conf b/system/lighttpd/lighttpd.conf
new file mode 100644
index 000000000..cfec00065
--- /dev/null
+++ b/system/lighttpd/lighttpd.conf
@@ -0,0 +1,261 @@
+###################################
+# Default lighttpd.conf for Adélie
+###################################
+
+
+######## Variables ########
+var.basedir = "/var/www/localhost"
+var.logdir = "/var/log/lighttpd"
+var.statedir = "/var/lib/lighttpd"
+
+
+######## Modules ########
+# NOTE: the order of modules is important.
+server.modules = (
+# "mod_rewrite",
+# "mod_redirect",
+# "mod_alias",
+ "mod_access",
+# "mod_cml",
+# "mod_trigger_b4_dl",
+# "mod_auth",
+# "mod_status",
+ "mod_setenv",
+# "mod_proxy",
+# "mod_simple_vhost",
+# "mod_evhost",
+# "mod_userdir",
+ "mod_compress",
+# "mod_ssi",
+# "mod_usertrack",
+ "mod_expire",
+# "mod_secdownload",
+# "mod_rrdtool",
+# "mod_webdav",
+ "mod_accesslog"
+)
+
+
+######## Inclusions ########
+include "mime-types.conf"
+# uncomment for cgi support
+# include "mod_cgi.conf"
+# uncomment for php/fastcgi support
+# include "mod_fastcgi.conf"
+# uncomment for php/fastcgi fpm support
+# include "mod_fastcgi_fpm.conf"
+
+
+######## Global Settings ########
+server.username = "lighttpd"
+server.groupname = "lighttpd"
+
+server.document-root = var.basedir + "/htdocs"
+server.pid-file = "/run/lighttpd.pid"
+
+server.errorlog = var.logdir + "/error.log"
+# To log errors to syslog instead, use:
+# server.errorlog-use-syslog = "enable"
+
+server.indexfiles = ("index.html", "index.htm", "default.htm")
+
+# server.tag = "lighttpd"
+
+server.follow-symlink = "enable"
+
+server.event-handler = "linux-sysepoll"
+
+# To chroot to a directory:
+# server.chroot = "/"
+
+# Default bind port is 80. To change:
+# server.port = 81
+
+# Default bind address is global (0.0.0.0). To change:
+# server.bind = "grisu.home.kneschke.de"
+
+# error-handler for status 404
+# server.error-handler-404 = "/error-handler.html"
+
+# Format: <errorfile-prefix><status-code>.html
+# -> ..../status-404.html for 'File not found'
+# server.errorfile-prefix = var.basedir + "/error/status-"
+
+# FAM support for caching stat() calls
+server.stat-cache-engine = "fam"
+
+# which extensions should not be handled via static-file transfer
+# (extensions that are usually handled by mod_cgi, mod_fastcgi, etc).
+static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi")
+
+
+######## mod_accesslog config ########
+accesslog.filename = var.logdir + "/access.log"
+
+
+######## mod_dirlisting config ########
+# Enable directory listings if no indexfile is present.
+#dir-listing.activate = "enable"
+
+# Don't list hidden files/directories (beginning with '.')
+#dir-listing.hide-dotfiles = "enable"
+#
+# Specify a path here for custom directory listing CSS:
+#dir-listing.external-css = "/path/to/dir-listing.css"
+#
+# Exclude files that match any regex in this list from directory listings:
+#dir-listing.exclude = ("^\.", "~$")
+
+
+######## mod_access config ########
+# See access.txt in lighttpd-doc package for more info.
+
+url.access-deny = ("~", ".inc")
+
+
+######## mod_userdir config ########
+# This will give all users with valid homedirs the chance to publish a
+# webpage from this server using traditional /~username/ paths.
+# See userdir.txt in lighttpd-doc package for more info.
+#
+#userdir.path = "public_html"
+#userdir.exclude-user = ("root")
+
+
+######## mod_ssi config ########
+# This allows you to use server-side includes.
+#ssi.extension = (".shtml")
+
+
+######## SSL config ########
+# See ssl.txt in lighttpd-doc package for more info.
+# The defaults here are NOT the server defaults. You need to uncomment
+# them to use them. They are HIGHLY recommended; by default, lighttpd
+# will serve older TLS protocols that may be vulnerable to attack.
+#
+#ssl.engine = "enable"
+#ssl.honor-cipher-order = "enable"
+#ssl.disable-client-renegotiation = "enable"
+# pemfile is cert+privkey, ca-file is the intermediate chain in one file
+#ssl.pemfile = "/path/to/signed_cert_plus_private_key.pem"
+#ssl.ca-file = "/path/to/intermediate_certificate.pem"
+# ECDH/ECDHE ciphers curve strength (see `openssl ecparam -list_curves`)
+#ssl.ec-curve = "secp384r1"
+# Environment flag for HTTPS enabled
+#setenv.add-environment = (
+# "HTTPS" => "on"
+#)
+# Modern configuration, tweak to your needs
+#ssl.use-sslv2 = "disable"
+#ssl.use-sslv3 = "disable"
+#ssl.cipher-list = "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"
+# HSTS(15768000 seconds = 6 months)
+#setenv.add-response-header = (
+# "Strict-Transport-Security" => "max-age=15768000;"
+#)
+
+
+######## mod_status config ########
+# This is generally handy and won't expose any sensitive info.
+#status.status-url = "/server-status"
+# This will expose some of your configuration to the world!
+#status.config-url = "/server-config"
+
+
+######## mod_compress config ########
+compress.cache-dir = var.statedir + "/cache/compress"
+compress.filetype = ("text/plain", "text/html")
+
+
+######## mod_proxy config ########
+# See proxy.txt in lighttpd-doc package for more info.
+# proxy.server = ( ".php" =>
+# ( "localhost" =>
+# (
+# "host" => "192.168.0.101",
+# "port" => 80
+# )
+# )
+# )
+# }}}
+
+
+######## mod_auth config ########
+# See authentication.txt in lighttpd-doc package for more info.
+#auth.backend = "plain"
+#auth.backend.plain.userfile = "lighttpd.user"
+#auth.backend.plain.groupfile = "lighttpd.group"
+
+#auth.backend.ldap.hostname = "localhost"
+#auth.backend.ldap.base-dn = "dc=my-domain,dc=com"
+#auth.backend.ldap.filter = "(uid=$)"
+
+#auth.require = ( "/server-status" =>
+# (
+# "method" => "digest",
+# "realm" => "download archiv",
+# "require" => "user=jan"
+# ),
+# "/server-info" =>
+# (
+# "method" => "digest",
+# "realm" => "download archiv",
+# "require" => "valid-user"
+# )
+# )
+
+
+######## mod_rewrite config ########
+# Apache-style mod_rewrite for implementing URL rewriting.
+# See rewrite.txt in lighttpd-doc package for more info.
+#
+#url.rewrite = (
+# "^/$" => "/server-status"
+#)
+
+
+######## mod_redirect config ########
+# See redirect.txt in lighttpd-doc package for more info.
+#
+#url.redirect = (
+# "^/wishlist/(.+)" => "http://www.123.org/$1"
+#)
+
+
+######## mod_expire config ########
+# It is highly recommended you configure Expire: headers correctly to
+# conserve bandwidth, especially for users on slow links.
+#expire.url = (
+# "/buggy/" => "access 2 hours",
+# "/asdhas/" => "access plus 1 seconds 2 minutes"
+#)
+
+# {{{ mod_trigger_b4_dl
+# see trigger_b4_dl.txt
+#
+# trigger-before-download.gdbm-filename = "/home/weigon/testbase/trigger.db"
+# trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" )
+# trigger-before-download.trigger-url = "^/trigger/"
+# trigger-before-download.download-url = "^/download/"
+# trigger-before-download.deny-url = "http://127.0.0.1/index.html"
+# trigger-before-download.trigger-timeout = 10
+# }}}
+
+
+######## mod_webdav config ########
+# lighttpd can act as a WebDAV server.
+# See webdav.txt in lighttpd-doc package for more info.
+#
+#$HTTP["url"] =~ "^/dav($|/)" {
+# webdav.activate = "enable"
+# webdav.is-readonly = "enable"
+#}
+
+
+######## Debugging options ########
+# debug.log-request-header = "enable"
+# debug.log-response-header = "enable"
+# debug.log-request-handling = "enable"
+# debug.log-file-not-found = "enable"
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/system/lighttpd/lighttpd.confd b/system/lighttpd/lighttpd.confd
new file mode 100644
index 000000000..da524afb4
--- /dev/null
+++ b/system/lighttpd/lighttpd.confd
@@ -0,0 +1,12 @@
+# /etc/conf.d/lighttpd
+
+# Location of a shell used by the 'include_shell' directive
+# in the lighttpd's configuration file
+#export SHELL="/bin/bash"
+
+# Location of the lighttpd configuration file
+LIGHTTPD_CONF="/etc/lighttpd/lighttpd.conf"
+
+# Location of the lighttpd pid file
+LIGHTTPD_PID="/run/lighttpd.pid"
+
diff --git a/system/lighttpd/lighttpd.initd b/system/lighttpd/lighttpd.initd
new file mode 100644
index 000000000..614cb2132
--- /dev/null
+++ b/system/lighttpd/lighttpd.initd
@@ -0,0 +1,75 @@
+#!/sbin/openrc-run
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/lighttpd.initd,v 1.21 2012/01/08 20:45:46 hwoarang Exp $
+
+extra_started_commands="reload graceful"
+required_files=$LIGHTTPD_CONF
+
+depend() {
+ need net
+ use mysql logger spawn-fcgi ldap slapd netmount dns
+ after firewall
+ after famd
+ after sshd
+}
+
+checkconfig() {
+ if [ ! -f "${LIGHTTPD_CONF}" ] ; then
+ ewarn "${LIGHTTPD_CONF} does not exist."
+ return 1
+ fi
+
+ if [ -z "${LIGHTTPD_PID}" ] ; then
+ ewarn "server.pid-file variable in ${LIGHTTPD_CONF}"
+ ewarn "is not set. Falling back to lighttpd.pid"
+ LIGHTTPD_PID="/run/lighttpd.pid"
+ fi
+ /usr/sbin/lighttpd -t -f ${LIGHTTPD_CONF} >/dev/null
+}
+
+start() {
+ checkconfig || return 1
+ checkpath -d -q -m 0750 -o lighttpd:lighttpd /run/lighttpd/
+
+ ebegin "Starting lighttpd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/lighttpd \
+ --pidfile "${LIGHTTPD_PID}" -- -f "${LIGHTTPD_CONF}"
+ eend $?
+}
+
+stop() {
+ local rv=0
+ ebegin "Stopping lighttpd"
+ start-stop-daemon --stop --quiet --pidfile "${LIGHTTPD_PID}"
+ eend $?
+}
+
+reload() {
+ if ! service_started "${SVCNAME}" ; then
+ eerror "${SVCNAME} isn't running"
+ return 1
+ fi
+ checkconfig || return 1
+
+ ebegin "Re-opening lighttpd log files"
+ start-stop-daemon --quiet --pidfile "${LIGHTTPD_PID}" \
+ --signal HUP
+ eend $?
+}
+
+graceful() {
+ if ! service_started "${SVCNAME}" ; then
+ eerror "${SVCNAME} isn't running"
+ return 1
+ fi
+ checkconfig || return 1
+
+ ebegin "Gracefully stopping lighttpd"
+ start-stop-daemon --quiet --pidfile "${LIGHTTPD_PID}" \
+ --signal INT
+ if eend $? ; then
+ rm -f "${LIGHTTPD_PID}"
+ start
+ fi
+}
diff --git a/system/lighttpd/lighttpd.logrotate b/system/lighttpd/lighttpd.logrotate
new file mode 100644
index 000000000..8fbb20fb0
--- /dev/null
+++ b/system/lighttpd/lighttpd.logrotate
@@ -0,0 +1,15 @@
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/lighttpd.logrotate,v 1.2 2006/05/30 19:49:29 bangert Exp $
+# lighttpd logrotate script for Gentoo
+
+/var/log/lighttpd/*.log {
+ daily
+ missingok
+ copytruncate
+ rotate 7
+ compress
+ notifempty
+ sharedscripts
+ postrotate
+ /etc/init.d/lighttpd --quiet --ifstarted reload
+ endscript
+}
diff --git a/system/lighttpd/lighttpd.pre-install b/system/lighttpd/lighttpd.pre-install
new file mode 100644
index 000000000..81ccda1f9
--- /dev/null
+++ b/system/lighttpd/lighttpd.pre-install
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+addgroup -S -g 82 www-data 2>/dev/null
+addgroup -S lighttpd 2>/dev/null
+adduser -S -D -H -h /var/www/localhost/htdocs -s /sbin/nologin -G lighttpd -g lighttpd lighttpd 2>/dev/null
+addgroup lighttpd www-data 2>/dev/null
+
+exit 0
diff --git a/system/lighttpd/lighttpd.pre-upgrade b/system/lighttpd/lighttpd.pre-upgrade
new file mode 120000
index 000000000..18a7fef66
--- /dev/null
+++ b/system/lighttpd/lighttpd.pre-upgrade
@@ -0,0 +1 @@
+lighttpd.pre-install \ No newline at end of file
diff --git a/system/lighttpd/mime-types.conf b/system/lighttpd/mime-types.conf
new file mode 100644
index 000000000..f24d4d858
--- /dev/null
+++ b/system/lighttpd/mime-types.conf
@@ -0,0 +1,79 @@
+###############################################################################
+# Default mime-types.conf for Gentoo.
+# include'd from lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mime-types.conf,v 1.4 2010/03/14 21:45:18 bangert Exp $
+###############################################################################
+
+# {{{ mime types
+mimetype.assign = (
+ ".svg" => "image/svg+xml",
+ ".svgz" => "image/svg+xml",
+ ".pdf" => "application/pdf",
+ ".sig" => "application/pgp-signature",
+ ".spl" => "application/futuresplash",
+ ".class" => "application/octet-stream",
+ ".ps" => "application/postscript",
+ ".torrent" => "application/x-bittorrent",
+ ".dvi" => "application/x-dvi",
+ ".gz" => "application/x-gzip",
+ ".pac" => "application/x-ns-proxy-autoconfig",
+ ".swf" => "application/x-shockwave-flash",
+ ".tar.gz" => "application/x-tgz",
+ ".tgz" => "application/x-tgz",
+ ".tar" => "application/x-tar",
+ ".zip" => "application/zip",
+ ".dmg" => "application/x-apple-diskimage",
+ ".mp3" => "audio/mpeg",
+ ".m3u" => "audio/x-mpegurl",
+ ".wma" => "audio/x-ms-wma",
+ ".wax" => "audio/x-ms-wax",
+ ".ogg" => "application/ogg",
+ ".wav" => "audio/x-wav",
+ ".gif" => "image/gif",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".png" => "image/png",
+ ".xbm" => "image/x-xbitmap",
+ ".xpm" => "image/x-xpixmap",
+ ".xwd" => "image/x-xwindowdump",
+ ".css" => "text/css",
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".js" => "text/javascript",
+ ".asc" => "text/plain",
+ ".c" => "text/plain",
+ ".h" => "text/plain",
+ ".cc" => "text/plain",
+ ".cpp" => "text/plain",
+ ".hh" => "text/plain",
+ ".hpp" => "text/plain",
+ ".conf" => "text/plain",
+ ".log" => "text/plain",
+ ".text" => "text/plain",
+ ".txt" => "text/plain",
+ ".diff" => "text/plain",
+ ".patch" => "text/plain",
+ ".ebuild" => "text/plain",
+ ".eclass" => "text/plain",
+ ".rtf" => "application/rtf",
+ ".bmp" => "image/bmp",
+ ".tif" => "image/tiff",
+ ".tiff" => "image/tiff",
+ ".ico" => "image/x-icon",
+ ".dtd" => "text/xml",
+ ".xml" => "text/xml",
+ ".mpeg" => "video/mpeg",
+ ".mpg" => "video/mpeg",
+ ".mov" => "video/quicktime",
+ ".qt" => "video/quicktime",
+ ".avi" => "video/x-msvideo",
+ ".asf" => "video/x-ms-asf",
+ ".asx" => "video/x-ms-asf",
+ ".wmv" => "video/x-ms-wmv",
+ ".bz2" => "application/x-bzip",
+ ".tbz" => "application/x-bzip-compressed-tar",
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
+ )
+# }}}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/system/lighttpd/mod_cgi.conf b/system/lighttpd/mod_cgi.conf
new file mode 100644
index 000000000..1cb3770f9
--- /dev/null
+++ b/system/lighttpd/mod_cgi.conf
@@ -0,0 +1,33 @@
+###############################################################################
+# mod_cgi.conf
+# include'd by lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mod_cgi.conf,v 1.1 2005/08/27 12:36:13 ka0ttic Exp $
+###############################################################################
+
+#
+# see cgi.txt for more information on using mod_cgi
+#
+
+server.modules += ("mod_cgi")
+
+# NOTE: this requires mod_alias
+alias.url = (
+ "/cgi-bin/" => var.basedir + "/cgi-bin/"
+)
+
+#
+# Note that you'll also want to enable the
+# cgi-bin alias via mod_alias (above).
+#
+
+$HTTP["url"] =~ "^/cgi-bin/" {
+ # disable directory listings
+ dir-listing.activate = "disable"
+ # only allow cgi's in this directory
+ cgi.assign = (
+ ".pl" => "/usr/bin/perl",
+ ".cgi" => "/usr/bin/perl"
+ )
+}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/system/lighttpd/mod_fastcgi.conf b/system/lighttpd/mod_fastcgi.conf
new file mode 100644
index 000000000..549b84c2e
--- /dev/null
+++ b/system/lighttpd/mod_fastcgi.conf
@@ -0,0 +1,17 @@
+###############################################################################
+# mod_fastcgi.conf
+# include'd by lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mod_fastcgi.conf-1.4.13-r2,v 1.1 2007/04/01 23:22:00 robbat2 Exp $
+###############################################################################
+
+server.modules += ("mod_fastcgi")
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "socket" => "/run/lighttpd/lighttpd-fastcgi-php-" + PID + ".socket",
+ "bin-path" => "/usr/bin/php-cgi"
+ )
+ )
+ )
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/system/lighttpd/mod_fastcgi_fpm.conf b/system/lighttpd/mod_fastcgi_fpm.conf
new file mode 100644
index 000000000..926137a43
--- /dev/null
+++ b/system/lighttpd/mod_fastcgi_fpm.conf
@@ -0,0 +1,16 @@
+###############################################################################
+# mod_fastcgi_fpm.conf
+# include'd by lighttpd.conf.
+###############################################################################
+
+server.modules += ("mod_fastcgi")
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "host" => "127.0.0.1",
+ "port" => "9000"
+ )
+ )
+ )
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/system/linux-pam/APKBUILD b/system/linux-pam/APKBUILD
new file mode 100644
index 000000000..f55963c5c
--- /dev/null
+++ b/system/linux-pam/APKBUILD
@@ -0,0 +1,91 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: William Pitcock <nenolod@dereferenced.org>
+pkgname=linux-pam
+pkgver=1.3.0
+pkgrel=1
+pkgdesc="pluggable authentication modules for linux"
+url="http://www.kernel.org/pub/linux/libs/pam"
+arch="all"
+license="BSD"
+depends_dev="gettext-dev"
+makedepends_host="$depends_dev"
+makedepends_build="$depends_dev bison flex-dev autoconf automake libtool"
+makedepends="$makedepends_host $makedepends_build"
+options="suid !check"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://linux-pam.org/library/Linux-PAM-$pkgver.tar.bz2
+ fix-compat.patch
+ libpam-fix-build-with-eglibc-2.16.patch
+ musl-fix-pam_exec.patch
+
+ base-auth.pamd
+ base-account.pamd
+ base-password.pamd
+ base-session.pamd
+ base-session-noninteractive.pamd
+ other.pamd
+ su.pamd
+ "
+
+builddir="$srcdir"/Linux-PAM-$pkgver
+prepare() {
+ cd "$builddir"
+ default_prepare
+ # disable insecure modules
+ sed -e 's/pam_rhosts//g' -i modules/Makefile.am
+}
+
+build() {
+ cd "$builddir"
+ autoreconf -vif
+ [ "$CLIBC" = "musl" ] && export ac_cv_search_crypt=no
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --libdir=/lib \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --disable-nls \
+ --disable-db
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ # do not install pam.d files bundled with the source, they could be broken
+ rm -rf "$pkgdir"/etc/pam.d
+
+ # install our pam.d files
+ mkdir "$pkgdir"/etc/pam.d
+ for i in $source; do
+ case $i in
+ *.pamd)
+ basename=$(echo $i | cut -d. -f1)
+ cp "$srcdir"/$i "$pkgdir"/etc/pam.d/"$basename"
+ # ensure users can use PAM services without SUID
+ chmod 644 "$pkgdir"/etc/pam.d/"$basename"
+ ;;
+ esac
+ done
+
+ # delete pointless libtool archives.
+ chgrp shadow "$pkgdir"/sbin/unix_chkpwd \
+ && chmod g+s "$pkgdir"/sbin/unix_chkpwd
+}
+
+sha512sums="4a89ca4b6f4676107aca4018f7c11addf03495266b209cb11c913f8b5d191d9a1f72197715dcf2a69216b4036de88780bcbbb5a8652e386910d71ba1b6282e42 Linux-PAM-1.3.0.tar.bz2
+52b97e23084f7b835ce1fa441663f91a50ea797cb38ba2c6662bcdaf0d25ba487118442674ac347fb17353af126dd6b3b696612faa56cac428dd842d14e1c90d fix-compat.patch
+f49edf3876cc6bcb87bbea4e7beaeb0a382d596898c755f5fbaf6c2ed4e0c8f082b2cd16dde8a74af82bb09a1334f463e07a4bb5b8a48f023ff90a67ad2fdd44 libpam-fix-build-with-eglibc-2.16.patch
+bc443d2a9b1d90b81959ce6fa154042365d5e7840f8696f847a145bbaaeffcbe1e9cd2b8ba76131a7b48737929e281f4fe864582fa4fc40315f2d10c650e0cd9 musl-fix-pam_exec.patch
+0672ab21adb969af2a0082e2559f1196d8a4f8b1cff2836f97e5f24edb03b6aed156c61cf335a4df978e423dcd9934ffee8cb5784ed5dde704d7e5ddec4ba9f6 base-auth.pamd
+85462201a4044c7e170e617d39b0eceb4790abc6c0504999117548030a16d80a9d2078d1ad97690d7d346e6374201f0c52e792ccb08ce2b1c4bbf0cc2be96f5b base-account.pamd
+8223b815148c3b9b874d2c283840f6428c266e56c7cf49ce8fc508c4945ae31c837bef96dab17f64a60812d1c9cd0055cf0a50d7951d23070b69bd2e5bb9666d base-password.pamd
+b0138f662715974bd865d755c5e7d403faf5b9ad1b7e2b1d1598ad7eb5764a9ff407f1a5e6ce7f16db9fc10f8d643323b494563416fd6a654032529b52213c5b base-session.pamd
+444e20046843057b17c0aac14d2b71a68923b989b3d8b478bbf684698673683186e928e5ca2e6cb9a1c76abc4248044a0e10ef6b06b3f51857106796ecce250d base-session-noninteractive.pamd
+d103ba06b2c4929171e09c845f9866539220cd20d8d56a03d25850342ef5eabe281e958dfe1eaefd550c00f9440e8700c1d74c88c3001f933134ca6fd7cb9b7b other.pamd
+b512d691f2a6b11fc329bf91dd05ca9c589bbd444308b27d3c87c75262dedf6afc68a9739229249a4bd3d0c43cb1f871eecbb93c4fe559e0f38bdabbffd06ad7 su.pamd"
diff --git a/system/linux-pam/base-account.pamd b/system/linux-pam/base-account.pamd
new file mode 100644
index 000000000..591092944
--- /dev/null
+++ b/system/linux-pam/base-account.pamd
@@ -0,0 +1,3 @@
+# basic PAM configuration for Alpine.
+
+account required pam_unix.so
diff --git a/system/linux-pam/base-auth.pamd b/system/linux-pam/base-auth.pamd
new file mode 100644
index 000000000..012445aa3
--- /dev/null
+++ b/system/linux-pam/base-auth.pamd
@@ -0,0 +1,5 @@
+# basic PAM configuration for Alpine.
+
+auth required pam_env.so
+auth required pam_unix.so nullok_secure
+auth required pam_nologin.so successok
diff --git a/system/linux-pam/base-password.pamd b/system/linux-pam/base-password.pamd
new file mode 100644
index 000000000..a146a93fe
--- /dev/null
+++ b/system/linux-pam/base-password.pamd
@@ -0,0 +1,3 @@
+# basic PAM configuration for Alpine.
+
+password required pam_unix.so nullok obscure md5 sha512
diff --git a/system/linux-pam/base-session-noninteractive.pamd b/system/linux-pam/base-session-noninteractive.pamd
new file mode 100644
index 000000000..85e07d594
--- /dev/null
+++ b/system/linux-pam/base-session-noninteractive.pamd
@@ -0,0 +1,4 @@
+# basic PAM configuration for Alpine.
+
+session required pam_limits.so
+session required pam_unix.so
diff --git a/system/linux-pam/base-session.pamd b/system/linux-pam/base-session.pamd
new file mode 100644
index 000000000..bf5bcb734
--- /dev/null
+++ b/system/linux-pam/base-session.pamd
@@ -0,0 +1,4 @@
+# basic PAM configuration for Alpine.
+
+session include base-session-noninteractive
+session required pam_motd.so
diff --git a/system/linux-pam/fix-compat.patch b/system/linux-pam/fix-compat.patch
new file mode 100644
index 000000000..4096c3a47
--- /dev/null
+++ b/system/linux-pam/fix-compat.patch
@@ -0,0 +1,21 @@
+--- Linux-PAM-1.1.6.orig/modules/pam_lastlog/pam_lastlog.c
++++ Linux-PAM-1.1.6/modules/pam_lastlog/pam_lastlog.c
+@@ -10,6 +10,7 @@
+
+ #include "config.h"
+
++#include <paths.h>
+ #include <fcntl.h>
+ #include <time.h>
+ #include <errno.h>
+@@ -48,6 +49,10 @@
+
+ #ifndef _PATH_BTMP
+ # define _PATH_BTMP "/var/log/btmp"
++#endif
++
++#ifndef __GLIBC__
++#define logwtmp(args...)
+ #endif
+
+ /* XXX - time before ignoring lock. Is 1 sec enough? */
diff --git a/system/linux-pam/libpam-fix-build-with-eglibc-2.16.patch b/system/linux-pam/libpam-fix-build-with-eglibc-2.16.patch
new file mode 100644
index 000000000..1a0716598
--- /dev/null
+++ b/system/linux-pam/libpam-fix-build-with-eglibc-2.16.patch
@@ -0,0 +1,10 @@
+--- Linux-PAM-1.1.5/modules/pam_unix/pam_unix_acct.c.orig
++++ Linux-PAM-1.1.5/modules/pam_unix/pam_unix_acct.c
+@@ -47,6 +47,7 @@
+ #include <time.h> /* for time() */
+ #include <errno.h>
+ #include <sys/wait.h>
++#include <sys/resource.h>
+
+ #include <security/_pam_macros.h>
+
diff --git a/system/linux-pam/musl-fix-pam_exec.patch b/system/linux-pam/musl-fix-pam_exec.patch
new file mode 100644
index 000000000..b6b999fae
--- /dev/null
+++ b/system/linux-pam/musl-fix-pam_exec.patch
@@ -0,0 +1,31 @@
+--- ./modules/pam_exec/pam_exec.c.orig
++++ ./modules/pam_exec/pam_exec.c
+@@ -103,11 +103,14 @@
+ int optargc;
+ const char *logfile = NULL;
+ const char *authtok = NULL;
++ char authtok_buf[PAM_MAX_RESP_SIZE+1];
++
+ pid_t pid;
+ int fds[2];
+ int stdout_fds[2];
+ FILE *stdout_file = NULL;
+
++ memset(authtok_buf, 0, sizeof(authtok_buf));
+ if (argc < 1) {
+ pam_syslog (pamh, LOG_ERR,
+ "This module needs at least one argument");
+@@ -178,11 +181,11 @@
+ }
+
+ pam_set_item (pamh, PAM_AUTHTOK, resp);
+- authtok = strndupa (resp, PAM_MAX_RESP_SIZE);
++ authtok = strncpy(authtok_buf, resp, sizeof(authtok_buf));
+ _pam_drop (resp);
+ }
+ else
+- authtok = strndupa (void_pass, PAM_MAX_RESP_SIZE);
++ authtok = strncpy(authtok_buf, void_pass, sizeof(authtok_buf));
+
+ if (pipe(fds) != 0)
+ {
diff --git a/system/linux-pam/other.pamd b/system/linux-pam/other.pamd
new file mode 100644
index 000000000..8c9797e71
--- /dev/null
+++ b/system/linux-pam/other.pamd
@@ -0,0 +1,6 @@
+# basic PAM configuration for Alpine.
+
+auth include base-auth
+account include base-account
+password include base-password
+session include base-session-noninteractive
diff --git a/system/linux-pam/su.pamd b/system/linux-pam/su.pamd
new file mode 100644
index 000000000..84f2ae7ea
--- /dev/null
+++ b/system/linux-pam/su.pamd
@@ -0,0 +1,6 @@
+# basic PAM configuration for Alpine.
+auth sufficient pam_rootok.so
+auth include base-auth
+account include base-account
+password include base-password
+session include base-session-noninteractive
diff --git a/system/lm_sensors/APKBUILD b/system/lm_sensors/APKBUILD
new file mode 100644
index 000000000..694adb868
--- /dev/null
+++ b/system/lm_sensors/APKBUILD
@@ -0,0 +1,85 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lm_sensors
+pkgver=3.4.0
+pkgrel=5
+pkgdesc="Collection of user space tools for general SMBus access and hardware monitoring."
+url="http://www.lm-sensors.org/"
+arch="all"
+license="GPL"
+options="!check" # No test suite.
+depends="bash sysfsutils"
+makedepends="perl rrdtool-dev bison flex which"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-detect $pkgname-sensord
+ $pkgname-sensord-openrc:sensord_openrc"
+#install=sensors.install
+
+# 2015-11-11 (bpiotrowski): upstream website is down, Fedora mirrored the file
+#source="http://dl.lm-sensors.org/lm-sensors/releases/$pkgname-$pkgver.tar.bz2
+source="http://pkgs.fedoraproject.org/repo/pkgs/lm_sensors/lm_sensors-3.4.0.tar.bz2/c03675ae9d43d60322110c679416901a/lm_sensors-3.4.0.tar.bz2
+ sensors-detect-alpine.patch
+ musl-fix-includes.patch
+ fancontrol.initd
+ sensord.confd
+ sensord.initd
+ "
+
+prepare() {
+ cd "$builddir"
+ sed -i -e 's:^# \(PROG_EXTRA\):\1:' Makefile
+ # Respect LDFLAGS
+ sed -i -e 's/\$(LIBDIR)$/\$(LIBDIR) \$(LDFLAGS)/g' Makefile
+ sed -i -e 's/\$(LIBSHSONAME) -o/$(LIBSHSONAME) \$(LDFLAGS) -o/g' \
+ lib/Module.mk
+
+ # do not check for libiconv in ldconfig cache
+ sed -i -e 's/^LIBICONV.*/LIBICONV ?=/' prog/sensors/Module.mk
+
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ export CFLAGS="$CFLAGS -fno-stack-protector"
+ make PREFIX=/usr user
+}
+
+package() {
+ cd "$builddir"
+ make PROG_EXTRA:=sensord user_install \
+ PREFIX=/usr \
+ MANDIR=/usr/share/man \
+ DESTDIR="$pkgdir"
+
+ cd "$srcdir"
+ install -Dm755 fancontrol.initd "$pkgdir"/etc/init.d/fancontrol
+}
+
+detect() {
+ depends="perl"
+ pkgdesc="Detection/migration scripts for lm_sensors"
+ mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/sbin
+ cd "$pkgdir"
+ mv usr/bin/sensors-conf-convert "$subpkgdir"/usr/bin/
+ mv usr/sbin/sensors-detect "$subpkgdir"/usr/bin/
+}
+
+sensord() {
+ pkgdesc="sensord daemon"
+ cd "$builddir"
+ mkdir -p "$subpkgdir"/usr/sbin
+ mv "$pkgdir"/usr/sbin/sensord "$subpkgdir"/usr/sbin/sensord
+}
+
+sensord_openrc() {
+ pkgdesc="sensord daemon (OpenRC init scripts)"
+ install_if="sensord=$pkgver-r$pkgrel openrc"
+ install -Dm755 "$srcdir"/sensord.initd "$subpkgdir"/etc/init.d/sensord
+ install -Dm755 "$srcdir"/sensord.confd "$subpkgdir"/etc/conf.d/sensord
+}
+
+sha512sums="993064bd14b855c1ae8c057e89313df5b3d5efe441fb2e8c3e508f42bb15658564df2563fac8fabbdb0d650dfdbc694037736c748d45cb9d85dfb8fb5a3d1ea9 lm_sensors-3.4.0.tar.bz2
+794cf2aaa2a9e809c6b67f4c888a89064bba3e5b9333a9f0101a92372c25012e506fa48e86523f57cf30e5c2a808bc38058fd8640c870ea6b48faab44794cfbb sensors-detect-alpine.patch
+333751cb580c94f2d32ef5520d2f2acc0ef7e1cd4a6390ea75cae4c755fbdfcade1805c979ba3319905f1267bdc120a6746e6f70d89e0c72a8c2faefd34a9e79 musl-fix-includes.patch
+04756c3844033dc7897e1348181140a43f8470c1bb863f1524b21bbe6be2f13fbf17ac3a68270c96a70d8c148124fea569d1ef75619bbe383e15ec705ea18b21 fancontrol.initd
+a77d81ab7ded085ba19e4c637e93268f889ccb8ce9e008a210ae135cb6e2140be07e5d455cf7fcc1084fd57cfbfb3f2bb37207123aebe9566f78b5183806fd7d sensord.confd
+9a19874c158e82ab076ed5fb96a40d4bfb4957bfd5a2ce66aa207c06e577bc1b048336c0046a9f856f6d00dc10e68a0dc9726f6e726a8f7bfd50c4043ee1e26a sensord.initd"
diff --git a/system/lm_sensors/fancontrol.initd b/system/lm_sensors/fancontrol.initd
new file mode 100644
index 000000000..cb29a9ee9
--- /dev/null
+++ b/system/lm_sensors/fancontrol.initd
@@ -0,0 +1,33 @@
+#!/sbin/openrc-run
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/files/fancontrol-init.d,v 1.1 2007/05/17 07:31:41 phreak Exp $
+
+CONFIG=/etc/fancontrol
+PID=/var/run/fancontrol.pid
+
+depend() {
+ after lm_sensors
+}
+
+checkconfig() {
+ if [ ! -f ${CONFIG} ]; then
+ eerror "Configuration file ${CONFIG} not found"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting fancontrol"
+ start-stop-daemon --start --quiet --background --pidfile ${PID} \
+ --exec /usr/sbin/fancontrol -- ${CONFIG}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping fancontrol"
+ start-stop-daemon --stop --pidfile ${PID}
+ eend ${?}
+}
diff --git a/system/lm_sensors/musl-fix-includes.patch b/system/lm_sensors/musl-fix-includes.patch
new file mode 100644
index 000000000..501f2dd76
--- /dev/null
+++ b/system/lm_sensors/musl-fix-includes.patch
@@ -0,0 +1,62 @@
+--- lm_sensors-3.3.4.orig/prog/dump/isadump.c
++++ lm_sensors-3.3.4/prog/dump/isadump.c
+@@ -36,13 +36,7 @@
+ #include "util.h"
+ #include "superio.h"
+
+-
+-/* To keep glibc2 happy */
+-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 0
+ #include <sys/io.h>
+-#else
+-#include <asm/io.h>
+-#endif
+
+ #ifdef __powerpc__
+ unsigned long isa_io_base = 0; /* XXX for now */
+--- lm_sensors-3.3.4.orig/prog/dump/isaset.c
++++ lm_sensors-3.3.4/prog/dump/isaset.c
+@@ -32,13 +32,7 @@
+ #include <string.h>
+ #include "util.h"
+
+-
+-/* To keep glibc2 happy */
+-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 0
+ #include <sys/io.h>
+-#else
+-#include <asm/io.h>
+-#endif
+
+ #ifdef __powerpc__
+ unsigned long isa_io_base = 0; /* XXX for now */
+--- lm_sensors-3.3.4.orig/prog/dump/superio.c
++++ lm_sensors-3.3.4/prog/dump/superio.c
+@@ -20,12 +20,7 @@
+ */
+
+ #include <stdlib.h>
+-
+-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 0
+ #include <sys/io.h>
+-#else
+-#include <asm/io.h>
+-#endif
+
+ #include "superio.h"
+
+--- lm_sensors-3.3.4.orig/prog/dump/util.c
++++ lm_sensors-3.3.4/prog/dump/util.c
+@@ -11,12 +11,7 @@
+ #include <stdio.h>
+ #include "util.h"
+
+-/* To keep glibc2 happy */
+-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ >= 0
+ #include <sys/io.h>
+-#else
+-#include <asm/io.h>
+-#endif
+
+ /* Return 1 if we should continue, 0 if we should abort */
+ int user_ack(int def)
diff --git a/system/lm_sensors/sensord.confd b/system/lm_sensors/sensord.confd
new file mode 100644
index 000000000..d82841aeb
--- /dev/null
+++ b/system/lm_sensors/sensord.confd
@@ -0,0 +1,3 @@
+# Extra options to pass to the sensord daemon,
+# see sensord(8) for more information
+SENSORD_OPTIONS=""
diff --git a/system/lm_sensors/sensord.initd b/system/lm_sensors/sensord.initd
new file mode 100644
index 000000000..c100b1aa1
--- /dev/null
+++ b/system/lm_sensors/sensord.initd
@@ -0,0 +1,33 @@
+#!/sbin/openrc-run
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/lm_sensors/files/sensord-init.d,v 1.1 2007/05/17 07:31:41 phreak Exp $
+
+CONFIG=/etc/sensors3.conf
+
+depend() {
+ need logger
+ use lm_sensors
+}
+
+checkconfig() {
+ if [ ! -f ${CONFIG} ]; then
+ eerror "Configuration file ${CONFIG} not found"
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting sensord"
+ start-stop-daemon --start --exec /usr/sbin/sensord \
+ -- --config-file ${CONFIG} ${SENSORD_OPTIONS}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping sensord"
+ start-stop-daemon --stop --pidfile /var/run/sensord.pid
+ eend ${?}
+}
diff --git a/system/lm_sensors/sensors-detect-alpine.patch b/system/lm_sensors/sensors-detect-alpine.patch
new file mode 100644
index 000000000..319fcec06
--- /dev/null
+++ b/system/lm_sensors/sensors-detect-alpine.patch
@@ -0,0 +1,47 @@
+diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
+index 08721f0..6e83e97 100755
+--- a/prog/detect/sensors-detect
++++ b/prog/detect/sensors-detect
+@@ -7059,31 +7059,20 @@ sub write_config
+ }
+ }
+
+- my $have_sysconfig = -d '/etc/sysconfig';
+- printf "Do you want to \%s /etc/sysconfig/lm_sensors? (\%s): ",
+- (-e '/etc/sysconfig/lm_sensors' ? 'overwrite' : 'generate'),
+- ($have_sysconfig ? 'YES/no' : 'yes/NO');
++ my $config = '/etc/modules-load.d/lm_sensors.conf';
++ my $have_config = -f $config;
++ printf "Do you want to \%s \%s? (\%s): ",
++ (-e $config ? 'overwrite' : 'generate'),
++ $config,
++ ($have_config ? 'YES/no' : 'yes/NO');
+ $_ = read_answer();
+- if (($have_sysconfig and not m/^\s*n/i) or m/^\s*y/i) {
+- unless ($have_sysconfig) {
+- mkdir('/etc/sysconfig', 0777)
+- or die "Sorry, can't create /etc/sysconfig ($!)";
+- }
+- open(local *SYSCONFIG, ">/etc/sysconfig/lm_sensors")
+- or die "Sorry, can't create /etc/sysconfig/lm_sensors ($!)";
++ if (($have_config and not m/^\s*n/i) or m/^\s*y/i) {
++ open(local *SYSCONFIG, ">$config")
++ or die "Sorry, can't create $config ($!)";
+ print SYSCONFIG "# Generated by sensors-detect on " . scalar localtime() . "\n";
+- print SYSCONFIG <<'EOT';
+-# This file is sourced by /etc/init.d/lm_sensors and defines the modules to
+-# be loaded/unloaded.
+-#
+-# The format of this file is a shell script that simply defines variables:
+-# HWMON_MODULES for hardware monitoring driver modules, and optionally
+-# BUS_MODULES for any required bus driver module (for example for I2C or SPI).
+-
+-EOT
+- print SYSCONFIG "BUS_MODULES=\"", join(" ", @{$bus_modules}), "\"\n"
++ print SYSCONFIG join("\n", @{$bus_modules}), "\n"
+ if @{$bus_modules};
+- print SYSCONFIG "HWMON_MODULES=\"", join(" ", @{$hwmon_modules}), "\"\n";
++ print SYSCONFIG join("\n", @{$hwmon_modules}), "\n";
+ close(SYSCONFIG);
+
+ if (-x "/bin/systemctl" && -d "/lib/systemd/system" &&
diff --git a/system/lm_sensors/sensors.install b/system/lm_sensors/sensors.install
new file mode 100644
index 000000000..d593f8414
--- /dev/null
+++ b/system/lm_sensors/sensors.install
@@ -0,0 +1,12 @@
+post_install() {
+ echo ">>> to control the lm_sensors daemon type"
+ echo ">>> \"/etc/rc.d/sensors start|stop|restart\" "
+ echo ">>> --------------------------------------"
+ echo ">>> before you can use the fancontrol daemon"
+ echo ">>> first create a fancontrol config file, use \"pwmconfig\""
+ echo ">>> then type \"/etc/rc.d/fancontrol start|stop|restart\" "
+ echo ">>> --------------------------------------"
+ echo ">>> to decode memory SPD timings modprobe eeprom module"
+ echo ">>> and get this perl script from"
+ echo ">>> \"http://www.lm-sensors.org/browser/lm-sensors/trunk/prog/eeprom/decode-dimms.pl\""
+}
diff --git a/system/ltrace/APKBUILD b/system/ltrace/APKBUILD
new file mode 100644
index 000000000..bd07768bf
--- /dev/null
+++ b/system/ltrace/APKBUILD
@@ -0,0 +1,44 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=ltrace
+pkgver=0.7.3
+pkgrel=2
+pkgdesc="Tracks runtime library calls in dynamically linked programs"
+url="http://ltrace.alioth.debian.org/"
+arch="all"
+options="!check" # Test suite has glibc stuff hardcoded.
+license="GPL-2.0+"
+makedepends="linux-headers libelf-dev autoconf automake"
+subpackages="$pkgname-doc"
+# you find latest release here, but need a login:
+# https://alioth.debian.org/frs/?group_id=30892
+source="https://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.bz2
+ musl.patch
+ aarch64.patch
+ add_ppc64le.patch"
+
+builddir="$srcdir/$pkgname-$pkgver"
+prepare() {
+ default_prepare
+ aclocal && autoconf && automake --add-missing --force
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --disable-werror
+ make
+}
+
+package() {
+ cd "$builddir"
+ make install INSTALL=install DESTDIR="$pkgdir"
+}
+
+sha512sums="a842b16dcb81da869afa0bddc755fdff0d57b35672505bf2c7164fd983b1938d28b126714128930994cc1230ced69d779456d0cfc16f4008c9b6d19f0852285d ltrace-0.7.3.tar.bz2
+c53e05471c52e161a7f7389994c6467e8f3671c5d8478546bc1897f067c62aeab848d728295f339a241a3fc186e180d47bcc2872a6335877c3813b1b62834698 musl.patch
+e6682f8c9e1e049286b6462bbab03cbdcf31c1770f649be997393cbd9b3b2ce8ada93766474e16bb604624ffe3e3d46d467bfbedecac2af31b904bb4e763d43a aarch64.patch
+987c6d18bdb559e8fe739f09cfb0b567dafcf79b2bd5db7ca32ebb205f3b1d74a8008576e4d73ea90873c1ab9bed17d96ddb7ad8752bf0a160ea0638c955eb1f add_ppc64le.patch"
diff --git a/system/ltrace/aarch-part2.patch b/system/ltrace/aarch-part2.patch
new file mode 100644
index 000000000..c40d0a797
--- /dev/null
+++ b/system/ltrace/aarch-part2.patch
@@ -0,0 +1,1982 @@
+From ae7249250ea650ec82bc545d4281b852020c7a6f Mon Sep 17 00:00:00 2001
+From: Petr Machata <pmachata@redhat.com>
+Date: Fri, 24 Jan 2014 00:50:06 +0100
+Subject: [PATCH 1/1] Implement aarch64 support
+
+- IFUNC support is not implemented, the rest works well. The only
+ other failure is in wide char functions, and that occurs on x86_64
+ as well.
+---
+ configure.ac | 3 +-
+ sysdeps/linux-gnu/Makefile.am | 4 +-
+ sysdeps/linux-gnu/aarch64/Makefile.am | 25 +
+ sysdeps/linux-gnu/aarch64/arch.h | 37 ++
+ sysdeps/linux-gnu/aarch64/fetch.c | 365 +++++++++++
+ sysdeps/linux-gnu/aarch64/plt.c | 38 ++
+ sysdeps/linux-gnu/aarch64/ptrace.h | 22 +
+ sysdeps/linux-gnu/aarch64/regs.c | 130 ++++
+ sysdeps/linux-gnu/aarch64/signalent.h | 52 ++
+ sysdeps/linux-gnu/aarch64/syscallent.h | 1100 ++++++++++++++++++++++++++++++++
+ sysdeps/linux-gnu/aarch64/trace.c | 83 +++
+ 11 files changed, 1857 insertions(+), 2 deletions(-)
+ create mode 100644 sysdeps/linux-gnu/aarch64/Makefile.am
+ create mode 100644 sysdeps/linux-gnu/aarch64/arch.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/fetch.c
+ create mode 100644 sysdeps/linux-gnu/aarch64/plt.c
+ create mode 100644 sysdeps/linux-gnu/aarch64/ptrace.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/regs.c
+ create mode 100644 sysdeps/linux-gnu/aarch64/signalent.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/syscallent.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/trace.c
+
+diff --git a/configure.ac b/configure.ac
+index c6e6bf0..0e9a124 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,6 +1,6 @@
+ # -*- Autoconf -*-
+ # This file is part of ltrace.
+-# Copyright (C) 2010,2013 Petr Machata, Red Hat Inc.
++# Copyright (C) 2010,2012,2013,2014 Petr Machata, Red Hat Inc.
+ # Copyright (C) 2010,2011 Joe Damato
+ # Copyright (C) 2010 Marc Kleine-Budde
+ # Copyright (C) 2010 Zachary T Welch
+@@ -399,6 +399,7 @@ AC_CONFIG_FILES([
+ Makefile
+ sysdeps/Makefile
+ sysdeps/linux-gnu/Makefile
++ sysdeps/linux-gnu/aarch64/Makefile
+ sysdeps/linux-gnu/alpha/Makefile
+ sysdeps/linux-gnu/arm/Makefile
+ sysdeps/linux-gnu/cris/Makefile
+diff --git a/sysdeps/linux-gnu/Makefile.am b/sysdeps/linux-gnu/Makefile.am
+index ecee577..ec26162 100644
+--- a/sysdeps/linux-gnu/Makefile.am
++++ b/sysdeps/linux-gnu/Makefile.am
+@@ -1,4 +1,5 @@
+ # This file is part of ltrace.
++# Copyright (C) 2014 Petr Machata, Red Hat, Inc.
+ # Copyright (C) 2010,2012 Marc Kleine-Budde, Pengutronix
+ #
+ # This program is free software; you can redistribute it and/or
+@@ -16,7 +17,8 @@
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ # 02110-1301 USA
+
+-DIST_SUBDIRS = alpha arm cris ia64 m68k mips ppc s390 sparc x86
++DIST_SUBDIRS = aarch64 alpha arm cris ia64 m68k mips ppc s390 \
++ sparc x86
+
+ SUBDIRS = \
+ $(HOST_CPU)
+diff --git a/sysdeps/linux-gnu/aarch64/Makefile.am b/sysdeps/linux-gnu/aarch64/Makefile.am
+new file mode 100644
+index 0000000..0af4e6e
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/Makefile.am
+@@ -0,0 +1,25 @@
++# This file is part of ltrace.
++# Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++#
++# This program is free software; you can redistribute it and/or
++# modify it under the terms of the GNU General Public License as
++# published by the Free Software Foundation; either version 2 of the
++# License, or (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful, but
++# WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++# General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++# 02110-1301 USA
++
++noinst_LTLIBRARIES = ../libcpu.la
++
++___libcpu_la_SOURCES = fetch.c plt.c regs.c trace.c
++
++noinst_HEADERS = arch.h ptrace.h signalent.h syscallent.h
++
++MAINTAINERCLEANFILES = Makefile.in
+diff --git a/sysdeps/linux-gnu/aarch64/arch.h b/sysdeps/linux-gnu/aarch64/arch.h
+new file mode 100644
+index 0000000..4137613
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/arch.h
+@@ -0,0 +1,37 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++#ifndef LTRACE_AARCH64_ARCH_H
++#define LTRACE_AARCH64_ARCH_H
++
++/* | 31 21 | 20 5 | 4 0 | *
++ * | 1 1 0 1 0 1 0 0 0 0 1 | imm16 | 0 0 0 0 0 | */
++#define BREAKPOINT_VALUE { 0xd4, 0x20, 0, 0 }
++#define BREAKPOINT_LENGTH 4
++#define DECR_PC_AFTER_BREAK 0
++
++#define LT_ELFCLASS ELFCLASS64
++#define LT_ELF_MACHINE EM_AARCH64
++
++#define ARCH_HAVE_FETCH_ARG
++#define ARCH_ENDIAN_BIG
++#define ARCH_HAVE_SIZEOF
++#define ARCH_HAVE_ALIGNOF
++
++#endif /* LTRACE_AARCH64_ARCH_H */
+diff --git a/sysdeps/linux-gnu/aarch64/fetch.c b/sysdeps/linux-gnu/aarch64/fetch.c
+new file mode 100644
+index 0000000..8779f03
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/fetch.c
+@@ -0,0 +1,365 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <asm/ptrace.h>
++#include <stdlib.h>
++#include <string.h>
++
++#include "fetch.h"
++#include "proc.h"
++#include "type.h"
++#include "value.h"
++
++int aarch64_read_gregs(struct Process *proc, struct user_pt_regs *regs);
++int aarch64_read_fregs(struct Process *proc, struct user_fpsimd_state *regs);
++
++
++struct fetch_context
++{
++ struct user_pt_regs gregs;
++ struct user_fpsimd_state fpregs;
++ arch_addr_t nsaa;
++ unsigned ngrn;
++ unsigned nsrn;
++ arch_addr_t x8;
++};
++
++static int
++context_init(struct fetch_context *context, struct Process *proc)
++{
++ if (aarch64_read_gregs(proc, &context->gregs) < 0
++ || aarch64_read_fregs(proc, &context->fpregs) < 0)
++ return -1;
++
++ context->ngrn = 0;
++ context->nsrn = 0;
++ /* XXX double cast */
++ context->nsaa = (arch_addr_t) (uintptr_t) context->gregs.sp;
++ context->x8 = 0;
++
++ return 0;
++}
++
++struct fetch_context *
++arch_fetch_arg_clone(struct Process *proc, struct fetch_context *context)
++{
++ struct fetch_context *ret = malloc(sizeof(*ret));
++ if (ret == NULL)
++ return NULL;
++ return memcpy(ret, context, sizeof(*ret));
++}
++
++static void
++fetch_next_gpr(struct fetch_context *context, unsigned char *buf)
++{
++ uint64_t u = context->gregs.regs[context->ngrn++];
++ memcpy(buf, &u, 8);
++}
++
++static int
++fetch_gpr(struct fetch_context *context, struct value *value, size_t sz)
++{
++ if (sz < 8)
++ sz = 8;
++
++ unsigned char *buf = value_reserve(value, sz);
++ if (buf == NULL)
++ return -1;
++
++ size_t i;
++ for (i = 0; i < sz; i += 8)
++ fetch_next_gpr(context, buf + i);
++
++ return 0;
++}
++
++static void
++fetch_next_sse(struct fetch_context *context, unsigned char *buf, size_t sz)
++{
++ __int128 u = context->fpregs.vregs[context->nsrn++];
++ memcpy(buf, &u, sz);
++}
++
++static int
++fetch_sse(struct fetch_context *context, struct value *value, size_t sz)
++{
++ unsigned char *buf = value_reserve(value, sz);
++ if (buf == NULL)
++ return -1;
++
++ fetch_next_sse(context, buf, sz);
++ return 0;
++}
++
++static int
++fetch_hfa(struct fetch_context *context,
++ struct value *value, struct arg_type_info *hfa_t, size_t count)
++{
++ size_t sz = type_sizeof(value->inferior, hfa_t);
++ unsigned char *buf = value_reserve(value, sz * count);
++ if (buf == NULL)
++ return -1;
++
++ size_t i;
++ for (i = 0; i < count; ++i) {
++ fetch_next_sse(context, buf, sz);
++ buf += sz;
++ }
++ return 0;
++}
++
++static int
++fetch_stack(struct fetch_context *context, struct value *value,
++ size_t align, size_t sz)
++{
++ if (align < 8)
++ align = 8;
++ size_t amount = ((sz + align - 1) / align) * align;
++
++ /* XXX double casts */
++ uintptr_t sp = (uintptr_t) context->nsaa;
++ sp = ((sp + align - 1) / align) * align;
++
++ value_in_inferior(value, (arch_addr_t) sp);
++
++ sp += amount;
++ context->nsaa = (arch_addr_t) sp;
++
++ return 0;
++}
++
++enum convert_method {
++ CVT_ERR = -1,
++ CVT_NOP = 0,
++ CVT_BYREF,
++};
++
++enum fetch_method {
++ FETCH_NOP,
++ FETCH_STACK,
++ FETCH_GPR,
++ FETCH_SSE,
++ FETCH_HFA,
++};
++
++struct fetch_script {
++ enum convert_method c;
++ enum fetch_method f;
++ size_t sz;
++ struct arg_type_info *hfa_t;
++ size_t count;
++};
++
++static struct fetch_script
++pass_arg(struct fetch_context const *context,
++ struct Process *proc, struct arg_type_info *info)
++{
++ enum fetch_method cvt = CVT_NOP;
++
++ size_t sz = type_sizeof(proc, info);
++ if (sz == (size_t) -1)
++ return (struct fetch_script) { CVT_ERR, FETCH_NOP, sz };
++
++ switch (info->type) {
++ case ARGTYPE_VOID:
++ return (struct fetch_script) { cvt, FETCH_NOP, sz };
++
++ case ARGTYPE_STRUCT:
++ case ARGTYPE_ARRAY:;
++ size_t count;
++ struct arg_type_info *hfa_t = type_get_hfa_type(info, &count);
++ if (hfa_t != NULL && count <= 4) {
++ if (context->nsrn + count <= 8)
++ return (struct fetch_script)
++ { cvt, FETCH_HFA, sz, hfa_t, count };
++ return (struct fetch_script)
++ { cvt, FETCH_STACK, sz, hfa_t, count };
++ }
++
++ if (sz <= 16) {
++ size_t count = sz / 8;
++ if (context->ngrn + count <= 8)
++ return (struct fetch_script)
++ { cvt, FETCH_GPR, sz };
++ }
++
++ cvt = CVT_BYREF;
++ sz = 8;
++ /* Fall through. */
++
++ case ARGTYPE_POINTER:
++ case ARGTYPE_INT:
++ case ARGTYPE_UINT:
++ case ARGTYPE_LONG:
++ case ARGTYPE_ULONG:
++ case ARGTYPE_CHAR:
++ case ARGTYPE_SHORT:
++ case ARGTYPE_USHORT:
++ if (context->ngrn < 8 && sz <= 8)
++ return (struct fetch_script) { cvt, FETCH_GPR, sz };
++ /* We don't support types wider than 8 bytes as of
++ * now. */
++ assert(sz <= 8);
++
++ return (struct fetch_script) { cvt, FETCH_STACK, sz };
++
++ case ARGTYPE_FLOAT:
++ case ARGTYPE_DOUBLE:
++ if (context->nsrn < 8) {
++ /* ltrace doesn't support float128. */
++ assert(sz <= 8);
++ return (struct fetch_script) { cvt, FETCH_SSE, sz };
++ }
++
++ return (struct fetch_script) { cvt, FETCH_STACK, sz };
++ }
++
++ assert(! "Failed to allocate argument.");
++ abort();
++}
++
++static int
++convert_arg(struct value *value, struct fetch_script how)
++{
++ switch (how.c) {
++ case CVT_NOP:
++ return 0;
++ case CVT_BYREF:
++ return value_pass_by_reference(value);
++ case CVT_ERR:
++ return -1;
++ }
++
++ assert(! "Don't know how to convert argument.");
++ abort();
++}
++
++static int
++fetch_arg(struct fetch_context *context,
++ struct Process *proc, struct arg_type_info *info,
++ struct value *value, struct fetch_script how)
++{
++ if (convert_arg(value, how) < 0)
++ return -1;
++
++ switch (how.f) {
++ case FETCH_NOP:
++ return 0;
++
++ case FETCH_STACK:
++ if (how.hfa_t != NULL && how.count != 0 && how.count <= 8)
++ context->nsrn = 8;
++ return fetch_stack(context, value,
++ type_alignof(proc, info), how.sz);
++
++ case FETCH_GPR:
++ return fetch_gpr(context, value, how.sz);
++
++ case FETCH_SSE:
++ return fetch_sse(context, value, how.sz);
++
++ case FETCH_HFA:
++ return fetch_hfa(context, value, how.hfa_t, how.count);
++ }
++
++ assert(! "Don't know how to fetch argument.");
++ abort();
++}
++
++struct fetch_context *
++arch_fetch_arg_init(enum tof type, struct Process *proc,
++ struct arg_type_info *ret_info)
++{
++ struct fetch_context *context = malloc(sizeof *context);
++ if (context == NULL || context_init(context, proc) < 0) {
++ fail:
++ free(context);
++ return NULL;
++ }
++
++ /* There's a provision in ARMv8 parameter passing convention
++ * for returning types that, if passed as first argument to a
++ * function, would be passed on stack. For those types, x8
++ * contains an address where the return argument should be
++ * placed. The callee doesn't need to preserve the value of
++ * x8, so we need to fetch it now.
++ *
++ * To my knowledge, there are currently no types where this
++ * holds, but the code is here, utterly untested. */
++
++ struct fetch_script how = pass_arg(context, proc, ret_info);
++ if (how.c == CVT_ERR)
++ goto fail;
++ if (how.c == CVT_NOP && how.f == FETCH_STACK) {
++ /* XXX double cast. */
++ context->x8 = (arch_addr_t) (uintptr_t) context->gregs.regs[8];
++ /* See the comment above about the assert. */
++ assert(! "Unexpected: first argument passed on stack.");
++ abort();
++ }
++
++ return context;
++}
++
++int
++arch_fetch_arg_next(struct fetch_context *context, enum tof type,
++ struct Process *proc, struct arg_type_info *info,
++ struct value *value)
++{
++ return fetch_arg(context, proc, info, value,
++ pass_arg(context, proc, info));
++}
++
++int
++arch_fetch_retval(struct fetch_context *context, enum tof type,
++ struct Process *proc, struct arg_type_info *info,
++ struct value *value)
++{
++ if (context->x8 != 0) {
++ value_in_inferior(value, context->x8);
++ return 0;
++ }
++
++ if (context_init(context, proc) < 0)
++ return -1;
++
++ return fetch_arg(context, proc, info, value,
++ pass_arg(context, proc, info));
++}
++
++void
++arch_fetch_arg_done(struct fetch_context *context)
++{
++ if (context != NULL)
++ free(context);
++}
++
++size_t
++arch_type_sizeof(struct Process *proc, struct arg_type_info *arg)
++{
++ return (size_t) -2;
++}
++
++size_t
++arch_type_alignof(struct Process *proc, struct arg_type_info *arg)
++{
++ return (size_t) -2;
++}
+diff --git a/sysdeps/linux-gnu/aarch64/plt.c b/sysdeps/linux-gnu/aarch64/plt.c
+new file mode 100644
+index 0000000..29dc4c9
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/plt.c
+@@ -0,0 +1,38 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <gelf.h>
++
++#include "backend.h"
++#include "proc.h"
++#include "library.h"
++#include "ltrace-elf.h"
++
++arch_addr_t
++sym2addr(struct Process *proc, struct library_symbol *sym)
++{
++ return sym->enter_addr;
++}
++
++GElf_Addr
++arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela *rela)
++{
++ return lte->plt_addr + 32 + ndx * 16;
++}
+diff --git a/sysdeps/linux-gnu/aarch64/ptrace.h b/sysdeps/linux-gnu/aarch64/ptrace.h
+new file mode 100644
+index 0000000..283c314
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/ptrace.h
+@@ -0,0 +1,22 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <asm/ptrace.h>
+diff --git a/sysdeps/linux-gnu/aarch64/regs.c b/sysdeps/linux-gnu/aarch64/regs.c
+new file mode 100644
+index 0000000..06eb72b
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/regs.c
+@@ -0,0 +1,131 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <asm/ptrace.h>
++#include <linux/uio.h>
++#include <assert.h>
++#include <stdlib.h>
++#include <stdio.h>
++
++#include "backend.h"
++#include "proc.h"
++
++#define PC_OFF (32 * 4)
++
++int
++aarch64_read_gregs(struct Process *proc, struct user_pt_regs *regs)
++{
++ *regs = (struct user_pt_regs) {};
++ struct iovec iovec;
++ iovec.iov_base = regs;
++ iovec.iov_len = sizeof *regs;
++ return ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, &iovec) < 0
++ ? -1 : 0;
++}
++
++int
++aarch64_write_gregs(struct Process *proc, struct user_pt_regs *regs)
++{
++ struct iovec iovec;
++ iovec.iov_base = regs;
++ iovec.iov_len = sizeof *regs;
++ return ptrace(PTRACE_SETREGSET, proc->pid, NT_PRSTATUS, &iovec) < 0
++ ? -1 : 0;
++}
++
++int
++aarch64_read_fregs(struct Process *proc, struct user_fpsimd_state *regs)
++{
++ *regs = (struct user_fpsimd_state) {};
++ struct iovec iovec;
++ iovec.iov_base = regs;
++ iovec.iov_len = sizeof *regs;
++ return ptrace(PTRACE_GETREGSET, proc->pid, NT_FPREGSET, &iovec) < 0
++ ? -1 : 0;
++}
++
++arch_addr_t
++get_instruction_pointer(struct Process *proc)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_instruction_pointer: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return 0;
++ }
++
++ /*
++ char buf[128];
++ sprintf(buf, "cat /proc/%d/maps", proc->pid);
++ system(buf);
++ */
++
++ /* XXX double cast */
++ return (arch_addr_t) (uintptr_t) regs.pc;
++}
++
++void
++set_instruction_pointer(struct Process *proc, arch_addr_t addr)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_instruction_pointer: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return;
++ }
++
++ /* XXX double cast */
++ regs.pc = (uint64_t) (uintptr_t) addr;
++
++ if (aarch64_write_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_instruction_pointer: "
++ "Couldn't write registers of %d.\n", proc->pid);
++ return;
++ }
++}
++
++arch_addr_t
++get_stack_pointer(struct Process *proc)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_stack_pointer: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return 0;
++ }
++
++ /* XXX double cast */
++ return (arch_addr_t) (uintptr_t) regs.sp;
++}
++
++arch_addr_t
++get_return_addr(struct Process *proc, arch_addr_t stack_pointer)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_return_addr: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return 0;
++ }
++
++ /* XXX double cast */
++ return (arch_addr_t) (uintptr_t) regs.regs[30];
++}
+diff --git a/sysdeps/linux-gnu/aarch64/signalent.h b/sysdeps/linux-gnu/aarch64/signalent.h
+new file mode 100644
+index 0000000..bf56ebc
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/signalent.h
+@@ -0,0 +1,52 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2006 Ian Wienand
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++ "SIG_0", /* 0 */
++ "SIGHUP", /* 1 */
++ "SIGINT", /* 2 */
++ "SIGQUIT", /* 3 */
++ "SIGILL", /* 4 */
++ "SIGTRAP", /* 5 */
++ "SIGABRT", /* 6 */
++ "SIGBUS", /* 7 */
++ "SIGFPE", /* 8 */
++ "SIGKILL", /* 9 */
++ "SIGUSR1", /* 10 */
++ "SIGSEGV", /* 11 */
++ "SIGUSR2", /* 12 */
++ "SIGPIPE", /* 13 */
++ "SIGALRM", /* 14 */
++ "SIGTERM", /* 15 */
++ "SIGSTKFLT", /* 16 */
++ "SIGCHLD", /* 17 */
++ "SIGCONT", /* 18 */
++ "SIGSTOP", /* 19 */
++ "SIGTSTP", /* 20 */
++ "SIGTTIN", /* 21 */
++ "SIGTTOU", /* 22 */
++ "SIGURG", /* 23 */
++ "SIGXCPU", /* 24 */
++ "SIGXFSZ", /* 25 */
++ "SIGVTALRM", /* 26 */
++ "SIGPROF", /* 27 */
++ "SIGWINCH", /* 28 */
++ "SIGIO", /* 29 */
++ "SIGPWR", /* 30 */
++ "SIGSYS", /* 31 */
+diff --git a/sysdeps/linux-gnu/aarch64/syscallent.h b/sysdeps/linux-gnu/aarch64/syscallent.h
+new file mode 100644
+index 0000000..aca8191
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/syscallent.h
+@@ -0,0 +1,1100 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++ "io_setup", /* 0 */
++ "io_destroy", /* 1 */
++ "io_submit", /* 2 */
++ "io_cancel", /* 3 */
++ "io_getevents", /* 4 */
++ "setxattr", /* 5 */
++ "lsetxattr", /* 6 */
++ "fsetxattr", /* 7 */
++ "getxattr", /* 8 */
++ "lgetxattr", /* 9 */
++ "fgetxattr", /* 10 */
++ "listxattr", /* 11 */
++ "llistxattr", /* 12 */
++ "flistxattr", /* 13 */
++ "removexattr", /* 14 */
++ "lremovexattr", /* 15 */
++ "fremovexattr", /* 16 */
++ "getcwd", /* 17 */
++ "lookup_dcookie", /* 18 */
++ "eventfd2", /* 19 */
++ "epoll_create1", /* 20 */
++ "epoll_ctl", /* 21 */
++ "epoll_pwait", /* 22 */
++ "dup", /* 23 */
++ "dup3", /* 24 */
++ "fcntl", /* 25 */
++ "inotify_init1", /* 26 */
++ "inotify_add_watch", /* 27 */
++ "inotify_rm_watch", /* 28 */
++ "ioctl", /* 29 */
++ "ioprio_set", /* 30 */
++ "ioprio_get", /* 31 */
++ "flock", /* 32 */
++ "mknodat", /* 33 */
++ "mkdirat", /* 34 */
++ "unlinkat", /* 35 */
++ "symlinkat", /* 36 */
++ "linkat", /* 37 */
++ "renameat", /* 38 */
++ "umount2", /* 39 */
++ "mount", /* 40 */
++ "pivot_root", /* 41 */
++ "nfsservctl", /* 42 */
++ "statfs", /* 43 */
++ "fstatfs", /* 44 */
++ "truncate", /* 45 */
++ "ftruncate", /* 46 */
++ "fallocate", /* 47 */
++ "faccessat", /* 48 */
++ "chdir", /* 49 */
++ "fchdir", /* 50 */
++ "chroot", /* 51 */
++ "fchmod", /* 52 */
++ "fchmodat", /* 53 */
++ "fchownat", /* 54 */
++ "fchown", /* 55 */
++ "openat", /* 56 */
++ "close", /* 57 */
++ "vhangup", /* 58 */
++ "pipe2", /* 59 */
++ "quotactl", /* 60 */
++ "getdents64", /* 61 */
++ "lseek", /* 62 */
++ "read", /* 63 */
++ "write", /* 64 */
++ "readv", /* 65 */
++ "writev", /* 66 */
++ "pread64", /* 67 */
++ "pwrite64", /* 68 */
++ "preadv", /* 69 */
++ "pwritev", /* 70 */
++ "sendfile", /* 71 */
++ "pselect6", /* 72 */
++ "ppoll", /* 73 */
++ "signalfd4", /* 74 */
++ "vmsplice", /* 75 */
++ "splice", /* 76 */
++ "tee", /* 77 */
++ "readlinkat", /* 78 */
++ "fstatat", /* 79 */
++ "fstat", /* 80 */
++ "sync", /* 81 */
++ "fsync", /* 82 */
++ "fdatasync", /* 83 */
++ "sync_file_range", /* 84 */
++ "timerfd_create", /* 85 */
++ "timerfd_settime", /* 86 */
++ "timerfd_gettime", /* 87 */
++ "utimensat", /* 88 */
++ "acct", /* 89 */
++ "capget", /* 90 */
++ "capset", /* 91 */
++ "personality", /* 92 */
++ "exit", /* 93 */
++ "exit_group", /* 94 */
++ "waitid", /* 95 */
++ "set_tid_address", /* 96 */
++ "unshare", /* 97 */
++ "futex", /* 98 */
++ "set_robust_list", /* 99 */
++ "get_robust_list", /* 100 */
++ "nanosleep", /* 101 */
++ "getitimer", /* 102 */
++ "setitimer", /* 103 */
++ "kexec_load", /* 104 */
++ "init_module", /* 105 */
++ "delete_module", /* 106 */
++ "timer_create", /* 107 */
++ "timer_gettime", /* 108 */
++ "timer_getoverrun", /* 109 */
++ "timer_settime", /* 110 */
++ "timer_delete", /* 111 */
++ "clock_settime", /* 112 */
++ "clock_gettime", /* 113 */
++ "clock_getres", /* 114 */
++ "clock_nanosleep", /* 115 */
++ "syslog", /* 116 */
++ "ptrace", /* 117 */
++ "sched_setparam", /* 118 */
++ "sched_setscheduler", /* 119 */
++ "sched_getscheduler", /* 120 */
++ "sched_getparam", /* 121 */
++ "sched_setaffinity", /* 122 */
++ "sched_getaffinity", /* 123 */
++ "sched_yield", /* 124 */
++ "sched_get_priority_max", /* 125 */
++ "sched_get_priority_min", /* 126 */
++ "sched_rr_get_interval", /* 127 */
++ "restart_syscall", /* 128 */
++ "kill", /* 129 */
++ "tkill", /* 130 */
++ "tgkill", /* 131 */
++ "sigaltstack", /* 132 */
++ "rt_sigsuspend", /* 133 */
++ "rt_sigaction", /* 134 */
++ "rt_sigprocmask", /* 135 */
++ "rt_sigpending", /* 136 */
++ "rt_sigtimedwait", /* 137 */
++ "rt_sigqueueinfo", /* 138 */
++ "rt_sigreturn", /* 139 */
++ "setpriority", /* 140 */
++ "getpriority", /* 141 */
++ "reboot", /* 142 */
++ "setregid", /* 143 */
++ "setgid", /* 144 */
++ "setreuid", /* 145 */
++ "setuid", /* 146 */
++ "setresuid", /* 147 */
++ "getresuid", /* 148 */
++ "setresgid", /* 149 */
++ "getresgid", /* 150 */
++ "setfsuid", /* 151 */
++ "setfsgid", /* 152 */
++ "times", /* 153 */
++ "setpgid", /* 154 */
++ "getpgid", /* 155 */
++ "getsid", /* 156 */
++ "setsid", /* 157 */
++ "getgroups", /* 158 */
++ "setgroups", /* 159 */
++ "uname", /* 160 */
++ "sethostname", /* 161 */
++ "setdomainname", /* 162 */
++ "getrlimit", /* 163 */
++ "setrlimit", /* 164 */
++ "getrusage", /* 165 */
++ "umask", /* 166 */
++ "prctl", /* 167 */
++ "getcpu", /* 168 */
++ "gettimeofday", /* 169 */
++ "settimeofday", /* 170 */
++ "adjtimex", /* 171 */
++ "getpid", /* 172 */
++ "getppid", /* 173 */
++ "getuid", /* 174 */
++ "geteuid", /* 175 */
++ "getgid", /* 176 */
++ "getegid", /* 177 */
++ "gettid", /* 178 */
++ "sysinfo", /* 179 */
++ "mq_open", /* 180 */
++ "mq_unlink", /* 181 */
++ "mq_timedsend", /* 182 */
++ "mq_timedreceive", /* 183 */
++ "mq_notify", /* 184 */
++ "mq_getsetattr", /* 185 */
++ "msgget", /* 186 */
++ "msgctl", /* 187 */
++ "msgrcv", /* 188 */
++ "msgsnd", /* 189 */
++ "semget", /* 190 */
++ "semctl", /* 191 */
++ "semtimedop", /* 192 */
++ "semop", /* 193 */
++ "shmget", /* 194 */
++ "shmctl", /* 195 */
++ "shmat", /* 196 */
++ "shmdt", /* 197 */
++ "socket", /* 198 */
++ "socketpair", /* 199 */
++ "bind", /* 200 */
++ "listen", /* 201 */
++ "accept", /* 202 */
++ "connect", /* 203 */
++ "getsockname", /* 204 */
++ "getpeername", /* 205 */
++ "sendto", /* 206 */
++ "recvfrom", /* 207 */
++ "setsockopt", /* 208 */
++ "getsockopt", /* 209 */
++ "shutdown", /* 210 */
++ "sendmsg", /* 211 */
++ "recvmsg", /* 212 */
++ "readahead", /* 213 */
++ "brk", /* 214 */
++ "munmap", /* 215 */
++ "mremap", /* 216 */
++ "add_key", /* 217 */
++ "request_key", /* 218 */
++ "keyctl", /* 219 */
++ "clone", /* 220 */
++ "execve", /* 221 */
++ "mmap", /* 222 */
++ "fadvise64", /* 223 */
++ "swapon", /* 224 */
++ "swapoff", /* 225 */
++ "mprotect", /* 226 */
++ "msync", /* 227 */
++ "mlock", /* 228 */
++ "munlock", /* 229 */
++ "mlockall", /* 230 */
++ "munlockall", /* 231 */
++ "mincore", /* 232 */
++ "madvise", /* 233 */
++ "remap_file_pages", /* 234 */
++ "mbind", /* 235 */
++ "get_mempolicy", /* 236 */
++ "set_mempolicy", /* 237 */
++ "migrate_pages", /* 238 */
++ "move_pages", /* 239 */
++ "rt_tgsigqueueinfo", /* 240 */
++ "perf_event_open", /* 241 */
++ "accept4", /* 242 */
++ "recvmmsg", /* 243 */
++ "arch_specific_syscall", /* 244 */
++ "245", /* 245 */
++ "246", /* 246 */
++ "247", /* 247 */
++ "248", /* 248 */
++ "249", /* 249 */
++ "250", /* 250 */
++ "251", /* 251 */
++ "252", /* 252 */
++ "253", /* 253 */
++ "254", /* 254 */
++ "255", /* 255 */
++ "256", /* 256 */
++ "257", /* 257 */
++ "258", /* 258 */
++ "259", /* 259 */
++ "wait4", /* 260 */
++ "prlimit64", /* 261 */
++ "fanotify_init", /* 262 */
++ "fanotify_mark", /* 263 */
++ "name_to_handle_at", /* 264 */
++ "open_by_handle_at", /* 265 */
++ "clock_adjtime", /* 266 */
++ "syncfs", /* 267 */
++ "setns", /* 268 */
++ "sendmmsg", /* 269 */
++ "process_vm_readv", /* 270 */
++ "process_vm_writev", /* 271 */
++ "kcmp", /* 272 */
++ "finit_module", /* 273 */
++ "syscalls", /* 274 */
++ "275", /* 275 */
++ "276", /* 276 */
++ "277", /* 277 */
++ "278", /* 278 */
++ "279", /* 279 */
++ "280", /* 280 */
++ "281", /* 281 */
++ "282", /* 282 */
++ "283", /* 283 */
++ "284", /* 284 */
++ "285", /* 285 */
++ "286", /* 286 */
++ "287", /* 287 */
++ "288", /* 288 */
++ "289", /* 289 */
++ "290", /* 290 */
++ "291", /* 291 */
++ "292", /* 292 */
++ "293", /* 293 */
++ "294", /* 294 */
++ "295", /* 295 */
++ "296", /* 296 */
++ "297", /* 297 */
++ "298", /* 298 */
++ "299", /* 299 */
++ "300", /* 300 */
++ "301", /* 301 */
++ "302", /* 302 */
++ "303", /* 303 */
++ "304", /* 304 */
++ "305", /* 305 */
++ "306", /* 306 */
++ "307", /* 307 */
++ "308", /* 308 */
++ "309", /* 309 */
++ "310", /* 310 */
++ "311", /* 311 */
++ "312", /* 312 */
++ "313", /* 313 */
++ "314", /* 314 */
++ "315", /* 315 */
++ "316", /* 316 */
++ "317", /* 317 */
++ "318", /* 318 */
++ "319", /* 319 */
++ "320", /* 320 */
++ "321", /* 321 */
++ "322", /* 322 */
++ "323", /* 323 */
++ "324", /* 324 */
++ "325", /* 325 */
++ "326", /* 326 */
++ "327", /* 327 */
++ "328", /* 328 */
++ "329", /* 329 */
++ "330", /* 330 */
++ "331", /* 331 */
++ "332", /* 332 */
++ "333", /* 333 */
++ "334", /* 334 */
++ "335", /* 335 */
++ "336", /* 336 */
++ "337", /* 337 */
++ "338", /* 338 */
++ "339", /* 339 */
++ "340", /* 340 */
++ "341", /* 341 */
++ "342", /* 342 */
++ "343", /* 343 */
++ "344", /* 344 */
++ "345", /* 345 */
++ "346", /* 346 */
++ "347", /* 347 */
++ "348", /* 348 */
++ "349", /* 349 */
++ "350", /* 350 */
++ "351", /* 351 */
++ "352", /* 352 */
++ "353", /* 353 */
++ "354", /* 354 */
++ "355", /* 355 */
++ "356", /* 356 */
++ "357", /* 357 */
++ "358", /* 358 */
++ "359", /* 359 */
++ "360", /* 360 */
++ "361", /* 361 */
++ "362", /* 362 */
++ "363", /* 363 */
++ "364", /* 364 */
++ "365", /* 365 */
++ "366", /* 366 */
++ "367", /* 367 */
++ "368", /* 368 */
++ "369", /* 369 */
++ "370", /* 370 */
++ "371", /* 371 */
++ "372", /* 372 */
++ "373", /* 373 */
++ "374", /* 374 */
++ "375", /* 375 */
++ "376", /* 376 */
++ "377", /* 377 */
++ "378", /* 378 */
++ "379", /* 379 */
++ "380", /* 380 */
++ "381", /* 381 */
++ "382", /* 382 */
++ "383", /* 383 */
++ "384", /* 384 */
++ "385", /* 385 */
++ "386", /* 386 */
++ "387", /* 387 */
++ "388", /* 388 */
++ "389", /* 389 */
++ "390", /* 390 */
++ "391", /* 391 */
++ "392", /* 392 */
++ "393", /* 393 */
++ "394", /* 394 */
++ "395", /* 395 */
++ "396", /* 396 */
++ "397", /* 397 */
++ "398", /* 398 */
++ "399", /* 399 */
++ "400", /* 400 */
++ "401", /* 401 */
++ "402", /* 402 */
++ "403", /* 403 */
++ "404", /* 404 */
++ "405", /* 405 */
++ "406", /* 406 */
++ "407", /* 407 */
++ "408", /* 408 */
++ "409", /* 409 */
++ "410", /* 410 */
++ "411", /* 411 */
++ "412", /* 412 */
++ "413", /* 413 */
++ "414", /* 414 */
++ "415", /* 415 */
++ "416", /* 416 */
++ "417", /* 417 */
++ "418", /* 418 */
++ "419", /* 419 */
++ "420", /* 420 */
++ "421", /* 421 */
++ "422", /* 422 */
++ "423", /* 423 */
++ "424", /* 424 */
++ "425", /* 425 */
++ "426", /* 426 */
++ "427", /* 427 */
++ "428", /* 428 */
++ "429", /* 429 */
++ "430", /* 430 */
++ "431", /* 431 */
++ "432", /* 432 */
++ "433", /* 433 */
++ "434", /* 434 */
++ "435", /* 435 */
++ "436", /* 436 */
++ "437", /* 437 */
++ "438", /* 438 */
++ "439", /* 439 */
++ "440", /* 440 */
++ "441", /* 441 */
++ "442", /* 442 */
++ "443", /* 443 */
++ "444", /* 444 */
++ "445", /* 445 */
++ "446", /* 446 */
++ "447", /* 447 */
++ "448", /* 448 */
++ "449", /* 449 */
++ "450", /* 450 */
++ "451", /* 451 */
++ "452", /* 452 */
++ "453", /* 453 */
++ "454", /* 454 */
++ "455", /* 455 */
++ "456", /* 456 */
++ "457", /* 457 */
++ "458", /* 458 */
++ "459", /* 459 */
++ "460", /* 460 */
++ "461", /* 461 */
++ "462", /* 462 */
++ "463", /* 463 */
++ "464", /* 464 */
++ "465", /* 465 */
++ "466", /* 466 */
++ "467", /* 467 */
++ "468", /* 468 */
++ "469", /* 469 */
++ "470", /* 470 */
++ "471", /* 471 */
++ "472", /* 472 */
++ "473", /* 473 */
++ "474", /* 474 */
++ "475", /* 475 */
++ "476", /* 476 */
++ "477", /* 477 */
++ "478", /* 478 */
++ "479", /* 479 */
++ "480", /* 480 */
++ "481", /* 481 */
++ "482", /* 482 */
++ "483", /* 483 */
++ "484", /* 484 */
++ "485", /* 485 */
++ "486", /* 486 */
++ "487", /* 487 */
++ "488", /* 488 */
++ "489", /* 489 */
++ "490", /* 490 */
++ "491", /* 491 */
++ "492", /* 492 */
++ "493", /* 493 */
++ "494", /* 494 */
++ "495", /* 495 */
++ "496", /* 496 */
++ "497", /* 497 */
++ "498", /* 498 */
++ "499", /* 499 */
++ "500", /* 500 */
++ "501", /* 501 */
++ "502", /* 502 */
++ "503", /* 503 */
++ "504", /* 504 */
++ "505", /* 505 */
++ "506", /* 506 */
++ "507", /* 507 */
++ "508", /* 508 */
++ "509", /* 509 */
++ "510", /* 510 */
++ "511", /* 511 */
++ "512", /* 512 */
++ "513", /* 513 */
++ "514", /* 514 */
++ "515", /* 515 */
++ "516", /* 516 */
++ "517", /* 517 */
++ "518", /* 518 */
++ "519", /* 519 */
++ "520", /* 520 */
++ "521", /* 521 */
++ "522", /* 522 */
++ "523", /* 523 */
++ "524", /* 524 */
++ "525", /* 525 */
++ "526", /* 526 */
++ "527", /* 527 */
++ "528", /* 528 */
++ "529", /* 529 */
++ "530", /* 530 */
++ "531", /* 531 */
++ "532", /* 532 */
++ "533", /* 533 */
++ "534", /* 534 */
++ "535", /* 535 */
++ "536", /* 536 */
++ "537", /* 537 */
++ "538", /* 538 */
++ "539", /* 539 */
++ "540", /* 540 */
++ "541", /* 541 */
++ "542", /* 542 */
++ "543", /* 543 */
++ "544", /* 544 */
++ "545", /* 545 */
++ "546", /* 546 */
++ "547", /* 547 */
++ "548", /* 548 */
++ "549", /* 549 */
++ "550", /* 550 */
++ "551", /* 551 */
++ "552", /* 552 */
++ "553", /* 553 */
++ "554", /* 554 */
++ "555", /* 555 */
++ "556", /* 556 */
++ "557", /* 557 */
++ "558", /* 558 */
++ "559", /* 559 */
++ "560", /* 560 */
++ "561", /* 561 */
++ "562", /* 562 */
++ "563", /* 563 */
++ "564", /* 564 */
++ "565", /* 565 */
++ "566", /* 566 */
++ "567", /* 567 */
++ "568", /* 568 */
++ "569", /* 569 */
++ "570", /* 570 */
++ "571", /* 571 */
++ "572", /* 572 */
++ "573", /* 573 */
++ "574", /* 574 */
++ "575", /* 575 */
++ "576", /* 576 */
++ "577", /* 577 */
++ "578", /* 578 */
++ "579", /* 579 */
++ "580", /* 580 */
++ "581", /* 581 */
++ "582", /* 582 */
++ "583", /* 583 */
++ "584", /* 584 */
++ "585", /* 585 */
++ "586", /* 586 */
++ "587", /* 587 */
++ "588", /* 588 */
++ "589", /* 589 */
++ "590", /* 590 */
++ "591", /* 591 */
++ "592", /* 592 */
++ "593", /* 593 */
++ "594", /* 594 */
++ "595", /* 595 */
++ "596", /* 596 */
++ "597", /* 597 */
++ "598", /* 598 */
++ "599", /* 599 */
++ "600", /* 600 */
++ "601", /* 601 */
++ "602", /* 602 */
++ "603", /* 603 */
++ "604", /* 604 */
++ "605", /* 605 */
++ "606", /* 606 */
++ "607", /* 607 */
++ "608", /* 608 */
++ "609", /* 609 */
++ "610", /* 610 */
++ "611", /* 611 */
++ "612", /* 612 */
++ "613", /* 613 */
++ "614", /* 614 */
++ "615", /* 615 */
++ "616", /* 616 */
++ "617", /* 617 */
++ "618", /* 618 */
++ "619", /* 619 */
++ "620", /* 620 */
++ "621", /* 621 */
++ "622", /* 622 */
++ "623", /* 623 */
++ "624", /* 624 */
++ "625", /* 625 */
++ "626", /* 626 */
++ "627", /* 627 */
++ "628", /* 628 */
++ "629", /* 629 */
++ "630", /* 630 */
++ "631", /* 631 */
++ "632", /* 632 */
++ "633", /* 633 */
++ "634", /* 634 */
++ "635", /* 635 */
++ "636", /* 636 */
++ "637", /* 637 */
++ "638", /* 638 */
++ "639", /* 639 */
++ "640", /* 640 */
++ "641", /* 641 */
++ "642", /* 642 */
++ "643", /* 643 */
++ "644", /* 644 */
++ "645", /* 645 */
++ "646", /* 646 */
++ "647", /* 647 */
++ "648", /* 648 */
++ "649", /* 649 */
++ "650", /* 650 */
++ "651", /* 651 */
++ "652", /* 652 */
++ "653", /* 653 */
++ "654", /* 654 */
++ "655", /* 655 */
++ "656", /* 656 */
++ "657", /* 657 */
++ "658", /* 658 */
++ "659", /* 659 */
++ "660", /* 660 */
++ "661", /* 661 */
++ "662", /* 662 */
++ "663", /* 663 */
++ "664", /* 664 */
++ "665", /* 665 */
++ "666", /* 666 */
++ "667", /* 667 */
++ "668", /* 668 */
++ "669", /* 669 */
++ "670", /* 670 */
++ "671", /* 671 */
++ "672", /* 672 */
++ "673", /* 673 */
++ "674", /* 674 */
++ "675", /* 675 */
++ "676", /* 676 */
++ "677", /* 677 */
++ "678", /* 678 */
++ "679", /* 679 */
++ "680", /* 680 */
++ "681", /* 681 */
++ "682", /* 682 */
++ "683", /* 683 */
++ "684", /* 684 */
++ "685", /* 685 */
++ "686", /* 686 */
++ "687", /* 687 */
++ "688", /* 688 */
++ "689", /* 689 */
++ "690", /* 690 */
++ "691", /* 691 */
++ "692", /* 692 */
++ "693", /* 693 */
++ "694", /* 694 */
++ "695", /* 695 */
++ "696", /* 696 */
++ "697", /* 697 */
++ "698", /* 698 */
++ "699", /* 699 */
++ "700", /* 700 */
++ "701", /* 701 */
++ "702", /* 702 */
++ "703", /* 703 */
++ "704", /* 704 */
++ "705", /* 705 */
++ "706", /* 706 */
++ "707", /* 707 */
++ "708", /* 708 */
++ "709", /* 709 */
++ "710", /* 710 */
++ "711", /* 711 */
++ "712", /* 712 */
++ "713", /* 713 */
++ "714", /* 714 */
++ "715", /* 715 */
++ "716", /* 716 */
++ "717", /* 717 */
++ "718", /* 718 */
++ "719", /* 719 */
++ "720", /* 720 */
++ "721", /* 721 */
++ "722", /* 722 */
++ "723", /* 723 */
++ "724", /* 724 */
++ "725", /* 725 */
++ "726", /* 726 */
++ "727", /* 727 */
++ "728", /* 728 */
++ "729", /* 729 */
++ "730", /* 730 */
++ "731", /* 731 */
++ "732", /* 732 */
++ "733", /* 733 */
++ "734", /* 734 */
++ "735", /* 735 */
++ "736", /* 736 */
++ "737", /* 737 */
++ "738", /* 738 */
++ "739", /* 739 */
++ "740", /* 740 */
++ "741", /* 741 */
++ "742", /* 742 */
++ "743", /* 743 */
++ "744", /* 744 */
++ "745", /* 745 */
++ "746", /* 746 */
++ "747", /* 747 */
++ "748", /* 748 */
++ "749", /* 749 */
++ "750", /* 750 */
++ "751", /* 751 */
++ "752", /* 752 */
++ "753", /* 753 */
++ "754", /* 754 */
++ "755", /* 755 */
++ "756", /* 756 */
++ "757", /* 757 */
++ "758", /* 758 */
++ "759", /* 759 */
++ "760", /* 760 */
++ "761", /* 761 */
++ "762", /* 762 */
++ "763", /* 763 */
++ "764", /* 764 */
++ "765", /* 765 */
++ "766", /* 766 */
++ "767", /* 767 */
++ "768", /* 768 */
++ "769", /* 769 */
++ "770", /* 770 */
++ "771", /* 771 */
++ "772", /* 772 */
++ "773", /* 773 */
++ "774", /* 774 */
++ "775", /* 775 */
++ "776", /* 776 */
++ "777", /* 777 */
++ "778", /* 778 */
++ "779", /* 779 */
++ "780", /* 780 */
++ "781", /* 781 */
++ "782", /* 782 */
++ "783", /* 783 */
++ "784", /* 784 */
++ "785", /* 785 */
++ "786", /* 786 */
++ "787", /* 787 */
++ "788", /* 788 */
++ "789", /* 789 */
++ "790", /* 790 */
++ "791", /* 791 */
++ "792", /* 792 */
++ "793", /* 793 */
++ "794", /* 794 */
++ "795", /* 795 */
++ "796", /* 796 */
++ "797", /* 797 */
++ "798", /* 798 */
++ "799", /* 799 */
++ "800", /* 800 */
++ "801", /* 801 */
++ "802", /* 802 */
++ "803", /* 803 */
++ "804", /* 804 */
++ "805", /* 805 */
++ "806", /* 806 */
++ "807", /* 807 */
++ "808", /* 808 */
++ "809", /* 809 */
++ "810", /* 810 */
++ "811", /* 811 */
++ "812", /* 812 */
++ "813", /* 813 */
++ "814", /* 814 */
++ "815", /* 815 */
++ "816", /* 816 */
++ "817", /* 817 */
++ "818", /* 818 */
++ "819", /* 819 */
++ "820", /* 820 */
++ "821", /* 821 */
++ "822", /* 822 */
++ "823", /* 823 */
++ "824", /* 824 */
++ "825", /* 825 */
++ "826", /* 826 */
++ "827", /* 827 */
++ "828", /* 828 */
++ "829", /* 829 */
++ "830", /* 830 */
++ "831", /* 831 */
++ "832", /* 832 */
++ "833", /* 833 */
++ "834", /* 834 */
++ "835", /* 835 */
++ "836", /* 836 */
++ "837", /* 837 */
++ "838", /* 838 */
++ "839", /* 839 */
++ "840", /* 840 */
++ "841", /* 841 */
++ "842", /* 842 */
++ "843", /* 843 */
++ "844", /* 844 */
++ "845", /* 845 */
++ "846", /* 846 */
++ "847", /* 847 */
++ "848", /* 848 */
++ "849", /* 849 */
++ "850", /* 850 */
++ "851", /* 851 */
++ "852", /* 852 */
++ "853", /* 853 */
++ "854", /* 854 */
++ "855", /* 855 */
++ "856", /* 856 */
++ "857", /* 857 */
++ "858", /* 858 */
++ "859", /* 859 */
++ "860", /* 860 */
++ "861", /* 861 */
++ "862", /* 862 */
++ "863", /* 863 */
++ "864", /* 864 */
++ "865", /* 865 */
++ "866", /* 866 */
++ "867", /* 867 */
++ "868", /* 868 */
++ "869", /* 869 */
++ "870", /* 870 */
++ "871", /* 871 */
++ "872", /* 872 */
++ "873", /* 873 */
++ "874", /* 874 */
++ "875", /* 875 */
++ "876", /* 876 */
++ "877", /* 877 */
++ "878", /* 878 */
++ "879", /* 879 */
++ "880", /* 880 */
++ "881", /* 881 */
++ "882", /* 882 */
++ "883", /* 883 */
++ "884", /* 884 */
++ "885", /* 885 */
++ "886", /* 886 */
++ "887", /* 887 */
++ "888", /* 888 */
++ "889", /* 889 */
++ "890", /* 890 */
++ "891", /* 891 */
++ "892", /* 892 */
++ "893", /* 893 */
++ "894", /* 894 */
++ "895", /* 895 */
++ "896", /* 896 */
++ "897", /* 897 */
++ "898", /* 898 */
++ "899", /* 899 */
++ "900", /* 900 */
++ "901", /* 901 */
++ "902", /* 902 */
++ "903", /* 903 */
++ "904", /* 904 */
++ "905", /* 905 */
++ "906", /* 906 */
++ "907", /* 907 */
++ "908", /* 908 */
++ "909", /* 909 */
++ "910", /* 910 */
++ "911", /* 911 */
++ "912", /* 912 */
++ "913", /* 913 */
++ "914", /* 914 */
++ "915", /* 915 */
++ "916", /* 916 */
++ "917", /* 917 */
++ "918", /* 918 */
++ "919", /* 919 */
++ "920", /* 920 */
++ "921", /* 921 */
++ "922", /* 922 */
++ "923", /* 923 */
++ "924", /* 924 */
++ "925", /* 925 */
++ "926", /* 926 */
++ "927", /* 927 */
++ "928", /* 928 */
++ "929", /* 929 */
++ "930", /* 930 */
++ "931", /* 931 */
++ "932", /* 932 */
++ "933", /* 933 */
++ "934", /* 934 */
++ "935", /* 935 */
++ "936", /* 936 */
++ "937", /* 937 */
++ "938", /* 938 */
++ "939", /* 939 */
++ "940", /* 940 */
++ "941", /* 941 */
++ "942", /* 942 */
++ "943", /* 943 */
++ "944", /* 944 */
++ "945", /* 945 */
++ "946", /* 946 */
++ "947", /* 947 */
++ "948", /* 948 */
++ "949", /* 949 */
++ "950", /* 950 */
++ "951", /* 951 */
++ "952", /* 952 */
++ "953", /* 953 */
++ "954", /* 954 */
++ "955", /* 955 */
++ "956", /* 956 */
++ "957", /* 957 */
++ "958", /* 958 */
++ "959", /* 959 */
++ "960", /* 960 */
++ "961", /* 961 */
++ "962", /* 962 */
++ "963", /* 963 */
++ "964", /* 964 */
++ "965", /* 965 */
++ "966", /* 966 */
++ "967", /* 967 */
++ "968", /* 968 */
++ "969", /* 969 */
++ "970", /* 970 */
++ "971", /* 971 */
++ "972", /* 972 */
++ "973", /* 973 */
++ "974", /* 974 */
++ "975", /* 975 */
++ "976", /* 976 */
++ "977", /* 977 */
++ "978", /* 978 */
++ "979", /* 979 */
++ "980", /* 980 */
++ "981", /* 981 */
++ "982", /* 982 */
++ "983", /* 983 */
++ "984", /* 984 */
++ "985", /* 985 */
++ "986", /* 986 */
++ "987", /* 987 */
++ "988", /* 988 */
++ "989", /* 989 */
++ "990", /* 990 */
++ "991", /* 991 */
++ "992", /* 992 */
++ "993", /* 993 */
++ "994", /* 994 */
++ "995", /* 995 */
++ "996", /* 996 */
++ "997", /* 997 */
++ "998", /* 998 */
++ "999", /* 999 */
++ "1000", /* 1000 */
++ "1001", /* 1001 */
++ "1002", /* 1002 */
++ "1003", /* 1003 */
++ "1004", /* 1004 */
++ "1005", /* 1005 */
++ "1006", /* 1006 */
++ "1007", /* 1007 */
++ "1008", /* 1008 */
++ "1009", /* 1009 */
++ "1010", /* 1010 */
++ "1011", /* 1011 */
++ "1012", /* 1012 */
++ "1013", /* 1013 */
++ "1014", /* 1014 */
++ "1015", /* 1015 */
++ "1016", /* 1016 */
++ "1017", /* 1017 */
++ "1018", /* 1018 */
++ "1019", /* 1019 */
++ "1020", /* 1020 */
++ "1021", /* 1021 */
++ "1022", /* 1022 */
++ "1023", /* 1023 */
++ "open", /* 1024 */
++ "link", /* 1025 */
++ "unlink", /* 1026 */
++ "mknod", /* 1027 */
++ "chmod", /* 1028 */
++ "chown", /* 1029 */
++ "mkdir", /* 1030 */
++ "rmdir", /* 1031 */
++ "lchown", /* 1032 */
++ "access", /* 1033 */
++ "rename", /* 1034 */
++ "readlink", /* 1035 */
++ "symlink", /* 1036 */
++ "utimes", /* 1037 */
++ "stat", /* 1038 */
++ "lstat", /* 1039 */
++ "pipe", /* 1040 */
++ "dup2", /* 1041 */
++ "epoll_create", /* 1042 */
++ "inotify_init", /* 1043 */
++ "eventfd", /* 1044 */
++ "signalfd", /* 1045 */
++ "sendfile", /* 1046 */
++ "ftruncate", /* 1047 */
++ "truncate", /* 1048 */
++ "stat", /* 1049 */
++ "lstat", /* 1050 */
++ "fstat", /* 1051 */
++ "fcntl", /* 1052 */
++ "fadvise64", /* 1053 */
++ "newfstatat", /* 1054 */
++ "fstatfs", /* 1055 */
++ "statfs", /* 1056 */
++ "lseek", /* 1057 */
++ "mmap", /* 1058 */
++ "alarm", /* 1059 */
++ "getpgrp", /* 1060 */
++ "pause", /* 1061 */
++ "time", /* 1062 */
++ "utime", /* 1063 */
++ "creat", /* 1064 */
++ "getdents", /* 1065 */
++ "futimesat", /* 1066 */
++ "select", /* 1067 */
++ "poll", /* 1068 */
++ "epoll_wait", /* 1069 */
++ "ustat", /* 1070 */
++ "vfork", /* 1071 */
++ "oldwait4", /* 1072 */
++ "recv", /* 1073 */
++ "send", /* 1074 */
++ "bdflush", /* 1075 */
++ "umount", /* 1076 */
++ "uselib", /* 1077 */
++ "_sysctl", /* 1078 */
++ "fork", /* 1079 */
+diff --git a/sysdeps/linux-gnu/aarch64/trace.c b/sysdeps/linux-gnu/aarch64/trace.c
+new file mode 100644
+index 0000000..5544b51
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/trace.c
+@@ -0,0 +1,84 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <sys/types.h>
++#include <sys/wait.h>
++#include <asm/ptrace.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#include "backend.h"
++#include "proc.h"
++
++void
++get_arch_dep(struct Process *proc)
++{
++}
++
++int aarch64_read_gregs(struct Process *proc, struct user_pt_regs *regs);
++
++/* The syscall instruction is:
++ * | 31 21 | 20 5 | 4 0 |
++ * | 1 1 0 1 0 1 0 0 | 0 0 0 | imm16 | 0 0 0 0 1 | */
++#define SVC_MASK 0xffe0001f
++#define SVC_VALUE 0xd4000001
++
++int
++syscall_p(struct Process *proc, int status, int *sysnum)
++{
++ if (WIFSTOPPED(status)
++ && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
++
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "syscall_p: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return -1;
++ }
++
++ errno = 0;
++ unsigned long insn = (unsigned long) ptrace(PTRACE_PEEKTEXT,
++ proc->pid,
++ regs.pc - 4, 0);
++ if (insn == -1UL && errno != 0) {
++ fprintf(stderr, "syscall_p: "
++ "Couldn't peek into %d: %s\n", proc->pid,
++ strerror(errno));
++ return -1;
++ }
++
++ insn &= 0xffffffffUL;
++ if ((insn & SVC_MASK) == SVC_VALUE) {
++ *sysnum = regs.regs[8];
++
++ size_t d1 = proc->callstack_depth - 1;
++ if (proc->callstack_depth > 0
++ && proc->callstack[d1].is_syscall
++ && proc->callstack[d1].c_un.syscall == *sysnum)
++ return 2;
++
++ return 1;
++ }
++ }
++
++ return 0;
++}
+--
+1.9.1
+
diff --git a/system/ltrace/aarch64.patch b/system/ltrace/aarch64.patch
new file mode 100644
index 000000000..a89c3073a
--- /dev/null
+++ b/system/ltrace/aarch64.patch
@@ -0,0 +1,2155 @@
+From 982cbca34b2b49a158086ff5f43eb9bba89edead Mon Sep 17 00:00:00 2001
+From: Petr Machata <pmachata@redhat.com>
+Date: Wed, 6 Feb 2013 15:46:04 +0100
+Subject: [PATCH] Move get_hfa_type from IA64 backend to type.c, name it
+ type_get_hfa_type
+
+---
+ sysdeps/linux-gnu/ia64/fetch.c | 48 ++++++++----------------------------------
+ type.c | 36 +++++++++++++++++++++++++++++++
+ type.h | 11 +++++++++-
+ 3 files changed, 55 insertions(+), 40 deletions(-)
+
+diff --git a/sysdeps/linux-gnu/ia64/fetch.c b/sysdeps/linux-gnu/ia64/fetch.c
+index e90dbed..171c7a2 100644
+--- a/sysdeps/linux-gnu/ia64/fetch.c
++++ b/sysdeps/linux-gnu/ia64/fetch.c
+@@ -1,6 +1,6 @@
+ /*
+ * This file is part of ltrace.
+- * Copyright (C) 2012 Petr Machata, Red Hat Inc.
++ * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2008,2009 Juan Cespedes
+ * Copyright (C) 2006 Steve Fink
+ * Copyright (C) 2006 Ian Wienand
+@@ -249,37 +249,6 @@ allocate_float(struct fetch_context *ctx, struct process *proc,
+ return 0;
+ }
+
+-static enum arg_type
+-get_hfa_type(struct arg_type_info *info, size_t *countp)
+-{
+- size_t n = type_aggregate_size(info);
+- if (n == (size_t)-1)
+- return ARGTYPE_VOID;
+-
+- enum arg_type type = ARGTYPE_VOID;
+- *countp = 0;
+-
+- while (n-- > 0) {
+- struct arg_type_info *emt = type_element(info, n);
+-
+- enum arg_type emt_type = emt->type;
+- size_t emt_count = 1;
+- if (emt_type == ARGTYPE_STRUCT || emt_type == ARGTYPE_ARRAY)
+- emt_type = get_hfa_type(emt, &emt_count);
+-
+- if (type == ARGTYPE_VOID) {
+- if (emt_type != ARGTYPE_FLOAT
+- && emt_type != ARGTYPE_DOUBLE)
+- return ARGTYPE_VOID;
+- type = emt_type;
+- }
+- if (emt_type != type)
+- return ARGTYPE_VOID;
+- *countp += emt_count;
+- }
+- return type;
+-}
+-
+ static int
+ allocate_hfa(struct fetch_context *ctx, struct process *proc,
+ struct arg_type_info *info, struct value *valuep,
+@@ -380,10 +349,11 @@ allocate_ret(struct fetch_context *ctx, struct process *proc,
+ * floating-point registers, beginning with f8. */
+ if (info->type == ARGTYPE_STRUCT || info->type == ARGTYPE_ARRAY) {
+ size_t hfa_size;
+- enum arg_type hfa_type = get_hfa_type(info, &hfa_size);
+- if (hfa_type != ARGTYPE_VOID && hfa_size <= 8)
++ struct arg_type_info *hfa_info
++ = type_get_hfa_type(info, &hfa_size);
++ if (hfa_info != NULL && hfa_size <= 8)
+ return allocate_hfa(ctx, proc, info, valuep,
+- hfa_type, hfa_size);
++ hfa_info->type, hfa_size);
+ }
+
+ /* Integers and pointers are passed in r8. 128-bit integers
+@@ -409,7 +379,7 @@ arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
+ struct arg_type_info *info, struct value *valuep)
+ {
+ switch (info->type) {
+- enum arg_type hfa_type;
++ struct arg_type_info *hfa_info;
+ size_t hfa_size;
+
+ case ARGTYPE_VOID:
+@@ -421,10 +391,10 @@ arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
+ return allocate_float(ctx, proc, info, valuep, 1);
+
+ case ARGTYPE_STRUCT:
+- hfa_type = get_hfa_type(info, &hfa_size);
+- if (hfa_type != ARGTYPE_VOID)
++ hfa_info = type_get_hfa_type(info, &hfa_size);
++ if (hfa_info != NULL)
+ return allocate_hfa(ctx, proc, info, valuep,
+- hfa_type, hfa_size);
++ hfa_info->type, hfa_size);
+ /* Fall through. */
+ case ARGTYPE_CHAR:
+ case ARGTYPE_SHORT:
+diff --git a/type.c b/type.c
+index 11b4ce1..d5bc98f 100644
+--- a/type.c
++++ b/type.c
+@@ -564,3 +564,39 @@ type_get_fp_equivalent(struct arg_type_info *info)
+ }
+ abort();
+ }
++
++struct arg_type_info *
++type_get_hfa_type(struct arg_type_info *info, size_t *countp)
++{
++ assert(info != NULL);
++ if (info->type != ARGTYPE_STRUCT
++ && info->type != ARGTYPE_ARRAY)
++ return NULL;
++
++ size_t n = type_aggregate_size(info);
++ if (n == (size_t)-1)
++ return NULL;
++
++ struct arg_type_info *ret = NULL;
++ *countp = 0;
++
++ while (n-- > 0) {
++ struct arg_type_info *emt = type_element(info, n);
++
++ size_t emt_count = 1;
++ if (emt->type == ARGTYPE_STRUCT || emt->type == ARGTYPE_ARRAY)
++ emt = type_get_hfa_type(emt, &emt_count);
++ if (emt == NULL)
++ return NULL;
++ if (ret == NULL) {
++ if (emt->type != ARGTYPE_FLOAT
++ && emt->type != ARGTYPE_DOUBLE)
++ return NULL;
++ ret = emt;
++ }
++ if (emt->type != ret->type)
++ return NULL;
++ *countp += emt_count;
++ }
++ return ret;
++}
+diff --git a/type.h b/type.h
+index b92c1af..3210677 100644
+--- a/type.h
++++ b/type.h
+@@ -1,6 +1,6 @@
+ /*
+ * This file is part of ltrace.
+- * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc.
++ * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc.
+ * Copyright (C) 1997-2009 Juan Cespedes
+ *
+ * This program is free software; you can redistribute it and/or
+@@ -142,4 +142,13 @@ int type_is_signed(enum arg_type type);
+ * type. */
+ struct arg_type_info *type_get_fp_equivalent(struct arg_type_info *info);
+
++/* If INFO is homogeneous floating-point aggregate, return the
++ * corresponding floating point type, and set *COUNTP to number of
++ * fields of the structure. Otherwise return NULL. INFO is a HFA if
++ * it's an aggregate whose each field is either a HFA, or a
++ * floating-point type. */
++struct arg_type_info *type_get_hfa_type(struct arg_type_info *info,
++ size_t *countp);
++
++
+ #endif /* TYPE_H */
+--
+1.9.1
+
+From ae7249250ea650ec82bc545d4281b852020c7a6f Mon Sep 17 00:00:00 2001
+From: Petr Machata <pmachata@redhat.com>
+Date: Fri, 24 Jan 2014 00:50:06 +0100
+Subject: [PATCH 1/1] Implement aarch64 support
+
+- IFUNC support is not implemented, the rest works well. The only
+ other failure is in wide char functions, and that occurs on x86_64
+ as well.
+---
+ configure.ac | 3 +-
+ sysdeps/linux-gnu/Makefile.am | 4 +-
+ sysdeps/linux-gnu/aarch64/Makefile.am | 25 +
+ sysdeps/linux-gnu/aarch64/arch.h | 37 ++
+ sysdeps/linux-gnu/aarch64/fetch.c | 365 +++++++++++
+ sysdeps/linux-gnu/aarch64/plt.c | 38 ++
+ sysdeps/linux-gnu/aarch64/ptrace.h | 22 +
+ sysdeps/linux-gnu/aarch64/regs.c | 130 ++++
+ sysdeps/linux-gnu/aarch64/signalent.h | 52 ++
+ sysdeps/linux-gnu/aarch64/syscallent.h | 1100 ++++++++++++++++++++++++++++++++
+ sysdeps/linux-gnu/aarch64/trace.c | 83 +++
+ 11 files changed, 1857 insertions(+), 2 deletions(-)
+ create mode 100644 sysdeps/linux-gnu/aarch64/Makefile.am
+ create mode 100644 sysdeps/linux-gnu/aarch64/arch.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/fetch.c
+ create mode 100644 sysdeps/linux-gnu/aarch64/plt.c
+ create mode 100644 sysdeps/linux-gnu/aarch64/ptrace.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/regs.c
+ create mode 100644 sysdeps/linux-gnu/aarch64/signalent.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/syscallent.h
+ create mode 100644 sysdeps/linux-gnu/aarch64/trace.c
+
+diff --git a/configure.ac b/configure.ac
+index c6e6bf0..0e9a124 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,6 +1,6 @@
+ # -*- Autoconf -*-
+ # This file is part of ltrace.
+-# Copyright (C) 2010,2013 Petr Machata, Red Hat Inc.
++# Copyright (C) 2010,2012,2013,2014 Petr Machata, Red Hat Inc.
+ # Copyright (C) 2010,2011 Joe Damato
+ # Copyright (C) 2010 Marc Kleine-Budde
+ # Copyright (C) 2010 Zachary T Welch
+@@ -399,6 +399,7 @@ AC_CONFIG_FILES([
+ Makefile
+ sysdeps/Makefile
+ sysdeps/linux-gnu/Makefile
++ sysdeps/linux-gnu/aarch64/Makefile
+ sysdeps/linux-gnu/alpha/Makefile
+ sysdeps/linux-gnu/arm/Makefile
+ sysdeps/linux-gnu/cris/Makefile
+diff --git a/sysdeps/linux-gnu/Makefile.am b/sysdeps/linux-gnu/Makefile.am
+index ecee577..ec26162 100644
+--- a/sysdeps/linux-gnu/Makefile.am
++++ b/sysdeps/linux-gnu/Makefile.am
+@@ -1,4 +1,5 @@
+ # This file is part of ltrace.
++# Copyright (C) 2014 Petr Machata, Red Hat, Inc.
+ # Copyright (C) 2010,2012 Marc Kleine-Budde, Pengutronix
+ #
+ # This program is free software; you can redistribute it and/or
+@@ -16,7 +17,8 @@
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ # 02110-1301 USA
+
+-DIST_SUBDIRS = alpha arm cris ia64 m68k mips ppc s390 sparc x86
++DIST_SUBDIRS = aarch64 alpha arm cris ia64 m68k mips ppc s390 \
++ sparc x86
+
+ SUBDIRS = \
+ $(HOST_CPU)
+diff --git a/sysdeps/linux-gnu/aarch64/Makefile.am b/sysdeps/linux-gnu/aarch64/Makefile.am
+new file mode 100644
+index 0000000..0af4e6e
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/Makefile.am
+@@ -0,0 +1,25 @@
++# This file is part of ltrace.
++# Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++#
++# This program is free software; you can redistribute it and/or
++# modify it under the terms of the GNU General Public License as
++# published by the Free Software Foundation; either version 2 of the
++# License, or (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful, but
++# WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++# General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++# 02110-1301 USA
++
++noinst_LTLIBRARIES = ../libcpu.la
++
++___libcpu_la_SOURCES = fetch.c plt.c regs.c trace.c
++
++noinst_HEADERS = arch.h ptrace.h signalent.h syscallent.h
++
++MAINTAINERCLEANFILES = Makefile.in
+diff --git a/sysdeps/linux-gnu/aarch64/arch.h b/sysdeps/linux-gnu/aarch64/arch.h
+new file mode 100644
+index 0000000..4137613
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/arch.h
+@@ -0,0 +1,37 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++#ifndef LTRACE_AARCH64_ARCH_H
++#define LTRACE_AARCH64_ARCH_H
++
++/* | 31 21 | 20 5 | 4 0 | *
++ * | 1 1 0 1 0 1 0 0 0 0 1 | imm16 | 0 0 0 0 0 | */
++#define BREAKPOINT_VALUE { 0xd4, 0x20, 0, 0 }
++#define BREAKPOINT_LENGTH 4
++#define DECR_PC_AFTER_BREAK 0
++
++#define LT_ELFCLASS ELFCLASS64
++#define LT_ELF_MACHINE EM_AARCH64
++
++#define ARCH_HAVE_FETCH_ARG
++#define ARCH_ENDIAN_BIG
++#define ARCH_HAVE_SIZEOF
++#define ARCH_HAVE_ALIGNOF
++
++#endif /* LTRACE_AARCH64_ARCH_H */
+diff --git a/sysdeps/linux-gnu/aarch64/fetch.c b/sysdeps/linux-gnu/aarch64/fetch.c
+new file mode 100644
+index 0000000..8779f03
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/fetch.c
+@@ -0,0 +1,365 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <asm/ptrace.h>
++#include <stdlib.h>
++#include <string.h>
++
++#include "fetch.h"
++#include "proc.h"
++#include "type.h"
++#include "value.h"
++
++int aarch64_read_gregs(struct Process *proc, struct user_pt_regs *regs);
++int aarch64_read_fregs(struct Process *proc, struct user_fpsimd_state *regs);
++
++
++struct fetch_context
++{
++ struct user_pt_regs gregs;
++ struct user_fpsimd_state fpregs;
++ arch_addr_t nsaa;
++ unsigned ngrn;
++ unsigned nsrn;
++ arch_addr_t x8;
++};
++
++static int
++context_init(struct fetch_context *context, struct Process *proc)
++{
++ if (aarch64_read_gregs(proc, &context->gregs) < 0
++ || aarch64_read_fregs(proc, &context->fpregs) < 0)
++ return -1;
++
++ context->ngrn = 0;
++ context->nsrn = 0;
++ /* XXX double cast */
++ context->nsaa = (arch_addr_t) (uintptr_t) context->gregs.sp;
++ context->x8 = 0;
++
++ return 0;
++}
++
++struct fetch_context *
++arch_fetch_arg_clone(struct Process *proc, struct fetch_context *context)
++{
++ struct fetch_context *ret = malloc(sizeof(*ret));
++ if (ret == NULL)
++ return NULL;
++ return memcpy(ret, context, sizeof(*ret));
++}
++
++static void
++fetch_next_gpr(struct fetch_context *context, unsigned char *buf)
++{
++ uint64_t u = context->gregs.regs[context->ngrn++];
++ memcpy(buf, &u, 8);
++}
++
++static int
++fetch_gpr(struct fetch_context *context, struct value *value, size_t sz)
++{
++ if (sz < 8)
++ sz = 8;
++
++ unsigned char *buf = value_reserve(value, sz);
++ if (buf == NULL)
++ return -1;
++
++ size_t i;
++ for (i = 0; i < sz; i += 8)
++ fetch_next_gpr(context, buf + i);
++
++ return 0;
++}
++
++static void
++fetch_next_sse(struct fetch_context *context, unsigned char *buf, size_t sz)
++{
++ __int128 u = context->fpregs.vregs[context->nsrn++];
++ memcpy(buf, &u, sz);
++}
++
++static int
++fetch_sse(struct fetch_context *context, struct value *value, size_t sz)
++{
++ unsigned char *buf = value_reserve(value, sz);
++ if (buf == NULL)
++ return -1;
++
++ fetch_next_sse(context, buf, sz);
++ return 0;
++}
++
++static int
++fetch_hfa(struct fetch_context *context,
++ struct value *value, struct arg_type_info *hfa_t, size_t count)
++{
++ size_t sz = type_sizeof(value->inferior, hfa_t);
++ unsigned char *buf = value_reserve(value, sz * count);
++ if (buf == NULL)
++ return -1;
++
++ size_t i;
++ for (i = 0; i < count; ++i) {
++ fetch_next_sse(context, buf, sz);
++ buf += sz;
++ }
++ return 0;
++}
++
++static int
++fetch_stack(struct fetch_context *context, struct value *value,
++ size_t align, size_t sz)
++{
++ if (align < 8)
++ align = 8;
++ size_t amount = ((sz + align - 1) / align) * align;
++
++ /* XXX double casts */
++ uintptr_t sp = (uintptr_t) context->nsaa;
++ sp = ((sp + align - 1) / align) * align;
++
++ value_in_inferior(value, (arch_addr_t) sp);
++
++ sp += amount;
++ context->nsaa = (arch_addr_t) sp;
++
++ return 0;
++}
++
++enum convert_method {
++ CVT_ERR = -1,
++ CVT_NOP = 0,
++ CVT_BYREF,
++};
++
++enum fetch_method {
++ FETCH_NOP,
++ FETCH_STACK,
++ FETCH_GPR,
++ FETCH_SSE,
++ FETCH_HFA,
++};
++
++struct fetch_script {
++ enum convert_method c;
++ enum fetch_method f;
++ size_t sz;
++ struct arg_type_info *hfa_t;
++ size_t count;
++};
++
++static struct fetch_script
++pass_arg(struct fetch_context const *context,
++ struct Process *proc, struct arg_type_info *info)
++{
++ enum fetch_method cvt = CVT_NOP;
++
++ size_t sz = type_sizeof(proc, info);
++ if (sz == (size_t) -1)
++ return (struct fetch_script) { CVT_ERR, FETCH_NOP, sz };
++
++ switch (info->type) {
++ case ARGTYPE_VOID:
++ return (struct fetch_script) { cvt, FETCH_NOP, sz };
++
++ case ARGTYPE_STRUCT:
++ case ARGTYPE_ARRAY:;
++ size_t count;
++ struct arg_type_info *hfa_t = type_get_hfa_type(info, &count);
++ if (hfa_t != NULL && count <= 4) {
++ if (context->nsrn + count <= 8)
++ return (struct fetch_script)
++ { cvt, FETCH_HFA, sz, hfa_t, count };
++ return (struct fetch_script)
++ { cvt, FETCH_STACK, sz, hfa_t, count };
++ }
++
++ if (sz <= 16) {
++ size_t count = sz / 8;
++ if (context->ngrn + count <= 8)
++ return (struct fetch_script)
++ { cvt, FETCH_GPR, sz };
++ }
++
++ cvt = CVT_BYREF;
++ sz = 8;
++ /* Fall through. */
++
++ case ARGTYPE_POINTER:
++ case ARGTYPE_INT:
++ case ARGTYPE_UINT:
++ case ARGTYPE_LONG:
++ case ARGTYPE_ULONG:
++ case ARGTYPE_CHAR:
++ case ARGTYPE_SHORT:
++ case ARGTYPE_USHORT:
++ if (context->ngrn < 8 && sz <= 8)
++ return (struct fetch_script) { cvt, FETCH_GPR, sz };
++ /* We don't support types wider than 8 bytes as of
++ * now. */
++ assert(sz <= 8);
++
++ return (struct fetch_script) { cvt, FETCH_STACK, sz };
++
++ case ARGTYPE_FLOAT:
++ case ARGTYPE_DOUBLE:
++ if (context->nsrn < 8) {
++ /* ltrace doesn't support float128. */
++ assert(sz <= 8);
++ return (struct fetch_script) { cvt, FETCH_SSE, sz };
++ }
++
++ return (struct fetch_script) { cvt, FETCH_STACK, sz };
++ }
++
++ assert(! "Failed to allocate argument.");
++ abort();
++}
++
++static int
++convert_arg(struct value *value, struct fetch_script how)
++{
++ switch (how.c) {
++ case CVT_NOP:
++ return 0;
++ case CVT_BYREF:
++ return value_pass_by_reference(value);
++ case CVT_ERR:
++ return -1;
++ }
++
++ assert(! "Don't know how to convert argument.");
++ abort();
++}
++
++static int
++fetch_arg(struct fetch_context *context,
++ struct Process *proc, struct arg_type_info *info,
++ struct value *value, struct fetch_script how)
++{
++ if (convert_arg(value, how) < 0)
++ return -1;
++
++ switch (how.f) {
++ case FETCH_NOP:
++ return 0;
++
++ case FETCH_STACK:
++ if (how.hfa_t != NULL && how.count != 0 && how.count <= 8)
++ context->nsrn = 8;
++ return fetch_stack(context, value,
++ type_alignof(proc, info), how.sz);
++
++ case FETCH_GPR:
++ return fetch_gpr(context, value, how.sz);
++
++ case FETCH_SSE:
++ return fetch_sse(context, value, how.sz);
++
++ case FETCH_HFA:
++ return fetch_hfa(context, value, how.hfa_t, how.count);
++ }
++
++ assert(! "Don't know how to fetch argument.");
++ abort();
++}
++
++struct fetch_context *
++arch_fetch_arg_init(enum tof type, struct Process *proc,
++ struct arg_type_info *ret_info)
++{
++ struct fetch_context *context = malloc(sizeof *context);
++ if (context == NULL || context_init(context, proc) < 0) {
++ fail:
++ free(context);
++ return NULL;
++ }
++
++ /* There's a provision in ARMv8 parameter passing convention
++ * for returning types that, if passed as first argument to a
++ * function, would be passed on stack. For those types, x8
++ * contains an address where the return argument should be
++ * placed. The callee doesn't need to preserve the value of
++ * x8, so we need to fetch it now.
++ *
++ * To my knowledge, there are currently no types where this
++ * holds, but the code is here, utterly untested. */
++
++ struct fetch_script how = pass_arg(context, proc, ret_info);
++ if (how.c == CVT_ERR)
++ goto fail;
++ if (how.c == CVT_NOP && how.f == FETCH_STACK) {
++ /* XXX double cast. */
++ context->x8 = (arch_addr_t) (uintptr_t) context->gregs.regs[8];
++ /* See the comment above about the assert. */
++ assert(! "Unexpected: first argument passed on stack.");
++ abort();
++ }
++
++ return context;
++}
++
++int
++arch_fetch_arg_next(struct fetch_context *context, enum tof type,
++ struct Process *proc, struct arg_type_info *info,
++ struct value *value)
++{
++ return fetch_arg(context, proc, info, value,
++ pass_arg(context, proc, info));
++}
++
++int
++arch_fetch_retval(struct fetch_context *context, enum tof type,
++ struct Process *proc, struct arg_type_info *info,
++ struct value *value)
++{
++ if (context->x8 != 0) {
++ value_in_inferior(value, context->x8);
++ return 0;
++ }
++
++ if (context_init(context, proc) < 0)
++ return -1;
++
++ return fetch_arg(context, proc, info, value,
++ pass_arg(context, proc, info));
++}
++
++void
++arch_fetch_arg_done(struct fetch_context *context)
++{
++ if (context != NULL)
++ free(context);
++}
++
++size_t
++arch_type_sizeof(struct Process *proc, struct arg_type_info *arg)
++{
++ return (size_t) -2;
++}
++
++size_t
++arch_type_alignof(struct Process *proc, struct arg_type_info *arg)
++{
++ return (size_t) -2;
++}
+diff --git a/sysdeps/linux-gnu/aarch64/plt.c b/sysdeps/linux-gnu/aarch64/plt.c
+new file mode 100644
+index 0000000..29dc4c9
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/plt.c
+@@ -0,0 +1,38 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <gelf.h>
++
++#include "backend.h"
++#include "proc.h"
++#include "library.h"
++#include "ltrace-elf.h"
++
++arch_addr_t
++sym2addr(struct Process *proc, struct library_symbol *sym)
++{
++ return sym->enter_addr;
++}
++
++GElf_Addr
++arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela *rela)
++{
++ return lte->plt_addr + 32 + ndx * 16;
++}
+diff --git a/sysdeps/linux-gnu/aarch64/ptrace.h b/sysdeps/linux-gnu/aarch64/ptrace.h
+new file mode 100644
+index 0000000..283c314
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/ptrace.h
+@@ -0,0 +1,22 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <asm/ptrace.h>
+diff --git a/sysdeps/linux-gnu/aarch64/regs.c b/sysdeps/linux-gnu/aarch64/regs.c
+new file mode 100644
+index 0000000..06eb72b
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/regs.c
+@@ -0,0 +1,131 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <asm/ptrace.h>
++#include <linux/uio.h>
++#include <assert.h>
++#include <stdlib.h>
++#include <stdio.h>
++
++#include "backend.h"
++#include "proc.h"
++
++#define PC_OFF (32 * 4)
++
++int
++aarch64_read_gregs(struct Process *proc, struct user_pt_regs *regs)
++{
++ *regs = (struct user_pt_regs) {};
++ struct iovec iovec;
++ iovec.iov_base = regs;
++ iovec.iov_len = sizeof *regs;
++ return ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, &iovec) < 0
++ ? -1 : 0;
++}
++
++int
++aarch64_write_gregs(struct Process *proc, struct user_pt_regs *regs)
++{
++ struct iovec iovec;
++ iovec.iov_base = regs;
++ iovec.iov_len = sizeof *regs;
++ return ptrace(PTRACE_SETREGSET, proc->pid, NT_PRSTATUS, &iovec) < 0
++ ? -1 : 0;
++}
++
++int
++aarch64_read_fregs(struct Process *proc, struct user_fpsimd_state *regs)
++{
++ *regs = (struct user_fpsimd_state) {};
++ struct iovec iovec;
++ iovec.iov_base = regs;
++ iovec.iov_len = sizeof *regs;
++ return ptrace(PTRACE_GETREGSET, proc->pid, NT_FPREGSET, &iovec) < 0
++ ? -1 : 0;
++}
++
++arch_addr_t
++get_instruction_pointer(struct Process *proc)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_instruction_pointer: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return 0;
++ }
++
++ /*
++ char buf[128];
++ sprintf(buf, "cat /proc/%d/maps", proc->pid);
++ system(buf);
++ */
++
++ /* XXX double cast */
++ return (arch_addr_t) (uintptr_t) regs.pc;
++}
++
++void
++set_instruction_pointer(struct Process *proc, arch_addr_t addr)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_instruction_pointer: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return;
++ }
++
++ /* XXX double cast */
++ regs.pc = (uint64_t) (uintptr_t) addr;
++
++ if (aarch64_write_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_instruction_pointer: "
++ "Couldn't write registers of %d.\n", proc->pid);
++ return;
++ }
++}
++
++arch_addr_t
++get_stack_pointer(struct Process *proc)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_stack_pointer: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return 0;
++ }
++
++ /* XXX double cast */
++ return (arch_addr_t) (uintptr_t) regs.sp;
++}
++
++arch_addr_t
++get_return_addr(struct Process *proc, arch_addr_t stack_pointer)
++{
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "get_return_addr: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return 0;
++ }
++
++ /* XXX double cast */
++ return (arch_addr_t) (uintptr_t) regs.regs[30];
++}
+diff --git a/sysdeps/linux-gnu/aarch64/signalent.h b/sysdeps/linux-gnu/aarch64/signalent.h
+new file mode 100644
+index 0000000..bf56ebc
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/signalent.h
+@@ -0,0 +1,52 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2006 Ian Wienand
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++ "SIG_0", /* 0 */
++ "SIGHUP", /* 1 */
++ "SIGINT", /* 2 */
++ "SIGQUIT", /* 3 */
++ "SIGILL", /* 4 */
++ "SIGTRAP", /* 5 */
++ "SIGABRT", /* 6 */
++ "SIGBUS", /* 7 */
++ "SIGFPE", /* 8 */
++ "SIGKILL", /* 9 */
++ "SIGUSR1", /* 10 */
++ "SIGSEGV", /* 11 */
++ "SIGUSR2", /* 12 */
++ "SIGPIPE", /* 13 */
++ "SIGALRM", /* 14 */
++ "SIGTERM", /* 15 */
++ "SIGSTKFLT", /* 16 */
++ "SIGCHLD", /* 17 */
++ "SIGCONT", /* 18 */
++ "SIGSTOP", /* 19 */
++ "SIGTSTP", /* 20 */
++ "SIGTTIN", /* 21 */
++ "SIGTTOU", /* 22 */
++ "SIGURG", /* 23 */
++ "SIGXCPU", /* 24 */
++ "SIGXFSZ", /* 25 */
++ "SIGVTALRM", /* 26 */
++ "SIGPROF", /* 27 */
++ "SIGWINCH", /* 28 */
++ "SIGIO", /* 29 */
++ "SIGPWR", /* 30 */
++ "SIGSYS", /* 31 */
+diff --git a/sysdeps/linux-gnu/aarch64/syscallent.h b/sysdeps/linux-gnu/aarch64/syscallent.h
+new file mode 100644
+index 0000000..aca8191
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/syscallent.h
+@@ -0,0 +1,1100 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++ "io_setup", /* 0 */
++ "io_destroy", /* 1 */
++ "io_submit", /* 2 */
++ "io_cancel", /* 3 */
++ "io_getevents", /* 4 */
++ "setxattr", /* 5 */
++ "lsetxattr", /* 6 */
++ "fsetxattr", /* 7 */
++ "getxattr", /* 8 */
++ "lgetxattr", /* 9 */
++ "fgetxattr", /* 10 */
++ "listxattr", /* 11 */
++ "llistxattr", /* 12 */
++ "flistxattr", /* 13 */
++ "removexattr", /* 14 */
++ "lremovexattr", /* 15 */
++ "fremovexattr", /* 16 */
++ "getcwd", /* 17 */
++ "lookup_dcookie", /* 18 */
++ "eventfd2", /* 19 */
++ "epoll_create1", /* 20 */
++ "epoll_ctl", /* 21 */
++ "epoll_pwait", /* 22 */
++ "dup", /* 23 */
++ "dup3", /* 24 */
++ "fcntl", /* 25 */
++ "inotify_init1", /* 26 */
++ "inotify_add_watch", /* 27 */
++ "inotify_rm_watch", /* 28 */
++ "ioctl", /* 29 */
++ "ioprio_set", /* 30 */
++ "ioprio_get", /* 31 */
++ "flock", /* 32 */
++ "mknodat", /* 33 */
++ "mkdirat", /* 34 */
++ "unlinkat", /* 35 */
++ "symlinkat", /* 36 */
++ "linkat", /* 37 */
++ "renameat", /* 38 */
++ "umount2", /* 39 */
++ "mount", /* 40 */
++ "pivot_root", /* 41 */
++ "nfsservctl", /* 42 */
++ "statfs", /* 43 */
++ "fstatfs", /* 44 */
++ "truncate", /* 45 */
++ "ftruncate", /* 46 */
++ "fallocate", /* 47 */
++ "faccessat", /* 48 */
++ "chdir", /* 49 */
++ "fchdir", /* 50 */
++ "chroot", /* 51 */
++ "fchmod", /* 52 */
++ "fchmodat", /* 53 */
++ "fchownat", /* 54 */
++ "fchown", /* 55 */
++ "openat", /* 56 */
++ "close", /* 57 */
++ "vhangup", /* 58 */
++ "pipe2", /* 59 */
++ "quotactl", /* 60 */
++ "getdents64", /* 61 */
++ "lseek", /* 62 */
++ "read", /* 63 */
++ "write", /* 64 */
++ "readv", /* 65 */
++ "writev", /* 66 */
++ "pread64", /* 67 */
++ "pwrite64", /* 68 */
++ "preadv", /* 69 */
++ "pwritev", /* 70 */
++ "sendfile", /* 71 */
++ "pselect6", /* 72 */
++ "ppoll", /* 73 */
++ "signalfd4", /* 74 */
++ "vmsplice", /* 75 */
++ "splice", /* 76 */
++ "tee", /* 77 */
++ "readlinkat", /* 78 */
++ "fstatat", /* 79 */
++ "fstat", /* 80 */
++ "sync", /* 81 */
++ "fsync", /* 82 */
++ "fdatasync", /* 83 */
++ "sync_file_range", /* 84 */
++ "timerfd_create", /* 85 */
++ "timerfd_settime", /* 86 */
++ "timerfd_gettime", /* 87 */
++ "utimensat", /* 88 */
++ "acct", /* 89 */
++ "capget", /* 90 */
++ "capset", /* 91 */
++ "personality", /* 92 */
++ "exit", /* 93 */
++ "exit_group", /* 94 */
++ "waitid", /* 95 */
++ "set_tid_address", /* 96 */
++ "unshare", /* 97 */
++ "futex", /* 98 */
++ "set_robust_list", /* 99 */
++ "get_robust_list", /* 100 */
++ "nanosleep", /* 101 */
++ "getitimer", /* 102 */
++ "setitimer", /* 103 */
++ "kexec_load", /* 104 */
++ "init_module", /* 105 */
++ "delete_module", /* 106 */
++ "timer_create", /* 107 */
++ "timer_gettime", /* 108 */
++ "timer_getoverrun", /* 109 */
++ "timer_settime", /* 110 */
++ "timer_delete", /* 111 */
++ "clock_settime", /* 112 */
++ "clock_gettime", /* 113 */
++ "clock_getres", /* 114 */
++ "clock_nanosleep", /* 115 */
++ "syslog", /* 116 */
++ "ptrace", /* 117 */
++ "sched_setparam", /* 118 */
++ "sched_setscheduler", /* 119 */
++ "sched_getscheduler", /* 120 */
++ "sched_getparam", /* 121 */
++ "sched_setaffinity", /* 122 */
++ "sched_getaffinity", /* 123 */
++ "sched_yield", /* 124 */
++ "sched_get_priority_max", /* 125 */
++ "sched_get_priority_min", /* 126 */
++ "sched_rr_get_interval", /* 127 */
++ "restart_syscall", /* 128 */
++ "kill", /* 129 */
++ "tkill", /* 130 */
++ "tgkill", /* 131 */
++ "sigaltstack", /* 132 */
++ "rt_sigsuspend", /* 133 */
++ "rt_sigaction", /* 134 */
++ "rt_sigprocmask", /* 135 */
++ "rt_sigpending", /* 136 */
++ "rt_sigtimedwait", /* 137 */
++ "rt_sigqueueinfo", /* 138 */
++ "rt_sigreturn", /* 139 */
++ "setpriority", /* 140 */
++ "getpriority", /* 141 */
++ "reboot", /* 142 */
++ "setregid", /* 143 */
++ "setgid", /* 144 */
++ "setreuid", /* 145 */
++ "setuid", /* 146 */
++ "setresuid", /* 147 */
++ "getresuid", /* 148 */
++ "setresgid", /* 149 */
++ "getresgid", /* 150 */
++ "setfsuid", /* 151 */
++ "setfsgid", /* 152 */
++ "times", /* 153 */
++ "setpgid", /* 154 */
++ "getpgid", /* 155 */
++ "getsid", /* 156 */
++ "setsid", /* 157 */
++ "getgroups", /* 158 */
++ "setgroups", /* 159 */
++ "uname", /* 160 */
++ "sethostname", /* 161 */
++ "setdomainname", /* 162 */
++ "getrlimit", /* 163 */
++ "setrlimit", /* 164 */
++ "getrusage", /* 165 */
++ "umask", /* 166 */
++ "prctl", /* 167 */
++ "getcpu", /* 168 */
++ "gettimeofday", /* 169 */
++ "settimeofday", /* 170 */
++ "adjtimex", /* 171 */
++ "getpid", /* 172 */
++ "getppid", /* 173 */
++ "getuid", /* 174 */
++ "geteuid", /* 175 */
++ "getgid", /* 176 */
++ "getegid", /* 177 */
++ "gettid", /* 178 */
++ "sysinfo", /* 179 */
++ "mq_open", /* 180 */
++ "mq_unlink", /* 181 */
++ "mq_timedsend", /* 182 */
++ "mq_timedreceive", /* 183 */
++ "mq_notify", /* 184 */
++ "mq_getsetattr", /* 185 */
++ "msgget", /* 186 */
++ "msgctl", /* 187 */
++ "msgrcv", /* 188 */
++ "msgsnd", /* 189 */
++ "semget", /* 190 */
++ "semctl", /* 191 */
++ "semtimedop", /* 192 */
++ "semop", /* 193 */
++ "shmget", /* 194 */
++ "shmctl", /* 195 */
++ "shmat", /* 196 */
++ "shmdt", /* 197 */
++ "socket", /* 198 */
++ "socketpair", /* 199 */
++ "bind", /* 200 */
++ "listen", /* 201 */
++ "accept", /* 202 */
++ "connect", /* 203 */
++ "getsockname", /* 204 */
++ "getpeername", /* 205 */
++ "sendto", /* 206 */
++ "recvfrom", /* 207 */
++ "setsockopt", /* 208 */
++ "getsockopt", /* 209 */
++ "shutdown", /* 210 */
++ "sendmsg", /* 211 */
++ "recvmsg", /* 212 */
++ "readahead", /* 213 */
++ "brk", /* 214 */
++ "munmap", /* 215 */
++ "mremap", /* 216 */
++ "add_key", /* 217 */
++ "request_key", /* 218 */
++ "keyctl", /* 219 */
++ "clone", /* 220 */
++ "execve", /* 221 */
++ "mmap", /* 222 */
++ "fadvise64", /* 223 */
++ "swapon", /* 224 */
++ "swapoff", /* 225 */
++ "mprotect", /* 226 */
++ "msync", /* 227 */
++ "mlock", /* 228 */
++ "munlock", /* 229 */
++ "mlockall", /* 230 */
++ "munlockall", /* 231 */
++ "mincore", /* 232 */
++ "madvise", /* 233 */
++ "remap_file_pages", /* 234 */
++ "mbind", /* 235 */
++ "get_mempolicy", /* 236 */
++ "set_mempolicy", /* 237 */
++ "migrate_pages", /* 238 */
++ "move_pages", /* 239 */
++ "rt_tgsigqueueinfo", /* 240 */
++ "perf_event_open", /* 241 */
++ "accept4", /* 242 */
++ "recvmmsg", /* 243 */
++ "arch_specific_syscall", /* 244 */
++ "245", /* 245 */
++ "246", /* 246 */
++ "247", /* 247 */
++ "248", /* 248 */
++ "249", /* 249 */
++ "250", /* 250 */
++ "251", /* 251 */
++ "252", /* 252 */
++ "253", /* 253 */
++ "254", /* 254 */
++ "255", /* 255 */
++ "256", /* 256 */
++ "257", /* 257 */
++ "258", /* 258 */
++ "259", /* 259 */
++ "wait4", /* 260 */
++ "prlimit64", /* 261 */
++ "fanotify_init", /* 262 */
++ "fanotify_mark", /* 263 */
++ "name_to_handle_at", /* 264 */
++ "open_by_handle_at", /* 265 */
++ "clock_adjtime", /* 266 */
++ "syncfs", /* 267 */
++ "setns", /* 268 */
++ "sendmmsg", /* 269 */
++ "process_vm_readv", /* 270 */
++ "process_vm_writev", /* 271 */
++ "kcmp", /* 272 */
++ "finit_module", /* 273 */
++ "syscalls", /* 274 */
++ "275", /* 275 */
++ "276", /* 276 */
++ "277", /* 277 */
++ "278", /* 278 */
++ "279", /* 279 */
++ "280", /* 280 */
++ "281", /* 281 */
++ "282", /* 282 */
++ "283", /* 283 */
++ "284", /* 284 */
++ "285", /* 285 */
++ "286", /* 286 */
++ "287", /* 287 */
++ "288", /* 288 */
++ "289", /* 289 */
++ "290", /* 290 */
++ "291", /* 291 */
++ "292", /* 292 */
++ "293", /* 293 */
++ "294", /* 294 */
++ "295", /* 295 */
++ "296", /* 296 */
++ "297", /* 297 */
++ "298", /* 298 */
++ "299", /* 299 */
++ "300", /* 300 */
++ "301", /* 301 */
++ "302", /* 302 */
++ "303", /* 303 */
++ "304", /* 304 */
++ "305", /* 305 */
++ "306", /* 306 */
++ "307", /* 307 */
++ "308", /* 308 */
++ "309", /* 309 */
++ "310", /* 310 */
++ "311", /* 311 */
++ "312", /* 312 */
++ "313", /* 313 */
++ "314", /* 314 */
++ "315", /* 315 */
++ "316", /* 316 */
++ "317", /* 317 */
++ "318", /* 318 */
++ "319", /* 319 */
++ "320", /* 320 */
++ "321", /* 321 */
++ "322", /* 322 */
++ "323", /* 323 */
++ "324", /* 324 */
++ "325", /* 325 */
++ "326", /* 326 */
++ "327", /* 327 */
++ "328", /* 328 */
++ "329", /* 329 */
++ "330", /* 330 */
++ "331", /* 331 */
++ "332", /* 332 */
++ "333", /* 333 */
++ "334", /* 334 */
++ "335", /* 335 */
++ "336", /* 336 */
++ "337", /* 337 */
++ "338", /* 338 */
++ "339", /* 339 */
++ "340", /* 340 */
++ "341", /* 341 */
++ "342", /* 342 */
++ "343", /* 343 */
++ "344", /* 344 */
++ "345", /* 345 */
++ "346", /* 346 */
++ "347", /* 347 */
++ "348", /* 348 */
++ "349", /* 349 */
++ "350", /* 350 */
++ "351", /* 351 */
++ "352", /* 352 */
++ "353", /* 353 */
++ "354", /* 354 */
++ "355", /* 355 */
++ "356", /* 356 */
++ "357", /* 357 */
++ "358", /* 358 */
++ "359", /* 359 */
++ "360", /* 360 */
++ "361", /* 361 */
++ "362", /* 362 */
++ "363", /* 363 */
++ "364", /* 364 */
++ "365", /* 365 */
++ "366", /* 366 */
++ "367", /* 367 */
++ "368", /* 368 */
++ "369", /* 369 */
++ "370", /* 370 */
++ "371", /* 371 */
++ "372", /* 372 */
++ "373", /* 373 */
++ "374", /* 374 */
++ "375", /* 375 */
++ "376", /* 376 */
++ "377", /* 377 */
++ "378", /* 378 */
++ "379", /* 379 */
++ "380", /* 380 */
++ "381", /* 381 */
++ "382", /* 382 */
++ "383", /* 383 */
++ "384", /* 384 */
++ "385", /* 385 */
++ "386", /* 386 */
++ "387", /* 387 */
++ "388", /* 388 */
++ "389", /* 389 */
++ "390", /* 390 */
++ "391", /* 391 */
++ "392", /* 392 */
++ "393", /* 393 */
++ "394", /* 394 */
++ "395", /* 395 */
++ "396", /* 396 */
++ "397", /* 397 */
++ "398", /* 398 */
++ "399", /* 399 */
++ "400", /* 400 */
++ "401", /* 401 */
++ "402", /* 402 */
++ "403", /* 403 */
++ "404", /* 404 */
++ "405", /* 405 */
++ "406", /* 406 */
++ "407", /* 407 */
++ "408", /* 408 */
++ "409", /* 409 */
++ "410", /* 410 */
++ "411", /* 411 */
++ "412", /* 412 */
++ "413", /* 413 */
++ "414", /* 414 */
++ "415", /* 415 */
++ "416", /* 416 */
++ "417", /* 417 */
++ "418", /* 418 */
++ "419", /* 419 */
++ "420", /* 420 */
++ "421", /* 421 */
++ "422", /* 422 */
++ "423", /* 423 */
++ "424", /* 424 */
++ "425", /* 425 */
++ "426", /* 426 */
++ "427", /* 427 */
++ "428", /* 428 */
++ "429", /* 429 */
++ "430", /* 430 */
++ "431", /* 431 */
++ "432", /* 432 */
++ "433", /* 433 */
++ "434", /* 434 */
++ "435", /* 435 */
++ "436", /* 436 */
++ "437", /* 437 */
++ "438", /* 438 */
++ "439", /* 439 */
++ "440", /* 440 */
++ "441", /* 441 */
++ "442", /* 442 */
++ "443", /* 443 */
++ "444", /* 444 */
++ "445", /* 445 */
++ "446", /* 446 */
++ "447", /* 447 */
++ "448", /* 448 */
++ "449", /* 449 */
++ "450", /* 450 */
++ "451", /* 451 */
++ "452", /* 452 */
++ "453", /* 453 */
++ "454", /* 454 */
++ "455", /* 455 */
++ "456", /* 456 */
++ "457", /* 457 */
++ "458", /* 458 */
++ "459", /* 459 */
++ "460", /* 460 */
++ "461", /* 461 */
++ "462", /* 462 */
++ "463", /* 463 */
++ "464", /* 464 */
++ "465", /* 465 */
++ "466", /* 466 */
++ "467", /* 467 */
++ "468", /* 468 */
++ "469", /* 469 */
++ "470", /* 470 */
++ "471", /* 471 */
++ "472", /* 472 */
++ "473", /* 473 */
++ "474", /* 474 */
++ "475", /* 475 */
++ "476", /* 476 */
++ "477", /* 477 */
++ "478", /* 478 */
++ "479", /* 479 */
++ "480", /* 480 */
++ "481", /* 481 */
++ "482", /* 482 */
++ "483", /* 483 */
++ "484", /* 484 */
++ "485", /* 485 */
++ "486", /* 486 */
++ "487", /* 487 */
++ "488", /* 488 */
++ "489", /* 489 */
++ "490", /* 490 */
++ "491", /* 491 */
++ "492", /* 492 */
++ "493", /* 493 */
++ "494", /* 494 */
++ "495", /* 495 */
++ "496", /* 496 */
++ "497", /* 497 */
++ "498", /* 498 */
++ "499", /* 499 */
++ "500", /* 500 */
++ "501", /* 501 */
++ "502", /* 502 */
++ "503", /* 503 */
++ "504", /* 504 */
++ "505", /* 505 */
++ "506", /* 506 */
++ "507", /* 507 */
++ "508", /* 508 */
++ "509", /* 509 */
++ "510", /* 510 */
++ "511", /* 511 */
++ "512", /* 512 */
++ "513", /* 513 */
++ "514", /* 514 */
++ "515", /* 515 */
++ "516", /* 516 */
++ "517", /* 517 */
++ "518", /* 518 */
++ "519", /* 519 */
++ "520", /* 520 */
++ "521", /* 521 */
++ "522", /* 522 */
++ "523", /* 523 */
++ "524", /* 524 */
++ "525", /* 525 */
++ "526", /* 526 */
++ "527", /* 527 */
++ "528", /* 528 */
++ "529", /* 529 */
++ "530", /* 530 */
++ "531", /* 531 */
++ "532", /* 532 */
++ "533", /* 533 */
++ "534", /* 534 */
++ "535", /* 535 */
++ "536", /* 536 */
++ "537", /* 537 */
++ "538", /* 538 */
++ "539", /* 539 */
++ "540", /* 540 */
++ "541", /* 541 */
++ "542", /* 542 */
++ "543", /* 543 */
++ "544", /* 544 */
++ "545", /* 545 */
++ "546", /* 546 */
++ "547", /* 547 */
++ "548", /* 548 */
++ "549", /* 549 */
++ "550", /* 550 */
++ "551", /* 551 */
++ "552", /* 552 */
++ "553", /* 553 */
++ "554", /* 554 */
++ "555", /* 555 */
++ "556", /* 556 */
++ "557", /* 557 */
++ "558", /* 558 */
++ "559", /* 559 */
++ "560", /* 560 */
++ "561", /* 561 */
++ "562", /* 562 */
++ "563", /* 563 */
++ "564", /* 564 */
++ "565", /* 565 */
++ "566", /* 566 */
++ "567", /* 567 */
++ "568", /* 568 */
++ "569", /* 569 */
++ "570", /* 570 */
++ "571", /* 571 */
++ "572", /* 572 */
++ "573", /* 573 */
++ "574", /* 574 */
++ "575", /* 575 */
++ "576", /* 576 */
++ "577", /* 577 */
++ "578", /* 578 */
++ "579", /* 579 */
++ "580", /* 580 */
++ "581", /* 581 */
++ "582", /* 582 */
++ "583", /* 583 */
++ "584", /* 584 */
++ "585", /* 585 */
++ "586", /* 586 */
++ "587", /* 587 */
++ "588", /* 588 */
++ "589", /* 589 */
++ "590", /* 590 */
++ "591", /* 591 */
++ "592", /* 592 */
++ "593", /* 593 */
++ "594", /* 594 */
++ "595", /* 595 */
++ "596", /* 596 */
++ "597", /* 597 */
++ "598", /* 598 */
++ "599", /* 599 */
++ "600", /* 600 */
++ "601", /* 601 */
++ "602", /* 602 */
++ "603", /* 603 */
++ "604", /* 604 */
++ "605", /* 605 */
++ "606", /* 606 */
++ "607", /* 607 */
++ "608", /* 608 */
++ "609", /* 609 */
++ "610", /* 610 */
++ "611", /* 611 */
++ "612", /* 612 */
++ "613", /* 613 */
++ "614", /* 614 */
++ "615", /* 615 */
++ "616", /* 616 */
++ "617", /* 617 */
++ "618", /* 618 */
++ "619", /* 619 */
++ "620", /* 620 */
++ "621", /* 621 */
++ "622", /* 622 */
++ "623", /* 623 */
++ "624", /* 624 */
++ "625", /* 625 */
++ "626", /* 626 */
++ "627", /* 627 */
++ "628", /* 628 */
++ "629", /* 629 */
++ "630", /* 630 */
++ "631", /* 631 */
++ "632", /* 632 */
++ "633", /* 633 */
++ "634", /* 634 */
++ "635", /* 635 */
++ "636", /* 636 */
++ "637", /* 637 */
++ "638", /* 638 */
++ "639", /* 639 */
++ "640", /* 640 */
++ "641", /* 641 */
++ "642", /* 642 */
++ "643", /* 643 */
++ "644", /* 644 */
++ "645", /* 645 */
++ "646", /* 646 */
++ "647", /* 647 */
++ "648", /* 648 */
++ "649", /* 649 */
++ "650", /* 650 */
++ "651", /* 651 */
++ "652", /* 652 */
++ "653", /* 653 */
++ "654", /* 654 */
++ "655", /* 655 */
++ "656", /* 656 */
++ "657", /* 657 */
++ "658", /* 658 */
++ "659", /* 659 */
++ "660", /* 660 */
++ "661", /* 661 */
++ "662", /* 662 */
++ "663", /* 663 */
++ "664", /* 664 */
++ "665", /* 665 */
++ "666", /* 666 */
++ "667", /* 667 */
++ "668", /* 668 */
++ "669", /* 669 */
++ "670", /* 670 */
++ "671", /* 671 */
++ "672", /* 672 */
++ "673", /* 673 */
++ "674", /* 674 */
++ "675", /* 675 */
++ "676", /* 676 */
++ "677", /* 677 */
++ "678", /* 678 */
++ "679", /* 679 */
++ "680", /* 680 */
++ "681", /* 681 */
++ "682", /* 682 */
++ "683", /* 683 */
++ "684", /* 684 */
++ "685", /* 685 */
++ "686", /* 686 */
++ "687", /* 687 */
++ "688", /* 688 */
++ "689", /* 689 */
++ "690", /* 690 */
++ "691", /* 691 */
++ "692", /* 692 */
++ "693", /* 693 */
++ "694", /* 694 */
++ "695", /* 695 */
++ "696", /* 696 */
++ "697", /* 697 */
++ "698", /* 698 */
++ "699", /* 699 */
++ "700", /* 700 */
++ "701", /* 701 */
++ "702", /* 702 */
++ "703", /* 703 */
++ "704", /* 704 */
++ "705", /* 705 */
++ "706", /* 706 */
++ "707", /* 707 */
++ "708", /* 708 */
++ "709", /* 709 */
++ "710", /* 710 */
++ "711", /* 711 */
++ "712", /* 712 */
++ "713", /* 713 */
++ "714", /* 714 */
++ "715", /* 715 */
++ "716", /* 716 */
++ "717", /* 717 */
++ "718", /* 718 */
++ "719", /* 719 */
++ "720", /* 720 */
++ "721", /* 721 */
++ "722", /* 722 */
++ "723", /* 723 */
++ "724", /* 724 */
++ "725", /* 725 */
++ "726", /* 726 */
++ "727", /* 727 */
++ "728", /* 728 */
++ "729", /* 729 */
++ "730", /* 730 */
++ "731", /* 731 */
++ "732", /* 732 */
++ "733", /* 733 */
++ "734", /* 734 */
++ "735", /* 735 */
++ "736", /* 736 */
++ "737", /* 737 */
++ "738", /* 738 */
++ "739", /* 739 */
++ "740", /* 740 */
++ "741", /* 741 */
++ "742", /* 742 */
++ "743", /* 743 */
++ "744", /* 744 */
++ "745", /* 745 */
++ "746", /* 746 */
++ "747", /* 747 */
++ "748", /* 748 */
++ "749", /* 749 */
++ "750", /* 750 */
++ "751", /* 751 */
++ "752", /* 752 */
++ "753", /* 753 */
++ "754", /* 754 */
++ "755", /* 755 */
++ "756", /* 756 */
++ "757", /* 757 */
++ "758", /* 758 */
++ "759", /* 759 */
++ "760", /* 760 */
++ "761", /* 761 */
++ "762", /* 762 */
++ "763", /* 763 */
++ "764", /* 764 */
++ "765", /* 765 */
++ "766", /* 766 */
++ "767", /* 767 */
++ "768", /* 768 */
++ "769", /* 769 */
++ "770", /* 770 */
++ "771", /* 771 */
++ "772", /* 772 */
++ "773", /* 773 */
++ "774", /* 774 */
++ "775", /* 775 */
++ "776", /* 776 */
++ "777", /* 777 */
++ "778", /* 778 */
++ "779", /* 779 */
++ "780", /* 780 */
++ "781", /* 781 */
++ "782", /* 782 */
++ "783", /* 783 */
++ "784", /* 784 */
++ "785", /* 785 */
++ "786", /* 786 */
++ "787", /* 787 */
++ "788", /* 788 */
++ "789", /* 789 */
++ "790", /* 790 */
++ "791", /* 791 */
++ "792", /* 792 */
++ "793", /* 793 */
++ "794", /* 794 */
++ "795", /* 795 */
++ "796", /* 796 */
++ "797", /* 797 */
++ "798", /* 798 */
++ "799", /* 799 */
++ "800", /* 800 */
++ "801", /* 801 */
++ "802", /* 802 */
++ "803", /* 803 */
++ "804", /* 804 */
++ "805", /* 805 */
++ "806", /* 806 */
++ "807", /* 807 */
++ "808", /* 808 */
++ "809", /* 809 */
++ "810", /* 810 */
++ "811", /* 811 */
++ "812", /* 812 */
++ "813", /* 813 */
++ "814", /* 814 */
++ "815", /* 815 */
++ "816", /* 816 */
++ "817", /* 817 */
++ "818", /* 818 */
++ "819", /* 819 */
++ "820", /* 820 */
++ "821", /* 821 */
++ "822", /* 822 */
++ "823", /* 823 */
++ "824", /* 824 */
++ "825", /* 825 */
++ "826", /* 826 */
++ "827", /* 827 */
++ "828", /* 828 */
++ "829", /* 829 */
++ "830", /* 830 */
++ "831", /* 831 */
++ "832", /* 832 */
++ "833", /* 833 */
++ "834", /* 834 */
++ "835", /* 835 */
++ "836", /* 836 */
++ "837", /* 837 */
++ "838", /* 838 */
++ "839", /* 839 */
++ "840", /* 840 */
++ "841", /* 841 */
++ "842", /* 842 */
++ "843", /* 843 */
++ "844", /* 844 */
++ "845", /* 845 */
++ "846", /* 846 */
++ "847", /* 847 */
++ "848", /* 848 */
++ "849", /* 849 */
++ "850", /* 850 */
++ "851", /* 851 */
++ "852", /* 852 */
++ "853", /* 853 */
++ "854", /* 854 */
++ "855", /* 855 */
++ "856", /* 856 */
++ "857", /* 857 */
++ "858", /* 858 */
++ "859", /* 859 */
++ "860", /* 860 */
++ "861", /* 861 */
++ "862", /* 862 */
++ "863", /* 863 */
++ "864", /* 864 */
++ "865", /* 865 */
++ "866", /* 866 */
++ "867", /* 867 */
++ "868", /* 868 */
++ "869", /* 869 */
++ "870", /* 870 */
++ "871", /* 871 */
++ "872", /* 872 */
++ "873", /* 873 */
++ "874", /* 874 */
++ "875", /* 875 */
++ "876", /* 876 */
++ "877", /* 877 */
++ "878", /* 878 */
++ "879", /* 879 */
++ "880", /* 880 */
++ "881", /* 881 */
++ "882", /* 882 */
++ "883", /* 883 */
++ "884", /* 884 */
++ "885", /* 885 */
++ "886", /* 886 */
++ "887", /* 887 */
++ "888", /* 888 */
++ "889", /* 889 */
++ "890", /* 890 */
++ "891", /* 891 */
++ "892", /* 892 */
++ "893", /* 893 */
++ "894", /* 894 */
++ "895", /* 895 */
++ "896", /* 896 */
++ "897", /* 897 */
++ "898", /* 898 */
++ "899", /* 899 */
++ "900", /* 900 */
++ "901", /* 901 */
++ "902", /* 902 */
++ "903", /* 903 */
++ "904", /* 904 */
++ "905", /* 905 */
++ "906", /* 906 */
++ "907", /* 907 */
++ "908", /* 908 */
++ "909", /* 909 */
++ "910", /* 910 */
++ "911", /* 911 */
++ "912", /* 912 */
++ "913", /* 913 */
++ "914", /* 914 */
++ "915", /* 915 */
++ "916", /* 916 */
++ "917", /* 917 */
++ "918", /* 918 */
++ "919", /* 919 */
++ "920", /* 920 */
++ "921", /* 921 */
++ "922", /* 922 */
++ "923", /* 923 */
++ "924", /* 924 */
++ "925", /* 925 */
++ "926", /* 926 */
++ "927", /* 927 */
++ "928", /* 928 */
++ "929", /* 929 */
++ "930", /* 930 */
++ "931", /* 931 */
++ "932", /* 932 */
++ "933", /* 933 */
++ "934", /* 934 */
++ "935", /* 935 */
++ "936", /* 936 */
++ "937", /* 937 */
++ "938", /* 938 */
++ "939", /* 939 */
++ "940", /* 940 */
++ "941", /* 941 */
++ "942", /* 942 */
++ "943", /* 943 */
++ "944", /* 944 */
++ "945", /* 945 */
++ "946", /* 946 */
++ "947", /* 947 */
++ "948", /* 948 */
++ "949", /* 949 */
++ "950", /* 950 */
++ "951", /* 951 */
++ "952", /* 952 */
++ "953", /* 953 */
++ "954", /* 954 */
++ "955", /* 955 */
++ "956", /* 956 */
++ "957", /* 957 */
++ "958", /* 958 */
++ "959", /* 959 */
++ "960", /* 960 */
++ "961", /* 961 */
++ "962", /* 962 */
++ "963", /* 963 */
++ "964", /* 964 */
++ "965", /* 965 */
++ "966", /* 966 */
++ "967", /* 967 */
++ "968", /* 968 */
++ "969", /* 969 */
++ "970", /* 970 */
++ "971", /* 971 */
++ "972", /* 972 */
++ "973", /* 973 */
++ "974", /* 974 */
++ "975", /* 975 */
++ "976", /* 976 */
++ "977", /* 977 */
++ "978", /* 978 */
++ "979", /* 979 */
++ "980", /* 980 */
++ "981", /* 981 */
++ "982", /* 982 */
++ "983", /* 983 */
++ "984", /* 984 */
++ "985", /* 985 */
++ "986", /* 986 */
++ "987", /* 987 */
++ "988", /* 988 */
++ "989", /* 989 */
++ "990", /* 990 */
++ "991", /* 991 */
++ "992", /* 992 */
++ "993", /* 993 */
++ "994", /* 994 */
++ "995", /* 995 */
++ "996", /* 996 */
++ "997", /* 997 */
++ "998", /* 998 */
++ "999", /* 999 */
++ "1000", /* 1000 */
++ "1001", /* 1001 */
++ "1002", /* 1002 */
++ "1003", /* 1003 */
++ "1004", /* 1004 */
++ "1005", /* 1005 */
++ "1006", /* 1006 */
++ "1007", /* 1007 */
++ "1008", /* 1008 */
++ "1009", /* 1009 */
++ "1010", /* 1010 */
++ "1011", /* 1011 */
++ "1012", /* 1012 */
++ "1013", /* 1013 */
++ "1014", /* 1014 */
++ "1015", /* 1015 */
++ "1016", /* 1016 */
++ "1017", /* 1017 */
++ "1018", /* 1018 */
++ "1019", /* 1019 */
++ "1020", /* 1020 */
++ "1021", /* 1021 */
++ "1022", /* 1022 */
++ "1023", /* 1023 */
++ "open", /* 1024 */
++ "link", /* 1025 */
++ "unlink", /* 1026 */
++ "mknod", /* 1027 */
++ "chmod", /* 1028 */
++ "chown", /* 1029 */
++ "mkdir", /* 1030 */
++ "rmdir", /* 1031 */
++ "lchown", /* 1032 */
++ "access", /* 1033 */
++ "rename", /* 1034 */
++ "readlink", /* 1035 */
++ "symlink", /* 1036 */
++ "utimes", /* 1037 */
++ "stat", /* 1038 */
++ "lstat", /* 1039 */
++ "pipe", /* 1040 */
++ "dup2", /* 1041 */
++ "epoll_create", /* 1042 */
++ "inotify_init", /* 1043 */
++ "eventfd", /* 1044 */
++ "signalfd", /* 1045 */
++ "sendfile", /* 1046 */
++ "ftruncate", /* 1047 */
++ "truncate", /* 1048 */
++ "stat", /* 1049 */
++ "lstat", /* 1050 */
++ "fstat", /* 1051 */
++ "fcntl", /* 1052 */
++ "fadvise64", /* 1053 */
++ "newfstatat", /* 1054 */
++ "fstatfs", /* 1055 */
++ "statfs", /* 1056 */
++ "lseek", /* 1057 */
++ "mmap", /* 1058 */
++ "alarm", /* 1059 */
++ "getpgrp", /* 1060 */
++ "pause", /* 1061 */
++ "time", /* 1062 */
++ "utime", /* 1063 */
++ "creat", /* 1064 */
++ "getdents", /* 1065 */
++ "futimesat", /* 1066 */
++ "select", /* 1067 */
++ "poll", /* 1068 */
++ "epoll_wait", /* 1069 */
++ "ustat", /* 1070 */
++ "vfork", /* 1071 */
++ "oldwait4", /* 1072 */
++ "recv", /* 1073 */
++ "send", /* 1074 */
++ "bdflush", /* 1075 */
++ "umount", /* 1076 */
++ "uselib", /* 1077 */
++ "_sysctl", /* 1078 */
++ "fork", /* 1079 */
+diff --git a/sysdeps/linux-gnu/aarch64/trace.c b/sysdeps/linux-gnu/aarch64/trace.c
+new file mode 100644
+index 0000000..5544b51
+--- /dev/null
++++ b/sysdeps/linux-gnu/aarch64/trace.c
+@@ -0,0 +1,84 @@
++/*
++ * This file is part of ltrace.
++ * Copyright (C) 2014 Petr Machata, Red Hat, Inc.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of the
++ * License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
++ * 02110-1301 USA
++ */
++
++#include <sys/ptrace.h>
++#include <sys/types.h>
++#include <sys/wait.h>
++#include <asm/ptrace.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#include "backend.h"
++#include "proc.h"
++
++void
++get_arch_dep(struct Process *proc)
++{
++}
++
++int aarch64_read_gregs(struct Process *proc, struct user_pt_regs *regs);
++
++/* The syscall instruction is:
++ * | 31 21 | 20 5 | 4 0 |
++ * | 1 1 0 1 0 1 0 0 | 0 0 0 | imm16 | 0 0 0 0 1 | */
++#define SVC_MASK 0xffe0001f
++#define SVC_VALUE 0xd4000001
++
++int
++syscall_p(struct Process *proc, int status, int *sysnum)
++{
++ if (WIFSTOPPED(status)
++ && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
++
++ struct user_pt_regs regs;
++ if (aarch64_read_gregs(proc, &regs) < 0) {
++ fprintf(stderr, "syscall_p: "
++ "Couldn't read registers of %d.\n", proc->pid);
++ return -1;
++ }
++
++ errno = 0;
++ unsigned long insn = (unsigned long) ptrace(PTRACE_PEEKTEXT,
++ proc->pid,
++ regs.pc - 4, 0);
++ if (insn == -1UL && errno != 0) {
++ fprintf(stderr, "syscall_p: "
++ "Couldn't peek into %d: %s\n", proc->pid,
++ strerror(errno));
++ return -1;
++ }
++
++ insn &= 0xffffffffUL;
++ if ((insn & SVC_MASK) == SVC_VALUE) {
++ *sysnum = regs.regs[8];
++
++ size_t d1 = proc->callstack_depth - 1;
++ if (proc->callstack_depth > 0
++ && proc->callstack[d1].is_syscall
++ && proc->callstack[d1].c_un.syscall == *sysnum)
++ return 2;
++
++ return 1;
++ }
++ }
++
++ return 0;
++}
+--
+1.9.1
+
diff --git a/system/ltrace/add_ppc64le.patch b/system/ltrace/add_ppc64le.patch
new file mode 100644
index 000000000..32efa8b52
--- /dev/null
+++ b/system/ltrace/add_ppc64le.patch
@@ -0,0 +1,54 @@
+--- ltrace-0.7.3.orig/configure.ac
++++ ltrace-0.7.3/configure.ac
+@@ -43,7 +43,7 @@
+ arm*|sa110) HOST_CPU="arm" ;;
+ cris*) HOST_CPU="cris" ;;
+ mips*) HOST_CPU="mips" ;;
+- powerpc|powerpc64) HOST_CPU="ppc" ;;
++ powerpc|powerpc64|powerpc64le) HOST_CPU="ppc" ;;
+ sun4u|sparc64) HOST_CPU="sparc" ;;
+ s390x) HOST_CPU="s390" ;;
+ i?86|x86_64) HOST_CPU="x86" ;;
+@@ -159,7 +159,7 @@
+ arm*|sa110) UNWIND_ARCH="arm" ;;
+ i?86) UNWIND_ARCH="x86" ;;
+ powerpc) UNWIND_ARCH="ppc32" ;;
+- powerpc64) UNWIND_ARCH="ppc64" ;;
++ powerpc64|powerpc64le) UNWIND_ARCH="ppc64" ;;
+ mips*) UNWIND_ARCH="mips" ;;
+ *) UNWIND_ARCH="${host_cpu}" ;;
+ esac
+--- ltrace-0.7.3.orig/sysdeps/linux-gnu/ppc/ptrace.h
++++ ltrace-0.7.3/sysdeps/linux-gnu/ppc/ptrace.h
+@@ -18,4 +18,5 @@
+ * 02110-1301 USA
+ */
+
++#include <asm/ptrace.h>
+ #include <sys/ptrace.h>
+--- ltrace-0.7.3.orig/sysdeps/linux-gnu/ppc/regs.c
++++ ltrace-0.7.3/sysdeps/linux-gnu/ppc/regs.c
+@@ -26,7 +26,9 @@
+ #include <sys/ptrace.h>
+ #include <asm/ptrace.h>
+ #include <errno.h>
++#ifdef HAVE_ERROR_H
+ #include <error.h>
++#endif
+
+ #include "proc.h"
+ #include "common.h"
+@@ -47,8 +49,11 @@
+ void
+ set_instruction_pointer(Process *proc, void *addr)
+ {
+- if (ptrace(PTRACE_POKEUSER, proc->pid, sizeof(long)*PT_NIP, addr) != 0)
+- error(0, errno, "set_instruction_pointer");
++ if (ptrace(PTRACE_POKEUSER, proc->pid, sizeof(long)*PT_NIP, addr) != 0){
++ strerror(0, errno, "set_instruction_pointer");
++ report_global_error("%s: set_instruction_pointer",
++ strerror(errno));
++ }
+ }
+
+ void *
diff --git a/system/ltrace/musl.patch b/system/ltrace/musl.patch
new file mode 100644
index 000000000..2dc909c95
--- /dev/null
+++ b/system/ltrace/musl.patch
@@ -0,0 +1,153 @@
+--- ./configure.ac.orig
++++ ./configure.ac
+@@ -34,6 +34,7 @@
+ case "${host_os}" in
+ linux-gnu*) HOST_OS="linux-gnu" ;;
+ linux-uclibc*) HOST_OS="linux-gnu" ;;
++ linux-musl*) HOST_OS="linux-gnu" ;;
+ *) AC_MSG_ERROR([unkown host-os ${host_os}]) ;;
+ esac
+ AC_SUBST(HOST_OS)
+@@ -234,6 +235,7 @@
+ sys/param.h \
+ sys/time.h \
+ unistd.h \
++ error.h \
+ ])
+
+ # Checks for typedefs, structures, and compiler characteristics.
+diff --git a/expr.c b/expr.c
+index 32860fd..374c549 100644
+--- a/expr.c
++++ b/expr.c
+@@ -19,9 +19,12 @@
+ */
+
+ #include <string.h>
++#include <stdio.h>
+ #include <assert.h>
+ #include <errno.h>
++#ifdef HAVE_ERROR_H
+ #include <error.h>
++#endif
+ #include <stdlib.h>
+
+ #include "expr.h"
+@@ -330,8 +333,11 @@ expr_self(void)
+ static struct expr_node *node = NULL;
+ if (node == NULL) {
+ node = malloc(sizeof(*node));
+- if (node == NULL)
+- error(1, errno, "malloc expr_self");
++ if (node == NULL) {
++ fprintf(stderr, "%s: malloc expr_self\n",
++ strerror(errno));
++ exit(1);
++ }
+ expr_init_self(node);
+ }
+ return node;
+diff --git a/glob.c b/glob.c
+index 075c867..06fec47 100644
+--- a/glob.c
++++ b/glob.c
+@@ -180,7 +180,7 @@ glob_to_regex(const char *glob, char **retp)
+ goto fail;
+ }
+ *retp = buf;
+- return REG_NOERROR;
++ return 0;
+ }
+
+ int
+@@ -188,7 +188,7 @@ globcomp(regex_t *preg, const char *glob, int cflags)
+ {
+ char *regex = NULL;
+ int status = glob_to_regex(glob, &regex);
+- if (status != REG_NOERROR)
++ if (status != 0)
+ return status;
+ assert(regex != NULL);
+ status = regcomp(preg, regex, cflags);
+diff --git a/options.c b/options.c
+index 1e19dc7..1dc5e1e 100644
+--- a/options.c
++++ b/options.c
+@@ -204,7 +204,7 @@ compile_libname(const char *expr, const char *a_lib, int lib_re_p,
+
+ regex_t lib_re;
+ int status = (lib_re_p ? regcomp : globcomp)(&lib_re, lib, 0);
+- if (status != REG_NOERROR) {
++ if (status != 0) {
+ char buf[100];
+ regerror(status, &lib_re, buf, sizeof buf);
+ fprintf(stderr, "Rule near '%s' will be ignored: %s.\n",
+diff --git a/read_config_file.c b/read_config_file.c
+index e247436..73528fe 100644
+--- a/read_config_file.c
++++ b/read_config_file.c
+@@ -27,7 +27,9 @@
+ #include <stdlib.h>
+ #include <ctype.h>
+ #include <errno.h>
++#ifdef HAVE_ERROR_H
+ #include <error.h>
++#endif
+ #include <assert.h>
+
+ #include "common.h"
+@@ -1258,8 +1260,12 @@ void
+ init_global_config(void)
+ {
+ struct arg_type_info *info = malloc(2 * sizeof(*info));
+- if (info == NULL)
+- error(1, errno, "malloc in init_global_config");
++ if (info == NULL) {
++ report_error(filename, line_no,
++ "%s: malloc in init_global_config",
++ strerror(errno));
++ exit(1);
++ }
+
+ memset(info, 0, 2 * sizeof(*info));
+ info[0].type = ARGTYPE_POINTER;
+diff --git a/zero.c b/zero.c
+index bc119ee..e685f59 100644
+--- a/zero.c
++++ b/zero.c
+@@ -18,8 +18,11 @@
+ * 02110-1301 USA
+ */
+
++#ifdef HAVE_ERROR_H
+ #include <error.h>
++#endif
+ #include <errno.h>
++#include <string.h>
+
+ #include "zero.h"
+ #include "common.h"
+@@ -96,8 +99,11 @@ expr_node_zero(void)
+ static struct expr_node *node = NULL;
+ if (node == NULL) {
+ node = malloc(sizeof(*node));
+- if (node == NULL)
+- error(1, errno, "malloc expr_node_zero");
++ if (node == NULL) {
++ report_global_error("%s: malloc expr_node_zero",
++ strerror(errno));
++ exit(1);
++ }
+ expr_init_cb1(node, &zero1_callback,
+ expr_self(), 0, (void *)-1);
+ }
+--- ./proc.h.orig
++++ ./proc.h
+@@ -26,6 +26,7 @@
+ #include "config.h"
+
+ #include <sys/time.h>
++#include <unistd.h>
+
+ #if defined(HAVE_LIBUNWIND)
+ # include <libunwind.h>
diff --git a/system/mlt/APKBUILD b/system/mlt/APKBUILD
new file mode 100644
index 000000000..0dc7d8041
--- /dev/null
+++ b/system/mlt/APKBUILD
@@ -0,0 +1,43 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer:
+pkgname=mlt
+pkgver=6.8.0
+pkgrel=0
+pkgdesc="MLT Multimedia Framework"
+url="https://www.mltframework.org/"
+arch="all !s390x" # depends on fftw which does not work on s390x
+options="!check" # No test suite.
+license="LGPL-2.1"
+makedepends="ffmpeg-dev libsamplerate-dev sox-dev gtk+2.0-dev sdl_image-dev
+ frei0r-plugins-dev libxml2-dev fftw-dev sdl2-dev sdl-dev libexif-dev
+ bsd-compat-headers qt5-qttools-dev qt5-qtsvg-dev"
+subpackages="$pkgname-dev"
+source="https://github.com/mltframework/mlt/releases/download/v$pkgver/mlt-$pkgver.tar.gz
+ mlt-6.8.0-locale-header.patch
+ "
+builddir="$srcdir/mlt-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var \
+ --avformat-swscale \
+ --enable-motion-est \
+ --enable-gpl \
+ --enable-gpl3 \
+ --disable-rtaudio
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="5f88d82b0b1656875d19c7cd322181cf974e1cad36692854835ae313723dfd412e6ba4fbb6cca9d70756ca83b512b0f78e95df517cfa007c76f94b26a9901ec8 mlt-6.8.0.tar.gz
+c7c9fe70475ccf78c719c1ca6e1a7f2189e08abe04d556fe558dd787799bd7808d61326cfb2818eefe4a6868eed300b0c0d1480aa3df302b65b79a9a9aacc1b1 mlt-6.8.0-locale-header.patch"
diff --git a/system/mlt/mlt-6.8.0-locale-header.patch b/system/mlt/mlt-6.8.0-locale-header.patch
new file mode 100644
index 000000000..5b45b600a
--- /dev/null
+++ b/system/mlt/mlt-6.8.0-locale-header.patch
@@ -0,0 +1,18 @@
+Extremely incorrect logic here; fix it so that locale_t is defined properly.
+
+--- mlt-6.8.0/src/framework/mlt_property.h.old 2018-05-10 20:16:56.000000000 -0500
++++ mlt-6.8.0/src/framework/mlt_property.h 2018-06-07 05:22:57.345580154 -0500
+@@ -30,10 +30,10 @@
+ #include <sys/param.h>
+ #endif
+
+-#if (defined(__GLIBC__) && !defined(__APPLE__)) || HAVE_LOCALE_H
+-# include <locale.h>
+-#elif defined(__APPLE__) || (__FreeBSD_version >= 900506)
++#if defined(__APPLE__) || (__FreeBSD_version >= 900506)
+ # include <xlocale.h>
++#elif defined(__linux__) || HAVE_LOCALE_H
++# include <locale.h>
+ #else
+ typedef char* locale_t;
+ #endif
diff --git a/system/mutt/APKBUILD b/system/mutt/APKBUILD
new file mode 100644
index 000000000..2b3424421
--- /dev/null
+++ b/system/mutt/APKBUILD
@@ -0,0 +1,61 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Contributor: Andrew Manison<amanison@anselsystems.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=mutt
+pkgver=1.9.1
+pkgrel=0
+pkgdesc="a small but very powerful text-mode email client"
+url="http://www.mutt.org"
+arch="all"
+license="GPL"
+makedepends="cyrus-sasl-dev gdbm-dev gettext-dev gpgme-dev
+ libidn-dev ncurses-dev openssl-dev perl"
+options="suid !check"
+subpackages="$pkgname-doc $pkgname-lang"
+source="https://bitbucket.org/$pkgname/$pkgname/downloads/$pkgname-$pkgver.tar.gz"
+builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ ISPELL=/usr/bin/hunspell \
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --enable-imap \
+ --enable-pop \
+ --enable-smtp \
+ --enable-hcache \
+ --enable-gpgme \
+ --enable-sidebar \
+ --enable-smime \
+ --with-curses \
+ --with-mailpath=/var/spool/mail \
+ --with-docdir=/usr/share/doc/$pkgname \
+ --without-included-gettext \
+ --with-ssl \
+ --with-sasl
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ rm "$pkgdir"/etc/*.dist \
+ "$pkgdir"/etc/mime.types \
+ "$pkgdir"/usr/bin/muttbug \
+ "$pkgdir"/usr/bin/flea
+
+ # Don't tamper with the global configuration file.
+ # Many options set in the global config cannot be
+ # overwritten in the users configuration file.
+ # Example: Resetting colors isn't possible.
+ install -Dm644 contrib/gpg.rc \
+ "$pkgdir"/etc/Muttrc.gpg.dist
+}
+
+sha512sums="1a6871eb8499c60ae18b03d56b81e64de1643c68f8fbe05bbe114085b20098be58175e5bd6d2515e8332a824cbed75640744a261d4f10654c56625f903224095 mutt-1.9.1.tar.gz"
diff --git a/system/neon/APKBUILD b/system/neon/APKBUILD
new file mode 100644
index 000000000..a0ddbd5d4
--- /dev/null
+++ b/system/neon/APKBUILD
@@ -0,0 +1,41 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=neon
+pkgver=0.30.2
+pkgrel=2
+pkgdesc="HTTP and WebDAV client library with a C interface"
+url="http://www.webdav.org/neon/"
+arch="all"
+license="GPL LGPL"
+makedepends="expat-dev openssl-dev zlib-dev"
+depends="ca-certificates"
+depends_dev="$makedepends"
+subpackages="$pkgname-dev $pkgname-doc"
+source="https://distfiles.adelielinux.org/source/$pkgname-$pkgver.tar.gz"
+
+build () {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --with-ssl \
+ --with-expat \
+ --without-gssapi \
+ --disable-nls \
+ --enable-shared \
+ --disable-static \
+ --enable-threadsafe-ssl=posix \
+ --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+sha512sums="634caf87522e0bd2695c6fba39cae2465e403f9fbd8007eb10e4e035c765d24cb8da932c67bfa35c34aa51b90c7bc7037ebebaa1ec43259366d5d07233efc631 neon-0.30.2.tar.gz"
diff --git a/system/openldap/APKBUILD b/system/openldap/APKBUILD
new file mode 100644
index 000000000..84cbc1471
--- /dev/null
+++ b/system/openldap/APKBUILD
@@ -0,0 +1,212 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+#
+# secfixes:
+# 2.4.46:
+# - CVE-2017-14159
+# - CVE-2017-17740
+# 2.4.44-r5:
+# - CVE-2017-9287
+#
+pkgname=openldap
+pkgver=2.4.46
+pkgrel=0
+pkgdesc="LDAP Server"
+url="http://www.openldap.org/"
+arch="all"
+options="!check" # Test suite takes > 2 hours to complete on each builder.
+license="custom"
+depends=""
+pkgusers="ldap"
+pkggroups="ldap"
+depends_dev="openssl-dev cyrus-sasl-dev util-linux-dev"
+makedepends="$depends_dev db-dev groff unixodbc-dev libtool
+ autoconf automake libtool"
+subpackages="$pkgname-dev $pkgname-doc libldap $pkgname-openrc
+ $pkgname-clients $pkgname-passwd-pbkdf2:passwd_pbkdf2
+ $pkgname-backend-all:_backend_all:noarch
+ $pkgname-overlay-all:_overlay_all:noarch"
+install="$pkgname.pre-install $pkgname.post-install $pkgname.post-upgrade"
+source="ftp://ftp.$pkgname.org/pub/OpenLDAP/$pkgname-release/$pkgname-$pkgver.tgz
+ openldap-2.4-ppolicy.patch
+ openldap-2.4.11-libldap_r.patch
+ fix-manpages.patch
+ configs.patch
+
+ slapd.initd
+ slapd.confd
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+
+# SLAPD backends
+_backends=""
+for _name in bdb dnssrv hdb ldap mdb meta monitor null passwd \
+ relay shell sql sock
+do
+ subpackages="$subpackages $pkgname-back-$_name:_backend"
+ _backends="$_backends $pkgname-back-$_name"
+done
+
+# SLAPD overlays
+_overlays=""
+for _name in accesslog auditlog collect constraint dds deref dyngroup \
+ dynlist memberof ppolicy proxycache refint retcode rwm seqmod \
+ sssvlv syncprov translucent unique valsort
+do
+ subpackages="$subpackages $pkgname-overlay-$_name:_overlay"
+ _overlays="$_overlays $pkgname-overlay-$_name"
+done
+
+prepare() {
+ cd "$builddir"
+ update_config_sub
+
+ sed -i '/^STRIP/s,-s,,g' build/top.mk
+ libtoolize --force && aclocal && autoconf
+}
+
+build () {
+ cd "$builddir"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --libexecdir=/usr/lib \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var/lib/openldap \
+ --enable-slapd \
+ --enable-crypt \
+ --enable-modules \
+ --enable-dynamic \
+ --enable-bdb=mod \
+ --enable-dnssrv=mod \
+ --enable-hdb=mod \
+ --enable-ldap=mod \
+ --enable-mdb=mod \
+ --enable-meta=mod \
+ --enable-monitor=mod \
+ --enable-null=mod \
+ --enable-passwd=mod \
+ --enable-relay=mod \
+ --enable-shell=mod \
+ --enable-sock=mod \
+ --enable-sql=mod \
+ --enable-overlays=mod \
+ --with-tls=openssl \
+ --with-cyrus-sasl
+ make
+
+ # Build passwd pbkdf2.
+ make prefix=/usr libexecdir=/usr/lib \
+ -C contrib/slapd-modules/passwd/pbkdf2
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+
+ make DESTDIR="$pkgdir" install
+
+ # Install passwd pbkdf2.
+ make DESTDIR="$pkgdir" prefix=/usr libexecdir=/usr/lib \
+ -C contrib/slapd-modules/passwd/pbkdf2 install
+
+ cd "$pkgdir"
+
+ rmdir var/lib/openldap/run
+
+ # Fix tools symlinks to slapd.
+ local path; for path in $(find usr/sbin/ -type l); do
+ ln -sf slapd $path
+ done
+
+ # Move executable from lib to sbin.
+ mv usr/lib/slapd usr/sbin/
+
+ # Move *.default configs to docs.
+ mkdir -p usr/share/doc/$pkgname
+ mv etc/openldap/*.default usr/share/doc/$pkgname/
+
+ chgrp ldap etc/openldap/slapd.*
+ chmod g+r etc/openldap/slapd.*
+
+ install -d -m 700 -o ldap -g ldap \
+ var/lib/openldap \
+ var/lib/openldap/openldap-data
+
+ install -D -m 755 "$srcdir"/slapd.initd etc/init.d/slapd
+ install -D -m 644 "$srcdir"/slapd.confd etc/conf.d/slapd
+}
+
+libldap() {
+ pkgdesc="OpenLDAP libraries"
+ depends=""
+ install=""
+
+ _submv "usr/lib/*.so*" etc/openldap/ldap.conf
+}
+
+clients() {
+ pkgdesc="LDAP client utilities"
+
+ _submv usr/bin
+}
+
+passwd_pbkdf2() {
+ pkgdesc="PBKDF2 OpenLDAP support"
+ depends="$pkgname"
+
+ _submv "usr/lib/openldap/pw-pbkdf2.*"
+}
+
+_backend_all() {
+ pkgdesc="Virtual package that installs all OpenLDAP backends"
+ depends="$_backends"
+
+ mkdir -p "$subpkgdir"
+}
+
+_overlay_all() {
+ pkgdesc="Virtual package that installs all OpenLDAP overlays"
+ depends="$_overlays"
+
+ mkdir -p "$subpkgdir"
+}
+
+_backend() {
+ backend_name="${subpkgname#openldap-back-}"
+ pkgdesc="OpenLDAP $backend_name backend"
+
+ _submv "usr/lib/openldap/back_$backend_name*"
+}
+
+_overlay() {
+ overlay_name="${subpkgname#openldap-overlay-}"
+ pkgdesc="OpenLDAP $backend_name overlay"
+
+ case "$overlay_name" in
+ proxycache) overlay_name=pcache;;
+ esac
+ _submv "usr/lib/openldap/$overlay_name*"
+}
+
+_submv() {
+ local path; for path in "$@"; do
+ mkdir -p "$subpkgdir"/${path%/*}
+ mv "$pkgdir"/$path "$subpkgdir"/${path%/*}/
+ done
+}
+
+sha512sums="eef39d43f04aa09c657a1422cefef060fe00368559ae40d0d97536c08ebeaaa1ab06207b3f121ba6afcde54abdc550027c3505e5217e5fd47ae6f8c001260186 openldap-2.4.46.tgz
+5d34d49eabe7cb66cf8284cc3bd9730fa23df4932df68549e242d250ee50d40c434ae074ebc720d5fbcd9d16587c9333c5598d30a5f1177caa61461ab7771f38 openldap-2.4-ppolicy.patch
+44d97efb25d4f39ab10cd5571db43f3bfa7c617a5bb087085ae16c0298aca899b55c8742a502121ba743a73e6d77cd2056bc96cee63d6d0862dabc8fb5574357 openldap-2.4.11-libldap_r.patch
+8c4244d316a05870dd1147b2ab7ddbcfd7626b5dce2f5a0e72f066dc635c2edb4f1ea3be88c6fec2d5ab016001be16bedef70f2ce0695c3cd96f69e1614ff177 fix-manpages.patch
+0d2e570ddcb7ace1221abad9fc1d3dd0d00d6948340df69879b449959a68feee6a0ad8e17ef9971b35986293e16fc9d8e88de81815fedd5ea6a952eb085406ca configs.patch
+0c3606e4dad1b32f1c4b62f2bc1990a4c9f7ccd10c7b50e623309ba9df98064e68fc42a7242450f32fb6e5fa2203609d3d069871b5ae994cd4b227a078c93532 slapd.initd
+64dc4c0aa0abe3d9f7d2aef25fe4c8e23c53df2421067947ac4d096c9e942b26356cb8577ebc41b52d88d0b0a03b2a3e435fe86242671f9b36555a5f82ee0e3a slapd.confd"
diff --git a/system/openldap/CVE-2017-9287.patch b/system/openldap/CVE-2017-9287.patch
new file mode 100644
index 000000000..1599c1331
--- /dev/null
+++ b/system/openldap/CVE-2017-9287.patch
@@ -0,0 +1,28 @@
+From 0cee1ffb6021b1aae3fcc9581699da1c85a6dd6e Mon Sep 17 00:00:00 2001
+From: Ryan Tandy <ryan@nardis.ca>
+Date: Wed, 17 May 2017 20:07:39 -0700
+Subject: [PATCH] ITS#8655 fix double free on paged search with pagesize 0
+
+Fixes a double free when a search includes the Paged Results control
+with a page size of 0 and the search base matches the filter.
+---
+ servers/slapd/back-mdb/search.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/servers/slapd/back-mdb/search.c b/servers/slapd/back-mdb/search.c
+index 301d1a4..43442aa 100644
+--- a/servers/slapd/back-mdb/search.c
++++ b/servers/slapd/back-mdb/search.c
+@@ -1066,7 +1066,8 @@ notfound:
+ /* check size limit */
+ if ( get_pagedresults(op) > SLAP_CONTROL_IGNORED ) {
+ if ( rs->sr_nentries >= ((PagedResultsState *)op->o_pagedresults_state)->ps_size ) {
+- mdb_entry_return( op, e );
++ if (e != base)
++ mdb_entry_return( op, e );
+ e = NULL;
+ send_paged_response( op, rs, &lastid, tentries );
+ goto done;
+--
+1.7.10.4
+
diff --git a/system/openldap/configs.patch b/system/openldap/configs.patch
new file mode 100644
index 000000000..e7ec65c4b
--- /dev/null
+++ b/system/openldap/configs.patch
@@ -0,0 +1,117 @@
+--- a/servers/slapd/slapd.conf
++++ b/servers/slapd/slapd.conf
+@@ -2,7 +2,7 @@
+ # See slapd.conf(5) for details on configuration options.
+ # This file should NOT be world readable.
+ #
+-include %SYSCONFDIR%/schema/core.schema
++include /etc/openldap/schema/core.schema
+
+ # Define global ACLs to disable default read access.
+
+@@ -10,13 +10,16 @@
+ # service AND an understanding of referrals.
+ #referral ldap://root.openldap.org
+
+-pidfile %LOCALSTATEDIR%/run/slapd.pid
+-argsfile %LOCALSTATEDIR%/run/slapd.args
++# If you change this, adjust pidfile path also in runscript!
++pidfile /run/openldap/slapd.pid
++argsfile /run/openldap/slapd.args
+
+ # Load dynamic backend modules:
+-# modulepath %MODULEDIR%
+-# moduleload back_mdb.la
+-# moduleload back_ldap.la
++modulepath /usr/lib/openldap
++moduleload back_mdb.so
++# moduleload back_hdb.so
++# moduleload back_bbd.so
++# moduleload back_ldap.so
+
+ # Sample security restrictions
+ # Require integrity protection (prevent hijacking)
+@@ -53,13 +56,16 @@
+ maxsize 1073741824
+ suffix "dc=my-domain,dc=com"
+ rootdn "cn=Manager,dc=my-domain,dc=com"
++
+ # Cleartext passwords, especially for the rootdn, should
+ # be avoid. See slappasswd(8) and slapd.conf(5) for details.
+ # Use of strong authentication encouraged.
+ rootpw secret
++
+ # The database directory MUST exist prior to running slapd AND
+ # should only be accessible by the slapd and slap tools.
+ # Mode 700 recommended.
+-directory %LOCALSTATEDIR%/openldap-data
++directory /var/lib/openldap/openldap-data
++
+ # Indices to maintain
+ index objectClass eq
+--- a/servers/slapd/slapd.ldif
++++ b/servers/slapd/slapd.ldif
+@@ -9,8 +9,9 @@
+ #
+ # Define global ACLs to disable default read access.
+ #
+-olcArgsFile: %LOCALSTATEDIR%/run/slapd.args
+-olcPidFile: %LOCALSTATEDIR%/run/slapd.pid
++# If you change this, set pidfile variable in /etc/conf.d/slapd!
++olcPidFile: /run/openldap/slapd.pid
++olcArgsFile: /run/openldap/slapd.args
+ #
+ # Do not enable referrals until AFTER you have a working directory
+ # service AND an understanding of referrals.
+@@ -26,22 +27,23 @@
+ #
+ # Load dynamic backend modules:
+ #
+-#dn: cn=module,cn=config
+-#objectClass: olcModuleList
+-#cn: module
+-#olcModulepath: %MODULEDIR%
+-#olcModuleload: back_bdb.la
+-#olcModuleload: back_hdb.la
+-#olcModuleload: back_ldap.la
+-#olcModuleload: back_passwd.la
+-#olcModuleload: back_shell.la
++dn: cn=module,cn=config
++objectClass: olcModuleList
++cn: module
++olcModulepath: /usr/lib/openldap
++#olcModuleload: back_bdb.so
++#olcModuleload: back_hdb.so
++#olcModuleload: back_ldap.so
++olcModuleload: back_mdb.so
++#olcModuleload: back_passwd.so
++#olcModuleload: back_shell.so
+
+
+ dn: cn=schema,cn=config
+ objectClass: olcSchemaConfig
+ cn: schema
+
+-include: file://%SYSCONFDIR%/schema/core.ldif
++include: file:///etc/openldap/schema/core.ldif
+
+ # Frontend settings
+ #
+@@ -83,13 +85,16 @@
+ olcDatabase: mdb
+ olcSuffix: dc=my-domain,dc=com
+ olcRootDN: cn=Manager,dc=my-domain,dc=com
++
+ # Cleartext passwords, especially for the rootdn, should
+ # be avoided. See slappasswd(8) and slapd-config(5) for details.
+ # Use of strong authentication encouraged.
+ olcRootPW: secret
++
+ # The database directory MUST exist prior to running slapd AND
+ # should only be accessible by the slapd and slap tools.
+ # Mode 700 recommended.
+-olcDbDirectory: %LOCALSTATEDIR%/openldap-data
++olcDbDirectory: /var/lib/openldap/openldap-data
++
+ # Indices to maintain
+ olcDbIndex: objectClass eq
diff --git a/system/openldap/fix-manpages.patch b/system/openldap/fix-manpages.patch
new file mode 100644
index 000000000..179569494
--- /dev/null
+++ b/system/openldap/fix-manpages.patch
@@ -0,0 +1,75 @@
+Various manual pages changes:
+* removes LIBEXECDIR from slapd.8
+* removes references to non-existing manpages (bz 624616)
+
+Patch-Source: https://src.fedoraproject.org/rpms/openldap/blob/f27/f/openldap-manpages.patch
+
+diff --git a/doc/man/man1/ldapmodify.1 b/doc/man/man1/ldapmodify.1
+index 3def6da..466c772 100644
+--- a/doc/man/man1/ldapmodify.1
++++ b/doc/man/man1/ldapmodify.1
+@@ -397,8 +397,7 @@ exit status and a diagnostic message being written to standard error.
+ .BR ldap_add_ext (3),
+ .BR ldap_delete_ext (3),
+ .BR ldap_modify_ext (3),
+-.BR ldap_modrdn_ext (3),
+-.BR ldif (5).
++.BR ldif (5)
+ .SH AUTHOR
+ The OpenLDAP Project <http://www.openldap.org/>
+ .SH ACKNOWLEDGEMENTS
+diff --git a/doc/man/man5/ldap.conf.5 b/doc/man/man5/ldap.conf.5
+index cfde143..63592cb 100644
+--- a/doc/man/man5/ldap.conf.5
++++ b/doc/man/man5/ldap.conf.5
+@@ -317,6 +317,7 @@ certificates in separate individual files. The
+ .B TLS_CACERT
+ is always used before
+ .B TLS_CACERTDIR.
++The specified directory must be managed with the LibreSSL c_rehash utility.
+ This parameter is ignored with GnuTLS.
+
+ When using Mozilla NSS, <path> may contain a Mozilla NSS cert/key
+diff --git a/doc/man/man8/slapd.8 b/doc/man/man8/slapd.8
+index b739f4d..e2a1a00 100644
+--- a/doc/man/man8/slapd.8
++++ b/doc/man/man8/slapd.8
+@@ -5,7 +5,7 @@
+ .SH NAME
+ slapd \- Stand-alone LDAP Daemon
+ .SH SYNOPSIS
+-.B LIBEXECDIR/slapd
++.B slapd
+ [\c
+ .BR \-4 | \-6 ]
+ [\c
+@@ -317,7 +317,7 @@ the LDAP databases defined in the default config file, just type:
+ .LP
+ .nf
+ .ft tt
+- LIBEXECDIR/slapd
++ slapd
+ .ft
+ .fi
+ .LP
+@@ -328,7 +328,7 @@ on voluminous debugging which will be printed on standard error, type:
+ .LP
+ .nf
+ .ft tt
+- LIBEXECDIR/slapd \-f /var/tmp/slapd.conf \-d 255
++ slapd -f /var/tmp/slapd.conf -d 255
+ .ft
+ .fi
+ .LP
+@@ -336,7 +336,7 @@ To test whether the configuration file is correct or not, type:
+ .LP
+ .nf
+ .ft tt
+- LIBEXECDIR/slapd \-Tt
++ slapd -Tt
+ .ft
+ .fi
+ .LP
+--
+1.8.1.4
+
diff --git a/system/openldap/libressl.patch b/system/openldap/libressl.patch
new file mode 100644
index 000000000..ac0106418
--- /dev/null
+++ b/system/openldap/libressl.patch
@@ -0,0 +1,65 @@
+--- a/libraries/libldap/tls_o.c.orig 2017-06-04 16:31:28 UTC
++++ b/libraries/libldap/tls_o.c
+@@ -47,7 +47,7 @@
+ #include <ssl.h>
+ #endif
+
+-#if OPENSSL_VERSION_NUMBER >= 0x10100000
++#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+ #define ASN1_STRING_data(x) ASN1_STRING_get0_data(x)
+ #endif
+
+@@ -157,7 +157,7 @@ tlso_init( void )
+ (void) tlso_seed_PRNG( lo->ldo_tls_randfile );
+ #endif
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
+ SSL_load_error_strings();
+ SSL_library_init();
+ OpenSSL_add_all_digests();
+@@ -205,7 +205,7 @@ static void
+ tlso_ctx_ref( tls_ctx *ctx )
+ {
+ tlso_ctx *c = (tlso_ctx *)ctx;
+-#if OPENSSL_VERSION_NUMBER < 0x10100000
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
+ #define SSL_CTX_up_ref(ctx) CRYPTO_add( &(ctx->references), 1, CRYPTO_LOCK_SSL_CTX )
+ #endif
+ SSL_CTX_up_ref( c );
+@@ -464,7 +464,7 @@ tlso_session_my_dn( tls_session *sess, struct berval *
+ if (!x) return LDAP_INVALID_CREDENTIALS;
+
+ xn = X509_get_subject_name(x);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
+ der_dn->bv_len = i2d_X509_NAME( xn, NULL );
+ der_dn->bv_val = xn->bytes->data;
+ #else
+@@ -500,7 +500,7 @@ tlso_session_peer_dn( tls_session *sess, struct berval
+ return LDAP_INVALID_CREDENTIALS;
+
+ xn = X509_get_subject_name(x);
+-#if OPENSSL_VERSION_NUMBER < 0x10100000
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
+ der_dn->bv_len = i2d_X509_NAME( xn, NULL );
+ der_dn->bv_val = xn->bytes->data;
+ #else
+@@ -721,7 +721,7 @@ struct tls_data {
+ Sockbuf_IO_Desc *sbiod;
+ };
+
+-#if OPENSSL_VERSION_NUMBER < 0x10100000
++#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(LIBRESSL_VERSION_NUMBER)
+ #define BIO_set_init(b, x) b->init = x
+ #define BIO_set_data(b, x) b->ptr = x
+ #define BIO_clear_flags(b, x) b->flags &= ~(x)
+@@ -822,7 +822,7 @@ tlso_bio_puts( BIO *b, const char *str )
+ return tlso_bio_write( b, str, strlen( str ) );
+ }
+
+-#if OPENSSL_VERSION_NUMBER >= 0x10100000
++#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
+ struct bio_method_st {
+ int type;
+ const char *name;
diff --git a/system/openldap/openldap-2.4-ppolicy.patch b/system/openldap/openldap-2.4-ppolicy.patch
new file mode 100644
index 000000000..c05790e3e
--- /dev/null
+++ b/system/openldap/openldap-2.4-ppolicy.patch
@@ -0,0 +1,13 @@
+diff -urN ./clients.orig/tools/common.c ./clients/tools/common.c
+--- ./clients.orig/tools/common.c 2007-09-01 01:13:50.000000000 +0200
++++ ./clients/tools/common.c 2008-01-13 21:50:06.000000000 +0100
+@@ -1262,8 +1262,8 @@
+ int nsctrls = 0;
+
+ #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
++ LDAPControl c;
+ if ( ppolicy ) {
+- LDAPControl c;
+ c.ldctl_oid = LDAP_CONTROL_PASSWORDPOLICYREQUEST;
+ c.ldctl_value.bv_val = NULL;
+ c.ldctl_value.bv_len = 0;
diff --git a/system/openldap/openldap-2.4.11-libldap_r.patch b/system/openldap/openldap-2.4.11-libldap_r.patch
new file mode 100644
index 000000000..448249a3b
--- /dev/null
+++ b/system/openldap/openldap-2.4.11-libldap_r.patch
@@ -0,0 +1,11 @@
+diff -Nuar openldap-2.4.11.orig/servers/slapd/slapi/Makefile.in openldap-2.4.11/servers/slapd/slapi/Makefile.in
+--- openldap-2.4.11.orig/servers/slapd/slapi/Makefile.in 2008-02-11 15:26:49.000000000 -0800
++++ openldap-2.4.11/servers/slapd/slapi/Makefile.in 2008-10-14 02:10:18.402799262 -0700
+@@ -37,6 +37,7 @@
+ XLIBS = $(LIBRARY)
+ XXLIBS =
+ NT_LINK_LIBS = $(AC_LIBS)
++UNIX_LINK_LIBS = ../../../libraries/libldap_r/libldap_r.la $(LTHREAD_LIBS)
+
+ XINCPATH = -I$(srcdir)/.. -I$(srcdir)
+ XDEFS = $(MODULES_CPPFLAGS)
diff --git a/system/openldap/openldap-mqtt-overlay.patch b/system/openldap/openldap-mqtt-overlay.patch
new file mode 100644
index 000000000..795480f1e
--- /dev/null
+++ b/system/openldap/openldap-mqtt-overlay.patch
@@ -0,0 +1,447 @@
+diff --git a/contrib/slapd-modules/mqtt/Makefile b/contrib/slapd-modules/mqtt/Makefile
+new file mode 100644
+index 0000000..2cb4db7
+--- /dev/null
++++ b/contrib/slapd-modules/mqtt/Makefile
+@@ -0,0 +1,45 @@
++# $OpenLDAP$
++
++LDAP_SRC = ../../..
++LDAP_BUILD = ../../..
++LDAP_INC = -I$(LDAP_BUILD)/include -I$(LDAP_SRC)/include -I$(LDAP_SRC)/servers/slapd
++LDAP_LIB = $(LDAP_BUILD)/libraries/libldap_r/libldap_r.la \
++ $(LDAP_BUILD)/libraries/liblber/liblber.la
++
++LIBTOOL = $(LDAP_BUILD)/libtool
++CC = gcc
++OPT = -g -O2 -Wall
++DEFS =
++INCS = $(LDAP_INC)
++LIBS = $(LDAP_LIB) -lmosquitto
++
++PROGRAMS = mqtt.la
++LTVER = 0:0:0
++
++prefix=/usr/local
++exec_prefix=$(prefix)
++ldap_subdir=/openldap
++
++libdir=$(exec_prefix)/lib
++libexecdir=$(exec_prefix)/libexec
++moduledir = $(libdir)$(ldap_subdir)
++
++.SUFFIXES: .c .o .lo
++
++.c.lo:
++ $(LIBTOOL) --mode=compile $(CC) $(OPT) $(DEFS) $(INCS) -c $<
++
++all: $(PROGRAMS)
++
++mqtt.la: mqtt.lo
++ $(LIBTOOL) --mode=link $(CC) $(OPT) -version-info $(LTVER) \
++ -rpath $(moduledir) -module -o $@ $? $(LIBS)
++
++clean:
++ rm -rf *.o *.lo *.la .libs
++
++install: $(PROGRAMS)
++ mkdir -p $(DESTDIR)$(moduledir)
++ for p in $(PROGRAMS) ; do \
++ $(LIBTOOL) --mode=install cp $$p $(DESTDIR)$(moduledir) ; \
++ done
+diff --git a/contrib/slapd-modules/mqtt/mqtt.c b/contrib/slapd-modules/mqtt/mqtt.c
+new file mode 100644
+index 0000000..b3a0a31
+--- /dev/null
++++ b/contrib/slapd-modules/mqtt/mqtt.c
+@@ -0,0 +1,389 @@
++/* $OpenLDAP$ */
++/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
++ *
++ * Copyright 2014 Timo Teräs <timo.teras@iki.fi>.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted only as authorized by the OpenLDAP
++ * Public License.
++ *
++ * A copy of this license is available in file LICENSE in the
++ * top-level directory of the distribution or, alternatively, at
++ * http://www.OpenLDAP.org/license.html.
++ */
++/* mqtt-overlay
++ *
++ * This is an OpenLDAP overlay that... */
++
++#include <mosquitto.h>
++#include <unistd.h>
++
++#include "portable.h"
++#include "slap.h"
++#include "config.h"
++
++typedef struct mqtt_notify_t {
++ struct mqtt_notify_t *next;
++ char *topic;
++ char *dn_group_str;
++ char *oc_group_str;
++ char *str_member;
++
++ struct berval ndn_group;
++ ObjectClass *oc_group;
++ AttributeDescription *ad_member;
++ int notify_pending;
++} mqtt_notify_t;
++
++typedef struct mqtt_t {
++ struct mosquitto *mq;
++ int port;
++ char *hostname, *username, *password;
++ mqtt_notify_t *notify_map;
++} mqtt_t;
++
++static ConfigDriver mqtt_config_notify;
++
++static ConfigTable mqttcfg[] = {
++ { "mqtt-hostname", "hostname", 2, 2, 0,
++ ARG_STRING|ARG_OFFSET, (void *)offsetof(mqtt_t, hostname),
++ "( OLcfgCtAt:5.1 NAME 'olcMqttHostname' "
++ "DESC 'Hostname of MQTT broker' "
++ "SYNTAX OMsDirectoryString SINGLE-VALUE )",
++ NULL, NULL },
++ { "mqtt-port", "port", 2, 2, 0,
++ ARG_INT|ARG_OFFSET, (void *)offsetof(mqtt_t, port),
++ "( OLcfgCtAt:5.2 NAME 'olcMqttPort' "
++ "DESC 'Port of MQTT broker' "
++ "SYNTAX OMsInteger SINGLE-VALUE )",
++ NULL, NULL },
++ { "mqtt-username", "username", 2, 2, 0,
++ ARG_STRING|ARG_OFFSET, (void *)offsetof(mqtt_t, username),
++ "( OLcfgCtAt:5.3 NAME 'olcMqttUsername' "
++ "DESC 'Username for MQTT broker' "
++ "SYNTAX OMsDirectoryString SINGLE-VALUE )",
++ NULL, NULL },
++ { "mqtt-password", "password", 2, 2, 0,
++ ARG_STRING|ARG_OFFSET, (void *)offsetof(mqtt_t, password),
++ "( OLcfgCtAt:5.4 NAME 'olcMqttPassword' "
++ "DESC 'Password for MQTT broker' "
++ "SYNTAX OMsDirectoryString SINGLE-VALUE )",
++ NULL, NULL },
++ { "mqtt-notify-password", "topic> <group-dn> <group-oc> <member-ad", 2, 5, 0,
++ ARG_MAGIC, mqtt_config_notify,
++ "( OLcfgCtAt:5.5 NAME 'olcMqttNotifyPassword' "
++ "DESC 'Notify password change on <topic>, optionally checking that the object is in the specified group.'"
++ "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
++ NULL, NULL },
++ { NULL, NULL, 0, 0, 0, ARG_IGNORED }
++};
++
++static ConfigOCs mqttocs[] = {
++ { "( OLcfgCtOc:5.1 "
++ "NAME 'olcMqttConfig' "
++ "DESC 'MQTT configuration' "
++ "SUP olcOverlayConfig "
++ "MAY ( "
++ "olcMqttHostname "
++ "$ olcMqttPort"
++ "$ olcMqttUsername"
++ "$ olcMqttPassword"
++ "$ olcMqttNotifyPassword"
++ " ) )",
++ Cft_Overlay, mqttcfg },
++
++ { NULL, 0, NULL }
++};
++
++static int mqtt_init(BackendInfo *bi)
++{
++ return mosquitto_lib_init();
++}
++
++static int mqtt_destroy(BackendInfo *bi)
++{
++ return mosquitto_lib_cleanup();
++}
++
++static const char *ca_arg(ConfigArgs *c, int n)
++{
++ return (c->argc <= n) ? NULL : c->argv[n];
++}
++
++static void free_notify(mqtt_notify_t *n)
++{
++ ch_free(n->topic);
++ ch_free(n->oc_group_str);
++ ch_free(n->str_member);
++ ch_free(n->dn_group_str);
++ if (!BER_BVISNULL(&n->ndn_group))
++ ber_memfree(n->ndn_group.bv_val);
++ ch_free(n);
++}
++
++static void free_all_notifies(mqtt_t *mqtt)
++{
++ mqtt_notify_t *n, *next;
++
++ for (n = mqtt->notify_map; n; n = next) {
++ next = n->next;
++ free_notify(n);
++ }
++ mqtt->notify_map = NULL;
++}
++
++static int mqtt_config_notify(ConfigArgs *c)
++{
++ slap_overinst *on = (slap_overinst *)c->bi;
++ mqtt_t *mqtt = (mqtt_t *) on->on_bi.bi_private;
++ mqtt_notify_t *n, **pprev;
++ const char *text = NULL;
++ struct berval bv = BER_BVNULL, ndn = BER_BVNULL;
++ int rc, i;
++
++ switch (c->op) {
++ case SLAP_CONFIG_EMIT:
++ for (i = 0, n = mqtt->notify_map; n; n = n->next, i++) {
++ char *ptr = c->cr_msg, *end = &c->cr_msg[sizeof(c->cr_msg)-1];
++
++ ptr += snprintf(ptr, end-ptr, SLAP_X_ORDERED_FMT "%s", i, n->topic);
++ if (n->dn_group_str)
++ ptr += snprintf(ptr, end-ptr, " \"%s\"", n->dn_group_str);
++ if (n->oc_group_str)
++ ptr += snprintf(ptr, end-ptr, " \"%s\"", n->oc_group_str);
++ if (n->str_member)
++ ptr += snprintf(ptr, end-ptr, " \"%s\"", n->str_member);
++
++ bv.bv_val = c->cr_msg;
++ bv.bv_len = ptr - bv.bv_val;
++ value_add_one(&c->rvalue_vals, &bv);
++ }
++ return 0;
++ case LDAP_MOD_DELETE:
++ if (c->valx < 0) {
++ free_all_notifies(mqtt);
++ } else {
++ pprev = &mqtt->notify_map;
++ n = mqtt->notify_map;
++ for (i = 0; i < c->valx; i++) {
++ pprev = &n->next;
++ n = n->next;
++ }
++ *pprev = n->next;
++ free_notify(n);
++ }
++ return 0;
++ }
++
++ const char *groupdn = ca_arg(c, 2);
++ const char *oc_name = ca_arg(c, 3);
++ const char *ad_name = ca_arg(c, 4);
++ ObjectClass *oc = NULL;
++ AttributeDescription *ad = NULL;
++
++ if (groupdn) {
++ oc = oc_find(oc_name ?: SLAPD_GROUP_CLASS);
++ if (oc == NULL) {
++ Debug(LDAP_DEBUG_ANY, "mqtt_db_open: unable to find objectClass=\"%s\"\n",
++ oc_name, 0, 0);
++ return 1;
++ }
++
++ rc = slap_str2ad(ad_name ?: SLAPD_GROUP_ATTR, &ad, &text);
++ if (rc != LDAP_SUCCESS) {
++ Debug(LDAP_DEBUG_ANY, "mqtt_db_config_notify: unable to find attribute=\"%s\": %s (%d)\n",
++ ad_name, text, rc);
++ return rc;
++ }
++
++ ber_str2bv(groupdn, 0, 0, &bv);
++ rc = dnNormalize(0, NULL, NULL, &bv, &ndn, NULL);
++ if (rc != LDAP_SUCCESS) {
++ Debug(LDAP_DEBUG_ANY, "mqtt_db_config_notify: DN normalization failed for \"%s\": %d\n",
++ groupdn, rc, 0);
++ return rc;
++ }
++ }
++
++ n = ch_calloc(1, sizeof(*n));
++ n->topic = ch_strdup(c->argv[1]);
++ n->dn_group_str = groupdn ? ch_strdup(groupdn) : NULL;
++ n->oc_group_str = oc_name ? ch_strdup(oc_name) : NULL;
++ n->str_member = ad_name ? ch_strdup(ad_name) : NULL;
++ n->ndn_group = ndn;
++ n->oc_group = oc;
++ n->ad_member = ad;
++
++ for (pprev = &mqtt->notify_map; *pprev; pprev = &(*pprev)->next);
++ *pprev = n;
++
++ return 0;
++}
++
++static void mqtt_send_notify(mqtt_t *mqtt, mqtt_notify_t *n)
++{
++ Debug(LDAP_DEBUG_TRACE, "mqtt_send_notify: pub on topic '%s'\n", n->topic, 0, 0);
++ n->notify_pending = mosquitto_publish(mqtt->mq, NULL, n->topic, 0, NULL, 1, true) == MOSQ_ERR_NO_CONN;
++}
++
++static void mqtt_on_connect(struct mosquitto *mq, void *obj, int rc)
++{
++ slap_overinst *on = (slap_overinst *) obj;
++ mqtt_t *mqtt = (mqtt_t *) on->on_bi.bi_private;
++ mqtt_notify_t *n;
++
++ Debug(LDAP_DEBUG_TRACE, "mqtt_on_connect: connected with status %d\n", rc, 0, 0);
++ if (rc != 0)
++ return;
++
++ for (n = mqtt->notify_map; n; n = n->next)
++ if (n->notify_pending)
++ mqtt_send_notify(mqtt, n);
++}
++
++static int mqtt_db_init(BackendDB *be, ConfigReply *cr)
++{
++ slap_overinst *on = (slap_overinst *) be->bd_info;
++
++ Debug(LDAP_DEBUG_TRACE, "mqtt_db_init: initialize overlay\n", 0, 0, 0);
++ on->on_bi.bi_private = ch_calloc(1, sizeof(mqtt_t));
++
++ return 0;
++}
++
++static int mqtt_db_destroy(BackendDB *be, ConfigReply *cr)
++{
++ slap_overinst *on = (slap_overinst *) be->bd_info;
++ mqtt_t *mqtt = on->on_bi.bi_private;
++
++ Debug(LDAP_DEBUG_TRACE, "mqtt_db_destroy: destroy overlay\n", 0, 0, 0);
++ free_all_notifies(mqtt);
++ ch_free(mqtt);
++
++ return 0;
++}
++
++static int mqtt_db_open(BackendDB *be, ConfigReply *cr)
++{
++ slap_overinst *on = (slap_overinst *) be->bd_info;
++ mqtt_t *mqtt = (mqtt_t *) on->on_bi.bi_private;
++ struct mosquitto *mq;
++ char id[256];
++ int n;
++
++ n = snprintf(id, sizeof(id), "openldap-mqtt/%d/", getpid());
++ gethostname(&id[n], sizeof(id) - n);
++
++ Debug(LDAP_DEBUG_TRACE, "mqtt_db_open, id='%s'\n", id, 0, 0);
++ mqtt->mq = mq = mosquitto_new(id, true, on);
++ if (!mq) return 1;
++
++ if (mqtt->username && mqtt->password)
++ mosquitto_username_pw_set(mq, mqtt->username, mqtt->password);
++
++ mosquitto_connect_callback_set(mq, mqtt_on_connect);
++ mosquitto_connect_async(mq, mqtt->hostname ?: "127.0.0.1", mqtt->port ?: 1883, 60);
++ mosquitto_loop_start(mq);
++
++ return 0;
++}
++
++static int mqtt_db_close(BackendDB *be, ConfigReply *cr)
++{
++ slap_overinst *on = (slap_overinst *) be->bd_info;
++ mqtt_t *mqtt = (mqtt_t *) on->on_bi.bi_private;
++
++ Debug(LDAP_DEBUG_TRACE, "mqtt_db_close\n", 0, 0, 0);
++ mosquitto_disconnect(mqtt->mq);
++ mosquitto_loop_stop(mqtt->mq, false);
++ mosquitto_destroy(mqtt->mq);
++
++ free(mqtt->hostname); mqtt->hostname = NULL;
++ free(mqtt->username); mqtt->username = NULL;
++ free(mqtt->password); mqtt->password = NULL;
++
++ return 0;
++}
++
++static int mqtt_response(Operation *op, SlapReply *rs)
++{
++ slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
++ mqtt_t *mqtt = (mqtt_t *) on->on_bi.bi_private;
++ Attribute *a;
++ Modifications *m;
++ bool change = false;
++
++ switch (op->o_tag) {
++ case LDAP_REQ_ADD:
++ for (a = op->ora_e->e_attrs; a; a = a->a_next) {
++ if (a->a_desc == slap_schema.si_ad_userPassword) {
++ change = true;
++ break;
++ }
++ }
++ break;
++ case LDAP_REQ_MODIFY:
++ for (m = op->orm_modlist; m; m = m->sml_next) {
++ if (m->sml_desc == slap_schema.si_ad_userPassword) {
++ change = true;
++ break;
++ }
++ }
++ break;
++ case LDAP_REQ_EXTENDED:
++ if (ber_bvcmp(&slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid) == 0)
++ change = true;
++ break;
++ }
++
++ if (change) {
++ mqtt_notify_t *n;
++ int r, cache;
++
++ for (n = mqtt->notify_map; n; n = n->next) {
++ if (n->oc_group) {
++ cache = op->o_do_not_cache;
++ op->o_do_not_cache = 1;
++ r = backend_group(op, NULL, &n->ndn_group, &op->o_req_ndn, n->oc_group, n->ad_member);
++ op->o_do_not_cache = cache;
++ } else {
++ r = 0;
++ }
++
++ Debug(LDAP_DEBUG_TRACE, "tested o_req_ndn='%s' in ndn_group='%s' r=%d\n",
++ op->o_req_ndn.bv_val, n->ndn_group.bv_val, r);
++
++ if (r == 0)
++ mqtt_send_notify(mqtt, n);
++ }
++ }
++
++ return SLAP_CB_CONTINUE;
++}
++
++static int mqtt_init_overlay()
++{
++ static slap_overinst ov;
++ int rc;
++
++ ov.on_bi.bi_type = "mqtt";
++ ov.on_bi.bi_init = mqtt_init;
++ ov.on_bi.bi_destroy = mqtt_destroy;
++ ov.on_bi.bi_db_init = mqtt_db_init;
++ ov.on_bi.bi_db_destroy = mqtt_db_destroy;
++ ov.on_bi.bi_db_open = mqtt_db_open;
++ ov.on_bi.bi_db_close = mqtt_db_close;
++ ov.on_bi.bi_cf_ocs = mqttocs;
++ ov.on_response = mqtt_response;
++
++ rc = config_register_schema(mqttcfg, mqttocs);
++ if (rc) return rc;
++
++ return overlay_register(&ov);
++}
++
++int init_module(int argc, char *argv[])
++{
++ return mqtt_init_overlay();
++}
+
diff --git a/system/openldap/openldap.post-install b/system/openldap/openldap.post-install
new file mode 100644
index 000000000..e90d25760
--- /dev/null
+++ b/system/openldap/openldap.post-install
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+cat >&2 <<-EOF
+*
+* To use LDAP server, you have to install some backend. Most users would need MDB
+* backend which you can install with: apk add openldap-back-mdb.
+*
+* If you use overlays, you have to install them separately too:
+* apk add openldap-overlay-<name>, or openldap-overlay-all to install them all.
+*
+EOF
diff --git a/system/openldap/openldap.post-upgrade b/system/openldap/openldap.post-upgrade
new file mode 100644
index 000000000..7be8906a9
--- /dev/null
+++ b/system/openldap/openldap.post-upgrade
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+new_ver="$1"
+old_ver="$2"
+
+if [ "$(apk version -t "$old_ver" "2.4.45-r2")" = "<" ]; then
+ cat >&2 <<-EOF
+ *
+ * All SLAPD backends and overlays have been moved to subpackages.
+ * You can install specific backend or overlay with apk:
+ *
+ * apk add openldap-back-<name>
+ * apk add openldap-overlay-<name>
+ *
+ * Or you can install all of them using metapackages openldap-back-all
+ * and openldap-overlay-all.
+ EOF
+ if [ -e /var/lib/openldap/openldap-data/data.mdb ]; then
+ cat >&2 <<-EOF
+ *
+ * Found existing MDB database. You have to install MDB backend:
+ * apk add openldap-back-mdb
+ *
+ * and add "moduleload back_mdb.so" to /etc/openldap/slapd.conf,
+ * or "olcModuleload back_mdb.so" to slapd.ldif.
+ *
+ EOF
+ else
+ echo "*" >&2
+ fi
+fi
diff --git a/system/openldap/openldap.pre-install b/system/openldap/openldap.pre-install
new file mode 100644
index 000000000..eb6b10fa4
--- /dev/null
+++ b/system/openldap/openldap.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+addgroup -S ldap 2>/dev/null
+adduser -S -D -H -h /usr/lib/openldap -s /sbin/nologin -G ldap \
+ -g "OpenLdap User" ldap 2>/dev/null
+
+exit 0
diff --git a/system/openldap/slapd.confd b/system/openldap/slapd.confd
new file mode 100644
index 000000000..f69f92b4a
--- /dev/null
+++ b/system/openldap/slapd.confd
@@ -0,0 +1,12 @@
+# Configuration for /etc/init.d/slapd
+
+# Location of the configuration file.
+cfgfile="/etc/openldap/slapd.conf"
+
+# Location of the configuration directory (OpenLDAP 2.3+).
+#cfgdir=""
+
+# To enable both the standard unciphered server and the ssl encrypted
+# one uncomment this line or set any other server starting options
+# you may desire.
+#command_args="-h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"
diff --git a/system/openldap/slapd.initd b/system/openldap/slapd.initd
new file mode 100644
index 000000000..350cc0d50
--- /dev/null
+++ b/system/openldap/slapd.initd
@@ -0,0 +1,34 @@
+#!/sbin/openrc-run
+
+: ${pidfile:="/run/openldap/slapd.pid"}
+
+name="LDAP server"
+extra_commands="checkconfig"
+description_checkconfig="Check slapd.conf for errors"
+
+command="/usr/sbin/slapd"
+# OPTS is for backward compatibility
+cfg_opt="${cfgdir:+"-F $cfgdir"} ${cfgfile:+"-f $cfgfile"}"
+command_args="-u ldap -g ldap $cfg_opt ${command_args:-${OPTS:-}}"
+
+stopsig=2
+start_stop_daemon_args="
+ ${KRB5_KTNAME:+"--env KRB5_KTNAME=$KRB5_KTNAME"}"
+
+depend() {
+ need net
+ after firewall
+ before dbus hald avahi-daemon
+ provide ldap
+}
+
+start_pre() {
+ checkpath --directory --owner ldap:ldap "${pidfile%/*}"
+ /usr/sbin/slaptest -u -Q $cfg_opt || /usr/sbin/slaptest -u $cfg_opt
+}
+
+checkconfig() {
+ ebegin "Checking $name configuration..."
+ /usr/sbin/slaptest -u $cfg_opt
+ eend $?
+}
diff --git a/system/orbit2/APKBUILD b/system/orbit2/APKBUILD
new file mode 100644
index 000000000..5caf3dcbc
--- /dev/null
+++ b/system/orbit2/APKBUILD
@@ -0,0 +1,45 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=orbit2
+pkgver=2.14.19
+pkgrel=4
+pkgdesc="CORBA implementation for GNOME"
+url="http://projects.gnome.org/ORBit2"
+arch="all"
+license="LGPL"
+depends=
+makedepends="glib-dev libidl-dev"
+install=""
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://ftp.gnome.org/pub/GNOME/sources/ORBit2/${pkgver%.*}/ORBit2-${pkgver}.tar.bz2
+ glib-2.36.patch"
+
+builddir="${srcdir}/ORBit2-${pkgver}"
+prepare() {
+ cd "$builddir"
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="313e125234e8d1195be277ad125af169f12ce312cb541a4641c5d57d3c905bbdc6a46672a86a012409cf4d7af58b5122f0e5db250730b65e8d95b2d5f4c4657e ORBit2-2.14.19.tar.bz2
+b90d8e200d16b735bece54454d1e2b1a7c1b75aaac83986263b5a9ac38c4235eed747408a07a266c0aaaeb9c7a75e7fda1ef1b2ed54300003da38ff2251fdcfa glib-2.36.patch"
diff --git a/system/orbit2/glib-2.36.patch b/system/orbit2/glib-2.36.patch
new file mode 100644
index 000000000..c94f920f7
--- /dev/null
+++ b/system/orbit2/glib-2.36.patch
@@ -0,0 +1,15 @@
+$NetBSD: patch-linc2_src_Makefile.in,v 1.1 2013/04/19 14:28:54 prlw1 Exp $
+
+Avoid compilation error caused by use of deprecated g_thread API
+
+--- ./linc2/src/Makefile.in.orig 2010-09-28 09:39:39.000000000 +0000
++++ ./linc2/src/Makefile.in
+@@ -244,7 +244,7 @@ noinst_LTLIBRARIES = liblinc.la
+ # -I$(top_srcdir)/include
+ INCLUDES = -I$(top_builddir)/linc2/include \
+ -I$(top_srcdir)/linc2/include $(LINC_CFLAGS) $(WARN_CFLAGS) \
+- -DG_DISABLE_DEPRECATED $(am__append_1)
++ $(am__append_1)
+ liblinc_la_SOURCES = \
+ linc.c \
+ linc-connection.c \
diff --git a/system/parted/APKBUILD b/system/parted/APKBUILD
new file mode 100644
index 000000000..0a4680a60
--- /dev/null
+++ b/system/parted/APKBUILD
@@ -0,0 +1,60 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=parted
+pkgver=3.2
+pkgrel=7
+pkgdesc="Utility to create, destroy, resize, check and copy partitions"
+url="http://www.gnu.org/software/parted/parted.html"
+arch="all"
+license="GPL3"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
+depends=
+makedepends="readline-dev ncurses-dev lvm2-dev bash util-linux-dev gettext-dev autoconf automake"
+checkdepends="check-dev python3"
+options="!checkroot"
+source="ftp://ftp.gnu.org/pub/gnu/$pkgname/$pkgname-$pkgver.tar.xz
+ disable-two-tests.patch
+ fix-includes.patch
+ fix-libintl-header-s390x.patch
+ tests-call-name-correctly.patch
+ tests-python3.patch
+ "
+
+builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+ autoreconf
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --disable-debug \
+ --disable-static \
+ --enable-shared \
+ --enable-device-mapper \
+ --with-readline
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ rm -rf "$pkgdir"/usr/lib/charset.alias
+ rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
+}
+sha512sums="4e37dbdd6f5032c9ebfec43704f6882379597d038167b9c4d04053efa083c68a705196713864451fa9e11d32777e16c68982877945c5efd9ea5f8252cb20e1c4 parted-3.2.tar.xz
+b49eb0211c405a4ef69e1bb0079621c22fec4adf0309f0a58b5d881540913de01d05ccd3eb521f35c3cf6f4eb8aa0f4c5270ce3dea47270a5c3fe8fae635c6f0 disable-two-tests.patch
+55ee63c218d1867c0f2c596e7c3eec5c42af160181456cc551fe3d432eabed0ac2dd3a3955ff0c375f76aeec8071e7f55a32834b87a0d39b8ef30361f671bfdd fix-includes.patch
+444a7e2fb3235dfd218f6b71fb25adde107d001f638d988ee1fa79686d8efee94a9499e27bdfdd75f9718760b448938b70a90a74285b93a39338d21f4ab4c9dc fix-libintl-header-s390x.patch
+8bd86d2b0401566e7757c43d849b7f913cc4ec1bf50d5641dc72d7e278ca38db2ac746cd8dcc756b245021ea1f9738875b6a831f05185b9217d3f1c287944748 tests-call-name-correctly.patch
+7486f98d535380a9e6598b9ac6153564319d5effa25456dc393cf3540ea47ac5b462be79cbd7d8efbd1fc2d2ef240a00873a2e2b138d4b4b0bb1494893de1eac tests-python3.patch"
diff --git a/system/parted/disable-two-tests.patch b/system/parted/disable-two-tests.patch
new file mode 100644
index 000000000..a6481dde3
--- /dev/null
+++ b/system/parted/disable-two-tests.patch
@@ -0,0 +1,16 @@
+These tests do not appear to work right upstream. Disable for now.
+
+--- parted-3.2/tests/Makefile.am.old 2014-06-15 19:15:54.000000000 +0000
++++ parted-3.2/tests/Makefile.am 2017-08-19 19:44:28.886245388 +0000
+@@ -24,11 +24,9 @@
+ t0209-gpt-pmbr_boot.sh \
+ t0210-gpt-resized-partition-entry-array.sh \
+ t0211-gpt-rewrite-header.sh \
+- t0212-gpt-many-partitions.sh \
+ t0220-gpt-msftres.sh \
+ t0250-gpt.sh \
+ t0251-gpt-unicode.sh \
+- t0280-gpt-corrupt.sh \
+ t0281-gpt-grow.sh \
+ t0282-gpt-move-backup.sh \
+ t0283-overlap-partitions.sh \
diff --git a/system/parted/fix-includes.patch b/system/parted/fix-includes.patch
new file mode 100644
index 000000000..c6eff0eb2
--- /dev/null
+++ b/system/parted/fix-includes.patch
@@ -0,0 +1,10 @@
+--- parted-3.1.orig/libparted/fs/xfs/platform_defs.h
++++ parted-3.1/libparted/fs/xfs/platform_defs.h
+@@ -35,6 +35,7 @@
+ #define __XFS_PLATFORM_DEFS_H__
+
+ #include <stdio.h>
++#include <fcntl.h>
+ #include <stdarg.h>
+ #include <assert.h>
+ #include <endian.h>
diff --git a/system/parted/fix-libintl-header-s390x.patch b/system/parted/fix-libintl-header-s390x.patch
new file mode 100644
index 000000000..68ae7d270
--- /dev/null
+++ b/system/parted/fix-libintl-header-s390x.patch
@@ -0,0 +1,58 @@
+From 4b2a566a3e007184d3ee9ce5b399a63eebbdadc3 Mon Sep 17 00:00:00 2001
+From: "Tuan M. Hoang" <tmhoang@flatglobe.org>
+Date: Thu, 23 Feb 2017 07:53:02 +0000
+Subject: [PATCH] main/parted: disable nls on s390x
+
+Because we build with --disable-nls by default, we need to remove libintl.h in
+these files on s390x. This is specific for DASD devices only on s390x.
+---
+ libparted/labels/dasd.c | 2 +-
+ libparted/labels/fdasd.c | 2 +-
+ libparted/labels/vtoc.c | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
+index fa9414f..5acf844 100644
+--- a/libparted/labels/dasd.c
++++ b/libparted/labels/dasd.c
+@@ -40,8 +40,8 @@
+ #include <parted/fdasd.h>
+ #include <arch/linux.h>
+
+-#include <libintl.h>
+ #if ENABLE_NLS
++# include <libintl.h>
+ # define _(String) dgettext (PACKAGE, String)
+ #else
+ # define _(String) (String)
+diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
+index 1f87937..e6a9086 100644
+--- a/libparted/labels/fdasd.c
++++ b/libparted/labels/fdasd.c
+@@ -24,8 +24,8 @@
+
+ #include <parted/parted.h>
+
+-#include <libintl.h>
+ #if ENABLE_NLS
++# include <libintl.h>
+ # define _(String) dgettext (PACKAGE, String)
+ #else
+ # define _(String) (String)
+diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
+index fdfa94f..64ba149 100644
+--- a/libparted/labels/vtoc.c
++++ b/libparted/labels/vtoc.c
+@@ -12,8 +12,8 @@
+
+ #include <parted/parted.h>
+
+-#include <libintl.h>
+ #if ENABLE_NLS
++# include <libintl.h>
+ # define _(String) dgettext (PACKAGE, String)
+ #else
+ # define _(String) (String)
+--
+2.11.1
+
diff --git a/system/parted/tests-call-name-correctly.patch b/system/parted/tests-call-name-correctly.patch
new file mode 100644
index 000000000..27a6287e8
--- /dev/null
+++ b/system/parted/tests-call-name-correctly.patch
@@ -0,0 +1,42 @@
+mkpart syntax recently changed, tests do not reflect that.
+
+--- parted-3.2/tests/t5000-tags.sh.old 2014-06-15 18:17:43.000000000 +0000
++++ parted-3.2/tests/t5000-tags.sh 2017-08-19 18:55:03.207451920 +0000
+@@ -48,7 +48,7 @@
+ compare exp out || fail=1
+
+ # add a partition
+-parted -s $dev u s mkpart name1 ${start_sector} ${end_sector} >out 2>&1 \
++parted -s $dev u s mkpart primary ${start_sector} ${end_sector} name 1 name1 >out 2>&1 \
+ || fail=1
+
+ # print the table before modification
+--- parted-3.2/tests/t0208-mkpart-end-in-IEC.sh.old 2014-06-15 18:17:43.000000000 +0000
++++ parted-3.2/tests/t0208-mkpart-end-in-IEC.sh 2017-08-19 20:05:19.650875813 +0000
+@@ -25,22 +25,22 @@
+
+ dd if=/dev/null of=$dev bs=1M seek=$n_mbs || fail=1
+ # create 1st partition
+-parted --align=none -s $dev mklabel gpt mkpart p1 1MiB 2MiB > err 2>&1 || fail=1
++parted --align=none -s $dev mklabel gpt mkpart primary 1MiB 2MiB name 1 p1 > err 2>&1 || fail=1
+ compare /dev/null err || fail=1 # expect no output
+ #parted -m -s $dev u s p > exp || fail=1
+
+ # create 2nd partition - they should not overlap
+ # this time specify default unit
+-parted --align=none -s $dev unit MiB mkpart p2 2 3 > err 2>&1 || fail=1
++parted --align=none -s $dev unit MiB mkpart primary 2 3 name 2 p2 > err 2>&1 || fail=1
+ compare /dev/null err || fail=1 # expect no output
+
+ # create 3rd partition - expect no overlap
+ # specify default unit, but explicitly override it
+-parted --align=none -s $dev unit TB mkpart p3 3MiB 4MiB > err 2>&1 || fail=1
++parted --align=none -s $dev unit TB mkpart primary 3MiB 4MiB name 3 p3 > err 2>&1 || fail=1
+ compare /dev/null err || fail=1 # expect no output
+
+ # Specify default unit of MiB, yet use explicit ending sector number.
+-parted --align=none -s $dev unit MiB mkpart p4 4MiB 10239s > err 2>&1 || fail=1
++parted --align=none -s $dev unit MiB mkpart primary 4MiB 10239s name 4 p4 > err 2>&1 || fail=1
+ compare /dev/null err || fail=1 # expect no output
+
+ # check boundaries of the partitions
diff --git a/system/parted/tests-python3.patch b/system/parted/tests-python3.patch
new file mode 100644
index 000000000..8811b7237
--- /dev/null
+++ b/system/parted/tests-python3.patch
@@ -0,0 +1,68 @@
+--- parted-3.2/tests/gpt-header-move.old 2014-06-15 18:27:30.000000000 +0000
++++ parted-3.2/tests/gpt-header-move 2017-08-19 20:47:02.443283140 +0000
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/env python3
+
+ # open img file, subtract 33 from altlba address, and move the last 33 sectors
+ # back by 33 sectors
+@@ -11,12 +11,12 @@
+ file.seek(512)
+ gptheader = file.read(512)
+ altlba = unpack_from('<q', gptheader,offset=32)[0]
+-gptheader = array.array('c',gptheader)
++gptheader = array.array('B',gptheader)
+ pack_into('<Q', gptheader, 32, altlba-33)
+ #zero header crc
+ pack_into('<L', gptheader, 16, 0)
+ #compute new crc
+-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
++newcrc = ((crc32(memoryview(gptheader[0:92]))) & 0xFFFFFFFF)
+ pack_into('<L', gptheader, 16, newcrc)
+ file.seek(512)
+ file.write(gptheader)
+@@ -25,7 +25,7 @@
+ file.seek(512*(altlba-32))
+ backup = file.read(512*32)
+ altlba -= 33
+-gptheader = array.array('c',gptheader)
++gptheader = array.array('B',gptheader)
+ #update mylba
+ pack_into('<Q', gptheader, 24, altlba)
+ #update table lba
+@@ -33,7 +33,7 @@
+ #zero header crc
+ pack_into('<L', gptheader, 16, 0)
+ #compute new crc
+-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
++newcrc = ((crc32(memoryview(gptheader[0:92]))) & 0xFFFFFFFF)
+ pack_into('<L', gptheader, 16, newcrc)
+ file.seek(512*(altlba-32))
+ file.write(backup)
+@@ -38,4 +38,4 @@
+ file.seek(512*(altlba-32))
+ file.write(backup)
+ file.write(gptheader)
+-file.write("\0" * (512 * 33))
++file.write(b"\0" * (512 * 33))
+--- parted-3.2/tests/msdos-overlap.old 2014-06-15 18:27:30.000000000 +0000
++++ parted-3.2/tests/msdos-overlap 2017-08-19 20:48:16.279847771 +0000
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/env python3
+ """
+ Write an overlapping partition to a msdos disk
+
+@@ -14,10 +14,10 @@
+ OFFSET = 0x1b8
+
+ if len(sys.argv) < 2:
+- print "%s: <image or device>"
++ print("%s: <image or device>")
+ sys.exit(1)
+
+-data = "".join(chr(c) for c in BAD_ENTRY)
++data = bytearray(BAD_ENTRY)
+ with open(sys.argv[1], "rb+") as f:
+ f.seek(OFFSET, 0)
+ f.write(data)
diff --git a/system/pcre/APKBUILD b/system/pcre/APKBUILD
new file mode 100644
index 000000000..43ac2a9d6
--- /dev/null
+++ b/system/pcre/APKBUILD
@@ -0,0 +1,90 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=pcre
+pkgver=8.41
+pkgrel=1
+pkgdesc="Perl-compatible regular expression library"
+url="http://pcre.sourceforge.net"
+arch="all"
+license="BSD"
+depends=
+makedepends=""
+checkdepends="paxmark"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-tools
+ libpcrecpp libpcre16 libpcre32"
+source="ftp://ftp.csx.cam.ac.uk/pub/software/programming/$pkgname/$pkgname-$pkgver.tar.bz2
+ "
+
+# secfixes:
+# 8.40-r2:
+# - CVE-2017-7186
+# 7.8-r0:
+# - CVE-2017-11164
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ ([ "$CARCH" = "s390x" ] || [ "$CARCH" = "ppc64" ]) && _enable_jit="" || _enable_jit="--enable-jit"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ $_enable_jit \
+ --enable-utf8 \
+ --enable-unicode-properties \
+ --enable-pcre8 \
+ --enable-pcre16 \
+ --enable-pcre32 \
+ --with-match-limit-recursion=8192 \
+ --htmldir=/usr/share/doc/$pkgname-$pkgver/html \
+ --docdir=/usr/share/doc/$pkgname-$pkgver
+
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+check() {
+ cd "$builddir"
+
+ # paxmark tests requiring JIT
+ for fn in pcre_jit_test pcretest; do
+ ./$fn &>/dev/null < /dev/null || true
+ [ -x .libs/lt-$fn ] && paxmark -m .libs/lt-$fn
+ done
+
+ # skip locale specific tests
+ sed -i -e 's/do3=yes//g' RunTest
+
+ make check
+}
+
+libpcrecpp() {
+ pkgdesc="C++ bindings for PCRE"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpcrecpp.so* "$subpkgdir"/usr/lib/
+}
+
+libpcre16() {
+ pkgdesc="PCRE with 16 bit character support"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpcre16.so* "$subpkgdir"/usr/lib/
+}
+
+libpcre32() {
+ pkgdesc="PCRE with 32 bit character support"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpcre32.so* "$subpkgdir"/usr/lib/
+}
+
+tools() {
+ pkgdesc="Auxiliary utilities for PCRE"
+ mkdir -p "$subpkgdir"/usr/
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+sha512sums="cc9cdbeb98c010fe4f093a019bebfb91965dae4c6a48f8e49c38ec8df7d9da7f0d32c12fc58f22c51f1c2f010e72b65bcbf8bbf180060e93edf464fa9a7c3551 pcre-8.41.tar.bz2"
diff --git a/system/pcre2/APKBUILD b/system/pcre2/APKBUILD
new file mode 100644
index 000000000..d06c4b22c
--- /dev/null
+++ b/system/pcre2/APKBUILD
@@ -0,0 +1,88 @@
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
+pkgname=pcre2
+pkgver=10.30
+pkgrel=1
+pkgdesc="Perl-compatible regular expression library"
+url="http://pcre.sourceforge.net/"
+arch="all"
+license="BSD"
+depends=""
+depends_dev="libedit-dev zlib-dev"
+makedepends="$depends_dev paxmark"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-tools
+ libpcre2-16:_libpcre libpcre2-32:_libpcre"
+source="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/$pkgname-$pkgver.tar.gz"
+builddir="$srcdir/$pkgname-$pkgver"
+
+case "$CARCH" in
+ s390x) _enable_jit="";;
+ ppc64) _enable_jit="";;
+ pmmx) _enable_jit="";; # maybe someday fix sse2 detection
+ *) _enable_jit="--enable-jit";;
+esac
+
+build() {
+ cd "$builddir"
+
+ # Note: Forced -O3 is recommended (needed?) for Julia.
+ ./configure \
+ CFLAGS="$CFLAGS -O3" \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --docdir=/usr/share/doc/$pkgname-$pkgver \
+ --htmldir=/usr/share/doc/$pkgname-$pkgver/html \
+ --enable-pcre2-16 \
+ --enable-pcre2-32 \
+ --enable-pcre2grep-libz \
+ --enable-pcre2test-libedit \
+ --with-match-limit-recursion=8192 \
+ $_enable_jit
+ make
+}
+
+# Note: RunTest and pcre2_jit_test generates some binaries in .libs that needs
+# to disable MPROTECT on grsecurity kernel. That's why it's so complicated...
+check() {
+ cd "$builddir"
+
+ local is_pax=$(grep -q PaX /proc/$$/status && echo 'yes' || echo 'no')
+
+ if [ "$is_pax" = yes ]; then
+ timeout -t 1 -s KILL ./RunTest 2>/dev/null || true
+ find .libs -type f ! -name 'lib*' | xargs paxmark m
+ fi
+ ./RunTest
+
+ if [ -n "$_enable_jit" ]; then
+ if [ "$is_pax" = yes ]; then
+ timeout -t 1 -s KILL ./pcre2_jit_test >/dev/null || true
+ find .libs -type f ! -name 'lib*' | xargs paxmark m
+ fi
+ ./pcre2_jit_test
+ fi
+}
+
+package() {
+ cd "$builddir"
+
+ make DESTDIR="$pkgdir" install
+}
+
+_libpcre() {
+ local bits="${subpkgname##*-}"
+ pkgdesc="PCRE2 with $bits bit character support"
+
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/libpcre2-$bits.so* "$subpkgdir"/usr/lib/
+}
+
+tools() {
+ pkgdesc="Auxiliary utilities for PCRE2"
+
+ mkdir -p "$subpkgdir"/usr/
+ mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+sha512sums="af6c7cd8e25ec1ed538c89808b144a508ee6f5ca08134f04119e4786d69643bea99bec3c9527d201cec47ba52032d55ad7692b448b4696d68fd4ed1081dbaa62 pcre2-10.30.tar.gz"
diff --git a/system/postgresql/APKBUILD b/system/postgresql/APKBUILD
new file mode 100644
index 000000000..e618eeb39
--- /dev/null
+++ b/system/postgresql/APKBUILD
@@ -0,0 +1,259 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+# Contributor: G.J.R. Timmer <gjr.timmer@gmail.com>
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+pkgname=postgresql
+pkgver=10.0
+pkgrel=0
+pkgdesc="A sophisticated object-relational DBMS"
+url="http://www.postgresql.org/"
+arch="all"
+license="BSD"
+depends="postgresql-client tzdata"
+options="!checkroot"
+install="$pkgname.pre-upgrade"
+pkgusers="postgres"
+pkggroups="postgres"
+checkdepends="diffutils"
+depends_dev="openssl-dev"
+makedepends="$depends_dev libedit-dev zlib-dev libxml2-dev util-linux-dev
+ openldap-dev tcl-dev perl-dev python3-dev"
+subpackages="$pkgname-contrib $pkgname-dev $pkgname-doc libpq $pkgname-libs
+ $pkgname-client $pkgname-pltcl
+ $pkgname-plperl $pkgname-plperl-contrib:plperl_contrib
+ $pkgname-plpython3 $pkgname-plpython3-contrib:plpython3_contrib"
+source="https://ftp.postgresql.org/pub/source/v$pkgver/$pkgname-$pkgver.tar.bz2
+ initdb.patch
+ perl-rpath.patch
+ conf-unix_socket_directories.patch
+ disable-broken-tests.patch
+ $pkgname.initd
+ $pkgname.confd
+ pg-restore.initd
+ pg-restore.confd
+ pltcl_create_tables.sql
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+options="!checkroot"
+
+# secfixes:
+# 9.6.4-r0:
+# - CVE-2017-7546
+# - CVE-2017-7547
+# - CVE-2017-7548
+# 9.6.3-r0:
+# - CVE-2017-7484
+# - CVE-2017-7485
+# - CVE-2017-7486
+
+prepare() {
+ default_prepare
+ cd "$builddir"
+
+ local file; for file in $pkgname.initd $pkgname.confd; do
+ sed "s|@VERSION@|${pkgver%.*}|" "$srcdir"/$file > $file
+ done
+}
+
+build() {
+ _configure
+ make world
+}
+
+# Note: (...) instead of {...} is NOT a typo!
+_configure() (
+ export CFLAGS="${CFLAGS/-Os/-O2}"
+ export CPPFLAGS="${CPPFLAGS/-Os/-O2}"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --mandir=/usr/share/man \
+ --with-system-tzdata=/usr/share/zoneinfo \
+ --with-ldap \
+ --with-libedit-preferred \
+ --with-libxml \
+ --with-openssl \
+ --with-uuid=e2fs \
+ --disable-rpath \
+ --with-perl \
+ --with-python \
+ --with-tcl
+)
+
+check() {
+ cd "$builddir"
+
+ _run_tests src/test
+ _run_tests src/pl
+ _run_tests contrib
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+
+ make DESTDIR="$pkgdir" install install-docs
+
+ cd "$pkgdir"
+
+ install -d -m750 -o postgres -g postgres \
+ ./var/lib/postgresql \
+ ./var/log/$pkgname
+
+ install -D -m755 "$builddir"/postgresql.initd ./etc/init.d/postgresql
+ install -D -m644 "$builddir"/postgresql.confd ./etc/conf.d/postgresql
+
+ install -D -m755 "$srcdir"/pg-restore.initd ./etc/init.d/pg-restore
+ install -D -m644 "$srcdir"/pg-restore.confd ./etc/conf.d/pg-restore
+}
+
+dev() {
+ default_dev
+
+ _submv usr/bin/pg_config \
+ usr/bin/ecpg \
+ usr/lib/postgresql/pgxs
+}
+
+libpq() {
+ pkgdesc="PostgreSQL libraries"
+ depends=""
+
+ _submv usr/lib/libpq.so.*
+}
+
+libs() {
+ depends=""
+ default_libs
+}
+
+client() {
+ pkgdesc="PostgreSQL client"
+ depends=""
+
+ cd "$pkgdir"/usr/bin
+ mkdir -p "$subpkgdir"/usr/bin
+ mv clusterdb \
+ createdb \
+ createuser \
+ dropdb \
+ dropuser \
+ pg_basebackup \
+ pg_dump \
+ pg_dumpall \
+ pg_isready \
+ pg_receivewal \
+ pg_recvlogical \
+ pg_restore \
+ psql \
+ reindexdb \
+ vacuumdb \
+ "$subpkgdir"/usr/bin/
+}
+
+contrib() {
+ pkgdesc="Extension modules distributed with PostgreSQL"
+ depends=""
+
+ cd "$builddir"
+
+ # Avoid installing plperl and plpython extensions, these will be
+ # installed into separate subpackages.
+ sed -Ei -e 's/(.*_plperl)/#\1/' \
+ -e 's/(.*_plpython)/#\1/' \
+ contrib/Makefile
+
+ make -C contrib DESTDIR="$subpkgdir" install
+
+ mv "$subpkgdir"/usr/share/doc/postgresql/extension \
+ "$pkgdir"/usr/share/doc/postgresql/
+ rmdir -p "$subpkgdir"/usr/share/doc/postgresql || true
+}
+
+pltcl() {
+ pkgdesc="PL/Tcl procedural language for PostgreSQL"
+ depends="pgtcl"
+
+ _submv usr/lib/postgresql/pltcl.so \
+ usr/share/postgresql/extension/pltcl*
+
+ install -m 644 "$srcdir"/pltcl_create_tables.sql \
+ "$subpkgdir"/usr/share/postgresql/
+}
+
+plperl() {
+ pkgdesc="PL/Perl procedural language for PostgreSQL"
+ depends=""
+
+ _submv usr/lib/postgresql/plperl.so \
+ usr/share/postgresql/extension/plperl*
+}
+
+plperl_contrib() {
+ _plcontrib plperl "PL/Perl"
+
+ cd "$builddir"
+ make -C contrib/hstore_plperl DESTDIR="$subpkgdir" install
+}
+
+plpython3() {
+ pkgdesc="PL/Python3 procedural language for PostgreSQL"
+ depends="python3"
+
+ cd "$builddir"
+ make -C src/pl/plpython DESTDIR="$subpkgdir" install
+ rm -R "$subpkgdir"/usr/include
+}
+
+plpython3_contrib() {
+ _plcontrib plpython3 "PL/Python 3"
+
+ cd "$builddir"
+ make -C contrib/hstore_plpython DESTDIR="$subpkgdir" install
+ make -C contrib/ltree_plpython DESTDIR="$subpkgdir" install
+}
+
+_plcontrib() {
+ local subname="$1"
+ pkgdesc="$2 extension modules distributed with PostgreSQL"
+ depends="$pkgname-$subname"
+ install_if="$pkgname-$subname=$pkgver-r$pkgrel $pkgname-contrib=$pkgver-r$pkgrel"
+}
+
+_run_tests() {
+ local path="$1"; shift
+
+ msg "Running test suite at $path..."
+ # Note: some tests fail when running in parallel.
+ make -k -j 1 -C "$path" $@ check MAX_CONNECTIONS=5 || {
+ printf "\n%s\n\n" "Trying to find all regression.diffs files in build directory..." >&2
+ find "$path" -name regression.diffs | while read file; do
+ echo "=== test failure: $file ===" >&2
+ cat "$file" >&2
+ done
+ return 1
+ }
+}
+
+_submv() {
+ local path; for path in "$@"; do
+ mkdir -p "$subpkgdir/${path%/*}"
+ mv "$pkgdir"/$path "$subpkgdir"/${path%/*}/
+ done
+}
+
+sha512sums="88295af13db77a85a604c925aa627d383fdac62c1185119bba87753ce4167a13aed0f055a7a1329b3051f8757c6ba7529baed00a564ef0cfbee685720f282678 postgresql-10.0.tar.bz2
+1f8e7dc58f5b0a12427cf2fd904ffa898a34f23f3332c8382b94e0d991c007289e7913a69e04498f3d93fc5701855796c207b4b1cc4a0b366f586050124d7fcc initdb.patch
+5f9d8bb4957194069d01af8ab3abc6d4d83a7e7f8bd7ebe1caae5361d621a3e58f91b14b952958138a794e0a80bc154fbb7e3e78d211e2a95b9b7901335de854 perl-rpath.patch
+8439a6fdfdea0a4867daeb8bc23d6c825f30c00d91d4c39f48653f5ee77341f23282ce03a77aad94b5369700f11d2cb28d5aee360e59138352a9ab331a9f9d0f conf-unix_socket_directories.patch
+1966b2a3971f56fbecd8daa45965236d487683e13300e5c000e595bbadbbe9d0e1301fbbfa034f452abe8a4e4a427781f772370b9ff392bb03fc11ee43c9dee7 disable-broken-tests.patch
+224e80f9e62843fd248e625abdd0d9fe477729ff3f9a64fc5c86dd37bb7176d3504107fbed7ce578e3a1db7f60b8cf2abf5fe4862c81f76b6d026e29ca495cfc postgresql.initd
+a6d9cba5c7270484b3a22083b2b37742faefb01b6643040050c92235840c601b2e206ebda32804937b729c6cf42c79a558b921900e52fc420df2a03b5f29e1f7 postgresql.confd
+f5a1cba051e7d846c2d16703514601cb25729ed96b677c9bd0c199d64552120a8b14b238af01917fdb87106681e12dee6fff7447558155ba273e4f96be5e2892 pg-restore.initd
+c14a5684e914abb3b0ee71bbf15eed71a9264deacaa404a6e3af6bfc330d93e7598624d0ed11a94263106cc660f7f54c8ff57e759033cf606a795f69ff6c1c7c pg-restore.confd
+5c9bfd9e295dcf678298bf0aa974347a7c311d6e7c2aa76a6920fcb751d01fd1ab77abbec11f3c672f927ad9deaa88e04e370c0b5cd1b60087554c474b748731 pltcl_create_tables.sql"
diff --git a/system/postgresql/conf-unix_socket_directories.patch b/system/postgresql/conf-unix_socket_directories.patch
new file mode 100644
index 000000000..24c51e7b9
--- /dev/null
+++ b/system/postgresql/conf-unix_socket_directories.patch
@@ -0,0 +1,14 @@
+Creating socket in /tmp is silly, but unfortunately it's default location,
+so many clients expect it. Thus we preconfigure PostgreSQL to create socket
+both in /run/postgresql and /tmp.
+--- a/src/backend/utils/misc/postgresql.conf.sample
++++ b/src/backend/utils/misc/postgresql.conf.sample
+@@ -63,7 +63,7 @@
+ #port = 5432 # (change requires restart)
+ #max_connections = 100 # (change requires restart)
+ #superuser_reserved_connections = 3 # (change requires restart)
+-#unix_socket_directories = '/tmp' # comma-separated list of directories
++unix_socket_directories = '/run/postgresql,/tmp' # comma-separated list of directories
+ # (change requires restart)
+ #unix_socket_group = '' # (change requires restart)
+ #unix_socket_permissions = 0777 # begin with 0 to use octal notation
diff --git a/system/postgresql/disable-broken-tests.patch b/system/postgresql/disable-broken-tests.patch
new file mode 100644
index 000000000..0bb5b03fa
--- /dev/null
+++ b/system/postgresql/disable-broken-tests.patch
@@ -0,0 +1,119 @@
+These tests fail due to some really weird linking issue like:
+
+ ERROR: could not load library "<builddir>/tmp_install/usr/lib/postgresql/libpqwalreceiver.so": Error loading shared library libpq.so.5: No such file or directory (needed by <builddir>/tmp_install/usr/lib/postgresql/libpqwalreceiver.so)
+
+psql dynamically loads libpq and libpqwalreceiver libs using pg_dlopen()
+which is an alias for dlopen() on Linux. The above message comes from
+src/backend/utils/fmgr/dfmgr.c. The part "Error loading ..." is from
+pg_dlerror() which is alias for dlerror().
+
+LD_LIBRARY_PATH is set and passed correctly. However, the error
+disappeared when I've copied libpq.so* to /usr/lib...
+
+Also:
+
+ $ LD_LIBRARY_PATH=$(pwd) ldd postgresql/libpqwalreceiver.so
+ ldd (0x280d565e000)
+ libpq.so.5 => <builddir>/tmp_install/usr/lib/libpq.so.5 (0x280d520d000)
+ libc.musl-x86_64.so.1 => ldd (0x280d565e000)
+ libssl.so.43 => /lib/libssl.so.43 (0x280d4fc2000)
+ libcrypto.so.41 => /lib/libcrypto.so.41 (0x280d4c1c000)
+ libldap_r-2.4.so.2 => /usr/lib/libldap_r-2.4.so.2 (0x280d49d6000)
+ liblber-2.4.so.2 => /usr/lib/liblber-2.4.so.2 (0x280d47c9000)
+ libsasl2.so.3 => /usr/lib/libsasl2.so.3 (0x280d45b0000)
+ Error relocating postgresql/libpqwalreceiver.so: appendStringInfoChar: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: MyLatch: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: MemoryContextDelete: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: errstart: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: pg_atoi: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: TupleDescGetAttInMetadata: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: WalReceiverFunctions: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: WaitLatchOrSocket: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: MemoryContextReset: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: pfree: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: errmsg: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: tuplestore_puttuple: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: pchomp: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: appendStringInfoString: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: errfinish: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: pstrdup: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: palloc0: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: errdetail: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: ResetLatch: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: work_mem: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: AllocSetContextCreate: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: CurrentMemoryContext: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: tuplestore_begin_heap: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: BuildTupleFromCStrings: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: errcode: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: MyDatabaseId: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: GetDatabaseEncodingName: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: palloc: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: pg_lsn_in: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: ProcessInterrupts: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: elog_start: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: DirectFunctionCall1Coll: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: elog_finish: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: CreateTemplateTupleDesc: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: InterruptPending: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: TupleDescInitEntry: symbol not found
+ Error relocating postgresql/libpqwalreceiver.so: initStringInfo: symbol not found w
+
+These symbols are really not provided by libpq.
+
+I wasted one day trying to figure out what's going on here, but still
+have no idea. :(
+
+--- a/src/test/regress/parallel_schedule
++++ b/src/test/regress/parallel_schedule
+@@ -84,7 +84,7 @@
+ # ----------
+ # Another group of parallel tests
+ # ----------
+-test: brin gin gist spgist privileges init_privs security_label collate matview lock replica_identity rowsecurity object_address tablesample groupingsets drop_operator password
++test: brin gin gist spgist privileges init_privs security_label collate matview lock replica_identity rowsecurity tablesample groupingsets drop_operator password
+
+ # ----------
+ # Another group of parallel tests
+@@ -98,7 +98,7 @@
+ test: select_parallel
+
+ # no relation related tests can be put in this group
+-test: publication subscription
++test: publication
+
+ # ----------
+ # Another group of parallel tests
+--- a/src/test/modules/dummy_seclabel/Makefile
++++ b/src/test/modules/dummy_seclabel/Makefile
+@@ -6,7 +6,7 @@
+ EXTENSION = dummy_seclabel
+ DATA = dummy_seclabel--1.0.sql
+
+-REGRESS = dummy_seclabel
++#REGRESS = dummy_seclabel
+
+ ifdef USE_PGXS
+ PG_CONFIG = pg_config
+--- a/contrib/postgres_fdw/Makefile
++++ b/contrib/postgres_fdw/Makefile
+@@ -10,7 +10,7 @@
+ EXTENSION = postgres_fdw
+ DATA = postgres_fdw--1.0.sql
+
+-REGRESS = postgres_fdw
++#REGRESS = postgres_fdw
+
+ ifdef USE_PGXS
+ PG_CONFIG = pg_config
+--- a/contrib/dblink/Makefile
++++ b/contrib/dblink/Makefile
+@@ -10,7 +10,7 @@
+ dblink--unpackaged--1.0.sql
+ PGFILEDESC = "dblink - connect to other PostgreSQL databases"
+
+-REGRESS = paths dblink
++#REGRESS = paths dblink
+ REGRESS_OPTS = --dlpath=$(top_builddir)/src/test/regress
+ EXTRA_CLEAN = sql/paths.sql expected/paths.out
+
diff --git a/system/postgresql/initdb.patch b/system/postgresql/initdb.patch
new file mode 100644
index 000000000..59a872a49
--- /dev/null
+++ b/system/postgresql/initdb.patch
@@ -0,0 +1,14 @@
+diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
+--- a/src/bin/initdb/initdb.c
++++ b/src/bin/initdb/initdb.c
+@@ -3259,9 +3259,7 @@
+ /* translator: This is a placeholder in a shell command. */
+ appendPQExpBuffer(start_db_cmd, " -l %s start", _("logfile"));
+
+- printf(_("\nSuccess. You can now start the database server using:\n\n"
+- " %s\n\n"),
+- start_db_cmd->data);
++ printf(_("\nSuccess.\n\n"));
+
+ destroyPQExpBuffer(start_db_cmd);
+
diff --git a/system/postgresql/perl-rpath.patch b/system/postgresql/perl-rpath.patch
new file mode 100644
index 000000000..a2505acf7
--- /dev/null
+++ b/system/postgresql/perl-rpath.patch
@@ -0,0 +1,22 @@
+We configure Postgres with --disable-rpath because for the most part we
+want to leave it to ldconfig to determine where libraries are. However,
+for some reason the Perl package puts libperl.so in a nonstandard place
+and doesn't add that place to the ldconfig search path. I think this
+is a Perl packaging bug, myself, but apparently it's not going to change.
+So work around it by adding an rpath spec to plperl.so (only).
+
+Alpine notes:
+This patch is copied from Fedora.
+
+--- a/src/pl/plperl/GNUmakefile
++++ b/src/pl/plperl/GNUmakefile
+@@ -43,6 +43,9 @@
+
+ SHLIB_LINK = $(perl_embed_ldflags)
+
++# Force rpath to be used even though we disable it everywhere else
++SHLIB_LINK += $(rpath)
++
+ REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=plperl --load-extension=plperlu
+ REGRESS = plperl plperl_lc plperl_trigger plperl_shared plperl_elog plperl_util plperl_init plperlu plperl_array
+ # if Perl can support two interpreters in one backend,
diff --git a/system/postgresql/pg-restore.confd b/system/postgresql/pg-restore.confd
new file mode 100644
index 000000000..84a179f6c
--- /dev/null
+++ b/system/postgresql/pg-restore.confd
@@ -0,0 +1,16 @@
+
+# Enable this to dump databases on shutdown and restore on boot
+#
+#PGDUMP="/var/lib/postgresql/backup/databases.pgdump"
+
+# The dump file will be deleted once restored unless KEEP_DUMP is set.
+# This is to avoid accidental restoring of running database. If you know what
+# you are doing and want keep the dump, then enable the KEEP_DUMP option
+# below.
+#
+#KEEP_DUMP=yes
+
+# If you enable KEEP_DUMP above you probably also want the --clean option
+# the the pg_dumpall command.
+#PG_DUMPALL_OPTS="--clean"
+
diff --git a/system/postgresql/pg-restore.initd b/system/postgresql/pg-restore.initd
new file mode 100644
index 000000000..e9fe65c19
--- /dev/null
+++ b/system/postgresql/pg-restore.initd
@@ -0,0 +1,36 @@
+#!/sbin/openrc-run
+
+extra_commands="${opts} dump restore purge"
+
+depend() {
+ need postgresql
+}
+
+restore() {
+ yesno "$PGDUMP" && return 0
+ ebegin "Restoring PostgreSQL $PGDUMP"
+ psql -U ${PG_USER:-postgres} ${PSQL_OPTS} -f "$PGDUMP" >/dev/null 2>/dev/null
+ local res=$?
+ yesno "$KEEP_DUMP" || rm -f "$PGDUMP"
+ eend $res
+ /etc/init.d/postgresql reload
+}
+
+dump() {
+ yesno "$PGDUMP" && return 0
+ mkdir -p "$( dirname "$PGDUMP" )"
+ ebegin "Saving PostgreSQL databases to $PGDUMP"
+ pg_dumpall -U ${PG_USER:-postgres} ${PG_DUMPALL_OPTS} -f "$PGDUMP"
+ eend $?
+}
+
+purge() {
+ yesno "$PGDUMP" && return 0
+ ebegin "Removing temporary $PGDUMP PostgreSQL backup"
+ rm -f "$PGDUMP"
+ eend $?
+}
+
+start() {
+ restore
+}
diff --git a/system/postgresql/pltcl_create_tables.sql b/system/postgresql/pltcl_create_tables.sql
new file mode 100644
index 000000000..76c7a954a
--- /dev/null
+++ b/system/postgresql/pltcl_create_tables.sql
@@ -0,0 +1,13 @@
+-- Create tables needed for PL/Tcl autoloading. This script should be run by
+-- the database administrator only.
+--
+-- Statements in this script are extracted from pltcl_loadmod script.
+--
+-- Author: G.J.R. Timmer
+-- Date: 2017-01-28
+
+create table pltcl_modules (modname name, modseq int2, modsrc text);
+create index pltcl_modules_i on pltcl_modules using btree (modname name_ops);
+
+create table pltcl_modfuncs (funcname name, modname name);
+create index pltcl_modfuncs_i on pltcl_modfuncs using hash (funcname name_ops);
diff --git a/system/postgresql/postgresql.confd b/system/postgresql/postgresql.confd
new file mode 100644
index 000000000..6a25cc381
--- /dev/null
+++ b/system/postgresql/postgresql.confd
@@ -0,0 +1,59 @@
+# Which port and socket to bind PostgreSQL.
+# This may be overriden in postgresql.conf.
+#port="5432"
+
+# How long to wait for server to start in seconds.
+#start_timeout=10
+
+# Number of seconds to wait for clients to disconnect from the server before
+# shutting down. Set to zero to disable this timeout.
+#nice_timeout=60
+
+# Timeout in seconds for rude quit - forecfully disconnect clients from server
+# and shut down. This is performed after nice_timeout exceeded. Terminated
+# client connections have their open transactions rolled back.
+# Set "rude_quit=no" to disable.
+#rude_quit="yes"
+#rude_timeout=30
+
+# Timeout in seconds for force quit - if the server still fails to shutdown,
+# you can force it to quit and a recover-run will execute on the next startup.
+# Set "force_quit=yes" to enable.
+#force_quit="no"
+#force_timeout="2"
+
+# Extra options to run postmaster with, e.g.:
+# -N is the maximal number of client connections
+# -B is the number of shared buffers (has to be at least 2x the value for -N)
+# Please read man postgres(1) for more options. Many of these options can be
+# set directly in the configuration file.
+#pg_opts="-N 512 -B 1024"
+
+# Pass extra environment variables. If you have to export environment variables
+# for the database process, this can be done here.
+# Don't forget to escape quotes.
+#env_vars="PGPASSFILE=\"/path/to/.pgpass\""
+
+# Location of postmaster.log. Default is $data_dir/postmaster.log.
+logfile="/var/log/postgresql/postmaster.log"
+
+# Automatically set up a new database if missing on startup.
+#auto_setup="yes"
+
+
+##############################################################################
+#
+# The following values should NOT be arbitrarily changed!
+#
+# The initscript uses these variables to inform PostgreSQL where to find
+# its data directory and configuration files.
+
+# Where the data directory is located/to be created.
+#data_dir="/var/lib/postgresql/@VERSION@/data"
+
+# Location of configuration files. Default is $data_dir.
+conf_dir="/etc/postgresql"
+
+# Additional options to pass to initdb.
+# See man initdb(1) for available options.
+#initdb_opts="--locale=en_US.UTF-8"
diff --git a/system/postgresql/postgresql.initd b/system/postgresql/postgresql.initd
new file mode 100644
index 000000000..846229a40
--- /dev/null
+++ b/system/postgresql/postgresql.initd
@@ -0,0 +1,220 @@
+#!/sbin/openrc-run
+
+extra_started_commands="reload"
+description_reload="Reload configuration"
+
+extra_stopped_commands="setup"
+description_setup="Initialize a new PostgreSQL cluster"
+
+# Note: Uppercase variables are here for backward compatibility.
+
+: ${user:=${PGUSER:-"postgres"}}
+: ${group:=${PGGROUP:-"postgres"}}
+
+: ${auto_setup:=${AUTO_SETUP:-"yes"}}
+: ${start_timeout:=${START_TIMEOUT:-10}}
+: ${nice_timeout:=${NICE_TIMEOUT:-60}}
+: ${rude_quit:=${RUDE_QUIT:-"yes"}}
+: ${rude_timeout:=${RUDE_TIMEOUT:-30}}
+: ${force_quit:=${FORCE_QUIT:-"no"}}
+: ${force_timeout:=${FORCE_TIMEOUT:-2}}
+
+: ${data_dir:=${PGDATA:-"/var/lib/postgresql/@VERSION@/data"}}
+: ${conf_dir:=$data_dir}
+: ${env_vars:=${PG_EXTRA_ENV:-}}
+: ${initdb_opts:=${PG_INITDB_OPTS:-}}
+: ${logfile:="$data_dir/postmaster.log"}
+: ${pg_opts:=${PGOPTS:-}}
+: ${port:=${PGPORT:-5432}}
+
+command="/usr/bin/postgres"
+
+conffile="$conf_dir/postgresql.conf"
+pidfile="$data_dir/postmaster.pid"
+start_stop_daemon_args="
+ --user $user
+ --group $group
+ --pidfile $pidfile
+ --wait 100"
+
+depend() {
+ use net
+ after firewall
+
+ if [ "$(get_config log_destination)" = "syslog" ]; then
+ use logger
+ fi
+}
+
+start_pre() {
+ check_deprecated_var WAIT_FOR_START start_timeout
+ check_deprecated_var WAIT_FOR_DISCONNECT nice_timeout
+ check_deprecated_var WAIT_FOR_CLEANUP rude_timeout
+ check_deprecated_var WAIT_FOR_QUIT force_timeout
+
+ if [ ! -d "$data_dir/base" ]; then
+ if yesno "$auto_setup"; then
+ setup || return 1
+ else
+ eerror "Database not found at: $data_dir"
+ eerror "Please make sure that 'data_dir' points to the right path."
+ eerror "You can run '/etc/init.d/postgresql setup' to setup a new database cluster."
+ return 1
+ fi
+ fi
+
+ local socket_dirs=$(get_config "unix_socket_directories" "/run/postgresql")
+ local port=$(get_config "port" "$port")
+
+ start_stop_daemon_args="$start_stop_daemon_args --env PGPORT=$port"
+
+ (
+ # Set the proper permission for the socket paths and create them if
+ # then don't exist.
+ set -f; IFS=","
+ for dir in $socket_dirs; do
+ if [ -e "${dir%/}/.s.PGSQL.$port" ]; then
+ eerror "Socket conflict. A server is already listening on:"
+ eerror " ${dir%/}/.s.PGSQL.$port"
+ eerror "Hint: Change 'port' to listen on a different socket."
+ return 1
+ elif [ "${dir%/}" != "/tmp" ]; then
+ checkpath -d -m 1775 -o $user:$group "$dir"
+ fi
+ done
+ )
+}
+
+start() {
+ local retval
+
+ ebegin "Starting PostgreSQL"
+
+ local var; for var in $env_vars; do
+ start_stop_daemon_args="$start_stop_daemon_args --env $var"
+ done
+
+ rm -f "$pidfile"
+ start-stop-daemon --start \
+ $start_stop_daemon_args \
+ --exec /usr/bin/pg_ctl \
+ -- start \
+ --silent \
+ -w --timeout="$start_timeout" \
+ --log="$logfile" \
+ --pgdata="$conf_dir" \
+ -o "--data-directory=$data_dir $pg_opts"
+ retval=$?
+
+ if [ $retval -ne 0 ]; then
+ eerror "Check the log for a possible explanation of the above error:"
+ eerror " $logfile"
+ fi
+ eend $retval
+}
+
+stop() {
+ local retry="SIGTERM/$nice_timeout"
+
+ yesno "$rude_quit" \
+ && retry="$retry/SIGINT/$rude_timeout" \
+ || rude_timeout=0
+
+ yesno "$force_quit" \
+ && retry="$retry/SIGQUIT/$force_timeout" \
+ || force_timeout=0
+
+ local seconds=$(( $nice_timeout + $rude_timeout + $force_timeout ))
+
+ ebegin "Stopping PostgreSQL (this can take up to $seconds seconds)"
+
+ start-stop-daemon --stop \
+ --exec "$command" \
+ --retry "$retry" \
+ --progress \
+ --pidfile "$pidfile"
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading PostgreSQL configuration"
+
+ start-stop-daemon --signal HUP --pidfile "$pidfile"
+ eend $?
+}
+
+setup() {
+ local bkpdir
+
+ ebegin "Creating a new PostgreSQL database cluster"
+
+ if [ -d "$data_dir/base" ]; then
+ eend 1 "$data_dir/base already exists!"; return 1
+ fi
+
+ # If data_dir exists, backup configs.
+ if [ -d "$data_dir" ]; then
+ bkpdir="$(mktemp -d)"
+ find "$data_dir" -type f -name "*.conf" -maxdepth 1 \
+ -exec mv -v {} "$bkpdir"/ \;
+ rm -rf "$data_dir"/*
+ fi
+
+ install -d -m 0700 -o $user -g $group "$data_dir"
+ install -d -m 0750 -o $user -g $group "$conf_dir"
+
+ cd "$data_dir" # to avoid the: could not change directory to "/root"
+ su $user -c "/usr/bin/initdb $initdb_opts --pgdata $data_dir"
+ local retval=$?
+
+ if [ -d "$bkpdir" ]; then
+ # Move backuped configs back.
+ mv -v "$bkpdir"/* "$data_dir"/
+ rm -rf "$bkpdir"
+ fi
+
+ if [ "${data_dir%/}" != "${conf_dir%/}" ]; then
+ # Move configs from data_dir to conf_dir and symlink them to data_dir.
+ local name newname
+ for name in postgresql.conf pg_hba.conf pg_ident.conf; do
+ newname="$name"
+ [ ! -e "$conf_dir"/$name ] || newname="$name.new"
+
+ mv "$data_dir"/$name "$conf_dir"/$newname
+ ln -s "$conf_dir"/$name "$data_dir"/$name
+ done
+ fi
+
+ eend $retval
+}
+
+
+get_config() {
+ local name="$1"
+ local default="${2:-}"
+
+ if [ ! -f "$conffile" ]; then
+ printf '%s\n' "$default"
+ return 1
+ fi
+ sed -En "/^\s*${name}\b/{ # find line starting with the name
+ s/^\s*${name}\s*=?\s*([^#]+).*/\1/; # capture the value
+ s/\s*$//; # trim trailing whitespaces
+ s/^['\"](.*)['\"]$/\1/; # remove delimiting quotes
+ p
+ }" "$conffile" \
+ | grep . || printf '%s\n' "$default"
+}
+
+check_deprecated_var() {
+ local old_name="$1"
+ local new_name="$2"
+
+ if [ -n "$(getval "$old_name")" ]; then
+ ewarn "Variable '$old_name' has been removed, please use '$new_name' instead."
+ fi
+}
+
+getval() {
+ eval "printf '%s\n' \"\$$1\""
+}
diff --git a/system/postgresql/postgresql.pre-upgrade b/system/postgresql/postgresql.pre-upgrade
new file mode 100644
index 000000000..6116252c1
--- /dev/null
+++ b/system/postgresql/postgresql.pre-upgrade
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+new="$1"
+old="$2"
+
+pgver=${new%.*}
+compare=$(apk version -t "$old" $pgver)
+
+# check if we upgrade from earlier than $pgver and if it is running
+if [ "$compare" != "<" ] || ! /etc/init.d/postgresql --quiet status; then
+ exit 0
+fi
+
+if [ -f /etc/conf.d/postgresql ]; then
+ . /etc/conf.d/postgresql
+fi
+
+cat <<EOF
+* You are upgrading to postgres $pgver wich is not compatible with the running
+* See: http://www.postgresql.org/docs/$pgver/static/upgrading.html
+*
+* The corresponding steps for Alpine Linux is:
+*
+* pg_dumpall -U ${PGUSER:-postgres} > dumpfile
+* /etc/init.d/postgresql stop
+* apk add -u postgresql
+* /etc/init.d/postgresql setup
+* /etc/init.d/postgresql start
+* psql -U ${PGUSER:-postgres} -f dumpfile
+*
+EOF
+exit 1
diff --git a/system/py-dbus/APKBUILD b/system/py-dbus/APKBUILD
new file mode 100644
index 000000000..87da11915
--- /dev/null
+++ b/system/py-dbus/APKBUILD
@@ -0,0 +1,44 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=py-dbus
+pkgver=1.2.0
+pkgrel=3
+pkgdesc="Python bindings for DBUS"
+url="http://www.freedesktop.org/wiki/Software/DBusBindings"
+arch="all"
+license="GPL LGPL"
+depends="python3"
+depends_dev="py-dbus"
+makedepends="dbus-glib-dev python3-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://dbus.freedesktop.org/releases/dbus-python/dbus-python-$pkgver.tar.gz"
+
+builddir="$srcdir"/dbus-python-$pkgver
+
+prepare() {
+ cd "$builddir"
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr
+ make
+}
+
+check() {
+ cd "$builddir"
+ make test
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+md5sums="b09cd2d1a057cc432ce944de3fc06bf7 dbus-python-1.2.0.tar.gz"
+sha256sums="e12c6c8b2bf3a9302f75166952cbe41d6b38c3441bbc6767dbd498942316c6df dbus-python-1.2.0.tar.gz"
+sha512sums="013b23e08fa1ed43f53a756587fefbc9770f7c51e93510e555acbd77230b7200693419bba9a69680d790bbaf123f4a195afa38b3eee1143da950fee0b5130bce dbus-python-1.2.0.tar.gz"
diff --git a/system/py-mako/APKBUILD b/system/py-mako/APKBUILD
new file mode 100644
index 000000000..2ef83e096
--- /dev/null
+++ b/system/py-mako/APKBUILD
@@ -0,0 +1,51 @@
+# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
+# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
+pkgname=py-mako
+_pkgname=Mako
+pkgver=1.0.7
+pkgrel=0
+pkgdesc="A Python fast templating language"
+url="http://www.makotemplates.org/"
+arch="noarch"
+license="MIT"
+depends=""
+makedepends="python3-dev"
+checkdepends="py-six"
+subpackages="py3-${pkgname#py-}:_py3"
+source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
+builddir="$srcdir"/$_pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ python3 setup.py build
+}
+
+package() {
+ mkdir -p "$pkgdir"
+}
+
+check() {
+ cd "$builddir"
+ python3 setup.py test
+}
+
+_py2() {
+ replaces="$pkgname"
+ _py python2
+}
+
+_py3() {
+ _py python3
+}
+
+_py() {
+ local python="$1"
+ pkgdesc="$pkgdesc (for $python)"
+ depends="$depends $python"
+ install_if="$pkgname=$pkgver-r$pkgrel $python"
+
+ cd "$builddir"
+ $python setup.py install --prefix=/usr --root="$subpkgdir"
+}
+
+sha512sums="d67af6788bf8603010361ce8b6d0355b0191657c07f3b5845f9d5e91653c3e349a7b35d5b36aa9c7f291973c83911ce94075e1cad78e6935d0ed4ee9c6e2a571 Mako-1.0.7.tar.gz"
diff --git a/system/qca/APKBUILD b/system/qca/APKBUILD
new file mode 100644
index 000000000..669389ac7
--- /dev/null
+++ b/system/qca/APKBUILD
@@ -0,0 +1,35 @@
+# Contributor: William Pitcock <nenolod@dereferenced.org>
+# Maintainer: A. Wilcox <awilfox@adelielinux.org>
+pkgname=qca
+pkgver=2.1.3
+pkgrel=5
+pkgdesc="Qt cryptographic architecture"
+url="http://delta.affinix.com/qca/"
+arch="all"
+license="LGPL-2.1+"
+depends=
+depends_dev="qt5-qtbase-dev"
+makedepends="$depends_dev cmake cyrus-sasl-dev"
+install=""
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://download.kde.org/stable/qca/$pkgver/src/qca-${pkgver}.tar.xz"
+
+builddir="$srcdir"/qca-$pkgver
+
+build() {
+ cd "$builddir"
+ cmake -DCMAKE_INSTALL_PREFIX=/usr -DWITH_cyrus-sasl_PLUGIN=yes .
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+check() {
+ cd "$builddir"
+ make test
+}
+
+sha512sums="0aec277e0695da2e45298f0a9006213829fe4c449a79969e472947db54f45000ba6e22361b782465bdc03f269b7301d318c843f5a83db459a118e58a03f3116a qca-2.1.3.tar.xz"
diff --git a/system/redis/APKBUILD b/system/redis/APKBUILD
new file mode 100644
index 000000000..fc8ea8426
--- /dev/null
+++ b/system/redis/APKBUILD
@@ -0,0 +1,87 @@
+# Contributor: V.Krishn <vkrishn4@gmail.com>
+# Maintainer:
+pkgname=redis
+pkgver=4.0.2
+pkgrel=2
+pkgdesc="Advanced key-value store"
+url="http://redis.io/"
+arch="all"
+license="BSD"
+depends=""
+makedepends="linux-headers"
+checkdepends="tcl"
+splitpackages="$pkgname-openrc"
+install="redis.pre-install"
+pkgusers="redis"
+pkggroups="redis"
+source="http://download.redis.io/releases/$pkgname-$pkgver.tar.gz
+ fix-ppc-atomics.patch
+ posix-runtest.patch
+ redis.initd
+ redis.logrotate
+ redis.confd
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+ default_prepare
+
+ cd "$builddir"
+ sed -i -e 's|^daemonize .*|daemonize yes|' \
+ -e 's|^dir .*|dir /var/lib/redis/|' \
+ -e 's|^logfile .*|logfile /var/log/redis/redis\.log|' \
+ -e 's|^pidfile .*|pidfile /var/run/redis/redis\.pid|' \
+ -e 's|^loglevel .*|loglevel notice|' \
+ redis.conf
+
+ # disable broken tests
+ # see: https://github.com/antirez/redis/issues/2814
+ # https://github.com/antirez/redis/issues/3810
+
+ sed -i -e '/integration\/aof/d' \
+ -e '/integration\/logging/d' \
+ tests/test_helper.tcl
+}
+
+build() {
+ cd "$builddir"
+ make PREFIX=/usr \
+ INSTALL_BIN="$pkgdir"/usr/bin \
+ MALLOC=libc \
+ FINAL_LIBS="-latomic " \
+ all
+}
+
+check() {
+ cd "$builddir"
+ make test
+}
+
+package() {
+ cd "$builddir"
+ mkdir -p "$pkgdir"/usr/bin
+ install -d -o redis -g redis \
+ "$pkgdir"/var/lib/redis \
+ "$pkgdir"/var/log/redis \
+ "$pkgdir"/var/run/redis
+
+ install -D -m755 "$builddir/COPYING" \
+ "$pkgdir/usr/share/licenses/redis/COPYING"
+ install -D -m755 "$srcdir/redis.initd" "$pkgdir/etc/init.d/redis" \
+ && install -Dm644 "$srcdir/redis.logrotate" \
+ "$pkgdir/etc/logrotate.d/redis" \
+ && install -Dm644 "$srcdir/redis.confd" \
+ "$pkgdir/etc/conf.d/redis"
+ install -D -m644 "$builddir/redis.conf" "$pkgdir/etc/redis.conf"
+
+ make PREFIX=/usr \
+ INSTALL_BIN="$pkgdir/usr/bin" \
+ install
+}
+
+sha512sums="1458909c6fc16cff8ca5e6dddff23b988ee1e447f2d0bccf5941553b22bab6abb851732b3fe53dafb8a69d6c0939c3ce7e0686d51e03be720fb018c038d3b1b4 redis-4.0.2.tar.gz
+f768acea3e1868dbf0596085640c83e58d899860d7d647b0965fa858844c494d0a49b229fb417456d83f3e2690e5450950c31e0fa40529df85a9cde38d8981c4 fix-ppc-atomics.patch
+856ae98e9e8670801827c3bd793dc14ed2c62c37365f8d04b452d7e1ab97300a0bf18c59b52ea686c2689d53aeed8e29e2c55207d3d4fb1fd8fc7fc820f33157 posix-runtest.patch
+91b663f802aea9a473195940d3bf2ce3ca2af4e5b6e61a2d28ebbfe502ef2c764b574b7e87c49e60345d1a5d6b73d12920924c93b26be110c2ce824023347b6f redis.initd
+6d17d169b40a7e23a0a2894eff0f3e2fe8e4461b36f2a9d45468f0abd84ea1035d679b4c0a34029bce093147f9c7bb697e843c113c17769d38c934d4a78a5848 redis.logrotate
+d87aad6185300c99cc9b6a478c83bf62c450fb2c225592d74cc43a3adb93e19d8d2a42cc279907b385aa73a7b9c77b66828dbfb001009edc16a604abb2087e99 redis.confd"
diff --git a/system/redis/fix-ppc-atomics.patch b/system/redis/fix-ppc-atomics.patch
new file mode 100644
index 000000000..0263bb531
--- /dev/null
+++ b/system/redis/fix-ppc-atomics.patch
@@ -0,0 +1,13 @@
+--- redis-4.0.2/src/Makefile.old 2017-09-21 09:12:52.000000000 -0500
++++ redis-4.0.2/src/Makefile 2018-05-26 18:45:23.494413590 -0500
+@@ -109,6 +109,10 @@
+ # Include paths to dependencies
+ FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src
+
++ifeq ($(uname_M),ppc)
++ FINAL_LIBS+= -latomic
++endif
++
+ ifeq ($(MALLOC),tcmalloc)
+ FINAL_CFLAGS+= -DUSE_TCMALLOC
+ FINAL_LIBS+= -ltcmalloc
diff --git a/system/redis/posix-runtest.patch b/system/redis/posix-runtest.patch
new file mode 100644
index 000000000..84d76ad10
--- /dev/null
+++ b/system/redis/posix-runtest.patch
@@ -0,0 +1,33 @@
+--- redis-4.0.2/runtest.old 2017-09-21 09:12:52.000000000 -0500
++++ redis-4.0.2/runtest 2017-12-31 05:50:13.037119127 -0600
+@@ -3,7 +3,7 @@
+ TCLSH=""
+
+ for VERSION in $TCL_VERSIONS; do
+- TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
++ TCL=`command -v tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
+ done
+
+ if [ -z $TCLSH ]
+--- redis-4.0.2/runtest-cluster.old 2017-09-21 09:12:52.000000000 -0500
++++ redis-4.0.2/runtest-cluster 2017-12-31 05:50:20.517111722 -0600
+@@ -3,7 +3,7 @@
+ TCLSH=""
+
+ for VERSION in $TCL_VERSIONS; do
+- TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
++ TCL=`command -v tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
+ done
+
+ if [ -z $TCLSH ]
+--- redis-4.0.2/runtest-sentinel.old 2017-09-21 09:12:52.000000000 -0500
++++ redis-4.0.2/runtest-sentinel 2017-12-31 05:50:26.877105425 -0600
+@@ -3,7 +3,7 @@
+ TCLSH=""
+
+ for VERSION in $TCL_VERSIONS; do
+- TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
++ TCL=`command -v tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
+ done
+
+ if [ -z $TCLSH ]
diff --git a/system/redis/redis.confd b/system/redis/redis.confd
new file mode 100644
index 000000000..a79f61ccd
--- /dev/null
+++ b/system/redis/redis.confd
@@ -0,0 +1,9 @@
+# Redis user.
+REDIS_USER="redis"
+
+# Redis group.
+REDIS_GROUP="redis"
+
+# Redis configuration file.
+REDIS_CONF="/etc/redis.conf"
+
diff --git a/system/redis/redis.initd b/system/redis/redis.initd
new file mode 100755
index 000000000..ce6aba7e3
--- /dev/null
+++ b/system/redis/redis.initd
@@ -0,0 +1,52 @@
+#!/sbin/openrc-run
+
+REDIS_CONF=${REDIS_CONF:-/etc/redis.conf}
+REDIS_USER=${REDIS_USER:-redis}
+REDIS_GROUP=${REDIS_GROUP:-redis}
+
+name="Redis server"
+command=/usr/bin/redis-server
+command_args=${REDIS_CONF}
+
+depend() {
+ use net localmount logger
+ after keepalived firewall
+}
+
+# get global pidfile, logfile, and dir from config file
+get_config() {
+ if [ ! -f "${REDIS_CONF}" ] ; then
+ eerror "You need a ${REDIS_CONF} file to run redis"
+ return 1;
+ fi
+
+ pidfile=$(awk '$1 == "pidfile" { print $2 }' "$REDIS_CONF")
+ logfile=$(awk '$1 == "logfile" { print $2 }' "$REDIS_CONF")
+ dir=$(awk '$1 == "dir" { print $2 }' "$REDIS_CONF")
+ : ${pidfile:=/var/run/redis/redis.pid}
+ : ${logfile:=/var/log/redis/redis.log}
+ : ${dir:=/var/lib/redis}
+}
+
+start() {
+ get_config || return 1
+ checkpath -d -o ${REDIS_USER}:${REDIS_GROUP} ${pidfile%/*} \
+ ${logfile%/*} ${dir}
+
+ ebegin "Starting $name"
+ start-stop-daemon --start \
+ --chdir "${dir}" \
+ --user ${REDIS_USER}:${REDIS_GROUP} \
+ --pidfile "${pidfile}" \
+ --exec "${command}" \
+ -- ${command_args}
+ eend $?
+}
+
+stop() {
+ get_config
+ ebegin "Stopping $name"
+ start-stop-daemon --stop --retry 30 --pidfile "${pidfile}"
+ eend $?
+}
+
diff --git a/system/redis/redis.logrotate b/system/redis/redis.logrotate
new file mode 100644
index 000000000..c77c9a0e8
--- /dev/null
+++ b/system/redis/redis.logrotate
@@ -0,0 +1,4 @@
+/var/log/redis/redis.log {
+ notifempty
+ missingok
+}
diff --git a/system/redis/redis.pre-install b/system/redis/redis.pre-install
new file mode 100644
index 000000000..f73213126
--- /dev/null
+++ b/system/redis/redis.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S redis 2>/dev/null
+adduser -S -D -H -h /var/lib/redis -s /bin/false -G redis -g redis redis 2>/dev/null
+
+exit 0
diff --git a/system/rsync/APKBUILD b/system/rsync/APKBUILD
new file mode 100644
index 000000000..af06ccd38
--- /dev/null
+++ b/system/rsync/APKBUILD
@@ -0,0 +1,65 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=rsync
+pkgver=3.1.2
+pkgrel=7
+pkgdesc="A file transfer program to keep remote files in sync"
+url="https://rsync.samba.org/"
+arch="all"
+license="GPL3"
+options="!checkroot"
+makedepends="perl acl-dev attr-dev popt-dev"
+subpackages="$pkgname-doc $pkgname-openrc rrsync"
+source="https://download.samba.org/pub/$pkgname/$pkgname-$pkgver.tar.gz
+ rsyncd.initd
+ rsyncd.confd
+ rsyncd.conf
+ rsyncd.logrotate
+ "
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ # Force IPv6 enabled, upstream bug https://bugzilla.samba.org/show_bug.cgi?id=10715
+ CFLAGS="$CFLAGS -DINET6" \
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var \
+ --enable-acl-support \
+ --enable-xattr-support
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ install -D -m 755 "$srcdir"/rsyncd.initd "$pkgdir"/etc/init.d/rsyncd
+ install -D -m 644 "$srcdir"/rsyncd.conf "$pkgdir"/etc/rsyncd.conf
+ install -D -m 644 "$srcdir"/rsyncd.confd "$pkgdir"/etc/conf.d/rsyncd
+ install -D -m 644 "$srcdir"/rsyncd.logrotate "$pkgdir"/etc/logrotate.d/rsyncd
+
+}
+
+rrsync() {
+ pkgdesc="Restricted rsync, restricts rsync to a subdir declared in .ssh/authorized_keys"
+ depends="rsync perl"
+ arch="noarch"
+
+ cd "$builddir"
+ install -D -m 755 ./support/rrsync "$subpkgdir"/usr/bin/rrsync
+}
+
+sha512sums="4c55fd69f436ead0cb5a0b7c6fdfef9bb28ddb9c63534eb619e756b118d5b08cfc5e696498650932c86e865b37e06633da947e6720ca0c27ed5c034313ae208b rsync-3.1.2.tar.gz
+638d87c9a753b35044f6321ccd09d2c0addaab3c52c40863eb6905905576b5268bec67b496df81225528c9e39fbd92e9225d7b3037ab1fda78508d452c78158f rsyncd.initd
+c7527e289c81bee5e4c14b890817cdb47d14f0d26dd8dcdcbe85c7199cf27c57a0b679bdd1b115bfe00de77b52709cc5d97522a47f63c1bb5104f4a7220c9961 rsyncd.confd
+3db8a2b364fc89132af6143af90513deb6be3a78c8180d47c969e33cb5edde9db88aad27758a6911f93781e3c9846aeadc80fffc761c355d6a28358853156b62 rsyncd.conf
+b8d6c0bb467a5c963317dc55478d2c10874564cd264d943d4a42037e2fce134fe001fabc92af5c6b5775e84dc310b1c8da147afaa61c99e5663c36580d8651a5 rsyncd.logrotate"
diff --git a/system/rsync/rsyncd.conf b/system/rsync/rsyncd.conf
new file mode 100644
index 000000000..6318016e9
--- /dev/null
+++ b/system/rsync/rsyncd.conf
@@ -0,0 +1,7 @@
+# /etc/rsyncd.conf
+# Minimal configuration file for rsync daemon.
+# See rsync(1) and rsyncd.conf(5) man pages for help.
+# Do not set "pid file" here.
+
+use chroot = yes
+read only = yes
diff --git a/system/rsync/rsyncd.confd b/system/rsync/rsyncd.confd
new file mode 100644
index 000000000..7128f97fd
--- /dev/null
+++ b/system/rsync/rsyncd.confd
@@ -0,0 +1,8 @@
+# Config file for /etc/init.d/rsyncd
+
+# Path to configuration file.
+#cfgfile="/etc/rsyncd.conf"
+
+# See man pages for rsync or run `rsync --daemon --help`
+# for valid cmdline options.
+#command_args=""
diff --git a/system/rsync/rsyncd.initd b/system/rsync/rsyncd.initd
new file mode 100644
index 000000000..eb05b3b59
--- /dev/null
+++ b/system/rsync/rsyncd.initd
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+
+: ${cfgfile:="/etc/rsyncd.conf"}
+
+command="/usr/bin/rsync"
+command_args="--daemon --no-detach --config=$cfgfile
+ $command_args $RSYNC_OPTS"
+command_background="yes"
+
+pidfile="/run/$RC_SVCNAME.pid"
+required_files="$cfgfile"
+
+depend() {
+ use net
+ after firewall
+}
diff --git a/system/rsync/rsyncd.logrotate b/system/rsync/rsyncd.logrotate
new file mode 100644
index 000000000..34bcf72d2
--- /dev/null
+++ b/system/rsync/rsyncd.logrotate
@@ -0,0 +1,9 @@
+/var/log/rsync.log {
+ compress
+ maxage 365
+ rotate 7
+ size=+1024k
+ notifempty
+ missingok
+ copytruncate
+}
diff --git a/system/sed/APKBUILD b/system/sed/APKBUILD
new file mode 100644
index 000000000..08fe6a55a
--- /dev/null
+++ b/system/sed/APKBUILD
@@ -0,0 +1,49 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=sed
+pkgver=4.4
+pkgrel=1
+subpackages="$pkgname-doc"
+pkgdesc="GNU stream editor"
+url="http://www.gnu.org/software/sed"
+arch="all"
+license="GPL"
+options="!checkroot"
+makedepends="perl"
+install="$pkgname.post-deinstall"
+source="http://ftp.gnu.org/pub/gnu/$pkgname/$pkgname-$pkgver.tar.xz
+ disable-mbrtowc-test.patch
+ localename-test-fix.patch
+ "
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --bindir=/bin \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --disable-i18n \
+ --disable-nls
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ rm -rf "$pkgdir"/usr/lib/charset.alias || true
+ rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
+}
+
+sha512sums="4e1b0a7403913f1e25047eb2292a0a9b3488b15b4463ce2803e05eaecbc2da19f477a18e6a70c992461c38ced90774415091aa2d8ce85cb74e391610d9eedb70 sed-4.4.tar.xz
+aeb55f85a5c724f0dacbf2f39e0f99ae4c66159115b00aa36d65f234f87e52e660878cb18b772a494349632dfa1b616b9306a4cafe87e91182ea8936c308506a disable-mbrtowc-test.patch
+3fbf7f5fbdef19f1212c4efad560b85e62744eecfe60eceaba1c8d093764f34bff844d31d704afdc064ca3d31bb7e46860a4b91e671b96930554a72953e88edf localename-test-fix.patch"
diff --git a/system/sed/disable-mbrtowc-test.patch b/system/sed/disable-mbrtowc-test.patch
new file mode 100644
index 000000000..51cdf3c25
--- /dev/null
+++ b/system/sed/disable-mbrtowc-test.patch
@@ -0,0 +1,10 @@
+--- sed-4.4/gnulib-tests/test-mbrtowc5.sh.old 2016-12-31 13:54:43.000000000 +0000
++++ sed-4.4/gnulib-tests/test-mbrtowc5.sh 2017-07-30 17:29:50.879924130 +0000
+@@ -1,6 +1,2 @@
+ #!/bin/sh
+-# Test whether the POSIX locale has encoding errors.
+-LC_ALL=C \
+-./test-mbrtowc${EXEEXT} 5 || exit
+-LC_ALL=POSIX \
+-./test-mbrtowc${EXEEXT} 5
++exit 77
diff --git a/system/sed/localename-test-fix.patch b/system/sed/localename-test-fix.patch
new file mode 100644
index 000000000..8a5d68dde
--- /dev/null
+++ b/system/sed/localename-test-fix.patch
@@ -0,0 +1,34 @@
+--- sed-4.4/gnulib-tests/localename.c.old 2016-12-31 13:54:43.000000000 +0000
++++ sed-4.4/gnulib-tests/localename.c 2017-07-30 16:40:47.098541270 +0000
+@@ -40,7 +40,7 @@
+ # if defined __APPLE__ && defined __MACH__
+ # include <xlocale.h>
+ # endif
+-# if __GLIBC__ >= 2 && !defined __UCLIBC__
++# if defined __linux__
+ # include <langinfo.h>
+ # endif
+ # if !defined IN_LIBINTL
+@@ -2692,16 +2692,19 @@
+ locale_t thread_locale = uselocale (NULL);
+ if (thread_locale != LC_GLOBAL_LOCALE)
+ {
+-# if __GLIBC__ >= 2 && !defined __UCLIBC__
++# if defined(_NL_LOCALE_NAME)
++ const char *name = nl_langinfo(_NL_LOCALE_NAME(category));
++# if __GLIBC__ >= 2 && !defined __UCLIBC__
+ /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
+ glibc < 2.12.
+ See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
+- const char *name =
+- nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
++ if (name[0] == '\0')
++ name = nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
+ if (name[0] == '\0')
+ /* Fallback code for glibc < 2.4, which did not implement
+ nl_langinfo (_NL_LOCALE_NAME (category)). */
+ name = thread_locale->__names[category];
++# endif
+ return name;
+ # elif defined __FreeBSD__ || (defined __APPLE__ && defined __MACH__)
+ /* FreeBSD, Mac OS X */
diff --git a/system/sed/sed.post-deinstall b/system/sed/sed.post-deinstall
new file mode 100644
index 000000000..5ec0031a4
--- /dev/null
+++ b/system/sed/sed.post-deinstall
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# we cannot rely on the busybox trigger since sed might be used from install
+# scripts
+
+[ -x /bin/busybox ] && exec /bin/busybox --install -s
diff --git a/system/snappy/APKBUILD b/system/snappy/APKBUILD
new file mode 100644
index 000000000..588164d55
--- /dev/null
+++ b/system/snappy/APKBUILD
@@ -0,0 +1,43 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=snappy
+pkgver=1.1.7
+pkgrel=0
+pkgdesc="Fast compression and decompression library"
+url="http://google.github.io/snappy/"
+arch="all"
+license="BSD-3-Clause"
+subpackages="$pkgname-dbg $pkgname-dev"
+source="snappy-$pkgver.tar.gz::https://github.com/google/snappy/archive/$pkgver.tar.gz
+ "
+[ "$CARCH" = "armhf" ] && options="!check" # does not pass testsuite on armhf
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ if [ "$CBUILD" != "$CHOST" ]; then
+ CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
+ fi
+ cmake \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DBUILD_SHARED_LIBS=True \
+ -DCMAKE_BUILD_TYPE=RelWithDebugInfo \
+ -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
+ -DCMAKE_C_FLAGS="$CFLAGS" \
+ ${CMAKE_CROSSOPTS}
+ make
+}
+
+check() {
+ cd "$builddir"
+ CTEST_OUTPUT_ON_FAILURE=TRUE ctest
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="32046f532606ba545a4e4825c0c66a19be449f2ca2ff760a6fa170a3603731479a7deadb683546e5f8b5033414c50f4a9a29f6d23b7a41f047e566e69eca7caf snappy-1.1.7.tar.gz"
diff --git a/system/ssmtp/APKBUILD b/system/ssmtp/APKBUILD
new file mode 100644
index 000000000..b7ae28bc7
--- /dev/null
+++ b/system/ssmtp/APKBUILD
@@ -0,0 +1,52 @@
+# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+
+pkgname=ssmtp
+pkgver=2.64
+pkgrel=11
+pkgdesc="Extremely simple MTA to get mail off the system to a mail hub"
+subpackages="$pkgname-doc"
+arch="all"
+url="https://packages.debian.org/stable/mail/ssmtp"
+license="GPL2"
+depends=
+makedepends="openssl-dev autoconf"
+options="!check"
+provides="/usr/sbin/sendmail"
+source="http://ftp.debian.org/debian/pool/main/s/$pkgname/${pkgname}_${pkgver}.orig.tar.bz2
+ generate_config.patch
+ libcrypto-underlinking.patch
+ inet6-getaddrinfo.patch
+ "
+_builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$_builddir"
+ sed -i -e 's:$(CC) -o:$(CC) @LDFLAGS@ -o:' Makefile.in
+ autoconf
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --mandir=/usr/share/man \
+ --sysconfdir=/etc \
+ --enable-ssl \
+ --enable-inet6 \
+ || return 1
+ make
+}
+
+package() {
+ cd "$srcdir"/$pkgname-$pkgver
+ make prefix="$pkgdir"/usr \
+ etcdir="$pkgdir"/etc \
+ mandir="$pkgdir"/usr/share/man \
+ install
+ ln -s ssmtp "$pkgdir"/usr/sbin/sendmail
+}
+
+sha512sums="911752e744420adf58552b9cf3a6e558d8b39103e5ad33a9ed4429b9a3a2091f7674aac11fe9bbd66747a61cdabe6bd638b80efcaadc86b057c12e2e235cca72 ssmtp_2.64.orig.tar.bz2
+a4273d7c5b50984994b35de052c450a872f0014c45c1d3bfe36f2edd4f224281aacea234be61c6e966da2c4d3e033042628b79b2216340001487e6bb3a55b6cd generate_config.patch
+9da89ec5ea66dae8b7a22ffcf196c45005c0403e6505162dba05003feac38eb397f8aff4f140d720f826ea057f92e47302ec3c24bddf5786c10b214ec906e82f libcrypto-underlinking.patch
+92dc128b2f6ce234843e8f1e6ddb72653825652544cd68f693457b3fdc4ee22b0f9861feec0dfd123d012c294c7083dd8d24a9a589a3c2ae5bcdde697d30a290 inet6-getaddrinfo.patch"
diff --git a/system/ssmtp/generate_config.patch b/system/ssmtp/generate_config.patch
new file mode 100644
index 000000000..23285b193
--- /dev/null
+++ b/system/ssmtp/generate_config.patch
@@ -0,0 +1,49 @@
+--- ./generate_config 2004-07-23 05:58:48.000000000 +0000
++++ ./generate_config 2009-01-27 10:09:11.000000000 +0000
+@@ -4,7 +4,7 @@
+ # Figure out the system's mailname
+ #
+
+-syshostname=`hostname --fqdn`
++syshostname="localhost"
+ if test -f /etc/mailname
+ then
+ mailname="`head -1 /etc/mailname`"
+@@ -15,23 +15,7 @@
+ mailname=$syshostname
+ fi
+
+-echo "Please enter the mail name of your system."
+-echo "This is the hostname portion of the address to be shown"
+-echo "on outgoing news and mail messages headers."
+-echo "The default is $syshostname, your system's host name."
+-echo
+-echo -n "Mail name [$syshostname]: "
+-read mailname
+-echo
+-
+-echo -n "Please enter the SMTP port number [25]: "
+-read smtpport
+-if test -z "$smtpport"
+-then
+- mailhub=$mailhub
+-else
+- mailhub="$mailhub:$smtpport"
+-fi
++mailhub="$mailhub:$smtpport"
+
+ #
+ # Generate configuration file
+@@ -56,11 +40,5 @@
+ # Where will the mail seem to come from?
+ #rewriteDomain=`echo -n $mailname`
+ # The full hostname
+-hostname=`hostname --fqdn`
++#hostname="localhost"
+ EOF
+-
+-echo
+-echo
+-echo "Please check the configuration file $1 for correctness."
+-echo
+-echo
diff --git a/system/ssmtp/inet6-getaddrinfo.patch b/system/ssmtp/inet6-getaddrinfo.patch
new file mode 100644
index 000000000..bbc2d90ba
--- /dev/null
+++ b/system/ssmtp/inet6-getaddrinfo.patch
@@ -0,0 +1,12 @@
+diff -up ssmtp.orig/ssmtp.c ssmtp/ssmtp.c
+--- ssmtp.orig/ssmtp.c 2009-11-23 10:55:11.000000000 +0100
++++ ssmtp/ssmtp.c 2015-07-27 17:34:12.498140804 +0200
+@@ -1157,7 +1157,7 @@ int smtp_open(char *host, int port)
+ snprintf(servname, sizeof(servname), "%d", port);
+
+ /* Check we can reach the host */
+- if (getaddrinfo(host, servname, &hints, &ai0)) {
++ if (getaddrinfo(host, servname, &hints, &ai0) != 0) {
+ log_event(LOG_ERR, "Unable to locate %s", host);
+ return(-1);
+ }
diff --git a/system/ssmtp/libcrypto-underlinking.patch b/system/ssmtp/libcrypto-underlinking.patch
new file mode 100644
index 000000000..4928f271c
--- /dev/null
+++ b/system/ssmtp/libcrypto-underlinking.patch
@@ -0,0 +1,11 @@
+--- ./configure.in.orig
++++ ./configure.in
+@@ -52,7 +52,7 @@
+ [ --enable-ssl support for secure connection to mail server])
+ if test x$enableval = xyes ; then
+ AC_DEFINE(HAVE_SSL)
+- LIBS="$LIBS -lssl"
++ LIBS="$LIBS -lssl -lcrypto"
+ fi
+ enableval=""
+
diff --git a/system/strace/APKBUILD b/system/strace/APKBUILD
new file mode 100644
index 000000000..aecde405f
--- /dev/null
+++ b/system/strace/APKBUILD
@@ -0,0 +1,65 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=strace
+pkgver=4.19
+pkgrel=0
+pkgdesc="A useful diagnositic, instructional, and debugging tool"
+url="https://strace.io/"
+arch="all"
+license="BSD"
+depends=""
+makedepends="linux-headers autoconf automake"
+subpackages="$pkgname-doc"
+options="!checkroot"
+source="$pkgname-$pkgver.tar.gz::https://github.com/strace/$pkgname/archive/v$pkgver.tar.gz
+ disable-fortify.patch
+ fix-ppc-pt-regs-collision.patch
+ nlattr-fix.patch
+ "
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ case "$CLIBC" in
+ musl) export CFLAGS="$CFLAGS -Dsigcontext_struct=sigcontext" ;;
+ esac
+
+ case "$CARCH" in
+ s390x)
+ # __SIGNAL_FRAMESIZE is defined in asm/sigcontext.h
+ # but including it would make conflict with struct sigcontext
+ # since we compile with it in musl.
+ # Temporarily add this until musl upstream has a proper fix
+ # for struct sigcontext.
+ export CFLAGS="$CFLAGS -D__SIGNAL_FRAMESIZE=160"
+ ;;
+ esac
+
+ ./bootstrap
+
+ ac_cv_have_long_long_off_t=yes \
+ st_cv_m32_mpers=no \
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make -j1 DESTDIR="$pkgdir" install
+}
+
+sha512sums="fbf953d64b43785648e2df0eb6beee409c6b6f6c6a4d227b54c02a049031c5ff3a3a6af52a68a2980d89eb06dcafc36be5f8784728e9a28348145cdb4a7764f9 strace-4.19.tar.gz
+273b92ebf0069f19bef7ec26c7860e2af7ef01e782255c70ded1ae5e967f8f6bf031ecba96612c6083bf58f46278ba4ab3ec0fb35b08c8c8d668191f97adee52 disable-fortify.patch
+b70cee89dd49a2b5a69dc2a56c3a11169d3306e1a73981155188b574486965c034aa52b4ac1c6edff5ef55c9d52f27750acb242fac095a8a9f69689b51b3fad1 fix-ppc-pt-regs-collision.patch
+44b1872cf996caa4970fa6c2875a3a2cffe4a38455e328d968bd7855ef9a05cf41190794dc137bc8667576635f5271057cf0e6cde9a6c7aee66afd1dba9bdba0 nlattr-fix.patch"
diff --git a/system/strace/disable-fortify.patch b/system/strace/disable-fortify.patch
new file mode 100644
index 000000000..26b2978c5
--- /dev/null
+++ b/system/strace/disable-fortify.patch
@@ -0,0 +1,39 @@
+Subject: [PATCH] don't use fortify-headers on netlink test sources
+From: A. Wilcox <AWilcox@Wilcox-Tech.com>
+
+We can't use fortify-headers on netlink tests because it tests what happens
+when a buffer overrun occurs.
+
+--- strace-4.18/tests/netlink_protocol.c.old 2017-07-05 07:08:09.000000000 +0000
++++ strace-4.18/tests/netlink_protocol.c 2017-08-17 01:09:45.822502012 +0000
+@@ -28,6 +28,8 @@
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
++#define _FORTIFY_SOURCE 0
++
+ #include "tests.h"
+
+ #ifdef HAVE_SYS_XATTR_H
+--- strace-4.18/tests/netlink_sock_diag.c.old 2017-07-05 07:08:09.000000000 +0000
++++ strace-4.18/tests/netlink_sock_diag.c 2017-08-17 01:10:00.935807300 +0000
+@@ -27,6 +27,8 @@
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
++#define _FORTIFY_SOURCE 0
++
+ #include "tests.h"
+ #include <stdio.h>
+ #include <string.h>
+--- strace-4.18/tests/nlattr.c.old 2017-07-05 07:08:09.000000000 +0000
++++ strace-4.18/tests/nlattr.c 2017-08-17 01:10:11.862453682 +0000
+@@ -28,6 +28,8 @@
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
++#define _FORTIFY_SOURCE 0
++
+ #include "tests.h"
+
+ #include <stdio.h>
diff --git a/system/strace/fix-ppc-pt-regs-collision.patch b/system/strace/fix-ppc-pt-regs-collision.patch
new file mode 100644
index 000000000..6de0fcdd6
--- /dev/null
+++ b/system/strace/fix-ppc-pt-regs-collision.patch
@@ -0,0 +1,19 @@
+--- a/ptrace.h
++++ b/ptrace.h
+@@ -48,7 +48,15 @@
+ # define ptrace_peeksiginfo_args XXX_ptrace_peeksiginfo_args
+ #endif
+
+-#include <linux/ptrace.h>
++#if defined(__powerpc__) || defined(__powerpc64__)
++# include <linux/types.h>
++# define __ASSEMBLY__
++# include <linux/ptrace.h>
++# undef __ASSEMBLY__
++#else
++# include <linux/ptrace.h>
++#endif
++
+
+ #ifdef HAVE_STRUCT_IA64_FPREG
+ # undef ia64_fpreg
diff --git a/system/strace/nlattr-fix.patch b/system/strace/nlattr-fix.patch
new file mode 100644
index 000000000..6d480fabb
--- /dev/null
+++ b/system/strace/nlattr-fix.patch
@@ -0,0 +1,21 @@
+--- strace-4.18/tests/nlattr.c.old 2017-07-05 07:08:09.000000000 +0000
++++ strace-4.18/tests/nlattr.c 2017-08-17 00:25:26.734218699 +0000
+@@ -61,7 +61,7 @@
+ };
+ struct msg *msg;
+ struct nlattr *nla;
+- unsigned int msg_len;
++ uint32_t msg_len;
+ long rc;
+
+ /* fetch fail: len < sizeof(struct nlattr) */
+@@ -259,7 +259,7 @@
+ };
+ struct msg *msg;
+ struct nlattr *nla;
+- unsigned int msg_len;
++ uint32_t msg_len;
+ long rc;
+
+ msg_len = NLMSG_SPACE(sizeof(msg->udm)) + sizeof(*nla);
+
diff --git a/system/tzdata/0001-posixtz-fix-up-lseek.patch b/system/tzdata/0001-posixtz-fix-up-lseek.patch
new file mode 100644
index 000000000..4bf164fec
--- /dev/null
+++ b/system/tzdata/0001-posixtz-fix-up-lseek.patch
@@ -0,0 +1,27 @@
+From 5c4cd3cee03428636e8d7cc4ed644389a4d598b3 Mon Sep 17 00:00:00 2001
+From: William Pitcock <nenolod@dereferenced.org>
+Date: Thu, 28 Apr 2011 02:56:42 -0500
+Subject: [PATCH] posixtz: ensure the file offset we pass to lseek is off_t
+
+on 32-bit systems, sizeof(off_t) is 4, on 64-bit sizeof(off_t) is 8
+causing a word masking issue.
+---
+ posixtz.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/posixtz.c b/posixtz.c
+index cddcb3e..972ca31 100644
+--- a/posixtz-0.5/posixtz.c
++++ b/posixtz-0.5/posixtz.c
+@@ -36,7 +36,7 @@ char *posix_tz(const char *filename)
+ if (r != TZ_BUFLEN
+ || strncmp(buf, "TZif", 4) != 0
+ || (unsigned char)buf[4] < 2
+- || lseek(fd, -TZ_BUFLEN, SEEK_END) < 0
++ || lseek(fd, (off_t) -TZ_BUFLEN, SEEK_END) < 0
+ )
+ goto ERROR;
+
+--
+1.7.4.5
+
diff --git a/system/tzdata/APKBUILD b/system/tzdata/APKBUILD
new file mode 100644
index 000000000..e4ff75efd
--- /dev/null
+++ b/system/tzdata/APKBUILD
@@ -0,0 +1,66 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=tzdata
+pkgver=2017c
+_tzcodever=2017c
+_ptzver=0.5
+pkgrel=1
+pkgdesc="Timezone data"
+url="https://www.iana.org/time-zones"
+arch="all"
+license="Public Domain"
+depends=""
+depends_dev=""
+makedepends=""
+checkdepends="sp"
+install=""
+subpackages="$pkgname-doc"
+source="http://www.iana.org/time-zones/repository/releases/tzcode$_tzcodever.tar.gz
+ http://www.iana.org/time-zones/repository/releases/tzdata$pkgver.tar.gz
+ http://dev.alpinelinux.org/archive/posixtz/posixtz-$_ptzver.tar.xz
+ 0001-posixtz-fix-up-lseek.patch"
+
+builddir="$srcdir"
+_timezones="africa antarctica asia australasia europe northamerica \
+ southamerica pacificnew etcetera backward systemv factory"
+
+build() {
+ cd "$builddir"
+ make cc="${CC:-gcc}" CFLAGS="$CFLAGS -DHAVE_STDINT_H=1"
+ TZDIR="/usr/share/zoneinfo"
+
+ cd "$builddir"/posixtz-$_ptzver
+ make posixtz
+}
+
+check() {
+ cd "$builddir"
+ make -j1 check
+}
+
+package() {
+ cd "$builddir"
+
+ ./zic -y ./yearistype -d "$pkgdir"/usr/share/zoneinfo ${_timezones}
+ ./zic -y ./yearistype -d "$pkgdir"/usr/share/zoneinfo/right -L leapseconds ${_timezones}
+ #./zic -y ./yearistype -d "$pkgdir"/usr/share/zoneinfo/posix ${_timezones}
+
+ ./zic -y ./yearistype -d "$pkgdir"/usr/share/zoneinfo -p America/New_York
+ install -m444 -t "$pkgdir"/usr/share/zoneinfo iso3166.tab zone1970.tab zone.tab
+
+ mkdir -p "$pkgdir"/usr/sbin
+ install -m755 zic zdump "$pkgdir"/usr/sbin
+
+ mkdir -p "$pkgdir"/usr/share/man/man8
+ install -m644 zic.8 zdump.8 "$pkgdir"/usr/share/man/man8
+
+ rm -f "$pkgdir"/usr/share/zoneinfo/localtime
+ install -Dm755 "$srcdir"/posixtz-$_ptzver/posixtz \
+ "$pkgdir"/usr/bin/posixtz
+}
+
+sha512sums="0d8c3e07b0de9015a137602450468ceb6358312a50eeda2a860882367107b8ba9ef275880b292570a671b9910afc54e6209e1e642387d246bc9c08c4ff660ffb tzcode2017c.tar.gz
+feb5c544e617b30c73a397e5a1c51f9847d0fddf1dfa0f9ace2e6f686786f09b666937b2048e07075c84593fc584bd5a25d639fce70eca9735267df28621ab4c tzdata2017c.tar.gz
+68dbaab9f4aef166ac2f2d40b49366527b840bebe17a47599fe38345835e4adb8a767910745ece9c384b57af815a871243c3e261a29f41d71f8054df3061b3fd posixtz-0.5.tar.xz
+f54ce213d74c5a8387e1a7c56299bc6eee65a035772288222128abc249a112067b8791b88b45c342b2d4d8d12e9e4f1f2f5c92c5de67f8b6413b1ebf1d7de467 0001-posixtz-fix-up-lseek.patch"
diff --git a/system/upower/APKBUILD b/system/upower/APKBUILD
new file mode 100644
index 000000000..9c596f3e0
--- /dev/null
+++ b/system/upower/APKBUILD
@@ -0,0 +1,40 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=upower
+pkgver=0.99.6
+pkgrel=0
+pkgdesc="Power Management Services"
+url="http://upower.freedesktop.org"
+arch="all"
+license="GPL2+"
+depends=""
+subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
+makedepends="linux-headers gtk+-dev libgudev-dev libusb-dev polkit-dev
+ dbus-glib-dev libxslt gobject-introspection-dev docbook-xsl"
+source="http://upower.freedesktop.org/releases/upower-$pkgver.tar.xz
+ "
+
+builddir="$srcdir"/$pkgname-$pkgver
+build() {
+ cd "$builddir"
+ DATADIRNAME=share ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --libexecdir=/usr/lib/upower \
+ --disable-static
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="7e7256491ecb5d3f04abf41f05a761b79761c8868a1aedadfc5085c3b9cf15f6099c1494596e6a24b0951511bc7cac074e93ebb2b84abb9fb7a4374483052d3f upower-0.99.6.tar.xz"
diff --git a/system/upower/daemon-fix-get_critical_action.patch b/system/upower/daemon-fix-get_critical_action.patch
new file mode 100644
index 000000000..6afe9b7a9
--- /dev/null
+++ b/system/upower/daemon-fix-get_critical_action.patch
@@ -0,0 +1,28 @@
+From 28cee8e2845b094488c337c4ecfa84ada0b6be60 Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martin.pitt@ubuntu.com>
+Date: Tue, 23 Feb 2016 09:51:07 +0100
+Subject: daemon: fix get_critical_action()
+
+Fix copy&paste error from e7e9156f that called the wrong _complete_ function
+for up_daemon_get_critical_action().
+
+https://bugs.freedesktop.org/show_bug.cgi?id=94262
+
+diff --git a/src/up-daemon.c b/src/up-daemon.c
+index be14cbe..e95f904 100644
+--- a/src/up-daemon.c
++++ b/src/up-daemon.c
+@@ -435,8 +435,8 @@ up_daemon_get_critical_action (UpExportedDaemon *skeleton,
+ GDBusMethodInvocation *invocation,
+ UpDaemon *daemon)
+ {
+- up_exported_daemon_complete_get_display_device (skeleton, invocation,
+- up_backend_get_critical_action (daemon->priv->backend));
++ up_exported_daemon_complete_get_critical_action (skeleton, invocation,
++ up_backend_get_critical_action (daemon->priv->backend));
+ return TRUE;
+ }
+
+--
+cgit v0.10.2
+
diff --git a/system/upower/lib-add-propererror-and-cancellable-handling-to-UpClient.patch b/system/upower/lib-add-propererror-and-cancellable-handling-to-UpClient.patch
new file mode 100644
index 000000000..47e2f4799
--- /dev/null
+++ b/system/upower/lib-add-propererror-and-cancellable-handling-to-UpClient.patch
@@ -0,0 +1,184 @@
+From 932a6a39e35754be571e1274aec4730fd42dba13 Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martin.pitt@ubuntu.com>
+Date: Wed, 18 May 2016 09:22:43 +0200
+Subject: lib: Add proper error and cancellable handling to UpClient
+ constructor
+
+A GObject's _init() should never fail or block, but this is currently the case
+as up_client_init() connects to upowerd on D-Bus. Convert this to the GInitable
+interface and provide a new constructor up_client_new_full() which accepts a
+GCancellable and GError, so that clients can do proper error handling
+and reporting.
+
+This changes up_client_new() to return NULL when connecting to upowerd fails.
+This provides a more well-defined behaviour in this case as clients can check
+for this and our methods stop segfaulting as they have checks like
+
+ g_return_val_if_fail (UP_IS_CLIENT (client), ...)
+
+Previously we returned a valid object, but trying to call any method on it
+segfaulted due to the NULL D-Bus proxy, so client code had no chance to check
+whether the UpClient object was really valid.
+
+https://bugs.freedesktop.org/show_bug.cgi?id=95350
+
+diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
+index 5b2218f..adc0b9b 100644
+--- a/libupower-glib/up-client.c
++++ b/libupower-glib/up-client.c
+@@ -39,9 +39,10 @@
+ #include "up-daemon-generated.h"
+ #include "up-device.h"
+
+-static void up_client_class_init (UpClientClass *klass);
+-static void up_client_init (UpClient *client);
+-static void up_client_finalize (GObject *object);
++static void up_client_class_init (UpClientClass *klass);
++static void up_client_initable_iface_init (GInitableIface *iface);
++static void up_client_init (UpClient *client);
++static void up_client_finalize (GObject *object);
+
+ #define UP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_CLIENT, UpClientPrivate))
+
+@@ -73,7 +74,8 @@ enum {
+ static guint signals [UP_CLIENT_LAST_SIGNAL] = { 0 };
+ static gpointer up_client_object = NULL;
+
+-G_DEFINE_TYPE (UpClient, up_client, G_TYPE_OBJECT)
++G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT,
++ G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, up_client_initable_iface_init))
+
+ /**
+ * up_client_get_devices:
+@@ -434,11 +436,10 @@ up_client_class_init (UpClientClass *klass)
+ * up_client_init:
+ * @client: This class instance
+ */
+-static void
+-up_client_init (UpClient *client)
++static gboolean
++up_client_initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
+ {
+- GError *error = NULL;
+-
++ UpClient *client = UP_CLIENT (initable);
+ client->priv = UP_CLIENT_GET_PRIVATE (client);
+
+ /* connect to main interface */
+@@ -446,13 +447,10 @@ up_client_init (UpClient *client)
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+- NULL,
+- &error);
+- if (client->priv->proxy == NULL) {
+- g_warning ("Couldn't connect to proxy: %s", error->message);
+- g_error_free (error);
+- return;
+- }
++ cancellable,
++ error);
++ if (client->priv->proxy == NULL)
++ return FALSE;
+
+ /* all callbacks */
+ g_signal_connect (client->priv->proxy, "device-added",
+@@ -461,6 +459,23 @@ up_client_init (UpClient *client)
+ G_CALLBACK (up_device_removed_cb), client);
+ g_signal_connect (client->priv->proxy, "notify",
+ G_CALLBACK (up_client_notify_cb), client);
++
++ return TRUE;
++}
++
++static void
++up_client_initable_iface_init (GInitableIface *iface)
++{
++ iface->init = up_client_initable_init;
++}
++
++/*
++ * up_client_init:
++ * @client: This class instance
++ */
++static void
++up_client_init (UpClient *client)
++{
+ }
+
+ /*
+@@ -482,23 +497,52 @@ up_client_finalize (GObject *object)
+ }
+
+ /**
+- * up_client_new:
++ * up_client_new_full:
++ * @cancellable: (allow-none): A #GCancellable or %NULL.
++ * @error: Return location for error or %NULL.
+ *
+- * Creates a new #UpClient object.
++ * Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
++ % this returns %NULL and sets @error.
+ *
+- * Return value: a new UpClient object.
++ * Return value: a new UpClient object, or %NULL on failure.
+ *
+- * Since: 0.9.0
++ * Since: 0.99.5
+ **/
+ UpClient *
+-up_client_new (void)
++up_client_new_full (GCancellable *cancellable, GError **error)
+ {
+ if (up_client_object != NULL) {
+ g_object_ref (up_client_object);
+ } else {
+- up_client_object = g_object_new (UP_TYPE_CLIENT, NULL);
+- g_object_add_weak_pointer (up_client_object, &up_client_object);
++ up_client_object = g_initable_new (UP_TYPE_CLIENT, cancellable, error, NULL);
++ if (up_client_object)
++ g_object_add_weak_pointer (up_client_object, &up_client_object);
+ }
+ return UP_CLIENT (up_client_object);
+ }
+
++/**
++ * up_client_new:
++ *
++ * Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
++ * this returns %NULL and prints out a warning with the error message.
++ * Consider using up_client_new_full() instead which allows you to handle errors
++ * and cancelling long operations yourself.
++ *
++ * Return value: a new UpClient object, or %NULL on failure.
++ *
++ * Since: 0.9.0
++ **/
++UpClient *
++up_client_new (void)
++{
++ GError *error = NULL;
++ UpClient *client;
++ client = up_client_new_full (NULL, &error);
++ if (client == NULL) {
++ g_warning ("Couldn't connect to proxy: %s", error->message);
++ g_error_free (error);
++ }
++ return client;
++}
++
+diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h
+index 79c2d9e..5b9af3c 100644
+--- a/libupower-glib/up-client.h
++++ b/libupower-glib/up-client.h
+@@ -72,6 +72,7 @@ typedef struct
+ /* general */
+ GType up_client_get_type (void);
+ UpClient *up_client_new (void);
++UpClient *up_client_new_full (GCancellable *cancellable, GError **error);
+
+ /* sync versions */
+ UpDevice * up_client_get_display_device (UpClient *client);
+--
+cgit v0.10.2
+
diff --git a/system/valgrind/APKBUILD b/system/valgrind/APKBUILD
new file mode 100644
index 000000000..c5371950d
--- /dev/null
+++ b/system/valgrind/APKBUILD
@@ -0,0 +1,76 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=valgrind
+pkgver=3.13.0
+pkgrel=0
+pkgdesc="A tool to help find memory-management problems in programs"
+url="http://valgrind.org/"
+arch="all"
+license="GPL-2.0-or-later"
+# it seems like busybox sed works but the configure script requires GNU sed
+makedepends="sed paxmark perl bash autoconf automake libtool"
+# from README_PACKAGERS:
+# Don't strip the debug info off lib/valgrind/$platform/vgpreload*.so
+# in the installation tree. Either Valgrind won't work at all, or it
+# will still work if you do, but will generate less helpful error
+# messages.
+options="!strip !check"
+subpackages="$pkgname-dev $pkgname-doc"
+source="ftp://sourceware.org/pub/$pkgname/$pkgname-$pkgver.tar.bz2
+ uclibc.patch
+ arm.patch
+ coregrind-elfv2.patch"
+# musl-fixes.patch
+builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ default_prepare
+ cd "$builddir"
+ aclocal && autoconf && automake --add-missing
+ echo '#include <linux/a.out.h>' > include/a.out.h
+}
+
+build() {
+ cd "$builddir"
+ # fails to build with ccache
+ export CC="gcc"
+ export CFLAGS="$CFLAGS -fno-stack-protector -no-pie"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --without-mpicc
+ make
+}
+
+check() {
+ cd "$buildir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ # we have options=!strip above so we strip the /usr/bin/* manually
+ if [ -z "$DEBUG" ]; then
+ strip "$pkgdir"/usr/bin/valgrind \
+ "$pkgdir"/usr/bin/valgrind-di-server \
+ "$pkgdir"/usr/bin/vgdb \
+ "$pkgdir"/usr/bin/valgrind-listener \
+ "$pkgdir"/usr/bin/cg_merge
+ fi
+
+ # pax causes some issues
+ # http://marc.info/?l=gentoo-hardened&m=119512627126298&w=2
+ # http://bugs.alpinelinux.org/issues/999
+ paxmark -m "$pkgdir"/usr/lib/valgrind/*-*-linux
+}
+
+sha512sums="34e1013cd3815d30a459b86220e871bb0a6209cc9e87af968f347083693779f022e986f211bdf1a5184ad7370cde12ff2cfca8099967ff94732970bd04a97009 valgrind-3.13.0.tar.bz2
+d59a10db9037e120df2ee94a103402ca95a79abee9d8be63e4e1bca29c82dca775cc402a79b854ec11a2160a4d2da202c237369418e221d1925267ea2613fd5d uclibc.patch
+9ee297d1b2b86891584443ad0caadc4977e1447979611ccf1cc55dbee61911b0b063bc4ad936d86c451cedae410cb3219b5a088b2ad0aa17df182d564fe36cfe arm.patch
+0f54b7b207870f495a0cf010b3091e2c0626bbf93b8a5ba7956b690981d4186de61f3e3b1fdc3aec2dfcacb69e712900f32c883a09dd4733c1e4569506272520 coregrind-elfv2.patch"
diff --git a/system/valgrind/arm.patch b/system/valgrind/arm.patch
new file mode 100644
index 000000000..8281c8ba1
--- /dev/null
+++ b/system/valgrind/arm.patch
@@ -0,0 +1,11 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -234,7 +234,7 @@
+ ARCH_MAX="s390x"
+ ;;
+
+- armv7*)
++ arm*)
+ AC_MSG_RESULT([ok (${host_cpu})])
+ ARCH_MAX="arm"
+ ;;
diff --git a/system/valgrind/coregrind-elfv2.patch b/system/valgrind/coregrind-elfv2.patch
new file mode 100644
index 000000000..7e4a2d636
--- /dev/null
+++ b/system/valgrind/coregrind-elfv2.patch
@@ -0,0 +1,443 @@
+The LE and BE code here is the same, except the BE has the old-style
+function descriptor. So, we use the LE code on ELFv2 to fix build errors.
+
+--- valgrind-3.13.0/coregrind/m_libcsetjmp.c 2017-05-31 10:14:45.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_libcsetjmp.c 2018-05-25 20:07:37.007835735 -0500
+@@ -149,7 +149,7 @@
+
+ /* ------------ ppc64-linux ------------ */
+
+-#if defined(VGP_ppc64be_linux)
++#if defined(VGP_ppc64be_linux) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
+
+ __asm__(
+ ".section \".toc\",\"aw\"" "\n"
+@@ -268,7 +268,8 @@
+ ".previous" "\n"
+ );
+
+-#elif defined(VGP_ppc64le_linux)
++#elif (defined(VGP_ppc64le_linux)) || \
++ (defined(VGP_ppc64be_linux) && defined(_CALL_ELF) && _CALL_ELF == 2)
+ __asm__(
+ ".section \".toc\",\"aw\"" "\n"
+
+--- valgrind-3.13.0/coregrind/m_main.c.old 2017-05-31 10:14:52.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_main.c 2018-05-30 19:01:00.534083618 -0500
+@@ -2585,7 +2585,7 @@
+ "\ttrap\n"
+ ".previous\n"
+ );
+-#elif defined(VGP_ppc64be_linux)
++#elif defined(VGP_ppc64be_linux) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
+ asm("\n"
+ /* PPC64 ELF ABI says '_start' points to a function descriptor.
+ So we must have one, and that is what goes into the .opd section. */
+@@ -2631,9 +2631,9 @@
+ "\tnop\n"
+ "\ttrap\n"
+ );
+-#elif defined(VGP_ppc64le_linux)
+-/* Little Endian uses ELF version 2 but in the future may also
+- * support other ELF versions.
++#elif defined(VGP_ppc64le_linux) || \
++ (defined(VGP_ppc64be_linux) && defined(_CALL_ELF) && _CALL_ELF == 2)
++/* PowerPC 64 ELF version 2 does not use function descriptors.
+ */
+ asm("\n"
+ "\t.align 2\n"
+--- valgrind-3.13.0/coregrind/m_syscall.c.old 2017-05-31 10:14:29.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_syscall.c 2018-05-30 19:02:00.984023769 -0500
+@@ -470,7 +470,7 @@
+ ".previous\n"
+ );
+
+-#elif defined(VGP_ppc64be_linux)
++#elif defined(VGP_ppc64be_linux) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
+ /* Due to the need to return 65 bits of result, this is completely
+ different from the ppc32 case. The single arg register points to a
+ 7-word block containing the syscall # and the 6 args. The syscall
+@@ -506,7 +506,8 @@
+ " blr\n"
+ );
+
+-#elif defined(VGP_ppc64le_linux)
++#elif defined(VGP_ppc64le_linux) || \
++ (defined(VGP_ppc64be_linux) && defined(_CALL_ELF) && _CALL_ELF == 2)
+ /* Due to the need to return 65 bits of result, this is completely
+ different from the ppc32 case. The single arg register points to a
+ 7-word block containing the syscall # and the 6 args. The syscall
+--- valgrind-3.13.0/coregrind/m_signals.c.old 2017-05-31 10:14:52.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_signals.c 2018-05-30 22:12:46.082692356 -0500
+@@ -889,7 +889,7 @@
+ " sc\n" \
+ ".previous\n"
+
+-#elif defined(VGP_ppc64be_linux)
++#elif defined(VGP_ppc64be_linux) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
+ # define _MY_SIGRETURN(name) \
+ ".align 2\n" \
+ ".globl my_sigreturn\n" \
+@@ -904,7 +904,8 @@
+ " li 0, " #name "\n" \
+ " sc\n"
+
+-#elif defined(VGP_ppc64le_linux)
++#elif defined(VGP_ppc64le_linux) || \
++ (defined(VGP_ppc64be_linux) && defined(_CALL_ELF) && _CALL_ELF == 2)
+ /* Little Endian supports ELF version 2. In the future, it may
+ * support other versions.
+ */
+--- valgrind-3.13.0/coregrind/m_syswrap/syswrap-ppc64-linux.c.old 2017-05-31 10:14:39.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_syswrap/syswrap-ppc64-linux.c 2018-05-30 22:15:42.112518074 -0500
+@@ -71,12 +71,12 @@
+ // r4 = retaddr
+ // r5 = function descriptor
+ // r6 = arg1
+-/* On PPC64, a func ptr is represented by a TOC entry ptr.
++/* On ELFv1, a func ptr is represented by a TOC entry ptr.
+ This TOC entry contains three words; the first word is the function
+ address, the second word is the TOC ptr (r2), and the third word is
+ the static chain value. */
+ asm(
+-#if defined(VGP_ppc64be_linux)
++#if defined(VGP_ppc64be_linux) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
+ " .align 2\n"
+ " .globl vgModuleLocal_call_on_new_stack_0_1\n"
+ " .section \".opd\",\"aw\"\n"
+@@ -126,7 +126,7 @@
+ " bctr\n\t" // jump to dst
+ " trap\n" // should never get here
+ #else
+-// ppc64le_linux
++// ppc64le_linux, or ELFv2 ABI on BE
+ " .align 2\n"
+ " .globl vgModuleLocal_call_on_new_stack_0_1\n"
+ "vgModuleLocal_call_on_new_stack_0_1:\n"
+@@ -211,7 +211,7 @@
+
+ // See priv_syswrap-linux.h for arg profile.
+ asm(
+-#if defined(VGP_ppc64be_linux)
++#if defined(VGP_ppc64be_linux) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
+ " .align 2\n"
+ " .globl do_syscall_clone_ppc64_linux\n"
+ " .section \".opd\",\"aw\"\n"
+--- valgrind-3.13.0/coregrind/m_syswrap/syscall-ppc64be-linux.S.old 2017-05-31 10:14:39.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_syswrap/syscall-ppc64be-linux.S 2018-05-30 22:18:31.742350130 -0500
+@@ -29,7 +29,7 @@
+
+ #include "pub_core_basics_asm.h"
+
+-#if defined(VGP_ppc64be_linux)
++#if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
+
+ #include "pub_core_vkiscnums_asm.h"
+ #include "libvex_guest_offsets.h"
+@@ -76,12 +76,25 @@
+
+ .align 2
+ .globl ML_(do_syscall_for_client_WRK)
++#if _CALL_ELF == 2
++.type .ML_(do_syscall_for_client_WRK),@function
++ML_(do_syscall_for_client_WRK):
++0: addis 2,12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry ML_(do_syscall_for_client_WRK), .-ML_(do_syscall_for_client_WRK)
++#else
+ .section ".opd","aw"
+ .align 3
+-ML_(do_syscall_for_client_WRK):
++ML_(do_syscall_for_client_WRK):
+ .quad .ML_(do_syscall_for_client_WRK),.TOC.@tocbase,0
+ .previous
+-.type .ML_(do_syscall_for_client_WRK),@function
++#endif
++#if _CALL_ELF == 2
++0: addis 2,12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry ML_(do_syscall_for_client_WRK), .-ML_(do_syscall_for_client_WRK)
++#endif
++.type .ML_(do_syscall_for_client_WRK),@function
+ .globl .ML_(do_syscall_for_client_WRK)
+ .ML_(do_syscall_for_client_WRK):
+ /* make a stack frame */
+@@ -145,7 +158,11 @@
+ /* failure: return 0x8000 | error code */
+ 7: ori 3,3,0x8000 /* FAILURE -- ensure return value is nonzero */
+ b 5b
+-
++#if _CALL_ELF == 2
++ .size .ML_(do_syscall_for_client_WRK),.-.ML_(do_syscall_for_client_WRK)
++#else
++ .size .ML_(do_syscall_for_client_WRK),.-.ML_(do_syscall_for_client_WRK)
++#endif
+ .section .rodata
+ /* export the ranges so that
+ VG_(fixup_guest_state_after_syscall_interrupted) can do the
+@@ -162,7 +179,7 @@
+ ML_(blksys_committed): .quad 4b
+ ML_(blksys_finished): .quad 5b
+
+-#endif // defined(VGP_ppc64be_linux)
++#endif // defined(VGP_ppc64le_linux)
+
+ /* Let the linker know we don't need an executable stack */
+ MARK_STACK_NO_EXEC
+--- valgrind-3.13.0/coregrind/m_dispatch/dispatch-ppc64be-linux.S.old 2017-05-31 10:14:33.000000000 -0500
++++ valgrind-3.13.0/coregrind/m_dispatch/dispatch-ppc64be-linux.S 2018-05-30 22:39:37.951096498 -0500
+@@ -30,12 +30,21 @@
+
+ #include "pub_core_basics_asm.h"
+
+-#if defined(VGP_ppc64be_linux)
++#if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
+
+ #include "pub_core_dispatch_asm.h"
+ #include "pub_core_transtab_asm.h"
+ #include "libvex_guest_offsets.h" /* for OFFSET_ppc64_CIA */
+
++/* NOTE: PPC64 supports Big Endian and Little Endian. It also supports the
++ ELF version 1 and ELF version 2 APIs.
++
++ Currently LE uses ELF version 2 and BE uses ELF version 1. However,
++ BE and LE may support the other ELF version in the future. So, the
++ _CALL_ELF is used in the assembly function to enable code for a
++ specific ELF version independently of the endianness of the machine.
++ The test "#if _CALL_ELF == 2" checks if ELF version 2 is being used.
++*/
+
+ /* References to globals via the TOC */
+
+@@ -75,14 +84,26 @@
+ .section ".text"
+ .align 2
+ .globl VG_(disp_run_translations)
++#if _CALL_ELF == 2
++.type VG_(disp_run_translations),@function
++VG_(disp_run_translations):
++.type .VG_(disp_run_translations),@function
++#else
+ .section ".opd","aw"
+ .align 3
+ VG_(disp_run_translations):
+ .quad .VG_(disp_run_translations),.TOC.@tocbase,0
+ .previous
+ .type .VG_(disp_run_translations),@function
++#endif
+ .globl .VG_(disp_run_translations)
+ .VG_(disp_run_translations):
++#if _CALL_ELF == 2
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry VG_(disp_run_translations), .-VG_(disp_run_translations)
++#endif
++
+ /* r3 holds two_words */
+ /* r4 holds guest_state */
+ /* r5 holds host_addr */
+@@ -229,8 +250,13 @@
+ /* make a stack frame for the code we are calling */
+ stdu 1,-48(1)
+
+- /* Set up the guest state ptr */
++ /* Set up the guest state ptr */
+ mr 31,4 /* r31 (generated code gsp) = r4 */
++#if _CALL_ELF == 2
++/* for the LE ABI need to setup r2 and r12 */
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++#endif
+
+ /* and jump into the code cache. Chained translations in
+ the code cache run, until for whatever reason, they can't
+@@ -385,6 +411,9 @@
+ mtlr 0
+ addi 1,1,624 /* stack_size */
+ blr
++#if _CALL_ELF == 2
++ .size VG_(disp_run_translations),.-VG_(disp_run_translations)
++#endif
+
+
+ /*----------------------------------------------------*/
+@@ -395,15 +424,25 @@
+ .section ".text"
+ .align 2
+ .globl VG_(disp_cp_chain_me_to_slowEP)
+- .section ".opd","aw"
++#if _CALL_ELF == 2
++ .type VG_(disp_cp_chain_me_to_slowEP),@function
++ VG_(disp_cp_chain_me_to_slowEP):
++#else
++ .section ".opd","aw"
+ .align 3
+ VG_(disp_cp_chain_me_to_slowEP):
+ .quad .VG_(disp_cp_chain_me_to_slowEP),.TOC.@tocbase,0
+ .previous
++#endif
+ .type .VG_(disp_cp_chain_me_to_slowEP),@function
+ .globl .VG_(disp_cp_chain_me_to_slowEP)
+ .VG_(disp_cp_chain_me_to_slowEP):
+- /* We got called. The return address indicates
++#if _CALL_ELF == 2
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry VG_(disp_cp_chain_me_to_slowEP), .-VG_(disp_cp_chain_me_to_slowEP)
++#endif
++ /* We got called. The return address indicates
+ where the patching needs to happen. Collect
+ the return address and, exit back to C land,
+ handing the caller the pair (Chain_me_S, RA) */
+@@ -415,20 +454,33 @@
+ */
+ subi 7,7,20+4+4
+ b .postamble
++#if _CALL_ELF == 2
++ .size VG_(disp_cp_chain_me_to_slowEP),.-VG_(disp_cp_chain_me_to_slowEP)
++#endif
+
+ /* ------ Chain me to fast entry point ------ */
+ .section ".text"
+ .align 2
+ .globl VG_(disp_cp_chain_me_to_fastEP)
+- .section ".opd","aw"
++#if _CALL_ELF == 2
++ .type VG_(disp_cp_chain_me_to_fastEP),@function
++VG_(disp_cp_chain_me_to_fastEP):
++#else
++ .section ".opd","aw"
+ .align 3
+ VG_(disp_cp_chain_me_to_fastEP):
+ .quad .VG_(disp_cp_chain_me_to_fastEP),.TOC.@tocbase,0
+ .previous
++#endif
+ .type .VG_(disp_cp_chain_me_to_fastEP),@function
+ .globl .VG_(disp_cp_chain_me_to_fastEP)
+ .VG_(disp_cp_chain_me_to_fastEP):
+- /* We got called. The return address indicates
++#if _CALL_ELF == 2
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry VG_(disp_cp_chain_me_to_fastEP), .-VG_(disp_cp_chain_me_to_fastEP)
++#endif
++ /* We got called. The return address indicates
+ where the patching needs to happen. Collect
+ the return address and, exit back to C land,
+ handing the caller the pair (Chain_me_S, RA) */
+@@ -440,20 +492,33 @@
+ */
+ subi 7,7,20+4+4
+ b .postamble
++#if _CALL_ELF == 2
++ .size VG_(disp_cp_chain_me_to_fastEP),.-VG_(disp_cp_chain_me_to_fastEP)
++#endif
+
+ /* ------ Indirect but boring jump ------ */
+ .section ".text"
+ .align 2
+ .globl VG_(disp_cp_xindir)
+- .section ".opd","aw"
++#if _CALL_ELF == 2
++ .type VG_(disp_cp_xindir),@function
++VG_(disp_cp_xindir):
++#else
++ .section ".opd","aw"
+ .align 3
+ VG_(disp_cp_xindir):
+ .quad .VG_(disp_cp_xindir),.TOC.@tocbase,0
+ .previous
++#endif
+ .type .VG_(disp_cp_xindir),@function
+ .globl .VG_(disp_cp_xindir)
+ .VG_(disp_cp_xindir):
+- /* Where are we going? */
++#if _CALL_ELF == 2
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry VG_(disp_cp_xindir), .-VG_(disp_cp_xindir)
++#endif
++ /* Where are we going? */
+ ld 3,OFFSET_ppc64_CIA(31)
+
+ /* stats only */
+@@ -479,6 +544,9 @@
+ /* Found a match. Jump to .host. */
+ mtctr 7
+ bctr
++#if _CALL_ELF == 2
++ .size VG_(disp_cp_xindir),.-VG_(disp_cp_xindir)
++#endif
+
+ .fast_lookup_failed:
+ /* stats only */
+@@ -496,39 +564,64 @@
+ .section ".text"
+ .align 2
+ .globl VG_(disp_cp_xassisted)
+- .section ".opd","aw"
++#if _CALL_ELF == 2
++ .type VG_(disp_cp_xassisted),@function
++VG_(disp_cp_xassisted):
++#else
++ .section ".opd","aw"
+ .align 3
+ VG_(disp_cp_xassisted):
+ .quad .VG_(disp_cp_xassisted),.TOC.@tocbase,0
+ .previous
+- .type .VG_(disp_cp_xassisted),@function
++#endif
++#if _CALL_ELF == 2
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry VG_(disp_cp_xassisted), .-VG_(disp_cp_xassisted)
++#endif
++ .type .VG_(disp_cp_xassisted),@function
+ .globl .VG_(disp_cp_xassisted)
+ .VG_(disp_cp_xassisted):
+ /* r31 contains the TRC */
+ mr 6,31
+ li 7,0
+ b .postamble
++#if _CALL_ELF == 2
++ .size VG_(disp_cp_xassisted),.-VG_(disp_cp_xassisted)
++#endif
+
+ /* ------ Event check failed ------ */
+ .section ".text"
+ .align 2
+ .globl VG_(disp_cp_evcheck_fail)
+- .section ".opd","aw"
++#if _CALL_ELF == 2
++ .type VG_(disp_cp_evcheck_fail),@function
++VG_(disp_cp_evcheck_fail):
++#else
++ .section ".opd","aw"
+ .align 3
+ VG_(disp_cp_evcheck_fail):
+ .quad .VG_(disp_cp_evcheck_fail),.TOC.@tocbase,0
+ .previous
++#endif
++#if _CALL_ELF == 2
++0: addis 2, 12,.TOC.-0b@ha
++ addi 2,2,.TOC.-0b@l
++ .localentry VG_(disp_cp_evcheck_fail), .-VG_(disp_cp_evcheck_fail)
++#endif
+ .type .VG_(disp_cp_evcheck_fail),@function
+ .globl .VG_(disp_cp_evcheck_fail)
+ .VG_(disp_cp_evcheck_fail):
+ li 6,VG_TRC_INNER_COUNTERZERO
+ li 7,0
+ b .postamble
++#if _CALL_ELF == 2
++ .size VG_(disp_cp_evcheck_fail),.-VG_(disp_cp_evcheck_fail)
++#endif
+
+-
+ .size .VG_(disp_run_translations), .-.VG_(disp_run_translations)
+
+-#endif // defined(VGP_ppc64be_linux)
++#endif // defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
+
+ /* Let the linker know we don't need an executable stack */
+ MARK_STACK_NO_EXEC
diff --git a/system/valgrind/uclibc.patch b/system/valgrind/uclibc.patch
new file mode 100644
index 000000000..69281ab2c
--- /dev/null
+++ b/system/valgrind/uclibc.patch
@@ -0,0 +1,10 @@
+--- ./coregrind/vg_preloaded.c.orig
++++ ./coregrind/vg_preloaded.c
+@@ -42,6 +42,7 @@
+ originates from Valgrind.
+ ------------------------------------------------------------------ */
+
++#include <features.h>
+ #include "pub_core_basics.h"
+ #include "pub_core_clreq.h"
+ #include "pub_core_debuginfo.h" // Needed for pub_core_redir.h
diff --git a/system/wayland/APKBUILD b/system/wayland/APKBUILD
new file mode 100644
index 000000000..a25cc87a1
--- /dev/null
+++ b/system/wayland/APKBUILD
@@ -0,0 +1,59 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
+# Maintainer: Valery Kartel <valery.kartel@gmail.com>
+pkgname=wayland
+pkgver=1.14.0
+pkgrel=2
+pkgdesc="A computer display server protocol"
+url="http://wayland.freedesktop.org"
+arch=all
+license="MIT"
+depends="$pkgname-libs-client $pkgname-libs-cursor $pkgname-libs-server"
+depends_dev="libffi-dev expat-dev"
+makedepends="$depends_dev doxygen xmlto graphviz grep libxml2-dev bash"
+subpackages="$pkgname-dev $pkgname-libs-client:_libs
+ $pkgname-libs-cursor:_libs $pkgname-libs-server:_libs"
+source="http://wayland.freedesktop.org/releases/$pkgname-$pkgver.tar.xz"
+
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --disable-documentation \
+ --disable-static
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+}
+
+dev() {
+ mkdir -p "$subpkgdir"/usr
+ mv "$pkgdir"/usr/bin "$pkgdir"/usr/share \
+ "$subpkgdir"/usr
+ default_dev
+}
+
+_libs() {
+ local name=${subpkgname#$pkgname-libs-}
+ pkgdesc="$pkgdesc ($name library)"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/*-$name.so.* "$subpkgdir"/usr/lib
+}
+
+sha512sums="bd38b2b8963d4d98d42c270e5d7dbff6323789a173b19b67a18258424fd8adee5021b282c9d7f6dad0bd25aa0160e76aecd8ed803d4eb25d911ef0a81cd713a5 wayland-1.14.0.tar.xz"
diff --git a/system/weechat/APKBUILD b/system/weechat/APKBUILD
new file mode 100644
index 000000000..2fe4eb629
--- /dev/null
+++ b/system/weechat/APKBUILD
@@ -0,0 +1,66 @@
+# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
+pkgname=weechat
+pkgver=1.9.1
+pkgrel=1
+pkgdesc="A fast, light, extensible ncurses-based chat client"
+url="http://www.weechat.org"
+arch="all"
+license="GPL-3.0+"
+options="!check" # Requires itself until 2.0.
+depends_dev="cmake gettext-dev ncurses-dev gnutls-dev libgcrypt-dev curl-dev
+ aspell-dev guile-dev lua5.3-dev perl-dev python3-dev zlib-dev"
+makedepends="$depends_dev"
+checkdepends="cpputest"
+subpackages="$pkgname-dev $pkgname-aspell:_plugin $pkgname-lua:_plugin
+ $pkgname-perl:_plugin $pkgname-python:_plugin
+ $pkgname-guile:_plugin $pkgname-lang"
+source="http://www.weechat.org/files/src/$pkgname-$pkgver.tar.gz
+ fix-python-linking.patch
+ libintl-fix.patch"
+builddir="$srcdir/$pkgname-$pkgver"
+
+# secfixes:
+# 1.7.1-r0:
+# - CVE-2017-8073
+# 1.9.1-r0:
+# - CVE-2017-14727
+
+prepare() {
+ cd "$builddir"
+ default_prepare
+}
+
+build() {
+ cd "$builddir"
+ mkdir -p build
+ cd build
+ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_MAN=ON -DENABLE_TESTS=ON -DENABLE_PYTHON3=ON
+ make
+}
+
+package() {
+ cd "$builddir"/build
+ make DESTDIR="$pkgdir/" install
+}
+
+_plugin() {
+ local _name=${subpkgname#*-}
+ local _dir=usr/lib/weechat/plugins
+ pkgdesc="WeeChat $_name plugin"
+ depends="weechat"
+ if [ "$_name" = python ]; then
+ depends="$depends python3"
+ fi
+
+ mkdir -p "$subpkgdir"/$_dir
+ mv "$pkgdir"/$_dir/${_name}.so "$subpkgdir"/$_dir
+}
+
+check() {
+ cd "$builddir"/build
+ ctest -V
+}
+
+sha512sums="e52bb5239e24477ec38f2ad71cb2274e0ffc4226fc36ec00beeb7cf7e754a8c58d9bbc424cb0900e7c803ed47b0956e8f420eaa4cc9cf407ab6dd4769ec94326 weechat-1.9.1.tar.gz
+23b1e3fa9fcade74738d9013b533a0be01dbadabe8a7d82c97d338cdf3e4efe0943b9671f6ec47ac4838d3ad29ab4fd2ce0e6b3c74b4c7280abfd7b040407678 fix-python-linking.patch
+59841bc343b1d10a542631eb01380789f96cac896380dbb3b159444c4806bd6367952e457b9ffd42fb87c1e19fc77eba78c38fd2178ef202ab9f7f1a543417ca libintl-fix.patch"
diff --git a/system/weechat/fix-python-linking.patch b/system/weechat/fix-python-linking.patch
new file mode 100644
index 000000000..c94be8026
--- /dev/null
+++ b/system/weechat/fix-python-linking.patch
@@ -0,0 +1,11 @@
+--- weechat-1.9/cmake/FindPython.cmake.old 2017-06-25 03:20:52.000000000 -0500
++++ weechat-1.9/cmake/FindPython.cmake 2017-09-24 18:04:48.181662013 -0500
+@@ -67,7 +67,7 @@
+ )
+ if(ENABLE_PYTHON3)
+ find_library(PYTHON_LIBRARY
+- NAMES python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python2.7 python2.6 python2.5 python
++ NAMES python3.6m python3.6 python3.5m python3.5 python3.4m python3.4 python3.3 python3.2 python3.1 python3.0 python3 python2.7 python2.6 python2.5 python
+ HINTS ${PYTHON_POSSIBLE_LIB_PATH}
+ )
+ else()
diff --git a/system/weechat/libintl-fix.patch b/system/weechat/libintl-fix.patch
new file mode 100644
index 000000000..a67cb37b6
--- /dev/null
+++ b/system/weechat/libintl-fix.patch
@@ -0,0 +1,12 @@
+libc gettext is never sufficient on musl
+
+--- weechat-1.9/CMakeLists.txt.old 2017-06-25 03:20:52.000000000 -0500
++++ weechat-1.9/CMakeLists.txt 2017-09-13 02:30:43.577284569 -0500
+@@ -162,6 +162,7 @@
+ find_package(Gettext)
+ if(GETTEXT_FOUND)
+ add_definitions(-DENABLE_NLS)
++ list(APPEND EXTRA_LIBS intl)
+ endif()
+ endif()
+
diff --git a/system/wget/APKBUILD b/system/wget/APKBUILD
new file mode 100644
index 000000000..5f7093ea5
--- /dev/null
+++ b/system/wget/APKBUILD
@@ -0,0 +1,50 @@
+# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
+pkgname=wget
+pkgver=1.19.2
+pkgrel=1
+pkgdesc="A network utility to retrieve files from the Web"
+url="http://www.gnu.org/software/wget/wget.html"
+arch="all"
+license="GPL-3.0+"
+depends=""
+makedepends="openssl-dev perl gettext-dev"
+checkdepends="perl-http-daemon"
+subpackages="$pkgname-doc $pkgname-lang"
+install=""
+source="ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz "
+builddir="$srcdir/$pkgname-$pkgver"
+
+# secfixes:
+# 1.19.1-r1:
+# - CVE-2017-6508
+# 1.19.2-r0:
+# - CVE-2017-13090
+
+build() {
+ cd "$builddir"
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --with-ssl=openssl
+ make
+}
+
+check() {
+ cd "$builddir"
+ make check
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+
+ rm -rf "$pkgdir"/usr/lib
+}
+
+sha512sums="a0f8afcc0767a8fd1acd64b1b1b27d177bc938e70cc3709c1b3faa6c1426ec926642cd8e49d292cec0268ee507683539b5152072110106de5a728a03efd8cedd wget-1.19.2.tar.gz"
diff --git a/system/wpa_supplicant/APKBUILD b/system/wpa_supplicant/APKBUILD
new file mode 100644
index 000000000..7aebbef1f
--- /dev/null
+++ b/system/wpa_supplicant/APKBUILD
@@ -0,0 +1,104 @@
+# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=wpa_supplicant
+pkgver=2.6
+pkgrel=7
+pkgdesc="A utility providing key negotiation for WPA wireless networks"
+url="https://w1.fi/wpa_supplicant/"
+arch="all"
+license="BSD"
+subpackages="$pkgname-doc $pkgname-openrc"
+depends="dbus"
+makedepends="linux-headers openssl-dev dbus-dev libnl3-dev pcsc-lite-dev"
+source="http://w1.fi/releases/$pkgname-$pkgver.tar.gz
+ rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch
+ rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch
+ rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch
+ rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch
+ rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch
+ rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch
+ rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch
+ rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch
+
+ wpa_supplicant.initd
+ wpa_supplicant.confd
+ eloop.patch
+
+ config
+ wpa_cli.sh"
+
+# secfixes:
+# 2.6-r7:
+# - CVE-2017-13077
+# - CVE-2017-13078
+# - CVE-2017-13079
+# - CVE-2017-13080
+# - CVE-2017-13081
+# - CVE-2017-13082
+# - CVE-2017-13086
+# - CVE-2017-13087
+# - CVE-2017-13088
+
+builddir="$srcdir"/$pkgname-$pkgver
+prepare() {
+ cd "$builddir"
+ default_prepare
+
+ # Copy our configuration file to the build directory
+ cp "$srcdir"/config "$builddir"/wpa_supplicant/.config
+}
+
+build() {
+ cd "$builddir"/wpa_supplicant
+ make LIBDIR=/lib BINDIR=/sbin
+}
+
+check() {
+ cd "$builddir"/wpa_supplicant
+ make eapol_test
+}
+
+package() {
+ cd "$builddir"/wpa_supplicant
+ make DESTDIR="$pkgdir" LIBDIR=/lib BINDIR=/sbin install
+ install -Dm644 wpa_supplicant.conf \
+ "$pkgdir"/usr/share/doc/wpa_supplicant/examples/wpa_supplicant.conf
+ install -Dm755 "$srcdir"/wpa_cli.sh \
+ "$pkgdir"/etc/wpa_supplicant/wpa_cli.sh
+
+ local man=
+ for man in doc/docbook/*.?; do
+ install -Dm644 "$man" \
+ "$pkgdir"/usr/share/man/man${man##*.}/${man##*/}
+ done
+ install -Dm755 eapol_test "$pkgdir"/sbin/eapol_test
+
+ # dbus
+ cd dbus
+ install -d "$pkgdir"/etc/dbus-1/system.d
+ install -m644 dbus-wpa_supplicant.conf \
+ "$pkgdir"/etc/dbus-1/system.d/wpa_supplicant.conf
+ install -d "$pkgdir"/usr/share/dbus-1/system-services
+ install fi.epitest.hostap.WPASupplicant.service \
+ "$pkgdir"/usr/share/dbus-1/system-services
+ install -d "$pkgdir"/var/run/wpa_supplicant
+ install -Dm755 "$srcdir"/wpa_supplicant.initd \
+ "$pkgdir"/etc/init.d/wpa_supplicant
+ install -Dm644 "$srcdir"/wpa_supplicant.confd \
+ "$pkgdir"/etc/conf.d/wpa_supplicant
+}
+
+sha512sums="46442cddb6ca043b8b08d143908f149954c238e0f3a57a0df73ca4fab9c1acd91b078f3f26375a1d99cd1d65625986328018c735d8705882c8f91e389cad28a6 wpa_supplicant-2.6.tar.gz
+f855fa792425f175ccc800eb49df42067b1c1f4b52ba2d24160af4dfbb74dcf8e81661b7e6c8d92fa408938b8a559fc74557d1677913e4a751bfd43706c14bb6 rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch
+b4e413aa815572ea0002d33d24b69cd499aebb5efebed8fcaade8b29324bb5853a5db64e8b1dfdf24478e02c66196238b81a6ec777a7a28610435dce4d2c344e rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch
+a6382d8e84b4829be33c46bf2f4c6f3232c9d924a4547a21dfe023bf5be8ee1c635920295f52be285359efaae95bcc1f12b512659cfd1653b871dd0bea7e5ace rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch
+51ed806f0d5b3f588e26d4db4dcfc6be2cfb12002e26893a6cedd62c7cad0d0de75aed4a666223c4877fc1854b08dce6ddf6f6c4cfd752a5d8d58ad4a968b553 rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch
+8707a123cd78149dfee9f5bd791761ee1eca605ef96580167044c2339c896920cf0e030b184a5afa9e310f5755afb30bef8ebd4522fc52753f3fbd6acead2cdf rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch
+37d050b2e4a3598484912667d8b2705fbe84c5c562267f900d42b0c7b606fb1fed09ddca8b80e2131768baa8f3690aab6ba7a232dee6ff1e66150fdb8816c927 rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch
+111e655cfbb3a86e3792040e0ea375490d31c42c9d43cbe911290d54df5f4db437e4c8ad0e937c51729dcefeb0db0989b8ab55b9523398683abd08ebfec18076 rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch
+fc84edd8b30305cc42053c872554098f3f077292ec980ed6a442f37884087ff2f055738fd55977ed792bef1887dcc8c4626586465d78dd0258edb83dcd50a65a rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch
+11eed22f6e793f40c788d586c715deecae03c421d11761b7b4a376660bce812c54cc6f353c7d4d5da9c455aeffd778baefb9e76d380027a729574a756e54ddcc wpa_supplicant.initd
+29103161ec2b9631fca9e8d9a97fafd60ffac3fe78cf613b834395ddcaf8be1e253c22e060d7d9f9b974b2d7ce794caa932a2125e29f6494b75bce475f7b30e1 wpa_supplicant.confd
+2be055dd1f7da5a3d8e79c2f2c0220ddd31df309452da18f290144d2112d6dbde0fc633bb2ad02c386a39d7785323acaf5f70e5969995a1e8303a094eb5fe232 eloop.patch
+6707991f9a071f2fcb09d164d31d12b1f52b91fbb5574b70b8d6f9727f72bbe42b03dd66d10fcc2126f5b7e49ac785657dec90e88b4bf54a9aa5638582f6e505 config
+44d33cfe419cdb65cc14f2ac05aa9f8a1b9f2f432181e498071e41ef835662db1e4c5142adf4cfab2475e7b606696169936bd159d1d711f803322db93f242361 wpa_cli.sh"
diff --git a/system/wpa_supplicant/config b/system/wpa_supplicant/config
new file mode 100644
index 000000000..f35daa0d1
--- /dev/null
+++ b/system/wpa_supplicant/config
@@ -0,0 +1,550 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Driver interface for generic Linux wireless extensions
+# Note: WEXT is deprecated in the current Linux kernel version and no new
+# functionality is added to it. nl80211-based interface is the new
+# replacement for WEXT and its use allows wpa_supplicant to properly control
+# the driver to improve existing functionality like roaming and to support new
+# functionality.
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# QCA vendor extensions to nl80211
+#CONFIG_DRIVER_NL80211_QCA=y
+
+# driver_nl80211.c requires libnl. If you are compiling it yourself
+# you may need to point hostapd to your version of libnl.
+#
+#CFLAGS += -I$<path to libnl include files>
+#LIBS += -L$<path to libnl library files>
+
+# Use libnl v2.0 (or 3.0) libraries.
+#CONFIG_LIBNL20=y
+
+# Use libnl 3.2 libraries (if this is selected, CONFIG_LIBNL20 is ignored)
+CONFIG_LIBNL32=y
+
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Solaris libraries
+#LIBS += -lsocket -ldlpi -lnsl
+#LIBS_c += -lsocket
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: If OpenSSL is used as the TLS library, OpenSSL 1.0 or newer is needed
+# for EAP-FAST support. Older OpenSSL releases would need to be patched, e.g.,
+# with openssl-0.9.8x-tls-extensions.patch, to add the needed functions.
+CONFIG_EAP_FAST=y
+
+# EAP-GTC
+CONFIG_EAP_GTC=y
+
+# EAP-OTP
+CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+CONFIG_EAP_PSK=y
+
+# EAP-pwd (secure authentication using only a password)
+#CONFIG_EAP_PWD=y
+
+# EAP-PAX
+CONFIG_EAP_PAX=y
+
+# LEAP
+CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+# Enable WPS external registrar functionality
+#CONFIG_WPS_ER=y
+# Disable credentials for an open network by default when acting as a WPS
+# registrar.
+#CONFIG_WPS_REG_DISABLE_OPEN=y
+# Enable WPS support with NFC config method
+#CONFIG_WPS_NFC=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# EAP-EKE
+#CONFIG_EAP_EKE=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+CONFIG_PCSC=y
+
+# Support HT overrides (disable HT/HT40, mask MCS rates, etc.)
+#CONFIG_HT_OVERRIDES=y
+
+# Support VHT overrides (disable VHT, mask MCS rates, etc.)
+#CONFIG_VHT_OVERRIDES=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# udp6 = UDP IPv6 sockets using localhost (::1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# udp-remote = UDP sockets with remote access (only for tests systems/purpose)
+# udp6-remote = UDP IPv6 sockets with remote access (only for tests purpose)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Include internal line edit mode in wpa_cli. This can be used as a replacement
+# for GNU Readline to provide limited command line editing and history support.
+CONFIG_WPA_CLI_EDIT=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operating system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+#CONFIG_ELOOP=eloop
+
+# Should we use poll instead of select? Select is used by default.
+#CONFIG_ELOOP_POLL=y
+
+# Should we use epoll instead of select? Select is used by default.
+#CONFIG_ELOOP_EPOLL=y
+
+# Should we use kqueue instead of select? Select is used by default.
+#CONFIG_ELOOP_KQUEUE=y
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# Disable Linux packet socket workaround applicable for station interface
+# in a bridge for EAPOL frames. This should be uncommented only if the kernel
+# is known to not have the regression issue in packet socket behavior with
+# bridge interfaces (commit 'bridge: respect RFC2863 operational state')').
+#CONFIG_NO_LINUX_PACKET_SOCKET_WAR=y
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection), also known as PMF
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+CONFIG_TLS=openssl
+
+# TLS-based EAP methods require at least TLS v1.0. Newer version of TLS (v1.1)
+# can be enabled to get a stronger construction of messages when block ciphers
+# are used. It should be noted that some existing TLS v1.0 -based
+# implementation may not be compatible with TLS v1.1 message (ClientHello is
+# sent prior to negotiating which version will be used)
+#CONFIG_TLSV11=y
+
+# TLS-based EAP methods require at least TLS v1.0. Newer version of TLS (v1.2)
+# can be enabled to enable use of stronger crypto algorithms. It should be
+# noted that some existing TLS v1.0 -based implementation may not be compatible
+# with TLS v1.2 message (ClientHello is sent prior to negotiating which version
+# will be used)
+#CONFIG_TLSV12=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+#CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Send debug messages to syslog instead of stdout
+#CONFIG_DEBUG_SYSLOG=y
+# Set syslog facility for debug messages
+#CONFIG_DEBUG_SYSLOG_FACILITY=LOG_DAEMON
+
+# Add support for sending all debug messages (regardless of debug verbosity)
+# to the Linux kernel tracing facility. This helps debug the entire stack by
+# making it easy to record everything happening from the driver up into the
+# same file, e.g., using trace-cmd.
+#CONFIG_DEBUG_LINUX_TRACING=y
+
+# Add support for writing debug log to Android logcat instead of standard
+# output
+#CONFIG_ANDROID_LOG=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, uncomment these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, uncomment these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+# wpa_supplicant depends on strong random number generation being available
+# from the operating system. os_get_random() function is used to fetch random
+# data when needed, e.g., for key generation. On Linux and BSD systems, this
+# works by reading /dev/urandom. It should be noted that the OS entropy pool
+# needs to be properly initialized before wpa_supplicant is started. This is
+# important especially on embedded devices that do not have a hardware random
+# number generator and may by default start up with minimal entropy available
+# for random number generation.
+#
+# As a safety net, wpa_supplicant is by default trying to internally collect
+# additional entropy for generating random data to mix in with the data fetched
+# from the OS. This by itself is not considered to be very strong, but it may
+# help in cases where the system pool is not initialized properly. However, it
+# is very strongly recommended that the system pool is initialized with enough
+# entropy either by using hardware assisted random number generator or by
+# storing state over device reboots.
+#
+# wpa_supplicant can be configured to maintain its own entropy store over
+# restarts to enhance random number generation. This is not perfect, but it is
+# much more secure than using the same sequence of random numbers after every
+# reboot. This can be enabled with -e<entropy file> command line option. The
+# specified file needs to be readable and writable by wpa_supplicant.
+#
+# If the os_get_random() is known to provide strong random data (e.g., on
+# Linux/BSD, the board in question is known to have reliable source of random
+# data from /dev/urandom), the internal wpa_supplicant random pool can be
+# disabled. This will save some in binary size and CPU use. However, this
+# should only be considered for builds that are known to be used on devices
+# that meet the requirements described above.
+#CONFIG_NO_RANDOM_POOL=y
+
+# IEEE 802.11n (High Throughput) support (mainly for AP mode)
+#CONFIG_IEEE80211N=y
+
+# IEEE 802.11ac (Very High Throughput) support (mainly for AP mode)
+# (depends on CONFIG_IEEE80211N)
+#CONFIG_IEEE80211AC=y
+
+# Wireless Network Management (IEEE Std 802.11v-2011)
+# Note: This is experimental and not complete implementation.
+#CONFIG_WNM=y
+
+# Interworking (IEEE 802.11u)
+# This can be used to enable functionality to improve interworking with
+# external networks (GAS/ANQP to learn more about the networks and network
+# selection based on available credentials).
+#CONFIG_INTERWORKING=y
+
+# Hotspot 2.0
+#CONFIG_HS20=y
+
+# Enable interface matching in wpa_supplicant
+#CONFIG_MATCH_IFACE=y
+
+# Disable roaming in wpa_supplicant
+#CONFIG_NO_ROAMING=y
+
+# AP mode operations with wpa_supplicant
+# This can be used for controlling AP mode operations with wpa_supplicant. It
+# should be noted that this is mainly aimed at simple cases like
+# WPA2-Personal while more complex configurations like WPA2-Enterprise with an
+# external RADIUS server can be supported with hostapd.
+CONFIG_AP=y
+
+# P2P (Wi-Fi Direct)
+# This can be used to enable P2P support in wpa_supplicant. See README-P2P for
+# more information on P2P operations.
+CONFIG_P2P=y
+
+# Enable TDLS support
+#CONFIG_TDLS=y
+
+# Wi-Fi Direct
+# This can be used to enable Wi-Fi Direct extensions for P2P using an external
+# program to control the additional information exchanges in the messages.
+#CONFIG_WIFI_DISPLAY=y
+
+# Autoscan
+# This can be used to enable automatic scan support in wpa_supplicant.
+# See wpa_supplicant.conf for more information on autoscan usage.
+#
+# Enabling directly a module will enable autoscan support.
+# For exponential module:
+#CONFIG_AUTOSCAN_EXPONENTIAL=y
+# For periodic module:
+#CONFIG_AUTOSCAN_PERIODIC=y
+
+# Password (and passphrase, etc.) backend for external storage
+# These optional mechanisms can be used to add support for storing passwords
+# and other secrets in external (to wpa_supplicant) location. This allows, for
+# example, operating system specific key storage to be used
+#
+# External password backend for testing purposes (developer use)
+#CONFIG_EXT_PASSWORD_TEST=y
+
+# Enable Fast Session Transfer (FST)
+#CONFIG_FST=y
+
+# Enable CLI commands for FST testing
+#CONFIG_FST_TEST=y
+
+# OS X builds. This is only for building eapol_test.
+#CONFIG_OSX=y
+
+# Automatic Channel Selection
+# This will allow wpa_supplicant to pick the channel automatically when channel
+# is set to "0".
+#
+# TODO: Extend parser to be able to parse "channel=acs_survey" as an alternative
+# to "channel=0". This would enable us to eventually add other ACS algorithms in
+# similar way.
+#
+# Automatic selection is currently only done through initialization, later on
+# we hope to do background checks to keep us moving to more ideal channels as
+# time goes by. ACS is currently only supported through the nl80211 driver and
+# your driver must have survey dump capability that is filled by the driver
+# during scanning.
+#
+# TODO: In analogy to hostapd be able to customize the ACS survey algorithm with
+# a newly to create wpa_supplicant.conf variable acs_num_scans.
+#
+# Supported ACS drivers:
+# * ath9k
+# * ath5k
+# * ath10k
+#
+# For more details refer to:
+# http://wireless.kernel.org/en/users/Documentation/acs
+#CONFIG_ACS=y
+
+# Support Multi Band Operation
+#CONFIG_MBO=y
diff --git a/system/wpa_supplicant/eloop.patch b/system/wpa_supplicant/eloop.patch
new file mode 100644
index 000000000..bab2cee4e
--- /dev/null
+++ b/system/wpa_supplicant/eloop.patch
@@ -0,0 +1,16 @@
+$OpenBSD: patch-src_utils_eloop_c,v 1.5 2015/09/29 11:57:54 dcoppa Exp $
+
+don't try to access list members to free them unless already initialised
+
+--- a/src/utils/eloop.c.orig Sun Sep 27 21:02:05 2015
++++ b/src/utils/eloop.c Mon Sep 28 09:35:05 2015
+@@ -1064,6 +1064,9 @@ void eloop_destroy(void)
+ struct eloop_timeout *timeout, *prev;
+ struct os_reltime now;
+
++ if (eloop.timeout.prev == NULL)
++ return;
++
+ os_get_reltime(&now);
+ dl_list_for_each_safe(timeout, prev, &eloop.timeout,
+ struct eloop_timeout, list) {
diff --git a/system/wpa_supplicant/libressl.patch b/system/wpa_supplicant/libressl.patch
new file mode 100644
index 000000000..56146eab5
--- /dev/null
+++ b/system/wpa_supplicant/libressl.patch
@@ -0,0 +1,49 @@
+--- a/src/crypto/crypto_openssl.c.orig
++++ b/src/crypto/crypto_openssl.c
+@@ -611,7 +611,7 @@
+
+ void * dh5_init(struct wpabuf **priv, struct wpabuf **publ)
+ {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ DH *dh;
+ struct wpabuf *pubkey = NULL, *privkey = NULL;
+ size_t publen, privlen;
+@@ -712,7 +712,7 @@
+
+ void * dh5_init_fixed(const struct wpabuf *priv, const struct wpabuf *publ)
+ {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ DH *dh;
+
+ dh = DH_new();
+--- a/src/crypto/tls_openssl.c.orig
++++ b/src/crypto/tls_openssl.c
+@@ -919,7 +919,7 @@
+ }
+ #endif /* OPENSSL_FIPS */
+ #endif /* CONFIG_FIPS */
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ SSL_load_error_strings();
+ SSL_library_init();
+ #ifndef OPENSSL_NO_SHA256
+@@ -1043,7 +1043,7 @@
+
+ tls_openssl_ref_count--;
+ if (tls_openssl_ref_count == 0) {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+ #ifndef OPENSSL_NO_ENGINE
+ ENGINE_cleanup();
+ #endif /* OPENSSL_NO_ENGINE */
+@@ -2334,7 +2334,7 @@
+ return 0;
+
+ #ifdef PKCS12_FUNCS
+-#if OPENSSL_VERSION_NUMBER < 0x10002000L
++#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER)
+ /*
+ * Clear previously set extra chain certificates, if any, from PKCS#12
+ * processing in tls_parse_pkcs12() to allow OpenSSL to build a new
diff --git a/system/wpa_supplicant/rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch b/system/wpa_supplicant/rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch
new file mode 100644
index 000000000..727684865
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0001-hostapd-Avoid-key-reinstallation-in-FT-handshake.patch
@@ -0,0 +1,174 @@
+From cf4cab804c7afd5c45505528a8d16e46163243a2 Mon Sep 17 00:00:00 2001
+From: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
+Date: Fri, 14 Jul 2017 15:15:35 +0200
+Subject: [PATCH 1/8] hostapd: Avoid key reinstallation in FT handshake
+
+Do not reinstall TK to the driver during Reassociation Response frame
+processing if the first attempt of setting the TK succeeded. This avoids
+issues related to clearing the TX/RX PN that could result in reusing
+same PN values for transmitted frames (e.g., due to CCM nonce reuse and
+also hitting replay protection on the receiver) and accepting replayed
+frames on RX side.
+
+This issue was introduced by the commit
+0e84c25434e6a1f283c7b4e62e483729085b78d2 ('FT: Fix PTK configuration in
+authenticator') which allowed wpa_ft_install_ptk() to be called multiple
+times with the same PTK. While the second configuration attempt is
+needed with some drivers, it must be done only if the first attempt
+failed.
+
+Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
+---
+ src/ap/ieee802_11.c | 16 +++++++++++++---
+ src/ap/wpa_auth.c | 11 +++++++++++
+ src/ap/wpa_auth.h | 3 ++-
+ src/ap/wpa_auth_ft.c | 10 ++++++++++
+ src/ap/wpa_auth_i.h | 1 +
+ 5 files changed, 37 insertions(+), 4 deletions(-)
+
+diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
+index 4e04169..333035f 100644
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -1841,6 +1841,7 @@ static int add_associated_sta(struct hostapd_data *hapd,
+ {
+ struct ieee80211_ht_capabilities ht_cap;
+ struct ieee80211_vht_capabilities vht_cap;
++ int set = 1;
+
+ /*
+ * Remove the STA entry to ensure the STA PS state gets cleared and
+@@ -1848,9 +1849,18 @@ static int add_associated_sta(struct hostapd_data *hapd,
+ * FT-over-the-DS, where a station re-associates back to the same AP but
+ * skips the authentication flow, or if working with a driver that
+ * does not support full AP client state.
++ *
++ * Skip this if the STA has already completed FT reassociation and the
++ * TK has been configured since the TX/RX PN must not be reset to 0 for
++ * the same key.
+ */
+- if (!sta->added_unassoc)
++ if (!sta->added_unassoc &&
++ (!(sta->flags & WLAN_STA_AUTHORIZED) ||
++ !wpa_auth_sta_ft_tk_already_set(sta->wpa_sm))) {
+ hostapd_drv_sta_remove(hapd, sta->addr);
++ wpa_auth_sm_event(sta->wpa_sm, WPA_DRV_STA_REMOVED);
++ set = 0;
++ }
+
+ #ifdef CONFIG_IEEE80211N
+ if (sta->flags & WLAN_STA_HT)
+@@ -1873,11 +1883,11 @@ static int add_associated_sta(struct hostapd_data *hapd,
+ sta->flags & WLAN_STA_VHT ? &vht_cap : NULL,
+ sta->flags | WLAN_STA_ASSOC, sta->qosinfo,
+ sta->vht_opmode, sta->p2p_ie ? 1 : 0,
+- sta->added_unassoc)) {
++ set)) {
+ hostapd_logger(hapd, sta->addr,
+ HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_NOTICE,
+ "Could not %s STA to kernel driver",
+- sta->added_unassoc ? "set" : "add");
++ set ? "set" : "add");
+
+ if (sta->added_unassoc) {
+ hostapd_drv_sta_remove(hapd, sta->addr);
+diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
+index 3587086..707971d 100644
+--- a/src/ap/wpa_auth.c
++++ b/src/ap/wpa_auth.c
+@@ -1745,6 +1745,9 @@ int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event)
+ #else /* CONFIG_IEEE80211R */
+ break;
+ #endif /* CONFIG_IEEE80211R */
++ case WPA_DRV_STA_REMOVED:
++ sm->tk_already_set = FALSE;
++ return 0;
+ }
+
+ #ifdef CONFIG_IEEE80211R
+@@ -3250,6 +3253,14 @@ int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm)
+ }
+
+
++int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm)
++{
++ if (!sm || !wpa_key_mgmt_ft(sm->wpa_key_mgmt))
++ return 0;
++ return sm->tk_already_set;
++}
++
++
+ int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
+ struct rsn_pmksa_cache_entry *entry)
+ {
+diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
+index 0de8d97..97461b0 100644
+--- a/src/ap/wpa_auth.h
++++ b/src/ap/wpa_auth.h
+@@ -267,7 +267,7 @@ void wpa_receive(struct wpa_authenticator *wpa_auth,
+ u8 *data, size_t data_len);
+ enum wpa_event {
+ WPA_AUTH, WPA_ASSOC, WPA_DISASSOC, WPA_DEAUTH, WPA_REAUTH,
+- WPA_REAUTH_EAPOL, WPA_ASSOC_FT
++ WPA_REAUTH_EAPOL, WPA_ASSOC_FT, WPA_DRV_STA_REMOVED
+ };
+ void wpa_remove_ptk(struct wpa_state_machine *sm);
+ int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event);
+@@ -280,6 +280,7 @@ int wpa_auth_pairwise_set(struct wpa_state_machine *sm);
+ int wpa_auth_get_pairwise(struct wpa_state_machine *sm);
+ int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm);
+ int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm);
++int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm);
+ int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm,
+ struct rsn_pmksa_cache_entry *entry);
+ struct rsn_pmksa_cache_entry *
+diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
+index 42242a5..e63b99a 100644
+--- a/src/ap/wpa_auth_ft.c
++++ b/src/ap/wpa_auth_ft.c
+@@ -780,6 +780,14 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm)
+ return;
+ }
+
++ if (sm->tk_already_set) {
++ /* Must avoid TK reconfiguration to prevent clearing of TX/RX
++ * PN in the driver */
++ wpa_printf(MSG_DEBUG,
++ "FT: Do not re-install same PTK to the driver");
++ return;
++ }
++
+ /* FIX: add STA entry to kernel/driver here? The set_key will fail
+ * most likely without this.. At the moment, STA entry is added only
+ * after association has been completed. This function will be called
+@@ -792,6 +800,7 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm)
+
+ /* FIX: MLME-SetProtection.Request(TA, Tx_Rx) */
+ sm->pairwise_set = TRUE;
++ sm->tk_already_set = TRUE;
+ }
+
+
+@@ -898,6 +907,7 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
+
+ sm->pairwise = pairwise;
+ sm->PTK_valid = TRUE;
++ sm->tk_already_set = FALSE;
+ wpa_ft_install_ptk(sm);
+
+ buflen = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) +
+diff --git a/src/ap/wpa_auth_i.h b/src/ap/wpa_auth_i.h
+index 72b7eb3..7fd8f05 100644
+--- a/src/ap/wpa_auth_i.h
++++ b/src/ap/wpa_auth_i.h
+@@ -65,6 +65,7 @@ struct wpa_state_machine {
+ struct wpa_ptk PTK;
+ Boolean PTK_valid;
+ Boolean pairwise_set;
++ Boolean tk_already_set;
+ int keycount;
+ Boolean Pair;
+ struct wpa_key_replay_counter {
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch b/system/wpa_supplicant/rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch
new file mode 100644
index 000000000..1802d664a
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0002-Prevent-reinstallation-of-an-already-in-use-group-ke.patch
@@ -0,0 +1,250 @@
+From 927f891007c402fefd1ff384645b3f07597c3ede Mon Sep 17 00:00:00 2001
+From: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
+Date: Wed, 12 Jul 2017 16:03:24 +0200
+Subject: [PATCH 2/8] Prevent reinstallation of an already in-use group key
+
+Track the current GTK and IGTK that is in use and when receiving a
+(possibly retransmitted) Group Message 1 or WNM-Sleep Mode Response, do
+not install the given key if it is already in use. This prevents an
+attacker from trying to trick the client into resetting or lowering the
+sequence counter associated to the group key.
+
+Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
+---
+ src/common/wpa_common.h | 11 +++++
+ src/rsn_supp/wpa.c | 116 ++++++++++++++++++++++++++++++------------------
+ src/rsn_supp/wpa_i.h | 4 ++
+ 3 files changed, 87 insertions(+), 44 deletions(-)
+
+diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
+index af1d0f0..d200285 100644
+--- a/src/common/wpa_common.h
++++ b/src/common/wpa_common.h
+@@ -217,6 +217,17 @@ struct wpa_ptk {
+ size_t tk_len;
+ };
+
++struct wpa_gtk {
++ u8 gtk[WPA_GTK_MAX_LEN];
++ size_t gtk_len;
++};
++
++#ifdef CONFIG_IEEE80211W
++struct wpa_igtk {
++ u8 igtk[WPA_IGTK_MAX_LEN];
++ size_t igtk_len;
++};
++#endif /* CONFIG_IEEE80211W */
+
+ /* WPA IE version 1
+ * 00-50-f2:1 (OUI:OUI type)
+diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
+index 3c47879..95bd7be 100644
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -714,6 +714,15 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
+ const u8 *_gtk = gd->gtk;
+ u8 gtk_buf[32];
+
++ /* Detect possible key reinstallation */
++ if (sm->gtk.gtk_len == (size_t) gd->gtk_len &&
++ os_memcmp(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len) == 0) {
++ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
++ "WPA: Not reinstalling already in-use GTK to the driver (keyidx=%d tx=%d len=%d)",
++ gd->keyidx, gd->tx, gd->gtk_len);
++ return 0;
++ }
++
+ wpa_hexdump_key(MSG_DEBUG, "WPA: Group Key", gd->gtk, gd->gtk_len);
+ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
+ "WPA: Installing GTK to the driver (keyidx=%d tx=%d len=%d)",
+@@ -748,6 +757,9 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
+ }
+ os_memset(gtk_buf, 0, sizeof(gtk_buf));
+
++ sm->gtk.gtk_len = gd->gtk_len;
++ os_memcpy(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len);
++
+ return 0;
+ }
+
+@@ -854,6 +866,48 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm,
+ }
+
+
++#ifdef CONFIG_IEEE80211W
++static int wpa_supplicant_install_igtk(struct wpa_sm *sm,
++ const struct wpa_igtk_kde *igtk)
++{
++ size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher);
++ u16 keyidx = WPA_GET_LE16(igtk->keyid);
++
++ /* Detect possible key reinstallation */
++ if (sm->igtk.igtk_len == len &&
++ os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) {
++ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
++ "WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)",
++ keyidx);
++ return 0;
++ }
++
++ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
++ "WPA: IGTK keyid %d pn %02x%02x%02x%02x%02x%02x",
++ keyidx, MAC2STR(igtk->pn));
++ wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len);
++ if (keyidx > 4095) {
++ wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
++ "WPA: Invalid IGTK KeyID %d", keyidx);
++ return -1;
++ }
++ if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher),
++ broadcast_ether_addr,
++ keyidx, 0, igtk->pn, sizeof(igtk->pn),
++ igtk->igtk, len) < 0) {
++ wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
++ "WPA: Failed to configure IGTK to the driver");
++ return -1;
++ }
++
++ sm->igtk.igtk_len = len;
++ os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len);
++
++ return 0;
++}
++#endif /* CONFIG_IEEE80211W */
++
++
+ static int ieee80211w_set_keys(struct wpa_sm *sm,
+ struct wpa_eapol_ie_parse *ie)
+ {
+@@ -864,30 +918,14 @@ static int ieee80211w_set_keys(struct wpa_sm *sm,
+ if (ie->igtk) {
+ size_t len;
+ const struct wpa_igtk_kde *igtk;
+- u16 keyidx;
++
+ len = wpa_cipher_key_len(sm->mgmt_group_cipher);
+ if (ie->igtk_len != WPA_IGTK_KDE_PREFIX_LEN + len)
+ return -1;
++
+ igtk = (const struct wpa_igtk_kde *) ie->igtk;
+- keyidx = WPA_GET_LE16(igtk->keyid);
+- wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: IGTK keyid %d "
+- "pn %02x%02x%02x%02x%02x%02x",
+- keyidx, MAC2STR(igtk->pn));
+- wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK",
+- igtk->igtk, len);
+- if (keyidx > 4095) {
+- wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
+- "WPA: Invalid IGTK KeyID %d", keyidx);
+- return -1;
+- }
+- if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher),
+- broadcast_ether_addr,
+- keyidx, 0, igtk->pn, sizeof(igtk->pn),
+- igtk->igtk, len) < 0) {
+- wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
+- "WPA: Failed to configure IGTK to the driver");
++ if (wpa_supplicant_install_igtk(sm, igtk) < 0)
+ return -1;
+- }
+ }
+
+ return 0;
+@@ -2307,7 +2345,7 @@ void wpa_sm_deinit(struct wpa_sm *sm)
+ */
+ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
+ {
+- int clear_ptk = 1;
++ int clear_keys = 1;
+
+ if (sm == NULL)
+ return;
+@@ -2333,11 +2371,11 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
+ /* Prepare for the next transition */
+ wpa_ft_prepare_auth_request(sm, NULL);
+
+- clear_ptk = 0;
++ clear_keys = 0;
+ }
+ #endif /* CONFIG_IEEE80211R */
+
+- if (clear_ptk) {
++ if (clear_keys) {
+ /*
+ * IEEE 802.11, 8.4.10: Delete PTK SA on (re)association if
+ * this is not part of a Fast BSS Transition.
+@@ -2347,6 +2385,10 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
+ os_memset(&sm->ptk, 0, sizeof(sm->ptk));
+ sm->tptk_set = 0;
+ os_memset(&sm->tptk, 0, sizeof(sm->tptk));
++ os_memset(&sm->gtk, 0, sizeof(sm->gtk));
++#ifdef CONFIG_IEEE80211W
++ os_memset(&sm->igtk, 0, sizeof(sm->igtk));
++#endif /* CONFIG_IEEE80211W */
+ }
+
+ #ifdef CONFIG_TDLS
+@@ -2877,6 +2919,10 @@ void wpa_sm_drop_sa(struct wpa_sm *sm)
+ os_memset(sm->pmk, 0, sizeof(sm->pmk));
+ os_memset(&sm->ptk, 0, sizeof(sm->ptk));
+ os_memset(&sm->tptk, 0, sizeof(sm->tptk));
++ os_memset(&sm->gtk, 0, sizeof(sm->gtk));
++#ifdef CONFIG_IEEE80211W
++ os_memset(&sm->igtk, 0, sizeof(sm->igtk));
++#endif /* CONFIG_IEEE80211W */
+ #ifdef CONFIG_IEEE80211R
+ os_memset(sm->xxkey, 0, sizeof(sm->xxkey));
+ os_memset(sm->pmk_r0, 0, sizeof(sm->pmk_r0));
+@@ -2949,29 +2995,11 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf)
+ os_memset(&gd, 0, sizeof(gd));
+ #ifdef CONFIG_IEEE80211W
+ } else if (subelem_id == WNM_SLEEP_SUBELEM_IGTK) {
+- struct wpa_igtk_kde igd;
+- u16 keyidx;
+-
+- os_memset(&igd, 0, sizeof(igd));
+- keylen = wpa_cipher_key_len(sm->mgmt_group_cipher);
+- os_memcpy(igd.keyid, buf + 2, 2);
+- os_memcpy(igd.pn, buf + 4, 6);
+-
+- keyidx = WPA_GET_LE16(igd.keyid);
+- os_memcpy(igd.igtk, buf + 10, keylen);
+-
+- wpa_hexdump_key(MSG_DEBUG, "Install IGTK (WNM SLEEP)",
+- igd.igtk, keylen);
+- if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher),
+- broadcast_ether_addr,
+- keyidx, 0, igd.pn, sizeof(igd.pn),
+- igd.igtk, keylen) < 0) {
+- wpa_printf(MSG_DEBUG, "Failed to install the IGTK in "
+- "WNM mode");
+- os_memset(&igd, 0, sizeof(igd));
++ const struct wpa_igtk_kde *igtk;
++
++ igtk = (const struct wpa_igtk_kde *) (buf + 2);
++ if (wpa_supplicant_install_igtk(sm, igtk) < 0)
+ return -1;
+- }
+- os_memset(&igd, 0, sizeof(igd));
+ #endif /* CONFIG_IEEE80211W */
+ } else {
+ wpa_printf(MSG_DEBUG, "Unknown element id");
+diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
+index f653ba6..afc9e37 100644
+--- a/src/rsn_supp/wpa_i.h
++++ b/src/rsn_supp/wpa_i.h
+@@ -31,6 +31,10 @@ struct wpa_sm {
+ u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN];
+ int rx_replay_counter_set;
+ u8 request_counter[WPA_REPLAY_COUNTER_LEN];
++ struct wpa_gtk gtk;
++#ifdef CONFIG_IEEE80211W
++ struct wpa_igtk igtk;
++#endif /* CONFIG_IEEE80211W */
+
+ struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
+
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch b/system/wpa_supplicant/rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch
new file mode 100644
index 000000000..e2937b851
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0003-Extend-protection-of-GTK-IGTK-reinstallation-of-WNM-.patch
@@ -0,0 +1,184 @@
+From 8280294e74846ea342389a0cd17215050fa5afe8 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j@w1.fi>
+Date: Sun, 1 Oct 2017 12:12:24 +0300
+Subject: [PATCH 3/8] Extend protection of GTK/IGTK reinstallation of WNM-Sleep
+ Mode cases
+
+This extends the protection to track last configured GTK/IGTK value
+separately from EAPOL-Key frames and WNM-Sleep Mode frames to cover a
+corner case where these two different mechanisms may get used when the
+GTK/IGTK has changed and tracking a single value is not sufficient to
+detect a possible key reconfiguration.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+ src/rsn_supp/wpa.c | 53 +++++++++++++++++++++++++++++++++++++---------------
+ src/rsn_supp/wpa_i.h | 2 ++
+ 2 files changed, 40 insertions(+), 15 deletions(-)
+
+diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
+index 95bd7be..7a2c68d 100644
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -709,14 +709,17 @@ struct wpa_gtk_data {
+
+ static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
+ const struct wpa_gtk_data *gd,
+- const u8 *key_rsc)
++ const u8 *key_rsc, int wnm_sleep)
+ {
+ const u8 *_gtk = gd->gtk;
+ u8 gtk_buf[32];
+
+ /* Detect possible key reinstallation */
+- if (sm->gtk.gtk_len == (size_t) gd->gtk_len &&
+- os_memcmp(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len) == 0) {
++ if ((sm->gtk.gtk_len == (size_t) gd->gtk_len &&
++ os_memcmp(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len) == 0) ||
++ (sm->gtk_wnm_sleep.gtk_len == (size_t) gd->gtk_len &&
++ os_memcmp(sm->gtk_wnm_sleep.gtk, gd->gtk,
++ sm->gtk_wnm_sleep.gtk_len) == 0)) {
+ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
+ "WPA: Not reinstalling already in-use GTK to the driver (keyidx=%d tx=%d len=%d)",
+ gd->keyidx, gd->tx, gd->gtk_len);
+@@ -757,8 +760,14 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm,
+ }
+ os_memset(gtk_buf, 0, sizeof(gtk_buf));
+
+- sm->gtk.gtk_len = gd->gtk_len;
+- os_memcpy(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len);
++ if (wnm_sleep) {
++ sm->gtk_wnm_sleep.gtk_len = gd->gtk_len;
++ os_memcpy(sm->gtk_wnm_sleep.gtk, gd->gtk,
++ sm->gtk_wnm_sleep.gtk_len);
++ } else {
++ sm->gtk.gtk_len = gd->gtk_len;
++ os_memcpy(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len);
++ }
+
+ return 0;
+ }
+@@ -852,7 +861,7 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm,
+ (wpa_supplicant_check_group_cipher(sm, sm->group_cipher,
+ gtk_len, gtk_len,
+ &gd.key_rsc_len, &gd.alg) ||
+- wpa_supplicant_install_gtk(sm, &gd, key_rsc))) {
++ wpa_supplicant_install_gtk(sm, &gd, key_rsc, 0))) {
+ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
+ "RSN: Failed to install GTK");
+ os_memset(&gd, 0, sizeof(gd));
+@@ -868,14 +877,18 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm,
+
+ #ifdef CONFIG_IEEE80211W
+ static int wpa_supplicant_install_igtk(struct wpa_sm *sm,
+- const struct wpa_igtk_kde *igtk)
++ const struct wpa_igtk_kde *igtk,
++ int wnm_sleep)
+ {
+ size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher);
+ u16 keyidx = WPA_GET_LE16(igtk->keyid);
+
+ /* Detect possible key reinstallation */
+- if (sm->igtk.igtk_len == len &&
+- os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) {
++ if ((sm->igtk.igtk_len == len &&
++ os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) ||
++ (sm->igtk_wnm_sleep.igtk_len == len &&
++ os_memcmp(sm->igtk_wnm_sleep.igtk, igtk->igtk,
++ sm->igtk_wnm_sleep.igtk_len) == 0)) {
+ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
+ "WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)",
+ keyidx);
+@@ -900,8 +913,14 @@ static int wpa_supplicant_install_igtk(struct wpa_sm *sm,
+ return -1;
+ }
+
+- sm->igtk.igtk_len = len;
+- os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len);
++ if (wnm_sleep) {
++ sm->igtk_wnm_sleep.igtk_len = len;
++ os_memcpy(sm->igtk_wnm_sleep.igtk, igtk->igtk,
++ sm->igtk_wnm_sleep.igtk_len);
++ } else {
++ sm->igtk.igtk_len = len;
++ os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len);
++ }
+
+ return 0;
+ }
+@@ -924,7 +943,7 @@ static int ieee80211w_set_keys(struct wpa_sm *sm,
+ return -1;
+
+ igtk = (const struct wpa_igtk_kde *) ie->igtk;
+- if (wpa_supplicant_install_igtk(sm, igtk) < 0)
++ if (wpa_supplicant_install_igtk(sm, igtk, 0) < 0)
+ return -1;
+ }
+
+@@ -1574,7 +1593,7 @@ static void wpa_supplicant_process_1_of_2(struct wpa_sm *sm,
+ if (wpa_supplicant_rsc_relaxation(sm, key->key_rsc))
+ key_rsc = null_rsc;
+
+- if (wpa_supplicant_install_gtk(sm, &gd, key_rsc) ||
++ if (wpa_supplicant_install_gtk(sm, &gd, key_rsc, 0) ||
+ wpa_supplicant_send_2_of_2(sm, key, ver, key_info) < 0)
+ goto failed;
+ os_memset(&gd, 0, sizeof(gd));
+@@ -2386,8 +2405,10 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
+ sm->tptk_set = 0;
+ os_memset(&sm->tptk, 0, sizeof(sm->tptk));
+ os_memset(&sm->gtk, 0, sizeof(sm->gtk));
++ os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep));
+ #ifdef CONFIG_IEEE80211W
+ os_memset(&sm->igtk, 0, sizeof(sm->igtk));
++ os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep));
+ #endif /* CONFIG_IEEE80211W */
+ }
+
+@@ -2920,8 +2941,10 @@ void wpa_sm_drop_sa(struct wpa_sm *sm)
+ os_memset(&sm->ptk, 0, sizeof(sm->ptk));
+ os_memset(&sm->tptk, 0, sizeof(sm->tptk));
+ os_memset(&sm->gtk, 0, sizeof(sm->gtk));
++ os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep));
+ #ifdef CONFIG_IEEE80211W
+ os_memset(&sm->igtk, 0, sizeof(sm->igtk));
++ os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep));
+ #endif /* CONFIG_IEEE80211W */
+ #ifdef CONFIG_IEEE80211R
+ os_memset(sm->xxkey, 0, sizeof(sm->xxkey));
+@@ -2986,7 +3009,7 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf)
+
+ wpa_hexdump_key(MSG_DEBUG, "Install GTK (WNM SLEEP)",
+ gd.gtk, gd.gtk_len);
+- if (wpa_supplicant_install_gtk(sm, &gd, key_rsc)) {
++ if (wpa_supplicant_install_gtk(sm, &gd, key_rsc, 1)) {
+ os_memset(&gd, 0, sizeof(gd));
+ wpa_printf(MSG_DEBUG, "Failed to install the GTK in "
+ "WNM mode");
+@@ -2998,7 +3021,7 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf)
+ const struct wpa_igtk_kde *igtk;
+
+ igtk = (const struct wpa_igtk_kde *) (buf + 2);
+- if (wpa_supplicant_install_igtk(sm, igtk) < 0)
++ if (wpa_supplicant_install_igtk(sm, igtk, 1) < 0)
+ return -1;
+ #endif /* CONFIG_IEEE80211W */
+ } else {
+diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
+index afc9e37..9a54631 100644
+--- a/src/rsn_supp/wpa_i.h
++++ b/src/rsn_supp/wpa_i.h
+@@ -32,8 +32,10 @@ struct wpa_sm {
+ int rx_replay_counter_set;
+ u8 request_counter[WPA_REPLAY_COUNTER_LEN];
+ struct wpa_gtk gtk;
++ struct wpa_gtk gtk_wnm_sleep;
+ #ifdef CONFIG_IEEE80211W
+ struct wpa_igtk igtk;
++ struct wpa_igtk igtk_wnm_sleep;
+ #endif /* CONFIG_IEEE80211W */
+
+ struct eapol_sm *eapol; /* EAPOL state machine from upper level code */
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch b/system/wpa_supplicant/rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch
new file mode 100644
index 000000000..22ee21794
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0004-Prevent-installation-of-an-all-zero-TK.patch
@@ -0,0 +1,79 @@
+From 8f82bc94e8697a9d47fa8774dfdaaede1084912c Mon Sep 17 00:00:00 2001
+From: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
+Date: Fri, 29 Sep 2017 04:22:51 +0200
+Subject: [PATCH 4/8] Prevent installation of an all-zero TK
+
+Properly track whether a PTK has already been installed to the driver
+and the TK part cleared from memory. This prevents an attacker from
+trying to trick the client into installing an all-zero TK.
+
+This fixes the earlier fix in commit
+ad00d64e7d8827b3cebd665a0ceb08adabf15e1e ('Fix TK configuration to the
+driver in EAPOL-Key 3/4 retry case') which did not take into account
+possibility of an extra message 1/4 showing up between retries of
+message 3/4.
+
+Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
+---
+ src/common/wpa_common.h | 1 +
+ src/rsn_supp/wpa.c | 5 ++---
+ src/rsn_supp/wpa_i.h | 1 -
+ 3 files changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
+index d200285..1021ccb 100644
+--- a/src/common/wpa_common.h
++++ b/src/common/wpa_common.h
+@@ -215,6 +215,7 @@ struct wpa_ptk {
+ size_t kck_len;
+ size_t kek_len;
+ size_t tk_len;
++ int installed; /* 1 if key has already been installed to driver */
+ };
+
+ struct wpa_gtk {
+diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
+index 7a2c68d..0550a41 100644
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -510,7 +510,6 @@ static void wpa_supplicant_process_1_of_4(struct wpa_sm *sm,
+ os_memset(buf, 0, sizeof(buf));
+ }
+ sm->tptk_set = 1;
+- sm->tk_to_set = 1;
+
+ kde = sm->assoc_wpa_ie;
+ kde_len = sm->assoc_wpa_ie_len;
+@@ -615,7 +614,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
+ enum wpa_alg alg;
+ const u8 *key_rsc;
+
+- if (!sm->tk_to_set) {
++ if (sm->ptk.installed) {
+ wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
+ "WPA: Do not re-install same PTK to the driver");
+ return 0;
+@@ -659,7 +658,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
+
+ /* TK is not needed anymore in supplicant */
+ os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
+- sm->tk_to_set = 0;
++ sm->ptk.installed = 1;
+
+ if (sm->wpa_ptk_rekey) {
+ eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL);
+diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
+index 9a54631..41f371f 100644
+--- a/src/rsn_supp/wpa_i.h
++++ b/src/rsn_supp/wpa_i.h
+@@ -24,7 +24,6 @@ struct wpa_sm {
+ struct wpa_ptk ptk, tptk;
+ int ptk_set, tptk_set;
+ unsigned int msg_3_of_4_ok:1;
+- unsigned int tk_to_set:1;
+ u8 snonce[WPA_NONCE_LEN];
+ u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
+ int renew_snonce;
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch b/system/wpa_supplicant/rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch
new file mode 100644
index 000000000..c19c4c710
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0005-Fix-PTK-rekeying-to-generate-a-new-ANonce.patch
@@ -0,0 +1,64 @@
+From 12fac09b437a1dc8a0f253e265934a8aaf4d2f8b Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j@w1.fi>
+Date: Sun, 1 Oct 2017 12:32:57 +0300
+Subject: [PATCH 5/8] Fix PTK rekeying to generate a new ANonce
+
+The Authenticator state machine path for PTK rekeying ended up bypassing
+the AUTHENTICATION2 state where a new ANonce is generated when going
+directly to the PTKSTART state since there is no need to try to
+determine the PMK again in such a case. This is far from ideal since the
+new PTK would depend on a new nonce only from the supplicant.
+
+Fix this by generating a new ANonce when moving to the PTKSTART state
+for the purpose of starting new 4-way handshake to rekey PTK.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+ src/ap/wpa_auth.c | 24 +++++++++++++++++++++---
+ 1 file changed, 21 insertions(+), 3 deletions(-)
+
+diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
+index 707971d..bf10cc1 100644
+--- a/src/ap/wpa_auth.c
++++ b/src/ap/wpa_auth.c
+@@ -1901,6 +1901,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2)
+ }
+
+
++static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm)
++{
++ if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
++ wpa_printf(MSG_ERROR,
++ "WPA: Failed to get random data for ANonce");
++ sm->Disconnect = TRUE;
++ return -1;
++ }
++ wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce,
++ WPA_NONCE_LEN);
++ sm->TimeoutCtr = 0;
++ return 0;
++}
++
++
+ SM_STATE(WPA_PTK, INITPMK)
+ {
+ u8 msk[2 * PMK_LEN];
+@@ -2458,9 +2473,12 @@ SM_STEP(WPA_PTK)
+ SM_ENTER(WPA_PTK, AUTHENTICATION);
+ else if (sm->ReAuthenticationRequest)
+ SM_ENTER(WPA_PTK, AUTHENTICATION2);
+- else if (sm->PTKRequest)
+- SM_ENTER(WPA_PTK, PTKSTART);
+- else switch (sm->wpa_ptk_state) {
++ else if (sm->PTKRequest) {
++ if (wpa_auth_sm_ptk_update(sm) < 0)
++ SM_ENTER(WPA_PTK, DISCONNECTED);
++ else
++ SM_ENTER(WPA_PTK, PTKSTART);
++ } else switch (sm->wpa_ptk_state) {
+ case WPA_PTK_INITIALIZE:
+ break;
+ case WPA_PTK_DISCONNECT:
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch b/system/wpa_supplicant/rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch
new file mode 100644
index 000000000..e1bd5a572
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0006-TDLS-Reject-TPK-TK-reconfiguration.patch
@@ -0,0 +1,132 @@
+From 6c4bed4f47d1960ec04981a9d50e5076aea5223d Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j@w1.fi>
+Date: Fri, 22 Sep 2017 11:03:15 +0300
+Subject: [PATCH 6/8] TDLS: Reject TPK-TK reconfiguration
+
+Do not try to reconfigure the same TPK-TK to the driver after it has
+been successfully configured. This is an explicit check to avoid issues
+related to resetting the TX/RX packet number. There was already a check
+for this for TPK M2 (retries of that message are ignored completely), so
+that behavior does not get modified.
+
+For TPK M3, the TPK-TK could have been reconfigured, but that was
+followed by immediate teardown of the link due to an issue in updating
+the STA entry. Furthermore, for TDLS with any real security (i.e.,
+ignoring open/WEP), the TPK message exchange is protected on the AP path
+and simple replay attacks are not feasible.
+
+As an additional corner case, make sure the local nonce gets updated if
+the peer uses a very unlikely "random nonce" of all zeros.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+ src/rsn_supp/tdls.c | 38 ++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 36 insertions(+), 2 deletions(-)
+
+diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c
+index e424168..9eb9738 100644
+--- a/src/rsn_supp/tdls.c
++++ b/src/rsn_supp/tdls.c
+@@ -112,6 +112,7 @@ struct wpa_tdls_peer {
+ u8 tk[16]; /* TPK-TK; assuming only CCMP will be used */
+ } tpk;
+ int tpk_set;
++ int tk_set; /* TPK-TK configured to the driver */
+ int tpk_success;
+ int tpk_in_progress;
+
+@@ -192,6 +193,20 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
+ u8 rsc[6];
+ enum wpa_alg alg;
+
++ if (peer->tk_set) {
++ /*
++ * This same TPK-TK has already been configured to the driver
++ * and this new configuration attempt (likely due to an
++ * unexpected retransmitted frame) would result in clearing
++ * the TX/RX sequence number which can break security, so must
++ * not allow that to happen.
++ */
++ wpa_printf(MSG_INFO, "TDLS: TPK-TK for the peer " MACSTR
++ " has already been configured to the driver - do not reconfigure",
++ MAC2STR(peer->addr));
++ return -1;
++ }
++
+ os_memset(rsc, 0, 6);
+
+ switch (peer->cipher) {
+@@ -209,12 +224,15 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
+ return -1;
+ }
+
++ wpa_printf(MSG_DEBUG, "TDLS: Configure pairwise key for peer " MACSTR,
++ MAC2STR(peer->addr));
+ if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1,
+ rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) {
+ wpa_printf(MSG_WARNING, "TDLS: Failed to set TPK to the "
+ "driver");
+ return -1;
+ }
++ peer->tk_set = 1;
+ return 0;
+ }
+
+@@ -696,7 +714,7 @@ static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer)
+ peer->cipher = 0;
+ peer->qos_info = 0;
+ peer->wmm_capable = 0;
+- peer->tpk_set = peer->tpk_success = 0;
++ peer->tk_set = peer->tpk_set = peer->tpk_success = 0;
+ peer->chan_switch_enabled = 0;
+ os_memset(&peer->tpk, 0, sizeof(peer->tpk));
+ os_memset(peer->inonce, 0, WPA_NONCE_LEN);
+@@ -1159,6 +1177,7 @@ skip_rsnie:
+ wpa_tdls_peer_free(sm, peer);
+ return -1;
+ }
++ peer->tk_set = 0; /* A new nonce results in a new TK */
+ wpa_hexdump(MSG_DEBUG, "TDLS: Initiator Nonce for TPK handshake",
+ peer->inonce, WPA_NONCE_LEN);
+ os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN);
+@@ -1751,6 +1770,19 @@ static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer,
+ }
+
+
++static int tdls_nonce_set(const u8 *nonce)
++{
++ int i;
++
++ for (i = 0; i < WPA_NONCE_LEN; i++) {
++ if (nonce[i])
++ return 1;
++ }
++
++ return 0;
++}
++
++
+ static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr,
+ const u8 *buf, size_t len)
+ {
+@@ -2004,7 +2036,8 @@ skip_rsn:
+ peer->rsnie_i_len = kde.rsn_ie_len;
+ peer->cipher = cipher;
+
+- if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) {
++ if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 ||
++ !tdls_nonce_set(peer->inonce)) {
+ /*
+ * There is no point in updating the RNonce for every obtained
+ * TPK M1 frame (e.g., retransmission due to timeout) with the
+@@ -2020,6 +2053,7 @@ skip_rsn:
+ "TDLS: Failed to get random data for responder nonce");
+ goto error;
+ }
++ peer->tk_set = 0; /* A new nonce results in a new TK */
+ }
+
+ #if 0
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch b/system/wpa_supplicant/rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch
new file mode 100644
index 000000000..85ea1d62b
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0007-WNM-Ignore-WNM-Sleep-Mode-Response-without-pending-r.patch
@@ -0,0 +1,43 @@
+From 53c5eb58e95004f86e65ee9fbfccbc291b139057 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j@w1.fi>
+Date: Fri, 22 Sep 2017 11:25:02 +0300
+Subject: [PATCH 7/8] WNM: Ignore WNM-Sleep Mode Response without pending
+ request
+
+Commit 03ed0a52393710be6bdae657d1b36efa146520e5 ('WNM: Ignore WNM-Sleep
+Mode Response if WNM-Sleep Mode has not been used') started ignoring the
+response when no WNM-Sleep Mode Request had been used during the
+association. This can be made tighter by clearing the used flag when
+successfully processing a response. This adds an additional layer of
+protection against unexpected retransmissions of the response frame.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+ wpa_supplicant/wnm_sta.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c
+index 1b3409c..67a07ff 100644
+--- a/wpa_supplicant/wnm_sta.c
++++ b/wpa_supplicant/wnm_sta.c
+@@ -260,7 +260,7 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s,
+
+ if (!wpa_s->wnmsleep_used) {
+ wpa_printf(MSG_DEBUG,
+- "WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode has not been used in this association");
++ "WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode operation has not been requested");
+ return;
+ }
+
+@@ -299,6 +299,8 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s,
+ return;
+ }
+
++ wpa_s->wnmsleep_used = 0;
++
+ if (wnmsleep_ie->status == WNM_STATUS_SLEEP_ACCEPT ||
+ wnmsleep_ie->status == WNM_STATUS_SLEEP_EXIT_ACCEPT_GTK_UPDATE) {
+ wpa_printf(MSG_DEBUG, "Successfully recv WNM-Sleep Response "
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch b/system/wpa_supplicant/rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch
new file mode 100644
index 000000000..b9678f681
--- /dev/null
+++ b/system/wpa_supplicant/rebased-v2.6-0008-FT-Do-not-allow-multiple-Reassociation-Response-fram.patch
@@ -0,0 +1,82 @@
+From b372ab0b7daea719749194dc554b26e6367603f2 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j@w1.fi>
+Date: Fri, 22 Sep 2017 12:06:37 +0300
+Subject: [PATCH 8/8] FT: Do not allow multiple Reassociation Response frames
+
+The driver is expected to not report a second association event without
+the station having explicitly request a new association. As such, this
+case should not be reachable. However, since reconfiguring the same
+pairwise or group keys to the driver could result in nonce reuse issues,
+be extra careful here and do an additional state check to avoid this
+even if the local driver ends up somehow accepting an unexpected
+Reassociation Response frame.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+ src/rsn_supp/wpa.c | 3 +++
+ src/rsn_supp/wpa_ft.c | 8 ++++++++
+ src/rsn_supp/wpa_i.h | 1 +
+ 3 files changed, 12 insertions(+)
+
+diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
+index 0550a41..2a53c6f 100644
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -2440,6 +2440,9 @@ void wpa_sm_notify_disassoc(struct wpa_sm *sm)
+ #ifdef CONFIG_TDLS
+ wpa_tdls_disassoc(sm);
+ #endif /* CONFIG_TDLS */
++#ifdef CONFIG_IEEE80211R
++ sm->ft_reassoc_completed = 0;
++#endif /* CONFIG_IEEE80211R */
+
+ /* Keys are not needed in the WPA state machine anymore */
+ wpa_sm_drop_sa(sm);
+diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
+index 205793e..d45bb45 100644
+--- a/src/rsn_supp/wpa_ft.c
++++ b/src/rsn_supp/wpa_ft.c
+@@ -153,6 +153,7 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
+ u16 capab;
+
+ sm->ft_completed = 0;
++ sm->ft_reassoc_completed = 0;
+
+ buf_len = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) +
+ 2 + sm->r0kh_id_len + ric_ies_len + 100;
+@@ -681,6 +682,11 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
+ return -1;
+ }
+
++ if (sm->ft_reassoc_completed) {
++ wpa_printf(MSG_DEBUG, "FT: Reassociation has already been completed for this FT protocol instance - ignore unexpected retransmission");
++ return 0;
++ }
++
+ if (wpa_ft_parse_ies(ies, ies_len, &parse) < 0) {
+ wpa_printf(MSG_DEBUG, "FT: Failed to parse IEs");
+ return -1;
+@@ -781,6 +787,8 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
+ return -1;
+ }
+
++ sm->ft_reassoc_completed = 1;
++
+ if (wpa_ft_process_gtk_subelem(sm, parse.gtk, parse.gtk_len) < 0)
+ return -1;
+
+diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
+index 41f371f..56f88dc 100644
+--- a/src/rsn_supp/wpa_i.h
++++ b/src/rsn_supp/wpa_i.h
+@@ -128,6 +128,7 @@ struct wpa_sm {
+ size_t r0kh_id_len;
+ u8 r1kh_id[FT_R1KH_ID_LEN];
+ int ft_completed;
++ int ft_reassoc_completed;
+ int over_the_ds_in_progress;
+ u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
+ int set_ptk_after_assoc;
+--
+2.7.4
+
diff --git a/system/wpa_supplicant/wpa_cli.sh b/system/wpa_supplicant/wpa_cli.sh
new file mode 100644
index 000000000..0a5a6cc03
--- /dev/null
+++ b/system/wpa_supplicant/wpa_cli.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Distributed under the terms of the BSD License.
+# Copyright (c) 2015 Sören Tempel <soeren+alpine@soeren-tempel.net>
+
+IFUP="/sbin/ifup"
+IFDOWN="/sbin/ifdown"
+
+if [ -z "${1}" -o -z "${2}" ]; then
+ logger -t wpa_cli "this script should be called from wpa_cli(8)"
+ exit 1
+elif ! [ -x "${IFUP}" -a -x "${IFDOWN}" ]; then
+ logger -t wpa_cli "${IFUP} or ${IFDOWN} doesn't exist"
+ exit 1
+fi
+
+IFNAME="${1}"
+ACTION="${2}"
+
+EXEC=""
+case "${ACTION}" in
+ CONNECTED)
+ EXEC="${IFUP}"
+ ;;
+ DISCONNECTED)
+ EXEC="${IFDOWN}"
+ ;;
+ *)
+ logger -t wpa_cli "unknown action '${ACTION}'"
+ exit 1
+esac
+
+logger -t wpa_cli "interface ${IFNAME} ${ACTION}"
+${EXEC} "${IFNAME}" || logger -t wpa_cli "executing '${EXEC}' failed"
diff --git a/system/wpa_supplicant/wpa_supplicant.confd b/system/wpa_supplicant/wpa_supplicant.confd
new file mode 100644
index 000000000..104b9dc5d
--- /dev/null
+++ b/system/wpa_supplicant/wpa_supplicant.confd
@@ -0,0 +1,6 @@
+# conf.d file for wpa_supplicant
+#
+# Please check man 8 wpa_supplicant for more information about the options
+# wpa_supplicant accepts.
+#
+wpa_supplicant_args=""
diff --git a/system/wpa_supplicant/wpa_supplicant.initd b/system/wpa_supplicant/wpa_supplicant.initd
new file mode 100644
index 000000000..988b267d1
--- /dev/null
+++ b/system/wpa_supplicant/wpa_supplicant.initd
@@ -0,0 +1,53 @@
+#!/sbin/openrc-run
+# Copyright (c) 2009 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+command=/sbin/wpa_supplicant
+: ${wpa_supplicant_conf:=/etc/wpa_supplicant/wpa_supplicant.conf}
+wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
+command_args="$wpa_supplicant_args -B -c$wpa_supplicant_conf $wpa_supplicant_if"
+name="WPA Supplicant Daemon"
+
+depend()
+{
+ need localmount
+ use logger dbus
+ after bootmisc modules
+ before dns dhcpcd net
+ keyword -shutdown
+}
+
+find_wireless()
+{
+ local iface=
+ for iface in /sys/class/net/*; do
+ if [ -e "$iface"/wireless -o -e "$iface"/phy80211 ]; then
+ echo "${iface##*/}"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+append_wireless()
+{
+ local iface= i=
+
+ iface=$(find_wireless)
+ if [ -n "$iface" ]; then
+ for i in $iface; do
+ command_args="$command_args -i$i"
+ done
+ else
+ eerror "Could not find a wireless interface"
+ fi
+}
+
+start_pre()
+{
+ case " $command_args" in
+ *" -i"*) ;;
+ *) append_wireless;;
+ esac
+}
diff --git a/system/xf86-video-ati/APKBUILD b/system/xf86-video-ati/APKBUILD
new file mode 100644
index 000000000..b5d128d60
--- /dev/null
+++ b/system/xf86-video-ati/APKBUILD
@@ -0,0 +1,36 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=xf86-video-ati
+pkgver=18.0.1
+pkgrel=0
+pkgdesc="ATI video driver"
+url="http://xorg.freedesktop.org/"
+arch="all"
+license="MIT"
+subpackages="$pkgname-doc"
+depends="mesa-dri-ati"
+makedepends="xorg-server-dev libxi-dev fontsproto randrproto util-macros
+ videoproto renderproto libdrm-dev xf86driproto glproto mesa-dev
+ xineramaproto eudev-dev pixman-dev"
+options="!check"
+source="http://www.x.org/releases/individual/driver/$pkgname-$pkgver.tar.bz2"
+builddir="$srcdir"/$pkgname-$pkgver
+
+build() {
+ cd "$builddir"
+ export LDFLAGS="$LDFLAGS -Wl,-z,lazy"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --enable-glamor
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
+}
+
+sha512sums="b468a78503a596bbf71a1b91b231ce1fa32908f619ff2dfe249352d046696a3641f2a9ff065e32545fff77100134b4b237591215e78ef885b6509d6b16112d14 xf86-video-ati-18.0.1.tar.bz2"
diff --git a/system/zsh/APKBUILD b/system/zsh/APKBUILD
new file mode 100644
index 000000000..3672a0445
--- /dev/null
+++ b/system/zsh/APKBUILD
@@ -0,0 +1,160 @@
+# Contributor: <kalonji@gmail.com>
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=zsh
+pkgver=5.4.1
+pkgrel=1
+pkgdesc="A very advanced and programmable command interpreter (shell)"
+url="http://www.zsh.org/"
+arch="all"
+license="BSD"
+depends="debianutils" # add-shell
+makedepends_host="ncurses-dev pcre-dev"
+install="zsh.post-install zsh.post-upgrade zsh.pre-deinstall"
+source="http://www.zsh.org/pub/$pkgname-$pkgver.tar.gz
+ zprofile
+ "
+subpackages="$pkgname-doc $pkgname-calendar::noarch $pkgname-vcs::noarch"
+[ "$CBUILD" != "$CHOST" ] || subpackages="$subpackages $pkgname-zftp"
+builddir="$srcdir/$pkgname-$pkgver"
+
+_libdir="usr/lib/zsh/$pkgver"
+_sharedir="usr/share/zsh/$pkgver"
+
+# Move some bigger completion files to subpackages.
+_comps="android-tools:Unix/_adb
+ bzr:Unix/_bzr
+ cvs:Unix/_cvs
+ gcc:Unix/_gcc
+ git:Unix/_git
+ graphicsmagick:Unix/_graphicsmagick
+ imagemagick:Unix/_imagemagick
+ lynx:Unix/_lynx
+ mercurial:Unix/_hg
+ rsync:Unix/_rsync
+ subversion:Unix/_subversion
+ tmux:Unix/_tmux
+ zfs:Unix/_zfs*:Unix/_zpool"
+for _i in $_comps; do
+ subpackages="$subpackages ${_i%%:*}-zsh-completion:_completion:noarch"
+done
+
+prepare() {
+ cd "$builddir"
+
+ default_prepare
+ update_config_sub
+
+ # Remove completions for other systems.
+ cd Completion
+ rm -Rf AIX BSD Cygwin Darwin Debian Mandriva Redhat Solaris openSUSE
+
+ # Remove completions for programs that are not available on Alpine
+ # (just to decrease size of the package).
+ cd Unix/Command
+ rm -f _aap _apm _baz _bittorrent _bpython _ccal _cdcd _chkconfig _clay \
+ _cowsay _cplay _cssh _darcs _devtodo _dict _dsh _elfdump _elm \
+ _enscript _finger _flasher _fsh _gnupod _guilt _initctl _lzop \
+ _mencal _module _monotone _moosic _mysqldiff _nkf \
+ _pack _perforce _pine _pkgadd _pkginfo _pkgrm _prcs \
+ _quilt _raggle _rcs _rlogin _rubber _sablotron _sisu _socket \
+ _stgit _surfraw _tardy _tin _tla _topgit _totd _twidge \
+ _unace _unison _units _uzbl _vcsh _vux _wiggle _xmms2 _yodl
+ cd ../../Linux/Command
+ rm -f _mondo _tpb _tpconfig _uml _vserver
+ cd ../../X/Command
+ rm -f _acroread _dcop _gnome-gv _gqview _gv _kfmclient _matlab \
+ _nautilus _netscape _qiv _vnc _xfig _xloadimage \
+ _xournal _xv _xwit
+}
+
+build() {
+ cd "$builddir"
+
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --bindir=/bin \
+ --enable-etcdir=/etc/zsh \
+ --enable-multibyte \
+ --enable-pcre \
+ --enable-function-subdirs \
+ --enable-zsh-secure-free \
+ --sysconfdir=/etc \
+ --with-tcsetpgrp \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info
+ make
+}
+
+check() {
+ cd "$builddir"
+ # Does not work with musl due to UTF-8
+ rm "$builddir"/Test/A03quoting.ztst
+ # Does not work with musl due to locale
+ rm "$builddir"/Test/B03print.ztst
+ # Not guaranteed to work portably (requires atime)
+ rm "$builddir"/Test/C02cond.ztst
+ # PPC?
+ rm "$builddir"/Test/V09datetime.ztst
+ make test
+}
+
+package() {
+ cd "$builddir"
+
+ make DESTDIR="$pkgdir" install
+ install -Dm644 "$srcdir"/zprofile "$pkgdir"/etc/zsh/zprofile
+}
+
+doc() {
+ default_doc
+ _submv $_sharedir/help
+}
+
+calendar() {
+ pkgdesc="Calendar Function System for ZSH"
+ depends="$pkgname"
+
+ _submv $_sharedir/functions/Calendar
+}
+
+vcs() {
+ pkgdesc="Version Control Information module for ZSH (vcs_info)"
+ depends="$pkgname"
+
+ _submv $_sharedir/functions/VCS_Info
+}
+
+zftp() {
+ pkgdesc="Zftp Function System for ZSH"
+ depends="$pkgname"
+
+ _submv $_libdir/zsh/zftp.so
+ _submv $_sharedir/functions/Zftp
+}
+
+_completion() {
+ local name="${subpkgname%-zsh-completion}"
+ pkgdesc="Zsh completions for $name"
+ depends="$pkgname"
+ install_if="$pkgname=$pkgver-r$pkgrel $name"
+
+ local files="$(printf '%s\n' $_comps \
+ | sed -En "s|^$name:(.*)|\1|p" | tr : ' ')"
+ test -n "$files" || { echo "$name not found in \$_comps" >&2; return 1; }
+
+ local f; for f in $files; do
+ _submv $_sharedir/functions/Completion/$f
+ done
+}
+
+_submv() {
+ local path="$1"
+ mkdir -p "$subpkgdir"/${path%/*}
+ mv "$pkgdir"/$path "$subpkgdir"/${path%/*}/
+}
+
+sha512sums="56a83b4a8ae97656ea5a2d7b15632a288017552c276ab306be6d242d83dc92ce871330aeb46a0e8a49e9f30f6bff32e3c956c62e5ce19361e52ea0799cb59f50 zsh-5.4.1.tar.gz
+cbc184f0c4af1441eaad2a3f7255be9941c64bd5a05977aea5ca3a0a11a3d121c34c1fc9e633465eda087cd196dabf9591082117bbb42cc6e6bc9352ec2c207d zprofile"
diff --git a/system/zsh/zprofile b/system/zsh/zprofile
new file mode 100644
index 000000000..363d4863c
--- /dev/null
+++ b/system/zsh/zprofile
@@ -0,0 +1,24 @@
+#
+# /etc/zprofile and ~/.zprofile are run for login shells
+#
+
+export PATH="$PATH:$HOME/bin"
+
+_src_etc_profile()
+{
+ # Make /etc/profile happier, and have possible ~/.zshenv options like
+ # NOMATCH ignored.
+ #
+ emulate -L ksh
+
+ # source profile
+ if [ -f /etc/profile ]; then
+ source /etc/profile
+ fi
+}
+_src_etc_profile
+
+export EDITOR=${EDITOR:-/usr/bin/vim}
+export PAGER=${PAGER:-/usr/bin/less}
+
+unset -f _src_etc_profile
diff --git a/system/zsh/zsh.post-install b/system/zsh/zsh.post-install
new file mode 100644
index 000000000..d2399cd8b
--- /dev/null
+++ b/system/zsh/zsh.post-install
@@ -0,0 +1,3 @@
+#!/bin/sh
+add-shell '/bin/zsh'
+exit 0
diff --git a/system/zsh/zsh.post-upgrade b/system/zsh/zsh.post-upgrade
new file mode 100644
index 000000000..1b42f8258
--- /dev/null
+++ b/system/zsh/zsh.post-upgrade
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+add-shell '/bin/zsh'
+
+ver_new="$1"
+ver_old="$2"
+
+if [ "$(apk version -t "$ver_old" "5.2-r2")" = "<" ]; then
+ cat <<-EOF
+ *
+ * Some modules has been moved into subpackages:
+ * zsh-calendar calendar function system
+ * zsh-vcs version control information (vcs_info)
+ * zsh-zftp zftp function system
+ *
+ EOF
+fi
+
+exit 0
diff --git a/system/zsh/zsh.pre-deinstall b/system/zsh/zsh.pre-deinstall
new file mode 100644
index 000000000..215f9a2e8
--- /dev/null
+++ b/system/zsh/zsh.pre-deinstall
@@ -0,0 +1,3 @@
+#!/bin/sh
+remove-shell '/bin/zsh'
+exit 0