Difference between revisions of "VCS package guidelines (简体中文)"

From ArchWiki
Jump to: navigation, search
(一些小提示)
(use https for links to archlinux.org)
(24 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{i18n_links_start}}
+
[[Category:简体中文]]
{{i18n_entry|English|Arch CVS & SVN & GIT PKGBUILD guidelines}}
+
[[en:VCS PKGBUILD Guidelines]]
{{i18n_entry|繁體中文|Arch CVS & SVN & GIT PKGBUILD 編寫指南}}
+
[[it:VCS PKGBUILD Guidelines]]
{{i18n_entry|间体中文|Arch CVS & SVN & GIT PKGBUILD 编写指南}}
+
[[zh-TW:VCS PKGBUILD Guidelines]]
{{i18n_links_end}}
+
{{Package Guidelines}}
 +
{{Translateme (简体中文)}}
 +
[[Wikipedia:Revision_control|Version control systems]] can be used for retrieval of source code for both usual statically versioned packages and latest (trunk) version of packages. This article covers both cases.
  
[[Category:Package Management]]
+
== Prototypes ==
==用 makepkg 打包 CVS, SVN & GIT 文件==
+
The [[ABS]] package provides prototypes for [[cvs]], [[svn]], [[git]], [[mercurial]], and [[Wikipedia:darcs|darcs]] [[PKGBUILD]]s. When {{Pkg|abs}} is installed, you can find them in {{ic|/usr/share/pacman}}. Latest versions can be found in the [https://projects.archlinux.org/abs.git/tree/prototypes prototypes directory in the ABS Git repository].
  
事实上,这个工作非常简单,您不需要什么特殊的知识。不管怎么样,您对CVS和SVN的知识懂得越多越好。很多人在 PKGBUILD 文件里面引入了不必要(译注:这个词是译者加的,在尽量不影响理解的前提下,译者可能会不自觉的使用自己的语言,后面不再声明)的自定义变量,这样会使工作变得复杂。这些看起来很复杂的语句并不是''必须的'',但是对于使语法结构清洗,是很有帮助的。
+
== Guidelines ==
 +
* Properly suffix {{Ic|pkgname}} with {{Ic|-cvs}}, {{Ic|-svn}}, {{Ic|-hg}}, {{Ic|-darcs}}, {{Ic|-bzr}}, {{Ic|-git}} etc. If the package tracks a moving development trunk it should be given a suffix. If the package fetches a release from a VCS tag then it should not be given a suffix. Use this rule of thumb: if the output of the package depends on the time at which it was compiled, append a suffix; otherwise do not.
  
===一些小提示===
+
* A VCS package may be updated as and when needed to adopt changes to the build system, including ammendments to dependencies, URL, sources, etc. If the revision number remains the same after such an update, but produces a resulting binary which is different, increasing the {{Ic|pkgrel}} is mandatory. If both the revision number and the resulting binary remain the same, {{Ic|pkgrel}} should be kept intact. There is no need to update the VCS package just to accommodate a revision bump, but one may choose to do so.
  
* 给 <code>pkgname</code> 加上 <code>-cvs</code> 或者 <code>-svn</code> 或者 <code>-git</code> 这样的后缀 (where applicable, 这个不知道怎么翻译) - 这样可以防止和非devel版本的包名混淆,比如 fluxbox-svn , fvwm-cvs 对 fluxbox , fvwm.
+
* When [[makepkg]] is run, by default it will check for newer revisions and then update the {{Ic|pkgver}} in the PKGBUILDLook at {{Ic|--holdver}} in [https://www.archlinux.org/pacman/makepkg.8.html man makepkg] if you want otherwise.  {{Ic|--holdver}} only works for cvs and svn, which allow checkout of older revisions.
* 您还必须小心处理 pacman 的冲突(依赖关系冲突)。比如 fluxbox-svn will 与 fluxbox 冲突。这样您就需要使用 <tt>conflicts=</tt> 字段(field)
+
  conflicts=('fluxbox')
+
: 您还应该使用 <tt>provides=</tt> 字段,以便让需要 fluxbox (作者这里用fluxbox来举例)的包知道 fluxbox-svn 就是 fluxbox
+
provides=('fluxbox')
+
: 您最好不要使用(your should avoid using) <tt>replaces=</tt> ,它可能会产生不必要的麻烦
+
*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 rejectedThey may be left blank though.
+
<pre>source=()
+
md5sums=()</pre>
+
* 使用 CVS/SVN/GIT 的时候,我们极少用到 pkgrel 字段,因为源文件时有改动,所以我们通常用 pkgver 来标记改动(假定我们用 pkgver 来保存日期)(英文原文:It is rarely necessary 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),英语不到家,有人会翻译的mail:fluke at sfcube.net)
+
* 不要忘记把 svn 或者 cvs 包含在 <code>makedepends=</code> 里面,如果必须的话(译注:如果你要从 svn checkout 源码包,自然要要保证你有 svn 客户端)
+
* 为了保证 check out(译注:cvs和svn的术语,就不翻译了) 下来的 code 的完整性,我们建立一个独立的 build 目录,比如你已经在 $startdir 把代码 ckeck out 到了 src/$_cvsmod 目录你可以:
+
<pre>  mkdir src/$_cvsmod-build
+
  
  cd src/$_cvsmod-build
+
* Check for package conflicts. For example ''fluxbox-svn'' will conflict with ''fluxbox''. In this case, you need to use {{Ic|1=conflicts=('fluxbox')}}.
  ../$_cvsmod/configure</pre>
+
''万一'' 这种方法失败了,你可以尝试:
+
<pre> cp -r src/$_cvsmod src/$_cvsmod-build
+
  cd src/$_cvsmod-build</pre>
+
  
* AUR的介绍中说最重要的是不要使用 backtick 扩展去创建 pkg 变量(With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables)
+
* Use the {{Ic|provides}} field so that packages that require the non-VCS package can be installed ({{Ic|1=provides=('fluxbox')}}).
** 对于 cvs 包 您应该避免 <code>pkgver=`date +%y%m%d`</code> - (译注:this also inteferes with the functionality of the AUR.,这句话不好翻译,我不知道inteferes什么意思) 作为替代的方案,还可以用日期格式的 $pkgver 变量,并且使用 cvs -D 去获取从那个日期起的代码 (看下面)
+
** 对于 svn 您可以使用修正号(revision number)。下面是一种简易的获取修正号的方法:
+
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g
+
这条命令从 svn repo (译注:就是 svn 的源)最近额记录里面取得修正号--修正号的前面带有''r''字母。下面的来自于 fluxbox 的 svn 记录,修正号就在左上角,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.
+
* You should AVOID using {{Ic|1=replaces=...}} as it generally causes unnecessary problems.
the "Sloppy" was always a bit .. unprecise.
+
</pre>
+
  
===Example CVS PKGBUILD===
+
* When using/defining the cvsroot, use {{Ic|anonymous:@}} rather than {{Ic|anonymous@}} to avoid a password prompt and having to enter a blank password ''OR'' use {{Ic|anonymous:password@}} if a password is required.
  
Here is a PKGBUILD for bmp-cvs that utilizes some of the tips above
+
* Don't forget to include the appropriate VCS tool (cvs, subversion, git, ...) in {{Ic|1=makedepends=...}}.
  
<pre># Contributor:  Lukas Sabota <punkrockguy318@comcast.net>
+
* To preserve the integrity of the checked-out code consider copying the original build directory if you have to make edits. For example, having checked out source code to {{ic|src/$_cvsmod}} from {{ic|$startdir}} you can use:
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
+
pkgname=bmp-cvs
+
pkgver=20050728
+
pkgrel=1
+
pkgdesc="BeepMP is a multimedia player that uses the WinAmp 2.x UI, GTK2, and is based on XMMS. This will checkout and package the latest CVS version."
+
url="http://beepmp.sourceforge.net/"
+
license=
+
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')
+
provides=('bmp')
+
conflicts=('bmp')
+
makedepends=('cvs')
+
install=$pkgname.install
+
  
_cvsroot=":pserver:anonymous:@cvs.sourceforge.net:/cvsroot/beepmp"
+
mkdir src/$_cvsmod-build
_cvsmod="bmp"
+
 +
cd src/$_cvsmod-build
 +
../$_cvsmod/configure
  
build() {
+
or:
  cd $startdir/src
+
  msg "Connecting to $_cvsmod.sourceforge.net CVS server...."
+
  cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod
+
  cd $_cvsmod
+
  ./autogen.sh
+
  
  msg "CVS checkout done or server timeout"
+
cp -r src/$_cvsmod src/$_cvsmod-build
  msg "Starting make..."
+
cd src/$_cvsmod-build
  
  cp -r ../$_cvsmod ../$_cvsmod-build
+
* With the introduction of the [[AUR]], it is most important to avoid using backtick execution to create package variables. makepkg will automatically bump the {{Ic|pkgver}} anyway when building the package (unless {{Ic|--holdver}} is used).
  cd ../$_cvsmod-build
+
  
  ./configure --prefix=/usr
+
== Tips ==
  make || return 1
+
* You should make sure that there are no VCS directories and files left over in your package. If there are, you may want to remove them, by adding a command similar to this one at the end of the the package() script:
  make DESTDIR=$startdir/pkg install || return 1
+
  
  mkdir -p $startdir/pkg/usr/share/xmms/Skins
+
rm -rf $(find "$pkgdir" -type d -name ".svn")
  mv $startdir/pkg/usr/share/bmp/Skins/* $startdir/pkg/usr/share/xmms/Skins
+
  rmdir $startdir/pkg/usr/share/bmp/Skins
+
  
  rm -r $startdir/src/$_cvsmod-build
+
* When using Git, one can speed up the cloning operation using the {{Ic|1=--depth=1}} parameter. This creates a shallow clone, and has only the last change history - since histories are unimportant for builds most of the time.
}
+
# vim:syntax=sh
+
</pre>
+
  
===Example SVN PKGBUILD===
+
git clone git://hostname.dom/project.git --depth=1
  
If you use the <tt>source</tt> command on the PKGBUILD first it will store the _svntrunk and _svnmod variables. So if you run :
+
* It's possible to create the package also from a branch other than the master. To do so add {{Ic|1=--branch branch_name}} after the first {{Ic|1=git clone}}, in this way:
source PKGBUILD
+
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g
+
you can get the revision number which can be used in pkgver
+
  
<pre>
+
  git clone "$_gitroot" "$_gitname" --branch branch_name
# Contributor: Lukas Sabota <punkrockguy318@comcast.net>
+
Remember to save package with a different name, for example {{Ic|1= pkgname-branchname-git}}, in order to avoid confusion with the package from the branch master.
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
+
pkgname=fluxbox-svn
+
pkgver=4084
+
pkgrel=1
+
pkgdesc="Fluxbox-svn is the bleeding edge version of a lightweight yet \
+
customizable windowmanager for X. This will checkout and package the latest SVN version."
+
url="http://www.fluxbox.org"
+
depends=('bash' 'x-server')
+
makedepends=('subversion')
+
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')
+
replaces=('fluxbox-cvs')
+
provides=('fluxbox')
+
  
_svntrunk=svn://svn.berlios.de/fluxbox/trunk
+
* Copy paste script when building from repo
_svnmod=fluxbox
+
If you are lazy here is a sample script when making git-based PKGBUILDs.
  
build() {
+
   cd "$srcdir"
   cd $startdir/src
+
   msg "Connecting to GIT server..."
 
+
   if [ -d $_gitname ] ; then
  svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod
+
    cd $_gitname && git pull origin
  cd $_svnmod
+
    msg "The local files are updated."
  ./autogen.sh
+
 
+
  msg "SVN checkout done or server timeout"
+
  msg "Starting make..."
+
 
+
  mkdir ../$_svnmod-build
+
  cd ../$_svnmod-build
+
 
+
  # fix for crap fb issue
+
  mkdir data
+
  cp ../$_svnmod/data/keys data/
+
 
+
  ../$_svnmod/configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug
+
  #./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug
+
  make || return 1
+
  make DESTDIR=$startdir/pkg/ install
+
 
+
  rm -r $startdir/src/$_svnmod-build
+
}
+
# vim:syntax=sh</pre>
+
 
+
===Example GIT PKGBUILD===
+
 
+
<pre>
+
pkgname=compiz-git
+
pkgver=20060707
+
pkgrel=1
+
pkgdesc="Composite and window manager for Xgl"
+
url="http://en.opensuse.org/Compiz"
+
license=""
+
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 $startdir/src
+
   msg "Connecting to git.freedesktop.org GIT server...."
+
 
+
   if [ -d $startdir/src/$_gitname ] ; then
+
  cd $_gitname && git-pull origin
+
  msg "The local files are updated."
+
 
   else
 
   else
  git clone $_gitroot
+
    git clone --depth=1 $_gitroot $_gitname
 
   fi
 
   fi
 
 
   msg "GIT checkout done or server timeout"
 
   msg "GIT checkout done or server timeout"
  msg "Starting make..."
 
 
  cp -r $startdir/src/$_gitname $startdir/src/$_gitname-build
 
  cd $startdir/src/$_gitname-build
 
  patch -Np0 -i ${startdir}/src/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/man \
 
    --sysconfdir=/opt/gnome/etc \
 
    --enable-gnome \
 
    --enable-libsvg-cairo \
 
    --enable-gconf-dump \
 
    --disable-kde || return 1
 
  make || return 1
 
  make DESTDIR=$startdir/pkg install
 
 
  find $startdir/pkg -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 $startdir/src/$_gitname ] ; then
 
cd $_gitname && git-pull origin
 
msg "The local files are updated."
 
else
 
git clone $_gitroot
 
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 ).
 
 
===versionpkg - a <tt>makepkg</tt> wrapper for CVS/SVN builds===
 
This is a very simple script that allows you to easily update your CVS and SVN packages without having to edit the PKGBUILDs manually to enter the date or revision number.
 
 
Simply run this script rather than <tt>makepkg</tt> in the build dir.  This script completely removes the need for backtick execution to set the date or tag version in PKGBUILDs.
 
 
To use the script;
 
* Ensure that pkgver is declared within the first ten lines of the PKGBUILD or it won't work!
 
* Ensure you have include the following custom variables and checkout command:
 
* CVS
 
_cvsroot=
 
: The root of the CVS server - remember to include a colon (:) after the username as outlined above
 
_cvsmod=
 
: Simply the CVS module name you wish to check out  e.g.
 
_cvsroot=":pserver:anonymous:@mplayerhq.hu:/cvsroot/ffmpeg"
 
_cvsmod="ffmpeg"
 
: Here is the checkout command for CVS that uses the above variables.  The <strong>-D</strong> option is essential for proper use of <code>versionpkg</code> and is best used in combination with the <strong>-f</strong> option.  Use of <strong>-D</strong> without <strong>-f</strong> may result in errors
 
cvs -z9 -q -d $_cvsroot co -D $pkgver -f $_cvsmod
 
: -z controls the level of compression (1 is low 9 is high)
 
: -D specifies the date to check out, we use $pkgver as that is set to the current date by the script.
 
: -q is a quiet switch
 
* SVN
 
_svntrunk=
 
: The address of the SVN trunk
 
_svnmod=
 
: Again the module you wish to check out from trun  e.g.
 
_svntrunk=svn://svn.berlios.de/fluxbox/trunk
 
_svnmod=fluxbox
 
: Here is the checkout command for SVN that uses the above variables.  The <strong>-r</strong> option is essential for proper use of <code>versionpkg</code>.
 
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod
 
: Here -r specifies the revision number, we use $pkgver as that is set to the latest revision number by the script.
 
 
====The script!====
 
To improve security versionpkg can now be installed directly from [community] <code>pacman -S versionpkg</code>.  I strongly recommend that you use that.  The script below is purely for illustrative purposes :)<br>
 
Changelog:
 
* check for both CVS/SVN vars
 
* If build fails revert to previous pkgver to allow correct gensync operation
 
* Added support for coloured messages
 
<pre>#!/bin/bash
 
  
# versionpkg - a makepkg wrapper for building CVS/SVN pkgs
+
* Temporary build directories: When using Git, and where you need to create a separate build directory (e.g., for building/compiling), you should avoid copying over the {{Ic|1=.git}} directory located in the parent folder because it contains history information that Git uses internally. With repos with thousands of commits, this .git directory will contain upwards of hundreds of MiB of useless commit history that has *nothing* to do with the current working tree. The only time you'd need to copy over the .git directory itself is when you need to build from a specific, older commit (which is generally never the case as the point of a VCS PKGBUILD is to pull from the latest bleeding edge commit). Thus, instead of
# dibblethewrecker.at.jiwe.org
+
  
# makepkg configuration
+
rm -rf "$srcdir/$_gitname-build"
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf
+
cp -R "$srcdir/$_gitname" "$srcdir/$_gitname-build" # copy everything, including the useless .git folder
 +
cd "$srcdir/$_gitname-build"
 +
make # build/compile from source
  
# SUBROUTINES
+
you should do
plain() {
+
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+
echo -e "    \033[1;1m$1\033[1;0m" >&2
+
else
+
echo "    $1" >&2
+
fi
+
}
+
msg() {
+
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2
+
else
+
echo "==> $1" >&2
+
fi
+
}
+
warning() {
+
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2
+
else
+
echo "==> WARNING: $1" >&2
+
fi
+
}
+
error() {
+
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then
+
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2
+
else
+
echo "==> ERROR: $1" >&2
+
fi
+
return 1
+
}
+
  
source ./PKGBUILD
+
rm -rf "$srcdir/$_gitname-build"
oldpkgver=$pkgver
+
cd "$srcdir/$_gitname" && ls -A | grep -v .git | xargs -d '\n' cp -r -t ../$_gitname-build # do not copy over the .git folder
 +
cd "$srcdir/$_gitname-build"
 +
make # build/compile from source
  
if [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then
+
to cut down on build time and disk usage.
cvsdate=`date +%Y%m%d`
+
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$cvsdate|" ./PKGBUILD
+
makepkg $@
+
if [ $? -gt 0 ] ; then
+
error "Reverting pkgver..."
+
sed -i "1,11 s|pkgver=$cvsdate|pkgver=$oldpkgver|" ./PKGBUILD
+
fi   
+
elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then
+
svnrevno=`svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g`
+
msg "Current revision number is $svnrevno"
+
if [ "${1}" != "-f" ] && [ "${oldpkgver}" == "${svnrevno}" ] ; then
+
error "No new revision available.  (use -f to overwrite)"
+
exit
+
fi
+
sleep 3
+
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$svnrevno|" ./PKGBUILD
+
makepkg $@
+
if [ $? -gt 0 ] ; then
+
error "Reverting pkgver..."
+
sed -i "1,11 s|pkgver=$svnrevno|pkgver=$oldpkgver|" ./PKGBUILD
+
fi
+
else
+
error "No SVN or CVS variables found! Aborting..."
+
exit
+
fi
+
</pre>
+

Revision as of 01:59, 6 December 2012

Template:Package Guidelines

Tango-preferences-desktop-locale.png本页面需要更新翻译,内容可能已经与英文脱节。要贡献翻译,请访问简体中文翻译组Tango-preferences-desktop-locale.png

附注: please use the first argument of the template to provide more detailed indications.

Version control systems can be used for retrieval of source code for both usual statically versioned packages and latest (trunk) version of packages. This article covers both cases.

Prototypes

The ABS package provides prototypes for cvs, svn, git, mercurial, and darcs PKGBUILDs. When abs is installed, you can find them in /usr/share/pacman. Latest versions can be found in the prototypes directory in the ABS Git repository.

Guidelines

  • Properly suffix pkgname with -cvs, -svn, -hg, -darcs, -bzr, -git etc. If the package tracks a moving development trunk it should be given a suffix. If the package fetches a release from a VCS tag then it should not be given a suffix. Use this rule of thumb: if the output of the package depends on the time at which it was compiled, append a suffix; otherwise do not.
  • A VCS package may be updated as and when needed to adopt changes to the build system, including ammendments to dependencies, URL, sources, etc. If the revision number remains the same after such an update, but produces a resulting binary which is different, increasing the pkgrel is mandatory. If both the revision number and the resulting binary remain the same, pkgrel should be kept intact. There is no need to update the VCS package just to accommodate a revision bump, but one may choose to do so.
  • When makepkg is run, by default it will check for newer revisions and then update the pkgver in the PKGBUILD. Look at --holdver in man makepkg if you want otherwise. --holdver only works for cvs and svn, which allow checkout of older revisions.
  • Check for package conflicts. For example fluxbox-svn will conflict with fluxbox. In this case, you need to use conflicts=('fluxbox').
  • Use the provides field so that packages that require the non-VCS package can be installed (provides=('fluxbox')).
  • You should AVOID using replaces=... as it generally causes unnecessary problems.
  • When using/defining the cvsroot, use anonymous:@ rather than anonymous@ to avoid a password prompt and having to enter a blank password OR use anonymous:password@ if a password is required.
  • Don't forget to include the appropriate VCS tool (cvs, subversion, git, ...) in makedepends=....
  • To preserve the integrity of the checked-out code consider copying the original build directory if you have to make edits. For example, having checked out source code to src/$_cvsmod from $startdir you can use:
mkdir src/$_cvsmod-build

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

or:

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 package variables. makepkg will automatically bump the pkgver anyway when building the package (unless --holdver is used).

Tips

  • You should make sure that there are no VCS directories and files left over in your package. If there are, you may want to remove them, by adding a command similar to this one at the end of the the package() script:
rm -rf $(find "$pkgdir" -type d -name ".svn")
  • When using Git, one can speed up the cloning operation using the --depth=1 parameter. This creates a shallow clone, and has only the last change history - since histories are unimportant for builds most of the time.
git clone git://hostname.dom/project.git --depth=1
  • It's possible to create the package also from a branch other than the master. To do so add --branch branch_name after the first git clone, in this way:
git clone "$_gitroot" "$_gitname" --branch branch_name

Remember to save package with a different name, for example pkgname-branchname-git, in order to avoid confusion with the package from the branch master.

  • Copy paste script when building from repo

If you are lazy here is a sample script when making git-based PKGBUILDs.

 cd "$srcdir"
 msg "Connecting to GIT server..."
 if [ -d $_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"
  • Temporary build directories: When using Git, and where you need to create a separate build directory (e.g., for building/compiling), you should avoid copying over the .git directory located in the parent folder because it contains history information that Git uses internally. With repos with thousands of commits, this .git directory will contain upwards of hundreds of MiB of useless commit history that has *nothing* to do with the current working tree. The only time you'd need to copy over the .git directory itself is when you need to build from a specific, older commit (which is generally never the case as the point of a VCS PKGBUILD is to pull from the latest bleeding edge commit). Thus, instead of
rm -rf "$srcdir/$_gitname-build"
cp -R "$srcdir/$_gitname" "$srcdir/$_gitname-build" # copy everything, including the useless .git folder
cd "$srcdir/$_gitname-build"
make # build/compile from source

you should do

rm -rf "$srcdir/$_gitname-build"
cd "$srcdir/$_gitname" && ls -A | grep -v .git | xargs -d '\n' cp -r -t ../$_gitname-build # do not copy over the .git folder
cd "$srcdir/$_gitname-build"
make # build/compile from source

to cut down on build time and disk usage.