Modified rpm build process

This commit is contained in:
Dennis Schwerdel 2019-03-02 01:12:42 +01:00
parent 87635ca07f
commit 7fdc0ef49d
5 changed files with 42 additions and 4 deletions

View File

@ -24,8 +24,10 @@ rm -rf %{buildroot}
mkdir -p %{buildroot} mkdir -p %{buildroot}
mkdir -p %{buildroot}/etc/vpncloud mkdir -p %{buildroot}/etc/vpncloud
mkdir -p %{buildroot}/lib/systemd/system mkdir -p %{buildroot}/lib/systemd/system
mkdir -p %{buildroot}/usr/share/man/man1
cp %{buildroot}/../../../../../assets/example.net.disabled %{buildroot}/etc/vpncloud/example.net.disabled cp %{buildroot}/../../../../../assets/example.net.disabled %{buildroot}/etc/vpncloud/example.net.disabled
cp %{buildroot}/../../../../../assets/vpncloud@.service %{buildroot}/lib/systemd/system/vpncloud@.service cp %{buildroot}/../../../../../assets/vpncloud@.service %{buildroot}/lib/systemd/system/vpncloud@.service
cp %{buildroot}/../../../../../target/vpncloud.1.gz %{buildroot}/usr/share/man/man1/vpncloud.1.gz
cp -a * %{buildroot} cp -a * %{buildroot}
%clean %clean
@ -36,6 +38,7 @@ rm -rf %{buildroot}
/etc/vpncloud/example.net.disabled /etc/vpncloud/example.net.disabled
/usr/bin/vpncloud /usr/bin/vpncloud
/lib/systemd/system/vpncloud@.service /lib/systemd/system/vpncloud@.service
/usr/share/man/man1/vpncloud.1.gz
%defattr(-,root,root,-) %defattr(-,root,root,-)
%{_bindir}/* %{_bindir}/*

View File

@ -66,3 +66,9 @@ assets = [
["assets/vpncloud@.service", "/lib/systemd/system/vpncloud@.service", "644"], ["assets/vpncloud@.service", "/lib/systemd/system/vpncloud@.service", "644"],
["target/vpncloud.1.gz", "/usr/share/man/man1/vpncloud.1.gz", "644"] ["target/vpncloud.1.gz", "/usr/share/man/man1/vpncloud.1.gz", "644"]
] ]
[package.metadata.rpm.cargo]
buildflags = ["--release"]
[package.metadata.rpm.targets]
vpncloud = { path = "/usr/bin/vpncloud" }

View File

@ -74,19 +74,17 @@ Debian packages can be built using [cargo-deb](https://github.com/mmstick/cargo-
There is a [VpnCloud package for Arch Linux](https://aur.archlinux.org/packages/vpncloud/) There is a [VpnCloud package for Arch Linux](https://aur.archlinux.org/packages/vpncloud/)
thanks to Oscar Rainford (fourbytes). thanks to Oscar Rainford (fourbytes).
#### CentOS 7 #### CentOS 7 (maybe other RPM based)
CentOS 7 .rpm package can be built using [cargo-rpm](https://github.com/RustRPM/cargo-rpm): ``cargo rpm`` CentOS 7 .rpm package can be built using [cargo-rpm](https://github.com/RustRPM/cargo-rpm): ``cargo rpm``
On an CentOS 7: On an CentOS 7:
1. Install the required build environment (on CentOS 7) 1. Install the required build environment (on CentOS 7)
$> yum install -y cargo
$> yum groupinstall -y 'Development Tools' $> yum groupinstall -y 'Development Tools'
2. Build the software 2. Build the software
$> cargo rpm build --release $> cargo rpm build
rpm will be situated in `target/release/rpmbuild/RPMS/` rpm will be situated in `target/release/rpmbuild/RPMS/`

24
builder/Dockerfile-rpm Normal file
View File

@ -0,0 +1,24 @@
FROM centos:latest
RUN yum groupinstall -y 'Development Tools'
RUN useradd -ms /bin/bash user
USER user
WORKDIR /home/user
ENV RUST=1.33.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}
ENV PATH=/home/user/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN rustup target add i686-unknown-linux-gnu \
&& rustup target add armv7-unknown-linux-gnueabihf
RUN cargo install cargo-rpm \
&& rm -rf /home/user/.cargo/{git,tmp,registry}
VOLUME /home/user/.cargo/tmp
VOLUME /home/user/.cargo/git
VOLUME /home/user/.cargo/registry

View File

@ -30,3 +30,10 @@ cp ../target/debian/vpncloud_${VERSION}_amd64.deb ../dist/vpncloud_${VERSION}_am
# arm7hf deb # arm7hf deb
docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf' docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf'
cp ../target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb ../dist/vpncloud_${VERSION}_armhf.deb cp ../target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb ../dist/vpncloud_${VERSION}_armhf.deb
docker build --rm -f=Dockerfile-rpm -t vpncloud-builder-rpm .
# x86_64 rpm
docker_cmd rpm 'cd code && cargo rpm build'
cp ../target/release/rpmbuild/RPMS/x86_64/vpncloud-${VERSION}-1.x86_64.rpm ../dist/vpncloud_${VERSION}.x86_64.rpm