https://wiki.archlinux.org/api.php?action=feedcontributions&user=Losinggeneration&feedformat=atomArchWiki - User contributions [en]2024-03-29T05:47:35ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=VCS_package_guidelines&diff=21750VCS package guidelines2007-03-08T08:45:22Z<p>Losinggeneration: /* A few tips */ makedepends should be subversion and not svn</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:Development (English)]]<br />
[[Category:Package development (English)]]<br />
[[Category:Tutorials (English)]]<br />
<br />
:''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 over complicate things. These are not ''really'' necessary but do help to clarify the syntax of the cvs/svn/git commands, which can appear quite complex.''<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Arch CVS %26 SVN PKGBUILD guidelines}}<br />
{{i18n_entry|繁體中文|Arch CVS %26 SVN PKGBUILD 編寫指南}}<br />
{{i18n_entry|简体中文|Arch CVS %26 SVN %26 GIT PKGBUILD 编写指南}}<br />
{{i18n_links_end}}<br />
<br />
<br />
==A few tips==<br />
<br />
* 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.<br />
* 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<br />
conflicts=('fluxbox')<br />
: You should also use the <tt>provides=</tt> field so that pkgs that require fluxbox to be installed recognize your fluxbox-svn pkg as fluxbox<br />
provides=('fluxbox')<br />
: You should AVOID using <tt>replaces=</tt> it generally causes unnecessary problems<br />
*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.<br />
* 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.<br />
<pre>source=()<br />
md5sums=()</pre><br />
* 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)<br />
* don't forget to include cvs or subversion in <code>makedepends=</code> as necessary<br />
* 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:<br />
<pre> mkdir src/$_cvsmod-build<br />
<br />
cd src/$_cvsmod-build<br />
../$_cvsmod/configure</pre><br />
''OR'' if that fails you can try:<br />
<pre> cp -r src/$_cvsmod src/$_cvsmod-build<br />
cd src/$_cvsmod-build</pre><br />
<br />
* With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables<br />
** 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)<br />
** For svn you can use the revision number. An easy way to find the revision number is to use the following command:<br />
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g<br />
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<br />
<pre><br />
------------------------------------------------------------------------<br />
r4084 | mathias | 2005-07-20 19:29:01 +0100 (Wed, 20 Jul 2005) | 16 lines<br />
<br />
Changed some *Focus options, just to make some things a bit more clear.<br />
the "Sloppy" was always a bit .. imprecise.<br />
</pre><br />
<br />
==Example CVS PKGBUILD==<br />
<br />
Here is a PKGBUILD for bmp-cvs that utilizes some of the tips above<br />
<br />
<pre># Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
pkgname=bmp-cvs<br />
pkgver=20050728<br />
pkgrel=1<br />
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."<br />
arch=(i686 x86_64)<br />
url="http://beepmp.sourceforge.net/"<br />
license=<br />
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')<br />
provides=('bmp')<br />
conflicts=('bmp')<br />
makedepends=('cvs')<br />
install=$pkgname.install<br />
<br />
_cvsroot=":pserver:anonymous:@cvs.sourceforge.net:/cvsroot/beepmp"<br />
_cvsmod="bmp"<br />
<br />
build() {<br />
cd $startdir/src<br />
msg "Connecting to $_cvsmod.sourceforge.net CVS server...."<br />
cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
cd $_cvsmod<br />
./autogen.sh<br />
<br />
msg "CVS checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r ../$_cvsmod ../$_cvsmod-build<br />
cd ../$_cvsmod-build<br />
<br />
./configure --prefix=/usr<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install || return 1<br />
<br />
mkdir -p $startdir/pkg/usr/share/xmms/Skins<br />
mv $startdir/pkg/usr/share/bmp/Skins/* $startdir/pkg/usr/share/xmms/Skins<br />
rmdir $startdir/pkg/usr/share/bmp/Skins<br />
<br />
rm -r $startdir/src/$_cvsmod-build<br />
}<br />
# vim:syntax=sh<br />
</pre><br />
<br />
==Example SVN PKGBUILD==<br />
<br />
If you use the <tt>source</tt> command on the PKGBUILD first it will store the _svntrunk and _svnmod variables. So if you run :<br />
source PKGBUILD<br />
svn info $_svntrunk<br />
you can get the revision number(Or,Last Changed Rev) which can be used in pkgver<br />
<br />
<pre><br />
# Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
pkgname=fluxbox-svn<br />
pkgver=4084<br />
pkgrel=1<br />
pkgdesc="Fluxbox-svn is the bleeding edge version of a lightweight yet \<br />
customizable windowmanager for X. This will checkout and package the latest SVN version."<br />
arch=(i686 x86_64)<br />
url="http://www.fluxbox.org"<br />
license=<br />
<br />
depends=('bash' 'x-server')<br />
makedepends=('subversion')<br />
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')<br />
provides=('fluxbox')<br />
<br />
source=()<br />
md5sums=()<br />
<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
<br />
build() {<br />
cd $startdir/src<br />
<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
<br />
msg "SVN checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $_svnmod $_svnmod-build<br />
cd $_svnmod-build<br />
<br />
./autogen.sh<br />
<br />
# fix for crap fb issue<br />
mkdir data<br />
cp ../$_svnmod/data/keys data/<br />
<br />
./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
make || return 1<br />
make DESTDIR=$startdir/pkg/ install<br />
<br />
rm -rf $startdir/src/$_svnmod-build<br />
}<br />
# vim:syntax=sh</pre><br />
<br />
==Example GIT PKGBUILD==<br />
<br />
<pre><br />
pkgname=compiz-git<br />
pkgver=20060707<br />
pkgrel=1<br />
pkgdesc="Composite and window manager for Xgl"<br />
arch=(i686 x86_64)<br />
url="http://en.opensuse.org/Compiz"<br />
license=""<br />
depends=('xgl-cvs' 'mesa-xgl-cvs' 'cairo-devel' 'libxevie' \<br />
'startup-notification' 'libpng' 'libxdamage' \<br />
'libxrandr' 'libwnck-compiz' 'gnome-desktop' 'control-center' \<br />
'libsvg-cairo' 'libxcomposite')<br />
makedepends=('git')<br />
conflicts=()<br />
replaces=()<br />
backup=()<br />
install=compiz.install<br />
source=(compiz-intel-copy-pixel-issue-workaround-1.diff)<br />
md5sums=('10a157b86d528bca2be6731c5eaff7b3')<br />
<br />
_gitroot="git://anongit.freedesktop.org/git/xorg/app/compiz"<br />
_gitname="compiz"<br />
build() {<br />
export CFLAGS="$CFLAGS -I/opt/mesa-xgl-cvs/include"<br />
cd $startdir/src<br />
msg "Connecting to git.freedesktop.org GIT server...."<br />
<br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
<br />
msg "GIT checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $startdir/src/$_gitname $startdir/src/$_gitname-build<br />
cd $startdir/src/$_gitname-build<br />
patch -Np0 -i ${startdir}/src/compiz-intel-copy-pixel-issue-workaround-1.diff<br />
<br />
ACLOCAL="aclocal -I /opt/gnome/share/aclocal" ./autogen.sh --host=${CHOST} \<br />
--prefix=/usr \<br />
--infodir=/usr/share/info \<br />
--mandir=/usr/man \<br />
--sysconfdir=/opt/gnome/etc \<br />
--enable-gnome \<br />
--enable-libsvg-cairo \<br />
--enable-gconf-dump \<br />
--disable-kde || return 1<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install<br />
<br />
find $startdir/pkg -type f -name '*.la' -exec rm {} \;<br />
} <br />
</pre><br />
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.<br />
I need to introduce an if condition: <br />
<pre><br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
</pre><br />
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 ).<br />
<br />
==versionpkg - a <tt>makepkg</tt> wrapper for CVS/SVN builds==<br />
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.<br />
<br />
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.<br />
<br />
To use the script;<br />
* Ensure that pkgver is declared within the first ten lines of the PKGBUILD or it won't work!<br />
* Ensure you have include the following custom variables and checkout command:<br />
* CVS<br />
_cvsroot=<br />
: The root of the CVS server - remember to include a colon (:) after the username as outlined above<br />
_cvsmod=<br />
: Simply the CVS module name you wish to check out e.g.<br />
_cvsroot=":pserver:anonymous:@mplayerhq.hu:/cvsroot/ffmpeg"<br />
_cvsmod="ffmpeg"<br />
: 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<br />
cvs -z9 -q -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
: -z controls the level of compression (1 is low 9 is high)<br />
: -D specifies the date to check out, we use $pkgver as that is set to the current date by the script.<br />
: -q is a quiet switch<br />
* SVN<br />
_svntrunk=<br />
: The address of the SVN trunk<br />
_svnmod=<br />
: Again the module you wish to check out from trun e.g.<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
: 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>.<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
: Here -r specifies the revision number, we use $pkgver as that is set to the latest revision number by the script.<br />
<br />
===The script!===<br />
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><br />
Changelog:<br />
* check for both CVS/SVN vars<br />
* If build fails revert to previous pkgver to allow correct gensync operation<br />
* Added support for coloured messages<br />
<pre>#!/bin/bash<br />
<br />
# versionpkg - a makepkg wrapper for building CVS/SVN pkgs<br />
# dibblethewrecker.at.jiwe.org<br />
<br />
# makepkg configuration<br />
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf<br />
<br />
# SUBROUTINES<br />
plain() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e " \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo " $1" >&2<br />
fi<br />
}<br />
msg() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> $1" >&2<br />
fi<br />
}<br />
warning() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> WARNING: $1" >&2<br />
fi<br />
}<br />
error() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> ERROR: $1" >&2<br />
fi<br />
return 1<br />
}<br />
<br />
source ./PKGBUILD<br />
oldpkgver=$pkgver<br />
<br />
if [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then<br />
cvsdate=`date +%Y%m%d`<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$cvsdate|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$cvsdate|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then<br />
svnrevno=`svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g`<br />
msg "Current revision number is $svnrevno"<br />
if [ "${1}" != "-f" ] && [ "${oldpkgver}" == "${svnrevno}" ] ; then<br />
error "No new revision available. (use -f to overwrite)"<br />
exit<br />
fi<br />
sleep 3<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$svnrevno|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$svnrevno|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
else<br />
error "No SVN or CVS variables found! Aborting..."<br />
exit<br />
fi<br />
</pre></div>Losinggeneration