Difference between revisions of "VCS package guidelines"

From ArchWiki
Jump to: navigation, search
m (moved Arch CVS & SVN PKGBUILD guidelines to VCS PKGBUILD guidelines: This page is not specific to cvs and svn...)
(cleanup)
Line 5: Line 5:
 
[[Category:Guidelines (English)]]
 
[[Category:Guidelines (English)]]
  
:''This is actually very easy and doesn't require any special knowledge.  However, the more you know about cvs and svn the easier it is.  Many people introduce custom variables into the PKGBUILD that can overcomplicate things.  These are not ''really'' necessary but do help to clarify the syntax of the cvs/svn/git commands, which can appear quite complex.''
+
==Prototypes==
 
 
{{i18n_links_start}}
 
{{i18n_entry|English|Arch CVS %26 SVN PKGBUILD guidelines}}
 
{{i18n_entry|繁體中文|Arch CVS %26 SVN PKGBUILD 編寫指南}}
 
{{i18n_entry|简体中文|Arch CVS %26 SVN %26 GIT PKGBUILD 编写指南}}
 
{{i18n_links_end}}
 
  
 +
abs provides a prototype for cvs, svn, git and darcs. Just do ''pacman -S abs'' and look in ''/usr/share/pacman''.
  
 
==A few tips==
 
==A few tips==
  
 
* Suffix <code>pkgname</code> with <code>-cvs</code> or <code>-svn</code> or <code>-git</code> where applicable - this prevents confusion with non-development versions e.g. fluxbox-svn or fvwm-cvs vs fluxbox and fvwm.
 
* Suffix <code>pkgname</code> with <code>-cvs</code> or <code>-svn</code> or <code>-git</code> where applicable - this prevents confusion with non-development versions e.g. fluxbox-svn or fvwm-cvs vs fluxbox and fvwm.
* When makepkg is run it will check for newer revisions and then bump pkgver to the latest. If this is not what you want see the --holdver in [http://www.archlinux.org/pacman/makepkg.8.html man makepkg]
+
* When makepkg is run it will check for newer revisions and then bump pkgver to the latest. If this is not what you want see the --holdver in [http://www.archlinux.org/pacman/makepkg.8.html man makepkg]. Note that this only works correctly for cvs and svn, which allow to checkout an older date or revision.
 
* You must also be careful about pacman conflicts.  For example fluxbox-svn will conflict with fluxbox.  In this case you need to use the <tt>conflicts=</tt> field
 
* You must also be careful about pacman conflicts.  For example fluxbox-svn will conflict with fluxbox.  In this case you need to use the <tt>conflicts=</tt> field
 
  conflicts=('fluxbox')
 
  conflicts=('fluxbox')
Line 23: Line 18:
 
  provides=('fluxbox')
 
  provides=('fluxbox')
 
: You should AVOID using <tt>replaces=</tt> it generally causes unnecessary problems
 
: You should AVOID using <tt>replaces=</tt> it generally causes unnecessary problems
*When using/defining the cvsroot use anonymous<b>:</b>@ rather than anonymous@ to avoid having to press enter to give blank password ''OR'' anonymous<b>:password</b>@ - if a password is required.
+
* When using/defining the cvsroot use anonymous<b>:</b>@ rather than anonymous@ to avoid having to press enter to give blank password ''OR'' anonymous<b>:password</b>@ - if a password is required.
* cvs and svn PKGBUILDs may not require a source or md5sum array but these fields '''must''' be included in the PKGBUILD if you wish to submit it to the AUR, otherwise the pkg will be rejected.  They may be left blank though.
 
<pre>source=()
 
md5sums=()</pre>
 
 
* Though it is often unneccesary to use the pkgrel field when building CVS/SVN/GIT pkgs (any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver [assuming pkgver is used to hold a date format], makepkg will require it.
 
* Though it is often unneccesary to use the pkgrel field when building CVS/SVN/GIT pkgs (any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver [assuming pkgver is used to hold a date format], makepkg will require it.
* don't forget to include cvs or subversion in <code>makedepends=</code> as necessary
+
* don't forget to include the appropriate vcs tool (cvs,subversion,git,...) in <code>makedepends=</code> as necessary
 
* to preserve the integrity of the checked out code it is usually possible to build in a separate build dir e.g. having checked out source code to src/$_cvsmod from $startdir you can use:
 
* to preserve the integrity of the checked out code it is usually possible to build in a separate build dir e.g. having checked out source code to src/$_cvsmod from $startdir you can use:
 
<pre>  mkdir src/$_cvsmod-build
 
<pre>  mkdir src/$_cvsmod-build
Line 38: Line 30:
 
   cd src/$_cvsmod-build</pre>
 
   cd src/$_cvsmod-build</pre>
  
* With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables
+
* With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables. makepkg will automatically bumps the pkgver anyway when building the package (unless --holdver is used).
** For cvs pkgs you should avoid <code>pkgver=`date +%y%m%d`</code> - this also interferes with the functionality of the AUR. Instead it is still possible to use a date format for the $pkgver variable and to use the cvs -D option to check out code from that date (see below)
 
** For svn you can use the revision number.  An easy way to find the revision number is to use the following command:
 
svn log $_svntrunk --limit 1 | sed -e '/^r/!d' -e 's/^r\([0-9]\+\) .*/\1/;q'
 
That command grabs the most recent log entry from the svn repo and finds the revision number, which is prefixed with an r.  This is from the fluxbox svn log, the revision number is in the top left, r4084
 
<pre>
 
------------------------------------------------------------------------
 
r4084 | mathias | 2005-07-20 19:29:01 +0100 (Wed, 20 Jul 2005) | 16 lines
 
 
 
Changed some *Focus options, just to make some things a bit more clear.
 
the "Sloppy" was always a bit .. imprecise.
 
</pre>
 
 
 
==Example CVS PKGBUILD==
 
 
 
Here is a PKGBUILD for bmp-cvs that utilizes some of the tips above:
 
 
 
<pre># Contributor:  Lukas Sabota <punkrockguy318@comcast.net>
 
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
 
 
 
pkgname=bmp-cvs
 
pkgver=20050728
 
pkgrel=1
 
pkgdesc="A multimedia player that uses the WinAmp 2.x UI, GTK2, and is based on XMMS"
 
url="http://beepmp.sourceforge.net/"
 
arch=('i686' 'x86_64')
 
license=('GPL')
 
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')
 
provides=('bmp')
 
conflicts=('bmp')
 
makedepends=('cvs')
 
install=(${pkgname}.install)
 
 
 
_cvsroot=":pserver:anonymous:@beepmp.cvs.sourceforge.net:/cvsroot/beepmp"
 
_cvsmod="bmp"
 
 
 
build() {
 
  cd ${srcdir}
 
 
 
  msg "Connecting to $_cvsmod.sourceforge.net CVS server...."
 
  if [ -d $_cvsmod/CVS ]; then
 
    cd $_cvsmod
 
    cvs -z3 update -d
 
  else
 
    cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod
 
    cd $_cvsmod
 
  fi
 
  ./autogen.sh
 
 
 
  msg "CVS checkout done or server timeout"
 
  msg "Starting make..."
 
 
 
  cp -r ../$_cvsmod ../$_cvsmod-build
 
  cd ../$_cvsmod-build
 
 
 
  ./configure --prefix=/usr
 
  make || return 1
 
  make DESTDIR=${pkgdir} install || return 1
 
 
 
  install -d ${pkgdir}/usr/share/xmms/Skins
 
  mv ${pkgdir}/usr/share/bmp/Skins/* ${pkgdir}/usr/share/xmms/Skins
 
  rmdir ${pkgdir}/usr/share/bmp/Skins
 
 
 
  rm -r ${srcdir}/$_cvsmod-build
 
}
 
# vim:syntax=sh
 
</pre>
 
 
 
==Example SVN PKGBUILD==
 
 
 
If you use the <tt>source</tt> command on the PKGBUILD first it will store the _svntrunk and _svnmod variables.  So if you run :
 
source PKGBUILD
 
svn info $_svntrunk
 
you can get the revision number(Or,Last Changed Rev) which can be used in pkgver
 
 
 
<pre>
 
# Contributor:  Lukas Sabota <punkrockguy318@comcast.net>
 
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
 
 
 
pkgname=fluxbox-svn
 
pkgver=4084
 
pkgrel=1
 
pkgdesc="The bleeding edge version of a lightweight yet \
 
        customizable windowmanager for X"
 
url="http://www.fluxbox.org/"
 
arch=('i686' 'x86_64')
 
license=('GPL')
 
depends=('bash' 'x-server')
 
makedepends=('subversion')
 
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')
 
provides=('fluxbox')
 
 
 
source=()
 
md5sums=()
 
 
 
_svntrunk=svn://svn.berlios.de/fluxbox/trunk
 
_svnmod=fluxbox
 
 
 
build() {
 
  cd ${srcdir}
 
 
 
  if [ -d $_svnmod/.svn ]; then
 
    (cd $_svnmod && svn up -r $pkgver)
 
  else
 
    svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod
 
  fi
 
 
 
  msg "SVN checkout done or server timeout"
 
  msg "Starting make..."
 
 
 
  cp -r $_svnmod $_svnmod-build
 
  cd $_svnmod-build
 
 
 
  ./autogen.sh
 
 
 
  # fix for crap fb issue
 
  mkdir data
 
  cp ../$_svnmod/data/keys data/
 
 
 
  ./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug
 
  make || return 1
 
  make DESTDIR=${pkgdir} install || return 1
 
 
 
  rm -rf ${srcdir}/$_svnmod-build
 
}
 
# vim:syntax=sh</pre>
 
 
 
==Example GIT PKGBUILD==
 
 
 
<pre>
 
# Contributor: Your Name <your@mail.org>
 
 
 
pkgname=compiz-git
 
pkgver=20080523
 
pkgrel=1
 
pkgdesc="Composite and window manager for Xgl"
 
url="http://en.opensuse.org/Compiz"
 
arch=('i686' 'x86_64')
 
license=('GPL')
 
depends=('xgl-cvs' 'mesa-xgl-cvs' 'cairo-devel' 'libxevie' \
 
        'startup-notification' 'libpng'  'libxdamage' \
 
        'libxrandr' 'libwnck-compiz' 'gnome-desktop' 'control-center' \
 
        'libsvg-cairo' 'libxcomposite')
 
makedepends=('git')
 
conflicts=()
 
replaces=()
 
backup=()
 
install=('compiz.install')
 
source=(compiz-intel-copy-pixel-issue-workaround-1.diff)
 
md5sums=('10a157b86d528bca2be6731c5eaff7b3')
 
 
 
_gitroot="git://anongit.freedesktop.org/git/xorg/app/compiz"
 
_gitname="compiz"
 
 
 
build() {
 
export CFLAGS="$CFLAGS -I/opt/mesa-xgl-cvs/include"
 
  cd ${srcdir}
 
  msg "Connecting to git.freedesktop.org GIT server...."
 
 
 
  if [ -d ${srcdir}/$_gitname ] ; then
 
  cd $_gitname && git pull origin
 
  msg "The local files are updated."
 
  else
 
  git clone --depth 1 $_gitroot $_gitname
 
  fi
 
 
 
  msg "GIT checkout done or server timeout"
 
  msg "Starting make..."
 
 
 
  git clone $_gitname $_gitname-build
 
  cd ${srcdir}/$_gitname-build
 
  patch -Np0 -i ${srcdir}/compiz-intel-copy-pixel-issue-workaround-1.diff
 
 
 
  ACLOCAL="aclocal -I /opt/gnome/share/aclocal" ./autogen.sh --host=${CHOST} \
 
    --prefix=/usr \
 
    --infodir=/usr/share/info \
 
    --mandir=/usr/share/man \
 
    --sysconfdir=/opt/gnome/etc \
 
    --enable-gnome \
 
    --enable-libsvg-cairo \
 
    --enable-gconf-dump \
 
    --disable-kde || return 1
 
  make || return 1
 
  make DESTDIR=${pkgdir} install || return 1
 
 
 
  find ${pkgdir} -type f -name '*.la' -exec rm {} \;
 
}
 
</pre>
 
As you see, I use "-git" suffix in the pkgname, and two variables, _gitroot and _gitname for identify the repositories and the name of the package.
 
I need to introduce an if condition:
 
<pre>
 
if [ -d ${srcdir}/$_gitname ] ; then
 
cd $_gitname && git pull origin
 
msg "The local files are updated."
 
else
 
git clone --depth 1 $_gitroot $_gitname
 
fi
 
</pre>
 
because we have two commands, one for updating source and one for getting it. I copy the source code in a "-build" directory ( the same thing that we do with -cvs and -svn program ).
 
 
 
==Example darcs PKGBUILD==
 
<pre>
 
# Contributor: Your Name <your@mail.org>
 
 
 
pkgname=psi-darcs
 
pkgver=20070404
 
pkgrel=2
 
pkgdesc="Psi - Jabber client (with SSL support) darcs version"
 
url="http://psi-im.org/"
 
arch=('i686' 'x86_64')
 
license=('')
 
depends=('qt4>=4.2' 'openssl' 'libxss' 'cyrus-sasl' 'aspell')
 
makedepends=('darcs' 'qt4>=4.2')
 
conflicts=('psi')
 
provides=('psi')
 
source=()
 
md5sums=()
 
 
 
_darcsmod="psi"
 
_darcstrunk="http://dev.psi-im.org/darcs"
 
 
 
build() {
 
  cd ${srcdir}
 
 
 
  # Erasing previous build
 
  msg "Checking for previous build"
 
  # get the sources
 
  if [[ -d $_darcsmod/_darcs ]]
 
  then
 
    msg "Retrieving missing patches"
 
    cd $_darcsmod
 
    darcs pull -a $_darcstrunk/$_darcsmod
 
  else
 
    msg "Retrieving complete sources"
 
    darcs get --partial --set-scripts-executable $_darcstrunk/$_darcsmod
 
    cd $_darcsmod
 
  fi
 
 
 
  . /etc/profile.d/qt4.sh
 
  export PATH=$QTDIR/bin:$PATH
 
 
 
  # Building
 
  msg "Starting build"
 
  ./configure --prefix=/usr --disable-xmms
 
  make || return 1
 
  make INSTALL_ROOT=${pkgdir} install || return 1
 
}
 
</pre>
 
 
 
==rc-script PROTO==
 
<pre>
 
#!/bin/bash
 
 
 
daemon_name=DAEMON_NAME
 
 
 
. /etc/rc.d/functions
 
 
 
. /etc/conf.d/$daemon_name.conf
 
 
 
. /etc/rc.conf
 
 
 
get_pid() {
 
      pidof $daemon_name
 
}
 
 
 
case "$1" in
 
start)
 
  stat_busy "Starting $daemon_name daemon"
 
 
 
  PID=`get_pid`
 
  if [ -z "$PID" ]; then
 
    [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
 
    # RUN
 
    $daemon_name
 
    #
 
    if [ $? -gt 0 ]; then
 
      stat_fail
 
      exit 1
 
    else
 
      echo `get_pid` > /var/run/$daemon_name.pid
 
      add_daemon $daemon_name
 
      stat_done
 
    fi
 
  else
 
    stat_fail
 
    exit 1
 
  fi
 
  ;;
 
 
 
stop)
 
  stat_busy "Stopping $daemon_name daemon"
 
  PID=`get_pid`
 
  # KILL
 
  [ ! -z "$PID" ] && kill $PID &> /dev/null
 
  #
 
  if [ $? -gt 0 ]; then
 
    stat_fail
 
    exit 1
 
  else
 
    rm -f /var/run/$daemon_name.pid &> /dev/null
 
    rm_daemon $daemon_name
 
    stat_done
 
  fi
 
  ;;
 
 
 
restart)
 
  $0 stop
 
  sleep 3
 
  $0 start
 
  ;;
 
*)
 
  echo "usage: $0 {start|stop|restart}"
 
esac
 
exit 0
 
</pre>
 
  
 
== Useful Links ==
 
== Useful Links ==

Revision as of 11:47, 4 October 2009


Prototypes

abs provides a prototype for cvs, svn, git and darcs. Just do pacman -S abs and look in /usr/share/pacman.

A few tips

  • Suffix pkgname with -cvs or -svn or -git where applicable - this prevents confusion with non-development versions e.g. fluxbox-svn or fvwm-cvs vs fluxbox and fvwm.
  • When makepkg is run it will check for newer revisions and then bump pkgver to the latest. If this is not what you want see the --holdver in man makepkg. Note that this only works correctly for cvs and svn, which allow to checkout an older date or revision.
  • You must also be careful about pacman conflicts. For example fluxbox-svn will conflict with fluxbox. In this case you need to use the conflicts= field
conflicts=('fluxbox')
You should also use the provides= field so that pkgs that require fluxbox to be installed recognize your fluxbox-svn pkg as fluxbox
provides=('fluxbox')
You should AVOID using replaces= it generally causes unnecessary problems
  • When using/defining the cvsroot use anonymous:@ rather than anonymous@ to avoid having to press enter to give blank password OR anonymous:password@ - if a password is required.
  • Though it is often unneccesary to use the pkgrel field when building CVS/SVN/GIT pkgs (any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver [assuming pkgver is used to hold a date format], makepkg will require it.
  • don't forget to include the appropriate vcs tool (cvs,subversion,git,...) in makedepends= as necessary
  • to preserve the integrity of the checked out code it is usually possible to build in a separate build dir e.g. having checked out source code to src/$_cvsmod from $startdir you can use:
  mkdir src/$_cvsmod-build

  cd src/$_cvsmod-build
  ../$_cvsmod/configure

OR if that fails you can try:

  cp -r src/$_cvsmod src/$_cvsmod-build
  cd src/$_cvsmod-build
  • With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables. makepkg will automatically bumps the pkgver anyway when building the package (unless --holdver is used).

Useful Links