-include defines.mk
-
CARGO ?= cargo
ifeq ($(BUILD_MODE), release)
mkdir build
echo system >build/rust-toolchain
cp -a ./Cargo.toml ./build
- cp -a ./scripts ./build
cp -a ./common ./build
cp -a ./pve-rs ./build
cp -a ./pmg-rs ./build
- cp -a ./Proxmox ./build
- cp defines.mk ./build
- mv ./build/Proxmox ./build/common/pkg
-# The template.pm is required by the products to produce their Proxmox::Lib
- mkdir ./build/Proxmox
- mkdir ./build/Proxmox/Lib
- cp ./Proxmox/Lib/template.pm ./build/Proxmox/Lib
+# Replace the symlinks with copies of the common code in pve/pmg:
+ cd build; for i in pve pmg; do \
+ rm ./$$i-rs/common ; \
+ mkdir ./$$i-rs/common ; \
+ cp -R ./common/src ./$$i-rs/common/src ; \
+ done
# So the common packages end up in ./build, rather than ./build/common
mv ./build/common/pkg ./build/common-pkg
+++ /dev/null
-package Proxmox::Lib::Common;
-
-=head1 NAME
-
-Proxmox::Lib::Common - base module for rust bindings common between PVE and PMG
-
-=head1 SYNOPSIS
-
- package Proxmox::RS::CalendarEvent;
-
- use base 'Proxmox::Lib::Common';
-
- BEGIN { __PACKAGE__->bootstrap(); }
-
- 1;
-
-=head1 DESCRIPTION
-
-This is the base modules for bindings which are provided by both PVE and PMG. This will ensure that
-either Proxmox::Lib::PVE or Proxmox::Lib::PMG have been loaded (in that order) and then use
-whichever was loaded.
-
-=cut
-
-use vars qw(@ISA);
-
-sub library {
- return '-current';
-}
-
-BEGIN {
- my $data = ($::{'proxmox-rs-library'} //= {});
- my $base = $data->{-package};
- if ($base) {
- push @ISA, $base;
- } else {
- eval { require Proxmox::Lib::PVE and push @ISA, 'Proxmox::Lib::PVE'; };
- eval { require Proxmox::Lib::PMG and push @ISA, 'Proxmox::Lib::PMG'; } if $@;
- die $@ if $@;
- }
-}
-
-1;
+++ /dev/null
-package Proxmox::Lib::{{PRODUCT}};
-
-=head1 NAME
-
-Proxmox::Lib::{{PRODUCT}} - base module for {{PRODUCT}} rust bindings
-
-=head1 SYNOPSIS
-
- package {{PRODUCT}}::RS::SomeBindings;
-
- use base 'Proxmox::Lib::{{PRODUCT}}';
-
- BEGIN { __PACKAGE__->bootstrap(); }
-
- 1;
-
-=head1 DESCRIPTION
-
-This is the base module of all {{PRODUCT}} bindings.
-Its job is to ensure the 'lib{{LIBRARY}}.so' library is loaded and provide a 'bootstrap' class
-method to load the actual code.
-
-=cut
-
-use DynaLoader;
-
-sub library {
- return '{{LIBRARY}}';
-}
-
-# Keep on a single line, modified by testsuite!
-sub libdirs { return (map "-L$_/auto", @INC); }
-
-sub load : prototype($) {
- my ($pkg) = @_;
-
- my $mod_name = $pkg->library();
-
- my @dirs = $pkg->libdirs();
- my $mod_file = DynaLoader::dl_findfile({{DEBUG_LIBPATH}}@dirs, $mod_name);
- die "failed to locate shared library for $mod_name (lib${mod_name}.so)\n" if !$mod_file;
-
- my $lib = DynaLoader::dl_load_file($mod_file)
- or die "failed to load library '$mod_file'\n";
-
- my $data = ($::{'proxmox-rs-library'} //= {});
- $data->{$mod_name} = $lib;
- $data->{-current} //= $lib;
- $data->{-package} //= $pkg;
-}
-
-sub bootstrap {
- my ($pkg) = @_;
-
- my $mod_name = $pkg->library();
-
- my $bootstrap_name = 'boot_' . ($pkg =~ s/::/__/gr);
-
- my $lib = $::{'proxmox-rs-library'}
- or die "rust library not available for '{PRODUCT}'\n";
- $lib = $lib->{$mod_name};
-
- my $sym = DynaLoader::dl_find_symbol($lib, $bootstrap_name);
- die "failed to locate '$bootstrap_name'\n" if !defined $sym;
- my $boot = DynaLoader::dl_install_xsub($bootstrap_name, $sym, "src/FIXME.rs");
- $boot->();
-}
-
-BEGIN {
- __PACKAGE__->load();
- __PACKAGE__->bootstrap();
- init();
-}
-
-1;
DESTDIR=
+PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
+ --lib=- \
+ --lib-tag=proxmox \
+ --lib-package=Proxmox::Lib::Common \
+ --lib-prefix=Proxmox
+
# Point to any generated pm file (Proxmox/ dir is already present in this package)
-Proxmox/RS/CalendarEvent.pm: ../scripts/genpackage.pl
- perl ../scripts/genpackage.pl Common \
+Proxmox/RS/CalendarEvent.pm:
+ $(PERLMOD_GENPACKAGE) \
Proxmox::RS::APT::Repositories \
Proxmox::RS::CalendarEvent \
Proxmox::RS::Subscription
install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORLIB)
find PVE \! -type d -print -exec install -Dm644 '{}' $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/{}' ';'
find Proxmox \! -type d -print -exec install -Dm644 '{}' $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/{}' ';'
- rm $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/Proxmox/Lib/template.pm'
.PHONY: deb
deb: $(DEB)
--- /dev/null
+package Proxmox::Lib::Common;
+
+=head1 NAME
+
+Proxmox::Lib::Common - base module for rust bindings common between PVE and PMG
+
+=head1 SYNOPSIS
+
+ package Proxmox::RS::CalendarEvent;
+
+ use base 'Proxmox::Lib::Common';
+
+ BEGIN { __PACKAGE__->bootstrap(); }
+
+ 1;
+
+=head1 DESCRIPTION
+
+This is the base modules for bindings which are provided by both PVE and PMG. This will ensure that
+either Proxmox::Lib::PVE or Proxmox::Lib::PMG have been loaded (in that order) and then use
+whichever was loaded.
+
+=cut
+
+use vars qw(@ISA);
+
+sub library {
+ return '-current';
+}
+
+BEGIN {
+ my $data = ($::{'proxmox-rs-library'} //= {});
+ my $base = $data->{-package};
+ if ($base) {
+ push @ISA, $base;
+ } else {
+ eval { require Proxmox::Lib::PVE and push @ISA, 'Proxmox::Lib::PVE'; };
+ eval { require Proxmox::Lib::PMG and push @ISA, 'Proxmox::Lib::PMG'; } if $@;
+ die $@ if $@;
+ }
+}
+
+1;
+++ /dev/null
-../scripts
\ No newline at end of file
+++ /dev/null
-define package_template
- sed -r \
- -e 's/\{\{PRODUCT\}\}/$(1)/g;' \
- -e 's/\{\{LIBRARY\}\}/$(2)/g;' \
- -e 's|\{\{DEBUG_LIBPATH\}\}|$(DEBUG_LIBPATH)|g;' \
- $(3)Proxmox/Lib/template.pm \
- >Proxmox/Lib/$(1).pm
-endef
-include ../defines.mk
include /usr/share/dpkg/default.mk
PACKAGE=libpmg-rs-perl
PM_DIR := PMG
+PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
+ --lib=pmg_rs \
+ --lib-tag=proxmox \
+ --lib-package=Proxmox::Lib::PMG \
+ --lib-prefix=PMG
+
+PERLMOD_PACKAGES := \
+ PMG::RS::APT::Repositories \
+ PMG::RS::Acme \
+ PMG::RS::CSR \
+ PMG::RS::OpenId \
+ PMG::RS::TFA
+
ifeq ($(BUILD_MODE), release)
CARGO_BUILD_ARGS += --release
+TARGET_DIR=release
+else
+TARGET_DIR=debug
endif
-all: Proxmox/Lib/PMG.pm
+all:
ifneq ($(BUILD_MODE), skip)
cargo build $(CARGO_BUILD_ARGS)
endif
-PMG: ../scripts/genpackage.pl
- perl ../scripts/genpackage.pl PMG \
- PMG::RS::APT::Repositories \
- PMG::RS::Acme \
- PMG::RS::CSR \
- PMG::RS::OpenId \
- PMG::RS::TFA
-
-Proxmox/Lib/PMG.pm: ../Proxmox/Lib/template.pm
- mkdir -p Proxmox/Lib
- $(call package_template,PMG,pmg_rs,../)
+PMG: Proxmox/Lib/PMG.pm
+Proxmox/Lib/PMG.pm:
+ $(PERLMOD_GENPACKAGE) $(PERLMOD_PACKAGES)
.PHONY: install
install: ../target/release/libpmg_rs.so Proxmox/Lib/PMG.pm PMG
--- /dev/null
+../common
\ No newline at end of file
Build-Depends:
debhelper (>= 12),
dh-cargo (>= 24),
+ perlmod-bin,
cargo:native <!nocheck>,
rustc:native <!nocheck>,
libstd-rust-dev <!nocheck>,
-#[path = "../../common/src/mod.rs"]
+#[path = "../common/src/mod.rs"]
pub mod common;
pub mod acme;
-include ../defines.mk
include /usr/share/dpkg/default.mk
PACKAGE=libpve-rs-perl
PM_DIR := PVE
+PERLMOD_GENPACKAGE := /usr/lib/perlmod/genpackage.pl \
+ --lib=pve_rs \
+ --lib-tag=proxmox \
+ --lib-package=Proxmox::Lib::PVE \
+ --lib-prefix=PVE
+
+PERLMOD_PACKAGES := \
+ PVE::RS::APT::Repositories \
+ PVE::RS::OpenId \
+ PVE::RS::ResourceScheduling::Static \
+ PVE::RS::TFA
+
ifeq ($(BUILD_MODE), release)
CARGO_BUILD_ARGS += --release
TARGET_DIR=release
TARGET_DIR=debug
endif
-all: PVE Proxmox/Lib/PVE.pm
+all: PVE
ifneq ($(BUILD_MODE), skip)
cargo build $(CARGO_BUILD_ARGS)
mkdir -p test/Proxmox/Lib
Proxmox/Lib/PVE.pm >test/Proxmox/Lib/PVE.pm
endif
-PVE: ../scripts/genpackage.pl
- perl ../scripts/genpackage.pl PVE \
- PVE::RS::APT::Repositories \
- PVE::RS::OpenId \
- PVE::RS::ResourceScheduling::Static \
- PVE::RS::TFA
-
-Proxmox/Lib/PVE.pm: ../Proxmox/Lib/template.pm
- mkdir -p Proxmox/Lib
- $(call package_template,PVE,pve_rs,../)
+PVE: Proxmox/Lib/PVE.pm
+Proxmox/Lib/PVE.pm:
+ $(PERLMOD_GENPACKAGE) $(PERLMOD_PACKAGES)
check: all
$(MAKE) -C test test
--- /dev/null
+../common
\ No newline at end of file
Build-Depends:
debhelper (>= 12),
dh-cargo (>= 24),
+ perlmod-bin,
cargo:native <!nocheck>,
rustc:native <!nocheck>,
libstd-rust-dev <!nocheck>,
//! Rust library for the Proxmox VE code base.
-#[path = "../../common/src/mod.rs"]
+#[path = "../common/src/mod.rs"]
pub mod common;
pub mod apt;
+++ /dev/null
-#!/usr/bin/env perl
-
-# Create a perl package given a product and package name.
-
-use strict;
-use warnings;
-
-use File::Path qw(make_path);
-
-my $product = shift @ARGV or die "missing product name (PVE, PMG or Common)\n";
-
-die "missing package name\n" if !@ARGV;
-
-for my $package (@ARGV) {
- my $path = ($package =~ s@::@/@gr) . ".pm";
-
- print "Generating $path\n";
-
- $path =~ m@^(.*)/[^/]+@;
- make_path($1, { mode => 0755 });
-
- open(my $fh, '>', $path) or die "failed to open '$path' for writing: $!\n";
-
- print {$fh} <<"EOF";
-package $package;
-use base 'Proxmox::Lib::$product';
-BEGIN { __PACKAGE__->bootstrap(); }
-1;
-EOF
-
- close($fh);
-}