diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6a2991..cbb30c1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,25 +10,74 @@ variables: stages: - prepare - build - - torrent services: - docker:dind -before_script: - - docker info - - apk add --no-cache make openssh-client - dockerimage: stage: prepare + before_script: + - docker info + - apk add --no-cache make openssh-client script: - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + - docker pull $DOCKER_IMAGE || true - make dockerimg - docker push $DOCKER_IMAGE tags: - fablab +aria2c: + stage: prepare + image: debian:stretch-slim + script: + - apt-get update + - apt-get -y install clang automake autoconf git make autopoint libtool pkg-config ccache + - git clone -q -b release-1.33.1 --depth 1 https://github.com/aria2/aria2 aria2 + - export CCACHE_DIR=${PWD}/ccache + - cd aria2 + - mkdir -p ccache + - export CCACHE_BASEDIR=${PWD} + - autoreconf -i + - automake + - autoconf + - export CXX="clang++ -Qunused-arguments -Wl,-s" CC="clang -Qunused-arguments -Wl,-s" + - > + ./configure + --disable-ssl + --disable-metalink + --disable-websocket + --disable-epoll + --disable-largefile + --disable-nls + --disable-rpath + --without-libnettle + --without-libgmp + --without-libgcrypt + --without-openssl + --without-sqlite3 + --without-libxml3 + --without-libexpat + --without-libcares + --without-libz + --without-libssh2 + ARIA2_STATIC=yes + - make CC="ccache $CC" CXX="ccache $CXX" + - mv src/aria2c .. + cache: + paths: + - ccache + artifacts: + paths: + - aria2c + expire_in: 2 weeks + tags: + - fablab + .squashfs_template: &squashfs_template + before_script: + - docker info + - apk add --no-cache make openssh-client stage: build script: - make images/debian-stretch.squashfs diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4d44b05..9f3a1c3 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -37,6 +37,8 @@ make_torrent() { } run_packer() { + touch /aria2c + packer build "$NAME.json" if [ "$user" != "" ] && [ "$group" != "" ]; then diff --git a/packer/debian-stretch.json b/packer/debian-stretch.json index 2587fa6..8402847 100644 --- a/packer/debian-stretch.json +++ b/packer/debian-stretch.json @@ -34,6 +34,11 @@ } ], "provisioners": [ + { + "type": "file", + "source": "/aria2c", + "destination": "/usr/local/bin/aria2c" + }, { "type": "shell", "inline": [ "mkdir -p /etc/initramfs-tools/scripts/local-premount/" ] @@ -43,6 +48,11 @@ "source": "initramfs/labsync", "destination": "/etc/initramfs-tools/scripts/" }, + { + "type": "file", + "source": "initramfs/labsync-prereqs", + "destination": "/etc/initramfs-tools/scripts/local-premount/" + }, { "type": "shell", "inline": [ @@ -52,18 +62,10 @@ "echo \"LABSYNC_COMMIT_REF_NAME='{{user `ci_commit_ref_name`}}'\" >> /etc/environment", "echo \"LABSYNC_COMMIT_REF_SLUG='{{user `ci_commit_ref_slug`}}'\" >> /etc/environment", "echo \"LABSYNC_PROJECT_URL='{{user `ci_project_url`}}'\" >> /etc/environment", - "sed -i 's#@@PROJECT_URL@@#{{user `ci_project_url`}}#' /etc/initramfs-tools/scripts/labsync" - ] - }, - { - "type": "file", - "source": "initramfs/labsync-prereqs", - "destination": "/etc/initramfs-tools/scripts/local-premount/" - }, - { - "type": "shell", - "inline": [ "set -x", + "sed -i 's#@@PROJECT_URL@@#{{user `ci_project_url`}}#' /etc/initramfs-tools/scripts/labsync", + "if [ -s /usr/local/bin/aria2c ]; then aria2c=/usr/local/bin/aria2c; else aria2c=/usr/bin/aria2c; fi", + "sed -i \"s#@@ARIA2C@@#$aria2c#\" /etc/initramfs-tools/scripts/local-premount/labsync-prereqs", "apt-get update", "apt-get -y dist-upgrade", "rmdir /boot && ln -s /usr/local/boot /boot", @@ -99,6 +101,7 @@ "echo '/etc/resolv.conf' >> /tmp/ignore_files", "echo '/etc/hostname' >> /tmp/ignore_files", "echo '/etc/hosts' >> /tmp/ignore_files", + "echo '/usr/local/bin/aria2c' >> /tmp/ignore_files", "mkdir -p /tmp/extra/tmp /tmp/extra/proc /tmp/extra/sys /tmp/extra/etc" ] }, diff --git a/packer/initramfs/labsync-prereqs b/packer/initramfs/labsync-prereqs index 120cd77..c981f00 100755 --- a/packer/initramfs/labsync-prereqs +++ b/packer/initramfs/labsync-prereqs @@ -8,7 +8,7 @@ case $1 in . /usr/share/initramfs-tools/hook-functions copy_exec /sbin/mke2fs copy_exec /sbin/e2fsck - copy_exec /usr/bin/aria2c + copy_exec @@ARIA2C@@ copy_exec /sbin/sfdisk copy_file cert /etc/ssl/certs/ca-certificates.crt exit 0