commit 5427ff5cec0451ac48b67485f4ad2a8c9e62bce8 Author: sleirsgoevy Date: Sun Dec 10 20:06:11 2017 +0300 Initial commit diff --git a/bin/compile b/bin/compile new file mode 100755 index 0000000..5bbe8bb --- /dev/null +++ b/bin/compile @@ -0,0 +1,29 @@ +#!/bin/bash + +export APP="$(realpath "$1")" +export CACHE="$2" +export ENV="$3" +export BP="$(realpath "$(dirname "$0")/..")" +export PATH="$PATH:$BP/bin" + +. "$BP/bin/read_config" + +mkdir "$CACHE/app_root" +find "$APP" ! -path "$APP" -maxdepth 1 -exec mv "{}" "$CACHE/app_root" \; +mv "$CACHE/app_root" "$APP/root" + +tar -xvzf "$BP/uml.tar.gz" -C "$APP" +mkdir "$APP/tmp" +mkdir "$APP/shadow_root" +mkdir "$APP/shadow_mount" +dd if=/dev/zero of="$APP/shadow_root.img" bs=1048576 count="$FS_SIZE" +/sbin/mke2fs "$APP/shadow_root.img" +wget http://ftp.debian.org/debian/pool/main/c/criu/criu_3.6-2_amd64.deb -O "$APP/criu.deb" +echo $MEM +uml_run "rm /var/lib/dpkg/lock /var/lib/dpkg/triggers/Lock; rm -r /var/cache/apt/archives/*; umount /app; dpkg -i '$APP/criu.deb'; apt-get -f install; mount --bind '$APP/root' /app; bash /app/install.sh" + +mkdir "$APP/.profile.d" +cp "$BP/bin/read_config" "$APP/.profile.d" + +cp "$APP/root/Procfile" "$APP/Procfile" +fix_procfile "$APP/Procfile" diff --git a/bin/detect b/bin/detect new file mode 100755 index 0000000..23c5d30 --- /dev/null +++ b/bin/detect @@ -0,0 +1,10 @@ +#!/bin/bash + +APP="$1" + +if test -f "$APP/config.sh" && test -f "$APP/install.sh" +then echo "UML" +exit 0 +fi + +exit 1 diff --git a/bin/fix_procfile b/bin/fix_procfile new file mode 100755 index 0000000..a3d0204 --- /dev/null +++ b/bin/fix_procfile @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import sys, shlex + +procfile_path = sys.argv[1] + +lines = [] + +with open(procfile_path) as file: + for line in file: + if ":" in line: + type, cmd = line.split(':', 1) + lines.append(type+': /app/uml/uml_run '+shlex.quote('cd /app; '+cmd.strip())+'\n') + else: + lines.append(line) + +with open(procfile_path, 'w') as file: + file.writelines(lines) diff --git a/bin/read_config b/bin/read_config new file mode 100644 index 0000000..d497d40 --- /dev/null +++ b/bin/read_config @@ -0,0 +1,11 @@ +FS_SIZE=512 +MEM=1024 + +if [ "x$APP" == x ] +then export APP=/app +fi + +. "$APP/config.sh" + +export FS_SIZE="$FS_SIZE" +export MEM="$MEM" diff --git a/bin/uml_run b/bin/uml_run new file mode 100755 index 0000000..bce19e3 --- /dev/null +++ b/bin/uml_run @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "$1" > "$APP/uml_command" +TEMP="$APP" "$APP/uml/uml" root=/dev/root rw rootflags=/ rootfstype=hostfs init="$APP/uml/init" mem=${MEM}M quiet app="$APP" +rm "$APP/uml_command" diff --git a/uml.tar.gz b/uml.tar.gz new file mode 100644 index 0000000..c707a2e Binary files /dev/null and b/uml.tar.gz differ