Created
May 16, 2018 19:53
-
-
Save therealkenc/10b2f8dd5c7a8b08e74a4f4a889be3dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build static bsdtar linked against musl in Ubuntu 16.04 on WSL | |
mkdir bsdtarbuild && cd bsdtarbuild | |
sudo su | |
ALPINE_MIRROR=http://dl-cdn.alpinelinux.org/alpine | |
mkdir alpine-root | |
ALPINE_ROOT=$PWD/alpine-root | |
ALPINE_APKTOOLS=apk-tools-static-2.9.1-r0.apk # note this is a moving target | |
wget -q $ALPINE_MIRROR/latest-stable/main/x86_64/$ALPINE_APKTOOLS | |
tar xf $ALPINE_APKTOOLS | |
./sbin/apk.static -X $ALPINE_MIRROR/latest-stable/main -U --allow-untrusted --root $ALPINE_ROOT --initdb add alpine-base | |
cd $ALPINE_ROOT | |
mount -o bind /dev ./dev | |
mount -t proc none ./proc | |
mount -t sysfs none ./sys | |
echo "$ALPINE_MIRROR/latest-stable/main" > ./etc/apk/repositories | |
echo "$ALPINE_MIRROR/latest-stable/community" >> ./etc/apk/repositories | |
cp -p /etc/resolv.conf etc/ | |
cd .. | |
chroot ./alpine-root /bin/sh -l | |
apk update | |
apk add alpine-sdk bash util-linux strace file | |
adduser -D build | |
su build | |
cd ~ | |
echo "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> .bashrc | |
echo "export PS1='(alpine) \u@\h:\w$ '" > .bashrc | |
exec /bin/bash | |
wget https://www.libarchive.org/downloads/libarchive-3.3.2.tar.gz | |
tar xf libarchive-3.3.2.tar.gz | |
cd libarchive-3.3.2 | |
./configure LDFLAGS='--static' --enable-bsdtar=static --disable-shared | |
make -j4 | |
# meh, I never liked libtool anyway... | |
ld -static -o bsdtar tar/bsdtar-bsdtar.o tar/bsdtar-cmdline.o tar/bsdtar-creation_set.o \ | |
tar/bsdtar-read.o tar/bsdtar-subst.o tar/bsdtar-util.o tar/bsdtar-write.o \ | |
/usr/lib/crt1.o .libs/libarchive.a .libs/libarchive_fe.a /usr/lib/libc.a | |
exit # out of build user | |
exit # out of chroot | |
umount ./alpine-root/dev | |
umount ./alpine-root/proc | |
umount ./alpine-root/sys | |
exit # out of sudo su | |
cp -a alpine-root/home/build/libarchive-3.3.2/bsdtar . | |
./bsdtar --version | |
file ./bsdtar | |
# for posterity... | |
sudo ./bsdtar czvpf alpine-root.tgz alpine-root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment