tests(packer): add source files for tests VM images.

This commit is contained in:
Alexandre Pujol 2023-04-16 21:28:58 +01:00
parent d717a24adc
commit 6b7a9ed3e5
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
6 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
source /usr/share/bash-completion/bash_completion
function up() {
for nb in $(seq "$1"); do
cd ../
done
}
alias sudo='sudo -E'
alias aa-log='sudo aa-log'
alias aa-status='sudo aa-status'
alias c='clear'
alias du='du -hs'
alias l='ll -h'
alias ll='ls -alFh'
alias p="ps auxZ | grep -v '\[.*\]'"
alias pf="ps auxfZ | grep -v '\[.*\]'"
alias pu="ps auxZ | grep -v '\[.*\]' | grep unconfined"
alias u='up 1'
alias uu='up 2'
alias uuu='up 3'
alias uuuu='up 4'
alias uuuuu='up 5'

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eu
export BUILDDIR=/tmp/build/ PKGDEST=/tmp/pkg
# shellcheck source=/dev/null
_lsb_release() { . /etc/os-release || exit 1; echo "$ID"; }
DISTRIBUTION="$(_lsb_release)"
cd "$HOME/Projects/apparmor.d"
case "$DISTRIBUTION" in
arch) make pkg ;;
debian | ubuntu | whonix) make dpkg ;;
opensuse-tumbleweed) make rpm ;;
*) ;;
esac

44
tests/packer/src/htoprc Normal file
View File

@ -0,0 +1,44 @@
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
htop_version=3.1.2
config_reader_min_version=2
fields=0 48 17 18 38 39 40 2 46 47 49 122 1
sort_key=0
sort_direction=1
tree_sort_key=0
tree_sort_direction=1
hide_kernel_threads=1
hide_userland_threads=1
shadow_other_users=0
show_thread_names=0
show_program_path=1
highlight_base_name=1
highlight_deleted_exe=1
highlight_megabytes=1
highlight_threads=1
highlight_changes=0
highlight_changes_delay_secs=5
find_comm_in_cmdline=1
strip_exe_from_cmdline=1
show_merged_command=0
tree_view=0
tree_view_always_by_pid=0
all_branches_collapsed=0
header_margin=1
detailed_cpu_time=1
cpu_count_from_one=1
show_cpu_usage=1
show_cpu_frequency=1
show_cpu_temperature=1
degree_fahrenheit=0
update_process_names=0
account_guest_in_cpu_meter=0
color_scheme=6
enable_mouse=1
delay=15
hide_function_bar=1
header_layout=two_50_50
column_meters_0=LeftCPUs Memory Swap
column_meter_modes_0=1 1 1
column_meters_1=RightCPUs Tasks LoadAverage Uptime
column_meter_modes_1=1 2 2 2

29
tests/packer/src/init.sh Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2023 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
set -eu
# shellcheck source=/dev/null
_lsb_release() { . /etc/os-release; echo "$ID"; }
DISTRIBUTION="$(_lsb_release)"
readonly SRC=/tmp/src
readonly DISTRIBUTION
main() {
install -dm0750 -o "$SUDO_USER" -g "$SUDO_USER" "/home/$SUDO_USER/Projects/" "/home/$SUDO_USER/.config/"
install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/.bash_aliases "/home/$SUDO_USER/.bash_aliases"
install -Dm0644 -o "$SUDO_USER" -g "$SUDO_USER" $SRC/htoprc "/home/$SUDO_USER/.config/htop/htoprc"
install -Dm0644 $SRC/parser.conf /etc/apparmor/parser.conf
install -Dm0644 $SRC/site.local /etc/apparmor.d/tunables/etc.d/site.local
install -Dm0755 $SRC/aa-update /usr/bin/aa-update
chown -R "$SUDO_USER:$SUDO_USER" "/home/$SUDO_USER/.config/"
case "$DISTRIBUTION" in
debian | ubuntu) dpkg -i $SRC/apparmor.d_*_all.deb ;;
opensuse*) zypper install -y bash-completion git go htop lsb-release make rsync vim ;;
arch) pacman --noconfirm -U $SRC/apparmor.d-*-x86_64.pkg.tar.zst ;;
esac
}
main "$@"

View File

@ -0,0 +1,4 @@
write-cache
cache-loc /etc/apparmor/earlypolicy/
Optimize=compress-fast

View File

@ -0,0 +1,3 @@
@{user_build_dirs}+=@{user_projects_dirs}
@{user_pkg_dirs}+=@{user_projects_dirs}