23 Commits

Author SHA1 Message Date
29bce39352 Update the -debug packages exception rule 2025-06-22 11:43:12 +02:00
2f313c7684 Add doomsday-debug to exceptions 2025-03-08 10:42:48 +01:00
0a67dc9468 Update exception rules 2025-01-18 13:34:21 +01:00
24bd826d61 Add package-query-debug to permanent exceptions 2024-09-21 11:45:27 +02:00
513cfce006 Update to support any compression extension for packages 2024-09-21 11:43:30 +02:00
034c623728 Update previous commit to match another case 2024-01-09 09:43:26 +01:00
512a26ffef Add kodi libretro debug packages to check exclusion list 2024-01-09 09:41:01 +01:00
8daacd295f Remove non-root requirement for clear script 2022-08-19 10:11:00 +02:00
0e0d7fb89c Correct typos in comments in clear-repo.sh 2022-08-19 10:05:41 +02:00
fb1de49639 Replace bang in variables.conf.template 2022-07-31 12:06:52 +02:00
f78fe2d14e Move repo files copy after specific kernel building 2022-07-03 11:56:21 +02:00
21693c5729 Add TODO item in README 2022-07-01 14:08:06 +02:00
4d3f8720e5 Add case for GNU Tar as gtar (OpenBSD) 2022-04-18 13:44:29 +02:00
1ffae99efd Initial support for multiple additions 2022-04-18 12:33:09 +02:00
4572fbcbc8 Fix addPackage feature, which could not work (never tested before...) 2022-04-18 12:19:50 +02:00
4342916369 Fix same issue in update script... 2022-04-18 12:09:22 +02:00
7ee2fa6755 Move variables definition (to prevent a stupid error) 2022-04-18 12:05:20 +02:00
5103e3b6b0 Fix issue in init 2022-04-18 12:02:06 +02:00
e6680cec18 Replace shebang with env 2022-04-18 11:57:58 +02:00
4723e1aa35 Add clearing support (directly on remote server) 2022-04-18 11:54:06 +02:00
bb27c7061f Add build directory to gitignore 2022-02-15 16:23:59 +01:00
8a64dc90c5 Functional version 1.1 2022-02-14 22:26:48 +01:00
dfd59d987e Initial commit (WIP) 2022-02-13 15:17:55 +01:00
5 changed files with 132 additions and 76 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
variables.conf
build/*

View File

@ -1,10 +1,19 @@
# ArchRepo
## Version 1
## Version 1.1
### Introduction
### Version 1
In a nutshell:
* this script is run punctually, on a dedicated Arch VM;
* Process:
* it takes all packages in the repository;
* checks online if a new version is available
* if so build it and then add it to the repository
### Version 1.1
Version 1.1 is an adapted version 1, with remote repository. The idea is to replace NFS by SCP for everything related
with connection to repository.
We also have a specific clearing script, which should run directly on remote server.
#### TODO
* Replace `scp` calls by `sftp` (or `rsync`)

80
clear-repo.sh Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/env bash
# The purpose of this script is to clear our custom pacman repository
# i.e. remove old versions of packages
# This script should NOT be run as root.
# Make sure that AWK rules file is present, readable and correctly set in this script's parameters
init() {
source variables.conf
repo_db_file=$repo_name.db.tar
repo_db_filesfile=$repo_name.files.tar
awk_rules_file='parser.awk'
if [ ! -e $repo_directory/$repo_db_file ] ; then
echo "Could not find db file. Exiting..."
exit 1
fi
echo "ArchRepo clearing script"
}
clearRepo() {
if [ "$(uname)" = "OpenBSD" ]; then # TODO This could probably be done better (like with actually checking if tar is GNU...)
gnutar="gtar"
else
gnutar="tar"
fi
stream=$($gnutar xOf $repo_directory/$repo_db_file --wildcards */desc | awk -f $awk_rules_file)
OIFS=$IFS
IFS='|'
stream="${stream:1}"
current=""
for package in $stream
do
IFS='
'
count=0
for line in $package; do
if [ $count -eq 0 ]; then
current="$current $line"
else
continue
fi
((count++))
done
IFS='|'
done
IFS=$OIFS
cd $repo_directory
reg="^($repo_name.).+"
for filename in *; do
if [[ $filename =~ $reg || $filename = 'sync' || $filename = 'local' || $filename = 'resources' ]]; then
continue
fi
for package in $current; do
if [ $filename = $package ]; then
continue 2
fi
done
echo "Removing $filename..."
rm $filename
done
}
run_directory_path=$(pwd)
# Main process
if [ "$1" = "" ]; then
init
clearRepo
else
echo "Please call this script without any arguments."
exit 1
fi
exit 0

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# The purpose of this script is to automate the maintenance of a custom pacman (Arch Linux) repository, whose goal is to
# provide package-ready AUR softs.
@ -9,6 +9,7 @@
# Make sure the following packages are installed before running this script:
# package-query aurutils git
# Functions
##################################################################
@ -82,6 +83,11 @@ init() {
fi
source ../variables.conf
repo_db_file=$repo_name.db.tar
repo_db_filesfile=$repo_name.files.tar
awk_rules_file='../parser.awk'
eval "$(ssh-agent)"
ssh-add $ssh_key
# TODO Check if required packages are installed
@ -91,7 +97,8 @@ init() {
checkUpdates() {
echo "Checking for updates:"
upgraded_packages=""
stream=$(tar xOf $repo_directory/$repo_db_file --wildcards */desc | awk -f $awk_rules_file)
scp $ssh_options $remote_repository/$repo_db_file $remote_repository/$repo_db_filesfile $run_directory_path/
stream=$(tar xOf $run_directory_path/$repo_db_file --wildcards */desc | awk -f $awk_rules_file)
OIFS=$IFS
IFS='|'
@ -119,6 +126,12 @@ checkUpdates() {
continue 1
fi
reg=".+-(debug)"
if [[ $name =~ $reg ]]; then
echo -e "\nSkipping $name ($version, default exception)."
continue 1
fi
if echo $exlist | grep -w $name > /dev/null; then
echo -e "\nSkipping $name ($version, temporary exception)."
continue 1
@ -131,6 +144,7 @@ checkUpdates() {
result=$?
if [[ $result -eq 1 ]]; then
echo "New version for $name: $version -> $aur_version"
IFS=$OIFS
createPackage $name
addPackageToRepo $name $aur_version
upgraded_packages="$upgraded_packages $name"
@ -157,27 +171,22 @@ createPackage() { # Create package $1
aur fetch $1 # TODO This could be replaced by a git clone or even a wget+tar thanks to package-query
echo "Making $1 package..."
cd $1
# if linux-lts{414,49} then download kernel source from local repo (saves ~100MB each time)
# WARNING this onlys works because we already have said sources AND because PKBUILD follow this particular line
# (not the same in 419 nor 54)
reg="(linux-lts).+"
if [[ $1 =~ $reg ]]; then
sed -i -e "s/\"https:\/\/www.kernel.org\/pub\/linux\/kernel\/v4.x\/\${_srcname}.tar.xz\"/\"https:\/\/archlinux.kto.black\/resources\/\${_srcname}.tar.xz\"/g" ./PKGBUILD
fi
makepkg -s --noconfirm --noprogressbar
cd $run_directory_path
}
# TODO: try manually: can we update db file before sending to remote repo?
addPackageToRepo() { # Add package $1
echo "Adding $1 to repository..."
cp $run_directory_path/$1/$1-$2*.pkg.tar.xz $repo_directory
repo-add $repo_directory/$repo_db_file $repo_directory/$1-$2*.pkg.tar.xz
scp $ssh_options $run_directory_path/$1/$1-$2*.pkg.tar.* $remote_repository/
repo-add $repo_db_file $run_directory_path/$1/$1-$2*.pkg.tar.*
reg="(linux-lts).+"
if [[ $name =~ $reg ]]; then
echo "Adding $1-headers and $1-docs to repository..."
cp $run_directory_path/$1/$1-headers-$2*.pkg.tar.xz $run_directory_path/$1/$1-docs-$2*.pkg.tar.xz $repo_directory
repo-add $repo_directory/$repo_db_file $repo_directory/$1-headers-$2*.pkg.tar.xz $repo_directory/$1-docs-$2*.pkg.tar.xz
repo-add $repo_db_file $run_directory_path/$1/$1-headers-$2*.pkg.tar.* $run_directory_path/$1/$1-docs-$2*.pkg.tar.*
scp $ssh_options $run_directory_path/$1/$1-headers-$2*.pkg.tar.* $run_directory_path/$1/$1-docs-$2*.pkg.tar.* $remote_repository/
fi
scp $ssh_options $run_directory_path/$repo_db_file $run_directory_path/$repo_db_file.old $run_directory_path/$repo_db_filesfile $run_directory_path/$repo_db_filesfile.old $remote_repository/
}
clean() {
@ -186,58 +195,8 @@ clean() {
echo "Done."
}
clearRepo() {
stream=$(tar xOf $repo_directory/$repo_db_file --wildcards */desc | awk -f $awk_rules_file)
OIFS=$IFS
IFS='|'
stream="${stream:1}"
current=""
for package in $stream
do
IFS='
'
count=0
for line in $package; do
if [ $count -eq 0 ]; then
current="$current $line"
else
continue
fi
((count++))
done
IFS='|'
done
IFS=$OIFS
cd $repo_directory
reg="^($repo_name.).+"
for filename in *; do
if [[ $filename =~ $reg || $filename = 'sync' || $filename = 'local' || $filename = 'resources' ]]; then
continue
fi
for package in $current; do
if [ $filename = $package ]; then
continue 2
fi
done
echo "Removing $filename..."
rm $filename
done
}
run_directory_path=$(pwd)
# Set parameters
repo_directory='/mnt/archrepo'
repo_name='kto'
repo_db_file=$repo_name.db.tar
awk_rules_file='../parser.awk'
#repo_db_file='kto.db.tar' # You can set db name manually here if different
# Main process
if [ "$1" = "" ]; then
@ -245,18 +204,15 @@ if [ "$1" = "" ]; then
checkUpdates
elif [ "$1" = "add" ]; then
init
addPackage $2
scp $ssh_options $remote_repository/$repo_db_file $remote_repository/$repo_db_filesfile $run_directory_path/
for arg in "$@"; do
if [[ $arg = "add" ]]; then
continue
fi
addPackage $arg
done
elif [ "$1" = "clean" ]; then
clean
elif [ "$1" = "clear" ]; then
read -r -p "Are you sure? [y/N] " response
response=${response,,} # tolower
if [[ "$response" =~ ^(yes|y)$ ]]; then
clearRepo
else
echo "Cancelling... Perhaps did you mean 'clean', which empties the local build directory?"
exit 1
fi
else
exit 1
fi

View File

@ -1,5 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
# Copy this file as variables.conf, with the correct values
# For both update and clear scripts:
repo_name=""
# For update script:
remote_repository=""
ssh_key=""
ssh_options="-i $ssh_key"
exlist=""
# For clear script:
repo_directory=""