#!/bin/bash # # Make an Alpine Linux chroot. # # Use Cases: # - Test if the oil tarball can be configured/compiled/installed inside a # minimal Linux distro. # - TODO: Test BUILDING this distro, by running their ash/bash scripts. # - Should symlink BOTH /bin/sh and /bin/bash to osh! # # Usage: # ./alpine.sh set -o nounset set -o pipefail set -o errexit readonly ROOTFS_URL='http://dl-cdn.alpinelinux.org/alpine/v3.6/releases/x86_64/alpine-minirootfs-3.6.2-x86_64.tar.gz' readonly CHROOT_DIR=_chroot/alpine1 readonly DISTRO_BUILD_CHROOT_DIR=_chroot/alpine-distro-build proc download { wget --no-clobber --directory _tmp $ROOTFS_URL } proc _extract { local dest=$(1:-$CHROOT_DIR) local tarball=_tmp/$[basename $ROOTFS_URL] mkdir -p $dest # Must be run as root tar --extract --gzip --verbose --directory $dest < $tarball } proc extract { sudo $0 _extract @ARGV; } proc extract-distro-build { sudo $0 _extract $DISTRO_BUILD_CHROOT_DIR; } # Without this, you can't 'su myusername'. It won't be able to execute bash. proc chmod-chroot { local dest=$(1:-$CHROOT_DIR) sudo chmod 755 $dest } # add DNS -- for package manager proc _setup-dns { local chroot_dir=$(1:-$CHROOT_DIR) cat >$chroot_dir/etc/resolv.conf <