You are not logged in.

#1 2012-06-03 12:26:41

Amzo2
Member
Registered: 2012-06-02
Posts: 50

Manually Create Packages

I know this may sound a little strange, and you'll be wondering... "Why don't you just use makepkg?

Well, I don't actually use Arch Linux, and have always used FreeBSD, but I was interested in pacman , which I decided to port and run on FreeBSD, all is well, but now I'm stuck at creating packages from within the ports.

The idea was to make a script, which would build the port, then package up the binary files that are in 'work/$portname-$portversion' and create packages that would be compatible with pacman .

I was wondering if anyone knew the steps to manually create packages from a compiled source, so then I can implement it into a working script to use with my port tree.

Any help would be greatly appreciated.

[amzo@Bahamut ~]$ uname -a ; pacman -V
FreeBSD Bahamut 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:15:25 UTC 2012     root@obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

 .--.                  Pacman v4.0.3 - libalpm v7.0.3

Offline

#2 2012-06-03 13:11:37

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,835

Re: Manually Create Packages

I still think you should explain why you won't "just use makepkg", but in the meantime, at least have a read through it - in particular, look at the -R/--repackage option, which repackages without recompiling.

Offline

#3 2012-06-03 13:15:38

Amzo2
Member
Registered: 2012-06-02
Posts: 50

Re: Manually Create Packages

The reason I won't use Makepkg, is because the PKGBUILDS, won't build under FreeBSD. I've kinda made a working script to make packages, but it's no where near advance as makepkg is.

Well, it seems to be working fine for now, but doesn't handle dependencies well.


#!/bin/bash

me=`basename $0`
myver='1.0'
startdir=`pwd`
pkgname=`grep PORTNAME= Makefile | awk '{print $2}'`
pkgver=`grep PORTVERSION= Makefile | awk '{print $2}'`
[ -f /etc/makepkg.conf ] && . /etc/makepkg.conf

strip_url() {
  echo $1 | sed 's|^.*://.*/||g'
}

if [ ! -f $startdir/Makefile ]; then
  echo "error: Are you in the port directory?"
  exit
fi


# Make pkg dir
mkdir -p pkg

# build
echo "==> Building Package..."
make PREFIX=$startdir/pkg install

# write the .PKGINFO file
echo "==> Generating .PKGINFO file..."
cd $startdir/pkg
echo "# Generated by makepkg $myver" >.PKGINFO
echo -n "# " >>.PKGINFO
date >>.PKGINFO
echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver" >>.PKGINFO

# remove info files
cd $startdir
rm -rf pkg/usr/info pkg/usr/share/info

# strip binaries
cd $startdir
echo "==> Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local}/lib -type f \
   -exec /usr/bin/strip --strip-debug '{}' ';'
echo "==> Stripping symbols from binaries..."
find pkg/{,usr,usr/local}/{bin,sbin} -type f \
   -exec /usr/bin/strip '{}' ';'

# tar it up
echo "==> Compressing package..."
cd $startdir/pkg
tar czvf $startdir/$pkgname-$pkgver.pkg.tar.gz .PKGINFO *

cd $startdir
echo "==> Finished";

And the packages play fine with pacman. Wooo big_smile

[amzo@Bahamut /usr/ports/x11-wm/dwm]$ sudo pacman -U dwm-6.0.pkg.tar.gz 
loading packages...
resolving dependencies...
looking for inter-conflicts...

Targets (1): dwm-6.0


Proceed with installation? [Y/n] y
(1/1) checking package integrity                                                                                               [#############################################################################] 100%
(1/1) loading package files                                                                                                    [#############################################################################] 100%
(1/1) checking for file conflicts                                                                                              [#############################################################################] 100%
(1/1) checking available disk space                                                                                            [#############################################################################] 100%
(1/1) installing dwm                                                                                                           [#############################################################################] 100%

The only problem that this brings to the field, is that it doesn't play nice with the database:

error: invalid name for database entry 'dwm-6.0'

Maybe someone could help me here a bit, someone who's more experienced with creating packages?

Last edited by Amzo2 (2012-06-03 13:42:07)

Offline

#4 2012-06-03 13:44:05

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,835

Re: Manually Create Packages

"the PKGBUILDS won't build"... a bit vague, don't you think?

I know very little about *BSD, but I would expect that you would have to change things to some degree to get makepkg and pacman working as intended. How about taking one or two representative PKGBUILDs and digging a bit deeper to establish why they "won't build"?

Offline

#5 2012-06-03 14:00:05

Amzo2
Member
Registered: 2012-06-02
Posts: 50

Re: Manually Create Packages

It's due to the way the ports build, they don't use gnumake, but their own version of make. This version of make has a huge list of .mk files which contains system variables, for building software from the port. This includes patches, options etc. If I were to try and build with a PKGBUILD, it would just error. So to make makepkg work with a pkgbuild, it would require me rewriting every PKGBUILD I wanted to use.

So the simplest way for me, was to find a way to make a package using the ports, since then, all the software already has a Makefile. and once I make the working script to work with the make files and ports, I will need no more work, but to run the script and have the package created.

That's the best as I can explain it. ;p

Offline

#6 2012-06-03 20:48:15

Amzo2
Member
Registered: 2012-06-02
Posts: 50

Re: Manually Create Packages

Well I managed to fix the database issue by passing the value from PORTREVISION into the package naming. So everything is working fine now, just a few little bugs. So now it's just to fix them and make my local repo for my FreeBSD machines:

Removing a package:

[amzo@Bahamut /usr/ports/irc]$ sudo pacman -R irssi
checking dependencies...

Targets (1): irssi-0.8.15-1

Do you want to remove these packages? [Y/n] y
(1/1) removing irssi     [##] 100%

Checking packages:

[amzo@Bahamut /usr/ports/irc]$ pacman -Qs irssi
[amzo@Bahamut /usr/ports/irc]$ irssi
bash: /bin/irssi: No such file or directory 

Reinstalling:

[amzo@Bahamut /usr/ports/irc]$ sudo pacman -U irssi/irssi-0.8.15.pkg.tar.gz 
loading packages...
resolving dependencies...
looking for inter-conflicts...

Targets (1): irssi-0.8.15-1

Proceed with installation? [Y/n] y
(1/1) checking package integrity         [###############] 100%
(1/1) loading package files                  [###############] 100%
(1/1) checking for file conflicts            [###############] 100%
(1/1) checking available disk space    [###############] 100%
(1/1) installing irssi                              [###############] 100% 

And running it:

[amzo@Bahamut /usr/ports/irc]$ irssi -v
irssi 0.8.15 (20100403 1617) 

The makepkg I wrote to use the FreeBSD ports isn't nearly as advance as the one on Arch Linux, but it makes working packages for now. I'll have to improve it.

Offline

Board footer

Powered by FluxBB