When you say no to the prompt in emerge --ask --depclean, the exit status is 1. This is bad because I use a script to run several update commands that aborts when a command fails. I can work around this if a different exit code is used, but right now I have to ignore the exit status for depclean entirely. If there is actually a problem with depclean, I may miss it unless I watch the script very closely. Reproducible: Always Steps to Reproduce: 1. run emerge --ask --depclean with at least one package that will be cleaned present 2. When prompted, say no 3. Check the exit status (echo $?) Actual Results: 1 (generic failure) Expected Results: 0 (success) # emerge --info portage Portage 2.1.10.49 (default/linux/amd64/10.0/desktop/kde, gcc-4.5.3, glibc-2.13-r4, 3.2.9-desktop-fglrx-vanilla x86_64) ================================================================= System Settings ================================================================= System uname: Linux-3.2.9-desktop-fglrx-vanilla-x86_64-AMD_FX-tm-6100_Six-Core_Processor-with-gentoo-2.0.3 Timestamp of tree: Sat, 24 Mar 2012 20:30:01 +0000 app-shells/bash: 4.2_p20 dev-java/java-config: 2.1.11-r3 dev-lang/python: 2.7.2-r3, 3.2.2 dev-util/cmake: 2.8.6-r4 dev-util/pkgconfig: 0.26 sys-apps/baselayout: 2.0.3 sys-apps/openrc: 0.9.8.4 sys-apps/sandbox: 2.5 sys-devel/autoconf: 2.13, 2.68 sys-devel/automake: 1.9.6-r3, 1.11.1 sys-devel/binutils: 2.21.1-r1 sys-devel/gcc: 4.5.3-r2 sys-devel/gcc-config: 1.5-r2 sys-devel/libtool: 2.4-r1 sys-devel/make: 3.82-r1 sys-kernel/linux-headers: 3.1 (virtual/os-headers) sys-libs/glibc: 2.13-r4 Repositories: gentoo ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O2 -pipe -ggdb" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/hddtemp/hddtemp.db" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-march=native -O2 -pipe -ggdb" DISTDIR="/usr/portage/distfiles" EMERGE_DEFAULT_OPTS="--jobs --load-average=9" FEATURES="assume-digests binpkg-logs collision-protect distlocks fixlafiles multilib-strict news parallel-fetch parallel-install protect-owned sandbox sfperms split-log splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch usersandbox usersync xattr" FFLAGS="" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_US.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" LINGUAS="en_US en" MAKEOPTS="--jobs=12 --load-average=9" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_EXTRA_OPTS="--exclude=/lost+found" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" USE="3dnow X a52 aac acl acpi aim alsa amd64 bash-completion berkdb bluetooth branding btrfs bzip2 cairo caps cjk cli consolekit cracklib crypt cscope css cups curl cxx dbus declarative dga dri dts dvd dvdr emboss encode exif fam ffmpeg fftw firefox flac fontconfig fontforge fortran gd gdbm gdu gif git gpm gsm gtk gtk3 handbook hddtemp iconv icu idn imagemagick inotify ipv6 jabber jpeg jpeg2k kde kipi lame latex lcms libnotify libsamplerate lm_sensors lua lzma lzo mad matroska mikmod mmap mmx mng modules mp3 mp4 mpeg mpi mplayer msn mudflap multilib musicbrainz ncurses network-cron nls nptl nptlonly nsplugin ntfs ogg openal opencl opengl openmp openvg pam pango pch pcre pdf phonon pic plasma png policykit portaudio ppds pppd qt3support qt4 readline sdl session smp speex spell sse sse2 sse3 ssl ssse3 startup-notification subversion svg symlink sysfs tcpd theora threads tiff tk truetype udev unicode usb vaapi video vim-syntax vnc vorbis vpx x264 xattr xcb xcomposite xinerama xml xorg xscreensaver xulrunner xv xvid yahoo zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="caps lvm" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_US en" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev fglrx radeon vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS ================================================================= Package Settings ================================================================= sys-apps/portage-2.1.10.49 was built with the following: USE="(consolekit) (ipc) (multilib) (policykit) xattr -build -doc -epydoc (-pypy1_8) -python2 -python3 (-selinux)" LINGUAS="-pl" #
(In reply to comment #0) > If there is actually a problem with depclean, I may miss it > unless I watch the script very closely. You could run it once with --pretend, and then have your script prompt the user. Alternatively, you could intercept the user's y/n answer and feed it to emerge (though you'd have to use a pty since --ask only works with a tty device).
(In reply to comment #1) > (In reply to comment #0) > > If there is actually a problem with depclean, I may miss it > > unless I watch the script very closely. > > You could run it once with --pretend, and then have your script prompt the > user. Alternatively, you could intercept the user's y/n answer and feed it > to emerge (though you'd have to use a pty since --ask only works with a tty > device). I prefer not running the depclean dependency calculations twice, but it is an option. From the other bug, it looks like 0 or 1 were the only options considered. Can we return 2 or some higher value instead if the user cancels (in both cases)? I can see the argument for not returning 0, but it seems odd to have an intentional abort look the same as an error.
Since a 'no' answer is roughly equivalent to interruption by SIGINT, we could return 130 = 128 + signal.SIGINT.
(In reply to comment #3) > Since a 'no' answer is roughly equivalent to interruption by SIGINT, we > could return 130 = 128 + signal.SIGINT. Sounds good to me.
This is fixed in git: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ac13a18708d6223accb85d12ba895bc121df89c6
(In reply to comment #5) > This is fixed in git: > > http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit; > h=ac13a18708d6223accb85d12ba895bc121df89c6 I see 130 when saying no in a normal emerge --ask, but not when running emerge --ask --depclean: # emerge --ask --depclean * Always study the list of packages to be cleaned for any obvious * mistakes. Packages that are part of the world set will always * be kept. They can be manually added to this set with * `emerge --noreplace <atom>`. Packages that are listed in * package.provided (see portage(5)) will be removed by * depclean, even if they are part of the world set. * * As a safety measure, depclean will not remove any packages * unless *all* required dependencies have been resolved. As a * consequence, it is often necessary to run `emerge --update * --newuse --deep @world` prior to depclean. Calculating dependencies... done! >>> Calculating removal order... >>> These are the packages that would be unmerged: sys-kernel/vanilla-sources selected: 3.2.9 protected: none omitted: none All selected packages: sys-kernel/vanilla-sources-3.2.9 >>> 'Selected' packages are slated for removal. >>> 'Protected' and 'omitted' packages will not be removed. Would you like to unmerge these packages? [Yes/No] no Quitting. Packages installed: 1108 Packages in world: 152 Packages in system: 42 Required packages: 1104 Number to remove: 4 # echo $? 1 # emerge --ask portage These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild UD ] sys-apps/portage-2.1.10.49 [9999] LINGUAS="-pl%" Would you like to merge these packages? [Yes/No] no Quitting. # echo $? 130 # It looks like the culprit may be in unmerge.py, line 538: 530 if "--ask" in myopts: 531 if userquery("Would you like to unmerge these packages?", 532 enter_invalid) == "No": 533 # enter pretend mode for correct formatting of results 534 myopts["--pretend"] = True 535 print() 536 print("Quitting.") 537 print() 538 return 0 It could be in the caller of that code, as well, but I don't know the portage code well enough to track that down quickly.
Ok, this should fix it for unmerge actions, including --depclean: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=774f387710bfcd14ffb270375bce3b310c2609ee
(In reply to comment #7) > Ok, this should fix it for unmerge actions, including --depclean: > > http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit; > h=774f387710bfcd14ffb270375bce3b310c2609ee That commit was buggy. Use this instead: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4e2abb474f0fc624c51948f0939e3123f6382992
(In reply to comment #8) > (In reply to comment #7) > > Ok, this should fix it for unmerge actions, including --depclean: > > > > http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit; > > h=774f387710bfcd14ffb270375bce3b310c2609ee > > That commit was buggy. Use this instead: > > http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit; > h=4e2abb474f0fc624c51948f0939e3123f6382992 Looks good. Thanks!
This is fixed in 2.1.10.52 and 2.2.0_alpha96.
This breaks scripts running emerge in a loop, for example to have a file containing a list of packages to rebuild one-by-one. If I answer "no", I want to skip to the next package. If I hit ^C, I want to quit. I have no way of differentiating between these two now. Can we use a different error code?
(In reply to comment #11) > This breaks scripts running emerge in a loop, for example to have a file > containing a list of packages to rebuild one-by-one. If I answer "no", I > want to skip to the next package. If I hit ^C, I want to quit. I have no > way of differentiating between these two now. Can we use a different error > code? Can't your script use a sigint trap if it wants to exit when ^C is pressed?
Yes. Thanks for the tip.