summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-24 21:54:51 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-02-09 18:06:12 +0100
commit35f7d973b3e07a1f2481c1eacc1fb0c139701913 (patch)
tree67b3b0ea5012f6f15af006afa40f12df817e3e03
parentPacman::Repo requires pacman. (diff)
downloadpacman-35f7d973b3e07a1f2481c1eacc1fb0c139701913.tar.gz
pacman-35f7d973b3e07a1f2481c1eacc1fb0c139701913.tar.xz
Pacman module makepkg.
-rw-r--r--manifests/makepkg.pp104
-rw-r--r--templates/makepkg.conf.epp163
2 files changed, 267 insertions, 0 deletions
diff --git a/manifests/makepkg.pp b/manifests/makepkg.pp
new file mode 100644
index 0000000..cf020d2
--- /dev/null
+++ b/manifests/makepkg.pp
@@ -0,0 +1,104 @@
+type Buildenv = Struct[{
+ distcc => Boolean,
+ color => Boolean,
+ ccache => Boolean,
+ check => Boolean,
+ sign => Boolean,
+}]
+
+type PackageOptions = Struct[{
+ string => Boolean,
+ docs => Boolean,
+ libtool => Boolean,
+ staticlibs => Boolean,
+ emptydirs => Boolean,
+ zipman => Boolean,
+ purge => Boolean,
+ debug => Boolean,
+ lto => Boolean,
+}]
+
+type ChecksumTypes = Enum['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'b2']
+
+class pacman::makepkg (
+ # protocol: agent
+ Hash[String, String] $dlagents = {
+ 'file' => '/usr/bin/curl -gqC - -o %o %u',
+ 'ftp' => '/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u',
+ 'http' => '/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u',
+ 'https' => '/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u',
+ 'rsync' => '/usr/bin/rsync --no-motd -z %u %o',
+ 'scp' => '/usr/bin/scp -C %u %o',
+ },
+ # protocol: package
+ Hash[String,String] $vcsclients = {
+ 'bzr' => 'bzr',
+ 'git' => 'git',
+ 'hg' => 'mercurial',
+ 'svn' => 'subversion',
+ },
+ String $carch = 'x86_64',
+ String $chost = 'x86_64-pc-linux-gnu',
+ Optional[String] $cppflags = undef, # ''
+ String $cflags = '-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
+ -Wp,-D_FORTIFY_SOURCE=2
+ -Wformat -Werror=format-security
+ -fstack-clash-protection -fcf-protection',
+ String $cxxflags = '$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS',
+ String $ldflags = '-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now',
+ Optional[String] $rustflags = undef, # '-C opt-level=2',
+ Optional[String] $makeflags = undef, # '-j2'
+ String $debug_cflags = '-g -fvar-tracking-assignments',
+ String $debug_cxxflags = '-g -fvar-tracking-assignments',
+ Optional[String] $debug_rustflags = undef, # '-C debuginfo=2'
+ Buildenv $buildenv = {
+ distcc => false,
+ color => true,
+ ccache => false,
+ check => true,
+ sign => false,
+ },
+ Optional[String] $distcc_hosts = undef, # ''
+ Optional[String] $builddir = undef, # '/tmp/makepkg'
+ PackageOptions $options = {
+ string => true,
+ docs => true,
+ libtool => false,
+ staticlibs => false,
+ emptydirs => true,
+ zipman => true,
+ purge => true,
+ debug => false,
+ lto => false, # This is fairly new...
+ },
+ Array[ChecksumTypes] $integrity_check = [ 'sha256' ],
+ String $strip_binaries = '--strip-all',
+ String $strip_shared = '--strip-unneeded',
+ String $strip_static = '--strip-debug',
+ Array[String] $man_dirs = [ '{usr{,/local}{,/share},opt/*}/{man,info}' ],
+ Array[String] $doc_dirs = [ 'usr/{,local/}{,share/}{doc,gtk-doc}', 'opt/*/{doc,gtk-doc}' ],
+ Array[String] $purge_targets = [ 'usr/{,share}/info/dir', '.packlist', '*.pod' ],
+ String $dbgsrcdir = '/usr/src/debug',
+ Optional[String] $pkgdest = undef, # /home/packages
+ Optional[String] $srcdest = undef, # /home/soruces
+ Optional[String] $srcpkgdest = undef, # /home/srcpackages
+ Optional[String] $logdest = undef, # /home/makepkglogs
+ Optional[String] $packager = undef, # John Doe <john@doe.com>
+ Optional[String] $gpgkey = undef, # ""
+ String $compressgz = 'gzip -c -f -n',
+ String $compressbz2 = 'bzip2 -c -f',
+ String $compressxz = 'xz -c -z -',
+ String $compresszst = 'zstd -c -z -q -',
+ String $compresslrz = 'lrzip -q',
+ String $compresslzo = 'lzop -q',
+ String $compressz = 'compress -c -f',
+ String $compresslz4 = 'lz4 -q',
+ String $compresslz = 'lzip -c -f',
+ String $pkgext = '.pkg.tar.zst',
+ String $srcext = '.src.tar.gz',
+ Optional[String] $pacman_auth = undef, # ''
+) {
+ file { '/etc/makepkg.conf':
+ content => epp('pacman/makepkg.conf.epp'),
+ }
+}
diff --git a/templates/makepkg.conf.epp b/templates/makepkg.conf.epp
new file mode 100644
index 0000000..d74ba4e
--- /dev/null
+++ b/templates/makepkg.conf.epp
@@ -0,0 +1,163 @@
+#!/hint/bash
+#
+# /etc/makepkg.conf
+#
+#########################################################################
+# FILE MANAGED BY PUPPET
+# LOCAL CHANGES WILL BE OVERWRITTEN
+#########################################################################
+
+#########################################################################
+# SOURCE ACQUISITION
+#########################################################################
+#
+#-- The download utilities that makepkg should use to acquire sources
+# Format: 'protocol::agent'
+DLAGENTS=(<%- $pacman::makepkg::dlagents.each |$key, $value| { -%>
+'<%= "${key}::${value}" %>'
+<%- } %>)
+
+# Other common tools:
+# /usr/bin/snarf
+# /usr/bin/lftpget -c
+# /usr/bin/wget
+
+#-- The package required by makepkg to download VCS sources
+# Format: 'protocol::package'
+VCSCLIENTS=(<%- $pacman::makepkg::vcsclients.each |$key, $value| { -%>
+'<%= "${key}::${value}" %>'
+<%- } %>)
+
+#########################################################################
+# ARCHITECTURE, COMPILE FLAGS
+#########################################################################
+#
+CARCH="<%= $pacman::makepkg::carch %>"
+CHOST="<%= $pacman::makepkg::chost %>"
+
+#-- Compiler and Linker Flags
+<%= if $pacman::makepkg::cppflags == undef { '#' } %>CPPFLAGS="<%= $pacman::makepkg::cppflags %>"
+CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
+ -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS \
+ -Wformat -Werror=format-security \
+ -fstack-clash-protection -fcf-protection"
+CXXFLAGS="<%= $pacman::makepkg::cxxflags %>"
+LDFLAGS="<%= $pacman::makepkg::ldflags %>"
+<%= if $pacman::makepkg::rustflags == undef { '#' } %>RUSTFLAGS="<%= $pacman::makepkg::rustflags %>"
+#-- Make Flags: change this for DistCC/SMP systems
+<%= if $pacman::makepkg::makeflags == undef { '#' } %>MAKEFLAGS="<%= $pacman::makepkg::makeflags %>"
+#-- Debugging flags
+DEBUG_CFLAGS="<%= $pacman::makepkg::debug_cflags %>"
+DEBUG_CXXFLAGS="<%= $pacman::makepkg::debug_cxxflags %>"
+<%= if $pacman::makepkg::debug_rustflags == undef { '#' } %>DEBUG_RUSTFLAGS="-C debuginfo=2"
+
+#########################################################################
+# BUILD ENVIRONMENT
+#########################################################################
+#
+# Makepkg defaults: BUILDENV=(!distcc !color !ccache check !sign)
+# A negated environment option will do the opposite of the comments below.
+#
+#-- distcc: Use the Distributed C/C++/ObjC compiler
+#-- color: Colorize output messages
+#-- ccache: Use ccache to cache compilation
+#-- check: Run the check() function if present in the PKGBUILD
+#-- sign: Generate PGP signature file
+#
+BUILDENV=(<%- $pacman::makepkg::buildenv.each |$key, $value| { -%>
+ <%= if ! $value { '!' } -%><%= $key -%>
+<%- } -%>)
+
+#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
+#-- specify a space-delimited list of hosts running in the DistCC cluster.
+<%= if $pacman::makepkg::distcc_hosts == undef { '#' } %>DISTCC_HOSTS="<%= $pacman::makepkg::distcc_hosts %>"
+#
+#-- Specify a directory for package building.
+<%= if $pacman::makepkg::builddir == undef { '#' } %>BUILDDIR="<%= $pacman::makepkg::builddir %>"
+
+#########################################################################
+# GLOBAL PACKAGE OPTIONS
+# These are default values for the options=() settings
+#########################################################################
+#
+# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug !lto)
+# A negated option will do the opposite of the comments below.
+#
+#-- strip: Strip symbols from binaries/libraries
+#-- docs: Save doc directories specified by DOC_DIRS
+#-- libtool: Leave libtool (.la) files in packages
+#-- staticlibs: Leave static library (.a) files in packages
+#-- emptydirs: Leave empty directories in packages
+#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
+#-- purge: Remove files specified by PURGE_TARGETS
+#-- debug: Add debugging flags as specified in DEBUG_* variables
+#-- lto: Add compile flags for building with link time optimization
+#
+OPTIONS=(<%- $pacman::makepkg::options.each |$key, $value| { -%>
+ <%= if ! $value { '!' } -%><%= $key -%>
+<%- } -%>)
+
+#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
+INTEGRITY_CHECK=(<%= $pacman::makepkg::integrity_check.join(' ') -%>)
+#-- Options to be used when stripping binaries. See `man strip' for details.
+STRIP_BINARIES="<%= $pacman::makepkg::strip_binaries %>"
+#-- Options to be used when stripping shared libraries. See `man strip' for details.
+STRIP_SHARED="<%= $pacman::makepkg::strip_shared %>"
+#-- Options to be used when stripping static libraries. See `man strip' for details.
+STRIP_STATIC="<%= $pacman::makepkg::strip_static %>"
+#-- Manual (man and info) directories to compress (if zipman is specified)
+MAN_DIRS=(<%= $pacman::makepkg::man_dirs.join(' ') -%>)
+#-- Doc directories to remove (if !docs is specified)
+DOC_DIRS=(<%= $pacman::makepkg::doc_dirs.join(' ') -%>)
+#-- Files to be removed from all packages (if purge is specified)
+PURGE_TARGETS=(<%= $pacman::makepkg::purge_targets.join(' ') -%>)
+#-- Directory to store source code in for debug packages
+DBGSRCDIR="<%= $pacman::makepkg::dbgsrcdir %>"
+
+#########################################################################
+# PACKAGE OUTPUT
+#########################################################################
+#
+# Default: put built package and cached source in build directory
+#
+#-- Destination: specify a fixed directory where all packages will be placed
+<%= if $pacman::makepkg::pkgdest == undef { '#' } %>PKGDEST="<%= $pacman::makepkg::pkgdest %>"
+#-- Source cache: specify a fixed directory where source files will be cached
+<%= if $pacman::makepkg::srcdest == undef { '#' } %>SRCDEST="<%= $pacman::makepkg::srcdest %>"
+#-- Source packages: specify a fixed directory where all src packages will be placed
+<%= if $pacman::makepkg::srcpkgdest == undef { '#' } %>SRCPKGDEST="<%= $pacman::makepkg::srcpkgdest %>"
+#-- Log files: specify a fixed directory where all log files will be placed
+<%= if $pacman::makepkg::logdest == undef { '#' } %>LOGDEST="<%= $pacman::makepkg::logdest %>"
+#-- Packager: name/email of the person or organization building packages
+<%= if $pacman::makepkg::packager == undef { '#' } %>PACKAGER="<%= $pacman::makepkg::packager %>"
+#-- Specify a key to use for package signing
+<%= if $pacman::makepkg::gpgkey == undef { '#' } %>GPGKEY="<%= $pacman::makepkg::gpgkey %>"
+
+#########################################################################
+# COMPRESSION DEFAULTS
+#########################################################################
+#
+COMPRESSGZ=(<%= $pacman::makepkg::compressgz -%>)
+COMPRESSBZ2=(<%= $pacman::makepkg::compressbz2 -%>)
+COMPRESSXZ=(<%= $pacman::makepkg::compressxz -%>)
+COMPRESSZST=(<%= $pacman::makepkg::compresszst -%>)
+COMPRESSLRZ=(<%= $pacman::makepkg::compresslrz -%>)
+COMPRESSLZO=(<%= $pacman::makepkg::compresslzo -%>)
+COMPRESSZ=(<%= $pacman::makepkg::compressz -%>)
+COMPRESSLZ4=(<%= $pacman::makepkg::compresslz4 -%>)
+COMPRESSLZ=(<%= $pacman::makepkg::compresslz -%>)
+
+#########################################################################
+# EXTENSION DEFAULTS
+#########################################################################
+#
+PKGEXT='<%= $pacman::makepkg::pkgext %>'
+SRCEXT='<%= $pacman::makepkg::srcext %>'
+
+#########################################################################
+# OTHER
+#########################################################################
+#
+#-- Command used to run pacman as root, instead of trying sudo and su
+<%= if $pacman::makepkg::pacman_auth == undef { '#' } %>PACMAN_AUTH=(<%= $pacman::makepkg::pacman_auth %>)
+