diff --git a/usr/bin/archboot-aarch64-create-container.sh b/usr/bin/archboot-aarch64-create-container.sh index 6c69fc583..9e76423e0 100755 --- a/usr/bin/archboot-aarch64-create-container.sh +++ b/usr/bin/archboot-aarch64-create-container.sh @@ -5,37 +5,36 @@ source /usr/lib/archboot/container_functions _ARCHBOOT="archboot-arm" _KEYRING="archlinuxarm" [[ -z "${1}" ]] && _usage -_DIR="$1" _parameters "$@" _root_check echo "Starting container creation ..." -[[ -d "${_DIR}" ]] || (echo "Create directory ${_DIR} ..."; mkdir "${_DIR}") +[[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then - _prepare_pacman || exit 1 - _install_base_packages || exit 1 - _clean_mkinitcpio || exit 1 - _clean_cache || exit 1 - _install_archboot || exit 1 - _umount_special || exit 1 - _generate_locales || exit 1 - _clean_locale - _clean_container || exit 1 + _prepare_pacman "${1}" || exit 1 + _install_base_packages "${1}" || exit 1 + _clean_mkinitcpio "${1}" || exit 1 + _clean_cache "${1}" || exit 1 + _install_archboot "${1}" || exit 1 + _umount_special "${1}" || exit 1 + _generate_locales "${1}" || exit 1 + _clean_locale "${1}" + _clean_container "${1}" || exit 1 _clean_archboot_cache - _generate_keyring || exit 1 - _copy_mirrorlist_and_pacman_conf - _change_pacman_conf || exit 1 + _generate_keyring "${1}" || exit 1 + _copy_mirrorlist_and_pacman_conf "${1}" + _change_pacman_conf "${1}" || exit 1 fi if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then - _aarch64_pacman_chroot || exit 1 - _aarch64_install_base_packages || exit 1 - _clean_mkinitcpio || exit 1 - _clean_cache || exit 1 - _aarch64_install_archboot || exit 1 - _clean_mkinitcpio || exit 1 - _clean_cache || exit 1 - _generate_locales || exit 1 - _clean_locale - _clean_container || exit 1 + _aarch64_pacman_chroot "${1}" || exit 1 + _aarch64_install_base_packages "${1}" || exit 1 + _clean_mkinitcpio "${1}" || exit 1 + _clean_cache "${1}" || exit 1 + _aarch64_install_archboot "${1}" || exit 1 + _clean_mkinitcpio "${1}" || exit 1 + _clean_cache "${1}" || exit 1 + _generate_locales "${1}" || exit 1 + _clean_locale "${1}" + _clean_container "${1}" || exit 1 fi -_set_hostname || exit 1 -echo "Finished container setup in ${_DIR} ." +_set_hostname "${1}" || exit 1 +echo "Finished container setup in ${1} ." diff --git a/usr/bin/archboot-aarch64-create-repository.sh b/usr/bin/archboot-aarch64-create-repository.sh new file mode 100755 index 000000000..24e371e92 --- /dev/null +++ b/usr/bin/archboot-aarch64-create-repository.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# created by Tobias Powalowski +source /usr/lib/archboot/functions +source /usr/lib/archboot/container_functions +source /usr/lib/archboot/repository_functions +_ARCHBOOT="archboot-arm" +[[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") +_DIR="$(mktemp -d ${1}/repository.XXX)" +_CACHEDIR="${_DIR}/var/cache/pacman/pkg" +[[ -z "${1}" ]] && _usage +_root_check +_buildserver_check +_cachedir_check +echo "Starting repository creation ..." +if [[ "${_RUNNING_ARCH}" == "aarch64" ]]; then + _prepare_pacman "${_DIR}" || exit 1 + _download_packages "${_DIR}" || exit 1 + _umount_special "${_DIR}" || exit 1 +fi +if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then + _aarch64_pacman_chroot "${_DIR}" || exit 1 + _aarch64_download_packages "${_DIR}" || exit 1 +fi +_move_packages "${_DIR}" "${1}" || exit 1 +_cleanup_repodir "${_DIR}" || exit 1 +_create_archboot_db "${1}" || exit 1 +echo "Finished repository creation in ${_DIR} ." + diff --git a/usr/bin/archboot-update-installer.sh b/usr/bin/archboot-update-installer.sh index 000bf2359..46f9c6b60 100755 --- a/usr/bin/archboot-update-installer.sh +++ b/usr/bin/archboot-update-installer.sh @@ -64,18 +64,18 @@ fi # Download latest setup and quickinst script from git repository if [[ "${_D_SCRIPTS}" == "1" ]]; then echo "Downloading latest km, tz, quickinst, setup and helpers..." - [[ -e /usr/bin/quickinst ]] && wget -q "$_INSTALLER_SOURCE/archboot-quickinst.sh?inline=false" -O /usr/bin/quickinst >/dev/null 2>&1 - [[ -e /usr/bin/setup ]] && wget -q "$_INSTALLER_SOURCE/archboot-setup.sh?inline=false" -O /usr/bin/setup >/dev/null 2>&1 - [[ -e /usr/bin/km ]] && wget -q "$_INSTALLER_SOURCE/archboot-km.sh?inline=false" -O /usr/bin/km >/dev/null 2>&1 - [[ -e /usr/bin/tz ]] && wget -q "$_INSTALLER_SOURCE/archboot-tz.sh?inline=false" -O /usr/bin/tz >/dev/null 2>&1 - [[ -e /usr/bin/archboot-${_RUNNING_ARCH}-create-container.sh ]] && wget -q "$_INSTALLER_SOURCE/archboot-${_RUNNING_ARCH}-create-container.sh?inline=false" -O "/usr/bin/archboot-${_RUNNING_ARCH}-create-container.sh" >/dev/null 2>&1 - [[ -e /usr/bin/archboot-${_RUNNING_ARCH}-release.sh ]] && wget -q "$_INSTALLER_SOURCE/archboot-${_RUNNING_ARCH}-release.sh?inline=false" -O "/usr/bin/archboot-${_RUNNING_ARCH}-release.sh" >/dev/null 2>&1 - [[ -e /usr/bin/archboot-binary-check.sh ]] && wget -q "$_INSTALLER_SOURCE/archboot-binary-check.sh?inline=false" -O /usr/bin/archboot-binary-check.sh >/dev/null 2>&1 - [[ -e /usr/bin/update-installer.sh ]] && wget -q "$_INSTALLER_SOURCE/archboot-update-installer.sh?inline=false" -O /usr/bin/update-installer.sh >/dev/null 2>&1 - [[ -e /usr/lib/archboot/functions ]] && wget -q "$_INSTALLER_SOURCE/functions?inline=false" -O "/usr/lib/archboot/functions" >/dev/null 2>&1 - [[ -e /usr/lib/archboot/container_functions ]] && wget -q "$_INSTALLER_SOURCE/container_functions?inline=false" -O "/usr/lib/archboot/container_functions" >/dev/null 2>&1 - [[ -e /usr/lib/archboot/release_functions ]] && wget -q "$_INSTALLER_SOURCE/release_functions?inline=false" -O "/usr/lib/archboot/release_functions" >/dev/null 2>&1 - [[ -e /usr/lib/archboot/iso_functions ]] && wget -q "$_INSTALLER_SOURCE/iso_functions?inline=false" -O "/usr/lib/archboot/iso_functions" >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-quickinst.sh?inline=false" -O /usr/bin/quickinst >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-setup.sh?inline=false" -O /usr/bin/setup >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-km.sh?inline=false" -O /usr/bin/km >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-tz.sh?inline=false" -O /usr/bin/tz >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-${_RUNNING_ARCH}-create-container.sh?inline=false" -O "/usr/bin/archboot-${_RUNNING_ARCH}-create-container.sh" >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-${_RUNNING_ARCH}-release.sh?inline=false" -O "/usr/bin/archboot-${_RUNNING_ARCH}-release.sh" >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-binary-check.sh?inline=false" -O /usr/bin/archboot-binary-check.sh >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/archboot-update-installer.sh?inline=false" -O /usr/bin/update-installer.sh >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/functions?inline=false" -O "/usr/lib/archboot/functions" >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/container_functions?inline=false" -O "/usr/lib/archboot/container_functions" >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/release_functions?inline=false" -O "/usr/lib/archboot/release_functions" >/dev/null 2>&1 + wget -q "$_INSTALLER_SOURCE/iso_functions?inline=false" -O "/usr/lib/archboot/iso_functions" >/dev/null 2>&1 echo "Finished: Downloading scripts done." exit 0 fi diff --git a/usr/bin/archboot-x86_64-create-container.sh b/usr/bin/archboot-x86_64-create-container.sh index 44696816d..72c88924a 100755 --- a/usr/bin/archboot-x86_64-create-container.sh +++ b/usr/bin/archboot-x86_64-create-container.sh @@ -2,35 +2,35 @@ # created by Tobias Powalowski source /usr/lib/archboot/functions source /usr/lib/archboot/container_functions +_CACHEDIR="${1}/var/cache/pacman/pkg" _ARCHBOOT="archboot" _KEYRING="archlinux" [[ -z "${1}" ]] && _usage -_DIR="$1" _parameters "$@" _root_check _x86_64_check echo "Starting container creation ..." -[[ -d "${_DIR}" ]] || (echo "Create directory ${_DIR} ..."; mkdir "${_DIR}") -_prepare_pacman || exit 1 -_install_base_packages || exit 1 -_clean_mkinitcpio || exit 1 -_clean_cache || exit 1 -_install_archboot || exit 1 -_umount_special || exit 1 -_generate_locales || exit 1 -_clean_locale -_clean_container || exit 1 +[[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") +_prepare_pacman "${1}" || exit 1 +_install_base_packages "${1}" || exit 1 +_clean_mkinitcpio "${1}" || exit 1 +_clean_cache "${1}" || exit 1 +_install_archboot "${1}" || exit 1 +_umount_special "${1}" || exit 1 +_generate_locales "${1}" || exit 1 +_clean_locale "${1}" +_clean_container "${1}" || exit 1 _clean_archboot_cache -_generate_keyring || exit 1 -_copy_mirrorlist_and_pacman_conf -_change_pacman_conf || exit 1 +_generate_keyring "${1}" || exit 1 +_copy_mirrorlist_and_pacman_conf "${1}" +_change_pacman_conf "${1}" || exit 1 # enable [testing] if enabled in host if grep -q "^\[testing" /etc/pacman.conf; then echo "Enable [testing] repository in container ..." - sed -i -e '/^#\[testing\]/ { n ; s/^#// }' "${_DIR}/etc/pacman.conf" - sed -i -e '/^#\[community-testing\]/ { n ; s/^#// }' "${_DIR}/etc/pacman.conf" - sed -i -e 's:^#\[testing\]:\[testing\]:g' -e 's:^#\[community-testing\]:\[community-testing\]:g' "${_DIR}/etc/pacman.conf" + sed -i -e '/^#\[testing\]/ { n ; s/^#// }' "${1}/etc/pacman.conf" + sed -i -e '/^#\[community-testing\]/ { n ; s/^#// }' "${1}/etc/pacman.conf" + sed -i -e 's:^#\[testing\]:\[testing\]:g' -e 's:^#\[community-testing\]:\[community-testing\]:g' "${1}/etc/pacman.conf" fi -_set_hostname || exit 1 -echo "Finished container setup in ${_DIR} ." +_set_hostname "${1}" || exit 1 +echo "Finished container setup in ${1} ." diff --git a/usr/bin/archboot-x86_64-create-repository.sh b/usr/bin/archboot-x86_64-create-repository.sh new file mode 100755 index 000000000..3d96a78a1 --- /dev/null +++ b/usr/bin/archboot-x86_64-create-repository.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# created by Tobias Powalowski +source /usr/lib/archboot/functions +source /usr/lib/archboot/container_functions +source /usr/lib/archboot/repository_functions +_ARCHBOOT="archboot" +[[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") +_DIR="$(mktemp -d ${1}/repository.XXX)" +_CACHEDIR="${_DIR}/var/cache/pacman/pkg" +[[ -z "${1}" ]] && _usage +_root_check +_buildserver_check +_x86_64_pacman_use_default || exit 1 +_cachedir_check +_x86_64_check +echo "Starting repository creation ..." +_prepare_pacman "${_DIR}" || exit 1 +_download_packages "${_DIR}" || exit 1 +_x86_64_pacman_restore || exit 1 +_umount_special "${_DIR}" || exit 1 +_move_packages "${_DIR}" "${1}" || exit 1 +_cleanup_repodir "${_DIR}" || exit 1 +_create_archboot_db "${1}" || exit 1 +echo "Finished repository creation in ${_DIR} ." + diff --git a/usr/lib/archboot/container_functions b/usr/lib/archboot/container_functions index 5bb682f67..002ba5d7e 100644 --- a/usr/lib/archboot/container_functions +++ b/usr/lib/archboot/container_functions @@ -1,9 +1,8 @@ #!/bin/bash -_CACHEDIR="$1/var/cache/pacman/pkg" +# created by Tobias Powalowski _CLEANUP_CACHE="" _CLEANUP_CONTAINER="" _LINUX_FIRMWARE="linux-firmware" -_DIR="" _PACMAN_AARCH64_CHROOT_SERVER="https://pkgbuild.com/~tpowa/archboot-helper/pacman-chroot-aarch64" _PACMAN_AARCH64_CHROOT="pacman-aarch64-chroot-latest.tar.zst" @@ -31,8 +30,8 @@ _parameters() { _clean_cache() { if [[ "${_CLEANUP_CACHE}" == "1" ]]; then # clean cache - echo "Clean pacman cache in ${_DIR} ..." - rm -r "${_DIR}"/var/cache/pacman + echo "Clean pacman cache in ${1} ..." + rm -r "${1}"/var/cache/pacman fi } @@ -42,35 +41,35 @@ _aarch64_pacman_chroot() { # verify dowload sleep 1 gpg --verify "${_PACMAN_AARCH64_CHROOT}.sig" >/dev/null 2>&1 || exit 1 - bsdtar -C "${_DIR}" -xf "${_PACMAN_AARCH64_CHROOT}" + bsdtar -C "${1}" -xf "${_PACMAN_AARCH64_CHROOT}" echo "Removing installation tarball ..." rm ${_PACMAN_AARCH64_CHROOT}{,.sig} # update container to latest packages echo "Update container to latest packages..." - systemd-nspawn -D "${_DIR}" pacman -Syu --noconfirm >/dev/null 2>&1 + systemd-nspawn -D "${1}" pacman -Syu --noconfirm >/dev/null 2>&1 } # clean container from not needed files _clean_container() { if [[ "${_CLEANUP_CONTAINER}" == "1" ]]; then - echo "Clean container, delete not needed files from ${_DIR} ..." - rm -r "${_DIR}"/usr/include - rm -r "${_DIR}"/usr/share/{aclocal,applications,audit,avahi,awk,bash-completion,cmake,common-lisp,cracklib,dhclient,dhcpcd,dict,dnsmasq,emacs,et,fish,gdb,gettext,gettext-0.21,glib-2.0,gnupg,graphite2,gtk-doc,iana-etc,icons,icu,iptables,keyutils,libalpm,libgpg-error,makepkg-template,misc,mkinitcpio,ncat,ntp,p11-kit,pixmaps,pkgconfig,readline,screen,smartmontools,ss,stoken,tabset,texinfo,vala,xml,xtables,zoneinfo-leaps,man,doc,info,perl5} - rm -r "${_DIR}"/usr/lib/{audit,avahi,awk,bash,binfmt.d,cifs-utils,cmake,coreutils,cryptsetup,cups,dracut,e2fsprogs,engines-1.1,environment.d,gawk,getconf,gettext,girepository-1.0,glib-2.0,gnupg,gssproxy,guile,icu,itcl4.2.2,iwd,krb5,ldb,ldscripts,libnl,libproxy,named,ntfs-3g,openconnect,openssl-1.0,p11-kit,pcsc,perl5,pkcs11,pkgconfig,python3.10,rsync,samba,sasl2,siconv,sysctl.d,sysusers.d,tar,tcl8.6,tcl8,tdbc1.1.3,tdbcmysql1.1.3,tdbcodbc1.1.3,tdbcpostgres1.1.3,terminfo,texinfo,thread2.8.7,valgrind,xfsprogs,xplc-0.3.13,xtables} + echo "Clean container, delete not needed files from ${1} ..." + rm -r "${1}"/usr/include + rm -r "${1}"/usr/share/{aclocal,applications,audit,avahi,awk,bash-completion,cmake,common-lisp,cracklib,dhclient,dhcpcd,dict,dnsmasq,emacs,et,fish,gdb,gettext,gettext-0.21,glib-2.0,gnupg,graphite2,gtk-doc,iana-etc,icons,icu,iptables,keyutils,libalpm,libgpg-error,makepkg-template,misc,mkinitcpio,ncat,ntp,p11-kit,pixmaps,pkgconfig,readline,screen,smartmontools,ss,stoken,tabset,texinfo,vala,xml,xtables,zoneinfo-leaps,man,doc,info,perl5} + rm -r "${1}"/usr/lib/{audit,avahi,awk,bash,binfmt.d,cifs-utils,cmake,coreutils,cryptsetup,cups,dracut,e2fsprogs,engines-1.1,environment.d,gawk,getconf,gettext,girepository-1.0,glib-2.0,gnupg,gssproxy,guile,icu,itcl4.2.2,iwd,krb5,ldb,ldscripts,libnl,libproxy,named,ntfs-3g,openconnect,openssl-1.0,p11-kit,pcsc,perl5,pkcs11,pkgconfig,python3.10,rsync,samba,sasl2,siconv,sysctl.d,sysusers.d,tar,tcl8.6,tcl8,tdbc1.1.3,tdbcmysql1.1.3,tdbcodbc1.1.3,tdbcpostgres1.1.3,terminfo,texinfo,thread2.8.7,valgrind,xfsprogs,xplc-0.3.13,xtables} fi } # remove mkinitcpio hooks to speed up process, remove not needed initramdisks _clean_mkinitcpio() { - echo "Clean mkinitcpio from ${_DIR} ..." - [[ -e "${_DIR}/usr/share/libalpm/hooks/60-mkinitcpio-remove.hook" ]] && rm "${_DIR}/usr/share/libalpm/hooks/60-mkinitcpio-remove.hook" - [[ -e "${_DIR}/usr/share/libalpm/hooks/90-mkinitcpio-install.hook" ]] && rm "${_DIR}/usr/share/libalpm/hooks/90-mkinitcpio-install.hook" - [[ -e "${_DIR}/boot/initramfs-linux.img" ]] && rm "${_DIR}/boot/initramfs-linux.img" - [[ -e "${_DIR}/boot/initramfs-linux-fallback.img" ]] && rm "${_DIR}/boot/initramfs-linux-fallback.img" + echo "Clean mkinitcpio from ${1} ..." + [[ -e "${1}/usr/share/libalpm/hooks/60-mkinitcpio-remove.hook" ]] && rm "${1}/usr/share/libalpm/hooks/60-mkinitcpio-remove.hook" + [[ -e "${1}/usr/share/libalpm/hooks/90-mkinitcpio-install.hook" ]] && rm "${1}/usr/share/libalpm/hooks/90-mkinitcpio-install.hook" + [[ -e "${1}/boot/initramfs-linux.img" ]] && rm "${1}/boot/initramfs-linux.img" + [[ -e "${1}/boot/initramfs-linux-fallback.img" ]] && rm "${1}/boot/initramfs-linux-fallback.img" } _clean_locale() { - [[ "${_SAVE_RAM}" == "1" ]] && (echo "Clean locale from ${_DIR} ..."; rm -r "${_DIR}"/usr/share/{i18n,locale}) + [[ "${_SAVE_RAM}" == "1" ]] && (echo "Clean locale from ${1} ..."; rm -r "${1}"/usr/share/{i18n,locale}) } _clean_archboot_cache() { @@ -80,65 +79,75 @@ _clean_archboot_cache() { _prepare_pacman() { # prepare pacman dirs - echo "Create directories in ${_DIR} ..." - mkdir -p "${_DIR}/var/lib/pacman" + echo "Create directories in ${1} ..." + mkdir -p "${1}/var/lib/pacman" mkdir -p "${_CACHEDIR}" - [[ -e "${_DIR}/proc" ]] || mkdir -m 555 "${_DIR}/proc" - [[ -e "${_DIR}/sys" ]] || mkdir -m 555 "${_DIR}/sys" - [[ -e "${_DIR}/dev" ]] || mkdir -m 755 "${_DIR}/dev" - # mount special filesystems to ${_DIR} - echo "Mount special filesystems in ${_DIR} ..." - mount proc "${_DIR}/proc" -t proc -o nosuid,noexec,nodev - mount sys "${_DIR}/sys" -t sysfs -o nosuid,noexec,nodev,ro - mount udev "${_DIR}/dev" -t devtmpfs -o mode=0755,nosuid - mount devpts "${_DIR}/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec - mount shm "${_DIR}/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev + [[ -e "${1}/proc" ]] || mkdir -m 555 "${1}/proc" + [[ -e "${1}/sys" ]] || mkdir -m 555 "${1}/sys" + [[ -e "${1}/dev" ]] || mkdir -m 755 "${1}/dev" + # mount special filesystems to ${1} + echo "Mount special filesystems in ${1} ..." + mount proc "${1}/proc" -t proc -o nosuid,noexec,nodev + mount sys "${1}/sys" -t sysfs -o nosuid,noexec,nodev,ro + mount udev "${1}/dev" -t devtmpfs -o mode=0755,nosuid + mount devpts "${1}/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec + mount shm "${1}/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev } _change_pacman_conf() { # enable parallel downloads - sed -i -e 's:^#ParallelDownloads:ParallelDownloads:g' "${_DIR}"/etc/pacman.conf + sed -i -e 's:^#ParallelDownloads:ParallelDownloads:g' "${1}"/etc/pacman.conf # disable checkspace option in pacman.conf, to allow to install packages in environment - sed -i -e 's:^CheckSpace:#CheckSpace:g' "${_DIR}"/etc/pacman.conf + sed -i -e 's:^CheckSpace:#CheckSpace:g' "${1}"/etc/pacman.conf } # umount special filesystems _umount_special() { - echo "Umount special filesystems in to ${_DIR} ..." - umount -R "${_DIR}/proc" - umount -R "${_DIR}/sys" - umount -R "${_DIR}/dev" + echo "Umount special filesystems in to ${1} ..." + umount -R "${1}/proc" + umount -R "${1}/sys" + umount -R "${1}/dev" } _install_base_packages() { - echo "Installing packages base linux and ${_LINUX_FIRMWARE} to ${_DIR} ..." - pacman --root "${_DIR}" -Sy base linux "${_LINUX_FIRMWARE}" --ignore systemd-resolvconf --noconfirm --cachedir "${_PWD}"/"${_CACHEDIR}" >/dev/null 2>&1 + echo "Installing packages base linux and ${_LINUX_FIRMWARE} to ${1} ..." + pacman --root "${1}" -Sy base linux "${_LINUX_FIRMWARE}" --ignore systemd-resolvconf --noconfirm --cachedir "${_PWD}"/"${_CACHEDIR}" >/dev/null 2>&1 } _install_archboot() { - echo "Installing ${_ARCHBOOT} to ${_DIR} ..." - pacman --root "${_DIR}" -Sy "${_ARCHBOOT}" --ignore systemd-resolvconf --noconfirm >/dev/null 2>&1 + echo "Installing ${_ARCHBOOT} to ${1} ..." + pacman --root "${1}" -Sy "${_ARCHBOOT}" --ignore systemd-resolvconf --noconfirm >/dev/null 2>&1 } _aarch64_install_base_packages() { - echo "Installing packages base linux and ${_LINUX_FIRMWARE} to ${_DIR} ..." - systemd-nspawn -q -D "${_DIR}" /bin/bash -c "pacman -Sy base linux ${_LINUX_FIRMWARE} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 + echo "Installing packages base linux and ${_LINUX_FIRMWARE} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Sy base linux ${_LINUX_FIRMWARE} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 } _aarch64_install_archboot() { - echo "Installing ${_ARCHBOOT} to ${_DIR} ..." - systemd-nspawn -q -D "${_DIR}" /bin/bash -c "pacman -Sy ${_ARCHBOOT} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 + echo "Installing ${_ARCHBOOT} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Sy ${_ARCHBOOT} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 +} + +_download_packages() { + echo "Downloading packages base linux ${_LINUX_FIRMWARE} and ${_ARCHBOOT} to ${1} ..." + CacheDir="" pacman --root "${1}" -Syw base linux "${_LINUX_FIRMWARE}" "${_ARCHBOOT}" --ignore systemd-resolvconf --noconfirm --cachedir "${_PWD}"/"${_CACHEDIR}" >/dev/null 2>&1 +} + +_aarch64_download_packages() { + echo "Downloading packages base linux ${_LINUX_FIRMWARE} and ${_ARCHBOOT} to ${1} ..." + systemd-nspawn -q -D "${1}" /bin/bash -c "pacman -Syw base linux ${_LINUX_FIRMWARE} ${_ARCHBOOT} --ignore systemd-resolvconf --noconfirm" >/dev/null 2>&1 } _copy_mirrorlist_and_pacman_conf() { # copy local mirrorlist to container echo "Create pacman config and mirrorlist in container..." - cp "/etc/pacman.d/mirrorlist" "${_DIR}/etc/pacman.d/mirrorlist" + cp "/etc/pacman.d/mirrorlist" "${1}/etc/pacman.d/mirrorlist" # only copy from archboot pacman.conf, else use default file - grep -qw 'archboot' /etc/hostname && cp /etc/pacman.conf "${_DIR}"/etc/pacman.conf + grep -qw 'archboot' /etc/hostname && cp /etc/pacman.conf "${1}"/etc/pacman.conf } _set_hostname() { echo "Setting hostname to archboot ..." - echo 'archboot' > "${_DIR}/etc/hostname" + echo 'archboot' > "${1}/etc/hostname" } diff --git a/usr/lib/archboot/functions b/usr/lib/archboot/functions index 0ca2004b3..96e926f77 100644 --- a/usr/lib/archboot/functions +++ b/usr/lib/archboot/functions @@ -1,9 +1,12 @@ #!/bin/bash +# created by Tobias Powalowski # change to english locale! export LANG="en_US" _BASENAME="$(basename "${0}")" _PWD="$(pwd)" _RUNNING_ARCH="$(uname -m)" +_PACMAN_MIRROR="/etc/pacman.d/mirrorlist" +_PACMAN_CONF="/etc/pacman.conf" ### check for root _root_check() { @@ -51,3 +54,18 @@ _generate_keyring() { systemd-nspawn -q -D "${_DIR}" pacman-key --init >/dev/null 2>&1 systemd-nspawn -q -D "${_DIR}" pacman-key --populate "${_KEYRING}" >/dev/null 2>&1 } + +_x86_64_pacman_use_default() { + # use pacman.conf with disabled [testing] repository + cp "${_PACMAN_CONF}" "${_PACMAN_CONF}".old + cp "${_PACMAN_CONF}".archboot "${_PACMAN_CONF}" + # use mirrorlist with enabled rackspace mirror + cp "${_PACMAN_MIRROR}" "${_PACMAN_MIRROR}".old + cp "${_PACMAN_MIRROR}".archboot "${_PACMAN_MIRROR}" +} + +_x86_64_pacman_restore() { + # restore pacman.conf and mirrorlist + cp "${_PACMAN_MIRROR}".old "${_PACMAN_MIRROR}" + cp "${_PACMAN_CONF}".old "${_PACMAN_CONF}" +} diff --git a/usr/lib/archboot/iso_functions b/usr/lib/archboot/iso_functions index 606dd0f74..07838a08e 100644 --- a/usr/lib/archboot/iso_functions +++ b/usr/lib/archboot/iso_functions @@ -1,4 +1,5 @@ #!/bin/bash +# created by Tobias Powalowski _PRESET_DIR="/etc/archboot/presets" _SHIM_URL="https://pkgbuild.com/~tpowa/archboot-helper/fedora-shim" _GRUB_CONFIG="/usr/share/archboot/grub/grub.cfg" diff --git a/usr/lib/archboot/release_functions b/usr/lib/archboot/release_functions index 086681396..8260cb3e0 100644 --- a/usr/lib/archboot/release_functions +++ b/usr/lib/archboot/release_functions @@ -1,4 +1,5 @@ #!/bin/bash +# created by Tobias Powalowski _PRESET_LATEST="${_ARCH}-latest" _AMD_UCODE="boot/amd-ucode.img" _INTEL_UCODE="boot/intel-ucode.img" diff --git a/usr/lib/archboot/repository_functions b/usr/lib/archboot/repository_functions new file mode 100644 index 000000000..c2a0bffab --- /dev/null +++ b/usr/lib/archboot/repository_functions @@ -0,0 +1,28 @@ +#!/bin/bash +# created by Tobias Powalowski +_usage () { + echo "CREATE ARCHBOOT REPOSITORY" + echo "-----------------------------" + echo "This will create an archboot repository for an archboot image." + echo "Usage: ${_BASENAME} " + exit 0 +} + +_cachedir_check() { + if grep -q ^CacheDir /etc/pacman.conf; then + echo "Error: CacheDir set in /etc/pacman.conf. Aborting ..." + exit 1 + fi +} + +_move_packages() { + mv "${1}"/var/cache/pacman/pkg/./* "${2}" +} + +_cleanup_repodir() { + rm -r "${1}" +} + +_create_archboot_db() { + repo-add "${1}"/archboot.db.tar.gz "${1}"/./*.{zst,xz} +} diff --git a/usr/lib/archboot/server_functions b/usr/lib/archboot/server_functions index 998c313ef..b89397ec2 100644 --- a/usr/lib/archboot/server_functions +++ b/usr/lib/archboot/server_functions @@ -1,4 +1,5 @@ #!/bin/bash +# created by Tobias Powalowski _DIRECTORY="$(date +%Y.%m)" _ISOHOME="/home/tobias/Arch/iso/${_ARCH}" _BUILDDIR="$(mktemp -d ${_ISOHOME}/server-release.XXX)" @@ -13,8 +14,7 @@ _PACMAN_AARCH_SERVERDIR="/home/tpowa/public_html/archboot-helper/pacman-chroot-a _PACMAN_AARCH64="pacman-aarch64-chroot" _PACMAN_AARCH64_CHROOT_SERVER="https://pkgbuild.com/~tpowa/archboot-helper/pacman-chroot-aarch64" _PACMAN_AARCH64_CHROOT="pacman-aarch64-chroot-latest.tar.zst" -_PACMAN_MIRROR="/etc/pacman.d/mirrorlist" -_PACMAN_CONF="/etc/pacman.conf" + _update_aarch64_pacman_chroot() { # update aarch64 pacman chroot @@ -56,7 +56,7 @@ _update_aarch64_pacman_chroot() { _server_release() { # create release in "${_ISOHOME}" cd "${_ISOHOME}" || exit 1 - "archboot-${_ARCH}-release.sh" "${_BUILDDIR}" || (rm -r "${_BUILDDIR}"; exit 1) + "archboot-${_ARCH}-release.sh" "${_BUILDDIR}" || rm -r "${_BUILDDIR}" # set user rights on files [[ -d "${_BUILDDIR}" ]] || exit 1 chmod 755 "${_BUILDDIR}" @@ -96,17 +96,3 @@ ln -s "${_DIRECTORY}" latest EOF } -_x86_64_pacman_use_default() { - # use pacman.conf with disabled [testing] repository - cp "${_PACMAN_CONF}" "${_PACMAN_CONF}".old - cp "${_PACMAN_CONF}".archboot "${_PACMAN_CONF}" - # use mirrorlist with enabled rackspace mirror - cp "${_PACMAN_MIRROR}" "${_PACMAN_MIRROR}".old - cp "${_PACMAN_MIRROR}".archboot "${_PACMAN_MIRROR}" -} - -_x86_64_pacman_restore() { - # restore pacman.conf and mirrorlist - cp "${_PACMAN_MIRROR}".old "${_PACMAN_MIRROR}" - cp "${_PACMAN_CONF}".old "${_PACMAN_CONF}" -}