Skip to content

Commit f02477f

Browse files
committed
add pve-install pve-container pve-common-patch
1 parent 6778e54 commit f02477f

12 files changed

Lines changed: 366 additions & 0 deletions

‎.gitmodules‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313
[submodule "packages/pve-common/pve-common"]
1414
path = packages/pve-common/pve-common
1515
url = https://git.proxmox.com/git/pve-common
16+
[submodule "packages/pve-installer/pve-installer"]
17+
path = packages/pve-installer/pve-installer
18+
url = https://git.proxmox.com/git/pve-installer.git
19+
[submodule "packages/pve-container/pve-container"]
20+
path = packages/pve-container/pve-container
21+
url = https://git.proxmox.com/git/pve-container.git

‎packages/pve-common/series‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
patches/001-add-for-port.patch
2+
patches/changelog/001-add-changlog-8.1.0-1.patch
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
2+
index 1664a35..73f60f0 100644
3+
--- a/src/PVE/LXC/Config.pm
4+
+++ b/src/PVE/LXC/Config.pm
5+
@@ -473,7 +473,7 @@ my $confdesc = {
6+
arch => {
7+
optional => 1,
8+
type => 'string',
9+
- enum => ['amd64', 'i386', 'arm64', 'armhf', 'riscv32', 'riscv64'],
10+
+ enum => ['amd64', 'i386', 'arm64', 'armhf', 'riscv32', 'riscv64', 'loongarch64'],
11+
description => "OS architecture type.",
12+
default => 'amd64',
13+
},
14+
diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
15+
index 5c9114c..cae55b1 100644
16+
--- a/src/PVE/LXC/Setup.pm
17+
+++ b/src/PVE/LXC/Setup.pm
18+
@@ -135,17 +135,6 @@ sub new {
19+
if (!defined($conf->{arch})) {
20+
my $arch = eval { $self->protected_call(sub { $plugin->detect_architecture() }) };
21+
22+
- if (my $err = $@) {
23+
- warn "Architecture detection failed: $err" if $err;
24+
- }
25+
-
26+
- if (!defined($arch)) {
27+
- $arch = 'amd64';
28+
- print "Falling back to $arch.\nUse `pct set VMID --arch ARCH` to change.\n";
29+
- } else {
30+
- print "Detected container architecture: $arch\n";
31+
- }
32+
-
33+
$conf->{arch} = $arch;
34+
}
35+
36+
diff --git a/src/PVE/LXC/Setup/Plugin.pm b/src/PVE/LXC/Setup/Plugin.pm
37+
index b9d9c2d..533afe0 100644
38+
--- a/src/PVE/LXC/Setup/Plugin.pm
39+
+++ b/src/PVE/LXC/Setup/Plugin.pm
40+
@@ -6,6 +6,7 @@ use strict;
41+
use warnings;
42+
43+
use Carp;
44+
+use PVE::Tools;
45+
46+
sub new {
47+
my ($class, $conf, $rootdir, $os_release) = @_;
48+
@@ -64,7 +65,48 @@ sub ssh_host_key_types_to_generate {
49+
50+
sub detect_architecture {
51+
my ($self) = @_;
52+
- croak "implement me in sub-class\n";
53+
+ # see https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
54+
+ my $supported_elf_machine = {
55+
+ 0x03 => 'i386',
56+
+ 0x3e => 'amd64',
57+
+ 0x28 => 'armhf',
58+
+ 0xb7 => 'arm64',
59+
+ 0xf3 => 'riscv',
60+
+ 0x2 => 'loongarch64',
61+
+ };
62+
+
63+
+ my $elf_fn = '/bin/sh'; # '/bin/sh' is POSIX mandatory
64+
+ my $detect_arch = sub {
65+
+ # chroot avoids a problem where we check the binary of the host system
66+
+ # if $elf_fn is an absolut symlink (e.g. $rootdir/bin/sh -> /bin/bash)
67+
+ open(my $fh, "<", $elf_fn) or die "open '$elf_fn' failed: $!\n";
68+
+ binmode($fh);
69+
+
70+
+ my $length = read($fh, my $data, 20) or die "read failed: $!\n";
71+
+
72+
+ # 4 bytes ELF magic number and 1 byte ELF class, padding, machine
73+
+ my ($magic, $class, undef, $machine) = unpack("A4CA12n", $data);
74+
+
75+
+ die "'$elf_fn' does not resolve to an ELF!\n"
76+
+ if (!defined($class) || !defined($magic) || $magic ne "\177ELF");
77+
+
78+
+ my $arch = $supported_elf_machine->{$machine};
79+
+ die "'$elf_fn' has unknown ELF machine '$machine'!\n"
80+
+ if !defined($arch);
81+
+
82+
+ return $arch;
83+
+ };
84+
+
85+
+ my $arch = eval { PVE::Tools::run_fork_with_timeout(5, $detect_arch) };
86+
+ if (my $err = $@) {
87+
+ $arch = 'arm64';
88+
+ print "Architecture detection failed: $err\nFalling back to loongarch64.\n" .
89+
+ "Use `pct set VMID --arch ARCH` to change.\n";
90+
+ } else {
91+
+ print "Detected container architecture: $arch\n";
92+
+ }
93+
+
94+
+ return $arch;
95+
}
96+
97+
# hooks
98+
diff --git a/src/PVE/LXC/Tools.pm b/src/PVE/LXC/Tools.pm
99+
index 7e3e530..838327f 100644
100+
--- a/src/PVE/LXC/Tools.pm
101+
+++ b/src/PVE/LXC/Tools.pm
102+
@@ -179,6 +179,7 @@ sub detect_elf_architecture {
103+
0x28 => 'armhf',
104+
0xb7 => 'arm64',
105+
0xf3 => 'riscv',
106+
+ 0x2 => 'loongarch64',
107+
};
108+
109+
my $detect_arch = sub {
Submodule pve-container added at eaeb284

‎packages/pve-container/series‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patches/001-add-loongarch-support.patch
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm
2+
index fa2702c..636e684 100644
3+
--- a/Proxmox/Install.pm
4+
+++ b/Proxmox/Install.pm
5+
@@ -6,6 +6,7 @@ use warnings;
6+
use Cwd 'abs_path';
7+
use Encode;
8+
use POSIX ":sys_wait_h";
9+
+use POSIX qw(EINTR EEXIST EOPNOTSUPP);
10+
11+
use Proxmox::Install::ISOEnv;
12+
use Proxmox::Install::RunEnv;
13+
@@ -58,6 +59,13 @@ sub reset_last_display_change {
14+
$last_display_change = 0;
15+
}
16+
17+
+my $host_arch;
18+
+sub get_host_arch {
19+
+ $host_arch = (POSIX::uname())[4] if !$host_arch;
20+
+ return $host_arch;
21+
+}
22+
+my $arch = get_host_arch();
23+
+
24+
sub display_info {
25+
my $min_display_time = 15;
26+
27+
@@ -97,6 +105,7 @@ my $fssetup = {
28+
},
29+
};
30+
31+
+
32+
sub create_filesystem {
33+
my ($dev, $name, $type, $start, $end, $fs, $fe) = @_;
34+
35+
@@ -625,9 +653,18 @@ sub prepare_grub_efi_boot_esp {
36+
37+
syscmd("mount -n $espdev -t vfat $targetdir/boot/efi") == 0 ||
38+
die "unable to mount $espdev\n";
39+
-
40+
+ my $arch = get_host_arch();
41+
+ my $rc;
42+
eval {
43+
- my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev");
44+
+ if ($arch eq "aarch64"){
45+
+ my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target arm64-efi --no-floppy --bootloader-id='proxmox' $dev");
46+
+ } elsif ($arch eq "loongarch64"){
47+
+ my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target loongarch64-efi --no-floppy --bootloader-id='proxmox' $dev");
48+
+ } elsif ($arch eq "riscv64"){
49+
+ my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target riscv64-efi --no-floppy --bootloader-id='proxmox' $dev");
50+
+ } else {
51+
+ die "unable to install grub on arch $arch\n";
52+
+ }
53+
if ($rc != 0) {
54+
my $run_env = Proxmox::Install::RunEnv::get();
55+
if ($run_env->{boot_type} eq 'efi') {
56+
@@ -636,12 +673,23 @@ sub prepare_grub_efi_boot_esp {
57+
warn "unable to install the EFI boot loader on '$dev', ignoring (not booted using UEFI)\n";
58+
}
59+
}
60+
+ rockchip_dtb_setup($espdev, $targetdir , 0);
61+
+
62+
# also install fallback boot file (OVMF does not boot without)
63+
mkdir("$targetdir/boot/efi/EFI/BOOT");
64+
- syscmd("cp $targetdir/boot/efi/EFI/proxmox/*.efi $targetdir/boot/efi/EFI/BOOT/") == 0 ||
65+
+ syscmd("cp -r $targetdir/boot/efi/EFI/proxmox/* $targetdir/boot/efi/EFI/BOOT/");
66+
+ if ($arch eq "aarch64"){
67+
+ syscmd("cp $targetdir/boot/efi/EFI/BOOT/grubaa64.efi $targetdir/boot/efi/EFI/BOOT/BOOTAA64.EFI ") == 0 ||
68+
die "unable to copy efi boot loader\n";
69+
- syscmd("mv $targetdir/boot/efi/EFI/BOOT/shimx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.efi") == 0 ||
70+
- die "unable to setup default efi boot loader\n";
71+
+ } elsif ($arch eq "loongarch64") {
72+
+ syscmd("cp $targetdir/boot/efi/EFI/BOOT/grubloongarch64.efi $targetdir/boot/efi/EFI/BOOT/BOOTLOONGARCH64.efi") == 0 ||
73+
+ die "unable to copy efi boot loader\n";
74+
+ } elsif ($arch eq "riscv64") {
75+
+ syscmd("cp $targetdir/boot/efi/EFI/BOOT/grubriscv64.efi $targetdir/boot/efi/EFI/BOOT/BOOTRISCV64.efi") == 0 ||
76+
+ die "unable to copy efi boot loader\n";
77+
+ } else {
78+
+ die "unable to opy efi boot loader on arch $arch\n";
79+
+ }
80+
};
81+
my $err = $@;
82+
83+
@@ -1258,14 +1306,6 @@ _EOD
84+
diversion_remove($targetdir, "/usr/sbin/update-grub");
85+
diversion_remove($targetdir, "/usr/sbin/update-initramfs");
86+
87+
- my $kapi;
88+
- foreach my $fn (<$targetdir/lib/modules/*>) {
89+
- if ($fn =~ m!/(\d+\.\d+\.\d+-\d+-pve)$!) {
90+
- die "found multiple kernels\n" if defined($kapi);
91+
- $kapi = $1;
92+
- }
93+
- }
94+
- die "unable to detect kernel version\n" if !defined($kapi);
95+
96+
if (!is_test_mode()) {
97+
98+
@@ -1275,7 +1315,7 @@ _EOD
99+
100+
my $bootloader_err_list = [];
101+
eval {
102+
- syscmd("chroot $targetdir /usr/sbin/update-initramfs -c -k $kapi") == 0 ||
103+
+ syscmd("chroot $targetdir /usr/sbin/update-initramfs -c -k all") == 0 ||
104+
die "unable to install initramfs\n";
105+
106+
my $native_4k_disk_bootable = 0;
107+
@@ -1290,8 +1330,8 @@ _EOD
108+
} else {
109+
if (!$native_4k_disk_bootable) {
110+
eval {
111+
- syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
112+
- die "unable to install the i386-pc boot loader on '$dev'\n";
113+
+# syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
114+
+ print ("not need install the i386-pc boot loader on '$dev'\n");
115+
};
116+
push @$bootloader_err_list, $@ if $@;
117+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/proxinstall b/proxinstall
2+
index 12f3eaa..dcf6e7e 100755
3+
--- a/proxinstall
4+
+++ b/proxinstall
5+
@@ -1592,6 +1592,6 @@ sub create_intro_view {
6+
- if ($iso_env->{product} eq 'pve' && !$run_env->{hvm_supported}) {
7+
- Proxmox::UI::error(
8+
- "No support for hardware-accelerated KVM virtualization detected.\n\n"
9+
- ."Check BIOS settings for Intel VT / AMD-V / SVM."
10+
- );
11+
- }
12+
+# if ($iso_env->{product} eq 'pve' && !$run_env->{hvm_supported}) {
13+
+# Proxmox::UI::error(
14+
+# "No support for hardware-accelerated KVM virtualization detected.\n\n"
15+
+# ."Check BIOS settings for Intel VT / AMD-V / SVM."
16+
+# );
17+
+# }
18+
diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs
19+
index 3fb87a7..242978b 100644
20+
--- a/proxmox-tui-installer/src/main.rs
21+
+++ b/proxmox-tui-installer/src/main.rs
22+
@@ -207,15 +207,15 @@ fn installer_setup_late(siv: &mut Cursive) {
23+
);
24+
}
25+
26+
- if state.setup_info.config.product == ProxmoxProduct::PVE && !state.runtime_info.hvm_supported {
27+
- display_setup_warning(
28+
- siv,
29+
- concat!(
30+
- "No support for hardware-accelerated KVM virtualization detected.\n\n",
31+
- "Check BIOS settings for Intel VT / AMD-V / SVM."
32+
- ),
33+
- );
34+
- }
35+
+ // if state.setup_info.config.product == ProxmoxProduct::PVE && !state.runtime_info.hvm_supported {
36+
+ // display_setup_warning(
37+
+ // siv,
38+
+ // concat!(
39+
+ // "No support for hardware-accelerated KVM virtualization detected.\n\n",
40+
+ // "Check BIOS settings for Intel VT / AMD-V / SVM."
41+
+ // ),
42+
+ // );
43+
+ // }
44+
}
45+
46+
fn initial_setup_error(siv: &mut CursiveRunnable, message: &str) -> ! {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/debian/control b/debian/control
2+
index 04b0c6e..c6232af 100644
3+
--- a/debian/control
4+
+++ b/debian/control
5+
@@ -34,14 +34,22 @@ Homepage: https://www.proxmox.com
6+
7+
Package: proxmox-installer
8+
Architecture: any
9+
-Depends: chrony,
10+
+Depends: btrfs-progs,
11+
+ chrony,
12+
+ eject,
13+
geoip-bin,
14+
iproute2,
15+
libgtk3-perl,
16+
libgtk3-webkit2-perl,
17+
libjson-perl,
18+
+ lvm2,
19+
+ openbox,
20+
proxmox-kernel-helper,
21+
squashfs-tools,
22+
+ thin-provisioning-tools,
23+
+ xorg,
24+
+ zfsutils-linux,
25+
+ zfs-initramfs,
26+
${misc:Depends},
27+
${perl:Depends},
28+
${shlibs:Depends},
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/Proxmox/Sys/Block.pm b/Proxmox/Sys/Block.pm
2+
index e337474..cb728cb 100644
3+
--- a/Proxmox/Sys/Block.pm
4+
+++ b/Proxmox/Sys/Block.pm
5+
@@ -171,6 +171,8 @@ sub get_partition_dev {
6+
return "${dev}$partnum";
7+
} elsif ($dev =~ m|^/dev/nvme\d+n\d+$|) {
8+
return "${dev}p$partnum";
9+
+ } elsif ($dev =~ m|^/dev/mmcblk\d+$|) {
10+
+ return "${dev}p$partnum";
11+
} else {
12+
die "unable to get device for partition $partnum on device $dev\n";
13+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm
2+
index fa2702c..636e684 100644
3+
--- a/Proxmox/Install.pm
4+
+++ b/Proxmox/Install.pm
5+
@@ -608,6 +617,24 @@ my sub chroot_chmod {
6+
die "chroot: unable to change permission mode for '$path'\n";
7+
}
8+
9+
+sub rockchip_dtb_setup {
10+
+ my ($espdev, $targetdir, $zfs) = @_;
11+
+ # For rockchpi efi env need Device Tree mode, https://github.com/edk2-porting/edk2-rk3588
12+
+ # We create \dtb\base\ in esp root
13+
+ my $kernel_version = `uname -r`;
14+
+ if ($kernel_version =~ /rockchip/){
15+
+ print "kernel is rockchip\n";
16+
+ if ($zfs == '1') {
17+
+ syscmd("mount $espdev $targetdir/boot/efi/");
18+
+ syscmd("cp -r /cdrom/dtb $targetdir/boot/efi/");
19+
+ syscmd("umount -l $targetdir/boot/efi/") ;
20+
+ }else{
21+
+ syscmd("cp -r /cdrom/dtb $targetdir/boot/efi/");
22+
+ }
23+
+ }
24+
+}
25+
+
26+
+
27+
sub prepare_proxmox_boot_esp {
28+
my ($espdev, $targetdir, $secureboot) = @_;
29+
30+
@@ -618,6 +645,7 @@ sub prepare_proxmox_boot_esp {
31+
32+
syscmd("chroot $targetdir proxmox-boot-tool init $espdev $mode") == 0 ||
33+
die "unable to init ESP and install proxmox-boot loader on '$espdev'\n";
34+
+ rockchip_dtb_setup($espdev, $targetdir,1);
35+
}
36+
37+
sub prepare_grub_efi_boot_esp {

0 commit comments

Comments
 (0)