Hi Steve,

I need some help with patching pam - I must admit I don't like quilt,
I find it hard to use and understand, especially when I am trying to
modify the quilt patches for someone else's package.
:-(

(Is there was a standard way of using quilt that doesn't rely on
prefixing every command with QUILT_PATCHES= ? *and* which is portable
to *all* Debian packages using quilt no matter whether the package
uses debian/patches debian/patches-applied or debian/manglesource or
debian/foo ?) 

Could there be a debian/rules target that would allow people like me to
work with quilt in any package without having to know about
QUILT_PATCHES ?

(I much prefer to CDBS method of "just drop the patch file in and build".)

I've sorted out the build-dep, now pam fails to cross-build within the
Linux-PAM/doc/specs/ directory:

make[5]: Entering directory 
`/opt/emdebian/trunk/p/pam/trunk/pam-0.99.7.1/Linux-PAM/doc/specs'
arm-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../..     -g -D_GNU_SOURCE -D_REENTRANT 
-fPIC -DCRACKLIB_DICTS=CRACKLIB_DICTPATH -O2 -MT parse_l.o -MD -MP -MF 
.deps/parse_l.Tpo -c -o parse_l.o parse_l.c
mv -f .deps/parse_l.Tpo .deps/parse_l.Po
arm-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../..     -g -D_GNU_SOURCE -D_REENTRANT 
-fPIC -DCRACKLIB_DICTS=CRACKLIB_DICTPATH -O2 -MT parse_y.o -MD -MP -MF 
.deps/parse_y.Tpo -c -o parse_y.o parse_y.c
parse_y.y:232:13: warning: trigraph ??> ignored, use -trigraphs to enable
parse_y.y:245:19: warning: trigraph ??> ignored, use -trigraphs to enable
mv -f .deps/parse_y.Tpo .deps/parse_y.Po
/bin/sh ../../libtool --tag=CC   --mode=link arm-linux-gnu-gcc  -g 
-D_GNU_SOURCE -D_REENTRANT -fPIC -DCRACKLIB_DICTS=CRACKLIB_DICTPATH -O2  
-Wl,--as-needed -Wl,-O1 -o padout parse_l.o parse_y.o -lfl 
mkdir .libs
arm-linux-gnu-gcc -g -D_GNU_SOURCE -D_REENTRANT -fPIC 
-DCRACKLIB_DICTS=CRACKLIB_DICTPATH -O2 -Wl,--as-needed -Wl,-O1 -o padout 
parse_l.o parse_y.o  -lfl
./padout < ./draft-morgan-pam.raw > draft-morgan-pam-current.txt
/bin/sh: ./padout: cannot execute binary file
make[5]: *** [draft-morgan-pam-current.txt] Error 126
make[5]: Leaving directory 
`/opt/emdebian/trunk/p/pam/trunk/pam-0.99.7.1/Linux-PAM/doc/specs'
make[4]: *** [all] Error 2
make[4]: Leaving directory 
`/opt/emdebian/trunk/p/pam/trunk/pam-0.99.7.1/Linux-PAM/doc/specs'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory 
`/opt/emdebian/trunk/p/pam/trunk/pam-0.99.7.1/Linux-PAM/doc'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory 
`/opt/emdebian/trunk/p/pam/trunk/pam-0.99.7.1/Linux-PAM'
make[1]: *** [all] Error 2
make[1]: Leaving directory 
`/opt/emdebian/trunk/p/pam/trunk/pam-0.99.7.1/Linux-PAM'
make: *** [build-stamp] Error 2
dpkg-buildpackage: removing temporary directory

Now this is because pam does not support CC_FOR_BUILD which should be
used to allow cross-builds to use gcc to build internal tools that are
expected to be run during the build (and which would then have to be
cleaned and rebuilt if these were to be packaged).

These are the preliminary changes I need to make to support CC_FOR_BUILD:

Index: pam-0.99.7.1/Linux-PAM/configure.in
===================================================================
--- pam-0.99.7.1.orig/Linux-PAM/configure.in    2007-09-11
09:16:59.000000000 +0100 +++ pam-0.99.7.1/Linux-PAM/configure.in
2007-09-11 09:17:02.000000000 +0100 @@ -72,6 +72,12 @@
 PAM_LD_AS_NEEDED
 PAM_LD_O1
 
+if test x"$cross_compiling" = xyes; then
+       AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
+else
+       CC_FOR_BUILD="$CC"
+fi
+
 dnl Largefile support
 AC_SYS_LARGEFILE
 

Index: pam-0.99.7.1/Linux-PAM/doc/specs/Makefile.am
===================================================================
--- pam-0.99.7.1.orig/Linux-PAM/doc/specs/Makefile.am   2007-09-11
09:16:59.000000000 +0100 +++
pam-0.99.7.1/Linux-PAM/doc/specs/Makefile.am        2007-09-11
09:17:02.000000000 +0100 @@ -11,6 +11,8 @@ 
 AM_YFLAGS = -d
 
+CC = @CC_FOR_BUILD@
+
 BUILT_SOURCES = parse_y.h
 
 noinst_PROGRAMS = padout

(CC_FOR_BUILD support for cross-building in Debian is only available
via the experimental version of dpkg-cross (>= 1.99+2.0.0pre2-1) along
with apt-cross (>= 0.2.9) (from Emdebian SVN) and emdebian-tools (>=
0.3.9) (from Emdebian SVN) *and* a patched version of
dpkg-buildpackage from #439979 [0]. However, all these changes are
being incorporated into the main packages in due course.)

[0] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439979#10

As noted with the other changes, this change lets CC_FOR_BUILD default
to $CC if not cross-building so this change has no effect on normal
Debian builds.

Thankfully, CC_FOR_BUILD can be applied to this entire directory which
makes life easier.

This is what I tried (with a cleaned source tree and the above
experimental packages)

$ QUILT_PATCHES=debian/patches-applied/ quilt new 070_cross_build_tool
$ QUILT_PATCHES=debian/patches-applied/ quilt add -P 070_cross_build_tool 
Linux-PAM/configure.in
$ QUILT_PATCHES=debian/patches-applied/ quilt edit Linux-PAM/configure.in
$ QUILT_PATCHES=debian/patches-applied/ quilt edit 
Linux-PAM/doc/specs/Makefile.am
$ QUILT_PATCHES=debian/patches-applied/ quilt refresh -P 070_cross_build_tool
$ less debian/patches-applied/070_cross_build_tool 

I've attached the quilt patch file created but it doesn't work with the
rest of the quilt patches.

$ QUILT_PATCHES=debian/patches-applied/ quilt refresh

then modifies the autoconf patch which I don't think I really wanted to
do but that is what appears necessary to get quilt to allow the build
to proceed.

However, it appears I did something right - the patch correctly builds
a cross-built pam for arm! (The build log clearly shows that gcc - and
associated programs - is called only to build the internal tool,
arm-linux-gnu-gcc etc. elsewhere.) :-)

Date: Sun, 09 Sep 2007 16:53:33 +0100
Source: pam
Binary: libpam0g-dev libpam0g libpam-modules libpam-doc libpam-runtime 
libpam-cracklib
Architecture: source arm all
Version: 0.99.7.1-4em1

I now need to tweak the package a little more to remove the -doc
package and a few other things that are Emdebian-specific.

The relevant changes in debian/rules are:

+DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+# FOR AUTOCONF 2.52 AND NEWER ONLY
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+  confflags +=
+else
+  confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
+endif
+
 CFLAGS := -g -D_GNU_SOURCE -D_REENTRANT -fPIC 
-DCRACKLIB_DICTS=CRACKLIB_DICTPATH
 LDFLAGS := -Wl,-z,defs
 
@@ -40,7 +50,7 @@
 configure-stamp:
        cd $(BUILD_TREE) && \
        ./configure --sysconfdir=/etc --prefix=/usr --enable-static \
-       --enable-shared \
+       --enable-shared $(confflags) \
        --mandir=/usr/share/man --infodir=/usr/share/info --libdir=/lib \
        --sbindir=/sbin --enable-docdir=/usr/share/doc/libpam-doc \
        --with-mailspool=/var/mail

With the experimental dpkg-cross support, the new quilt file in
debian/patches-applied/ and the changes to debian/rules, pam will now
successfully cross-build. It's up to you whether to close this bug in a
pam upload containing these changes, re-assign/clone it to dpkg-cross
and/or set it as blocked by #439979.

Thanks.

-- 


Neil Williams
=============
http://www.data-freedom.org/
http://www.nosoftwarepatents.com/
http://www.linux.codehelp.co.uk/

Attachment: 070_cross_build_tool
Description: Binary data

Attachment: pgpqJ833AJz9Z.pgp
Description: PGP signature

Reply via email to