Skip to content

Commit

Permalink
Add support for PBS v3.2.7 (#52)
Browse files Browse the repository at this point in the history
* Add support for PBS v3.2.7
* fix: paths must not contain interior null bytes
  • Loading branch information
clansty authored Sep 14, 2024
1 parent 99ffabc commit bb5c741
Show file tree
Hide file tree
Showing 20 changed files with 505 additions and 6 deletions.
8 changes: 4 additions & 4 deletions PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

```bash
# Fork the build
make fork-version NEW_VERSION=2.3.2 NEW_SHA=e6120a8f6ff36f627a4da3a1a51a1e47231f5cc8
make fork-version NEW_VERSION=3.2.7 NEW_SHA=cb3d41e838dec0e1002aaf5ee4c0e6cd28284c74

# Try to naively apply patches
# Fix patches until it succeeds
make tmp-env
make tmp-env-client

# Try to naively compile first
cd tmp/v2.3.2/proxmox-backup
cd tmp/v3.2.7/proxmox-backup
cargo build

# Try to run dev build first
Expand All @@ -31,7 +31,7 @@ make github-latest-release

## Build on your own

Refer to [PROESS.md](PROCESS.md).
Refer to [PROCESS.md](PROCESS.md).

```bash
make dev-build
Expand All @@ -54,4 +54,4 @@ make dev-run
```

You might as well pull the `*.deb` from within the image
and install on Debian Bullseye.
and install on Debian Bookworm.
4 changes: 2 additions & 2 deletions scripts/strip-cargo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ for package in *; do
while read cargo_config; do
echo -n > "$cargo_config"
git -C "$package" add "$(realpath "$cargo_config")"
done < <(find "$package" -wholename '*/.cargo/config')
done < <(find "$package" -wholename '*/.cargo/config' -o -wholename '*/.cargo/config.toml')

while read cargo_config; do
echo -n > "$cargo_config"
git -C "$package" add "$(realpath "$cargo_config")"
done < <(find "$package" -wholename '*/debian/cargo_home/config')
done < <(find "$package" -wholename '*/debian/cargo_home/config' -o -wholename '*/debian/cargo_home/config.toml')

while read debian_control; do
echo "Stripping '$debian_control'..."
Expand Down
102 changes: 102 additions & 0 deletions versions/v3.2.7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
ARG ARCH=
FROM ${ARCH}debian:bookworm AS toolchain

RUN apt-get -y update && \
apt-get -y install \
build-essential git-core \
lintian pkg-config quilt patch cargo \
nodejs node-colors node-commander \
libudev-dev libapt-pkg-dev \
libacl1-dev libpam0g-dev libfuse3-dev \
libsystemd-dev uuid-dev libssl-dev \
libclang-dev libjson-perl libcurl4-openssl-dev \
dh-exec dh-nodejs wget

RUN wget https://static.rust-lang.org/rustup/rustup-init.sh && \
chmod +x rustup-init.sh && \
./rustup-init.sh -y --default-toolchain stable

ENV RUSTUP_TOOLCHAIN=stable

WORKDIR /src

RUN for tool in /root/.cargo/bin/*; do ln -vsf $tool /usr/bin/; done
RUN /usr/bin/rustc --version
RUN git config --global user.email "[email protected]" && \
git config --global user.name "Docker Compile"

FROM toolchain as builder

# Clone all sources
ARG VERSION=master
ADD /versions/${VERSION}/ /patches/
RUN /patches/clone.bash

# Apply all patches
ADD /scripts/ /scripts/
RUN /scripts/apply-patches.bash /patches/server/*.patch
RUN /scripts/strip-cargo.bash
RUN /scripts/resolve-dependencies.bash

# A first required dep
RUN apt-get -y build-dep $PWD/pve-eslint
RUN cd pve-eslint/ && make dinstall

# A proxmox-perl-rs required deps
RUN apt-get -y build-dep $PWD/perlmod/perlmod $PWD/perlmod/perlmod-bin $PWD/perlmod/perlmod-macro
RUN cd perlmod/perlmod-bin && dpkg-buildpackage -us -uc -b && dpkg -i ../perlmod-bin*.deb

# A pve-common required deps
RUN apt-get -y build-dep $PWD/proxmox-perl-rs/pve-rs
RUN cd proxmox-perl-rs/pve-rs && make dinstall
RUN cd proxmox-perl-rs/common/pkg && make deb && dpkg -i *.deb
RUN apt-get -y build-dep $PWD/pve-common
RUN cd pve-common/ && ( make dinstall || apt-get -f -y install && make dinstall )

# Install dev dependencies of widget toolkit
RUN apt-get -y build-dep $PWD/proxmox-widget-toolkit
RUN cd proxmox-widget-toolkit/ && make deb && dpkg -i proxmox-widget-toolkit-dev*.deb

# Deps for all rest
RUN apt-get -y build-dep $PWD/proxmox-acme
RUN apt-get -y build-dep $PWD/proxmox-backup
RUN apt-get -y build-dep $PWD/proxmox-mini-journalreader
RUN apt-get -y build-dep $PWD/extjs
RUN apt-get -y build-dep $PWD/proxmox-i18n
RUN apt-get -y build-dep $PWD/pve-xtermjs/termproxy
RUN apt-get -y build-dep $PWD/pve-xtermjs/xterm.js
RUN apt-get -y build-dep $PWD/libjs-qrcodejs

# Compile ALL
RUN cd proxmox-backup/ && make deb
RUN cd extjs/ && make deb
RUN cd proxmox-i18n/ && make deb
RUN cd pve-xtermjs/termproxy/ && make deb
RUN cd pve-xtermjs/xterm.js/ && make deb
RUN cd proxmox-mini-journalreader/ && make deb
RUN cd libjs-qrcodejs/ && make deb
RUN cd proxmox-acme/ && make deb

# Copy all debian packages
RUN mkdir -p /deb && \
find /src/ -name '*.deb' -exec cp -av {} /deb/ \;

#=================================

FROM ${ARCH}debian:bookworm
COPY --from=builder /deb/ /deb/

# Install all packages
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get -y update && \
apt install -y runit ssmtp /deb/*.deb

# Add default configs
ADD /pbs/ /etc/proxmox-backup-default/

VOLUME /etc/proxmox-backup
VOLUME /var/log/proxmox-backup
VOLUME /var/lib/proxmox-backup

ADD runit/ /runit/
CMD ["runsvdir", "/runit"]
50 changes: 50 additions & 0 deletions versions/v3.2.7/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ARG DOCKER_ARCH
FROM ${DOCKER_ARCH}/debian:bookworm AS builder

RUN apt-get -y update && \
apt-get -y install \
build-essential git-core \
lintian pkg-config quilt patch cargo \
nodejs node-colors node-commander \
libudev-dev libapt-pkg-dev \
libacl1-dev libpam0g-dev libfuse3-dev \
libsystemd-dev uuid-dev libssl-dev \
libclang-dev libjson-perl libcurl4-openssl-dev \
dh-exec wget

WORKDIR /src

RUN /usr/bin/rustc --version
RUN git config --global user.email "[email protected]" && \
git config --global user.name "Docker Compile"

# Clone all sources
ARG VERSION=master
ADD /versions/${VERSION}/ /patches/
RUN /patches/clone.bash

# Install valid rust toolchain
ARG DOCKER_ARCH
RUN \
if [ "${DOCKER_ARCH}" != "arm32v7" ]; then \
wget https://static.rust-lang.org/rustup/rustup-init.sh && \
chmod +x rustup-init.sh && \
./rustup-init.sh -y --default-toolchain nightly && \
for tool in /root/.cargo/bin/*; do ln -vsf $tool /usr/bin/; done; \
fi

# Apply all patches
ADD /scripts/ /scripts/
RUN /scripts/apply-patches.bash /patches/server/*.patch /patches/client/*.patch /patches/client-${DOCKER_ARCH}/*.patch
RUN /scripts/strip-cargo.bash
RUN /scripts/experimental-cargo.bash
RUN /scripts/resolve-dependencies.bash

# Build
RUN \
. /root/.cargo/env; \
cargo build --manifest-path proxmox-backup/proxmox-backup-client/Cargo.toml --release && \
cargo build --manifest-path proxmox-backup/pxar-bin/Cargo.toml --release

# Bundle client
RUN /scripts/bundle-client.bash
56 changes: 56 additions & 0 deletions versions/v3.2.7/clone.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -eo pipefail

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

if [[ "$1" == "show-sha" ]]; then
VERSION="${2:-master}"
VERSION_DATE=""

tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
cd "$tmp_dir/"
trap 'cd ; rm -rf $tmp_dir' EXIT

perform() {
git clone "git://git.proxmox.com/git/$1.git" 2>/dev/null
if [[ -z "$VERSION_TIMESTAMP" ]]; then
REVISION=$(git -C "$1" rev-parse "$VERSION")
VERSION_TIMESTAMP=$(git -C "$1" log -1 --format=%ct "$VERSION")
else
while read TIMESTAMP REVISION; do
if [[ $TIMESTAMP -le $VERSION_TIMESTAMP ]]; then
break
fi
done < <(git -C "$1" log --format="%ct %H")
fi

CHANGE_TIME=$(git -C "$1" log -1 --format="%cd" $REVISION)

echo "$1 $REVISION # $CHANGE_TIME"
}
else
if [[ -n "$1" ]]; then
cd "$1"
fi

perform() {
if [[ ! -d "$1" ]]; then
git clone "git://git.proxmox.com/git/$1.git"
else
git -C "$1" fetch
fi
git -C "$1" checkout "$2" -f
git -C "$1" clean -fdx
}
fi

if [[ ! -e "$SCRIPT_DIR/versions" ]]; then
echo "Missing 'versions' file."
exit 1
fi

while read REPO COMMIT_SHA REST; do
echo "$REPO $COMMIT_SHA..." 1>&2
perform "$REPO" "$COMMIT_SHA"
done < "$SCRIPT_DIR/versions"
25 changes: 25 additions & 0 deletions versions/v3.2.7/server/proxmox-backup~fix-cargo.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/Makefile b/Makefile
index dfbaacab..d7620d73 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,7 @@ COMPILEDIR := target/$(DEB_HOST_RUST_TYPE)/release
else
COMPILEDIR := target/$(DEB_HOST_RUST_TYPE)/debug
endif
+CARGO_BUILD_ARGS += --target-dir target/$(DEB_HOST_RUST_TYPE)

ifeq ($(valgrind), yes)
CARGO_BUILD_ARGS += --features valgrind
diff --git a/debian/rules b/debian/rules
index fa94743d..675fd445 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,7 +9,7 @@ include /usr/share/rustc/architecture.mk

export BUILD_MODE=release

-export CARGO=/usr/share/cargo/bin/cargo
+export CARGO=/usr/bin/cargo

export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
13 changes: 13 additions & 0 deletions versions/v3.2.7/server/proxmox-backup~fix-kernel-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/www/panel/NodeInfo.js b/www/panel/NodeInfo.js
index 9d741e45..5196f64b 100644
--- a/www/panel/NodeInfo.js
+++ b/www/panel/NodeInfo.js
@@ -150,7 +150,7 @@ Ext.define('PBS.NodeInfoPanel', {
return data.kversion;
}
let kernel = data['current-kernel'];
- let buildDate = kernel.version.match(/\((.+)\)\s*$/)?.[1] ?? 'unknown';
+ let buildDate = kernel.version;
return `${kernel.sysname} ${kernel.release} (${buildDate})`;
},
value: '',
17 changes: 17 additions & 0 deletions versions/v3.2.7/server/proxmox-backup~hide-shell.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index a5ea390f..2853fe10 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -89,12 +89,6 @@ Ext.define('PBS.store.NavigationStore', {
expanded: true,
leaf: false,
children: [
- {
- text: gettext('Shell'),
- iconCls: 'fa fa-terminal',
- path: 'pbsXtermJsConsole',
- leaf: true,
- },
{
text: gettext('Storage / Disks'),
iconCls: 'fa fa-hdd-o',
53 changes: 53 additions & 0 deletions versions/v3.2.7/server/proxmox-backup~multi-arch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/debian/proxmox-backup-file-restore.install b/debian/proxmox-backup-file-restore.install
old mode 100644
new mode 100755
index 409988a3..8b4034bd
--- a/debian/proxmox-backup-file-restore.install
+++ b/debian/proxmox-backup-file-restore.install
@@ -1,4 +1,5 @@
+#! /usr/bin/dh-exec
usr/bin/proxmox-file-restore
-usr/lib/x86_64-linux-gnu/proxmox-backup/file-restore/proxmox-restore-daemon
+usr/lib/${DEB_HOST_MULTIARCH}/proxmox-backup/file-restore/proxmox-restore-daemon
usr/share/man/man1/proxmox-file-restore.1
usr/share/zsh/vendor-completions/_proxmox-file-restore
diff --git a/debian/proxmox-backup-server.install b/debian/proxmox-backup-server.install
old mode 100644
new mode 100755
index ef1e9ba1..29b6b234
--- a/debian/proxmox-backup-server.install
+++ b/debian/proxmox-backup-server.install
@@ -1,3 +1,4 @@
+#! /usr/bin/dh-exec
etc/pbs-enterprise.list /etc/apt/sources.list.d/
etc/proxmox-backup-banner.service /lib/systemd/system/
etc/proxmox-backup-daily-update.service /lib/systemd/system/
@@ -7,11 +8,11 @@ etc/proxmox-backup.service /lib/systemd/system/
usr/bin/pmt
usr/bin/pmtx
usr/bin/proxmox-tape
-usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-api
-usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-banner
-usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-proxy
-usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-daily-update
-usr/lib/x86_64-linux-gnu/proxmox-backup/sg-tape-cmd
+usr/lib/${DEB_HOST_MULTIARCH}/proxmox-backup/proxmox-backup-api
+usr/lib/${DEB_HOST_MULTIARCH}/proxmox-backup/proxmox-backup-banner
+usr/lib/${DEB_HOST_MULTIARCH}/proxmox-backup/proxmox-backup-proxy
+usr/lib/${DEB_HOST_MULTIARCH}/proxmox-backup/proxmox-daily-update
+usr/lib/${DEB_HOST_MULTIARCH}/proxmox-backup/sg-tape-cmd
usr/sbin/pbs2to3
usr/sbin/proxmox-backup-debug
usr/sbin/proxmox-backup-manager
diff --git a/debian/rules b/debian/rules
index a82c3e12..92fd6e90 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,6 +2,7 @@
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
DH_VERBOSE = 1
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

include /usr/share/dpkg/pkg-info.mk
include /usr/share/rustc/architecture.mk
13 changes: 13 additions & 0 deletions versions/v3.2.7/server/proxmox-backup~no-cargo.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/debian/rules b/debian/rules
index 92fd6e90..fa94743d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -28,7 +28,7 @@ endif
override_dh_auto_configure:
@perl -ne 'if (/^version\s*=\s*"(\d+(?:\.\d+)+)"/) { my $$v_cargo = $$1; my $$v_deb = "$(DEB_VERSION_UPSTREAM)"; \
die "ERROR: d/changelog <-> Cargo.toml version mismatch: $$v_cargo != $$v_deb\n" if $$v_cargo ne $$v_deb; exit(0); }' Cargo.toml
- $(CARGO) prepare-debian $(CURDIR)/debian/cargo_registry --link-from-system
+ #$(CARGO) prepare-debian --help $(CURDIR)/debian/cargo_registry --link-from-system
dh_auto_configure

override_dh_auto_build:
13 changes: 13 additions & 0 deletions versions/v3.2.7/server/proxmox-mini-journalreader.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/Makefile b/src/Makefile
index 449004f..eeee305 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -5,7 +5,7 @@ BIN_DIR ?= $(DESTDIR)/usr/bin
MAN1_DIR ?= $(DESTDIR)/usr/share/man/man1

LIBS := libsystemd
-CFLAGS += -Werror -Wall -Wextra -Wl,-z,relro -g -O2 --std=gnu11
+CFLAGS += -Wall -Wextra -Wl,-z,relro -g -O2 --std=gnu11
CFLAGS += -fstack-protector-strong -D_FORTIFY_SOURCE=2
CFLAGS += $(shell pkg-config --cflags $(LIBS))
LDFLAGS += $(shell pkg-config --libs $(LIBS))
Loading

0 comments on commit bb5c741

Please sign in to comment.