diff --git a/.build/DEB/control b/.build/DEB/control index 759f84c..526d11b 100644 --- a/.build/DEB/control +++ b/.build/DEB/control @@ -1,10 +1,10 @@ -Package: rpxy -Version: @BUILD_VERSION@-1 -Maintainer: Jun Kurihara -Homepage: https://github.com/junkurihara/rust-rpxy -Architecture: amd64 -Depends: systemd -Recommends: rpxy-webui -Priority: optional -Section: base -Description: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust +Package: rpxy +Version: @BUILD_VERSION@-1 +Maintainer: Jun Kurihara +Homepage: https://github.com/junkurihara/rust-rpxy +Architecture: amd64 +Depends: systemd +Recommends: rpxy-webui +Priority: optional +Section: base +Description: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust diff --git a/.build/DEB/postinst b/.build/DEB/postinst index cf3206d..f7564d8 100644 --- a/.build/DEB/postinst +++ b/.build/DEB/postinst @@ -1,9 +1,9 @@ -#!/bin/bash - -set -e - -systemctl daemon-reload -systemctl enable rpxy -systemctl start rpxy - +#!/bin/bash + +set -e + +systemctl daemon-reload +systemctl enable rpxy +systemctl start rpxy + exit 0 \ No newline at end of file diff --git a/.build/DEB/prerm b/.build/DEB/prerm index 889ae8c..fa07f70 100644 --- a/.build/DEB/prerm +++ b/.build/DEB/prerm @@ -1,8 +1,8 @@ -#!/bin/bash - -set -e - -systemctl stop rpxy || true -systemctl disable rpxy || true - +#!/bin/bash + +set -e + +systemctl stop rpxy || true +systemctl disable rpxy || true + exit 0 \ No newline at end of file diff --git a/.build/Jenkinsfile b/.build/Jenkinsfile index 8148cd4..a0b96f1 100644 --- a/.build/Jenkinsfile +++ b/.build/Jenkinsfile @@ -1,208 +1,208 @@ -pipeline { - agent none - parameters { - string(name: 'BUILD_VERSION', defaultValue: '', description: 'Build version for the distribution packages') - } - stages { - stage('Build Binary and Prepare Files') { - agent { - kubernetes { - inheritFrom 'default' - yaml """ - apiVersion: v1 - kind: Pod - spec: - containers: - - name: rust-cargo - image: rust:slim - command: - - cat - tty: true - """ - } - } - steps { - container('rust-cargo') { - script { - // Install git - sh 'apt-get update && apt-get -y install git --no-install-recommends' - // Clone git repo - sh 'git clone -b patch-1 --single-branch https://github.com/Gamerboy59/rust-rpxy.git' - dir('rust-rpxy') { - sh """ - sed -i 's|git@github.com:junkurihara/rusty-http-cache-semantics.git|https://github.com/junkurihara/rusty-http-cache-semantics.git|g' .gitmodules - sed -i 's|git@github.com:junkurihara/rustls-acme.git|https://github.com/junkurihara/rustls-acme.git|g' .gitmodules - """ - // Load required submodules - sh 'git submodule update --init' - // Compile rustc binary - sh 'cargo build --release' - - // Extract the version from Cargo.toml if not passed as parameter - if (params.BUILD_VERSION == "") { - def versionMatch = sh(script: 'grep "^version" Cargo.toml | sed \'s/version = "\\([0-9.]*\\)"/\\1/\'', returnStdout: true).trim() - if (versionMatch) { - env.BUILD_VERSION = versionMatch - echo "Using extracted version: ${env.BUILD_VERSION}" - } else { - error "Version not found in Cargo.toml" - } - } else { - env.BUILD_VERSION = params.BUILD_VERSION - echo "Using provided build version: ${env.BUILD_VERSION}" - } - } - // Stash the binary for later use in package building stages - sh 'mv rust-rpxy/target/release/rpxy .' - stash includes: "rpxy", name: "rpxy" - - // Stash the service, control, and spec files for later use - sh ''' - mv rust-rpxy/.build/DEB/control . - mv rust-rpxy/.build/DEB/postinst . - mv rust-rpxy/.build/DEB/prerm . - mv rust-rpxy/.build/RPM/rpxy.spec . - mv rust-rpxy/.build/rpxy-start.sh . - mv rust-rpxy/.build/rpxy.service . - ''' - stash includes: "control, postinst, prerm, rpxy-start.sh", name: "deb-control" - stash includes: "rpxy.spec", name: "rpm-spec" - stash includes: "rpxy.service", name: "service-file" - - // Stash LICENSE and README.md - sh 'mv rust-rpxy/LICENSE .' - sh 'mv rust-rpxy/README.md .' - stash includes: "LICENSE, README.md", name: "docs" - - // Archive the binary and create fingerprint - archiveArtifacts artifacts: "rpxy", allowEmptyArchive: false, fingerprint: true - } - } - } - } - stage('Build RPM Package') { - agent { - kubernetes { - inheritFrom 'default' - yaml """ - apiVersion: v1 - kind: Pod - spec: - containers: - - name: rpm-build - image: rockylinux:9 - command: - - cat - tty: true - """ - } - } - steps { - container('rpm-build') { - script { - // Unstash the necessary files for this stage - unstash 'rpxy' - unstash 'rpm-spec' - unstash 'service-file' - unstash 'docs' - - // Install required tools - sh 'dnf update -y && dnf install -y rpmdevtools tar' - - // Create a tar.gz archive containing all necessary files - sh """ - mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} - mkdir -p rpxy-${env.BUILD_VERSION} - mv rpxy rpxy.service LICENSE README.md rpxy-${env.BUILD_VERSION}/ - tar -czf rpmbuild/SOURCES/rpxy-${env.BUILD_VERSION}.tar.gz rpxy-${env.BUILD_VERSION}/ - rm -rf rpxy-${env.BUILD_VERSION} - """ - - // Move the RPM spec file - sh 'mv rpxy.spec rpmbuild/SPECS/' - - // Replace @BUILD_VERSION@ in control file with actual version - sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpmbuild/SPECS/rpxy.spec" - - // Replace @Source0@ in control file with actual version - sh "sed -i 's/@Source0@/rpxy-${env.BUILD_VERSION}.tar.gz/' rpmbuild/SPECS/rpxy.spec" - - // Build the RPM package - sh "rpmbuild --define '_topdir ${WORKSPACE}/rpmbuild' --define '_version ${env.BUILD_VERSION}' -bb rpmbuild/SPECS/rpxy.spec" - - // Archive the RPM package and create fingerprint - archiveArtifacts artifacts: "rpmbuild/RPMS/x86_64/rpxy-${env.BUILD_VERSION}-1.el9.x86_64.rpm", allowEmptyArchive: false, fingerprint: true - } - } - } - } - stage('Build DEB Package') { - agent { - kubernetes { - inheritFrom 'default' - yaml """ - apiVersion: v1 - kind: Pod - spec: - containers: - - name: debian-build - image: debian:stable-slim - command: - - cat - tty: true - """ - } - } - steps { - container('debian-build') { - script { - // Unstash the necessary files for this stage - unstash 'rpxy' - unstash 'deb-control' - unstash 'service-file' - unstash 'docs' - - // Install required tools - sh 'apt-get update && apt-get install --no-install-recommends -y dpkg-dev' - - // Create folder structure - sh """ - mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin - mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin - mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/etc/systemd/system - mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/share/doc/rpxy - mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN - """ - - // Move postinstall, pre-removal and start-wrapper scripts - sh """ - mv postinst rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ - chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/postinst - mv prerm rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ - chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/prerm - mv rpxy-start.sh rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin - chmod 0755 rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin/rpxy-start.sh - """ - - // Move binary, service file, control file, LICENSE, and README.md - sh """ - mv rpxy rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin/ - mv rpxy.service rpxy_${env.BUILD_VERSION}-1_amd64/etc/systemd/system/ - mv LICENSE README.md rpxy_${env.BUILD_VERSION}-1_amd64/usr/share/doc/rpxy/ - mv control rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ - """ - - // Replace @BUILD_VERSION@ in control file with actual version - sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/control" - - // Build the DEB package - sh "dpkg-deb --build --root-owner-group rpxy_${env.BUILD_VERSION}-1_amd64" - - // Archive the DEB package and create fingerprint - archiveArtifacts artifacts: "rpxy_${env.BUILD_VERSION}-1_amd64.deb", allowEmptyArchive: false, fingerprint: true - } - } - } - } - } -} +pipeline { + agent none + parameters { + string(name: 'BUILD_VERSION', defaultValue: '', description: 'Build version for the distribution packages') + } + stages { + stage('Build Binary and Prepare Files') { + agent { + kubernetes { + inheritFrom 'default' + yaml """ + apiVersion: v1 + kind: Pod + spec: + containers: + - name: rust-cargo + image: rust:slim + command: + - cat + tty: true + """ + } + } + steps { + container('rust-cargo') { + script { + // Install git + sh 'apt-get update && apt-get -y install git --no-install-recommends' + // Clone git repo + sh 'git clone -b patch-1 --single-branch https://github.com/Gamerboy59/rust-rpxy.git' + dir('rust-rpxy') { + sh """ + sed -i 's|git@github.com:junkurihara/rusty-http-cache-semantics.git|https://github.com/junkurihara/rusty-http-cache-semantics.git|g' .gitmodules + sed -i 's|git@github.com:junkurihara/rustls-acme.git|https://github.com/junkurihara/rustls-acme.git|g' .gitmodules + """ + // Load required submodules + sh 'git submodule update --init' + // Compile rustc binary + sh 'cargo build --release' + + // Extract the version from Cargo.toml if not passed as parameter + if (params.BUILD_VERSION == "") { + def versionMatch = sh(script: 'grep "^version" Cargo.toml | sed \'s/version = "\\([0-9.]*\\)"/\\1/\'', returnStdout: true).trim() + if (versionMatch) { + env.BUILD_VERSION = versionMatch + echo "Using extracted version: ${env.BUILD_VERSION}" + } else { + error "Version not found in Cargo.toml" + } + } else { + env.BUILD_VERSION = params.BUILD_VERSION + echo "Using provided build version: ${env.BUILD_VERSION}" + } + } + // Stash the binary for later use in package building stages + sh 'mv rust-rpxy/target/release/rpxy .' + stash includes: "rpxy", name: "rpxy" + + // Stash the service, control, and spec files for later use + sh ''' + mv rust-rpxy/.build/DEB/control . + mv rust-rpxy/.build/DEB/postinst . + mv rust-rpxy/.build/DEB/prerm . + mv rust-rpxy/.build/RPM/rpxy.spec . + mv rust-rpxy/.build/rpxy-start.sh . + mv rust-rpxy/.build/rpxy.service . + ''' + stash includes: "control, postinst, prerm, rpxy-start.sh", name: "deb-control" + stash includes: "rpxy.spec", name: "rpm-spec" + stash includes: "rpxy.service", name: "service-file" + + // Stash LICENSE and README.md + sh 'mv rust-rpxy/LICENSE .' + sh 'mv rust-rpxy/README.md .' + stash includes: "LICENSE, README.md", name: "docs" + + // Archive the binary and create fingerprint + archiveArtifacts artifacts: "rpxy", allowEmptyArchive: false, fingerprint: true + } + } + } + } + stage('Build RPM Package') { + agent { + kubernetes { + inheritFrom 'default' + yaml """ + apiVersion: v1 + kind: Pod + spec: + containers: + - name: rpm-build + image: rockylinux:9 + command: + - cat + tty: true + """ + } + } + steps { + container('rpm-build') { + script { + // Unstash the necessary files for this stage + unstash 'rpxy' + unstash 'rpm-spec' + unstash 'service-file' + unstash 'docs' + + // Install required tools + sh 'dnf update -y && dnf install -y rpmdevtools tar' + + // Create a tar.gz archive containing all necessary files + sh """ + mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} + mkdir -p rpxy-${env.BUILD_VERSION} + mv rpxy rpxy.service LICENSE README.md rpxy-${env.BUILD_VERSION}/ + tar -czf rpmbuild/SOURCES/rpxy-${env.BUILD_VERSION}.tar.gz rpxy-${env.BUILD_VERSION}/ + rm -rf rpxy-${env.BUILD_VERSION} + """ + + // Move the RPM spec file + sh 'mv rpxy.spec rpmbuild/SPECS/' + + // Replace @BUILD_VERSION@ in control file with actual version + sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpmbuild/SPECS/rpxy.spec" + + // Replace @Source0@ in control file with actual version + sh "sed -i 's/@Source0@/rpxy-${env.BUILD_VERSION}.tar.gz/' rpmbuild/SPECS/rpxy.spec" + + // Build the RPM package + sh "rpmbuild --define '_topdir ${WORKSPACE}/rpmbuild' --define '_version ${env.BUILD_VERSION}' -bb rpmbuild/SPECS/rpxy.spec" + + // Archive the RPM package and create fingerprint + archiveArtifacts artifacts: "rpmbuild/RPMS/x86_64/rpxy-${env.BUILD_VERSION}-1.el9.x86_64.rpm", allowEmptyArchive: false, fingerprint: true + } + } + } + } + stage('Build DEB Package') { + agent { + kubernetes { + inheritFrom 'default' + yaml """ + apiVersion: v1 + kind: Pod + spec: + containers: + - name: debian-build + image: debian:stable-slim + command: + - cat + tty: true + """ + } + } + steps { + container('debian-build') { + script { + // Unstash the necessary files for this stage + unstash 'rpxy' + unstash 'deb-control' + unstash 'service-file' + unstash 'docs' + + // Install required tools + sh 'apt-get update && apt-get install --no-install-recommends -y dpkg-dev' + + // Create folder structure + sh """ + mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin + mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin + mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/etc/systemd/system + mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/share/doc/rpxy + mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN + """ + + // Move postinstall, pre-removal and start-wrapper scripts + sh """ + mv postinst rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ + chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/postinst + mv prerm rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ + chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/prerm + mv rpxy-start.sh rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin + chmod 0755 rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin/rpxy-start.sh + """ + + // Move binary, service file, control file, LICENSE, and README.md + sh """ + mv rpxy rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin/ + mv rpxy.service rpxy_${env.BUILD_VERSION}-1_amd64/etc/systemd/system/ + mv LICENSE README.md rpxy_${env.BUILD_VERSION}-1_amd64/usr/share/doc/rpxy/ + mv control rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ + """ + + // Replace @BUILD_VERSION@ in control file with actual version + sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/control" + + // Build the DEB package + sh "dpkg-deb --build --root-owner-group rpxy_${env.BUILD_VERSION}-1_amd64" + + // Archive the DEB package and create fingerprint + archiveArtifacts artifacts: "rpxy_${env.BUILD_VERSION}-1_amd64.deb", allowEmptyArchive: false, fingerprint: true + } + } + } + } + } +} diff --git a/.build/RPM/rpxy.spec b/.build/RPM/rpxy.spec index b282345..29e1c99 100644 --- a/.build/RPM/rpxy.spec +++ b/.build/RPM/rpxy.spec @@ -1,46 +1,46 @@ -Name: rpxy -Version: @BUILD_VERSION@ -Release: 1%{?dist} -Summary: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust - -License: MIT -URL: https://github.com/junkurihara/rust-rpxy -Source0: @Source0@ -BuildArch: x86_64 - -Requires: systemd - -%description -This rpm installs rpxy into /usr/bin and sets up a systemd service. - -%prep -%autosetup - -%install -rm -rf %{buildroot} -mkdir -p %{buildroot}%{_bindir} -cp rpxy %{buildroot}%{_bindir}/ -mkdir -p %{buildroot}%{_sysconfdir}/systemd/system -cp rpxy.service %{buildroot}%{_sysconfdir}/systemd/system/ -mkdir -p %{buildroot}%{_docdir}/rpxy -cp LICENSE %{buildroot}%{_docdir}/rpxy/ -cp README.md %{buildroot}%{_docdir}/rpxy/ - -%clean -rm -rf %{buildroot} - -%files -%license %{_docdir}/rpxy/LICENSE -%doc %{_docdir}/rpxy/README.md -%{_bindir}/rpxy -%{_sysconfdir}/systemd/system/rpxy.service - -%post -systemctl daemon-reload -systemctl enable rpxy - -%preun -systemctl stop rpxy - -%postun +Name: rpxy +Version: @BUILD_VERSION@ +Release: 1%{?dist} +Summary: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust + +License: MIT +URL: https://github.com/junkurihara/rust-rpxy +Source0: @Source0@ +BuildArch: x86_64 + +Requires: systemd + +%description +This rpm installs rpxy into /usr/bin and sets up a systemd service. + +%prep +%autosetup + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}%{_bindir} +cp rpxy %{buildroot}%{_bindir}/ +mkdir -p %{buildroot}%{_sysconfdir}/systemd/system +cp rpxy.service %{buildroot}%{_sysconfdir}/systemd/system/ +mkdir -p %{buildroot}%{_docdir}/rpxy +cp LICENSE %{buildroot}%{_docdir}/rpxy/ +cp README.md %{buildroot}%{_docdir}/rpxy/ + +%clean +rm -rf %{buildroot} + +%files +%license %{_docdir}/rpxy/LICENSE +%doc %{_docdir}/rpxy/README.md +%{_bindir}/rpxy +%{_sysconfdir}/systemd/system/rpxy.service + +%post +systemctl daemon-reload +systemctl enable rpxy + +%preun +systemctl stop rpxy + +%postun systemctl disable rpxy \ No newline at end of file diff --git a/.build/rpxy.service b/.build/rpxy.service index d8c880a..836efaa 100644 --- a/.build/rpxy.service +++ b/.build/rpxy.service @@ -1,11 +1,11 @@ -[Unit] -Description=rpxy Service -After=network.target - -[Service] -ExecStart=/usr/local/bin/rpxy-start.sh -Restart=always -User=nobody - -[Install] -WantedBy=multi-user.target +[Unit] +Description=rpxy Service +After=network.target + +[Service] +ExecStart=/usr/local/bin/rpxy-start.sh +Restart=always +User=nobody + +[Install] +WantedBy=multi-user.target