You are not logged in.

#1 2022-06-20 03:37:40

randomxusr
Member
Registered: 2021-08-04
Posts: 30

Suggestions for Downloading an Array of packages for AUR

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

#2 2022-06-20 04:25:01

Awebb
Member
Registered: 2010-05-06
Posts: 6,275

Re: Suggestions for Downloading an Array of packages for AUR

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

#3 2022-06-20 04:27:49

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Suggestions for Downloading an Array of packages for AUR


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2022-06-20 04:49:05

randomxusr
Member
Registered: 2021-08-04
Posts: 30

Re: Suggestions for Downloading an Array of packages for AUR

Thanks jasonwryan for the tutorial.

Curious; How might you implement something like this?

Offline

#5 2022-06-20 05:00:53

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Suggestions for Downloading an Array of packages for AUR

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.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2022-06-20 11:28:05

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: Suggestions for Downloading an Array of packages for AUR

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

Board footer

Powered by FluxBB