Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 377303 - webapp.eclass: webapp_serverowned should die if arguments start with ${D}
Summary: webapp.eclass: webapp_serverowned should die if arguments start with ${D}
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Web Application Packages Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-01 18:14 UTC by Martin Mokrejš
Modified: 2021-07-27 05:04 UTC (History)
1 user (show)

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


Attachments
GBrowse-2.39.ebuild (GBrowse-2.39.ebuild,5.04 KB, text/plain)
2011-08-02 01:37 UTC, Martin Mokrejš
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Mokrejš 2011-08-01 18:14:48 UTC
I am writing an ebuild using EAPI4 (GBrowse-2.39.ebuild) and when I do

dodir "${D}"/var/db/gbrowse2/sessions

it actually creates /var/tmp/portage/sci-biology/GBrowse-2.39/image//var/tmp/portage/sci-biology/GBrowse-2.39/image/var/db/gbrowse2/sessions/

Or is that an interference with 'inherit perl-module webapp'?

I think it is easy to check if the PATH to be created starts already with the DESTDIR string and adjust accordingly -- or at least raise an error.



I also see in one case under src_install() where I do

webapp_serverowned -R "${D}"/var/tmp/gbrowse2 "${D}"/var/db/gbrowse2

the following errors:

find: `/var/tmp/portage/sci-biology/GBrowse-2.39/image//var/tmp/portage/sci-biology/GBrowse-2.39/image//var/tmp/gbrowse2': No such file or directory
find: `/var/tmp/portage/sci-biology/GBrowse-2.39/image//var/tmp/portage/sci-biology/GBrowse-2.39/image//var/db/gbrowse2': No such file or directory

# emerge --info
Portage 2.1.10.7 (default/linux/x86/10.0/desktop, gcc-4.5.2, glibc-2.13-r4, 2.6.39.2 i686)
=================================================================
System uname: Linux-2.6.39.2-i686-Mobile_Intel-R-_Pentium-R-_4_-_M_CPU_1.80GHz-with-gentoo-2.0.3
Timestamp of tree: Sun, 31 Jul 2011 10:15:01 +0000
distcc 3.1 i686-pc-linux-gnu [disabled]
app-shells/bash:          4.2_p10
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.5.4-r4, 2.6.7-r2, 2.7.2-r2, 3.1.4-r2, 3.2-r2
dev-util/cmake:           2.8.5-r2
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.8.3-r1
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13::<unknown repository>, 2.68
sys-devel/automake:       1.4_p6-r1, 1.5-r1, 1.6.3-r1, 1.7.9-r2, 1.8.5-r4, 1.9.6-r3, 1.10.3, 1.11.1-r1
sys-devel/binutils:       2.21.1
sys-devel/gcc:            3.3.6-r1, 4.2.4-r1, 4.3.5, 4.4.5, 4.5.2
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.81-r2
sys-kernel/linux-headers: 2.6.38 (virtual/os-headers)
sys-libs/glibc:           2.13-r4
Repositories: gentoo x-portage science
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="* -@EULA dlj-1.1 sun-bcla-java-vm Nero-EULA-US skype-eula AdobeFlash AdobeFlash-10 AdobeFlash-10.1 PUEL"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium4m -mmmx -msse -msse2 -pipe -fno-strict-aliasing -ggdb"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa /var/bind /var/lib/hsqldb /var/vpopmail/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.2/ext-active/ /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.2/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.2/ext-active/ /etc/php/cli-php5.3/ext-active/ /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="-O2 -march=pentium4m -mmmx -msse -msse2 -pipe -fno-strict-aliasing -ggdb"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles fixpackages metadata-transfer news nostrip parallel-fetch protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://gentoo.mirror.web4u.cz"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en cs cz"
MAKEOPTS="-j4"
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="/usr/local/portage /home/mmokrejs/proj/sci"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="32bit 7zip R X Xaw3d a52 aac aalib ace acl acpi alsa amr amrnb amrwb apache apache2 apng audacious audiofile bash-completion bcmath berkdb blas bluetooth boost branding bzip2 cairo caps cblas cdda cddb cdparanoia cdr cgi clamav cli colordiff compress consolekit cpio cracklib crypt cscope css ctype cups curl curlwrappers cxx dbi dbus dga dhcp dia directfb djbfft dri dts dv dvb dvd dvdr dvdread emboss emf enblend encode enscript exif expat faad fam fame fat fbcon ffmpeg fftw firefox flac flash fontconfig fortran fpx ftp gcj gd gdbm gdu ggi gif gimp gimpprint glibc-compat20 glibc-omitfp glut gmp gnuplot gnutls gpgme gphoto2 gpm graphviz gs gsl gsm gtk gtkhtml hdf hdf5 hp2xx i8x0 iconv icu id3 id3tag ieee1394 imagemagick imlib inifile innodb ithreads jack java javascript jbig jce jikes jpeg jpeg2k kdtree kerberos ladspa lame lapack laptop largefile lcms leim libcaca libnotify libwww live lzo lzw mad maildir matroska mhash mikmod mime ming mjpeg mmap mmx mng mod_python modperl modplug modules motif mozilla moznoirc mp2 mp3 mp4 mpeg mplayer mudflap mule musepack mxdatetime mysql mysqli nat ncurses netcdf netpbm network nls nntp nptl nptlonly nsplugin ntfs numeric objc ogg opengl openmp openssl pam pango parport pcmcia pcntl pcre pdf perl php plotutils plugin png pnm policykit postproc postscript ppds pppd procmail pymol python qt3support qt4 quicktime rar raw readline recode reiserfs romio rpm samba sasl scanner scp sdl seamonkey server session sftp sift slp smime sndfile soap sockets spell sqlite srt sse sse2 ssl startup-notification static-libs subtitles subversion svg svgz sysfs sysvipc t1lib tcl tcpd theora threads tidy tiff tk transcode truetype udev unicode urandom usb userlocales utils uuencode v4l v4l2 vcd vhook vim-syntax vim-with-x vorbis wavpack wifi win32codecs wmf wxwindows x264 x86 xanim xcb xcf xfs xft xinerama xinetd xml xorg xpm xsl xslt xulrunner xv xvid xvmc yv12 zip zlib" ALSA_CARDS="intel-8x0m" 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 auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dbd deflate dir disk_cache env expires ext_filter file_cache filter headers icu ident imagemap include info log_config mem_cache mime mime_magic php rewrite setenvif speling status unique_id userdir usertrack vhost_alias negotiation" CALLIGRA_FEATURES="braindump flow karbon kexi kpresenter krita tables words" 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 cs cz" PHP_TARGETS="php-5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="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, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Zac Medico gentoo-dev 2011-08-02 00:14:19 UTC
I wonder if it dies for you or not, because we already have a post src_install check in bin/misc-functions.sh that's supposed detect this case and abort:

if [[ -d ${D}/${D} ]] ; then
	declare -i INSTALLTOD=0
	for i in $(find "${D}/${D}/"); do
		eqawarn "QA Notice: /${i##${D}/${D}} installed in \${D}/\${D}"
		((INSTALLTOD++))
	done
	die "Aborting due to QA concerns: ${INSTALLTOD} files installed in ${D}/${D}"
	unset INSTALLTOD
fi
Comment 2 Martin Mokrejš 2011-08-02 01:31:19 UTC
(In reply to comment #1)
> I wonder if it dies for you or not, because we already have a post src_install
> check in bin/misc-functions.sh that's supposed detect this case and abort:
> 
> if [[ -d ${D}/${D} ]] ; then
>     declare -i INSTALLTOD=0
>     for i in $(find "${D}/${D}/"); do
>         eqawarn "QA Notice: /${i##${D}/${D}} installed in \${D}/\${D}"
>         ((INSTALLTOD++))
>     done
>     die "Aborting due to QA concerns: ${INSTALLTOD} files installed in
> ${D}/${D}"
>     unset INSTALLTOD
> fi

Hmm. I saw few times this error when tuning the ebuild but it certainly does NOT detect all cases, that I am quite sure. Maybe the bug is elsewhere? I was asked not to insert "|| die ..." anymore because EAPI=4 does that automagically. I think it happened to me with these dodir() or some webapp*() functions which should have died but did not. Look into current sci-biology/GBrowse-2.39, one one the lines should fail but does not. I will attach my current ebuild which still has to call chown() manually ... maybe that leads you to the answer? ;)
Comment 3 Martin Mokrejš 2011-08-02 01:37:26 UTC
Created attachment 281791 [details]
GBrowse-2.39.ebuild

My "current" ebuild.
Comment 4 Martin Mokrejš 2011-08-02 01:43:28 UTC
(In reply to comment #2)

> Hmm. I saw few times this error when tuning the ebuild but it certainly does
> NOT detect all cases, that I am quite sure. Maybe the bug is elsewhere? I was
> asked not to insert "|| die ..." anymore because EAPI=4 does that
> automagically. I think it happened to me with these dodir() or some webapp*()

Yes, I used to have in there:

	dodir /var/tmp/gbrowse2 || die "dodir /var/tmp/gbrowse2 failed"

> functions which should have died but did not. Look into current
> sci-biology/GBrowse-2.39, one one the lines should fail but does not. I will

I mean the one in main tree, not the one attached here.

> attach my current ebuild which still has to call chown() manually ... maybe
> that leads you to the answer? ;)
Comment 5 Zac Medico gentoo-dev 2011-08-02 02:02:21 UTC
It's not supposed to die immediately after the dodir call. Portage is supposed to abort after src_install completes, using the code that I pasted in comment #1. The die should get triggered by a normal emerge invocation, by running `ebuild GBrowse-2.39.ebuild install`.
Comment 6 SpanKY gentoo-dev 2011-08-06 10:31:45 UTC
`dodir "${D}"...` is wrong
Comment 7 Martin Mokrejš 2011-08-08 21:16:05 UTC
(In reply to comment #6)
> `dodir "${D}"...` is wrong

Would you agree that 'repoman' can catch this at the very beginning at least? Do I have to compile the whole thing to realize that?
Comment 8 Zac Medico gentoo-dev 2011-08-08 21:55:57 UTC
A repoman check would be nice. It would have to check docinto, docompress, dodir, insinto, into, exeinto, fowners, and fperms. Also, dohard and dosed, which are deprecated in EAPI 4. Are there any others?
Comment 9 Zac Medico gentoo-dev 2011-08-08 21:59:55 UTC
In addition to ${D}, beginning with EAPI 3 we should also check for ${ED} and ${EPREFIX}.
Comment 10 SpanKY gentoo-dev 2011-08-09 01:48:46 UTC
i dont generally believe in python code parsing shell code and doing it sanely
Comment 11 Zac Medico gentoo-dev 2011-08-09 02:06:24 UTC
It seems that we already have this check, but it could be extended to include more of the helpers mentioned in comment #5:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8e1c57067c4556ee2c730f0722d344c52cf4888c
Comment 13 Martin Mokrejš 2011-08-09 07:39:46 UTC
But the issue I happened to face was with dodir() so I think this code is maybe not called for EAPI4? Or would you mind checking the webapp-config code path?
Comment 14 Zac Medico gentoo-dev 2011-08-09 07:52:51 UTC
(In reply to comment #13)
> But the issue I happened to face was with dodir() so I think this code is maybe
> not called for EAPI4?

This repoman check works for me with EAPI 4. Are you sure that you ran repoman and carefully reviewed the output?

> Or would you mind checking the webapp-config code path?

I'm not sure what you mean. Repoman doesn't execute any code, it just searches for patterns, so code paths should be irrelevant.
Comment 15 Martin Mokrejš 2011-08-09 08:18:00 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > But the issue I happened to face was with dodir() so I think this code is maybe
> > not called for EAPI4?
> 
> This repoman check works for me with EAPI 4. Are you sure that you ran repoman
> and carefully reviewed the output?

Well, not sure at which moment did that or had this very version of the ebuild. Will test later once the changes get released for test arches.

> 
> > Or would you mind checking the webapp-config code path?
> 
> I'm not sure what you mean. Repoman doesn't execute any code, it just searches
> for patterns, so code paths should be irrelevant.

The line in original report and its associated error
webapp_serverowned -R "${D}"/var/tmp/gbrowse2 "${D}"/var/db/gbrowse2
Comment 16 Zac Medico gentoo-dev 2011-08-09 08:26:47 UTC
(In reply to comment #15)
> The line in original report and its associated error
> webapp_serverowned -R "${D}"/var/tmp/gbrowse2 "${D}"/var/db/gbrowse2

That explains it. The repoman check doesn't work for webapp_serverowned since it's an eclass function, not a portage function. I'd prefer not to add check like this for eclass APIs. Other things, like paths installed to $D via Makefile internals, can't be checked until after src_install. I think that's acceptable, especially since an ebuild writer typically learns pretty quickly not to make this kind of mistake. It's just part of the learning curve.
Comment 17 Martin Mokrejš 2011-08-09 09:22:20 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > The line in original report and its associated error
> > webapp_serverowned -R "${D}"/var/tmp/gbrowse2 "${D}"/var/db/gbrowse2
> 
> That explains it. The repoman check doesn't work for webapp_serverowned since
> it's an eclass function, not a portage function. I'd prefer not to add check
> like this for eclass APIs. Other things, like paths installed to $D via
> Makefile internals, can't be checked until after src_install. I think that's

Why cannot repoman check for the leading "${D}" and report that?

> acceptable, especially since an ebuild writer typically learns pretty quickly
> not to make this kind of mistake. It's just part of the learning curve.

Took me several days and current maintainer had no time for years and sci herd is overloaded with complex package bundles. And bugzilla is full of requests involving webapp-config interaction. This is the difficult part, not running econf or sed to fix some Makefile.am files, etc.

Notably, I realized the error only because I directly tried to chmod some perms in "${D}" and chmod complained file does not exist. Took me while then to get the webapp_serverowned -related error to have something clear to be reported as an example. So what I mean is that silently I pushed via "ebuild ... qmerge" into the filesystem "${D}"/"${D}"/usr/.../whatever. Please try to do something in this regard.
Comment 18 Zac Medico gentoo-dev 2011-08-09 10:55:38 UTC
(In reply to comment #17)> 
> Why cannot repoman check for the leading "${D}" and report that?

A leading "${D}" maybe be appropriate for some APIs and not others.

> > acceptable, especially since an ebuild writer typically learns pretty quickly
> > not to make this kind of mistake. It's just part of the learning curve.
> 
> Took me several days and current maintainer had no time for years and sci herd
> is overloaded with complex package bundles. And bugzilla is full of requests
> involving webapp-config interaction. This is the difficult part, not running
> econf or sed to fix some Makefile.am files, etc.
> 
> Notably, I realized the error only because I directly tried to chmod some perms
> in "${D}" and chmod complained file does not exist. Took me while then to get
> the webapp_serverowned -related error to have something clear to be reported as
> an example. So what I mean is that silently I pushed via "ebuild ... qmerge"
> into the filesystem "${D}"/"${D}"/usr/.../whatever. Please try to do something
> in this regard.

I would suggest to modify the eclass function to check for this case and die if it is detected. Here's an example of what the beginning of the eclass function should look like:

  [[ ${1} == "${D}"* ]] && die "Arguments should not begin with \${D}: ${1}"
Comment 19 Martin Mokrejš 2011-08-09 11:36:05 UTC
(In reply to comment #18)
> I would suggest to modify the eclass function to check for this case and die if
> it is detected. Here's an example of what the beginning of the eclass function
> should look like:
> 
>   [[ ${1} == "${D}"* ]] && die "Arguments should not begin with \${D}: ${1}"

Yes, please. ;)
Comment 20 Zac Medico gentoo-dev 2011-08-09 12:39:21 UTC
(In reply to comment #19)
> (In reply to comment #18)
> > I would suggest to modify the eclass function to check for this case and die if
> > it is detected. Here's an example of what the beginning of the eclass function
> > should look like:
> > 
> >   [[ ${1} == "${D}"* ]] && die "Arguments should not begin with \${D}: ${1}"
> 
> Yes, please. ;)

Okay, reassigning to web-apps then.