]> git.proxmox.com Git - pve-installer.git/commitdiff
move ProxmoxInstallerSetup to Proxmox::Install::Setup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 2 Apr 2023 09:20:43 +0000 (11:20 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Jun 2023 07:36:58 +0000 (09:36 +0200)
in preparation of splitting out more code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Makefile
Proxmox/Install/Setup.pm [new file with mode: 0644]
Proxmox/Makefile [new file with mode: 0644]
ProxmoxInstallerSetup.pm [deleted file]
debian/rules
proxinstall

index 72f9202fae6a0e797fce4fc8f2d934d80bebacda..5ded58b5012cc6fe522d217841f5eb7048103060 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,7 @@ HTMLDIR=$(VARLIBDIR)/html/common
 .PHONY: install
 install: ${INSTALLER_SOURCES} ${HTML_COMMON_SOURCES} ${HTML_SOURCES}
        $(MAKE) -C banner install
+       $(MAKE) -C Proxmox install
        install -D -m 644 interfaces ${DESTDIR}/etc/network/interfaces
        install -D -m 755 fake-start-stop-daemon ${VARLIBDIR}/fake-start-stop-daemon
        install -D -m 755 policy-disable-rc.d $(VARLIBDIR)/policy-disable-rc.d
diff --git a/Proxmox/Install/Setup.pm b/Proxmox/Install/Setup.pm
new file mode 100644 (file)
index 0000000..18fd690
--- /dev/null
@@ -0,0 +1,61 @@
+package Proxmox::Install::Setup;
+
+use strict;
+use warnings;
+
+my $product_cfg = {
+    pve => {
+       fullname => 'Proxmox VE',
+       port => '8006',
+       enable_btrfs => 1,
+       bridged_network => 1,
+    },
+    pmg => {
+       fullname => 'Proxmox Mail Gateway',
+       port => '8006',
+       enable_btrfs => 0,
+       bridged_network => 0,
+    },
+    pbs => {
+       fullname => 'Proxmox Backup Server',
+       port => '8007',
+       enable_btrfs => 0,
+       bridged_network => 0,
+    },
+};
+
+sub setup {
+    my $cd_info = get_cd_info();
+    my $product = $cd_info->{product};
+
+    my $setup_info = $product_cfg->{$product};
+    die "unknown product '$product'\n" if !$setup_info;
+
+    $setup_info->{product} = $product;
+
+    return ($setup_info, $cd_info);
+}
+
+sub get_cd_info {
+    my $info_fn = '/.cd-info'; # default place in the ISO environment
+    if (!-f $info_fn && -f "cd-info.test") {
+       $info_fn = "cd-info.test"; # use from CWD for test mode
+    }
+
+    open(my $fh, '<', $info_fn) or die "Could not open CD info file '$info_fn' $!";
+
+    my $cd_info = {};
+    while (my $line = <$fh>) {
+       chomp $line;
+       if ($line =~ /^(\S+)=['"]?(.+?)['"]?$/) { # we control cd-info content, so good enough.
+           $cd_info->{lc($1)} = $2;
+       }
+    }
+    close ($fh);
+
+    die "CD-info is missing required key 'product'!\n" if !defined $cd_info->{product};
+
+    return $cd_info;
+}
+
+1;
diff --git a/Proxmox/Makefile b/Proxmox/Makefile
new file mode 100644 (file)
index 0000000..028010d
--- /dev/null
@@ -0,0 +1,18 @@
+all:
+
+DESTDIR=
+VARLIBDIR=$(DESTDIR)/var/lib/proxmox-installer
+PERL5DIR=$(DESTDIR)/usr/share/perl5/Proxmox
+
+#PERL_MODULES=$(shell git ls-files . | grep '.pm$')
+PERL_MODULES=\
+    Install/Setup.pm \
+
+.PHONY: install
+install: $(PERL_MODULES)
+       for f in $(PERL_MODULES); \
+           do install -D -m 644 "$$f" "$(PERL5DIR)/$$f"; \
+       done
+
+.PHONY: clean
+clean:
diff --git a/ProxmoxInstallerSetup.pm b/ProxmoxInstallerSetup.pm
deleted file mode 100644 (file)
index d13838b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package ProxmoxInstallerSetup;
-
-use strict;
-use warnings;
-
-my $product_cfg = {
-    pve => {
-       fullname => 'Proxmox VE',
-       port => '8006',
-       enable_btrfs => 1,
-       bridged_network => 1,
-    },
-    pmg => {
-       fullname => 'Proxmox Mail Gateway',
-       port => '8006',
-       enable_btrfs => 0,
-       bridged_network => 0,
-    },
-    pbs => {
-       fullname => 'Proxmox Backup Server',
-       port => '8007',
-       enable_btrfs => 0,
-       bridged_network => 0,
-    },
-};
-
-sub setup {
-    my $cd_info = get_cd_info();
-    my $product = $cd_info->{product};
-
-    my $setup_info = $product_cfg->{$product};
-    die "unknown product '$product'\n" if !$setup_info;
-
-    $setup_info->{product} = $product;
-
-    return ($setup_info, $cd_info);
-}
-
-sub get_cd_info {
-    my $info_fn = '/.cd-info'; # default place in the ISO environment
-    if (!-f $info_fn && -f "cd-info.test") {
-       $info_fn = "cd-info.test"; # use from CWD for test mode
-    }
-
-    open(my $fh, '<', $info_fn) or die "Could not open CD info file '$info_fn' $!";
-
-    my $cd_info = {};
-    while (my $line = <$fh>) {
-       chomp $line;
-       if ($line =~ /^(\S+)=['"]?(.+?)['"]?$/) { # we control cd-info content, so good enough.
-           $cd_info->{lc($1)} = $2;
-       }
-    }
-    close ($fh);
-
-    die "CD-info is missing required key 'product'!\n" if !defined $cd_info->{product};
-
-    return $cd_info;
-}
-
-1;
index be74737f255936de846220e28a8e33fca000c712..462e4b25d32dfde413f7ba3a1fe0a950697b0c90 100755 (executable)
@@ -4,16 +4,9 @@
 #DH_VERBOSE = 1
 
 
-SETUPFN = "/usr/share/perl5/ProxmoxInstallerSetup.pm"
-
 %:
        dh $@
 
-# FIXME: could all be in d/install or in makefile?!
-override_dh_auto_install:
-       install -D -m 0644 ProxmoxInstallerSetup.pm $(CURDIR)/debian/proxmox-installer/${SETUPFN}
-       dh_auto_install --destdir debian/proxmox-installer
-
 override_dh_missing:
        dh_missing --fail-missing
 
index 86f2a8cb38d9bf69ea3b8ce5a70e0a9c68546bac..c5c62b3055870356d182bc8f7441d2c266280b96 100755 (executable)
@@ -23,7 +23,7 @@ use File::Path;
 use Time::HiRes;
 use POSIX ":sys_wait_h";
 
-use ProxmoxInstallerSetup;
+use Proxmox::Install::Setup;
 
 if (!$ENV{G_SLICE} ||  $ENV{G_SLICE} ne "always-malloc") {
     die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
@@ -37,7 +37,7 @@ if (!GetOptions('testmode=s' => \$opt_testmode)) {
 
 $ENV{'LVM_SUPPRESS_FD_WARNINGS'} = '1';
 
-my ($setup, $cd_info) = ProxmoxInstallerSetup::setup();
+my ($setup, $cd_info) = Proxmox::Install::Setup::setup();
 
 my $zfstestpool = "test_rpool";
 my $zfspoolname = $opt_testmode ? $zfstestpool : 'rpool';