simplify docker build process

This commit is contained in:
Git User
2025-03-13 14:34:04 +08:00
parent e26a212c97
commit 74b4a40418
3 changed files with 15 additions and 26 deletions

View File

@@ -28,12 +28,7 @@ Current version: (will follow debian sid upstream automatically when `./pullsrc.
```bash
# Install Dependencies
sudo apt install pkgconf build-essential fakeroot \
dpkg-dev debhelper debhelper-compat dh-exec dh-runit \
libkrb5-dev libpam0g-dev libwrap0-dev \
libaudit-dev libedit-dev libfido2-dev \
libgtk-3-dev libselinux1-dev libsystemd-dev \
libcbor-dev
./install_deps.sh
# pull source
./pullsrc.sh
@@ -51,19 +46,9 @@ Build without installing a bunch of dev packages, also for a different distro by
./pullsrc.sh
# build a docker image that fits your target system.
docker build \
-t opensshbuild \
--build-arg DISTRO=ubuntu \
--build-arg DISTVER=22.04 \
--build-arg APT_MIRROR=archive.ubuntu.com \
-f ./docker/Dockerfile \
.
# run the build process
docker run --rm -v $PWD/output:/data/output opensshbuild
docker run --rm -v "$(pwd):/work" -w /work ubuntu:20.04 bash -c "install_deps.sh && compile.sh"
# clean up docker image
docker image rm opensshbuild
docker builder prune
```

View File

@@ -18,25 +18,27 @@ __libssl="$(dpkg-query -f '${Version}' -W libssl-dev || true)"
[[ -z $__libssl ]] && __libssl="0.0.0"
__libfido2_ver="$(dpkg-query -f '${Version}' -W libfido2-dev || true)"
[[ -z $__libfido2_ver ]] && __libfido2_ver="0.0.0"
__debhelper_ver="$(dpkg-query -f '${Version}' -W debhelper || true)"
[[ -z $__debhelper_ver ]] && __debhelper_ver="0.0.0"
source $__dir/version.env
STATIC_OPENSSL=0
if dpkg --compare-versions $__libssl lt '3.0.0' || [[ -n ${FORCESSL+x} ]]; then
STATIC_OPENSSL=1
fi
echo "-- Build OpenSSH : ${OPENSSH_SIDPKG}"
echo "-- Linked OpenSSL: ${OPENSSLSRC/.tar.gz/}"
SOURCES=(
openssh_${OPENSSH_SIDPKG}.debian.tar.xz \
openssh_${OPENSSH_SIDPKG}.dsc \
openssh_${OPENSSHVER}.orig.tar.gz \
openssh_${OPENSSHVER}.orig.tar.gz.asc \
)
[[ $STATIC_OPENSSL -eq 1 ]] && SOURCES+=("$OPENSSLSRC")
echo "-- Build OpenSSH : ${OPENSSH_SIDPKG}"
if [[ $STATIC_OPENSSL -eq 1 ]]; then
echo "-- Linked OpenSSL: ${OPENSSLSRC/.tar.gz/}"
SOURCES+=("$OPENSSLSRC")
else
echo "-- Linked OpenSSL: libssl-dev ${__libssl}"
fi
CHECKEXISTS() {
if [[ ! -f $__dir/downloads/$1 ]];then
@@ -49,9 +51,6 @@ for fn in ${SOURCES[@]}; do
CHECKEXISTS $fn
done
dpkg --compare-versions $__debhelper_ver le '13.1~' && \
sudo apt install -y $__dir/builddep/*.deb
cd $__dir
[[ -d build ]] && rm -rf build
mkdir -p build && pushd build

View File

@@ -1,4 +1,6 @@
#!/bin/bash
__debhelper_ver="$(dpkg-query -f '${Version}' -W debhelper || true)"
[[ -z $__debhelper_ver ]] && __debhelper_ver="0.0.0"
export DEBIAN_FRONTEND=noninteractive
@@ -20,3 +22,6 @@ if [[ $(apt-cache search --names-only 'libfido2-dev' | wc -l) -gt 0 ]]; then
apt install -y libfido2-dev libcbor-dev
fi
dpkg --compare-versions $__debhelper_ver le '13.1~' && \
sudo apt install -y $__dir/builddep/*.deb