add some tools
This commit is contained in:
parent
ae8f20a7e0
commit
c23681617e
4 changed files with 169 additions and 3 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -10,5 +10,7 @@
|
||||||
!LICENSE
|
!LICENSE
|
||||||
!qt6-rebuild
|
!qt6-rebuild
|
||||||
!REUSE.toml
|
!REUSE.toml
|
||||||
!upload-to-forgejo-repo
|
!upload-to-dalci-3rdparty-repo
|
||||||
|
!upload-to-dalci-repo
|
||||||
|
!chroot-build
|
||||||
|
|
||||||
|
|
|
||||||
65
chroot-build
Executable file
65
chroot-build
Executable file
|
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: Christian Schendel
|
||||||
|
# SPDX-License-Identifier: 0BSD
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
use_tmpfs=true
|
||||||
|
CHROOT="/tmp/mkarchroot"
|
||||||
|
|
||||||
|
check_available_ram() {
|
||||||
|
if [ "$(awk '/^MemAvailable:/ { print $2; }' /proc/meminfo)" -lt 50000 ]; then
|
||||||
|
use_tmpfs=false
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
create_chroot_directory() {
|
||||||
|
if [ $use_tmpfs ]; then
|
||||||
|
sudo mount --mkdir -t tmpfs -o defaults,size=20G tmpfs $CHROOT
|
||||||
|
else
|
||||||
|
sudo mkdir -p "$CHROOT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
create_chroot_environment() {
|
||||||
|
if [[ ! -d "$CHROOT/root" ]]; then
|
||||||
|
mkarchroot -M ~/.config/pacman/makepkg.conf "$CHROOT/root" base-devel
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_package(){
|
||||||
|
arch-nspawn "$CHROOT/root" pacman -Syu
|
||||||
|
if makechrootpkg -c -r "$CHROOT" -- -Asf . ; then
|
||||||
|
makepkg --printsrcinfo >.SRCINFO
|
||||||
|
else
|
||||||
|
delete_chroot_environment && echo -e "\n\e[1;31m==> BUILD FAILED: \e[1;37m$CHROOT removed\e[0m " && exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sign_package(){
|
||||||
|
PACKAGE="$(makepkg --packagelist)"
|
||||||
|
gpg --use-agent --output "$PACKAGE.sig" --detach-sign "$PACKAGE"
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_chroot_environment() {
|
||||||
|
if [ "$(stat -f --format=%T "$CHROOT")" == "btrfs" ]; then
|
||||||
|
{
|
||||||
|
sudo btrfs subvolume delete "$CHROOT/root/var/lib/portables"
|
||||||
|
sudo btrfs subvolume delete "$CHROOT/root/var/lib/machines"
|
||||||
|
sudo btrfs subvolume delete "$CHROOT/root"
|
||||||
|
sudo rm -Rf $CHROOT
|
||||||
|
} >>/dev/null 2>&1
|
||||||
|
elif [ "$(stat -f --format=%T "$CHROOT")" == "tmpfs" ]; then
|
||||||
|
sudo umount -f $CHROOT
|
||||||
|
fi
|
||||||
|
sudo rm -Rf $CHROOT
|
||||||
|
}
|
||||||
|
|
||||||
|
check_available_ram
|
||||||
|
create_chroot_directory
|
||||||
|
create_chroot_environment
|
||||||
|
build_package
|
||||||
|
sign_package
|
||||||
|
delete_chroot_environment
|
||||||
|
|
||||||
|
# vim: set ts=4 sw=4 et:
|
||||||
99
upload-to-dalci-3rdparty-repo
Executable file
99
upload-to-dalci-3rdparty-repo
Executable file
|
|
@ -0,0 +1,99 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# SPDX-License-Identifier: 0BSD
|
||||||
|
# SPDX-FileCopyrightText: 2025 Christian Schendel <doppelhelix@gmail.com>
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
color_note="\e[1;36m==>\e[0m"
|
||||||
|
color_ok="\e[1;32m==>\e[0m"
|
||||||
|
color_error="\e[1;31m==>\e[0m"
|
||||||
|
color_warning="\e[1;35m==>\e[0m"
|
||||||
|
|
||||||
|
|
||||||
|
show_cursor() {
|
||||||
|
tput cnorm
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
hide_cursor() {
|
||||||
|
tput civis
|
||||||
|
}
|
||||||
|
|
||||||
|
trap show_cursor INT TERM
|
||||||
|
hide_cursor
|
||||||
|
|
||||||
|
|
||||||
|
configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-3rdparty-repo.cfg"
|
||||||
|
|
||||||
|
## check for config file
|
||||||
|
if [[ -r "$configfile" ]]; then
|
||||||
|
configfile_secured="${TMPDIR:-/tmp}/tmp.upload-to-dalci-3rdparty-repo.cfg"
|
||||||
|
else
|
||||||
|
echo -e "\b$color_error no configuration found"
|
||||||
|
cat > "$configfile" << EOF
|
||||||
|
forgejo_repo_url="https://{domain}/api/packages/{owner}/arch/{group}"
|
||||||
|
forgejo_user="your_username"
|
||||||
|
forgejo_token="your_token_or_password"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
echo -e "\b$color_note example configuration created at"
|
||||||
|
echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg"
|
||||||
|
echo -e "\b$color_warning please edit it before running this script again"
|
||||||
|
show_cursor
|
||||||
|
fi
|
||||||
|
|
||||||
|
# secure the config file
|
||||||
|
rm -f "$configfile_secured"
|
||||||
|
while IFS= read -r line; do
|
||||||
|
printf '%s\n' \
|
||||||
|
"$(sed -E "s/^(\s)?+(#.+$|[a-zA-Z0-9_]+=['\"]?[a-zA-Z0-9_~\.\`-]+['\"]).+$/\2/g" <<< "$line")" \
|
||||||
|
>> "$configfile_secured"
|
||||||
|
configfile=$configfile_secured
|
||||||
|
done <<EOF
|
||||||
|
$(cat "$configfile" | grep -v "^$")
|
||||||
|
EOF
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$configfile"
|
||||||
|
|
||||||
|
show_progress() {
|
||||||
|
pid=$1
|
||||||
|
spin='—\|/'
|
||||||
|
i=0
|
||||||
|
while kill -0 "$pid" 2>/dev/null; do
|
||||||
|
i=$(((i + 1) % 4))
|
||||||
|
spinner="${spin:$i:1}"
|
||||||
|
printf '\b%s' "$spinner"
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
check_for_pkg() {
|
||||||
|
pkg=$(find ./ -type f -name "*.pkg.tar.zst")
|
||||||
|
if [ ! -z "$pkg" ]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo -e "\b$color_error no packges found."
|
||||||
|
echo -e "\b\tPlease run this script from inside the directory"
|
||||||
|
echo -e "\b\twhich holds the Arch-packages."
|
||||||
|
echo -e "\b$color_ok Exiting now."
|
||||||
|
show_cursor
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_package() {
|
||||||
|
for file in ./*; do
|
||||||
|
if [[ "$file" != *.pkg.tar.zst ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo -e "\b$color_note uploading $file"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
curl -X PUT "$forgejo_repo_url" \
|
||||||
|
--user "${forgejo_user}:${forgejo_token}" \
|
||||||
|
--header "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e "\n\b$color_ok packges uploaded"
|
||||||
|
}
|
||||||
|
check_for_pkg
|
||||||
|
upload_package & show_progress $!
|
||||||
|
show_cursor
|
||||||
|
|
@ -79,7 +79,7 @@ check_for_pkg() {
|
||||||
upload_package() {
|
upload_package() {
|
||||||
for file in ./*; do
|
for file in ./*; do
|
||||||
if [[ "$file" != *.pkg.tar.zst ]]; then
|
if [[ "$file" != *.pkg.tar.zst ]]; then
|
||||||
exit 1
|
:
|
||||||
else
|
else
|
||||||
echo -e "\b$color_note uploading $file"
|
echo -e "\b$color_note uploading $file"
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
|
|
@ -89,7 +89,7 @@ upload_package() {
|
||||||
--data-binary "@$file"
|
--data-binary "@$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo -e "\b$color_ok packges uploaded"
|
echo -e "\n\b$color_ok packges uploaded"
|
||||||
}
|
}
|
||||||
check_for_pkg
|
check_for_pkg
|
||||||
upload_package & show_progress $!
|
upload_package & show_progress $!
|
||||||
Loading…
Add table
Add a link
Reference in a new issue