From ba0fec07193b4255ca8a22fbc6e5d642a68758c9 Mon Sep 17 00:00:00 2001 From: Oneric Date: Wed, 15 Dec 2021 21:33:15 +0100 Subject: [PATCH] Initial commit --- .github/scripts/prunetags.sh | 62 ++++++++++++++++++++++++++++++++ .github/workflows/containers.yml | 57 +++++++++++++++++++++++++++++ .gitignore | 5 +++ Dockerfile | 15 ++++++++ README.rst | 28 +++++++++++++++ build.sh | 57 +++++++++++++++++++++++++++++ setup_root.sh | 41 +++++++++++++++++++++ 7 files changed, 265 insertions(+) create mode 100755 .github/scripts/prunetags.sh create mode 100644 .github/workflows/containers.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.rst create mode 100644 build.sh create mode 100644 setup_root.sh diff --git a/.github/scripts/prunetags.sh b/.github/scripts/prunetags.sh new file mode 100755 index 0000000..d316d44 --- /dev/null +++ b/.github/scripts/prunetags.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Copyright 2020-2021 BtbN +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# from: https://github.com/BtbN/FFmpeg-Builds/blob/4eb20ade1bfdd7c1ff8f23921b7c366a20157edb/util/prunetags.sh + +set -e +git fetch --tags +TAGS=( $(git tag -l "autobuild-*" | sort -r) ) + +KEEP_LATEST=14 +KEEP_MONTHLY=12 + +LATEST_TAGS=() +MONTHLY_TAGS=() + +CUR_MONTH="-1" + +for TAG in ${TAGS[@]}; do + if [[ ${#LATEST_TAGS[@]} -lt ${KEEP_LATEST} ]]; then + LATEST_TAGS+=( "$TAG" ) + fi + + if [[ ${#MONTHLY_TAGS[@]} -lt ${KEEP_MONTHLY} ]]; then + TAG_MONTH="$(echo $TAG | cut -d- -f3)" + + if [[ ${TAG_MONTH} != ${CUR_MONTH} ]]; then + CUR_MONTH="${TAG_MONTH}" + MONTHLY_TAGS+=( "$TAG" ) + fi + fi +done + +for TAG in ${LATEST_TAGS[@]} ${MONTHLY_TAGS[@]}; do + TAGS=( "${TAGS[@]/$TAG}" ) +done + +for TAG in ${TAGS[@]}; do + echo "Deleting ${TAG}" + hub release delete "${TAG}" + git tag -d "${TAG}" +done + +git push --tags --prune diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml new file mode 100644 index 0000000..81f4da2 --- /dev/null +++ b/.github/workflows/containers.yml @@ -0,0 +1,57 @@ +name: Build and Publish Container Images + +on: + push: + branches: [master] + paths-ignore: + - '**.rst' + - '.gitignore' + +jobs: + build_images: + name: Build Container Images + runs-on: ubuntu-latest + strategy: + matrix: + image: [oldlibs] + steps: + - name: checkout code + uses: actions/checkout@v2 + - name: Build image + run: | + docker build -t "${{ matrix.image }}" . + docker save "${{ matrix.image }}":latest \ + | zstd -9 > /tmp/"${{ matrix.image }}".tar.zst + # Repeated uploads to the same name append to the artifact archive + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: all-images + path: /tmp/${{ matrix.image }}.tar.zst + + publish_images: + needs: build_images + name: Publish + runs-on: ubuntu-latest + steps: + # Checkout the repo so hub knows where to create a release + - name: Checkout + uses: actions/checkout@v2 + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + name: all-images + path: /tmp/images/ + - name: Create Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + set -xe + tag="containers-$(date +'%Y%m%d-%H%M%S')" + asset_opts="$(for i in /tmp/images/*.zst ; do echo \-a "$i" ; done)" + hub release create $asset_opts -m "$tag" -t master "$tag" + - name: Prune Old Releases + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + bash ./.github/scripts/prunetags.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b3760b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.swp +*.bak +*.tmp +*~ +*.old diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e849dbc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM docker.io/library/debian:stretch-slim + +ENV DEBIAN_FRONTEND=noninteractive +ENV LC_ALL=C.UTF-8 + +COPY setup_root.sh / +RUN /bin/dash setup_root.sh +RUN /bin/rm /setup_root.sh + +COPY build.sh / +RUN /bin/su -c '/bin/dash /build.sh' runner +RUN /bin/rm /build.sh + +USER runner:runner +CMD ["/bin/sh", "-c", "echo 'This container is supposed to run custom commands or be used interactively!'"] diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..24fc82d --- /dev/null +++ b/README.rst @@ -0,0 +1,28 @@ +=============================== +Container images for libass' CI +=============================== + +At the moment the only image is *“oldlibs”*. + + +Containers +========== + +oldlibs +------- + +This container has the minimum version of all of libass' dependencies installed +and otherwise an old'ish toolchain. + + +Releases +======== + +Releases are created automatically at every push to master +to workaround the ``download-artifacts`` action only being +able to use artifcats from (a different job of) the same workflow +(see `action's issue `_). + +As the releases only serve as a public asset storage, +they may be deleted after some time. +Tracking tags is a bad idea in this repo. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..27fac5d --- /dev/null +++ b/build.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +mkdir -p /tmp/build +set -e + + +# Build from autotools(-like) tarballs +tarball_build() ( + if [ "$#" -lt 3 ] ; then + echo "Usage: tarball_build [configure_options...]" + exit 2 + fi + + url="$(printf "$2" "$3")" + filename="tmp-${url##*/}" + name="$1" + version="$3" + shift 3 + + # --insecure: Ignore cert-errors as installed certs are (too) old + curl --location "$url" > "$filename" + tar xf "$filename" + rm "$filename" + cd "$name"-"$version" + + ./configure "$@" + make -j "$(nproc)" + sudo make install + make clean +) + +## FriBiDi +cd /tmp/build +### libass min version 0.19.0, but 0.19.1 is the first "CVS release" +### and I couldn't locate a 0.19.0 tarball +urlfmt='https://github.com/fribidi/fribidi/releases/download/FRIBIDI_0_19_1/fribidi-%s.tar.gz' +tarball_build fribidi "$urlfmt" "0.19.1" + +## FreeType2 (without HarfBuzz) +cd /tmp/build +### Internal version 9.17.3 == external version 2.3.6 +urlfmt='https://download.savannah.gnu.org/releases/freetype/freetype-old/freetype-%s.tar.bz2' +tarball_build freetype "$urlfmt" "2.3.6" + +## HarfBuzz +cd /tmp/build +urlfmt='https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-%s.tar.bz2' +tarball_build harfbuzz "$urlfmt" "1.2.3" + +## Fontconfig +cd /tmp/build +urlfmt='https://www.freedesktop.org/software/fontconfig/release/fontconfig-%s.tar.bz2' +tarball_build fontconfig "$urlfmt" "2.10.92" + +# Clean up +cd / +rm -fr /tmp/build diff --git a/setup_root.sh b/setup_root.sh new file mode 100644 index 0000000..6f23213 --- /dev/null +++ b/setup_root.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +# Basic setup +export DEBIAN_FRONTEND=noninteractive +export LC_ALL=C.UTF-8 + +cat > /etc/apt/apt.conf.d/01_norecommend.conf <> /etc/apt/sources.list +apt-get update && apt-get upgrade -y --with-new-pkgs + +# Basic tools and not self-built libs +# to build libass-deps from tarballs +# and libass itself from git +apt-get install -y \ + sudo bash curl ca-certificates tar gzip bzip2 \ + make gcc g++ nasm pkg-config libexpat1-dev \ + nasm libtool libpng-dev \ + git automake1.11 autoconf2.64 +apt-get clean + +for i in aclocal automake ; do + ln -s /usr/bin/"$i"-1.11 /usr/local/bin/"$i" +done +for i in autoconf autoheader autom4te autoreconf autoscan ; do + ln -s /usr/bin/"$i"2.64 /usr/local/bin/"$i" +done + +# Create GitHub Actions user with matchin UID and work dir +groupadd -g 1001 runner +useradd -m -d /home/runner -s /bin/bash -g runner -G sudo -u 1001 runner +runuser -u runner mkdir /home/runner/work + +sed -i -e '/^%sudo[ \t]/d' /etc/sudoers +printf '%%sudo\tALL=(ALL:ALL)\tNOPASSWD:ALL\n' | EDITOR='tee -a' visudo