Skip to content

Commit

Permalink
create different packages for linux and portable
Browse files Browse the repository at this point in the history
  • Loading branch information
glerchundi committed Mar 3, 2015
1 parent d924516 commit 5be040d
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ RUN chmod +x /build-latest
ENV OVERLAY_ROOTFS_PATH /overlay-rootfs
COPY overlay-rootfs $OVERLAY_ROOTFS_PATH

ENTRYPOINT [ "/build-latest" ]
CMD [ "/build-latest" ]
112 changes: 71 additions & 41 deletions rootfs/build-latest
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,86 @@
##

OVERLAY_ROOTFS_PATH=${1:-/overlay-rootfs}
RELEASE_VERSION=${2:-1.3.0}
RELEASE_VERSION=${2:-1.4.0}

outputs=(
linux
portable
)

get_packages_with_versions_from_manifest() {
# manifest
manifest=$1

# skarnet versions manifest
curl -R -L \
-o /tmp/manifest.txt \
https://github.com/glerchundi/container-skarnet-builder/releases/download/v$RELEASE_VERSION/$manifest

# parse manifest into s6 associative array
versions=()
while read -r line
do
key=`echo "${line}" | cut -d"=" -f1`
value=`echo "${line}" | cut -d"=" -f2`
if [[ ! -z "${key}" && ! -z "${value}" ]]; then
versions+=("${key}-${value}")
fi
done < /tmp/manifest.txt

# delete manifest
rm /tmp/manifest.txt

echo ${versions[@]}
}

##
## OVERLAY
## DOWNLOAD PACKAGES
##

# create overlay folder
mkdir -p $OVERLAY_ROOTFS_PATH
# destination folder
cd /tmp

# fix-attrs
curl -R -L \
-o $OVERLAY_ROOTFS_PATH/usr/bin/fix-attrs \
https://github.com/glerchundi/fix-attrs/releases/download/v0.4.0/fix-attrs-0.4.0-linux-amd64

# skarnet versions manifest
curl -R -L \
-o /tmp/manifest.txt \
https://github.com/glerchundi/container-s6-builder/releases/download/v$RELEASE_VERSION/manifest.txt

# parse manifest into s6 associative array
declare -A versions
while read -r line
do
key=`echo "${line}" | cut -d"=" -f1`
value=`echo "${line}" | cut -d"=" -f2`
if [[ ! -z "${key}" && ! -z "${value}" ]]; then
versions[${key}]=${value}
fi
done < /tmp/manifest.txt

# iterate over manifest and install required binaries
for i in "${!versions[@]}"
do
url=https://github.com/glerchundi/container-s6-builder/releases/download/v$RELEASE_VERSION/$i-${versions[$i]}-linux-amd64-bin.tar.gz
curl -R -L -o /tmp/bin.tar.gz $url
tar xvfz /tmp/bin.tar.gz -C $OVERLAY_ROOTFS_PATH
packages=($(get_packages_with_versions_from_manifest "manifest.txt"))
for package in "${packages[@]}"; do
file=$package-linux-amd64-bin.tar.gz
curl -R -L -O https://github.com/glerchundi/container-s6-builder/releases/download/v$RELEASE_VERSION/$file
done

# fix-attrs
curl -R -L -o /tmp/fix-attrs https://github.com/glerchundi/fix-attrs/releases/download/v0.4.0/fix-attrs-0.4.0-linux-amd64

##
## FIX PERMS
## OVERLAYS
##

chmod +x $OVERLAY_ROOTFS_PATH/init \
$OVERLAY_ROOTFS_PATH/etc/s6/.s6-svscan/finish \
$OVERLAY_ROOTFS_PATH/etc/s6/.s6-init/init-stage* \
$OVERLAY_ROOTFS_PATH/usr/bin/fix-attrs
for output in "${outputs[@]}"
do
# overlay path
overlaypath="$OVERLAY_ROOTFS_PATH-$output"

##
## DIST!
##
# create overlay folder
mkdir -p $overlaypath

# skarnet versions manifest
packages=($(get_packages_with_versions_from_manifest "manifest-$output.txt"))

mkdir -p /dist
tar -zcvf /dist/s6-overlay-$RELEASE_VERSION-linux-amd64.tar.gz -C $OVERLAY_ROOTFS_PATH ./
# install required binaries for this concrete output
for package in "${packages[@]}"
do
tar xvfz /tmp/$package-linux-amd64-bin.tar.gz -C $overlaypath
done

# fix perms
chmod +x $overlaypath/init \
$overlaypath/etc/s6/.s6-svscan/finish \
$overlaypath/etc/s6/.s6-init/init-stage* \
$overlaypath/usr/bin/fix-attrs

##
## DIST!
##

mkdir -p /dist
tar -zcvf /dist/s6-overlay-$RELEASE_VERSION-$output-amd64.tar.gz -C $overlaypath ./
done

0 comments on commit 5be040d

Please sign in to comment.