Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 394407 - app-admin/checkrestart does not work with python3
Summary: app-admin/checkrestart does not work with python3
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-12 03:48 UTC by David
Modified: 2011-12-15 17:26 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David 2011-12-12 03:48:38 UTC
'checkrestart' no longer works.

This is true even after doing 'emerge -ev checkrestart'

Perhaps this was caused by the move to OpenRC?

Reproducible: Always

Steps to Reproduce:
# checkrestart

Actual Results:  
  File "/usr/sbin/checkrestart", line 168
    print "Found %d processes using old versions of upgraded files" % len(toRestart)
                                                                  ^
SyntaxError: invalid syntax


Expected Results:  
Expecting it to output a list of programs that need to be restarted.

# emerge --info
Portage 2.1.10.11 (default/linux/x86/10.0, gcc-4.5.3, glibc-2.12.2-r0, 3.1.4-gentoo i686)
=================================================================
System uname: Linux-3.1.4-gentoo-i686-Mobile_Intel-R-_Pentium-R-_4_CPU_2.80GHz-with-gentoo-2.0.3
Timestamp of tree: Sat, 10 Dec 2011 07:15:01 +0000
app-shells/bash:          4.1_p9
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.2-r3, 3.1.4-r3
dev-util/cmake:           2.8.6-r4
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.9.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r1
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 2.6.39 (virtual/os-headers)
sys-libs/glibc:           2.12.2
Repositories: gentoo sunrise write2David desktop-effects
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="*"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
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"
CXXFLAGS="-O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps y"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles fixpackages news parallel-fetch parallel-install protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox webrsync-gpg"
FFLAGS=""
GENTOO_MIRRORS="ftp://chi-10g-1-mirror.fastsoft.net/pub/linux/gentoo/gentoo-distfiles/ http://chi-10g-1-mirror.fastsoft.net/pub/linux/gentoo/gentoo-distfiles/ http://mirror.mcs.anl.gov/pub/gentoo/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_US"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/sunrise /var/lib/layman/write2David /var/lib/layman/desktop-effects"
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="X acl acpi alsa berkdb bmp bzip2 cdr cli cracklib crypt cups cxx dbus dri dvd exif fortran gdbm gif gpm iconv ipv6 jpeg libnotify lm_sensors mmx modules mudflap ncurses nls nptl nptlonly openmp pam pcre png pppd raw readline session sse sse2 ssl svg sysfs tcpd thunar tiff unicode usb x86 xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 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" 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="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="vesa intel" XFCE_PLUGINS="trash menu brightness" 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, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 David 2011-12-12 03:49:29 UTC
Not sure if it matters:  my shell is zsh.
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-12 11:01:59 UTC
It works fine here. What's your system version of dev-lang/python?
Comment 3 David 2011-12-12 14:20:11 UTC
# eselect python list
Available Python interpreters:
  [1]   python2.7
  [2]   python3.1 *


Thanks for the tip.   Doing...

# eselect python set 1


...allows checkrestart to work.
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-12 20:57:55 UTC
print needs to be converted to print() and there are some other problems between 2.7 and 3 that probably cannot be implemented without breaking 2.7 support.

I bet python.eclass has the means to make this a python2.7 only executable, by way of setting the proper shebang, no doubt. I wonder if this will do:

--- checkrestart-0.47-r1.ebuild 12 Feb 2011 17:48:33 -0000      1.1
+++ checkrestart-0.47-r1.ebuild 12 Dec 2011 20:56:23 -0000
@@ -2,9 +2,10 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/app-admin/checkrestart/checkrestart-0.47-r1.ebuild,v 1.1 2011/02/12 17:48:33 jer Exp $
 
-EAPI="3"
+EAPI="4"
+PYTHON_DEPEND="2"
 
-inherit eutils
+inherit eutils python
 
 DESCRIPTION="the sysadmin's rolling upgrade tool"
 HOMEPAGE="http://arcdraco.net/checkrestart"
@@ -16,15 +17,19 @@
 IUSE=""
 
 RDEPEND="
+       ${DEPEND}
        sys-apps/lsb-release
        app-portage/portage-utils
        sys-process/lsof
-       "
+"
+
+S=${WORKDIR}
 
 src_prepare() {
        epatch "${FILESDIR}"/${P}-list-comprehension-fix.patch
+       python_convert_shebangs 2 ${PN}
 }
 
 src_install() {
-       dosbin ${PN} || die "dosbin failed"
+       dosbin ${PN}
 }

I had to add RDEPEND=DEPEND since I cannot set PYTHON_RDEPEND (I don't actually need dev-lang/python in DEPEND, just in RDEPEND) so there's probably some room for improvement.
Comment 5 Arfrever Frehtes Taifersar Arahesis 2011-12-12 21:53:03 UTC
(In reply to comment #4)

DEPEND, RDEPEND, PDEPEND, IUSE and REQUIRED_USE set in each eclass are independent and cannot be affected by ebuilds after inheriting of these eclasses.

PYTHON_DEPEND affects DEPEND and RDEPEND.
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-12 22:39:22 UTC
(In reply to comment #5)
> (In reply to comment #4)
> 
> DEPEND, RDEPEND, PDEPEND, IUSE and REQUIRED_USE set in each eclass are
> independent and cannot be affected by ebuilds after inheriting of these
> eclasses.

So setting PYTHON_DEPEND isn't actually needed in this case? I happen to only use python_convert_shebangs, it seems.

> PYTHON_DEPEND affects DEPEND and RDEPEND.

Yes, I noticed.
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-12 22:48:58 UTC
Never mind. I'll go for a solution that does not inherit python.eclass.
Comment 8 Arfrever Frehtes Taifersar Arahesis 2011-12-12 22:50:03 UTC
(In reply to comment #6)

/usr/sbin/checkrestart at run time will use /usr/bin/python2, so setting dependency on Python 2 is needed.
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-12 22:55:02 UTC
Fixed in -r2.
Comment 10 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-12 22:57:10 UTC
(In reply to comment #8)
> (In reply to comment #6)
> 
> /usr/sbin/checkrestart at run time will use /usr/bin/python2, so setting
> dependency on Python 2 is needed.

Yes, but I didn't need python.eclass for that... or anything as it turned out.
Comment 11 David 2011-12-14 05:37:45 UTC
(In reply to comment #9)
> Fixed in -r2.



Thanks for your work on this!

I have 0.47-r2 installed now.  Oddly, it took a couple resets of the system python before checkrestart would work with python3....


# eix checkrestart | grep Installed
     Installed versions:  0.47-r2{tbz2}(02:15:27 AM 12/13/2011)


# eselect python list
Available Python interpreters:
  [1]   python2.7 *
  [2]   python3.1


# eselect python set 2


# eselect python list
Available Python interpreters:
  [1]   python2.7
  [2]   python3.1 *


# checkrestart

[hangs indefinitely]

[Ctrl-C]


^CTraceback (most recent call last):
  File "/usr/sbin/checkrestart", line 495, in <module>
    main()
  File "/usr/sbin/checkrestart", line 160, in main
    toRestart = lsofcheck()
  File "/usr/sbin/checkrestart", line 269, in lsofcheck
    for line in os.popen('lsof +XL -F nf').readlines():
KeyboardInterrupt


[repeat a few times, in two different terminals = same result]


# eselect python list
Available Python interpreters:
  [1]   python2.7
  [2]   python3.1 *

# eselect python set 2

# checkrestart
Found 41 processes using old versions of upgraded files
(29 distinct programs)
(24 distinct packages)

Of these, 4 seem to contain init scripts which can be used to restart them:

[snip]


Works fine now.  Thanks!
Comment 12 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-14 15:29:07 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > Fixed in -r2.
> 
> 
> 
> Thanks for your work on this!
> 
> I have 0.47-r2 installed now.  Oddly, it took a couple resets of the system
> python before checkrestart would work with python3....

It doesn't work at all with python3 - it uses python2.
Comment 13 David 2011-12-15 00:45:56 UTC
(In reply to comment #12)
> It doesn't work at all with python3 - it uses python2.


Yes, I worded that poorly.  I should have said:

"Oddly, it took a couple resets of the system python before checkrestart would work with python3 set as the system version."
Comment 14 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-15 17:26:18 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > It doesn't work at all with python3 - it uses python2.
> 
> 
> Yes, I worded that poorly.  I should have said:
> 
> "Oddly, it took a couple resets of the system python before checkrestart would
> work with python3 set as the system version."

That would be an unrelated problem in eselect-python. checkrestart now uses python2 no matter what the system python is set to, so even a failed symlink change wouldn't affect it.