Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 141747 - improper handling of comments in /etc/portage/package.*
Summary: improper handling of comments in /etc/portage/package.*
Status: RESOLVED INVALID
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Configuration (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
: 159515 192690 270538 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-25 19:38 UTC by Zack Elan
Modified: 2009-05-20 15:01 UTC (History)
3 users (show)

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 Zack Elan 2006-07-25 19:38:21 UTC
Portage doesn't like comments on the same line as depend atoms in package.keywords, if the keyword for that atom (such as ~x86) is omitted.

Steps to reproduce (all of these should give the same version available):

cd /etc/portage
mv package.keywords package.keywords.old

echo -e "sys-devel/gcc ~x86 #" > package.keywords
emerge -s %^gcc$
# Latest version available: 4.1.1

echo -e "sys-devel/gcc\t" > package.keywords
emerge -s %^gcc$
# Latest version available: 4.1.1

echo -e "sys-devel/gcc\t#" > package.keywords
emerge -s %^gcc$
# Latest version available: 3.4.6-r1

echo -e "sys-devel/gcc " > package.keywords
emerge -s %^gcc$
# Latest version available: 4.1.1

echo -e "sys-devel/gcc #" > package.keywords
emerge -s %^gcc$
# Latest version available: 3.4.6-r1

mv package.keywords.old package.keywords


~ # emerge --info 
Portage 2.1.1_pre3-r4 (default-linux/x86/2005.1, gcc-4.1.0, glibc-2.3.6-r4, 2.6.16-gentoo-r13 i686)
=================================================================
System uname: 2.6.16-gentoo-r13 i686 AMD Athlon(tm) XP 2800+
Gentoo Base System version 1.6.15
ccache version 2.3 [enabled]
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.3
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE=""
ARCH="x86"
AUTOCLEAN="yes"
BROWSER="/usr/bin/firefox"
CBUILD="i686-pc-linux-gnu"
CCACHE_DIR="/var/tmp/ccache"
CCACHE_SIZE="5G"
CFLAGS="-march=athlon-xp -Os -pipe -fomit-frame-pointer -m3dnow -msse -mmmx"
CHOST="i686-pc-linux-gnu"
CLASSPATH="."
CLEAN_DELAY="5"
CONFCACHE_DIR="/var/cache/confcache"
CONFIG_PROTECT="/etc /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CVS_RSH="ssh"
CXXFLAGS="-march=athlon-xp -Os -pipe -fomit-frame-pointer -m3dnow -msse -mmmx"
DISPLAY=":0.0"
DISTDIR="/usr/portage/distfiles"
EDITOR="/bin/nano"
ELIBC="glibc"
EMERGE_DEFAULT_OPTS="--verbose"
EMERGE_WARNING_DELAY="10"
FEATURES="autoconfig ccache distlocks metadata-transfer notitles parallel-fetch sandbox sfperms strict"
FETCHCOMMAND="/usr/bin/wget -t 5 -T 60 --passive-ftp -P ${DISTDIR} ${URI}"
GCC_SPECS=""
GDK_USE_XFT="1"
GENTOO_MIRRORS="http://gentoo.mirrors.easynews.com/linux/gentoo/ http://gentoo.arcticnetwork.ca/ http://mirror.mcs.anl.gov/pub/gentoo/ http://gentoo.llarian.net/ http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/"
G_BROKEN_FILENAMES="1"
G_FILENAME_ENCODING="UTF-8"
HOME="/root"
HOSTNAME="gentoo"
INFOPATH="/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.1.0/info"
INPUT_DEVICES="keyboard mouse joystick"
JAVAC="/opt/blackdown-jdk-1.4.2.03/bin/javac"
JAVA_HOME="/opt/blackdown-jdk-1.4.2.03"
JDK_HOME="/opt/blackdown-jdk-1.4.2.03"
KDEDIRS="/usr"
KERNEL="linux"
LADSPA_PATH="/usr/lib/ladspa"
LESS="-R -M --shift 5"
LESSOPEN="|lesspipe.sh %s"
LINGUAS="en"
LOGNAME="root"
LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.qt=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.flac=01;35:*.mp3=01;35:*.mpc=00;36:*.ogg=00;36:*.wav=00;36:*.mid=00;36:*.midi=00;36:*.au=00;36:*.flac=00;36:*.aac=00;36:"
MAKEOPTS="-j2"
MANPATH="/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.1.0/man::/opt/blackdown-jdk-1.4.2.03/man:/usr/qt/3/doc/man"
OLDPWD="/root"
OPENGL_PROFILE="xorg-x11"
PAGER="/usr/bin/less"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.0:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin:/usr/kde/3.4/sbin:/usr/kde/3.4/bin"
PKGDIR="/usr/portage/packages"
PORTAGE_ARCHLIST="ppc s390 amd64 ppc64 x86-fbsd m68k arm sparc sh mips ia64 alpha ppc-macos hppa x86"
PORTAGE_BINHOST_CHUNKSIZE="3000"
PORTAGE_BIN_PATH="/usr/lib/portage/bin"
PORTAGE_CALLER="emerge"
PORTAGE_CONFIGROOT="/"
PORTAGE_DEBUG="0"
PORTAGE_ELOG_CLASSES="warn error log"
PORTAGE_ELOG_MAILFROM="portage"
PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}"
PORTAGE_ELOG_MAILURI="root"
PORTAGE_ELOG_SYSTEM="save"
PORTAGE_GID="250"
PORTAGE_INST_GID="0"
PORTAGE_INST_UID="0"
PORTAGE_NICENESS="3"
PORTAGE_PYM_PATH="/usr/lib/portage/pym"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_RSYNC_RETRIES="3"
PORTAGE_TMPDIR="/var/tmp"
PORTAGE_WORKDIR_MODE="0700"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
PORT_LOGDIR="/var/log/portage"
PRELINK_PATH=""
PRELINK_PATH_MASK="/lib/modules:/usr/lib/locale:/usr/lib/wine:/usr/lib/valgrind:*.la:*.png:*.py:*.pl:*.pm:*.sh:*.xml:*.xslt:*.a:*.js"
PWD="/etc/portage"
PYTHONPATH="/usr/lib/portage/pym"
QMAKESPEC="linux-g++"
QTDIR="/usr/qt/3"
RESUMECOMMAND="/usr/bin/wget -c -t 5 -T 60 --passive-ftp -P ${DISTDIR} ${URI}"
ROOT="/"
RPMDIR="/usr/portage/rpm"
SHELL="/bin/bash"
SHLVL="1"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
TERM="rxvt"
USE="x86 3dnow X aac aalib alsa apache apache2 avi bash-completion bitmap-fonts bzip2 cdr cli crypt cups dlloader dri dvd dvdr dvdread encode fbcon ffmpeg flac foomaticdb fortran gif gimpprint glut gmp gpm gtk gtk2 imagemagick imlib isdnlog java joystick jpeg libcaca libg++ libwww mad matroska mikmod mmx mmxext mozilla mp3 mpeg mplayer ncurses nptl nptlonly nsplugin offensive ogg oggvorbis opengl pam pcre pdflib perl pic png ppds pppd python quicktime readline real reflection samba sdl session spell spl sqlite sse ssl tcltk tcpd theora tiff truetype truetype-fonts type1-fonts usb vorbis win32codecs xml2 xmms xorg xv xvid zlib elibc_glibc input_devices_keyboard input_devices_mouse input_devices_joystick kernel_linux linguas_en userland_GNU video_cards_vga video_cards_vesa video_cards_radeon"
USER="root"
USERLAND="GNU"
USE_EXPAND="DVB_CARDS ELIBC FCDSL_CARDS FRITZCAPI_CARDS INPUT_DEVICES KERNEL LINGUAS LIRC_DEVICES USERLAND VIDEO_CARDS"
USE_EXPAND_HIDDEN="ELIBC KERNEL USERLAND"
USE_ORDER="env:pkg:conf:defaults"
VIDEO_CARDS="vga vesa radeon"
XARGS="xargs -r"
XAUTHORITY="/root/.xauth65C3YQ"
_="/usr/bin/emerge"
Comment 1 Andrew Gaffney (RETIRED) gentoo-dev 2006-07-25 19:44:21 UTC
Improper by what standards? The current code only allows for comments starting on the first character of a line. As far as I know, there's nothing that says otherwise.
Comment 2 Zack Elan 2006-07-25 20:11:54 UTC
I think it's improper by the standard of almost every other comment syntax in existence, including that of bash and python - the foundation of portage - which both allow line comments on lines with uncommented text as well.

package.* files having a different standard, particularly if that standard is not documented (man portage just says "comments begin with #, one DEPEND atom per line followed by additional KEYWORDS, lines without any KEYWORDS imply unstable host arch")

If the code really allowed comments only at the start of a line, then "sys-devel/gcc ~x86 #somecomment" would be invalid syntax as well, but portage is happy with that - see the first test case I posted.

This is even handled inconsistently across the various package.* files. I added "=sys-devel/gcc-4.1.1 #test" to package.mask and 'emerge -s %^gcc$' spits out an "--- Invalid atom in /etc/portage/package.mask: =sys-devel/gcc-4.1.1 #test" error. However, none of the test cases above give any errors, even with invalid atoms.
Comment 3 Jason Stubbs (RETIRED) gentoo-dev 2006-07-26 04:36:30 UTC
(In reply to comment #0)
> Portage doesn't like comments on the same line as depend atoms in
> package.keywords, if the keyword for that atom (such as ~x86) is omitted.

As already stated, this is the case for all package.* files.

> echo -e "sys-devel/gcc ~x86 #" > package.keywords

Unmask sys-devel/gcc versions with keywords '~x86' or '#'

> echo -e "sys-devel/gcc\t" > package.keywords

Unmask sys-devel/gcc versions with keyword ~${ARCH}

> echo -e "sys-devel/gcc\t#" > package.keywords

Unmask sys-devel/gcc versions with keyword '#'

> echo -e "sys-devel/gcc " > package.keywords
> echo -e "sys-devel/gcc #" > package.keywords

Both the same as the \t versions as whitespace is stripped and simplified before parsing.
Comment 4 Jason Stubbs (RETIRED) gentoo-dev 2006-07-26 04:44:11 UTC
(In reply to comment #2)
> If the code really allowed comments only at the start of a line, then
> "sys-devel/gcc ~x86 #somecomment" would be invalid syntax as well, but portage
> is happy with that - see the first test case I posted.

As per the docs and my explanation, one atom followed by a number of keywords.

> I added
> "=sys-devel/gcc-4.1.1 #test" to package.mask and 'emerge -s %^gcc$' spits out
> an "--- Invalid atom in /etc/portage/package.mask: =sys-devel/gcc-4.1.1 #test"
> error.

One atom per line...

I don't really care whether end-of-line comments are implemented either way, but the current comment handling is definitely consistent already. It just wasn't doing what you thought it was.
Comment 5 Marius Mauch (RETIRED) gentoo-dev 2006-07-27 11:19:57 UTC
As Jason explained this is expected behavior. Don't see the benefit of extending the format to allow EOL comments, this would prevent us from ever using # in use flags or atoms (not that I think we will use them, but I'd like to have the option).
Comment 6 Zac Medico gentoo-dev 2007-09-16 17:55:14 UTC
*** Bug 192690 has been marked as a duplicate of this bug. ***
Comment 7 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-05-20 14:59:42 UTC
*** Bug 270538 has been marked as a duplicate of this bug. ***
Comment 8 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-05-20 15:01:42 UTC
*** Bug 159515 has been marked as a duplicate of this bug. ***