rmarquis / pacaur

[unmaintained] An AUR helper that minimizes user interaction
https://bbs.archlinux.org/viewtopic.php?pid=1755144#p1755144
ISC License
796 stars 113 forks source link

Reading package list on stdin fails. #588

Open michaelcadilhac opened 8 years ago

michaelcadilhac commented 8 years ago
Version

pacaur -v

pacaur 4.6.10
Description

Suppose we have a list of packages in some pkg.txt file; then pacman -S - < pkg.txt would install all of them. Pacaur fails at doing so.

Output

pacaur -S - < pkg.txt

error: argument '-' specified with empty stdin
Debug output

bash -x pacaur -S - < pkg.txt

+ version=4.6.10
+ unset aur cleancache devel edit info installpkg foreign needed noconfirm nodeps noedit
+ unset operation pac pacQ pacS quiet rebuild refresh repo search selective upgrade
+ LC_COLLATE=C
+ TEXTDOMAIN=pacaur
+ TEXTDOMAINDIR=/usr/share/locale
+ [[ -n '' ]]
+ configdir=/etc/xdg/pacaur
+ userconfigdir=/home/micha/.config/pacaur
+ userpacmandir=/home/micha/.config/pacman
+ usercachedir=/home/micha/.cache/pacaur
+ [[ -r '' ]]
+ source /etc/makepkg.conf
++ DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' 'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' 'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' 'rsync::/usr/bin/rsync --no-motd -z %u %o' 'scp::/usr/bin/scp -C %u %o')
++ VCSCLIENTS=('bzr::bzr' 'git::git' 'hg::mercurial' 'svn::subversion')
++ CARCH=x86_64
++ CHOST=x86_64-pc-linux-gnu
++ CPPFLAGS=-D_FORTIFY_SOURCE=2
++ CFLAGS='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong'
++ CXXFLAGS='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong'
++ LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro
++ DEBUG_CFLAGS='-g -fvar-tracking-assignments'
++ DEBUG_CXXFLAGS='-g -fvar-tracking-assignments'
++ BUILDENV=(!distcc color !ccache check !sign)
++ OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !optipng !upx !debug)
++ INTEGRITY_CHECK=(md5)
++ STRIP_BINARIES=--strip-all
++ STRIP_SHARED=--strip-unneeded
++ STRIP_STATIC=--strip-debug
++ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
++ DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
++ PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
++ COMPRESSGZ=(gzip -c -f -n)
++ COMPRESSBZ2=(bzip2 -c -f)
++ COMPRESSXZ=(xz -c -z -)
++ COMPRESSLRZ=(lrzip -q)
++ COMPRESSLZO=(lzop -q)
++ COMPRESSZ=(compress -c -f)
++ PKGEXT=.pkg.tar.xz
++ SRCEXT=.src.tar.gz
+ [[ -r /home/micha/.config/pacman/makepkg.conf ]]
+ [[ -r /home/micha/.makepkg.conf ]]
+ tmpdir=/tmp/pacaurtmp-micha
+ clonedir=/home/micha/.cache/pacaur
+ editor=vi
+ displaybuildfiles=diff
+ fallback=true
+ silent=false
+ sortby=popularity
+ sortorder=descending
+ sudoloop=true
+ pacmanbin=pacman
+ aururl=aur.archlinux.org
+ aurrpc='/rpc.php?type=info&v=5'
+ source /etc/xdg/pacaur/config
+ [[ -r /home/micha/.config/pacaur/config ]]
+ [[ ! -d /tmp/pacaurtmp-micha ]]
+ [[ ! -d /home/micha/.cache/pacaur ]]
+ trap Cancel INT
+ args=($@)
+ for i in '"${args[@]}"'
+ [[ -S =~ ^-[a-zA-Z0-9] ]]
+ opts+=($i)
+ for i in '"${args[@]}"'
+ [[ - =~ ^-[a-zA-Z0-9] ]]
+ count=0
+ [[ -n -S ]]
+ getopts sidmykufecqrahvxVDFQRSTUbglnoptw-: OPT
+ pacmanarg+=("-$OPT")
+ case "$OPT" in
+ pacS=1
+ operation=sync
+ [[ -S =~ w ]]
+ installpkg=true
+ [[ -S =~ g ]]
+ [[ -S =~ l ]]
+ [[ -S =~ p ]]
+ getopts sidmykufecqrahvxVDFQRSTUbglnoptw-: OPT
+ [[ -z - ]]
+ pkgs+=("${!OPTIND}")
+ shift 2
+ OPTIND=1
+ [[ -n '' ]]
++ grep '^Color' /etc/pacman.conf
+ [[ -n '' ]]
++ grep '^Color' /etc/pacman.conf
+ [[ -z '' ]]
+ [[ '' = \a\l\w\a\y\s ]]
+ [[ '' = \a\u\t\o ]]
+ [[ '' != \a\l\w\a\y\s ]]
+ [[ '' != \a\u\t\o ]]
+ makeopts+=("--nocolor")
+ pacmanarg=(${pacmanarg[@]/--/})
+ pacmanarg=(${pacmanarg[@]/-r/})
+ pacmanarg=(${pacmanarg[@]/-a/})
+ [[ sync = sync ]]
+ [[ ! -n '' ]]
+ [[ ! -n '' ]]
+ [[ ! -n '' ]]
+ [[ 1000 -eq 0 ]]
+ [[ -n 1 ]]
+ pacmanarg=(${pacmanarg[@]/-e/})
+ [[ -n 1 ]]
+ [[ -n '' ]]
+ [[ -n 1 ]]
+ [[ -n '' ]]
+ [[ ! -n vi ]]
+ [[ sync = sync ]]
+ [[ ! -n '' ]]
+ [[ ! -n '' ]]
+ [[ ! -n '' ]]
+ [[ diff = diff ]]
+ [[ /home/micha/.cache/pacaur = /tmp/pacaurtmp-micha ]]
+ [[ ! -w /home/micha/.cache/pacaur ]]
+ [[ -z - ]]
+ [[ -z - ]]
+ [[ -n '' ]]
+ case $operation in
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -z - ]]
+ ClassifyPkgs -
+ local noaurpkgs norepopkgs
+ [[ true = true ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ ! -n '' ]]
+ [[ ! -n '' ]]
+ unset noaurpkgs
+ for i in '"${pkgs[@]}"'
+ [[ - == aur/* ]]
+ noaurpkgs+=($i)
+ [[ -n - ]]
+ norepopkgs=($(LANG=C $pacmanbin -Sp ${noaurpkgs[@]} 2>&1 >/dev/null | awk '{print $NF}'))
++ LANG=C
++ pacman -Sp -
++ awk '{print $NF}'
+ repopkgs=($(grep -xvf <(printf '%s\n' "${aurpkgs[@]}") <(printf '%s\n' "${noaurpkgs[@]}")))
++ grep -xvf /dev/fd/63 /dev/fd/62
+++ printf '%s\n' -
+++ printf '%s\n'
+ [[ -n - ]]
+ sudo pacman -S -
error: argument '-' specified with empty stdin
+ [[ -n '' ]]
+ exit
davidgasquez commented 7 years ago

Hey there! Is there any updates or workarounds for this?

rmarquis commented 7 years ago

Not really. I spent some time on it, but wasn't able to find a proper fix yet. Contribution welcome.

davidgasquez commented 7 years ago

I'm not really well versed around bash to be honest... I'll try to search at least a workaround and share here if that's ok. Thanks for answering so quickly!

juergenhoetzel commented 7 years ago

Hey there! Is there any updates or workarounds for this?

Workaround:

xargs <pkg.txt pacaur -S 
juergenhoetzel commented 7 years ago

Hey there! Is there any updates or workarounds for this?

Root cause (stdin is consumed here):

https://github.com/rmarquis/pacaur/blob/master/pacaur#L110

but used here again (but stdin is already closed/EOF):

https://github.com/rmarquis/pacaur/blob/master/pacaur#L2038

which is why pacman reports

error: argument '-' specified with empty stdin
rmarquis commented 7 years ago

Thanks! I'll have a look shortly (I haven't access to my nux system for the time being, bear with me). - should probably be filtered out in ClassifyPkgs().

rmarquis commented 7 years ago

Relevant info: