Add clearing support (directly on remote server)
This commit is contained in:
@ -95,8 +95,6 @@ checkUpdates() {
|
||||
echo "Checking for updates:"
|
||||
upgraded_packages=""
|
||||
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
|
||||
@ -164,13 +162,6 @@ 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
|
||||
}
|
||||
@ -195,54 +186,9 @@ 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
|
||||
repo_db_filesfile=$repo_name.files.tar
|
||||
awk_rules_file='../parser.awk'
|
||||
@ -257,15 +203,6 @@ elif [ "$1" = "add" ]; then
|
||||
addPackage $2
|
||||
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
|
||||
|
Reference in New Issue
Block a user