From c231fef961e57c2f0e3794a957928ad38fcd3c5c Mon Sep 17 00:00:00 2001 From: Helmut Buchsbaum Date: Wed, 27 Apr 2022 10:07:27 +0200 Subject: [PATCH] debian: Create local apt repo after build Provide local APR repository as part of the result in the distribution's build result folder and prepare this folder as a local APT repository for easy install on a target system. Tracked-On: #6688 Signed-off-by: Helmut Buchsbaum --- debian/docker/Dockerfile | 5 ++--- debian/docker/acrn-docker-build.sh | 9 ++++++++- debian/docker/create-apt-repo.sh | 31 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100755 debian/docker/create-apt-repo.sh diff --git a/debian/docker/Dockerfile b/debian/docker/Dockerfile index 311d8e7db..420265239 100644 --- a/debian/docker/Dockerfile +++ b/debian/docker/Dockerfile @@ -225,6 +225,7 @@ RUN apt-get -y update && apt-get install -y --no-install-recommends \ equivs \ git-buildpackage \ lintian \ + apt-utils \ sudo @@ -237,8 +238,6 @@ WORKDIR /source/ # Get default settings and helper scripts ADD gbp.conf /etc/git-buildpackage/ ADD debian-pkg-build.sh /usr/local/bin/debian-pkg-build.sh +ADD create-apt-repo.sh /usr/local/bin/create-apt-repo.sh ADD lintian.sh /usr/local/bin/lintian.sh -############################################################################### -# build Debian packages -ENTRYPOINT ["/usr/local/bin/debian-pkg-build.sh"] diff --git a/debian/docker/acrn-docker-build.sh b/debian/docker/acrn-docker-build.sh index df33ca15d..666f8bbfd 100755 --- a/debian/docker/acrn-docker-build.sh +++ b/debian/docker/acrn-docker-build.sh @@ -39,6 +39,13 @@ ${DOCKER} run \ --rm \ -e UID=$(id -u) \ -e GID=$(id -g) \ - -v $(pwd):/source acrn-pkg-builder:${DISTRO} -F --no-sign --git-export-dir=build/${DISTRO} "$@" + -v $(pwd):/source --entrypoint /usr/local/bin/debian-pkg-build.sh acrn-pkg-builder:${DISTRO} -F --no-sign --git-export-dir=build/${DISTRO} "$@" + +# create local apt repository +${DOCKER} run \ + --rm \ + -e UID=$(id -u) \ + -e GID=$(id -g) \ + -v $(pwd):/source --entrypoint create-apt-repo.sh acrn-pkg-builder:${DISTRO} build/${DISTRO} popd >/dev/null diff --git a/debian/docker/create-apt-repo.sh b/debian/docker/create-apt-repo.sh new file mode 100755 index 000000000..584096e1d --- /dev/null +++ b/debian/docker/create-apt-repo.sh @@ -0,0 +1,31 @@ +#!/bin/bash -e + +# helper to create local APT repository includeing all package available in +# the docker images's local apt repo + +if [ $# -ne 1 ]; then + echo "Call with: $(basename ${BASH_SOURCE[0]}) " >&2 + exit 1 +fi + +if [ ! -d $1 ]; then + echo "Please create target directory $1 before calling this script!" >&2 + exit 1 +fi + +if [[ -n ${UID} && -n ${GID} ]]; then + addgroup --gid ${GID} docker-build + adduser --uid=${UID} --gid=${GID} --disabled-password --gecos '' docker-build +else + echo "UID/GID not set. Use docker run -e UID=$(id -u) -e GID=$(id -g)" >&2 + exit 1 +fi + +# copy all Debian packages in local APT repo and create local APT repository +export HOME=$(echo ~docker-build) +sudo -E -u docker-build /bin/bash -c "\ + cd $1 && cp /opt/apt/*.deb . && \ + apt-ftparchive packages . > Packages && \ + cp /opt/apt/.Release.header Release && \ + apt-ftparchive release . >> Release" +