You are not logged in.
New to scripting and I'd like some suggestions for how to solve a challenge.
I'd like to declare and Array of the 10 or so packages I've installed from the AUR, and use a script to download updates, such as using a git pull.
Would something like work?
package=( "package1" , "package2" , "package3" )
for i in $package
do
git clone https://aur.archlinux.org/${package}.git
done
Last edited by randomxusr (2022-06-20 03:37:56)
Offline
Yes, but no. In bash, $package does not reference the whole array:
$ package=( "package1" , "package2" , "package3" ); for i in $package; do echo $i; done
package1
But besides you having to read up on for loops in bash, this will work. Just forget about arrays:
packages="package1 package2 package3"
Last edited by Awebb (2022-06-20 04:26:02)
Offline
Offline
Thanks jasonwryan for the tutorial.
Curious; How might you implement something like this?
Offline
I'd probably start the way you have proposed. But change into the named directories (otherwise the git command will fail). Then it depends whether or not this is a quick and dirty script to just update your build directory, or you intend to use it more frequently or add a build process with makepkg. If so, I'd think about adding error checking and generally try and make it more robust.
Offline
You may like to do a check before and after, say a local and a remote check before building a package and let the script do the job.
Something like this:
localversion=$(git rev-parse --short HEAD)
git fetch
remoteversion=$(git rev-parse --short HEAD)
diff both
build (when local- & remoteversion differ)
I personally use 'git fetch' for that then check for diff in the commit and rebuild - or not OC..
This way you wont need clone unless you don't have that package already, just rebuild if commit differs...
BTW. you also want to divide between static(git) or git projects(where the project itself is a git repo), unless all pkg's are git.
Offline