Linux Standard Base

Building LSB Compliant Applications

Christopher Yeoh

IBM OzLabs Linux Technology Centre

cyeoh@au.ibm.com

Overview

Introduction to LSB

Specification documents

Build tools

Testing

Certification

LSB Overview

Goals

Develop and promote a set of standards that will increase compatibility among Linux distributions

Coordinate efforts to recruit software vendors to port and write products for Linux

Organisation

Free Standards Group Workgroup

Steering Committee

Written Specification

Test Suites

Sample Implementation

Build Environment

Binary Compatibility

Why do free/open source software project care?

Minimise number of binary packages to build

Complying with standards helps with portability

Other UNIX or UNIX-like operating systems

Changes in base libraries

Reduces variety of bug reports

Easier for users

LSB Status

Specification

Release version 1.3 in January 2003

Support for 5 architectures

IA-32, 32-bit PowerPC™, Itanium™, 31 bit zSeries, 64 bit zSeries

Planned support for 64-bit PowerPC and AMD64 for LSB 2.0

Other architectures added on demand

Certification program

Support for 5 architectures for LSB 1.3

Application and Runtime (Distribution)

30 runtime products certified

Mostly IA-32, but at least one distribution for each supported architecture

LSB Status (cont')

LSB 2.0

Major additions

C++

SUSv3 update

Specification to be released February 2004

Certification program to start mid-year

LSB Specification

Binary (ABI) standard

Multiple documents

generic LSB (gLSB)

architecture/processor specific parts (psLSB)

Reference established standards

POSIX, C, System V ABI, File Hierarchy Standard

Covers core library on Linux

Base (libc, libm, ...)

Utility (ncurses, libutil)

Graphics (libX11, libGL)

LSB Specification (cont')

Object file format

Package format

Commands and utilities

System initialisation (init scripts/run levels)

Compliant Application

Properties of an LSB Compliant Application

Only use LSB specified interfaces (including symbol versioning)

Only use LSB specified commands and utilities

Linked against LSB runtime linker (/lib/ld-lsb-arch.so.1)

When using non LSB libraries

statically link

provide LSB compliant shared libraries

FHS compliant

Passes FVT on LSB Sample Implementation and 2 LSB certified runtimes

Packaged in subset of RPMv3 format or uses LSB compliant installer

Building Binaries

Problems

Symbol versions for libc

Header files (ABI compatibility)

LSB linker

Solutions

Stub libraries

LSB header files

lsbdev-cc

lsbdev-chroot

Build tools

Base development tools supplied by lsbdev-base package

stub libraries

LSB header files

lsbdev-cc and lsbdev-chroot installed on top of lsbdev-base

lsbdev-c++ provides support for static linking of C++ applications which will be LSB compliant

Only needed for pre LSB 2.0

lsbdev-cc

Wrapper program for gcc

sets up header include paths to use LSB header files

sets up link paths to use LSB stub libraries

makes gcc use LSB linker

Full functionality of system available and visible

C++ version available

Example.......

lsbdev-chroot

Restricted chroot environment

bind mounts

used to import outside environment

compile inside, edit/test outside

explicitly import extra header files and libraries

by default can only see LSB headers and smallest subset of libraries

/usr/lib contains LSB stub libraries

Example.....

lsbdev-cc vs. lsbdev-chroot

lsbdev-cc

Pros

Better tested. Used to build LSB application battery

Simple to use and setup

Full development environment available

Cons

Easier to accidentally 'pollute' binaries

Can't handle all situations (eg dependent on gcc)

lsbdev-cc vs lsbdev-chroot

lsbdev-chroot

Pros

Compiler independent

More tolerant of makefile problems

Cons

More difficult to setup/configure

Bind mounts can cause problems with upgrades of some systems

Package naming

Package naming

Must not conflict with native distribution packages

All package names start with lsb-

One hyphen in name then assigned by Linux Assigned Names and Number Authority (LANANA)

eg lsb-apache-1.3.rpm

More than one hyphen in name then second component

assigned by LANANA

DNS name in lower case with at least one '.'

eg. lsb-ibm.com-websphere-2.0.rpm

Directory naming

Init script naming

Testing for Compliance

lsbappchk

Checks object format

Checks dynamic symbols

part of specification OR

supplied by a shared library bundled with application

Example of use.....

FHS checklist

Test in

LSB sample implementation

Other LSB compliant runtimes

RPM package format checker

Sample lsbappchk

Examples of compliant
applications

LSB application battery

primarily used to test that a runtime is compliant

serves as examples of problems encountered when building a compliant application and how to fix

tests the build environment

feedback into modifications/additions to the specification

Applications built LSB compliant

Apache, rsync, samba, xpaint, xpdf, tcl, ...

Case Study: Rsync

Typical issues when making an application LSB compliant

Use rsync as an example

attempt to build with lsbcc

$ CC=lsbcc ./configure

configure: Configuring rsync 2.5.7

checking for gcc... lsbcc

checking for inet_ntop in -lresolv... yes

checking for poptGetContext in -lpopt... yes

libresolv and libpopt are not in the LSB but lsbcc has arranged that the configure test statically links them and so is available

Case Study (cont')

On build, some problems appear, however: . . .

$ make
. . .
lsbcc -I. -I. -g -O2 -DHAVE_CONFIG_H -Wall -W -c clientname.c -o clientname.o
clientname.c: In function `client_sockaddr':
clientname.c:120: warning: implicit declaration of function `IN6_IS_ADDR_V4MAPPED‘
clientname.c:120: dereferencing pointer to incomplete type
clientname.c:127: storage size of `sin6' isn't known
clientname.c:127: warning: unused variable `sin6‘
clientname.c: In function `compare_addrinfo_sockaddr':
clientname.c:213: dereferencing pointer to incomplete type

Case Study (cont')

If we look at clientname.c we see lines like:

#ifdef INET6

struct sockaddr_in6

#endif

LSB 1.3 doesn't support ipv6 and so type definitions like sockaddr_in6 are not in the LSB header files

LSB 2.0 supports ipv6

Why didn't configure work this out?

Looking back at the configure output we see

checking ipv6 stack type ... linux-glibc

Case Study (cont')

Rsync configure tests for linux glibc, rather than ipv6

Always should test for specific functionality, not for name of system that should provide it

configure script has –disable-ipv6 flag

Re-run configure and compile

Case Study (cont')

Final link fails:

lsbcc -g -O2 -DHAVE_CONFIG_H -Wall -W -o rsync rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o main.o checksum.o match.o syscall.o log.o backup.o options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o fileio.o batch.o clientname.o progress.o pipe.o params.o loadparm.o clientserver.o access.o connection.o authenticate.o lib/fnmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o lib/permstring.o zlib/deflate.o zlib/infblock.o zlib/infcodes.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/infutil.o zlib/trees.o zlib/zutil.o zlib/adler32.o -lpopt -lresolv

authenticate.o(.text+0x76e): In function `auth_client':

/home/cyeohg/src/rsync-2.5.7/authenticate.c:278: undefined reference to `getpass'

collect2: ld returned 1 exit status

make: *** [rsync] Error 1

Case Study (cont')

getpass is not part of the LSB

man page mentions it is obsolete and not to use it

used implementation recommended in info page

Patching source and rebuilding results in binary

Test binary with lsbappchk

$ lsbappchk rsync

lsbappchk for LSB Specification 1.3.3

Checking binary rsync

No errors reported

Case Study (cont')

Further testing required

FVT on LSB SI, and 2 other distributions

FHS issues

Should install in /opt/lsb-rsync

Config files

/etc/opt/lsb-rsync/rsyncd.conf

Formal Certification

Voluntary, but needed to use LSB trademark

Operated by a Certification Authority (CA)

The Open Group (http://www.opengroup.org/lsb/cert)

Also do UNIX™ certification

Application must be certified per architecture

Formal Certification Process

Informal Testing

Company/Organisation registration

LSB Trademark license Agreement (TMLA)

Registration of application

Warrant application passes FVT on SI and 2 LSB certified runtime environments

one chosen by applicant, one by certification authority

lsbappchk journal

Confirmation/Payment

Updating certification

Appeals

Specification authority, then FSG board of directors

Maintenance updates

do no need to recertify, but must be compliant

New functionality versions

need to recertify

Recertification needed after 2 years

Self-tested program

Publicly accessible register

free, but cannot use trademark

alternative for smaller, volunteer run, open source projects

Requirements similar to formal certification

Register at http://www.linuxbase.org

Complete a “Conformance Statement”

Upload lsbappchk journal file

Warrant application runs correctly on LSB SI and 2 LSB distributions

Useful Links

Linux Standard Base Project (http://www.linuxbase.org/)

Build Environment subproject (http://www.linuxbase.org/build)

lsb-build mailing list http://freestandards.org/mailman/listinfo/lsb-build/

LSB Certification (http://www.opengroup.org/lsb/cert)

LSB Certification Problem reports http://www.opengroup.org/lsb/cert/PR

Free Standards Group (http://www.freestandards.org/)

Legal Statement

This work represents the view of the author and does not necessarily represent the view of IBM

UNIX is a registered trademark of The Open Group in the United States and other countries

Linux is a registered trademark of Linux Torvalds

Other company, product and service names may be trademarks or service marks of others

Building LSB Compliant Applications

2003-10-03T14:46:17