Skip to content

Commit

Permalink
allow setting timezone in builder and set to UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
andyshinn committed Feb 23, 2015
1 parent 07f3a9a commit 325107d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ build() {
docker run --name "$build" "$BUILD_IMAGE" \
-s \
-c \
-t \
-r "$release" \
-m "$MIRROR"
docker cp "$build":/rootfs.tar.xz "./$version_dir/"
Expand Down
24 changes: 22 additions & 2 deletions builder/scripts/mkimage-alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set -e
}

usage() {
printf >&2 '%s: [-r release] [-m mirror] [-s] [-e] [-c]\n' "$0"
printf >&2 '%s: [-r release] [-m mirror] [-s] [-e] [-c] [-t]\n' "$0"
exit 1
}

Expand All @@ -39,13 +39,29 @@ mkbase() {
--root $ROOTFS --initdb add alpine-base
}

timezone() {
local timezone="${1:-UTC}"

$TMP/sbin/apk.static \
--repository $REPO \
--update-cache \
--allow-untrusted \
--root $ROOTFS \
--initdb add tzdata
cp -a "${ROOTFS}/usr/share/zoneinfo/${timezone}" "${ROOTFS}/etc/localtime"
$TMP/sbin/apk.static \
--root $ROOTFS \
del tzdata
}

conf() {
printf '%s\n' $REPO > $ROOTFS/etc/apk/repositories
[ $REPO_EXTRA -eq 1 ] && {
[ $REL = "edge" ] || printf '%s\n' "@edge $MIRROR/edge/main" >> $ROOTFS/etc/apk/repositories
printf '%s\n' "@testing $MIRROR/edge/testing" >> $ROOTFS/etc/apk/repositories
}
[ $ADD_APK_SCRIPT -eq 1 ] && cp /apk-install $ROOTFS/usr/sbin/apk-install
[ $ADD_TIMEZONE -eq 1 ] && timezone
rm -f $ROOTFS/var/cache/apk/*
}

Expand All @@ -55,7 +71,7 @@ save() {
tar --numeric-owner -C $ROOTFS -c . | xz > rootfs.tar.xz
}

while getopts "hr:m:sec" opt; do
while getopts "hr:m:sect" opt; do
case $opt in
r)
REL=$OPTARG
Expand All @@ -69,6 +85,9 @@ while getopts "hr:m:sec" opt; do
e)
REPO_EXTRA=1
;;
t)
ADD_TIMEZONE=1
;;
c)
ADD_APK_SCRIPT=1
;;
Expand All @@ -82,6 +101,7 @@ REL=${REL:-edge}
MIRROR=${MIRROR:-http://nl.alpinelinux.org/alpine}
SAVE=${SAVE:-0}
ADD_APK_SCRIPT=${ADD_APK_SCRIPT:-0}
ADD_TIMEZONE=${ADD_TIMEZONE:-0}
REPO=$MIRROR/$REL/main
REPO_EXTRA=${REPO_EXTRA:-0}
ARCH=$(uname -m)
Expand Down

0 comments on commit 325107d

Please sign in to comment.