falconindy / pkgbuild-introspection

Tools for generating .SRCINFO files and PKGBUILD data extraction
MIT License
39 stars 9 forks source link

mksrcinfo: Handle PKGBUILD path passed as argument #33

Closed mikkeloscar closed 8 years ago

mikkeloscar commented 8 years ago

Makes sure that mksrcinfo doesn't die if the PKGBUILD path is passed as an argument.

falconindy commented 8 years ago

Your fix isn't quite right:

1) You don't want an -n check, since this doesn't care for PKGBUILDs which don't exist on disk. 2) The error message when the PKGBUILD isn't found is no longer accurate if the PKGBUILD path is parsed.

You probably want something like:

if [[ $1 && ! -f $1 ]]; then
  die '%s not found' "$1"
 elif [[ ! -f PKGBUILD ]]; then
  die 'PKGBUILD not found in current directory'
fi
mikkeloscar commented 8 years ago

Oh, that's right, thank you. I have updated it with your version.

danielshub commented 8 years ago

I am not sure this is correct. If it does not die because the first argument is not a file, it then checks if there is a PKGBUILD file in the current directory. What about something like

if [ ! -f "${1:-$PWD/PKGBUILD}" ]; then
  die '%s not found' "${1:-$PWD/PKGBUILD}"
fi
falconindy commented 8 years ago

Right. 176dac035184 should fix this.

falconindy commented 8 years ago

Annnnd because of pacman 5.0, this is all effectively reverted. See a07cd59cea847d

mikkeloscar commented 8 years ago

I actually ended up doing something like this in the tool where I needed this feature so all is good. Thanks for keeping us updated!