NAME
cpan2arch - generate PKGBUILD from CPAN metadata
SYNOPSIS
cpan2arch [OPTION]... MODULE [VERSION]
Options:
-w, --write write to PKGBUILD in current dir
--force overwrite existing PKGBUILD
-u, --update rewrite PKGBUILD (show comparison + preserve attribs + bump pkgrel)
-c, --clear clear all caches before HTTP requests
--clear-mcpan clear MetaCPAN cache
--clear-arch clear Arch Linux cache
-h, --help show this help and exit
-v, --version show version info and exit
VERSION is only supported for distribution names, not module names.
Examples:
$ cpan2arch -w Foo::Bar # Module
$ cpan2arch -w Foo-Bar v1.0.0 # Dist + version
DESCRIPTION
cpan2arch is a command-line utility that generates an Arch Linux PKGBUILD based on module/distribution metadata. It relies on the MetaCPAN API to fetch metadata and the Official repositories web interface + Aurweb RPC interface for Arch Linux packages information, using caching to speed up repeated requests and reduce server load.
Warnings about flagged out-of-date packages, missing packages, license problems, and other issues are added as comments in the PKGBUILD to inform the packager.
The generated PKGBUILD follows Perl package guidelines and is printed to STDOUT by default, unless --update or --write is passed.
NOTE
This tool is intended to ease the maintenance of Perl packages through automation, but blindly relying on it is not recommended since distributions might depend on external libraries or even have wrong metadata, thus manual inspection is always advised.
OPTIONS
- -w, --write
-
Write to a file named PKGBUILD in the current directory.
- --force
-
Overwrite an existing PKGBUILD silently.
- -u, --update
-
Rewrite the PKGBUILD file in the current directory using the generated
PKGBUILD:.SRCINFO metadata is compared against the generated
PKGBUILDmetadata to show differences.Contributor attributions are preserved and
pkgrelis bumped wheneverpkgvernumbers from both metadatas are equal.epochis added or bumped whenever a newer version breaks pacman's version comparison logic.
Notes
Intended to quickly update obsolete
PKGBUILDs from adopted AUR Perl packages.Only metadata differences are shown in the comparison table and printed to
STDERR, soPKGBUILDsyntax and functions are ignored.Example:
+--------------+------------------+---------------------------------+------------------------+ | Variable | .SRCINFO | Generated | Status | +--------------+------------------+---------------------------------+------------------------+ | checkdepends | - | N/A | Missing from Generated | | checkdepends | perl-test-simple | - | Only in .SRCINFO | | depends | - | perl-version, perl>=5.10.1 | Only in Generated | | pkgdesc | Bogus abstract | Visually debug regexes in-place | Differs | +--------------+------------------+---------------------------------+------------------------+--write and --force are implied.
To only update
pkgver,pkgrel, andsha256sums, usepkgctl version upgrade, not this.
- -c, --clear
- --clear-mcpan
- --clear-arch
-
Clear all caches, or only MetaCPAN or Arch Linux cache, before HTTP requests to refresh stale data.
- -h, --help
-
Display a summary of options and exit.
- -v, --version
-
Display the cpan2arch version number and exit.
COMPLETION
To enable tab completion in bash, put the script in the PATH and run this in the shell or add it to a bash startup file (e.g. /etc/bash.bashrc or ~/.bashrc):
complete -C cpan2arch cpan2arch
Note that Getopt::Long::More is required.
EXIT STATUS
0 success
1 general failure
2 command-line usage error
ENVIRONMENT
- C2A_PACKAGER
-
If set, overrides the default packager attribution info. Default:
Your Name <email@domain.tld>. - C2A_USER_AGENT
-
If set, overrides the default user agent string. Default:
App::cpan2arch/$VERSION. - C2A_CACHE_MCPAN_PATH
-
If set, overrides the default MetaCPAN cache path. Default:
/tmp/mcpan_cache. - C2A_CACHE_ARCH_PATH
-
If set, overrides the default Arch Linux cache path. Default:
/tmp/arch_cache. - C2A_CACHE_EXPIRATION
-
If set, overrides the default cache expiration. Default:
1d. - C2A_CACHE_IGNORE
-
If true, disables the cache for HTTP requests. Default:
false. - C2A_DEBUG
-
If true, displays debug information to
STDERR(Requires Data::Printer). Default:false.
BUGS
Report bugs at https://github.com/author/App-cpan2arch/issues.
AUTHOR
ryoskzypu <ryoskzypu@proton.me>
SEE ALSO
https://blogs.perl.org/users/neilb/2017/04/an-introduction-to-distribution-metadata.html
https://blogs.perl.org/users/neilb/2016/11/an-overview-of-metacpan.html
This module ships with a similar utility that generates a PKGBUILD, but it is tied to CPANPLUS and does more stuff like packaging and installing CPAN modules on Arch using makepkg and pacman, without depending on the AUR.
COPYRIGHT
Copyright © 2026 ryoskzypu
MIT-0 License. See LICENSE for details.