debian: add files for packaging

Since we now have a standalone repository for Proxmox VE related
crates, add the required files for packaging the crates contained in
this repository.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
Stefan Hanreich 2024-11-12 13:25:39 +01:00 committed by Thomas Lamprecht
parent 0bd09fe6fa
commit f41170ba15
11 changed files with 258 additions and 11 deletions

5
.cargo/config.toml Normal file
View File

@ -0,0 +1,5 @@
[source]
[source.debian-packages]
directory = "/usr/share/cargo/registry"
[source.crates-io]
replace-with = "debian-packages"

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
/target
/*/target
Cargo.lock
**/*.rs.bk
/*.buildinfo
/*.changes
/build
/*-deb

17
Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[workspace]
members = [
"proxmox-ve-config",
]
exclude = [
"build",
]
resolver = "2"
[workspace.package]
authors = ["Proxmox Support Team <support@proxmox.com>"]
edition = "2021"
license = "AGPL-3"
homepage = "https://proxmox.com"
exclude = [ "debian" ]
rust-version = "1.82"

69
Makefile Normal file
View File

@ -0,0 +1,69 @@
# Shortcut for common operations:
CRATES != echo proxmox-*/Cargo.toml | sed -e 's|/Cargo.toml||g'
# By default we just run checks:
.PHONY: all
all: check
.PHONY: deb
deb: $(foreach c,$(CRATES), $c-deb)
echo $(foreach c,$(CRATES), $c-deb)
lintian build/*.deb
.PHONY: dsc
dsc: $(foreach c,$(CRATES), $c-dsc)
echo $(foreach c,$(CRATES), $c-dsc)
lintian build/*.dsc
.PHONY: autopkgtest
autopkgtest: $(foreach c,$(CRATES), $c-autopkgtest)
.PHONY: dinstall
dinstall:
$(MAKE) clean
$(MAKE) deb
sudo -k dpkg -i build/librust-*.deb
%-deb:
./build.sh $*
touch $@
%-dsc:
BUILDCMD='dpkg-buildpackage -S -us -uc -d' ./build.sh $*
touch $@
%-autopkgtest:
autopkgtest build/$* build/*.deb -- null
touch $@
.PHONY: check
check:
cargo test
# Prints a diff between the current code and the one rustfmt would produce
.PHONY: fmt
fmt:
cargo +nightly fmt -- --check
# Doc without dependencies
.PHONY: doc
doc:
cargo doc --no-deps
.PHONY: clean
clean:
cargo clean
rm -rf build/
rm -f -- *-deb *-dsc *-autopkgtest *.build *.buildinfo *.changes
.PHONY: update
update:
cargo update
%-upload: %-deb
cd build; \
dcmd --deb rust-$*_*.changes \
| grep -v '.changes$$' \
| tar -cf "$@.tar" -T-; \
cat "$@.tar" | ssh -X repoman@repo.proxmox.com upload --product devel --dist bookworm

35
build.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
set -eux
export CARGO=/usr/bin/cargo
export RUSTC=/usr/bin/rustc
CRATE=$1
BUILDCMD=${BUILDCMD:-"dpkg-buildpackage -b -uc -us"}
mkdir -p build
echo system >build/rust-toolchain
rm -rf "build/${CRATE}"
CONTROL="$PWD/${CRATE}/debian/control"
if [ -e "$CONTROL" ]; then
# check but only warn, debcargo fails anyway if crates are missing
dpkg-checkbuilddeps $PWD/${CRATE}/debian/control || true
# rm -f "$PWD/${CRATE}/debian/control"
fi
debcargo package \
--config "$PWD/${CRATE}/debian/debcargo.toml" \
--changelog-ready \
--no-overlay-write-back \
--directory "$PWD/build/${CRATE}" \
"${CRATE}" \
"$(dpkg-parsechangelog -l "${CRATE}/debian/changelog" -SVersion | sed -e 's/-.*//')"
cd "build/${CRATE}"
rm -f debian/source/format.debcargo.hint
${BUILDCMD}
cp debian/control "$CONTROL"

44
bump.sh Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
package=$1
if [[ -z "$package" ]]; then
echo "USAGE:"
echo -e "\t bump.sh <crate> [patch|minor|major|<version>]"
echo ""
echo "Defaults to bumping patch version by 1"
exit 0
fi
cargo_set_version="$(command -v cargo-set-version)"
if [[ -z "$cargo_set_version" || ! -x "$cargo_set_version" ]]; then
echo 'bump.sh requires "cargo set-version", provided by "cargo-edit".'
exit 1
fi
if [[ ! -e "$package/Cargo.toml" ]]; then
echo "Invalid crate '$package'"
exit 1
fi
version=$2
if [[ -z "$version" ]]; then
version="patch"
fi
case "$version" in
patch|minor|major)
bump="--bump"
;;
*)
bump=
;;
esac
cargo_toml="$package/Cargo.toml"
changelog="$package/debian/changelog"
cargo set-version -p "$package" $bump "$version"
version="$(cargo metadata --format-version=1 | jq ".packages[] | select(.name == \"$package\").version" | sed -e 's/\"//g')"
DEBFULLNAME="Proxmox Support Team" DEBEMAIL="support@proxmox.com" dch --no-conf --changelog "$changelog" --newversion "$version-1" --distribution stable
git commit --edit -sm "bump $package to $version-1" Cargo.toml "$cargo_toml" "$changelog"

View File

@ -1,25 +1,22 @@
[package]
name = "proxmox-ve-config"
version = "0.1.0"
edition = "2021"
authors = [
"Wolfgang Bumiller <w.bumiller@proxmox.com>",
"Stefan Hanreich <s.hanreich@proxmox.com>",
"Proxmox Support Team <support@proxmox.com>",
]
description = "Proxmox VE config parsing"
license = "AGPL-3"
authors.workspace = true
edition.workspace = true
license.workspace = true
exclude.workspace = true
[dependencies]
log = "0.4"
anyhow = "1"
nix = "0.26"
thiserror = "1.0.59"
serde = { version = "1", features = [ "derive" ] }
serde_json = "1"
serde_plain = "1"
serde_with = "2.3.3"
serde_with = "3"
proxmox-schema = "3.1.0"
proxmox-sys = "0.5.3"
proxmox-schema = "3.1.2"
proxmox-sys = "0.6.4"
proxmox-sortable-macro = "0.1.3"

View File

@ -0,0 +1,5 @@
proxmox-ve-config (0.1.0) UNRELEASED; urgency=medium
* Initial release.
-- Proxmox Support Team <support@proxmox.com> Mon, 03 Jun 2024 10:51:11 +0200

View File

@ -0,0 +1,46 @@
Source: proxmox-ve-config
Section: rust
Priority: optional
Maintainer: Proxmox Support Team <support@proxmox.com>
Build-Depends: cargo:native,
debhelper-compat (= 13),
dh-sequence-cargo,
librust-anyhow-1+default-dev,
librust-log-0.4+default-dev (>= 0.4.17-~~),
librust-nix-0.26+default-dev (>= 0.26.1-~~),
librust-thiserror-dev (>= 1.0.59-~~),
librust-proxmox-schema-3+default-dev,
librust-proxmox-sortable-macro-dev,
librust-proxmox-sys-dev,
librust-serde-1+default-dev,
librust-serde-1+derive-dev,
librust-serde-json-1+default-dev,
librust-serde-plain-1+default-dev,
librust-serde-with+default-dev,
libstd-rust-dev,
netbase,
python3,
rustc:native (>= 1.82),
Standards-Version: 4.7.0
Homepage: https://www.proxmox.com
Package: librust-proxmox-ve-config-dev
Architecture: any
Multi-Arch: same
Depends:
${misc:Depends},
librust-anyhow-1+default-dev,
librust-log-0.4+default-dev (>= 0.4.17-~~),
librust-nix-0.26+default-dev (>= 0.26.1-~~),
librust-thiserror-dev (>= 1.0.59-~~),
librust-proxmox-schema-3+default-dev,
librust-proxmox-sortable-macro-dev,
librust-proxmox-sys-dev,
librust-serde-1+default-dev,
librust-serde-1+derive-dev,
librust-serde-json-1+default-dev,
librust-serde-plain-1+default-dev,
librust-serde-with+default-dev,
libstd-rust-dev,
Description: Library for reading and writing the configuration files of Proxmox
Virtual Enviroment.

View File

@ -0,0 +1,18 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files:
*
Copyright: 2019 - 2024 Proxmox Server Solutions GmbH <support@proxmox.com>
License: AGPL-3.0-or-later
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -0,0 +1,3 @@
overlay = "."
crate_src_path = ".."
maintainer = "Proxmox Support Team <support@proxmox.com>"