Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 152886 - g-cpan does not follow "source" lines in /etc/make.conf
Summary: g-cpan does not follow "source" lines in /etc/make.conf
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Perl team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-26 08:58 UTC by Mark Glines
Modified: 2007-01-02 14:13 UTC (History)
0 users

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


Attachments
g-cpan-Gentoo-Config-follow-source-lines.diff (g-cpan-Gentoo-Config-follow-source-lines.diff,838 bytes, patch)
2006-10-26 09:00 UTC, Mark Glines
Details | Diff
g-cpan-Gentoo-Config-follow-source-lines.diff (g-cpan-Gentoo-Config-follow-source-lines.diff,844 bytes, patch)
2006-10-26 10:14 UTC, Mark Glines
Details | Diff
g-cpan-Gentoo-Config-follow-source-lines.diff (g-cpan-Gentoo-Config-follow-source-lines.diff,1.54 KB, patch)
2006-10-27 11:24 UTC, Mark Glines
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Glines 2006-10-26 08:58:41 UTC
I have a fairly complex portage overlay setup, and I find it useful (for syncing reasons) to put my overlay config in a separate file.  I use the shell "source" function to read that separate file into make.conf.  My setup is similar to the one shown in the "layman" documentation:

http://gentoo-wiki.com/Portage_Overlay_Listing#layman

g-cpan's Gentoo::Config module doesn't handle this properly.  I'll attach a patch to enable this.

Without the patch, running things like "g-cpan -p IO::All" result in the error message " * g-cpan: The option you have chosen isn't supported without a configured overlay."

With the patch, g-cpan works as expected.


Portage 2.1.2_pre3-r9 (hardened/x86/2.6, gcc-3.4.6, glibc-2.3.6-r5, 2.6.18-ck1 i686)
=================================================================
System uname: 2.6.18-ck1 i686 Intel(R) Pentium(R) M processor 1.70GHz
Gentoo Base System version 1.12.5
Last Sync: Thu, 26 Oct 2006 13:00:02 +0000
distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.3 [enabled]
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.0-r2, 2.0.30
dev-lang/python:     2.3.5-r3, 2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.3
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -O2 -pipe"
CHOST="i686-pc-linux-gnu"
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/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-march=pentium3 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig ccache distlocks fixpackages metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu/"
LANG="en_US.UTF-8"
LINGUAS="en"
PKGDIR="/usr/portage//packages/x86/"
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_TMPDIR="/var/tmp"
PORTDIR="/usr/portage/"
PORTDIR_OVERLAY="/usr/local/portage /usr/local/portage-overlay/perl-catalyst /usr/local/portage-overlay/zugaina /usr/local/portage-overlay/savonet /usr/local/portage-overlay/layman/sunrise"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X aac acpi adns aio akode alsa amr ansi aotuv apache2 arts atlas avi bash-completion berkdb bitmap-fonts bluetooth bzip2 cpanplus crypt cups curl dbus dga divx4linux dlloader doc dri dvd dvdread effects elibc_glibc encode esd ethereal exscalibar fbcon fbdev ffmpeg fftw firefox flac flash foomaticdb gimp glut gnome gphoto2 gpm gstreamer gtk gtk2 gvim hardened hbci hou httpd id3tag ifp input_devices_keyboard input_devices_mouse ipod ipv6 ithreads jack java jpeg jpeg2k kerberos kernel_linux lame libgda libsamplerate linguas_en live lzo mad matroska mikmod mjpeg mmx mng mod modperl mono mozdevelop mozilla moznoirc mozsvg mp3 mp3id3 mp4 mpeg mplayer mpm-worker musicbrainz nativecode ncurses netjack network nfsv4 nptl nptlonly nsplugin ofx ogg oggvorbis opengl pam pcmcia pdf perl pic plugin png pnp ppds python quicktime readline real rsync rtp rtsp ruby samba scanner scim sdl shout skins sndfile sou speex spell sse sse2 ssl stream subtitles svg tcltk tcpd test theora threads tiff truetype uim unicode usb userland_GNU userlocales v4l vcd vdr video_cards_ati video_cards_fglrx video_cards_radeon vorbis vorbis-psy win32codecs x264 x86 xine xinerama xml xml2 xorg xpm xv xvid zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LDFLAGS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Mark Glines 2006-10-26 09:00:18 UTC
Created attachment 100536 [details, diff]
g-cpan-Gentoo-Config-follow-source-lines.diff

Follows "source /some/file" lines, when reading config values from /etc/make.conf.

Thanks!

Mark
Comment 2 Mark Glines 2006-10-26 10:14:11 UTC
Created attachment 100539 [details, diff]
g-cpan-Gentoo-Config-follow-source-lines.diff

Reissue my patch: clean up whitespace and quotation a little better.  Handles single-quotes, double-quotes, with or without trailing whitespace.
Comment 3 Christian Hartmann (RETIRED) gentoo-dev 2006-10-27 10:35:27 UTC
Thanks for the patch but that's actually not the right place for your changes as this function is also used to fetch params from configs not meant to be sourceable as make.conf e.g. is nowadays (it wasn't a year ago).

Instead we need a bash-source-wrapper-function.
Comment 4 Mark Glines 2006-10-27 10:49:00 UTC
(In reply to comment #3)
> Instead we need a bash-source-wrapper-function.

Hi!  Are you saying we need a wrapper function to go between getFileContents and getParamFromFile?  Or have I misunderstood you?

I'm happy to reimplement my changes, but I need some design clarification first.  Right now, the getValue function does this:

    my $filedata =
    getFileContents("/etc/make.globals").getFileContents("/etc/make.conf");
    my $param    = getParamFromFile($filedata,$confVal,"lastseen");

Are you suggesting I make a "getParamFromBashScript" wrapper around getParamFromFile, and call that instead?  Such a wrapper would convert the string to a list, perform "source" rewrites as my first patch did, and then convert *back* to a string because that's what getParamFromFile() expects.  It can then return getParamFromFile(newstring,@_[1..]) and everything continues as normal.

It's not the most efficient way I can think of, but it does minimize changes and it keeps getParamFromFile unchanged so it can still be used for other kinds of files.  So, is this the kind of thing you had in mind?  If so, I'll do it and send in a new patch.

Thanks,

Mark
Comment 5 Mark Glines 2006-10-27 11:24:45 UTC
Created attachment 100604 [details, diff]
g-cpan-Gentoo-Config-follow-source-lines.diff

(In reply to comment #3)
> Instead we need a bash-source-wrapper-function.

Rather than a wrapper, how about a conversion function?  It seems a bit more readable that way.

Here's a patch that adds a handleBashSourceStuff() function, to replace "source /foo/bar" lines with the contents of /foo/bar.  Takes a string as an argument, returns a new string with source lines handled.

It does not handle the bash ". /foo/bar" syntax, but I can add that.  Do you think there are any additional bashisms it should support?

One final thing; if the file can't be found, it emits a message to STDERR.  I put this in because the module doesn't use Carp.  This error message should probably be replaced with whatever error reporting mechanism is common for the Gentoo modules.

What do you think?

Mark
Comment 6 Michael Cummings (RETIRED) gentoo-dev 2007-01-02 14:13:47 UTC
Fixed by using Shell::EnvImporter to read in make.conf. See sources.gentoo.org for the sneak peak.