Permalink
Browse files

Make another alpine chroot for testing abuild scripts.

  • Loading branch information...
Andy Chu
Andy Chu committed Sep 3, 2017
1 parent 8e43366 commit 14bfa7e853b9d8e94611a25f6af075af61a01ba2
Showing with 47 additions and 7 deletions.
  1. +1 −0 scripts/release.sh
  2. +46 −7 test/alpine.sh
View
@@ -30,6 +30,7 @@ log() {
# osh-quick-ref.html
# test/ # results
# spec/
# machine-lisa/
# unit/
# wild/
# gold/
View
@@ -1,5 +1,13 @@
#!/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 <function name>
@@ -10,49 +18,80 @@ 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)
local dest=$CHROOT_DIR
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; }
# add DNS -- for package manager
_setup-dns() {
cat >$CHROOT_DIR/etc/resolv.conf <<EOF
local chroot_dir=${1:-$CHROOT_DIR}
cat >$chroot_dir/etc/resolv.conf <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
}
setup-dns() { sudo $0 _setup-dns; }
setup-dns() { sudo $0 _setup-dns "$@"; }
# 106 MiB as of 7/7/2017.
add-oil-build-deps() {
sudo chroot $CHROOT_DIR /bin/sh <<EOF
local chroot_dir=${1:-$CHROOT_DIR}
sudo chroot $chroot_dir /bin/sh <<EOF
apk update
apk add bash make gcc musl-dev
EOF
}
# alpine-sdk scripts are /bin/sh busybox scripts!
# Executing busybox-1.26.2-r5.trigger
# Executing ca-certificates-20161130-r2.trigger
# OK: 195 MiB in 72 packages
#
# Hm they still have triggers...
# 72 packages. bash/readline are installed!
add-alpine-sdk() {
local chroot_dir=${1:-$DISTRO_BUILD_CHROOT_DIR}
sudo chroot $chroot_dir /bin/sh <<EOF
apk update
apk add bash alpine-sdk
EOF
}
list-packages() {
local chroot_dir=${1:-$DISTRO_BUILD_CHROOT_DIR}
sudo chroot $chroot_dir apk info
}
destroy-chroot() {
sudo rm -r -rf $CHROOT_DIR
local chroot_dir=${1:-$CHROOT_DIR}
sudo rm -r -rf $chroot_dir
}
# Interactive /bin/sh.
enter-chroot() {
sudo chroot $CHROOT_DIR "$@"
local chroot_dir=${1:-$CHROOT_DIR}
shift
sudo chroot $chroot_dir "$@"
}
interactive() {
enter-chroot /bin/sh
local chroot_dir=${1:-$CHROOT_DIR}
enter-chroot $chroot_dir /bin/sh
}
readonly OIL_VERSION=$(head -n 1 oil-version.txt)

0 comments on commit 14bfa7e

Please sign in to comment.