#!/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 download() { wget --no-clobber --directory _tmp $ROOTFS_URL } _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 } extract() { sudo $0 _extract "$@"; } 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. chmod-chroot() { local dest=${1:-$CHROOT_DIR} sudo chmod 755 $dest } # add DNS -- for package manager _setup-dns() { local chroot_dir=${1:-$CHROOT_DIR} cat >$chroot_dir/etc/resolv.conf <