Open miblodelcarpio opened 7 years ago
Okay, to enable echo's output to reach the terminal, we can change pickone() to:
pickone() {
n=1
maxnum=$1
shift
choices=( $(echo $@) )
for v in ${choices[@]}; do
echo "${n}) $v" >&2;
n=$((n+1))
done
echo >&2
echo -n "Enter a selection (default=1): " >&2
read -r
# Parse answer
if [[ $REPLY ]]; then
for num in $REPLY; do
if [[ $num -le $maxnum ]] && [[ $num -ge 1 ]]; then
num=$((num-1))
chosenone="${choices[$num]}"
else
err "Number \`$num' is not assigned to any of the options."
fi
done
else
chosenone="$choices"
fi
echo "$chosenone"
}
i.e. just appending >&2
to those echo lines. However, after doing this, the "Enter a selection" prompt is shown twice, and I don't understand the code well enough to figure out how to stop that from happening. Here's a full run of apacman -S get_iplayer
after having made the above changes.
bash -x apacman -S get_iplayer
+ version=3.1
+ [[ -n '' ]]
+ PACMAN=pacman
+ pacmanbin=/usr/bin/pacman
+ makepkgconf=/etc/makepkg.conf
+ usermakepkgconf=/home/matt/.makepkg.conf
+ pacmanconf=/etc/pacman.conf
+ apacmanconf=/etc/apacman.conf
+ gpgconf=/etc/pacman.d/gnupg/gpg.conf
+ downdir=/var/cache/pacman/pkg
+ savedir=/var/cache/apacman/pkg
+ database=/var/lib/apacman
+ pacmandb=/var/lib/pacman/sync/aur.db
+ pkgfiledb=/var/cache/pkgfile/aur.files
+ localrepo=aur
+ builddir=/tmp/pkgbuild-1000
+ tmpdir=/tmp/apacmantmp-1000
+ testdir=/tmp/apacman-testing
+ editor=vi
+ [[ -n vim ]]
+ editor=vim
+ pager='less -R'
+ [[ -n /bin/vimpager ]]
+ pager=/bin/vimpager
+ RPCURL='https://aur.archlinux.org/rpc/?v=5&type'
+ PKGURL=https://aur.archlinux.org
+ WEBURL=https://www.archlinux.org
+ ABSURL=rsync.archlinux.org
+ legacy=0
+ [[ -t 1 ]]
+ [[ ! '' = \N\O ]]
+ COLOR1='\e[1;39m'
+ COLOR2='\e[1;32m'
+ COLOR3='\e[1;35m'
+ COLOR4='\e[1;36m'
+ COLOR5='\e[1;34m'
+ COLOR6='\e[1;33m'
+ COLOR7='\e[1;31m'
+ ENDCOLOR='\e[0m'
+ S='\\'
++ stty size
++ cut -d ' ' -f 2
+ _WIDTH=166
+ trap ctrlc INT
+ export gpgconf
+ export -f checkpgpkeys
+ export -f askpgpkeys
+ export -f addpgpkeys
+ export -f removepgpkeys
+ export -f proceed
+ loadconfig -S get_iplayer
+ for flag in $@
+ [[ '' = 1 ]]
+ [[ -S = \-\-\c\o\n\f\i\g ]]
+ [[ -S = --config* ]]
+ for flag in $@
+ [[ '' = 1 ]]
+ [[ get_iplayer = \-\-\c\o\n\f\i\g ]]
+ [[ get_iplayer = --config* ]]
+ sourceapacmanconf
+ [[ -r /etc/apacman.conf ]]
+ . /etc/apacman.conf
++ progress=1
++ editor=vim
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ export keepkeys noconfirm COLOR1 COLOR2 COLOR3 COLOR4 COLOR5 COLOR6 COLOR7 ENDCOLOR
+ [[ -n -S ]]
+ packageargs=()
+ [[ -n -S ]]
+ case "$1" in
+ option=install
+ shift
+ [[ -n get_iplayer ]]
+ case "$1" in
+ packageargs+=("$1")
+ shift
+ [[ -n '' ]]
+ rm -rf /tmp/apacmantmp-1000
+ mkdir -p /tmp/apacmantmp-1000
+ olddir=/home/matt
+ cd
++ grep '^CARCH=' /etc/makepkg.conf
++ sed 's/^="//'
++ grep -o -e '=.*[0-9A-Za-z]'
+ makearch=x86_64
+ [[ '' == 1 ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ install = list ]]
+ [[ '' = 1 ]]
+ [[ -n '' ]]
+ [[ -n install ]]
+ [[ '' != 1 ]]
+ [[ -z get_iplayer ]]
+ [[ -n '' ]]
+ [[ install = install ]]
+ for pkg in ${packageargs[@]}
++ echo get_iplayer
++ tr -dc '0-9a-z-.\n'
+ regexmatch=getiplayer
+ [[ get_iplayer =~ ^/ ]]
+ [[ '' = 1 ]]
+ [[ get_iplayer != \g\e\t\i\p\l\a\y\e\r ]]
+ regex=1
+ echo -e '\e[1;33mnotice:\e[0m enabling regex mode (get_iplayer)'
notice: enabling regex mode (get_iplayer)
+ installhandling get_iplayer
+ packageargs=("$@")
+ getignoredpackages
+ IFS=,
+ read -ra ignoredpackages
+ ignoredpackages+=($(grep '^ *IgnorePkg' "$pacmanconf" | cut -d '=' -f 2-))
++ grep '^ *IgnorePkg' /etc/pacman.conf
++ cut -d = -f 2-
+ sourcemakepkgconf
+ . /etc/makepkg.conf
++ export CC=clang
++ CC=clang
++ export CXX=clang++
++ CXX=clang++
++ 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-unknown-linux-gnu
++ CPPFLAGS=-D_FORTIFY_SOURCE=2
++ CFLAGS='-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2'
++ CXXFLAGS='-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2'
++ LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro
++ MAKEFLAGS=-j4
++ 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)
++ PACKAGER='Matt Mascarenhas <miblodelcarpio@gmail.com>'
++ 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/matt/.makepkg.conf ]]
+ for package in "${packageargs[@]}"
+ [[ -n '' ]]
+ existsinpacman get_iplayer
+ chosenpkg=get_iplayer
+ [[ 1 = 1 ]]
++ selectprovider
++ virtpkg=
++ shift
++ virtual=($@)
++ virtnum=0
++ [[ 0 -eq 0 ]]
++ return 1
+ chosenpkg=
+ /usr/bin/pacman -Si -- ''
+ [[ -n '' ]]
+ existsinpacmangroup get_iplayer
++ /usr/bin/pacman -Sgq get_iplayer
+ [[ -n '' ]]
+ [[ -n '' ]]
+ providedinpacman get_iplayer
+ unset providepkg
+ IFS='
'
+ read -rd '' -a providepkg
++ /usr/bin/pacman -Ssq -- '^get_iplayer$'
+ selectprovider get_iplayer
+ virtpkg=get_iplayer
+ shift
+ virtual=($@)
+ virtnum=0
+ [[ 0 -eq 0 ]]
+ return 1
+ [[ -n '' ]]
+ [[ -n '' ]]
+ existsinaur get_iplayer package
++ echo get_iplayer
++ awk -F == '{print $1}'
++ sed 's/\~$//'
+ chosenpkg=get_iplayer
+ val=get_iplayer
++ echo get_iplayer
++ tr -dc '0-9a-z-.\n'
+ regexmatch=getiplayer
+ [[ get_iplayer != getiplayer ]]
++ aurpkglist get_iplayer
++ [[ -f /tmp/apacmantmp-1000/packages.lst ]]
++ curl -Lfs https://aur.archlinux.org/packages.gz
++ gunzip
++ grep -E get_iplayer /tmp/apacmantmp-1000/packages.lst
++ sort
+ matches='get_iplayer
get_iplayer-git'
+ selectprovider get_iplayer get_iplayer get_iplayer-git
+ virtpkg=get_iplayer
+ shift
+ virtual=($@)
+ virtnum=2
+ [[ 2 -eq 0 ]]
+ [[ 2 -eq 1 ]]
+ [[ 2 -gt 1 ]]
+ provmsg=provide
+ [[ 1 = 1 ]]
+ provmsg=match
+ unset regex
+ echo -e '\e[1;34m:: \e[1;39mThere are 2 packages that match get_iplayer:\e[0m'
:: There are 2 packages that match get_iplayer:
++ pickone 2 get_iplayer get_iplayer-git
++ n=1
++ maxnum=2
++ shift
++ choices=($(echo $@))
+++ echo get_iplayer get_iplayer-git
++ for v in ${choices[@]}
++ echo '1) get_iplayer'
1) get_iplayer
++ n=2
++ for v in ${choices[@]}
++ echo '2) get_iplayer-git'
2) get_iplayer-git
++ n=3
++ echo
++ echo -n 'Enter a selection (default=1): '
Enter a selection (default=1): ++ read -r
1
++ [[ -n 1 ]]
++ for num in $REPLY
++ [[ 1 -le 2 ]]
++ [[ 1 -ge 1 ]]
++ num=0
++ chosenone=get_iplayer
++ echo get_iplayer
+ providepkg=get_iplayer
+ [[ -n get_iplayer ]]
+ eval 'package="get_iplayer"'
+ chosenpkg=get_iplayer
+ rpcinfo get_iplayer
+ [[ -f /tmp/apacmantmp-1000/get_iplayer.info ]]
+ curl -LfGs --data-urlencode arg=get_iplayer 'https://aur.archlinux.org/rpc/?v=5&type=info'
++ jshon -Qe resultcount -u
+ [[ 1 != \0 ]]
+ finddeps get_iplayer
+ pacmandeps=()
+ aurdeps=()
+ scrapeaurdeps get_iplayer
+ pkginfo get_iplayer ''
+ [[ -f /tmp/apacmantmp-1000/get_iplayer.PKGBUILD ]]
++ pkglink get_iplayer
++ rpcinfo get_iplayer
++ [[ -f /tmp/apacmantmp-1000/get_iplayer.info ]]
+++ jshon -Q -e results -a -e URLPath -u
++ aurpkgpath=/cgit/aur.git/snapshot/get_iplayer.tar.gz
++ [[ -n /cgit/aur.git/snapshot/get_iplayer.tar.gz ]]
++ echo https://aur.archlinux.org/cgit/aur.git/snapshot/get_iplayer.tar.gz
+ pkgpath=https://aur.archlinux.org/cgit/aur.git/snapshot/get_iplayer.tar.gz
++ echo get_iplayer.tar.gz
++ sed 's/\.tar\.gz$//'
+ basepath=get_iplayer
+ [[ -n get_iplayer ]]
+ [[ 0 == 1 ]]
+ curl -Lfs 'https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=get_iplayer'
+ cstatus=0
+ curlyq 0 get_iplayer
+ '[' 0 -eq 6 ']'
+ '[' 0 -ne 0 -a 0 -ne 7 -a 0 -ne 22 ']'
+ [[ -n '' ]]
+ parser /tmp/apacmantmp-1000/get_iplayer.PKGBUILD
+ '[' -f /tmp/apacmantmp-1000/get_iplayer.PKGBUILD ']'
+ [[ '' == 1 ]]
+ . /tmp/apacmantmp-1000/get_iplayer.PKGBUILD
++ pkgname=get_iplayer
++ pkgver=2.97
++ pkgrel=1
++ pkgdesc='Allows you to download or stream any iPlayer programme from the BBC in H.264 (Quicktime/mp4) format, any radio programmes in MP3 or RealAudio format'
++ arch=('any')
++ url=http://www.infradead.org/get_iplayer/html/get_iplayer.html
++ license=('GPL3')
++ depends=('perl-libwww' 'perl-html-parser' 'perl-www-mechanize' 'perl-http-cookies' 'perl-net-http' 'perl-xml-simple')
++ optdepends=('rtmpdump: record high-quality flash-based content' 'flvstreamer: download files that are in flash (flv) format' 'ffmpeg: convert flash (flv) files' 'atomicparsley: add tags to MP4 files' 'id3v2: add basic tags to MP3 files (if perl-mp3-tag not installed)' 'perl-mp3-tag: add tags to MP3 files' 'perl-xml-libxml: backup parser for BBC feeds')
++ source=(https://github.com/get-iplayer/get_iplayer/archive/v${pkgver}.tar.gz)
++ md5sums=('783f5b692e23f5721b2ab2c8eec757ef')
+ [[ '' = 1 ]]
+ IFS='
'
+ dependencies=($(echo -e "${depends[*]}\n${makedepends[*]}\n${checkdepends[*]}" | sed -e 's/=.*//' -e 's/>.*//' -e 's/<.*//'| sort -u))
++ echo -e 'perl-libwww
perl-html-parser
perl-www-mechanize
perl-http-cookies
perl-net-http
perl-xml-simple\n\n'
++ sed -e 's/=.*//' -e 's/>.*//' -e 's/<.*//'
++ sort -u
+ purgedepends=($(echo -e "${makedepends[*]}\n${checkdepends[*]}" | sed -e 's/=.*//' -e 's/>.*//' -e 's/<.*//'| sort -u))
++ echo -e '\n'
++ sort -u
++ sed -e 's/=.*//' -e 's/>.*//' -e 's/<.*//'
+ unset IFS
+ [[ '' = 1 ]]
+ [[ '' = 1 ]]
+ missingdeps=($($pacmanbin -T "${dependencies[@]}"))
++ /usr/bin/pacman -T perl-html-parser perl-http-cookies perl-libwww perl-net-http perl-www-mechanize perl-xml-simple
+ [[ -n '' ]]
+ return 0
+ aurpackages+=("$package")
+ aurdepends=("${aurdeps[@]}" "${aurdepends[@]}")
+ pacmandepends+=("${pacmandeps[@]}")
+ for package in "${aurpackages[@]}"
+ isignored get_iplayer
+ [[ nodejs =~ get_iplayer ]]
+ aurtargets+=("$package")
+ [[ -n '' ]]
+ [[ -z get_iplayer ]]
+ for pkg in "${aurtargets[@]}"
+ existsinlocal get_iplayer
+ /usr/bin/pacman -Qq -- get_iplayer
++ /usr/bin/pacman -Qs get_iplayer
++ grep -F 'local/get_iplayer '
++ cut -d ' ' -f 2
+ localversion=2.97-1
+ aurversionisnewer get_iplayer 2.97-1
+ package=get_iplayer
+ rpcinfo get_iplayer
+ [[ -f /tmp/apacmantmp-1000/get_iplayer.info ]]
+ unset aurversion
+ existsinaur get_iplayer package
++ echo get_iplayer
++ sed 's/\~$//'
++ awk -F == '{print $1}'
+ chosenpkg=get_iplayer
+ val=get_iplayer
++ echo get_iplayer
++ tr -dc '0-9a-z-.\n'
+ regexmatch=getiplayer
+ [[ get_iplayer != getiplayer ]]
++ aurpkglist get_iplayer
++ [[ -f /tmp/apacmantmp-1000/packages.lst ]]
++ grep -E get_iplayer /tmp/apacmantmp-1000/packages.lst
++ sort
+ matches='get_iplayer
get_iplayer-git'
+ selectprovider get_iplayer get_iplayer get_iplayer-git
+ virtpkg=get_iplayer
+ shift
+ virtual=($@)
+ virtnum=2
+ [[ 2 -eq 0 ]]
+ [[ 2 -eq 1 ]]
+ [[ 2 -gt 1 ]]
+ provmsg=provide
+ [[ '' = 1 ]]
+ echo -e '\e[1;34m:: \e[1;39mThere are 2 packages that provide get_iplayer:\e[0m'
:: There are 2 packages that provide get_iplayer:
++ pickone 2 get_iplayer get_iplayer-git
++ n=1
++ maxnum=2
++ shift
++ choices=($(echo $@))
+++ echo get_iplayer get_iplayer-git
++ for v in ${choices[@]}
++ echo '1) get_iplayer'
1) get_iplayer
++ n=2
++ for v in ${choices[@]}
++ echo '2) get_iplayer-git'
2) get_iplayer-git
++ n=3
++ echo
++ echo -n 'Enter a selection (default=1): '
Enter a selection (default=1): ++ read -r
1
++ [[ -n 1 ]]
++ for num in $REPLY
++ [[ 1 -le 2 ]]
++ [[ 1 -ge 1 ]]
++ num=0
++ chosenone=get_iplayer
++ echo get_iplayer
+ providepkg=get_iplayer
+ [[ -n get_iplayer ]]
+ eval 'package="get_iplayer"'
+ chosenpkg=get_iplayer
+ rpcinfo get_iplayer
+ [[ -f /tmp/apacmantmp-1000/get_iplayer.info ]]
++ jshon -Qe resultcount -u
+ [[ 1 != \0 ]]
++ jshon -Q -e results -a -e Version -u
+ aurversion=2.97-1
++ LC_ALL=C
++ vercmp 2.97-1 2.97-1
+ [[ 0 -gt 0 ]]
+ return 1
+ '[' '' = 1 ']'
+ echo -e '\e[1;33mwarning:\e[0m get_iplayer-2.97-1 is up to date -- reinstalling'
warning: get_iplayer-2.97-1 is up to date -- reinstalling
+ for pkg in "${aurtargets[@]}" "${aurdepends[@]}"
+ isoutofdate get_iplayer
+ rpcinfo get_iplayer
+ [[ -f /tmp/apacmantmp-1000/get_iplayer.info ]]
++ jshon -Q -e results -a -e OutOfDate -u
+ [[ null = \1 ]]
+ num=1
+ [[ 1 -eq 0 ]]
+ [[ -n '' ]]
+ echo
+ echo -e '\e[1;33mAur Targets (1):\e[0m get_iplayer'
Aur Targets (1): get_iplayer
+ [[ -n '' ]]
+ pkgnum=0
+ totalcount=1
+ remains=($(printf "%s\n" "${aurdepends[@]}" "${aurtargets[@]}" | sort -u))
++ printf '%s\n' get_iplayer
++ sort -u
+ '[' 1 = 0 ']'
+ [[ '' = 1 ]]
+ phrasing=installation
+ echo -en '\n\e[1;34m:: \e[1;39mProceed with installation? [Y/n]\e[0m '
:: Proceed with installation? [Y/n] + [[ -n '' ]]
+ proceed
+ read -n 1
n+ echo
+ case "$REPLY" in
+ return 1
+ exit
I think the issue was the regex support added in #63. As per #79, I'm just going to remove that feature, it causes too many problems.
The issue is I thought package names in AUR were restricted to [a-z]
, [0-9]
, -
but apparently not, +
, _
and more are in use.
I might consider shell wildcards in the future, IDK.
For the end-user, is there currently any workaround?
Cheers, @oshazard. Personally, I'm not sure I'd have a use for either regex or wildcards, preferring to install the minimum packages necessary (which is encouraged by having to pass them individually), but maybe it would be worth trying shell wildcards to satisfy #63.
@john3voltas, the hacked in changes to pickone()
(in /usr/bin/apacman
) from my previous comment seem to workaround the issue okay for now.
Try removing the (UPDATE: Not the correct solution. Check the ref) Reference https://github.com/oshazard/apacman/issues/88#issuecomment-284028206aurpkglist()
function if you're just upgrading.
Check https://github.com/oshazard/apacman/issues/79#issuecomment-284021260 for a dirty patch that resolves this for me (-S
works after patch).
Great work investigating this, @zamabe. I've lately been giving a different AUR helper a go, but hope you folks manage to figure out a clean fix for this issue.
I can understand why you might. Hope that works out for you! o/
Deleted my fork pull request #91 was based on. Posting the patch here because relevant issue.
Package matches fail to be
echo
'd when runningapacman -S
on a package name that contains an underscore and has alternative packages suffixed-*
in the AUR, e.g.get_iplayer (get_iplayer-git)
,acd_cli (acd_cli-git)
,check_mk (check_mk-agent check_mk-git)
.If I'm understanding the output correctly, the issue seems to be that the
echo
invocations near the end of the output (i.e. after thepickone()
call) happen more than one / zero levels deep, thus their output never makes it to the terminal. I've tried to unwind that call stack a level, but just couldn't figure out how to do it, assuming that is the problem at all!