Fix line endings

This commit is contained in:
Gamerboy59 2024-09-08 18:42:21 +02:00 committed by GitHub
commit 227e11be02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 289 additions and 289 deletions

View file

@ -1,10 +1,10 @@
Package: rpxy Package: rpxy
Version: @BUILD_VERSION@-1 Version: @BUILD_VERSION@-1
Maintainer: Jun Kurihara <kurihara@ieee.org> Maintainer: Jun Kurihara <kurihara@ieee.org>
Homepage: https://github.com/junkurihara/rust-rpxy Homepage: https://github.com/junkurihara/rust-rpxy
Architecture: amd64 Architecture: amd64
Depends: systemd Depends: systemd
Recommends: rpxy-webui Recommends: rpxy-webui
Priority: optional Priority: optional
Section: base Section: base
Description: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust Description: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust

View file

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
set -e set -e
systemctl daemon-reload systemctl daemon-reload
systemctl enable rpxy systemctl enable rpxy
systemctl start rpxy systemctl start rpxy
exit 0 exit 0

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
set -e set -e
systemctl stop rpxy || true systemctl stop rpxy || true
systemctl disable rpxy || true systemctl disable rpxy || true
exit 0 exit 0

416
.build/Jenkinsfile vendored
View file

@ -1,208 +1,208 @@
pipeline { pipeline {
agent none agent none
parameters { parameters {
string(name: 'BUILD_VERSION', defaultValue: '', description: 'Build version for the distribution packages') string(name: 'BUILD_VERSION', defaultValue: '', description: 'Build version for the distribution packages')
} }
stages { stages {
stage('Build Binary and Prepare Files') { stage('Build Binary and Prepare Files') {
agent { agent {
kubernetes { kubernetes {
inheritFrom 'default' inheritFrom 'default'
yaml """ yaml """
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
spec: spec:
containers: containers:
- name: rust-cargo - name: rust-cargo
image: rust:slim image: rust:slim
command: command:
- cat - cat
tty: true tty: true
""" """
} }
} }
steps { steps {
container('rust-cargo') { container('rust-cargo') {
script { script {
// Install git // Install git
sh 'apt-get update && apt-get -y install git --no-install-recommends' sh 'apt-get update && apt-get -y install git --no-install-recommends'
// Clone git repo // Clone git repo
sh 'git clone -b patch-1 --single-branch https://github.com/Gamerboy59/rust-rpxy.git' sh 'git clone -b patch-1 --single-branch https://github.com/Gamerboy59/rust-rpxy.git'
dir('rust-rpxy') { dir('rust-rpxy') {
sh """ 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/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 sed -i 's|git@github.com:junkurihara/rustls-acme.git|https://github.com/junkurihara/rustls-acme.git|g' .gitmodules
""" """
// Load required submodules // Load required submodules
sh 'git submodule update --init' sh 'git submodule update --init'
// Compile rustc binary // Compile rustc binary
sh 'cargo build --release' sh 'cargo build --release'
// Extract the version from Cargo.toml if not passed as parameter // Extract the version from Cargo.toml if not passed as parameter
if (params.BUILD_VERSION == "") { if (params.BUILD_VERSION == "") {
def versionMatch = sh(script: 'grep "^version" Cargo.toml | sed \'s/version = "\\([0-9.]*\\)"/\\1/\'', returnStdout: true).trim() def versionMatch = sh(script: 'grep "^version" Cargo.toml | sed \'s/version = "\\([0-9.]*\\)"/\\1/\'', returnStdout: true).trim()
if (versionMatch) { if (versionMatch) {
env.BUILD_VERSION = versionMatch env.BUILD_VERSION = versionMatch
echo "Using extracted version: ${env.BUILD_VERSION}" echo "Using extracted version: ${env.BUILD_VERSION}"
} else { } else {
error "Version not found in Cargo.toml" error "Version not found in Cargo.toml"
} }
} else { } else {
env.BUILD_VERSION = params.BUILD_VERSION env.BUILD_VERSION = params.BUILD_VERSION
echo "Using provided build version: ${env.BUILD_VERSION}" echo "Using provided build version: ${env.BUILD_VERSION}"
} }
} }
// Stash the binary for later use in package building stages // Stash the binary for later use in package building stages
sh 'mv rust-rpxy/target/release/rpxy .' sh 'mv rust-rpxy/target/release/rpxy .'
stash includes: "rpxy", name: "rpxy" stash includes: "rpxy", name: "rpxy"
// Stash the service, control, and spec files for later use // Stash the service, control, and spec files for later use
sh ''' sh '''
mv rust-rpxy/.build/DEB/control . mv rust-rpxy/.build/DEB/control .
mv rust-rpxy/.build/DEB/postinst . mv rust-rpxy/.build/DEB/postinst .
mv rust-rpxy/.build/DEB/prerm . mv rust-rpxy/.build/DEB/prerm .
mv rust-rpxy/.build/RPM/rpxy.spec . mv rust-rpxy/.build/RPM/rpxy.spec .
mv rust-rpxy/.build/rpxy-start.sh . mv rust-rpxy/.build/rpxy-start.sh .
mv rust-rpxy/.build/rpxy.service . mv rust-rpxy/.build/rpxy.service .
''' '''
stash includes: "control, postinst, prerm, rpxy-start.sh", name: "deb-control" stash includes: "control, postinst, prerm, rpxy-start.sh", name: "deb-control"
stash includes: "rpxy.spec", name: "rpm-spec" stash includes: "rpxy.spec", name: "rpm-spec"
stash includes: "rpxy.service", name: "service-file" stash includes: "rpxy.service", name: "service-file"
// Stash LICENSE and README.md // Stash LICENSE and README.md
sh 'mv rust-rpxy/LICENSE .' sh 'mv rust-rpxy/LICENSE .'
sh 'mv rust-rpxy/README.md .' sh 'mv rust-rpxy/README.md .'
stash includes: "LICENSE, README.md", name: "docs" stash includes: "LICENSE, README.md", name: "docs"
// Archive the binary and create fingerprint // Archive the binary and create fingerprint
archiveArtifacts artifacts: "rpxy", allowEmptyArchive: false, fingerprint: true archiveArtifacts artifacts: "rpxy", allowEmptyArchive: false, fingerprint: true
} }
} }
} }
} }
stage('Build RPM Package') { stage('Build RPM Package') {
agent { agent {
kubernetes { kubernetes {
inheritFrom 'default' inheritFrom 'default'
yaml """ yaml """
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
spec: spec:
containers: containers:
- name: rpm-build - name: rpm-build
image: rockylinux:9 image: rockylinux:9
command: command:
- cat - cat
tty: true tty: true
""" """
} }
} }
steps { steps {
container('rpm-build') { container('rpm-build') {
script { script {
// Unstash the necessary files for this stage // Unstash the necessary files for this stage
unstash 'rpxy' unstash 'rpxy'
unstash 'rpm-spec' unstash 'rpm-spec'
unstash 'service-file' unstash 'service-file'
unstash 'docs' unstash 'docs'
// Install required tools // Install required tools
sh 'dnf update -y && dnf install -y rpmdevtools tar' sh 'dnf update -y && dnf install -y rpmdevtools tar'
// Create a tar.gz archive containing all necessary files // Create a tar.gz archive containing all necessary files
sh """ sh """
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p rpxy-${env.BUILD_VERSION} mkdir -p rpxy-${env.BUILD_VERSION}
mv rpxy rpxy.service LICENSE README.md 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}/ tar -czf rpmbuild/SOURCES/rpxy-${env.BUILD_VERSION}.tar.gz rpxy-${env.BUILD_VERSION}/
rm -rf rpxy-${env.BUILD_VERSION} rm -rf rpxy-${env.BUILD_VERSION}
""" """
// Move the RPM spec file // Move the RPM spec file
sh 'mv rpxy.spec rpmbuild/SPECS/' sh 'mv rpxy.spec rpmbuild/SPECS/'
// Replace @BUILD_VERSION@ in control file with actual version // Replace @BUILD_VERSION@ in control file with actual version
sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpmbuild/SPECS/rpxy.spec" sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpmbuild/SPECS/rpxy.spec"
// Replace @Source0@ in control file with actual version // Replace @Source0@ in control file with actual version
sh "sed -i 's/@Source0@/rpxy-${env.BUILD_VERSION}.tar.gz/' rpmbuild/SPECS/rpxy.spec" sh "sed -i 's/@Source0@/rpxy-${env.BUILD_VERSION}.tar.gz/' rpmbuild/SPECS/rpxy.spec"
// Build the RPM package // Build the RPM package
sh "rpmbuild --define '_topdir ${WORKSPACE}/rpmbuild' --define '_version ${env.BUILD_VERSION}' -bb rpmbuild/SPECS/rpxy.spec" sh "rpmbuild --define '_topdir ${WORKSPACE}/rpmbuild' --define '_version ${env.BUILD_VERSION}' -bb rpmbuild/SPECS/rpxy.spec"
// Archive the RPM package and create fingerprint // 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 archiveArtifacts artifacts: "rpmbuild/RPMS/x86_64/rpxy-${env.BUILD_VERSION}-1.el9.x86_64.rpm", allowEmptyArchive: false, fingerprint: true
} }
} }
} }
} }
stage('Build DEB Package') { stage('Build DEB Package') {
agent { agent {
kubernetes { kubernetes {
inheritFrom 'default' inheritFrom 'default'
yaml """ yaml """
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
spec: spec:
containers: containers:
- name: debian-build - name: debian-build
image: debian:stable-slim image: debian:stable-slim
command: command:
- cat - cat
tty: true tty: true
""" """
} }
} }
steps { steps {
container('debian-build') { container('debian-build') {
script { script {
// Unstash the necessary files for this stage // Unstash the necessary files for this stage
unstash 'rpxy' unstash 'rpxy'
unstash 'deb-control' unstash 'deb-control'
unstash 'service-file' unstash 'service-file'
unstash 'docs' unstash 'docs'
// Install required tools // Install required tools
sh 'apt-get update && apt-get install --no-install-recommends -y dpkg-dev' sh 'apt-get update && apt-get install --no-install-recommends -y dpkg-dev'
// Create folder structure // Create folder structure
sh """ sh """
mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin 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/usr/local/bin
mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/etc/systemd/system 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/usr/share/doc/rpxy
mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN mkdir -p rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN
""" """
// Move postinstall, pre-removal and start-wrapper scripts // Move postinstall, pre-removal and start-wrapper scripts
sh """ sh """
mv postinst rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ mv postinst rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/
chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/postinst chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/postinst
mv prerm rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ mv prerm rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/
chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/prerm chmod 755 rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/prerm
mv rpxy-start.sh rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin 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 chmod 0755 rpxy_${env.BUILD_VERSION}-1_amd64/usr/local/bin/rpxy-start.sh
""" """
// Move binary, service file, control file, LICENSE, and README.md // Move binary, service file, control file, LICENSE, and README.md
sh """ sh """
mv rpxy rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin/ mv rpxy rpxy_${env.BUILD_VERSION}-1_amd64/usr/bin/
mv rpxy.service rpxy_${env.BUILD_VERSION}-1_amd64/etc/systemd/system/ 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 LICENSE README.md rpxy_${env.BUILD_VERSION}-1_amd64/usr/share/doc/rpxy/
mv control rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/ mv control rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/
""" """
// Replace @BUILD_VERSION@ in control file with actual version // 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" sh "sed -i 's/@BUILD_VERSION@/${env.BUILD_VERSION}/' rpxy_${env.BUILD_VERSION}-1_amd64/DEBIAN/control"
// Build the DEB package // Build the DEB package
sh "dpkg-deb --build --root-owner-group rpxy_${env.BUILD_VERSION}-1_amd64" sh "dpkg-deb --build --root-owner-group rpxy_${env.BUILD_VERSION}-1_amd64"
// Archive the DEB package and create fingerprint // Archive the DEB package and create fingerprint
archiveArtifacts artifacts: "rpxy_${env.BUILD_VERSION}-1_amd64.deb", allowEmptyArchive: false, fingerprint: true archiveArtifacts artifacts: "rpxy_${env.BUILD_VERSION}-1_amd64.deb", allowEmptyArchive: false, fingerprint: true
} }
} }
} }
} }
} }
} }

View file

@ -1,46 +1,46 @@
Name: rpxy Name: rpxy
Version: @BUILD_VERSION@ Version: @BUILD_VERSION@
Release: 1%{?dist} Release: 1%{?dist}
Summary: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust Summary: A simple and ultrafast reverse-proxy serving multiple domain names with TLS termination, written in Rust
License: MIT License: MIT
URL: https://github.com/junkurihara/rust-rpxy URL: https://github.com/junkurihara/rust-rpxy
Source0: @Source0@ Source0: @Source0@
BuildArch: x86_64 BuildArch: x86_64
Requires: systemd Requires: systemd
%description %description
This rpm installs rpxy into /usr/bin and sets up a systemd service. This rpm installs rpxy into /usr/bin and sets up a systemd service.
%prep %prep
%autosetup %autosetup
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_bindir}
cp rpxy %{buildroot}%{_bindir}/ cp rpxy %{buildroot}%{_bindir}/
mkdir -p %{buildroot}%{_sysconfdir}/systemd/system mkdir -p %{buildroot}%{_sysconfdir}/systemd/system
cp rpxy.service %{buildroot}%{_sysconfdir}/systemd/system/ cp rpxy.service %{buildroot}%{_sysconfdir}/systemd/system/
mkdir -p %{buildroot}%{_docdir}/rpxy mkdir -p %{buildroot}%{_docdir}/rpxy
cp LICENSE %{buildroot}%{_docdir}/rpxy/ cp LICENSE %{buildroot}%{_docdir}/rpxy/
cp README.md %{buildroot}%{_docdir}/rpxy/ cp README.md %{buildroot}%{_docdir}/rpxy/
%clean %clean
rm -rf %{buildroot} rm -rf %{buildroot}
%files %files
%license %{_docdir}/rpxy/LICENSE %license %{_docdir}/rpxy/LICENSE
%doc %{_docdir}/rpxy/README.md %doc %{_docdir}/rpxy/README.md
%{_bindir}/rpxy %{_bindir}/rpxy
%{_sysconfdir}/systemd/system/rpxy.service %{_sysconfdir}/systemd/system/rpxy.service
%post %post
systemctl daemon-reload systemctl daemon-reload
systemctl enable rpxy systemctl enable rpxy
%preun %preun
systemctl stop rpxy systemctl stop rpxy
%postun %postun
systemctl disable rpxy systemctl disable rpxy

View file

@ -1,11 +1,11 @@
[Unit] [Unit]
Description=rpxy Service Description=rpxy Service
After=network.target After=network.target
[Service] [Service]
ExecStart=/usr/local/bin/rpxy-start.sh ExecStart=/usr/local/bin/rpxy-start.sh
Restart=always Restart=always
User=nobody User=nobody
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target