From 9513ee7f613c4206b13a498341895df0200dc6fc Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Thu, 6 May 2021 19:07:26 +0200 Subject: [PATCH] Update build script for Debian/Ubuntu --- scripts/dpkg.Dockerfile | 31 ++++++++++++++++++------------- scripts/release-deb.sh | 33 ++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/scripts/dpkg.Dockerfile b/scripts/dpkg.Dockerfile index 09d9f24..4238c18 100644 --- a/scripts/dpkg.Dockerfile +++ b/scripts/dpkg.Dockerfile @@ -3,35 +3,40 @@ ARG distrover FROM $distro:$distrover -ARG distro -ARG distrover - RUN apt-get update RUN apt-get install -y build-essential fakeroot debhelper git -RUN apt-get install -y python3-all python3-pip +RUN apt-get install -y python3-all python3-pip python3-venv RUN apt-get install -y ruby ruby-dev -RUN apt-get install -y python-all python-pip -RUN gem install fpm +RUN gem install fpm package_cloud -RUN pip2 install virtualenv-tools -RUN pip3 install virtualenv +RUN pip3 install virtualenv virtualenv-tools3 RUN virtualenv -p python3 /vdirsyncer/env/ +# See https://github.com/jordansissel/fpm/issues/1106#issuecomment-461678970 +RUN pip3 uninstall -y virtualenv +RUN echo 'python3 -m venv "$@"' > /usr/local/bin/virtualenv +RUN chmod +x /usr/local/bin/virtualenv + COPY . /vdirsyncer/vdirsyncer/ WORKDIR /vdirsyncer/vdirsyncer/ RUN mkdir /vdirsyncer/pkgs/ RUN basename *.tar.gz .tar.gz | cut -d'-' -f2 | sed -e 's/\.dev/~/g' | tee version RUN (echo -n *.tar.gz; echo '[google]') | tee requirements.txt -RUN . /vdirsyncer/env/bin/activate; fpm -s virtualenv -t deb \ --n "vdirsyncer-latest" \ --v "$(cat version)" \ ---prefix /opt/venvs/vdirsyncer-latest \ -requirements.txt +RUN fpm --verbose \ + --input-type virtualenv \ + --output-type deb \ + --name "vdirsyncer-latest" \ + --version "$(cat version)" \ + --prefix /opt/venvs/vdirsyncer-latest \ + --depends python3 \ + requirements.txt RUN mv /vdirsyncer/vdirsyncer/*.deb /vdirsyncer/pkgs/ WORKDIR /vdirsyncer/pkgs/ RUN dpkg -i *.deb + +# Check that it works: RUN LC_ALL=C.UTF-8 LANG=C.UTF-8 /opt/venvs/vdirsyncer-latest/bin/vdirsyncer --version diff --git a/scripts/release-deb.sh b/scripts/release-deb.sh index e4621f5..e2e7c12 100644 --- a/scripts/release-deb.sh +++ b/scripts/release-deb.sh @@ -1,19 +1,26 @@ #!/bin/sh + set -xe -distro=$1 -distrover=$2 -name=vdirsyncer-$distro-$distrover:latest -context="$(mktemp -d)" -python setup.py sdist -d "$context" -cp scripts/dpkg.Dockerfile "$context/Dockerfile" +DISTRO=$1 +DISTROVER=$2 +NAME="vdirsyncer-${DISTRO}-${DISTROVER}:latest" +CONTEXT="$(mktemp -d)" + +python setup.py sdist -d "$CONTEXT" + +# Build the package in a container with the right distro version. docker build \ - --build-arg distro=$distro \ - --build-arg distrover=$distrover \ - -t $name \ - "$context" + --build-arg distro=$DISTRO \ + --build-arg distrover=$DISTROVER \ + -t $NAME \ + -f scripts/dpkg.Dockerfile \ + "$CONTEXT" -docker run $name tar -c -C /vdirsyncer pkgs | tar x -C "$context" -package_cloud push pimutils/vdirsyncer/$distro/$distrover $context/pkgs/*.deb -rm -rf "$context" +# Push the package to packagecloud. +# TODO: Use ~/.packagecloud for CI. +docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN $NAME \ + bash -xec "package_cloud push pimutils/vdirsyncer/$DISTRO/$DISTROVER *.deb" + +rm -rf "$CONTEXT"