Updated to the last available mkimage.

This commit is contained in:
cyteen 2020-11-05 23:02:23 +00:00
parent 39a4ede453
commit 755c0b0a42
6 changed files with 150 additions and 47 deletions

View File

@ -17,6 +17,12 @@ Sets the repo to: "devuan"
Sets the mirror to: "pkgmaster.devian.org/merged"
Sets the include: "inetutils-ping,iproute2"
Calls docker-brew-debian/update.sh which calls ../bin/mkimage.sh with:
mkimage.sh --dir . --compression xz debootstrap --variant=minbase --components=main --include=inetutils-ping,iproute2 --force-check-gpg jessie http://pkgmaster.devuan.org/merged
which calls ../bin/mkimage/debootstrap
change-mkimage-link.sh
When we pulling in from upstream the symlink pointed to the maintainers home directory so we had to change the symlink to the local copy of mkimage.sh.
@ -25,8 +31,16 @@ Since the project has been archived we have those files in this repo under bin.
clean-devuan.sh
Clears docker-brew-devuan latest repo mirror and reduces components to only main
copy-in-dockerfiles.sh
copy-out-dockerfiles.sh
fetch-bfg.sh
git-prune.files
We want to add the dbootstrap for foreign archictectures with:
sudo debootstrap --foreign --arch=armhf jessie jessie-armhf
Note the --foreign option that prevents debootstrap from running the second stage as this needs to be run in a chroot and thus cannot run without further magic on our Intel development machine.

View File

@ -5,13 +5,12 @@ mkimg="$(basename "$0")"
usage() {
echo >&2 "usage: $mkimg [-d dir] [-t tag] [--compression algo| --no-compression] script [script-args]"
echo >&2 " ie: $mkimg -t someuser/debian debootstrap --variant=minbase jessie"
echo >&2 " ie: $mkimg -t someuser/debian debootstrap --variant=minbase buster"
echo >&2 " $mkimg -t someuser/ubuntu debootstrap --include=ubuntu-minimal --components=main,universe trusty"
echo >&2 " $mkimg -t someuser/busybox busybox-static"
echo >&2 " $mkimg -t someuser/centos:5 rinse --distribution centos-5"
echo >&2 " $mkimg -t someuser/mageia:4 mageia-urpmi --version=4"
echo >&2 " $mkimg -t someuser/mageia:4 mageia-urpmi --version=4 --mirror=http://somemirror/"
echo >&2 " $mkimg -t someuser/solaris solaris"
exit 1
}
@ -20,13 +19,6 @@ scriptDir="$(dirname "$(readlink -f "$BASH_SOURCE")")/mkimage"
os=
os=$(uname -o)
# set up path to gnu tools if solaris
[[ $os == "Solaris" ]] && export PATH=/usr/gnu/bin:$PATH
# TODO check for gnu-tar, gnu-getopt
# TODO requires root/sudo due to some pkg operations. sigh.
[[ $os == "Solaris" && $EUID != "0" ]] && echo >&2 "image create on Solaris requires superuser privilege"
optTemp=$(getopt --options '+d:t:c:hC' --longoptions 'dir:,tag:,compression:,no-compression,help' --name "$mkimg" -- "$@")
eval set -- "$optTemp"
unset optTemp
@ -36,12 +28,27 @@ tag=
compression="auto"
while true; do
case "$1" in
-d|--dir) dir="$2" ; shift 2 ;;
-t|--tag) tag="$2" ; shift 2 ;;
--compression) compression="$2" ; shift 2 ;;
--no-compression) compression="none" ; shift 1 ;;
-h|--help) usage ;;
--) shift ; break ;;
-d | --dir)
dir="$2"
shift 2
;;
-t | --tag)
tag="$2"
shift 2
;;
--compression)
compression="$2"
shift 2
;;
--no-compression)
compression="none"
shift 1
;;
-h | --help) usage ;;
--)
shift
break
;;
esac
done
@ -49,9 +56,8 @@ script="$1"
[ "$script" ] || usage
shift
if [ "$compression" == 'auto' ] || [ -z "$compression" ]
then
compression='xz'
if [ "$compression" == 'auto' ] || [ -z "$compression" ]; then
compression='xz'
fi
[ "$compression" == 'none' ] && compression=''
@ -76,7 +82,10 @@ if [ -z "$dir" ]; then
fi
rootfsDir="$dir/rootfs"
( set -x; mkdir -p "$rootfsDir" )
(
set -x
mkdir -p "$rootfsDir"
)
# pass all remaining arguments to $script
"$scriptDir/$script" "$rootfsDir" "$@"
@ -87,7 +96,7 @@ mkdir -p "$rootfsDir/dev" "$rootfsDir/proc"
# make sure /etc/resolv.conf has something useful in it
mkdir -p "$rootfsDir/etc"
cat > "$rootfsDir/etc/resolv.conf" <<'EOF'
cat > "$rootfsDir/etc/resolv.conf" << 'EOF'
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
@ -101,7 +110,7 @@ touch "$tarFile"
)
echo >&2 "+ cat > '$dir/Dockerfile'"
cat > "$dir/Dockerfile" <<EOF
cat > "$dir/Dockerfile" << EOF
FROM scratch
ADD $(basename "$tarFile") /
EOF
@ -109,20 +118,35 @@ EOF
# if our generated image has a decent shell, let's set a default command
for shell in /bin/bash /usr/bin/fish /usr/bin/zsh /bin/sh; do
if [ -x "$rootfsDir/$shell" ]; then
( set -x; echo 'CMD ["'"$shell"'"]' >> "$dir/Dockerfile" )
(
set -x
echo 'CMD ["'"$shell"'"]' >> "$dir/Dockerfile"
)
break
fi
done
( set -x; rm -rf "$rootfsDir" )
(
set -x
rm -rf "$rootfsDir"
)
if [ "$tag" ]; then
( set -x; docker build -t "$tag" "$dir" )
(
set -x
docker build -t "$tag" "$dir"
)
elif [ "$delDir" ]; then
# if we didn't specify a tag and we're going to delete our dir, let's just build an untagged image so that we did _something_
( set -x; docker build "$dir" )
(
set -x
docker build "$dir"
)
fi
if [ "$delDir" ]; then
( set -x; rm -rf "$dir" )
(
set -x
rm -rf "$dir"
)
fi

View File

@ -4,7 +4,7 @@ set -e
rootfsDir="$1"
shift
busybox="$(which busybox 2>/dev/null || true)"
busybox="$(which busybox 2> /dev/null || true)"
if [ -z "$busybox" ]; then
echo >&2 'error: busybox: not found'
echo >&2 ' install it with your distribution "busybox-static" package'
@ -24,7 +24,7 @@ cp "$busybox" "$rootfsDir/bin/busybox"
cd "$rootfsDir"
IFS=$'\n'
modules=( $(bin/busybox --list-modules) )
modules=($(bin/busybox --list-modules))
unset IFS
for module in "${modules[@]}"; do

View File

@ -1,22 +1,47 @@
#!/usr/bin/env bash
set -e
mkimgdeb="$(basename "$0")"
mkimg="$(dirname "$0").sh"
usage() {
echo >&2 "usage: $mkimgdeb rootfsDir suite [debootstrap-args]"
echo >&2 " note: $mkimgdeb meant to be used from $mkimg"
exit 1
}
rootfsDir="$1"
if [ -z "$rootfsDir" ]; then
echo >&2 "error: rootfsDir is missing"
echo >&2
usage
fi
shift
# we have to do a little fancy footwork to make sure "rootfsDir" becomes the second non-option argument to debootstrap
before=()
while [ $# -gt 0 ] && [[ "$1" == -* ]]; do
before+=( "$1" )
before+=("$1")
shift
done
suite="$1"
if [ -z "$suite" ]; then
echo >&2 "error: suite is missing"
echo >&2
usage
fi
shift
# get path to "chroot" in our current PATH
chrootPath="$(type -P chroot)"
chrootPath="$(type -P chroot || :)"
if [ -z "$chrootPath" ]; then
echo >&2 "error: chroot not found. Are you root?"
echo >&2
usage
fi
rootfs_chroot() {
# "chroot" doesn't set PATH, so we need to set it explicitly to something our new debootstrap chroot can use appropriately!
@ -37,7 +62,7 @@ rootfs_chroot() {
# prevent init scripts from running during install/update
echo >&2 "+ echo exit 101 > '$rootfsDir/usr/sbin/policy-rc.d'"
cat > "$rootfsDir/usr/sbin/policy-rc.d" <<-'EOF'
cat > "$rootfsDir/usr/sbin/policy-rc.d" <<- 'EOF'
#!/bin/sh
# For most Docker users, "apt-get install" only happens during "docker build",
@ -57,7 +82,10 @@ chmod +x "$rootfsDir/usr/sbin/policy-rc.d"
)
# shrink a little, since apt makes us cache-fat (wheezy: ~157.5MB vs ~120MB)
( set -x; rootfs_chroot apt-get clean )
(
set -x
rootfs_chroot apt-get clean
)
# this file is one APT creates to make sure we don't "autoremove" our currently
# in-use kernel, which doesn't really apply to debootstraps/Docker images that
@ -68,7 +96,7 @@ rm -f "$rootfsDir/etc/apt/apt.conf.d/01autoremove-kernels"
if strings "$rootfsDir/usr/bin/dpkg" | grep -q unsafe-io; then
# force dpkg not to call sync() after package extraction (speeding up installs)
echo >&2 "+ echo force-unsafe-io > '$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup'"
cat > "$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup" <<-'EOF'
cat > "$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup" <<- 'EOF'
# For most Docker users, package installs happen during "docker build", which
# doesn't survive power loss and gets restarted clean afterwards anyhow, so
# this minor tweak gives us a nice speedup (much nicer on spinning disks,
@ -82,7 +110,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
# _keep_ us lean by effectively running "apt-get clean" after every install
aptGetClean='"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";'
echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-clean'"
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-clean" <<-EOF
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-clean" <<- EOF
# Since for most Docker users, package installs happen in "docker build" steps,
# they essentially become individual layers due to the way Docker handles
# layering, especially using CoW filesystems. What this means for us is that
@ -106,7 +134,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
# remove apt-cache translations for fast "apt-get update"
echo >&2 "+ echo Acquire::Languages 'none' > '$rootfsDir/etc/apt/apt.conf.d/docker-no-languages'"
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-no-languages" <<-'EOF'
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-no-languages" <<- 'EOF'
# In Docker, we don't often need the "Translations" files, so we're just wasting
# time and space by downloading them, and this inhibits that. For users that do
# need them, it's a simple matter to delete this file and "apt-get update". :)
@ -115,7 +143,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
EOF
echo >&2 "+ echo Acquire::GzipIndexes 'true' > '$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes'"
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes" <<-'EOF'
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-gzip-indexes" <<- 'EOF'
# Since Docker users using "RUN apt-get update && apt-get install -y ..." in
# their Dockerfiles don't go delete the lists files afterwards, we want them to
# be as small as possible on-disk, so we explicitly request "gz" versions and
@ -131,7 +159,7 @@ if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then
# update "autoremove" configuration to be aggressive about removing suggests deps that weren't manually installed
echo >&2 "+ echo Apt::AutoRemove::SuggestsImportant 'false' > '$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests'"
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests" <<-'EOF'
cat > "$rootfsDir/etc/apt/apt.conf.d/docker-autoremove-suggests" <<- 'EOF'
# Since Docker users are looking for the smallest possible final images, the
# following emerges as a very common pattern:
@ -168,7 +196,7 @@ if [ -z "$DONT_TOUCH_SOURCES_LIST" ]; then
case "$lsbDist" in
debian)
# updates and security!
if [ "$suite" != 'sid' -a "$suite" != 'unstable' ]; then
if curl -o /dev/null -s --head --location --fail "http://security.debian.org/dists/$suite/updates/main/binary-$(rootfs_chroot dpkg --print-architecture)/Packages.gz"; then
(
set -x
sed -i "
@ -193,12 +221,12 @@ if [ -z "$DONT_TOUCH_SOURCES_LIST" ]; then
elif [ "$suite" != 'ceres' -a "$suite" != 'unstable' ]; then
(
set -x
echo "deb http://auto.mirrors.devuan.org/merged $suite main" > "$rootfsDir/etc/apt/sources.list"
echo "deb-src http://auto.mirrors.devuan.org/merged $suite main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb http://auto.mirrors.devuan.org/merged $suite-updates main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb-src http://auto.mirrors.devuan.org/merged $suite-updates main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb http://auto.mirrors.devuan.org/merged $suite-security main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb-src http://auto.mirrors.devuan.org/merged $suite-security main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb http://deb.devuan.org/merged $suite main" > "$rootfsDir/etc/apt/sources.list"
echo "deb-src http://deb.devuan.org/merged $suite main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb http://deb.devuan.org/merged $suite-updates main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb-src http://deb.devuan.org/merged $suite-updates main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb http://deb.devuan.org/merged $suite-security main" >> "$rootfsDir/etc/apt/sources.list"
echo "deb-src http://deb.devuan.org/merged $suite-security main" >> "$rootfsDir/etc/apt/sources.list"
)
fi
;;

View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e
rootfsDir="$1"
shift
(
cd "$rootfsDir"
# effectively: febootstrap-minimize --keep-zoneinfo --keep-rpmdb --keep-services "$target"
# locales
rm -rf usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive}
# docs and man pages
rm -rf usr/share/{man,doc,info,gnome/help}
# cracklib
rm -rf usr/share/cracklib
# i18n
rm -rf usr/share/i18n
# yum cache
rm -rf var/cache/yum
mkdir -p --mode=0755 var/cache/yum
# sln
rm -rf sbin/sln
# ldconfig
#rm -rf sbin/ldconfig
rm -rf etc/ld.so.cache var/cache/ldconfig
mkdir -p --mode=0755 var/cache/ldconfig
)

View File

@ -20,9 +20,18 @@ installversion=
mirror=
while true; do
case "$1" in
-v|--version) installversion="$2" ; shift 2 ;;
-m|--mirror) mirror="$2" ; shift 2 ;;
--) shift ; break ;;
-v | --version)
installversion="$2"
shift 2
;;
-m | --mirror)
mirror="$2"
shift 2
;;
--)
shift
break
;;
esac
done