PKGBUILD example

This example shows how to install packages on on OviOS Linux using makepkg and pacman

Can use both root or ovios (recommended)

1. Create a directory where you will build the new package


ovios-indt:~ # id
uid=1000(ovios) gid=1001(ovios) groups=1001(ovios)
ovios-indt:~ # mkdir parted
ovios-indt:~ # cd parted/
ovios-indt:~/parted #


2. Create a file called PKGBUILD

Available editors: nano or vi / vim.

This file MUST be called PKGBUILD

2.1. A simple example of a PKGBUILD for parted

ovios-indt:~/parted # cat PKGBUILD
pkgname=parted
pkgver=3.2
pkgrel=1
arch=(x86_64)
source=(ftp://ftp.gnu.org/gnu/parted/parted-3.2.tar.xz)

build() {
cd $pkgname-$pkgver
./configure --prefix=/usr \
        --disable-static
make
}

package() {
cd $pkgname-$pkgver
make DESTDIR=${pkgdir} install
}
ovios-indt:~/parted #


If you get this error:

==> ERROR: Unknown download protocol: http
    Aborting...

Download the source before and and change the source line in PKGBUILD to point to the file.

EX: source=(parted-3.2.tar.xz)

This will tell makepkg to look for the source in the build directory (in this case "parted")

2.2. A more detailed example of how to build binutils on OviOS

# Maintainer: Ovi Chis <ovi@ovios.org>
pkgname=binutils
pkgver=2.35.1
pkgrel=1
pkgdesc='A set of programs to assemble and manipulate binary and object files'
arch=(x86_64)
url='https://www.gnu.org/software/binutils/'
license=(GPL)
groups=(ovios)
depends=('zlib' 'glibc')
options=(!libtool !docs)

source=(https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz{,.sig})

build() {
  cd "$srcdir/$pkgname-$pkgver" 
  mkdir -v ../binutils-build 
  cd ../binutils-build 
  ../"$pkgname-$pkgver"/configure \
    --prefix=/usr \
    --with-lib-path=/usr/lib:/usr/local/lib \
    --enable-cet \
    --enable-deterministic-archives \
    --enable-gold \
    --enable-ld=default \
    --enable-lto \
    --enable-plugins \
    --enable-relro \
    --enable-shared \
    --enable-targets=x86_64-pep \
    --enable-threads \
    --disable-gdb \
    --disable-werror \
    --with-debuginfod \
    --with-pic \
    --with-system-zlib

    make configure-host
    make tooldir=/usr
}


package() {
  mkdir -p $pkgdir/usr/include
  cd "$srcdir/$pkgname-$pkgver" 
  cd ../binutils-build 
  make prefix="$pkgdir/usr" tooldir="$pkgdir/usr" install

  # Remove unwanted files
  rm -f "$pkgdir"/usr/share/man/man1/{dlltool,nlmconv,windres,windmc}*

  # No shared linking to these files outside binutils
  rm -f "$pkgdir"/usr/lib/lib{bfd,opcodes}.so
  echo 'INPUT( /usr/lib/libbfd.a -liberty -lz -ldl )' > "$pkgdir/usr/lib/libbfd.so"
  echo 'INPUT( /usr/lib/libopcodes.a -lbfd )' > "$pkgdir/usr/lib/libopcodes.so"
}


3. Update the md5sums, otherwise makepkg will error out.

Or skip all the security checks (unrecommended)

See makepkg --help for details how to skip some checks

ovios-indt:~/parted # makepkg
==> Making package: parted 3.2-1 (Tue Jul 26 06:18:12 EDT 2016)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found parted-3.2.tar.xz
==> ERROR: Integrity checks are missing for: source

Run 'makepkg -g >>PKGBUILD' to update PKGBULD with the checksums needed


ovios-indt:~/parted # makepkg -g >> PKGBUILD
==> Retrieving sources...
  -> Found parted-3.2.tar.xz
==> Generating checksums for source files...
ovios-indt:~/parted #


Now the package can be built:


ovios-indt:~/parted # makepkg
==> Making package: parted 3.2-1 (Tue Jul 26 06:13:40 EDT 2016)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found parted-3.2.tar.xz
==> Validating source files with md5sums...
    parted-3.2.tar.xz ... Passed
==> Extracting sources...
  -> Extracting parted-3.2.tar.xz with bsdtar
==> Starting build()...
...


4. Install with pacman:


ovios-indt:~/parted # su
Password:
bash-4.3# pacman -U parted-3.2-1-x86_64.pkg.tar.gz

5. Run parted:


bash-4.3# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)


Note: If the shared libraries are not found after installing a new package, run 'ldconfig' as root.


bash-4.3# ldconfig
bash-4.3#

PKGBUILD Template:


pkgname=
pkgver=
pkgrel=1
arch=(x86_64)
source=()

build() {
cd $pkgname-$pkgver
./configure --prefix=/usr
make
}

package() {
cd $pkgname-$pkgver
make DESTDIR=${pkgdir} install
}


IMPORTANT: In OviOS Linux, the 'init' directory is /etc/rc.d/init.d

Make sure any packages that require to install in this directory use the correct path. /etc/init.d/ is just a link to /etc/rc.d/init.d

If your PKGBUILD must define some init scripts, do not use something like this:

mkdir -p $pkgdir/etc/init.d

It should be:

mkdir -p $pkgdir/etc/rc.d/init.d