GNOME Bugzilla – Bug 702040
very strange gnome-doc-utils check in gparted
Last modified: 2013-09-18 16:52:24 UTC
in autogen.sh: # Check for GNOME-DOC-UTILS GDUMAKE="gnome-doc-utils.make" GDUMAKEFULLPATH=`locate $GDUMAKE | grep -m 1 "gnome-doc-utils/"` if test "x${GDUMAKEFULLPATH}" = "x" ; then echo "Cannot find file: $GDUMAKE" echo "You need to install gnome-doc-utils" exit 1 fi using 'locate' is wrong for so many reasons....
Thank you Ryan for your interest in improving GParted. Are you suggesting the logic be changed to be similar to that of the gparted.in script? For example: # Check for GNOME-DOC-UTILS HAVE_GDU=no GDUPREPARE="gnome-doc-prepare" for k in '' `echo "$PATH" | sed 's,:, ,g'`; do if test -x "$k/$GDUPREPARE"; then HAVE_GDU=yes break fi done if test "x${HAVE_GDU}" = "xno" ; then echo "Cannot find file: $GDUPREPARE" echo "You need to install gnome-doc-utils" exit 1 fi Or do you have another suggestion? The key thing is that the script notify that a package needed to build GParted from git is missing.
I think the best would be to use pkg-config. gnome-doc-utils installs a .pc file.
Do you have an example? Also, what if gnome-doc-utils is installed from source code and not from a package?
Something along these lines: if pkg-config --exists gnome-doc-utils; then echo good... else echo bad... fi .pc files are part of upstream projects and have nothing to do with distribution packages. They will be installed when building from source.
How do we get from good/bad to knowing the path to gnome-doc-utils.make so we can copy the file for the next section of code in autogen.sh? # Ensure a copy of gnome-doc-utils.make exists in the top source directory test -e $srcdir/$GDUMAKE || { echo "Copying $GDUMAKEFULLPATH to $srcdir" cp -p $GDUMAKEFULLPATH $srcdir }
Good point Mike (in comment #5). The script autogen.sh is only used to build GParted from the git repository. As such without a good solution to comment #5, I lean towards leaving the code as-is. Since typically autogen.sh is used by developers or advanced users, I do not believe that the use of locate is much of a problem. Ryan, Do you have a solution to Mike's question in comment #5?
I'd go with something along these lines: GDUMAKEFULLPATH="`pkg-config --variable=datadir gnome-doc-utils`/gnome-doc-utils/gnome-doc-utils.make"
Hi Ryan, (In reply to comment #0) > using 'locate' is wrong for so many reasons.... Can you tell me those reasons please. The only issue I have is when I install a new distro I have to run updatedb to update the locate database before I can run ./autogen.sh to build GParted for the first time. Thanks, Mike
The updatedb issue is a big deal, I think... it caught me... I was getting frustrated wondering why I couldn't autogen despite the fact that I had clearly installed this file. Using pkg-config also makes sure that we find the right version (jhbuild install vs. system install) according to the user's environment (which jhbuild takes care to setup properly). Additionally, it's a security problem. If you have some malicious user on the system who puts a copy of gnome-doc-utils.make into their home directory and it happens to show up in the 'locate' output before the system one, then you will copy it out of their home directory and execute whatever is inside of it as the current user...
Created attachment 246806 [details] [review] Stop using locate in autogen.sh (v1) Hi Curtis, Here's a patch for this. Tested on Fedora 14 and CentOS 5.9. Tested removing gnome-doc-uitls package and just removing the gnome-doc-utils.make file. Tested make distcheck. Looked at the gnome-doc-utils make file which installs g-d-u.make. https://git.gnome.org/browse/gnome-doc-utils/tree/tools/Makefile.am It is more obvious looking at the generated Makefile.in. g-d-u.make is installed in the directory $datadir/gnome-doc-utils/ presumably with datadir being set by ./configure and recorded in the pkg-config .pc metadata file. Thanks, Mike
Thank you Mike for digging deeper and developing a patch, and thank you Ryan for raising this report and working towards a solution. I tested the patch in comment #10 on the following distros: kubuntu 12.04 Debian 6 openSUSE 12.2 The patch passed all of my testing. This enhancement has been committed to the gnome repository for inclusion in the next release of GParted. The relevant git commit can be viewed at the following link: Stop using locate in autogen.sh (#702040) https://git.gnome.org/browse/gparted/commit/?id=f77d4e65a92a721d61a1212b3282a6cc87de8579
Review of attachment 246806 [details] [review]: ::: autogen.sh @@ +28,3 @@ # Check for GNOME-DOC-UTILS GDUMAKE="gnome-doc-utils.make" +datadir=`pkg-config --variable=datadir gnome-doc-utils` Could probably use some more quoting here in case someone is silly and has a space in their prefix...
Review of attachment 246806 [details] [review]: This works as expected in both bash and ash shells: $ a=`echo foo bar` $ echo $a foo bar Additional quoting isn't necessary.
The patch to address this report has been included in GParted 0.16.2 released on September 18, 2013.