LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Passing cmake variables in a src2pkg script... (http://www.linuxquestions.org/questions/slackware-14/passing-cmake-variables-in-a-src2pkg-script-655783/)

Lufbery 07-14-2008 10:31 PM

Passing cmake variables in a src2pkg script...
 
Gilbert,

I'm posting this here because others may have similar questions.

If I want to pass cmake variables via a src2pkg build script, does it go in the "# EXTRA_CONFIGS=''" line? I need to uncomment that line, right?

This page has the list of configuration options I'd like to use.

Finally, a quick note. I think I found a bug/feature. :)

When I first started to create the src2pkg script (as root), my source file was in a directory path with a space in it. I got this error:

Code:

FAILED! You don't have permission to create files in
the current directory: /home/drew/Downloaded-Packages/Installed/Non-Slackware Packages/QGIS_0.10.0/QGIS-0.10.0_Source
src2pkg FAILURE in WRITE_PERMISSION

When I moved the source file to a directory without spaces, everything worked fine.

Regards,

-Drew

gnashley 07-15-2008 01:22 AM

Drew, srcpkg isn't able to automatically handle extra arguments to cmake. Yours is the first case I've seen where someone wanted to do so -maybe it will be possible to incorporate this in the future.
Meanwhile, you'll need to manually write the configure commands, I'm afraid. Create a starting src2pkg script and then comment the 'configure_source' line and replace it with something like:

Code:

cd $SRC_DIR;
cmake . CMAKE_INSTALL_PREFIX=?? WITH_BINDINGS=TRUE WITH GRASS=TRUE

The compile_source and fake_install functions should work normally after that.
I'll have a look to see if passing extra args can be worked into the code so this is easier for you next time.

As to the problem with spaces in the path, this was pointed out a long time ago, but has not been fixed yet. Since it is a minor problem, I haven't tried to isolate the spot(s) where src2pkg isn't handling this.

gnashley 07-15-2008 06:37 AM

I was out for the morning but when I got back I looked into the src2pkg cmake routines and seem to have gotten EXTRA_CONFIGS working. I don't have the requireds for qgis so you can provide the final test of the changes.

Open the file: /usr/libexec/src2pkg/06-configure_source

You just need to add '$EXTRA_CONFIGS' to lines:
365, 388, 390, 394, 396, 408 and 410

Like this (lines 363 to 413):
Code:

elif [[ -f $CONFIG_DIR/CMakeLists.txt ]] ; then
                echo $BLUE"Found 'cmake' configuration - "$NORMAL"Configuring using:"
                echo "  cmake -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/${PRE_FIX} $EXTRA_CONFIGS"
                # make a build dir in the sources and use it as the OBJ_DIR
                if [[ $USE_OBJ_DIR ]] || [[ -d $CONFIG_DIR/build ]] ; then
                        mkdir -p $CONFIG_DIR/build
                        # Delete the normal OBJ_DIR which got created in 03-make_dirs
                        if [[ $OBJ_DIR_NAME != "" ]] && [[ -d $SRC_BUILDS_DIR/$OBJ_DIR_NAME ]] ; then
                          [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing object build directory from previous build - "$NORMAL
                          ( cd $SRC_BUILDS_DIR && rm -rf $OBJ_DIR_NAME 2> /dev/null 1> /dev/null )
                        fi
                        # now reset the OBJ_DIR for cmake
                        OBJ_DIR=$CONFIG_DIR/build
                else
                        OBJ_DIR=$CONFIG_DIR
                fi
                INSTALL_TYPE=DESTDIR
                cd $OBJ_DIR
                if ! [[ $(which cmake) ]] ; then
                        echo $RED"FAILED! "$NORMAL"No cmake found in path. "$RED"Exiting..."$NORMAL
                        FAILED="CONFIGURATION - Missing cmake"
                elif [[ "$PRE_FIX" != "usr/local" ]] ; then
                        if [[ $QUIET = "YES" ]] ; then
                                # this is what you need to change the default PREFIX for cmake non-interactively
                                if [[ $USE_OBJ_DIR ]] ; then
                                  cmake .. -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} ${EXTRA_CONFIGS} &> /dev/null
                                else
                                  cmake . -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} ${EXTRA_CONFIGS} &> /dev/null
                                fi
                        else
                                if [[ $USE_OBJ_DIR ]] ; then
                                  cmake .. -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} ${EXTRA_CONFIGS}
                                else
                                  cmake . -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} ${EXTRA_CONFIGS}
                                fi
                        fi
                else
                        if [[ $QUIET = "YES" ]] ; then
                                if [[ $USE_OBJ_DIR ]] ; then
                                  cmake .. ${EXTRA_CONFIGS} &> /dev/null
                                else
                                  cmake . ${EXTRA_CONFIGS} &> /dev/null
                                fi
                        else
                                if [[ $USE_OBJ_DIR ]] ; then
                                  cmake .. ${EXTRA_CONFIGS}
                                else
                                  cmake . ${EXTRA_CONFIGS}
                                fi
                        fi
                fi

As I said, I don't have the requireds for configuration to get very far, but the above changed code seemed to work okay to fix EXTRA_CONFIGS so that you can write it into the script variables, or use it from the command line:
Code:

src2pkg -e='-DWITH_BINDINGS=TRUE -DWITH_GRASS/usr/lib/grass' qgis_0.10.0.tar.gz
Let me know if that seems to work okay for you and I'll in include it in the next release.

Lufbery 07-15-2008 07:49 AM

Awesome work, Gilbert. Thanks!

I'll test it and let you know how things work out. We'll get the results of this exercise into the wiki too. :D

I'll test this tonight and post the results.

I'll also add a little bit about the error I got. As long as we document that it happens, I don't think it's a big deal.

Warm regards,

-Drew

Lufbery 07-15-2008 02:47 PM

Gilbert,

Quick question: my line numbers are two off from yours. That is, your 365 is my 367. That shouldn't be a problem, right? I'm using 1.9.6.

Also, should this line:
Code:

echo "  cmake -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/${PRE_FIX} $EXTRA_CONFIGS"
Be this (with the curly brackets)?

Code:

echo "  cmake -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/${PRE_FIX} ${EXTRA_CONFIGS}"
Thanks,

-Drew

Lufbery 07-15-2008 03:48 PM

Gilbert,

Here's the relevant part of the src2pkg.auto script:

Code:

#!/bin/bash
## src2pkg script for:        qgis
## Auto-generated by src2pkg-1.9.6
## src2pkg Copyright 2005-2008 Gilbert Ashley <amigo@ibilio.org>

SOURCE_NAME='qgis_0.10.0.tar.gz'
NAME='qgis'
VERSION='0.10.0'
# ARCH='i486'
BUILD='1'
PRE_FIX='usr'
# Any extra options go here
EXTRA_CONFIGS='-DCMAKE_INSTALL_PREFIX:PATH=/usr -DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake -DWITH_BINDINGS=TRUE -DWITH_GRASS=true -DGRASSPREFIX=/usr/grass-6.2.3'
# STD_FLAGS='-O2 -march=i486 -mtune=i686'

I'll let you know how it works out.

-Drew

gnashley 07-15-2008 04:14 PM

The difference in the line numbers is okay -I have addded a couple of lines somewhere above that lately.
You shouldn't need to supply the prefix with EXTRA_CONFIGS as it is already supplied separately:
EXTRA_CONFIGS='-DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake -DWITH_BINDINGS=TRUE -DWITH_GRASS=true -DGRASSPREFIX=/usr/grass-6.2.3'

Lufbery 07-15-2008 07:16 PM

Gilbert,

Thanks for the update. I'll modify the src2pkg script and run it tonight. I did the -T test and everything looks okay, but the proof is in the pudding. Unfortunately, it's about a six-hour compile on my computer, so I'm going to start it before going to bed and find out tomorrow how things will have gone.

Regards,

-Drew

gnashley 07-16-2008 02:46 AM

Oh, about the curly brackets -it shouldn't make any difference, at this particular spot in the src2pkg code, whether you use or not the curly brackets. I use them, or not, as a means of better formatting which shows up better with syntax highlighting in most editors. I use SciTE for nearly all text-editing because I like the colors and syntax-parser, but whatever you are used to should be fine. The curly-brackets show up differently. I usually use the curly brackets when writing the actual command and arguments which get run. The first $EXTRA_CONFIGS without braces is part of an 'echo' command which shows a prompt similar to this:

Found 'cmake' configuration - Configuring sources using:
cmake -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/${PRE_FIX} -DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake -DWITH_BINDINGS=TRUE -DWITH_GRASS=true -DGRASSPREFIX=/usr/grass-6.2.3

Notice that the above prompt output and the real command use separate arguments for the prefix which are apart from the rest of the configs in EXTRA_CONFIGS -in the same way that is used with other configuration types(autoconf, etc). src2pkg supplies the default prefix and assumes that EXTRA_CONFIGS is empty. The general form looks like this: CONFIG_COMMAND --prefix=PRE_FIX EXTRA_CONFIGS.Occassionaly this arbitrary insertion of the --prefix=PRE_FIX makes some configure scripts choke, but obviously works much more often than not.

"six-hour compile" -Yuck! Just the kind of build to drive you mad when things don't go right or extra unforseen steps are needed to make a really complete package. Good luck!

Lufbery 07-16-2008 10:40 AM

I've got good news and bad news.

The good news is that it wasn't a six-hour compile -- that must have been QT4 I was remembering. QGIS took about an hour.

The bad news is that even though the package compiled and was created just fine, QGIS won't run. I get this error when I try to run it:

Code:

qgis: /tmp/qgis-0.10.0-src-1/src/app/qgisapp.cpp:1192: void QgisApp::createStatusBar(): Assertion `!myProjPixmap.isNull()' failed.
Aborted

I'm not quite sure how to parse that.

I'm going to try the slacky.eu slackbuild script with the extra cmake options and see what happens. I'm not sure what the script does that src2pkg doesn't do. Here's a link, though, so maybe we can figure it out.

Regards, and stay tuned...

-Drew

P.S. Thanks for clearing up the part about the curly brackets.

Lufbery 07-16-2008 12:18 PM

Okay, part of the problem seems to be that I've (and the Slacky.eu slackbuild) have got the wrong location for cmake-qt4. The configuration is also saying it can't find GRASS, so I'm going to point right to the GRASS binary.

The new command looks like this:

Code:

cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4 -DWITH_BINDINGS=TRUE -DWITH_GRASS=true -DGRASSPREFIX=/usr/bin/grass62
Or in a src2pkg script:

Code:

EXTRA_CONFIGS='-DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4 -DWITH_BINDINGS=TRUE -DWITH_GRASS=true -DGRASSPREFIX=/usr/bin/grass62'
We'll see how it goes.

Edit: DARN! It still says it can't find GRASS.

-Drew

P.S. I've been home for the past three days with my son, who is ill, and is now napping. So at least I have something to keep me occupied...

:)

gnashley 07-16-2008 12:21 PM

Are you running that after installing or from the sources where it was compiled?

From looking at the slackbuild for it, I'd say try putting this in your src2pkg script near the top:

export PATH=$PATH:/opt/qt4/bin
export QTDIR=/opt/qt4
USE_OBJ_DIR=YES

Otherwise, comment out the configure_source, compile_source and fake_install lines and insert this:

export PATH=$PATH:/opt/qt4/bin
export QTDIR=/opt/qt4
mkdir $SRC_DIR/build
cd $SRC_DIR/build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr -DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake
make install DESTDIR=$PKG_DIR


This syntax '-DCMAKE_INSTALL_PREFIX:PATH=/usr' differs from what src2pkg usually uses: '-DCMAKE_INSTALL_PREFIX=/usr'. I'm not sure if that's part of the problem. Also, the directions in the sources say to run 'cmake .' in the top dir and the slackbuild does the compiling in a separate dir 'build'. USE_OBJ_DIR=YES tells src2pkg to do that automatically for you, but it will be inserting the CMAKE_INSTALL_PREFIX according to the latter syntax above. As always, if it seems harder to convince (or trick) src2pkg into doing what you want, simply comment out the offending lines and replace with very slightly -modified code from a slackbuild or as you would use from the CLI.

Lufbery 07-17-2008 08:07 PM

Hi Gilbert. I had to go back to work today :( so I'm just now getting back to this project.

Quote:

Originally Posted by gnashley (Post 3216619)
Are you running that after installing or from the sources where it was compiled?

If you're referring to finding GRASS, it's when I'm trying to compile from source. GRASS is installed, so I should just be able to point to its directory in the cmake command.

I'm posted in the QGIS help forum, but so far, there's been no answer.

I built from the slackbuild after modifying the cmake line and except for not finding GRASS, everything went well. I did not get the error when trying to run QGIS after installation that I did with the src2pkg-built package.

Quote:

From looking at the slackbuild for it, I'd say try putting this in your src2pkg script near the top:

export PATH=$PATH:/opt/qt4/bin
export QTDIR=/opt/qt4
USE_OBJ_DIR=YES

Otherwise, comment out the configure_source, compile_source and fake_install lines and insert this:

export PATH=$PATH:/opt/qt4/bin
export QTDIR=/opt/qt4
mkdir $SRC_DIR/build
cd $SRC_DIR/build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr -DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake
make install DESTDIR=$PKG_DIR
Okay. I'll try the first option first because I'd still like to be able to pass variables to cmake from the src2pkg script. That part seems to be working pretty well, actually.

What's going on with the $PATH variable above? Is it necessary to point to /opt/qt4 twice? I'm not criticizing, just wondering.

Quote:

This syntax '-DCMAKE_INSTALL_PREFIX:PATH=/usr' differs from what src2pkg usually uses: '-DCMAKE_INSTALL_PREFIX=/usr'. I'm not sure if that's part of the problem.
I wonder that too. Does passing the variable to cmake override the usual src2pkg behavior?

Quote:

Also, the directions in the sources say to run 'cmake .' in the top dir and the slackbuild does the compiling in a separate dir 'build'. USE_OBJ_DIR=YES tells src2pkg to do that automatically for you, but it will be inserting the CMAKE_INSTALL_PREFIX according to the latter syntax above.
I'm not sure I follow (it's been a long day). If I use USE_OBJ_DIR=YES, do it result in '-DCMAKE_INSTALL_PREFIX:PATH=/usr' (what I got from the documentation) or '-DCMAKE_INSTALL_PREFIX=/usr'?

Quote:

As always, if it seems harder to convince (or trick) src2pkg into doing what you want, simply comment out the offending lines and replace with very slightly -modified code from a slackbuild or as you would use from the CLI.
That's part of the beauty of src2pkg -- it's pretty malleable. :D

In terms of finding GRASS, I'm simply frustrated. The documentation for building QGIS is a little confusing because it covers building under Windows, Mac, and Linux, but their Linux instructions are only for Ubuntu. :( I get the feeling that they do most of their work on Windows and/or Mac computers.

HOWEVER, the docs indicate that I also need to compile GDAL with GRASS support. It may be that the GDAL w/ GRASS library is what cmake is looking for.

I'll keep everyone posted.

Regards,

-Drew

gnashley 07-18-2008 03:41 AM

Because of this:
qgis: /tmp/qgis-0.10.0-src-1/src/app/qgisapp.cpp:1192:
it seemed to me that maybe you were running the executable from inside the sources or something.

The QGIS wiki lists these dependencies:

libqt4-core libqt4-debug libqt4-gui libqt4-qt3support libqt4-sql
lsb-qt4 qt4-designer qt4-dev-tools qt4-doc qt4-qtconfig
uim-qt gcc libapt-pkg-perl resolvconf

gdal libgdal1 libgeos-dev proj libgdal-doc
libhdf4g libhdf4g-run python libgsl0-dev g++
libjasper libtiff4 subversion
libsqlite3 sqlite3 ccache make libpq-dev flex bison cmake txt2tags
python-qt4 python-qt4-dev python-sip4 sip4 python-sip4-dev

grass libgrass libgdal-1.4.0-grass


Doing these two exports just makes sure that everybody knows where QT is and any other bins located with it like qmake. The 'export' makes the values available to all executables called during configuration, compile and install. All the stuff with -Dsomething is specifically for cmake.
export PATH=$PATH:/opt/qt4/bin
export QTDIR=/opt/qt4

This part is telling cmake (or ccmake, I guess) the same thing
-DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake

I was just looking some more, the best instructions are probably in the INSTALL file included with the sources. It shows using these defines:

cmake -D CMAKE_INSTALL_PREFIX=${HOME}/apps/ \
-D GRASS_INCLUDE_DIR=/user/local/grass-6.3.0/include \
-D GRASS_PREFIX=/user/local/grass-6.3.0 \
-D CMAKE_BUILD_TYPE=Release ..

The thing about the install prefix is this: src2pkg automatically does this for cmake:
-DCMAKE_INSTALL_PREFIX=${PKG_DIR}/${PRE_FIX}
So, giving it again in EXTRA_CONFIGS could cause errors. This makes sure that when 'make install' is run, that the program files get copied into our PKG_DIR properly.
I do not find any reference to using '-DCMAKE_INSTALL_PREFIX:PATH' other than the wiki. It must surely be a typo.

Now, about the OBJ_DIR. using that simply means that the output of the compile process gets put into a 'clean' directory. The clean directory can be inside or outside the source directory. src2pkg normally creates the object dir outside of the sources. For cmake, it is done slightly differently from autoconf sources. Many sources which use cmake assume and direct you to do the build in a clean directory -
assuming you are inside the sources (SRC_DIR):
mkdir -p build
cd build
cmake ..

The 'cmake ..' tells cmake to look for the CMakeLists.txt file one level up -in the main source dir.
To build without using a separate object directory, you'd just cd into the sources and run:
'cmake .' (look for CMakeLists.txt in this directory)

I've just made src2pkg use the native method there -when you specify USE_OBJ_DIR=YES, for cmake configuration the OBJ_DIR used is: $SRC_DIR/build.

I dont find this syntax:

It seems to me that you need a script along these lines:
Code:

#!/bin/bash
## src2pkg script for:        qgis

SOURCE_NAME='qgis_0.10.0.tar.gz'
NAME='qgis'
VERSION='0.10.0'
# ARCH='i486'
BUILD='1'
PRE_FIX='usr'
# Any extra options go here
export PATH=$PATH:/opt/qt4/bin
export QTDIR=/opt/qt4
USE_OBJ_DIR=YES
EXTRA_CONFIGS='-DWITH_GRASS=TRUE \
    -DGRASSPREFIX=/usr/bin/grass62 \
    -DGRASS_PREFIX=/usr/lib/grass \
    -DGRASS_INCLUDE_DIR=/usr/lib/grass/include \
    -DGRASS_PREFIX=/usr/lib/grass \
    -DCMAKE_BUILD_TYPE=Release \
    -DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake \
    -DWITH_BINDINGS=TRUE'

# STD_FLAGS='-O2 -march=i486 -mtune=i686'

# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;

# do_all_processes can substitute these 16 steps:

pre_process
find_source
make_dirs
unpack_source
fix_source_perms
configure_source
compile_source
fake_install
fix_pkg_perms
strip_bins
create_docs
compress_man_pages
make_description
make_doinst
make_package
post_process

Since srcpkg supplies the CMAKE_INSTALL_PREFIX, you should something like this when you run the above script.
Code:

Found 'cmake' configuration - Configuring using:
cmake -DCMAKE_INSTALL_PREFIX=/your_path/qgis-0.10.0-pkg-1/usr -DGRASSPREFIX=/usr/bin/grass62 -DGRASS_PREFIX=/usr/lib/grass -DGRASS_INCLUDE_DIR=/usr/lib/grass/include -DGRASS_PREFIX=/usr/lib/grass -DCMAKE_BUILD_TYPE=Release -DQT_QMAKE_EXECUTABLE=/opt/qt4/bin/qmake -DWITH_BINDINGS=TRUE


Lufbery 07-18-2008 12:23 PM

Gilbert,

As usual, you've been very helpful. I'll give stuff a try and see how it works out.

Regarding the cmake variable INSTALL_PREFIX, check out this page from the cmake wiki. It looks like the "CMAKE_INSTALL_PREFIX:PATH=/usr" is correct.

Regards,

-Drew


All times are GMT -5. The time now is 08:28 PM.