You are not logged in.

#1 2017-06-11 20:48:48

xvzf
Member
Registered: 2014-05-18
Posts: 86

Scripting in PKGBUILD

Hi there,

I am just playing around with a PKGBUILD.

Is it possible to iterate using a for loop for install?

...
package() {
  mkdir -p "${pkgdir}/usr/libexec/dataleech/"
  for i in $(echo newdailysnap newshortsnap)
  do
	install -Dm755 "${srcdir}/bazel-bin/snapmanager/${i}" "${pkgdir}/usr/bin/${i}"

	  # install -d just doesnt work for that many files
	cp -R "${srcdir}/bazel-bin/snapmanager/${i}.runfiles" "${pkgdir}/usr/libexec/dataleech/${i}.runfiles" 
	chmod 755 -R "${pkgdir}/usr/libexec/dataleech/"
  done
}

Am I missing something or is this not possible and I have to create a custom install script?

Cheers,
Matthias

Last edited by xvzf (2017-06-11 20:49:52)

Offline

#2 2017-06-11 21:23:29

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Scripting in PKGBUILD

A PKGBUILD is written in bash, so any valid bash is valid in a PKGBUILD so long as the right variables and package() function are defined.

That being said, why on earth are you using `for i in $(echo key1 key2)` when `for i in key1 key2` does exactly the same thing, without introducing fragile re-handling of word splitting, and without invoking a subshell? (At least echo is a builtin rather than yet another external command, but that doesn't really excuse the sheer ugliness.)

tl;dr Did you actually try this before asking whether it is possible? Because your post reads as though you tried and failed to do so.

Last edited by eschwartz (2017-06-11 21:24:31)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB