Rpm: automate rpm building with build-rpm

This commit is contained in:
Dmitry Maksyoma 2021-02-11 21:50:14 +13:00
parent d658f2b8a3
commit b97633ca10
6 changed files with 41 additions and 9 deletions

View File

@ -8,9 +8,9 @@ cd "$(dirname "$0")/.."
docker build -t kasmvnc_rpmbuilder_${os}:${os_codename} -f \
builder/dockerfile.${os}_${os_codename}.rpm.build .
rpm_output_dir=$(cd .. && echo $PWD)
source_dir=$(echo $PWD)
L_UID=$(id -u) #Ubuntu already has UID env var, but this should work on all Linix systems
L_GID=$(id -g)
docker run --rm -v "$rpm_output_dir":/src --user $L_UID:$L_GID \
docker run --rm -v "$source_dir":/src --user $L_UID:$L_GID \
kasmvnc_rpmbuilder_${os}:${os_codename} /bin/bash -c \
'/src/*/builder/build-rpm-inside-docker'
'/src/builder/build-rpm-inside-docker'

29
builder/build-rpm-inside-docker Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
set -e
prepare_build_env() {
rpmdev-setuptree
copy_spec_and_tar_with_binaries
}
copy_spec_and_tar_with_binaries() {
cp /src/centos/kasmvncserver.spec ~/rpmbuild/SPECS/
cp /src/builder/build/kasmvnc.${os}_${os_codename}.tar.gz \
~/rpmbuild/SOURCES/
}
copy_rpm_to_build_dir() {
cd /src/builder && \
mkdir -p "$os_dir" && cp ~/rpmbuild/RPMS/*/*.rpm ${os_dir}
}
cd "$(dirname "$0")/.."
os=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
os_codename=$(lsb_release -cs | tr '[:upper:]' '[:lower:]')
os_dir="build/${os}_${os_codename}"
prepare_build_env
rpmbuild -ba ~/rpmbuild/SPECS/kasmvncserver.spec
copy_rpm_to_build_dir

View File

@ -1,10 +1,12 @@
FROM centos:centos7
RUN yum install -y rpm* gpg* rng-tools
RUN yum install -y tree vim less
RUN yum install -y redhat-lsb-core
COPY centos/*.spec /tmp
RUN yum-builddep -y /tmp/*.spec
RUN useradd -m docker && echo "docker:docker" | chpasswd
COPY . /src
RUN chown -R docker:docker /src
USER docker

View File

@ -7,7 +7,7 @@ cd "$(dirname "$0")"
echo kasmvnctester_${os}:$os_codename
docker build --build-arg \
KASMVNC_PACKAGE_DIR="build" \
KASMVNC_PACKAGE_DIR="build/${os}_${os_codename}" \
-t kasmvnctester_${os}:$os_codename \
-f dockerfile.${os}_${os_codename}.rpm.test .
echo docker run -it -p 443:8443 --rm -e "VNC_USER=foo" -e "VNC_PW=bar" \

View File

@ -6,7 +6,7 @@ cd "$(dirname "$0")"
os="centos"
os_codename="core"
docker build --build-arg KASMVNC_PACKAGE_DIR="build" \
docker build --build-arg KASMVNC_PACKAGE_DIR="build/${os}_${os_codename}" \
-t kasmvnctester_barebones_${os}:$os_codename \
-f dockerfile.${os}_${os_codename}.barebones.rpm.test .
echo

View File

@ -6,6 +6,7 @@ Summary: Lorem ipsum
License: GPLv2+
URL: https://github.com/kasmtech/KasmVNC
BuildRequires: rsync
Requires: xorg-x11-xauth, xorg-x11-xkb-utils, xkeyboard-config, xorg-x11-server-utils, openssl
%description
@ -16,7 +17,7 @@ Lorem ipsum
%install
rm -rf $RPM_BUILD_ROOT
DESTDIR=$RPM_BUILD_ROOT make -f /src/KasmVNC/debian/Makefile.to_fakebuild_tar_package install
DESTDIR=$RPM_BUILD_ROOT make -f /src/debian/Makefile.to_fakebuild_tar_package install
%files
/usr/bin/*