Compare commits

..

No commits in common. "3a83e3e65d52014a17ead4f3a1cb3b6c2bc9dfd5" and "903d29f84d62521669205617e4dbd6d3f67a19b2" have entirely different histories.

5 changed files with 34 additions and 80 deletions

2
.gitignore vendored
View File

@ -1,9 +1,9 @@
rootfs rootfs
config config
logfile logfile
PVE
.veid .veid
pacman.conf pacman.conf
pkgcache pkgcache
rootfs rootfs
aab.conf aab.conf
archlinux_base_*

View File

@ -16,7 +16,7 @@ aab.conf:
echo 'Version: $(VERSION)' >> aab.conf echo 'Version: $(VERSION)' >> aab.conf
echo 'Section: system' >> aab.conf echo 'Section: system' >> aab.conf
echo 'Maintainer: Proxmox Support Team <support@proxmox.com>' >> aab.conf echo 'Maintainer: Proxmox Support Team <support@proxmox.com>' >> aab.conf
echo 'Source: https://ftp.acc.umu.se/mirror/archlinux/$repo/os/$arch' >> aab.conf echo 'Source: http://archlinux.cu.be/$$repo/os/$$arch' >> aab.conf
echo 'Architecture: $(ARCH)' >> aab.conf echo 'Architecture: $(ARCH)' >> aab.conf
echo 'Description: ArchLinux base image.' >> aab.conf echo 'Description: ArchLinux base image.' >> aab.conf
echo " ArchLinux template with the 'base' group and the 'openssh' package installed." >> aab.conf echo " ArchLinux template with the 'base' group and the 'openssh' package installed." >> aab.conf
@ -51,4 +51,3 @@ clean:
.PHONY: distclean .PHONY: distclean
distclean: distclean:
@$(PERL) ./aab dist-clean @$(PERL) ./aab dist-clean
rm -rf archlinux*.tar*

View File

@ -11,7 +11,7 @@ use IPC::Open2;
use IPC::Open3; use IPC::Open3;
use UUID; use UUID;
use Cwd; use Cwd;
my @BASE_PACKAGES = qw(base openssh vi nano python); my @BASE_PACKAGES = qw(base openssh vi nano);
my @BASE_EXCLUDES = qw( my @BASE_EXCLUDES = qw(
e2fsprogs e2fsprogs
jfsutils jfsutils
@ -50,17 +50,6 @@ sub write_file {
$fh->close; $fh->close;
} }
sub read_file {
my ($filename) = @_;
my $fh = IO::File->new ("<$filename") or die "failed to read $filename - $!\n";
my $rec = '';
while (defined (my $line = <$fh>)) {
$rec .= $line;
};
return $rec;
}
sub copy_file { sub copy_file {
my ($a, $b) = @_; my ($a, $b) = @_;
copy($a, $b) or die "failed to copy $a => $b: $!"; copy($a, $b) or die "failed to copy $a => $b: $!";
@ -180,7 +169,7 @@ sub __sample_config {
return <<"CFG"; return <<"CFG";
lxc.arch = $arch lxc.arch = $arch
lxc.include = /usr/share/lxc/config/common.conf lxc.include = /usr/share/lxc/config/archlinux.common.conf
lxc.uts.name = localhost lxc.uts.name = localhost
lxc.rootfs.path = $self->{rootfs} lxc.rootfs.path = $self->{rootfs}
lxc.mount.entry = $self->{pkgcache} $self->{pkgdir} none bind 0 0 lxc.mount.entry = $self->{pkgcache} $self->{pkgdir} none bind 0 0
@ -489,12 +478,6 @@ sub mask_systemd_unit {
symln '/dev/null', "$root/etc/systemd/system/$unit"; symln '/dev/null', "$root/etc/systemd/system/$unit";
} }
sub enable_systemd_unit {
my ($self, $unit) = @_;
my $root = $self->{rootfs};
symln "/usr/lib/systemd/system/$unit", "$root/etc/systemd/system/multi-user.target.wants/$unit";
}
sub bootstrap { sub bootstrap {
my ($self, $include, $exclude) = @_; my ($self, $include, $exclude) = @_;
my $root = $self->{rootfs}; my $root = $self->{rootfs};
@ -584,14 +567,9 @@ sub bootstrap {
$self->ve_command(['pacman', '-S', '--needed', '--noconfirm', '--', @$packages]); $self->ve_command(['pacman', '-S', '--needed', '--noconfirm', '--', @$packages]);
print "Masking problematic systemd units...\n"; print "Masking problematic systemd units...\n";
for my $unit (qw(sys-kernel-config.mount sys-kernel-debug.mount systemd-journald-audit.socket systemd-resolved.service)) { for my $unit (qw(sys-kernel-config.mount sys-kernel-debug.mount)) {
$self->mask_systemd_unit($unit); $self->mask_systemd_unit($unit);
} }
print "Enable systemd services...\n";
for my $unit (qw(sshd.service)) {
$self->enable_systemd_unit($unit);
}
} }
# devices needed for gnupg to function: # devices needed for gnupg to function:
@ -697,10 +675,8 @@ sub finalize {
unlink $file; unlink $file;
rename_file($file.'.aab_orig', $file); rename_file($file.'.aab_orig', $file);
# experienced user can change it anytime and others do well to start out with an updatable system.. print "Removing weak temporary pacman keyring...\n";
my $mirrors = eval { read_file($file) } // ''; rmtree("$rootdir/etc/pacman.d/gnupg");
$mirrors = "\nServer = https://geo.mirror.pkgbuild.com/\$repo/os/\$arch\n\n" . $mirrors;
write_file($mirrors, $file, 0644);
my $sizestr = $self->run_command("du -sm $rootdir", undef, 1); my $sizestr = $self->run_command("du -sm $rootdir", undef, 1);
my $size; my $size;

27
README Normal file
View File

@ -0,0 +1,27 @@
Usage example:
1) Create an aab.conf file describing your template.
--- Example aab.conf:
Name: base
Version: 2015-08-21-1
Section: optional
Maintainer: Your Name
Headline: ArchLinux base image.
Architecture: x86_64
Source: http://archlinux.cu.be/$repo/os/$arch
--- End of example
2) Run as root:
# ./aab init
# ./aab bootstrap
3) Maybe install additional packages
# ./aab install base-devel
4) Create the archive and clean up:
# ./aab finalize
# ./aab cleanup

View File

@ -1,48 +0,0 @@
# Arch Linux Appliance Builder
This is a fork of [Proxmox AAB project](https://git.proxmox.com/) with the goal of building an updated Arch Linux LXC template for use with PVE, also to prevent removal of `pacman keyring`; disable `systemd-resolved` and enable `sshd`.
## Requirements for building
The best way to build this template is running inside of an Arch Linux environment and will need the following packages: **`lxc make perl-uuid`**
Also to prevent an error when starting the container, you need to enable devices cgroup since LXC will apply [device cgroup limits](https://github.com/lxc/lxc/issues/2268#issuecomment-380019126).
```Shell
mount -o remount,rw /sys/fs/cgroup
mkdir /sys/fs/cgroup/devices
mount -t cgroup devices -o devices /sys/fs/cgroup/devices
mount -o remount,ro /sys/fs/cgroup
```
## To enable/disable services and install additional packages
Go to the file `PVE/AAB.pm` and search for the following lines:
- Add new packages: `my @BASE_PACKAGES`
- Disable service: `print "Masking problematic systemd units...\n";`
- Enable serivce: `print "Enable systemd services...\n";`
## Usage
### with Make
- `make aab.conf`
- run as root `make build-current`
- go drink mate or kofi while is creating and compacting the template
- when done will have the following file `archlinux-base_${DATE}-1_${ARCH}.tar.zst`
- upload to your PVE and enjoy~
### or step by step
### 1. Create an aab.conf file describing your template.
- `make aab.conf`
- edit the source argument inside of `aab.conf` and change to a mirror of your choice
### 2. Run as root:
- `./aab init`
- `./aab bootstrap`
### 3. Maybe install additional packages
- `./aab install base-devel`
### 4. Create the archive and clean up:
- `./aab finalize`
- `./aab cleanup`