Difference between revisions of "AUR Metadata"

From ArchWiki
Jump to: navigation, search
(Short summary of recent .AURINFO innovations)
 
(new section: "pkgbuild_reflection and mkaurball"; remove the "addaurinfo" script {from,and} the "Tips and Tricks" section because "mkaurball" seems to be its successor)
Line 16: Line 16:
 
* Multiple architectures ({{ic|x86_64}} dependencies tend to be more numerous, so just put them)
 
* Multiple architectures ({{ic|x86_64}} dependencies tend to be more numerous, so just put them)
  
== Tips and tricks ==
+
== pkgbuild_reflection and mkaurball ==
Create this script:
+
[https://github.com/falconindy/pkgbuild_reflection pkgbuild_reflection] is a set of tools for generating {{ic|.AURINFO}} files. One of the provided tools is {{ic|mkaurball}}, which is a script that runs {{ic|makepkg --source}}, generates an {{ic|.AURINFO}} file, and inserts it into the resulting source package.
{{hc|/usr/local/addaurinfo|
+
<nowiki>
+
#! /usr/bin/env bash
+
  
process() {
+
{{Tip|{{ic|mkaurball}} is a wrapper for {{ic|makepkg --source}}. When creating source packages for inclusion in the [[AUR]], use {{ic|mkaurball}} instead of running {{ic|makepkg --source}} directly.}}
  
  if [ ! -f PKGBUILD ]; then
+
[[pacman|Install]] the package {{AUR|pkgbuild-reflection-git}} from the Arch User Repository.
    echo "PKGBUILD not found!"
+
  else
+
    source PKGBUILD
+
    echo ">>> Generate AURINFO for $pkgname"
+
    cat > .AURINFO << EOF
+
pkgname = $pkgname
+
pkgver = $pkgver-$pkgrel
+
pkgdesc = $pkgdesc
+
url = $url
+
license = $license
+
EOF
+
 
+
    for i in "${depends[@]}"; do
+
      echo "depend = $i" >> .AURINFO
+
    done
+
 
+
    print_aurinfo
+
    edit_aurinfo
+
    create_src "$pkgname-$pkgver-$pkgrel" "$pkgname"
+
  fi
+
}
+
 
+
print_aurinfo() {
+
  echo ">>> Generated .AURINFO:"
+
  cat .AURINFO
+
}
+
 
+
edit_aurinfo() {
+
  echo ">>> Edit .AURINFO ? [Y/n] ("A" to abort)"
+
  read -n 1 -r
+
  if [[ $REPLY =~ ^[Yy]$ ]]; then
+
    $EDITOR .AURINFO
+
    print_aurinfo
+
    edit_aurinfo
+
  elif [[ $REPLY =~ ^[Aa]$ ]]; then
+
    exit
+
  else
+
    return
+
  fi
+
}
+
 
+
create_src() {
+
  echo ">>> Generate pkgsrc"
+
  makepkg --source -f
+
  echo ">>> Update pkgsrc"
+
  srcpkg=`realpath $1.src.tar.gz`
+
  gzip -d "$srcpkg"
+
  tar rvf "${srcpkg/${srcpkg: -3}}" .AURINFO --transform s,.AURINFO,$2/.AURINFO,
+
  gzip "${srcpkg/${srcpkg: -3}}"
+
}
+
 
+
process
+
</nowiki>
+
}}
+
 
+
Make it executable:
+
{{bc|# chmod +x /usr/local/addaurinfo}}
+
 
+
and add following to {{ic|~/.bashrc}}:
+
 
+
{{bc|<nowiki>
+
alias mkaurpkg='makepkg --source && addaurinfo'</nowiki>
+
}}
+
 
+
Now you can use {{ic|mkaurpkg}} to build AUR packages with correct metadata.
+

Revision as of 22:42, 17 January 2014

In order to display information in web interface AUR attempts to parse PKGBUILD and salvage package name, version and other information from it. PKGBUILDs are Bash scripts, and correctly parsing Bash scripts is a huge challenge (which is why makepkg is a Bash script itself: it includes PKGBUILD of package being built via source directive). AUR metadata files were created to get rid of some hacks, used by AUR package maintainers to work around incorrect parsing. See also FS#25210, FS#15043 and FS#16394.

How it works

By adding a metadata file called ".AURINFO" to source tarballs to overwrite specific PKGBUILD fields. .AURINFO files are parsed line by line. The syntax for each line is key = value, where key is any of the following field names:

  • pkgname
  • pkgver
  • pkgdesc
  • url
  • license
  • depend

Multiple "depend" lines can be specified to add multiple dependencies. This format closely matches the .PKGINFO format that is used for binary packages in pacman/libalpm. It can be extended by field name prefixes or sections to support split packages later.

What does not work

  • Split packages
  • Multiple architectures (x86_64 dependencies tend to be more numerous, so just put them)

pkgbuild_reflection and mkaurball

pkgbuild_reflection is a set of tools for generating .AURINFO files. One of the provided tools is mkaurball, which is a script that runs makepkg --source, generates an .AURINFO file, and inserts it into the resulting source package.

Tip: mkaurball is a wrapper for makepkg --source. When creating source packages for inclusion in the AUR, use mkaurball instead of running makepkg --source directly.

Install the package pkgbuild-reflection-gitAUR from the Arch User Repository.