GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing wiki.archlinux.org — makepkg - ArchWiki
Related articles makepkg is a script to automate the building of packages. The requirements for using the script are a build-capable Unix platform and a PKGBUILD. makepkg is provided by the pacman package. ConfigurationThe system configuration is available in See makepkg.conf(5) for more information. Note devtools helper scripts for building packages in a clean chroot use the
/usr/share/devtools/makepkg.conf.d/$CARCH.conf configuration file instead.Packager informationEach package is tagged with metadata identifying amongst others also the packager. By default, user-compiled packages are marked with To check this on an installed package: $ pacman -Qi package ... Packager : John Doe <[email protected]> ... To automatically produce signed packages, also set the Package outputBy default, makepkg creates the package tarballs in the working directory and downloads source data directly to the Configure the following
Tip The
PKGDEST directory can be cleaned up with e.g. paccache -c ~/build/packages/ as described in pacman#Cleaning the package cache.You can also use relative paths inside each package directory. Signature checkingNote The signature checking implemented in makepkg does not use pacman's keyring, instead relying on the user's keyring.[1]
If a signature file in the form of .sig or .asc is part of the PKGBUILD source array, makepkg automatically attempts to verify it. In case the user's keyring does not contain the needed public key for signature verification, makepkg will abort the installation with a message that the PGP key could not be verified. If a needed public key for a package is missing, the PKGBUILD will most likely contain a validpgpkeys entry with the required key IDs and provide it under the UsageBefore continuing, install the base-devel meta package. Dependencies of this package are not required to be listed as build-time dependencies (makedepends) in PKGBUILD files. Note
To build a package, one must first create a PKGBUILD, or build script, as described in Creating packages. Existing scripts are available from the Arch build system (ABS) tree or the AUR. Once in possession of a $ makepkg If required dependencies are missing, makepkg will issue a warning before failing. To build the package and install needed dependencies, add the flag $ makepkg --syncdeps Adding the Note
Once all dependencies are satisfied and the package builds successfully, a package file ( $ makepkg --install To clean up leftover files and directories, such as files extracted to the $ makepkg --clean For more, see makepkg(8). OptimizationThe default options match the options devtools uses to build packages for the official repositories.[4] As such, end users may realize more or less significant gains by tweaking the following options to match their local environment. Building optimized binariesA performance improvement of the packaged software can be achieved by enabling compiler optimizations for the host machine. The downside is that binaries compiled for a specific processor architecture will not run correctly on other machines. On x86_64 machines, there are rarely significant enough real world performance gains that would warrant investing the time to rebuild official packages. However, it is very easy to reduce performance by using "non-standard" compiler flags. Many compiler optimizations are only useful in certain situations and should not be indiscriminately applied to every package. Unless benchmark data are available to prove that something is faster, there is a very good chance it is not! The Gentoo GCC optimization and Safe CFLAGS wiki articles provide more in-depth information about compiler optimization. C and C++The options passed to a C/C++ compiler (e.g. gcc or clang) are controlled by the Note
Architecture-specific optimizationsAll major compilers can automatically detect and enable safe architecture-specific optimizations. To use this feature, replace any /etc/makepkg.conf CFLAGS="-march=native -O2 -pipe ..."
CXXFLAGS="${CFLAGS} ..."
To see what flags this enables, run: $ gcc -march=native -v -Q --help=target Note Specifying different values instead of
-march=native, then -Q --help=target will not work as expected.[5] To find out which options are really enabled, go through a compilation. See Gentoo:Safe CFLAGS#Manual for instructions.Higher optimization levelFurther optimization of binaries can be achieved by enabling optimizations that are considered expensive in terms of memory usage and compile time. This can be achieved by changing the optimization level flag from RustMakepkg also includes overrides for the Rust upstream recommends using Cargo environment variables for the
See Cargo profile settings for details. There are some optimizations that can only be done via
See Rust codegen options for details. Improving build timesParallel compilationThe make build system uses the Users with multi-core/multi-processor systems can specify the number of jobs to run simultaneously. This can be accomplished with the use of nproc(1) to determine the number of available processors, e.g. Some See make(1) for a complete list of available options. Building from files in memoryAs compiling requires many I/O operations and handling of small files, moving the working directory to a tmpfs may bring improvements in build times. The $ BUILDDIR=/tmp/makepkg makepkg Persistent configuration can be done in Note
Using a compilation cacheThe use of ccache can improve build times by caching the results of compilations for successive use. Using mold linkermold is a drop-in replacement for ld/lld linkers, which claims to be significantly faster. To use mold, append /etc/makepkg.conf LDFLAGS="... -fuse-ld=mold" To pass extra options to mold, additionally add those to /etc/makepkg.conf LDFLAGS="... -fuse-ld=mold -Wl,--separate-debug-file" To use mold for Rust packages, append /etc/makepkg.conf.d/rust.conf RUSTFLAGS="... -C link-arg=-fuse-ld=mold" Disable debug packages and LTOMakepkg configuration shipped by pacman enables the Building debug packages enables the official repositories to provide more tools to troubleshoot issues for users [9], but it is not required when building packages on your own and slows down the build process [10]. Link-time optimization produces more optimized binaries but greatly lengthens the build process [11], which might not be a desired tradeoff. To disable those options, add a CompressionUse other compression algorithmsTo speed up both packaging and installation, with the tradeoff of having larger package archives, change For example, the following skips compression of the package file, which will in turn have no need to be decompressed on install: $ PKGEXT='.pkg.tar' makepkg As another example, the following uses the LZ4 algorithm, which is focused on speed: $ PKGEXT='.pkg.tar.lz4' makepkg To make one of these settings permanent, set Utilizing multiple cores on compressionzstd supports symmetric multiprocessing (SMP) via the COMPRESSZST=(zstd -c -T0 --auto-threads=logical -) lz4 and xz are multithreaded by default, so nothing needs to be changed in pigz is a drop-in, parallel implementation for gzip which by default uses all available CPU cores (the COMPRESSGZ=(pigz -c -f -n) pbzip2 is a drop-in, parallel implementation for bzip2 which also uses all available CPU cores by default. The COMPRESSBZ2=(pbzip2 -c -f) lbzip2 is another drop-in, parallel implementation for bzip2 which also uses all available CPU cores by default. The COMPRESSBZ2=(lbzip2 -c -f) plzipAUR is a multithreaded implementation for lzip which also uses all available CPU cores by default. The COMPRESSLZ=(plzip -c -f) Changing compression levelSeveral compression algorithms (including zstd and xz) support setting a compression level which defines a tradeoff between speed, memory and compression efficiency. Tips and tricksReduce source download and extraction timesDefining the sources locationMake use of Custom DLAGENTSYou can use a downloader supporting parallel downloading, e.g. axel: /etc/makepkg.conf DLAGENTS=('file::/bin/curl -gqC - -o %o %u'
'ftp::/bin/axel -n 2 -o %o %u'
'http::/bin/axel -n 2 -o %o %u'
'https::/bin/axel -n 2 -o %o %u')
See also Nonfree applications package guidelines#Custom DLAGENTS. Generate new checksumsInstall pacman-contrib and run the following command in the same directory as the PKGBUILD file to generate new checksums: $ updpkgsums
The checksums can also be obtained with e.g Build from local source filesIf you want to make changes to the source code you can download the source code without building the package by using the -o, --nobuild Download and extract files only option. $ makepkg -o You can now make changes to the sources and then build the package by using the -e, --noextract Do not extract source files (use existing $srcdir/ dir) option. Use the -f option to overwrite already built and existing packages. $ makepkg -ef Show packages with specific packagerexpac is a pacman database extraction utility. This command shows all packages installed on the system with the packager named packagername: $ expac "%n %p" | grep "packagername" | column -t This shows all packages installed on the system with the packager set in the $ . /etc/makepkg.conf; grep -xvFf <(pacman -Qqm) <(expac "%n\t%p" | grep "$PACKAGER$" | cut -f1) Build 32-bit packages on a 64-bit systemSee 32-bit package guidelines. Unattended package signingA person may not be available to provide the passphrase for the gpg private key used to sign with in automated build environments such as Jenkins. It is ill-advised to store a private gpg key on a system without a passphrase. A resulting zst package made with makepkg can still be signed after creation: $ gpg --detach-sign --pinentry-mode loopback --passphrase --passphrase-fd 0 --output NewlyBuilt.pkg.tar.zst.sig --sign NewlyBuilt.pkg.tar.zst where the GPG passphrase is securely provided and obscured by your automation suite of choice. The resulting Magnet URIsSupport for magnet URIs resources (with Running makepkg in a systemd control groupIf the package you are building takes too many resources to build with your default make flags, which are otherwise set properly for most packages, you can try running it in its own control group. makepkg-cgAUR is a wrapper for makepkg that achieved this via systemd control groups (see systemd.resource-control(5)). Running with idle scheduling policyPackage build process can lead to high CPU utilization, especially in case of #Parallel compilation. Under heavy CPU load, the system can issue a significant slowdown up to becoming unusable, even with the highest nice(1) value. User interface and foreground applications may stutter or even became unresponsive. This can be worked around by changing the scheduling policy to From sched(7) § SCHED_IDLE: Scheduling very low priority jobs:
The For most shells: $ chrt -iap 0 $$ Tip You can apply this command for every build by placing it into
makepkg.conf.For the fish shell, where $ chrt -iap 0 %self Relative paths inside each package directoryInstead of using absolute paths for the package output options, you can also configure relative paths inside each package directory. Note The following options might cause problems with some AUR helpers, as they might use
makepkg.conf in a context where $startdir is not defined. So be careful.For example, you can define target paths in your PKGDEST="$startdir/build/packages/" SRCDEST="$startdir/build/sources/" SRCPKGDEST="$startdir/build/srcpackages/" LOGDEST="$startdir/logs/" This will result in:
makepkg will still create TroubleshootingSpecifying install directory for QMAKE based packagesThe makefile generated by qmake uses the environment variable PKGBUILD ...
package() {
cd "$srcdir/${pkgname%-git}"
make INSTALL_ROOT="$pkgdir" install
}
...
Note, that qmake also has to be configured appropriately. For example put this in the corresponding .pro file: YourProject.pro ... target.path = /usr/local/bin INSTALLS += target ... WARNING: Package contains reference to $srcdirSomehow, the literal strings contained in the variables To identify which files, run the following from the makepkg build directory: $ grep -R "$PWD/src" pkg/ One possible cause would be from the usage of Dotnet binaries also sometimes contain full paths to the Makepkg fails to download dependencies when behind proxyWhen makepkg calls dependencies, it calls pacman to install the packages, which requires administrative privileges via sudo. However, sudo does not pass any environment variables to the privileged environment, and includes the proxy-related variables In order to have makepkg working behind a proxy, invoke one of the following methods. Enable proxy by setting its URL in XferCommandThe XferCommand can be set to use the desired proxy URL in /etc/pacman.conf ... XferCommand = /usr/bin/curl --proxy http://username:[email protected]:80 --location --continue-at - --fail --output %o %u ... Enable proxy via sudoer's env_keepAlternatively, one may want to use sudoer's Makepkg fails, but make succeedsIf something successfully compiles using make, but fails through makepkg, it is almost certainly because
If any of these fix the problem, this could warrant an upstream bug report assuming the offending flag has been identified. See alsoRetrieved from "https://wiki.archlinux.org/index.php?title=Makepkg&oldid=886871" |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |