Chapter 1. Development And Tools

Table of Contents

1.1. YaST2 Development Tools
1.2. YaST2 Logging
1.3. Check YCP Syntax
1.4. The YaST2 Macro Recorder
1.5. YaST Desktop Files

1.1. YaST2 Development Tools

This document is a user's guide to the YaST2 devtools (short for "development tools"), a utility collection to make developing YaST2 code easier - C++ as well as YCP.

1.1.1. Quick Start

  • Install the yast2-devtools RPM or check out the devtools module from the YaST2 CVS and build and install it:

    cd yast2                  # your YaST2 CVS working directory
    cvs co devtools
    cd devtools
    make -f Makefile.cvs
    make
    sudo make install
    

  • See the Migration how to change your C++ or YCP module.

  • Build and use your package as before.

  • If make package complains, fix the complaints. For a tempoarary package to check whether or not build works with your changes, use "make package-local" - but never check in a package to /work/src/done that you created this way!

1.1.2. What is it?

The YaST2 devtools are an add-on to the classic automake / autoconf environment YaST2 used to use.

Since the toplevel Makefile.am is pretty much the same throughout all YaST2 C++ or YCP modules yet contains more and more specialized make targets, this toplevel Makefile.am is now automatically generated.

The only thing that is (or, rather, "should be") different in all those toplevel Makefile.am files is the "SUBDIRS =" line. This line is moved to a SUBDIRS in the package's toplevel directory, much like RPMNAME, VERSION, MAINTAINER etc. - the rest of Makefile.am is copied from a common path /usr/share/YaST2/data/devtools/admin. Thus, changes that should affect all of YaST2's toplevel Makefile.am files are much easier to do and all YaST2 modules can benefit from them without the need to change (i.e. cvs up, edit, cvs ci) all of over 85 individual files.

This implies, of course, that the toplevel Makefile.am is no longer stored in the CVS repository since it is now automatically generated.

On the downside, this of course implies that the files and scripts required for this new automagic are available at build time - i.e. on each YaST2 developer's development machine as well as in the build environment. Thus, you will need to either install the appropriate RPM or build the devtools manually - see the Quick Start section for details.

1.1.3. Migration

If you haven't done that yet, install the devtools - see the Quick Start section for details.

If you are not sure, check /usr/share/YaST2/data/devtools - if you don't have that directory, the devtools are not installed.

You can simply use the devtools-migration script that comes with the devtools package:

cd yast2/modules/mypackage
y2tool devtools-migration
cvs ci

This script performs the following steps:

  • Go to your package's toplevel directory:

    cd yast2/modules/mypackage
    

  • Create a SUBDIRS file from your existing Makefile.am.

    [Note]Note

    You can do without that SUBDIRS file if you want to include all subdirectories that have a Makefile.am in alphabetical order anyway):

    grep 'SUBDIRS' Makefile.am | sed -e 's/SUBDIRS *= *//' >SUBDIRS
    

    Getting rid of the "SUBDIRS = " prefix is not exactly mandatory (the devtools are forgiving enough to handle that), but recommended.

  • Add that new SUBDIRS file to the CVS repository:

    cvs add SUBDIRS
    

  • Get rid of the old Makefile.am both locally and in the CVS repository - this file will be automatically generated from now on:

    cvs rm -f Makefile.am
    

  • Get rid of the old copyright notices (COPYING, COPYRIGHT.{english,german,french}) both locally and in the CVS repository:

    cvs rm -f COPYING COPYRIGHT.{english,french,german}
    

    Those files will automatically be added to the tarball upon make package, make dist and related commands.

  • Add Makefile.am to the .cvsignore file since it will be automatically generated from now on (otherwise "cvs up" will keep complaining about it):

        echo "Makefile.am" >>.cvsignore
    

  • Edit your .spec.in file. Locate the neededforbuild line and add yast2-devtools to it:

    vi *.spec.in
    ...
    (locate "neededforbuild")
    (add "yast2-devtools")
    (save + quit)
    

    OK, that was the wimp version. Here is the freak version:

    perl -p -i -e 's/neededforbuild/neededforbuild yast2-devtools/' *.spec.in
    

  • Add the line that creates the toplevel Makefile.am to your Makefile.cvs:

    vi Makefile.cvs
    (locate "aclocal")
    (add a new line above this:)
    [tab]	y2tool y2automake
    (save + quit)
    

    Again, a freak version for this:

    perl -p -i -e 'print "\ty2tool y2automake\n" if /aclocal/' Makefile.cvs
    

    The new Makefile.cvs should look like this:

    all:
            y2tool y2automake
            autoreconf --force --install
    

  • Double-check what you just did and check it into the CVS when everything looks OK. "cvs up" should print something like this:

    M .cvsignore
    R COPYING
    R COPYRIGHT.english
    R COPYRIGHT.french
    R COPYRIGHT.german
    R Makefile.am
    M Makefile.cvs
    A SUBDIRS
    M myproject.spec.in
    

    "cvs diff"should print something like this:

    Index: .cvsignore
    ...
     config.log
     aclocal.m4
    +Makefile.am
    ...
    cvs server: Makefile.am was removed, no comparison available
    ...
    Index: Makefile.cvs
    ...
     all:
    +       y2tool y2automake
    	autoreconf --force --install
    ...
    cvs server: SUBDIRS is a new entry, no comparison available
    ...
    Index: myproject.spec.in
    ...
    -# neededforbuild autoconf automake ...
    +# neededforbuild yast2-devtools autoconf automake ...
    ...
    

    Important: Don't build yet, otherwise Makefile.am will be regenerated and "cvs ci" will complain when trying to check all this in.

  • Check your changes in:

    cvs ci
    

  • Test-build your package locally:

    make -f Makefile.cvs && make && sudo make install
    

    You should now have a new Makefile.am.

1.1.4. Translation (po) Modules)

For YaST2 translation modules (yast2-trans-...), the Makefile.am in the po subdirectory is automatically generated as well. The strategy for that is slightly different, though: The resulting Makefile.am is combined from Makefile.am.top, Makefile.am.center, and Makefile.am.bottom. The top and bottom files are used from the current project, if there is such a file; otherwise, all files are taken from /usr/share/YaST2/data/devtools/admin/po. The center part is always taken from there.

Add custom make targets or variable definitions to the top or bottom part as required. This may only be necessary for the yast2-trans-... data modules (e.g., keyboard, mouse, printers).

The migration script takes care of that: It migrates the po/ subdirectory, too, if there is one - and if there is a Y2TEXTDOMAIN file in the the project toplevel directory. For data modules, the migration script backs up the existing Makefile.am to Makefile.am.bottom (or to Makefile.am.old, if there already is a file named Makefile.am.bottom). Make sure to edit this file and get rid of duplicate parts before checking in.

1.1.5. create-spec: Automatic creation of the .spec file

make package-local handles the file *.spec.in. The file package/*.spec created in the time of "make -f Makefile.cvs" is overwitten in the time of "make package(-local)" with the package/*.spec created by y2tool create-spec. But it should have the same content.

With create-spec you can use more 'macros' in the *.spec.in:

@HEADER-COMMENT@

writes the SuSE .spec comment

@HEADER@

writes the usual header except BuildArch:, Requires:, Summary:

@PREP@

writes %prep with %setup

@BUILD-YCP@

writes %build with usual make

@INSTALL-YCP@

writes %install with usual YCP make install

@CLEAN@

writes %clean with removing RPM_BUILD_ROOT

So the new *.spec.in could look like:

@HEADER-COMMENT@
# neededforbuild  autoconf automake ycpdoc yast2-testsuite ...

@HEADER@
Requires:       yast2 yast2-trans-XXpkgXX yast2-lib-wizard yast2-lib-sequencer
BuildArchitectures:     noarch

Summary:        Configuration of XXpkgXX

%description
This package is a part of YaST2. It contains the necessary scripts to
configure XXpkgXX.

@PREP@

@BUILD-YCP@

@INSTALL-YCP@

@CLEAN@

%files
%dir @yncludedir@/XXpkgXX
/...

1.1.6. Overview of Paths

These paths are defined in your configure.in generated by y2autoconf and substituted by create-spec. That means they are accessible in all your Makefiles and can be uses in spec.in files.

yast2dir=${prefix}/share/YaST2

not for direct use

docdir=${prefix}/share/doc/packages/\$RPMNAME

for documentation

ybindir=${prefix}/lib/YaST2/bin

for all yast2 programs not be started by the user.

plugindir=${libdir}/YaST2/plugin

for loadable plugins

includedir=${prefix}/include/YaST2

for c header files

localedir=${yast2dir}/locale

for translations files

clientdir=${yast2dir}/clients

for ycp clients

moduledir=${yast2dir}/modules

for ycp modules

schemadir=${yast2dir}/schema

for schema files (autoyast, control file)

yncludedir=${yast2dir}/include

for ycp includes

scrconfdir=${yast2dir}/scrconf

for scr files

desktopdir=${prefix}/share/applications/YaST2/modules

for .desktop files (former *.y2cc)

execcompdir=${prefix}/lib/YaST2

for external programs that are yast2 components. here you have to append servers, servers_non_y2, clients or clients_non_y2.

ydatadir=${yast2dir}/data

for general data

imagedir=${yast2dir}/images

for non theme-able images

themedir=${yast2dir}/theme

for theme-able images (every theme must provide the same list of images)

In Makefile.am you can simply say

    ybin_PROGRAMS = y2base

when you what the program y2base to be installed in ybindir. No need to change bindir or even prefix.

In the files section of your spec.in file use something like this:

    @scrconfdir@/*.scr

Remember that the asterisk is only save when using a BuildRoot (and please use a BuildRoot).

If you need a define in a C++ file you have to pass it to the compiler. Simply use

    AM_CXXFLAGS = -DPLUGINDIR=\"${plugindir}\"

in your Makefile.am.

1.1.7. Toplevel make Targets in Detail

1.1.7.1. make package-local

Create a tarball from your module and put it into the package/ directory. This also creates a spec file from the .spec.in file.

1.1.7.2. make package

This checks for cvs consistency (see make check-tagversion) and whether or not you correctly tagged that version (don't forget to increase the version number in VERSION!), then does everything make package-local did.

1.1.7.3. make check-tagversion

This is performed by make package prior to actually creating a tarball: It checks whether or not you correctly tagged the current version. Use "y2tool tagversion" to do that once you increased the version number in VERSION.

[Note]Note

You will very likely never call this manually.

1.1.7.4. make check-up-to-date

This is performed by make package prior to actually creating a tarball: It checks whether or not everyting in this directory tree is checked into CVS or Subversion. Any modified, added or removed files make this check fail.

[Note]Note

You will very likely never call this manually.

1.1.7.5. make checkin-stable

This makes a package (i.e. it does everything "make package" does and checks it into the correct SuSE Linux distribution.

[Note]Note

This requires /work/src/done to be mounted via NFS.

1.1.7.6.  make stable

Just an alias for "make checkin-stable".