You are not logged in.

#1 2012-12-25 20:10:38

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

How to build a lib32 package

I edited the post to reflect a general question on how to create a lib32 package

Hello,

I am running an x86_64 system but need to run a 32bit version of the libfaktime package. However, the package is not in the multilib repo and I wanted to create a lib32 package myself.

The original PKGBUILD:

# $Id$
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Dan Serban
# Contributor: Ross Melin <rdmelin@gmail.com>

pkgname=libfaketime
pkgver=0.9.1
pkgrel=1
pkgdesc='Report fake dates and times to programs without having to change the system-wide time.'
arch=('i686' 'x86_64')
url='http://www.code-wizards.com/projects/libfaketime/'
license=('GPL2')
source=("http://www.code-wizards.com/projects/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        'libfaketime-0.9.1-fix-as-needed.patch'
        'libfaketime-0.9.1-fix-README-NEWS.patch')
md5sums=('ce3f996dfd5826b4ac62f1a7cc36ea27'
         '90873e4df35283463ef54b159c318686'
         'b1b641a8e2298aa1646982e3bde96117')

build() {
  cd "${pkgname}-${pkgver}"

  patch -p1 -i ../libfaketime-0.9.1-fix-as-needed.patch
  patch -p1 -i ../libfaketime-0.9.1-fix-README-NEWS.patch

  make
}

package() {
  cd "${pkgname}-${pkgver}"
  make PREFIX=/usr DESTDIR="${pkgdir}" install
}

The adapted PKGBUILD:

# $Id$
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Dan Serban
# Contributor: Ross Melin <rdmelin@gmail.com>

_pkgbasename=libfaketime
pkgname=lib32-${_pkgbasename}
pkgver=0.9.1
pkgrel=1
pkgdesc='Report fake dates and times to programs without having to change the system-wide time.'
arch=('x86_64')
url='http://www.code-wizards.com/projects/libfaketime/'
license=('GPL2')
depends=(lib32-glibc $_pkgbasename)
makedepends=(gcc-multilib)
source=("http://www.code-wizards.com/projects/${_pkgbasename}/${_pkgbasename}-${pkgver}.tar.gz"
        'libfaketime-0.9.1-fix-as-needed.patch'
        'libfaketime-0.9.1-fix-README-NEWS.patch')
md5sums=('ce3f996dfd5826b4ac62f1a7cc36ea27'
         '90873e4df35283463ef54b159c318686'
         'b1b641a8e2298aa1646982e3bde96117')

build() {
  cd "${_pkgbasename}-${pkgver}"

  patch -p1 -i ../libfaketime-0.9.1-fix-as-needed.patch
  patch -p1 -i ../libfaketime-0.9.1-fix-README-NEWS.patch

  export CC="gcc -m32"
  export CXX="g++ -m32"
  export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"

  sed -i -e 's/^\(USR\)\?LIBDIR\s*:=.*$/\1LIBDIR=\/usr\/lib32/' Makefile
  make CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
}

package() {
  cd "${_pkgbasename}-${pkgver}"
  make PREFIX=/usr DESTDIR="${pkgdir}" install

  rm -rf "${pkgdir}"/{usr/{include,share,bin,sbin},etc,{s,}bin}
}

makepkg fails with the following error:

[orschiro@thinkpad anothertry]$ makepkg
==> Making package: lib32-libfaketime 0.9.1-1 (Mi 26. Dez 12:45:22 CET 2012)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving Sources...
  -> Found libfaketime-0.9.1.tar.gz
  -> Found libfaketime-0.9.1-fix-as-needed.patch
  -> Found libfaketime-0.9.1-fix-README-NEWS.patch
==> Validating source files with md5sums...
    libfaketime-0.9.1.tar.gz ... Passed
    libfaketime-0.9.1-fix-as-needed.patch ... Passed
    libfaketime-0.9.1-fix-README-NEWS.patch ... Passed
==> Extracting Sources...
  -> Extracting libfaketime-0.9.1.tar.gz with bsdtar
==> Removing existing pkg/ directory...
==> Starting build()...
patching file src/Makefile
patching file Makefile
make -C src all
make[1]: Entering directory `/home/orschiro/libfaketime/anothertry/src/libfaketime-0.9.1/src'
gcc -o libfaketime.so.1 -Wl,-soname,libfaketime.so.1 faketime.o -Wl,-O1,--sort-common,--as-needed,-z,relro
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
faketime.o: In function `_ftpl_time':
faketime.c:(.text+0x3d): undefined reference to `dlsym'
faketime.c:(.text+0x49): undefined reference to `dlerror'
faketime.o: In function `ftime':
faketime.c:(.text+0x5f5): undefined reference to `dlsym'
faketime.c:(.text+0x601): undefined reference to `dlerror'
faketime.o: In function `gettimeofday':
faketime.c:(.text+0x6ad): undefined reference to `dlsym'
faketime.c:(.text+0x6b9): undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
make[1]: *** [libfaketime.so.1] Error 1
make[1]: Leaving directory `/home/orschiro/libfaketime/anothertry/src/libfaketime-0.9.1/src'
make: *** [all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...

What is the problem here?

Last edited by orschiro (2012-12-26 11:48:32)

Offline

#2 2012-12-25 21:01:15

ConnorBehan
Trusted User (TU)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,356
Website

Re: How to build a lib32 package

This isn't even a problem with cross compiling right? You just need something like

DLAGENTS=('http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u')

added to your makepkg.i686.conf.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#3 2012-12-25 21:42:51

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: How to build a lib32 package

Another try with this PKGBUILD

# $Id$
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Dan Serban
# Contributor: Ross Melin <rdmelin@gmail.com>

_pkgbasename=libfaketime
pkgname=lib32-${_pkgbasename}
pkgver=0.9.1
pkgrel=1
pkgdesc='Report fake dates and times to programs without having to change the system-wide time.'
arch=('x86_64')
url='http://www.code-wizards.com/projects/libfaketime/'
license=('GPL2')
makedepends=('gcc-multilib')
source=("http://www.code-wizards.com/projects/${_pkgbasename}/${_pkgbasename}-${pkgver}.tar.gz"
        'libfaketime-0.9.1-fix-as-needed.patch'
        'libfaketime-0.9.1-fix-README-NEWS.patch')
md5sums=('ce3f996dfd5826b4ac62f1a7cc36ea27'
         '90873e4df35283463ef54b159c318686'
         'b1b641a8e2298aa1646982e3bde96117')

build() {
  # Added for lib32 built
  export CC='gcc -m32'
  export CXX="g++ -m32"
  export PKG_CONFIG_PATH=/usr/lib32/pkgconfig

  cd "${_pkgbasename}-${pkgver}"

  patch -p1 -i ../libfaketime-0.9.1-fix-as-needed.patch
  patch -p1 -i ../libfaketime-0.9.1-fix-README-NEWS.patch
 
  make
}

package() {
  cd "${_pkgbasename}-${pkgver}"
  make PREFIX=/usr DESTDIR="${pkgdir}" install
}

This PKGBUILD sucessfully builds a package. However, the compiled library is still a 64bit and not 32bit one.

[orschiro@thinkpad faketime]$ file /home/orschiro/libfaketime/anothertry/pkg/usr/lib/faketime/libfaketime.so.1 
libfaketime.so.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x1789a66d6e5b369c32588f3ef24349621108c2f7, stripped

Last edited by orschiro (2012-12-26 11:53:52)

Offline

#4 2012-12-26 12:05:45

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: How to build a lib32 package

I adapted my post. Could a moderator please move the thread to the right forum? I guess it is not the right place in Newbie Corner.

Thanks.

Offline

#5 2012-12-26 23:54:42

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 4,149

Re: How to build a lib32 package

you probably need to add something to make to tell it to create a 32-bit program instead of a 64 bit one.

example : my lib32-mesa-r600g-git aur pacakge needs the CC and CXX flag -m32 , BUT i also have to add -enable-32bit as a configure flag to build a 32-bit version.


Booting with apg Openrc, NOT systemd.
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#6 2012-12-27 00:27:33

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,790

Re: How to build a lib32 package

orschiro wrote:

Could a moderator please move the thread to the right forum?

Moved to Creating & Modifying Packages. In future please use the 'report' button to contact us rather than relying on us reading your message by luck smile.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#7 2012-12-27 01:52:46

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: How to build a lib32 package

@ngoonee,

Thank you for that hint. Strangely I never paid attention to the Report link albeit being just next to the Quote link. big_smile

example : my lib32-mesa-r600g-git aur pacakge needs the CC and CXX flag -m32 , BUT i also have to add -enable-32bit as a configure flag to build a 32-bit version.

What if a package does not use a configure file where I could set the flag such as in my case with the libfaketime package?

Is the best approach to provide a patch with the PKGBUILD that adds the flag to the Makefile?

Offline

#8 2012-12-27 02:02:09

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,790

Re: How to build a lib32 package

orschiro wrote:

example : my lib32-mesa-r600g-git aur pacakge needs the CC and CXX flag -m32 , BUT i also have to add -enable-32bit as a configure flag to build a 32-bit version.

What if a package does not use a configure file where I could set the flag such as in my case with the libfaketime package?

Is the best approach to provide a patch with the PKGBUILD that adds the flag to the Makefile?

Depends on your software, but if you want to provide a 32-bit binary you do need to compile it with the flags. Since the project doesn't use a configure script then you'd have to manually modify the makefile. Probably an sed job or two.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#9 2012-12-27 12:49:09

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: How to build a lib32 package

Thank you guys. Instead of sed I created a patch since not only the flags had to be changed but a couple of other things such as changing the /usr/lib to /usr/lib32 directory.

The PKBUILD now looks as follows:

# $Id$
# Maintainer: Robert Orzanna <orschiro@gmail.com>
# Contributor: Dan Serban
# Contributor: Ross Melin <rdmelin@gmail.com>

_pkgbasename=libfaketime
pkgname=lib32-$_pkgbasename
pkgver=0.9.1
pkgrel=1
pkgdesc='Report fake dates and times to programs without having to change the system-wide time.'
arch=('x86_64')
url='http://www.code-wizards.com/projects/libfaketime/'
license=('GPL2')
source=("http://www.code-wizards.com/projects/${_pkgbasename}/${_pkgbasename}-${pkgver}.tar.gz"
        'libfaketime-0.9.1-fix-as-needed.patch'
        'libfaketime-0.9.1-fix-README-NEWS.patch'
        'lib32.patch')
md5sums=('ce3f996dfd5826b4ac62f1a7cc36ea27'
         '90873e4df35283463ef54b159c318686'
         'b1b641a8e2298aa1646982e3bde96117'
         'c1fe2d8caf53450cf76e5939ea7ccd98')

build() {
  cd "${_pkgbasename}-${pkgver}"

  patch -p1 -i ../libfaketime-0.9.1-fix-as-needed.patch
  patch -p1 -i ../libfaketime-0.9.1-fix-README-NEWS.patch
  patch -p1 -i ../lib32.patch

  make
}

package() {
  cd "${_pkgbasename}-${pkgver}"
  make PREFIX=/usr DESTDIR="${pkgdir}" install
}

The lib32.patch

diff -aur old/Makefile new/Makefile
--- old/Makefile	2011-11-28 19:38:11.000000000 +0100
+++ new/Makefile	2012-12-27 13:37:39.422906389 +0100
@@ -1,9 +1,5 @@
 all:
 	$(MAKE) -C src all
-	$(MAKE) -C test all
-
-test:
-	$(MAKE) -C test all
 
 install:
 	$(MAKE) -C src install
@@ -21,10 +17,8 @@
 
 clean:
 	$(MAKE) -C src clean
-	$(MAKE) -C test clean
 
 distclean:
 	$(MAKE) -C src distclean
-	$(MAKE) -C test distclean
 
-.PHONY: all test install uninstall clean distclean
+.PHONY: all install uninstall clean distclean
diff -aur old/src/Makefile new/src/Makefile
--- old/src/Makefile	2012-01-11 21:27:41.000000000 +0100
+++ new/src/Makefile	2012-12-27 13:38:49.773576667 +0100
@@ -52,8 +52,8 @@
 
 PREFIX = /usr/local
 
-CFLAGS += -std=gnu99 -Wall -DFAKE_STAT -DFAKE_INTERNAL_CALLS -fPIC -DPOSIX_REALTIME -DLIMITEDFAKING -DSPAWNSUPPORT
-LDFLAGS += -shared -ldl -lm -lpthread
+CFLAGS += -std=gnu99 -Wall -DFAKE_STAT -DFAKE_INTERNAL_CALLS -fPIC -DPOSIX_REALTIME -DLIMITEDFAKING -DSPAWNSUPPORT -m32
+LDFLAGS += -shared -ldl -lm -lpthread -m32
 
 SRC = faketime.c
 OBJ = faketime.o faketimeMT.o
@@ -79,14 +79,14 @@
 
 install: ${LIBS}
 	@echo 
-	@echo "Copying the faketime libraries to ${DESTDIR}${PREFIX}/lib/faketime and the faketime wrapper script to ${DESTDIR}${PREFIX}/bin ..."
-	$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/lib/faketime/"
-	$(INSTALL) -m0644 ${LIBS} "${DESTDIR}${PREFIX}/lib/faketime/"
+	@echo "Copying the faketime libraries to ${DESTDIR}${PREFIX}/lib32/faketime and the faketime wrapper script to ${DESTDIR}${PREFIX}/bin ..."
+	$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/lib32/faketime/"
+	$(INSTALL) -m0644 ${LIBS} "${DESTDIR}${PREFIX}/lib32/faketime/"
 	$(INSTALL) -Dm0755 faketime "${DESTDIR}${PREFIX}/bin/faketime"
 
 uninstall:
-	for f in ${LIBS}; do rm -f "${DESTDIR}${PREFIX}/lib/faketime/$$f"; done
-	rmdir "${DESTDIR}${PREFIX}/lib/faketime"
+	for f in ${LIBS}; do rm -f "${DESTDIR}${PREFIX}/lib32/faketime/$$f"; done
+	rmdir "${DESTDIR}${PREFIX}/lib32/faketime"
 	rm -f "${DESTDIR}${PREFIX}/bin/faketime"
 
 .PHONY: all clean distclean install uninstall

When looking at other lib32 packages from multilib repo I wonder though when the following lines are needed since my PKGBUILD builds the 32bit libraries without these lines.

depends=('lib32-glib2>=2.25.17' $_pkgbasename)

Does the lib32 package have to depend on the original one?

makedepends=('gcc-multilib')
options=('!libtool')

When do I need these lines?

 export CC="gcc -m32"
 export CXX="g++ -m32"
 export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"

And when do I need to export the flags like that?

Last edited by orschiro (2012-12-27 12:50:29)

Offline

#10 2012-12-28 03:05:40

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 6,790

Re: How to build a lib32 package

orschiro wrote:

When looking at other lib32 packages from multilib repo I wonder though when the following lines are needed since my PKGBUILD builds the 32bit libraries without these lines.

depends=('lib32-glib2>=2.25.17' $_pkgbasename)

Does the lib32 package have to depend on the original one?

Well, if you don't have the original one, it won't work (it would build, but not work), same case with lib32-glib2.

orschiro wrote:
makedepends=('gcc-multilib')
options=('!libtool')

When do I need these lines?

man PKGBUILD and search for options/libtool. makedepends are of course necessary, could you build your package if gcc-multilib is not installed?

For both depends and makedepends, of course your package still builds without those lines, because you DO have those packages already installed (you're obviously not using a clean chroot).

orschiro wrote:
 export CC="gcc -m32"
 export CXX="g++ -m32"
 export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"

And when do I need to export the flags like that?

Depends on your package and whether the configure/makefile/whatever-magic-build-used honors those env variables. Most should.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB