a helper tool for AUR package maintainer to automatic update PKGBUILD files
Shell CSS
Switch branches/tags
Nothing to show
Latest commit 844b349 Jan 14, 2014 @fasheng fasheng Update README




pkgbuildup - a helper tool for AUR package maintainer to automatic update PKGBUILD files


pkgbuildup [ -p <file> ] [ -l <file> ] [ -h ] [ -v ]


-p <file>
Use an alternate update script (instead of ‘PKGBUILDUP’)
-l, –listvar <file>
List variables in a template file
-h, –help
Prints help message
-v, –version
Prints version information


pkgbuildup use two types of files named PKGBUILD.tpl and PKGBUILDUP to help AUR package maintainer to automatic update PKGBUILD files.

PKGBUILD.tpl is a template file used to generate new PKGBUILD, it support simple template variable syntax which format looks like {% var %}, the variable name is composed by english letters(a-z, A-Z), underline(_) and numbers(0-9).

PKGBUILDUP for pkgbuildup is corresponding to PKGBUILD for makepkg, its a shell script file, too. User could write code to getting the latest package information and store them to a key-value table, the key name is the variable name in PKGBUILD.tpl, and pkgbuildup will use it to generate a new PKGBUILD file.

And pkgbuildup also provides few functions and variables to make it easier to write a PKGBUILDUP script, for example, if porting a debian package to archlinux, you may want to use update_pkgbuild_for_source_site(), more information please see the documentation(http://fasheng.github.io/pkgbuildup).


Here is an example to porting hello binary package in debian to archlinux, and shows how to dispatch multiple source files in PKGBUILD. But be careful, in the real situation, download source file and compile it will be a better choice when porting a linux software.

Firstly, we get the package web page: http://ftp.debian.org/debian/pool/main/h/hello

And the content of PKGBUILD.tpl will be:

# There are six template variables: pkgver, pkgrel, fileurl_x86,
# fileurl_x64, md5_x86, and md5_x64. In this example we will see that
# pkgbuildup could dispatch multiple source files easily.
pkgver={% pkgver %}
pkgrel={% pkgrel %}
pkgdesc='Hello package from Debian'
arch=('i686' 'x86_64')

_fileurl_x86="{% fileurl_x86 %}"
_fileurl_x64="{% fileurl_x64 %}"
_md5_x86="{% md5_x86 %}"
_md5_x64="{% md5_x64 %}"
if test "$CARCH" == i686; then

package() {
    tar xvf ${srcdir}/data.tar.xz -C ${pkgdir}/

If run command pkgbuild -l PKGBUILD.tpl, it will output:


Then is the PKGBUILDUP file:

update_hello() {
    local url="http://ftp.debian.org/debian/pool/main/h/hello"
    local filereg_x86="hello_.*?_i386.deb"
    local filereg_x64="hello_.*?_amd64.deb"

    # Meaningful variables for update_pkgbuild_for_source_site()
    # $FILE_INFO, a array with useful information to get the latest
    #   package file name, echo element own four fields which were
    #   separate by "::".
    #   The element format looks like as:
    #     "fileurl_var::checksum_var::url::filename_regexp"
    #   fileurl_var and checksum_var are the template variable's name
    local FILE_INFO=("fileurl_x86::md5_x86::${url}::${filereg_x86}"

    # $PKGREL_CMD, the command to get package release version, if
    # exist "%s", will be replaced by $pkgrelreg. This command will
    # be used on first package file name in $FILE_INFO
    local PKGREL_CMD="grep -oP '\-\d+_' | tr -d '\-_'"

    # Arguments for update_pkgbuild_for_source_site()
    local tplfile="hello/PKGBUILD.tpl"
    local pkgverreg='[0-9]\.[0-9]'  # regexp to get package version
    local pkgrelreg=""             # regexp to get package release
                                   # version, we custom $PKGREL_CMD
                                   # directly, so here is just empty
    local makepkg="true"           # run makepkg after updating
    local upload="false"           # upload package to aur after updating

    # update_pkgbuild_for_source_site() is a helper function in
    # pkgbuildup, it will update PKGBUILD which package file living in
    # other linux distribution's source site, and get the latest
    # package file name by parsing the web page
    update_pkgbuild_for_source_site "${tplfile}" "${pkgverreg}" "${pkgrelreg}" "${makepkg}" "${upload}"

Now we just run command pkgbuildup under the directory of PKGBUILD, it will get the latest package name automatically and update the PKGBUILD file, run makepkg, and upload the newer PKGBUILD file to AUR if you wish. pkgbuildup also provide a simple log file named pkgbuildup_result.log, in this example, its content will be:


So, you can see, pkgbuildup is easy to use, and not much code needed, if used in conjunction with other tools like cron, it maybe be more powerful.


GNU General Public License, Version 3.0