From 8a64dc90c52d6029f9d1e2baf9abcf017d208f48 Mon Sep 17 00:00:00 2001 From: Alexandre CATTEAU Date: Mon, 14 Feb 2022 22:26:48 +0100 Subject: [PATCH] Functional version 1.1 --- .gitignore | 1 + README.md | 7 +++++-- update-repo.sh | 46 ++++++++++++++++++++--------------------- variables.conf.template | 9 ++++++++ 4 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 .gitignore create mode 100644 variables.conf.template diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bfdbd30 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +variables.conf diff --git a/README.md b/README.md index eb57aa9..5a1e1eb 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,14 @@ ### Version 1 In a nutshell: * this script is run punctually, on a dedicated Arch VM; -* Proces: +* 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 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. + +#### TODO +* clear function is not implemented yet diff --git a/update-repo.sh b/update-repo.sh index cfdb730..f51203b 100755 --- a/update-repo.sh +++ b/update-repo.sh @@ -9,6 +9,7 @@ # Make sure the following packages are installed before running this script: # package-query aurutils git + # Functions ################################################################## @@ -81,19 +82,21 @@ init() { exit 1 fi + source ../variables.conf + eval "$(ssh-agent)" + ssh-add $ssh_key + # TODO Check if required packages are installed echo "ArchRepo update script" } -ftpFetch() { - ftp fetch $remote_repository/$repo_db_file $run_directory_path # TODO use real syntax ^^' -} - 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/ +# 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) OIFS=$IFS @@ -122,7 +125,6 @@ checkUpdates() { continue 1 fi - exlist="" if echo $exlist | grep -w $name > /dev/null; then echo -e "\nSkipping $name ($version, temporary exception)." continue 1 @@ -135,6 +137,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" @@ -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 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 + ## 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 } -ftpSend() { - -} - # 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_db_file $1-$2*.pkg.tar.xz - ftp send $repo_db_file $repo_db_file.old $remote_repository - ftp send packages $remote_repository + scp $ssh_options $run_directory_path/$1/$1-$2*.pkg.tar.xz $remote_repository/ + repo-add $repo_db_file $run_directory_path/$1/$1-$2*.pkg.tar.xz + 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/ 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.xz $run_directory_path/$1/$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 } @@ -246,8 +244,8 @@ run_directory_path=$(pwd) repo_directory='/mnt/archrepo' repo_name='kto' repo_db_file=$repo_name.db.tar +repo_db_filesfile=$repo_name.files.tar awk_rules_file='../parser.awk' -#repo_db_file='kto.db.tar' # You can set db name manually here if different # Main process diff --git a/variables.conf.template b/variables.conf.template new file mode 100644 index 0000000..bfd0375 --- /dev/null +++ b/variables.conf.template @@ -0,0 +1,9 @@ +#!/bin/bash + +# Copy this file as variables.conf, with the correct values + +remote_repository="" +ssh_key="" +ssh_options="" + +exlist=""