Functional version 1.1

This commit is contained in:
Alexandre CATTEAU 2022-02-14 22:26:48 +01:00
parent dfd59d987e
commit 8a64dc90c5
4 changed files with 37 additions and 26 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
variables.conf

View File

@ -4,11 +4,14 @@
### Version 1 ### Version 1
In a nutshell: In a nutshell:
* this script is run punctually, on a dedicated Arch VM; * this script is run punctually, on a dedicated Arch VM;
* Proces: * Process:
* it takes all packages in the repository; * it takes all packages in the repository;
* checks online if a new version is available * checks online if a new version is available
* if so build it and then add it to the repository * if so build it and then add it to the repository
### Version 1.1 ### Version 1.1
Version 1.1 is an adapted version 1, with remote repository. The idea is to replace NFS by FTP for everything related 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. with connection to repository.
#### TODO
* clear function is not implemented yet

View File

@ -9,6 +9,7 @@
# Make sure the following packages are installed before running this script: # Make sure the following packages are installed before running this script:
# package-query aurutils git # package-query aurutils git
# Functions # Functions
################################################################## ##################################################################
@ -81,19 +82,21 @@ init() {
exit 1 exit 1
fi fi
source ../variables.conf
eval "$(ssh-agent)"
ssh-add $ssh_key
# TODO Check if required packages are installed # TODO Check if required packages are installed
echo "ArchRepo update script" echo "ArchRepo update script"
} }
ftpFetch() {
ftp fetch $remote_repository/$repo_db_file $run_directory_path # TODO use real syntax ^^'
}
checkUpdates() { checkUpdates() {
echo "Checking for updates:" echo "Checking for updates:"
upgraded_packages="" 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/
# scp $ssh_options $remote_repository/$repo_db_file $run_directory_path/
# cp $run_directory_path/../$repo_db_filesfile $run_directory_path/
stream=$(tar xOf $run_directory_path/$repo_db_file --wildcards */desc | awk -f $awk_rules_file) stream=$(tar xOf $run_directory_path/$repo_db_file --wildcards */desc | awk -f $awk_rules_file)
OIFS=$IFS OIFS=$IFS
@ -122,7 +125,6 @@ checkUpdates() {
continue 1 continue 1
fi fi
exlist=""
if echo $exlist | grep -w $name > /dev/null; then if echo $exlist | grep -w $name > /dev/null; then
echo -e "\nSkipping $name ($version, temporary exception)." echo -e "\nSkipping $name ($version, temporary exception)."
continue 1 continue 1
@ -135,6 +137,7 @@ checkUpdates() {
result=$? result=$?
if [[ $result -eq 1 ]]; then if [[ $result -eq 1 ]]; then
echo "New version for $name: $version -> $aur_version" echo "New version for $name: $version -> $aur_version"
IFS=$OIFS
createPackage $name createPackage $name
addPackageToRepo $name $aur_version addPackageToRepo $name $aur_version
upgraded_packages="$upgraded_packages $name" upgraded_packages="$upgraded_packages $name"
@ -161,33 +164,28 @@ 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 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..." echo "Making $1 package..."
cd $1 cd $1
# if linux-lts{414,49} then download kernel source from local repo (saves ~100MB each time) ## 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 ## WARNING this onlys works because we already have said sources AND because PKBUILD follow this particular line
# (not the same in 419 nor 54) ## (not the same in 419 nor 54)
reg="(linux-lts).+" #reg="(linux-lts).+"
if [[ $1 =~ $reg ]]; then #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 #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 #fi
makepkg -s --noconfirm --noprogressbar makepkg -s --noconfirm --noprogressbar
cd $run_directory_path cd $run_directory_path
} }
ftpSend() {
}
# TODO: try manually: can we update db file before sending to remote repo? # TODO: try manually: can we update db file before sending to remote repo?
addPackageToRepo() { # Add package $1 addPackageToRepo() { # Add package $1
echo "Adding $1 to repository..." echo "Adding $1 to repository..."
#cp $run_directory_path/$1/$1-$2*.pkg.tar.xz $repo_directory scp $ssh_options $run_directory_path/$1/$1-$2*.pkg.tar.xz $remote_repository/
repo-add $repo_db_file $1-$2*.pkg.tar.xz repo-add $repo_db_file $run_directory_path/$1/$1-$2*.pkg.tar.xz
ftp send $repo_db_file $repo_db_file.old $remote_repository 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/
ftp send packages $remote_repository
reg="(linux-lts).+" reg="(linux-lts).+"
if [[ $name =~ $reg ]]; then if [[ $name =~ $reg ]]; then
echo "Adding $1-headers and $1-docs to repository..." 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_db_file $run_directory_path/$1/$1-headers-$2*.pkg.tar.xz $run_directory_path/$1/$1-docs-$2*.pkg.tar.xz
repo-add $repo_directory/$repo_db_file $repo_directory/$1-headers-$2*.pkg.tar.xz $repo_directory/$1-docs-$2*.pkg.tar.xz scp $ssh_options $run_directory_path/$1/$1-headers-$2*.pkg.tar.xz $run_directory_path/$1/$1-docs-$2*.pkg.tar.xz $remote_repository/
fi fi
} }
@ -246,8 +244,8 @@ run_directory_path=$(pwd)
repo_directory='/mnt/archrepo' repo_directory='/mnt/archrepo'
repo_name='kto' repo_name='kto'
repo_db_file=$repo_name.db.tar repo_db_file=$repo_name.db.tar
repo_db_filesfile=$repo_name.files.tar
awk_rules_file='../parser.awk' awk_rules_file='../parser.awk'
#repo_db_file='kto.db.tar' # You can set db name manually here if different
# Main process # Main process

9
variables.conf.template Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# Copy this file as variables.conf, with the correct values
remote_repository=""
ssh_key=""
ssh_options=""
exlist=""