Compare commits

..

53 Commits

Author SHA1 Message Date
Andrew Gregory
0c633c27ea Release v5.0.2
Signed-off-by: Andrew Gregory <andrew@archlinux.org>
2017-06-03 22:20:58 -04:00
Andrew Gregory
fdf53393bc update NEWS for v5.0.2
Signed-off-by: Andrew Gregory <andrew@archlinux.org>
2017-06-03 22:20:58 -04:00
Allan McRae
34d8beaef8 Pull translation changes for 5.0.2
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-31 23:47:00 +10:00
Allan McRae
d39271ab56 Prepare translations for 5.0.2 release
Pull translation updates from transifex and regenerate po files.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-22 11:03:33 +10:00
Andrew Gregory
831cc8d9cd extract db files with dbonly
Some database files (install, mtree, and changelog) are extracted
directly from the package, but DBONLY was skipping extraction
altogether, causing those files to be missing after the transaction.

Fixes #52052

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 2c4511bdbe)
2017-05-08 23:27:45 -04:00
Christian Hesse
e708b606ae add generated scripts to gitignore
These files are generated at build time. Ignore in git.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit fc756c3c70)
2017-05-08 23:27:45 -04:00
Christian Hesse
cd8debfbfb libalpm/signing: support EDDSA from gpgme 1.7.0
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit c3b954e7b9)
2017-05-08 23:27:45 -04:00
Andrew Gregory
0fd8455c66 unlink_file: strip trailing slashes
If the user replaces a directory with a symlink, libalpm would get
confused because the trailing slash causes system calls to resolve the
symlink.  This leads to errors and a misleading message during upgrades.
Even though libalpm does not support this, it should not be giving
misleading errors.

Also adds an overflow check.

Fixes FS#51377

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
(cherry picked from commit 16b91f798f)
2017-05-08 23:27:44 -04:00
Armin K
908769b540 libalpm: Use archive_read_extract2
archive_read_extract() forces resolution of uid/gid to names
when extracting the tarball. This can lead to wrong file
ownership when using pacman with -r option and when uid/gid
differ in the host and in the chroot.

archive_read_extract2() uses uid's and gid's only. See also:

https://lists.archlinux.org/pipermail/pacman-dev/2017-March/021912.html

Signed-off-by: Armin K <krejzi@email.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 86f5c74694)
2017-05-08 23:27:44 -04:00
Dave Reisner
33dbe13a6b makepkg.conf: add -g to default curl options
This disables globbing, which should never be used in source URL
specifications as it would lead to mismatches in the checksum mapping
and un-checked sources.

(cherry picked from commit e7fc560866)
2017-05-08 23:27:44 -04:00
Alad Wenter
7bb1c73cfa libmakepkg: generate all scripts
In order for the scripts to be used in testsuites, it is easiest to generate
all of them so they are found in the build directory (which may be different
to the source directory).

Signed-off-by: Alad Wenter <alad@archlinux.info>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit aca153bfa6)
2017-05-08 23:27:44 -04:00
Martin Kühne
c2aed8aaff Use f_bavail for diskspace calculations
This should make pacman's behavior consistent with GNU coreutils df,
as well as follow advice from affected filesystems' devs as well as
`man statvfs`.

This fixes FS#37402

Signed-off-by: Martin Kühne <mysatyre@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 8c55c0096c)
2017-05-08 23:27:44 -04:00
Allan McRae
80a0016de4 Ensure makepkg-wrapper is built after makepkg
makepkg-wrapper did not get rebuilt if makepkg was regenerated due to library
changes.  Ensure makepkg-wrapper is always generated and linked any time
makepkg changes.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit ad27aa30fb)
2017-05-08 23:27:44 -04:00
Allan McRae
722be61ca8 Move bash/zsh completion out of contrib
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 2e76c184aa)
2017-05-08 23:27:44 -04:00
Levente Polyak
5de2ad13fd fix --printsrcinfo unify arch and non-arch specific variables
This fixes the issue with --printsrcinfo that all arch specific variants
of a variable get merged into their non arch specific variant.

The .SRCINFO file ends up having $depends containing $depends_x86_64
and omitting the latter.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 3190b87b65)
2017-05-08 23:27:43 -04:00
Ivy Foster
c889403cf7 Do not #define _RESERVED_IDENTIFIERS
Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 0d2ba870c9)
2017-05-08 23:27:43 -04:00
Alastair Hughes
537f8c881c Add missing newline in paclog-pkglist help output
Add missing newline in paclog-pkglist help output

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 45b6a3074a)
2017-05-08 23:27:43 -04:00
Rikard Falkeborn
f6ccb46dc9 Change type of count in be_sync
Making it size_t matches the return value of alpm_list_count() and
avoids the implicit cast to int.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 6a5156eedc)
2017-05-08 23:27:43 -04:00
Rikard Falkeborn
7cc5012549 Return boolean from db_populate
Since the number of packages is not used anywhere, just return a
boolean to avoid the implicit cast from size_t to int in be_local.c.
Use 0 as success to be consistent with db_validate.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 85171807c1)
2017-05-08 23:27:43 -04:00
Rikard Falkeborn
22cadea56a Fix gcc strict-overflow error
Recent gcc (tested with 6.2.1) produces the following error when
compiling with both --enable-warningflags and --enable-debug.
In particular, it seems it is the combination of GCC_STACK_PROTECT_LIB
and -Wstrict-overflow=5 produces the error.

    be_local.c:609:4: error: assuming signed overflow does not occur
                             when simplifying conditional
                             [-Werror=strict-overflow]
    if(count > 0) {

Fix this by changing the type of count from int to size_t, which is
fine since count is never negative.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 34f3f1e7a6)
2017-05-08 23:27:43 -04:00
Fabio Castell
eca2e0f5ed repo-add: fix error in directories with a space in their name
Fixes FS#50285

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 07d1e0441b)
2017-05-08 23:27:43 -04:00
Ivy Foster
1f3793e71a lib/libalpm/be_sync.c: Close memory leaks when mallocing while out of memory
Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 900a22b90c)
2017-05-08 23:27:42 -04:00
Eli Schwartz
9e3aeb30d3 bash-completion: fix leaking "files" array into shell environment
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 38e229e4db)
2017-05-08 23:27:42 -04:00
Allan McRae
5a7204ee18 Fix memory leak in remove_notify_needed_optdepends
Also add pactest which captures this leak when run under valgrind.

Reported-by: Sergey Petrenko
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit fac4831a09)
2017-05-08 23:27:42 -04:00
Allan McRae
d6b6896a13 Fix typo in pacman-db-upgrade usage message
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit d560a9aecd)
2017-05-08 23:27:42 -04:00
Alastair Hughes
31af485d7e Remove AC_FUNC_MALLOC check.
We weren't supplying the rpl_malloc function needed if this failed, and
didn't check for realloc, so just remove.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 1dbfef7b1c)
2017-05-08 23:27:42 -04:00
Lukas Fleischer
4024bf0490 pacman.8: fix typo in the documentation of --asexplicit
Add a space between the option and its argument. Also, do not enclose
the argument in asterisk characters.

Fixes a typo introduced in aa4c61f (Document database checking options,
2014-12-28).

Reported-by: Luca Weiss <luca.emanuel.weiss@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 1e2b398406)
2017-05-08 23:27:42 -04:00
Giulio Fidente
6d5c70cf93 Merge Giolio Fidente into "Pacman Development Team" contribution
As discussed on mailing list:
https://lists.archlinux.org/pipermail/pacman-dev/2016-July/021239.html

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 69aee3e391)
2017-05-08 23:27:42 -04:00
Jack O'Connor
e20a502c40 libmakepkg: look for architecture-specific hashes in get_integlist
`makepkg -g` looks for existing checksums in the PKGBUILD file, so that
it can generate new sums of the same type. Previously it only checked
variables of the form "sha256sums", and not "sha256sums_x86_64". That
meant it would always fall back to MD5 for packages with only
architecture-specific sources. This change makes it look at
architecture-specific checksums too to determine the type.

Signed-off-by: Jack O'Connor <oconnor663@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 56de155296)

[andrew@archlinux.org: patch adapted to makepkg.sh.in]
2017-05-08 23:27:41 -04:00
Olivier Brunel
2e7162fe87 configure.ac: Fix handling --with-libcurl
It was reported being --with-libcurl in the help (and the check for libcurl
being installed used $with_libcurl accordingly), but the option handling was set
using $with_curl and, therefore, expected option --with-curl.

In the end, --with-libcurl wasn't recognized, and --with-curl had no effect.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 56ae960376)
2017-05-08 23:27:41 -04:00
Andrew Gregory
cebb20762d hook.c: replace fstatat with stat
macOS < 10.10 do not provide fstatat.  We were constructing the full
path to the hook file for all other operations anyway, so there was no
real benefit to using fstatat.

Fixes FS#49771

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit be1ffedaf6)
2017-05-08 23:27:41 -04:00
Andrew Gregory
e770b5728b hook.c: replace readdir_r with readdir
glibc 2.24 deprecates readdir_r.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit c981f5ad76)
2017-05-08 23:27:41 -04:00
Tobias Stoeckmann
21fe34c3a1 Handle all POSIX compliant systems in mbscasecmp.
The width of wchar_t is allowed to be of the same width as long,
according to standards. The return type of mbscasecmp is int though.

On amd64 with a 32 bit int, this means that mbscasecmp can return
zero (indicating that strings are equal) even though the input
strings differ.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit af83a58574)
2017-05-08 23:27:41 -04:00
Tobias Stoeckmann
3218360114 Reject files larger than 16384 bytes in read_sigfile.
If signature files are larger than SIZE_MAX, not enough memory could
be allocated for this file. The script repo-add rejects files which
are larger than 16384 bytes, therefore handle these as errors here,
too.

While at it, I also rearranged the code to avoid a quite harmless
TOCTOU race condition between stat() and fopen().

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 5fcd60e264)
2017-05-08 23:27:41 -04:00
Tobias Stoeckmann
8abb0cbf0e Release resources on error paths.
Some resources (memory or file descriptors) are not released on all
error paths.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 681509fd44)
2017-05-08 23:27:41 -04:00
Tobias Stoeckmann
e03c539288 Always use proper error code in alpm_initialize.
In out of memory conditions, an undefined error value is written
into *err, because myerr is never explicitly set in these cases.

I have also converted a calloc into a MALLOC call, because the memory
will be properly filled by the snprintf call right after it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 80d97fcf75)
2017-05-08 23:27:40 -04:00
Andrew Gregory
f31792adb5 recursedeps: include cyclic dependencies
Cyclic dependencies (A depends on B, B depends on A) were not selected
because neither package could be removed individually, so
can_remove_package would always return false for both.  By preselecting
all dependencies then filtering back out any dependencies still required
by any packages that will not be uninstalled, groups of unneeded cyclic
dependencies can be found.

Fixes FS#41031

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 6ac2ee21b3)
2017-05-08 23:27:40 -04:00
Christian Hesse
f84d0a8282 pacman.8: add link to alpm-hooks(5) in see also
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 839417e8c6)
2017-05-08 23:27:40 -04:00
Christian Hesse
689c413b96 libalpm.3: add link to alpm-hooks(5) in see also
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit f018317f48)
2017-05-08 23:27:40 -04:00
Alastair Hughes
b9bf727e33 makepkg: ignore the architecture for --printsrcinfo
Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 87082e3f44)
2017-05-08 23:27:40 -04:00
Allan McRae
2f1797783e Avoid logical OR duplication warning from gcc-6
The value EAGAIN is allowed by POSIX to be the same as EWOULDBLOCK, but this is
not guaranteed. Thus on some systems (e.g. glibc Linux), we get a warning that
the logical OR is being performed on two expressions of the same type. We can
not get rid of this test in case any system defines these as unique values.

Suggested-by: Dave Reisner
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 3729ef7a9a)
2017-05-08 23:27:40 -04:00
Ashley Whetter
a9bec8bed8 pacsort help clearly states that files contain inputs to be sorted
Fixes FS#44121

Signed-off-by: Ashley Whetter <ashley@awhetter.co.uk>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 6c96ad36e0)
2017-05-08 23:27:40 -04:00
Allan McRae
a5c23f0643 Prevent wrapping of enum items
GCC-6 points out that the value we use for the sentinal in enums is actually
too large for the integer type. Reduce the bitshift by one to fix this.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 5b9bc6024c)
2017-04-27 22:25:19 -04:00
Eric Engestrom
fcf4da76e0 fix spelling mistakes
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 2694d17ad9)
2017-04-27 22:25:08 -04:00
Andrew Gregory
d6ea5bd26d use multi-byte character matching for user input
Fixes FS#47992

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 02731189f1)
2017-04-27 22:21:54 -04:00
Allan McRae
cd7acd7529 repo-add: do not alter the database if only verifying signature
Fixes FS#48085.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit f363cf7857)
2017-04-27 22:21:33 -04:00
Allan McRae
9bddaac93c Use versions specified in optdepends
Checking install status and if a package is optionally required on removal
now considers the version of the optdepend.

Fixes FS#44957.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 3da06c3519)
2017-04-27 22:18:39 -04:00
Allan McRae
5211118a06 Consider provides when warning about optdepnd removal
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 59112e186b)
2017-04-27 22:12:42 -04:00
Allan McRae
c6e46c9ebb Consider provides when labelling optdepends status as pending install
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 76a7d2293c)
2017-04-27 22:12:28 -04:00
Leonid Isaev
c2f9758018 Use a more generic regexp when parsing output of gpg(1) in signature verification.
The current way of extracting key trust from output of gpg --verify is not very
robust against changes in the format of said output. As a result, pacman-key
can return an error even if the signature is actuall good.

This change relaxes the regexp when parsing output of gpg.

Signed-off-by: Leonid Isaev <leonid.isaev@jila.colorado.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 892a1076c0)
2016-05-18 15:46:59 +10:00
Allan McRae
5469161dad PKGBUILD.5: document that the pkgver() function runs after prepare()
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 5901038610)
2016-05-05 13:57:32 +10:00
Allan McRae
07ccbc2691 Do not add root prefix twice when checking database files
When checking .INSTALL and .CHANGELOG files in the mtree file, we need to find
the path they are stored in the local database. This was appending the root
prefix twice as alpm_option_get_dbpath already returns the absolute path to
the database.

While fixing that issue I added checks that the paths for the database files
were not longer than PATH_MAX.

Fixes FS#48563.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 2ee1706a72)
2016-05-05 13:56:27 +10:00
Allan McRae
a66cba1b08 libmakepkg: ensure emptydir find command acts on individual directories
Using "-exec command {} +" systax exits on any error.  Such errors occur when
running rmdir on a non-empty directory.  Switch to "{} ;" syntax instead which
avoids exiting before the find command is completed.

Fixes FS#48515.

Note, we can not use "-empty" in the find command because it is not supported
by Busybox find, and the "--ignore-fail-on-non-empty" flag for rmdir is not
available on BSD rmdir variants.

Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit baf1ff64e6)
2016-05-05 13:56:06 +10:00
466 changed files with 81383 additions and 52952 deletions

View File

@@ -1,20 +0,0 @@
# EditorConfig configuration for pacman
# http://EditorConfig.org
# Top-most EditorConfig file
root = true
# Unix-style newlines without trailing whitespaces, but with a newline
# ending every file, utf-8 charset, set indent to tabs
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = tab
[{NEWS,HACKING}]
indent_style = space
[*.py]
indent_style = space

View File

@@ -1,250 +0,0 @@
#!/usr/bin/env python
# SPDX-License-Identifier: Unlicense
#
# Based on the template file provided by the 'YCM-Generator' project authored by
# Reuben D'Netto.
# Jiahui Xie has re-reformatted and expanded the original script in accordance
# to the requirements of the PEP 8 style guide and 'systemd' project,
# respectively.
#
# The original license is preserved as it is.
#
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
"""
YouCompleteMe configuration file tailored to support the 'meson' build system
used by the 'systemd' project.
"""
import glob
import os
import ycm_core
SOURCE_EXTENSIONS = (".C", ".cpp", ".cxx", ".cc", ".c", ".m", ".mm")
HEADER_EXTENSIONS = (".H", ".h", ".hxx", ".hpp", ".hh")
def DirectoryOfThisScript():
"""
Return the absolute path of the parent directory containing this
script.
"""
return os.path.dirname(os.path.abspath(__file__))
def GuessBuildDirectory():
"""
Guess the build directory using the following heuristics:
1. Returns the current directory of this script plus 'build'
subdirectory in absolute path if this subdirectory exists.
2. Otherwise, probes whether there exists any directory
containing '.ninja_log' file two levels above the current directory;
returns this single directory only if there is one candidate.
"""
result = os.path.join(DirectoryOfThisScript(), "build")
if os.path.exists(result):
return result
result = glob.glob(os.path.join(DirectoryOfThisScript(),
"..", "..", "*", ".ninja_log"))
if not result:
return ""
if 1 != len(result):
return ""
return os.path.split(result[0])[0]
def TraverseByDepth(root, include_extensions):
"""
Return a set of child directories of the 'root' containing file
extensions specified in 'include_extensions'.
NOTE:
1. The 'root' directory itself is excluded from the result set.
2. No subdirectories would be excluded if 'include_extensions' is left
to 'None'.
3. Each entry in 'include_extensions' must begin with string '.'.
"""
is_root = True
result = set()
# Perform a depth first top down traverse of the given directory tree.
for root_dir, subdirs, file_list in os.walk(root):
if not is_root:
# print("Relative Root: ", root_dir)
# print(subdirs)
if include_extensions:
get_ext = os.path.splitext
subdir_extensions = {
get_ext(f)[-1] for f in file_list if get_ext(f)[-1]
}
if subdir_extensions & include_extensions:
result.add(root_dir)
else:
result.add(root_dir)
else:
is_root = False
return result
_project_src_dir = os.path.join(DirectoryOfThisScript(), "src")
_include_dirs_set = TraverseByDepth(_project_src_dir, frozenset({".h"}))
flags = [
"-x",
"c"
# The following flags are partially redundant due to the existence of
# 'compile_commands.json'.
# '-Wall',
# '-Wextra',
# '-Wfloat-equal',
# '-Wpointer-arith',
# '-Wshadow',
# '-std=gnu99',
]
for include_dir in _include_dirs_set:
flags.append("-I" + include_dir)
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = GuessBuildDirectory()
if os.path.exists(compilation_database_folder):
database = ycm_core.CompilationDatabase(compilation_database_folder)
else:
database = None
def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
"""
Iterate through 'flags' and replace the relative paths prefixed by
'-isystem', '-I', '-iquote', '--sysroot=' with absolute paths
start with 'working_directory'.
"""
if not working_directory:
return list(flags)
new_flags = []
make_next_absolute = False
path_flags = ["-isystem", "-I", "-iquote", "--sysroot="]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith("/"):
new_flag = os.path.join(working_directory, flag)
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith(path_flag):
path = flag[len(path_flag):]
new_flag = path_flag + os.path.join(working_directory, path)
break
if new_flag:
new_flags.append(new_flag)
return new_flags
def IsHeaderFile(filename):
"""
Check whether 'filename' is considered as a header file.
"""
extension = os.path.splitext(filename)[1]
return extension in HEADER_EXTENSIONS
def GetCompilationInfoForFile(filename):
"""
Helper function to look up compilation info of 'filename' in the 'database'.
"""
# The compilation_commands.json file generated by CMake does not have
# entries for header files. So we do our best by asking the db for flags for
# a corresponding source file, if any. If one exists, the flags for that
# file should be good enough.
if not database:
return None
if IsHeaderFile(filename):
basename = os.path.splitext(filename)[0]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists(replacement_file):
compilation_info = \
database.GetCompilationInfoForFile(replacement_file)
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile(filename)
def FlagsForFile(filename, **kwargs):
"""
Callback function to be invoked by YouCompleteMe in order to get the
information necessary to compile 'filename'.
It returns a dictionary with a single element 'flags'. This element is a
list of compiler flags to pass to libclang for the file 'filename'.
"""
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile(filename)
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_)
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to)
return {
"flags": final_flags,
"do_cache": True
}

13
HACKING
View File

@@ -11,8 +11,13 @@ Coding Style
1. All code should be indented with tabs. (Ignore the use of only spaces in 1. All code should be indented with tabs. (Ignore the use of only spaces in
this file.) A tab size of two spaces is used when calculating line widths, this file.) A tab size of two spaces is used when calculating line widths,
which should be a maximum of 80 characters. An EditorConfig file is used which should be a maximum of 80 characters. By default, source files
to set this project-wide default. contain the following Vim modeline:
+
[source,C]
-------------------------------------------
/* vim: set noet: */
-------------------------------------------
2. When opening new blocks such as 'while', 'if', or 'for', leave the opening 2. When opening new blocks such as 'while', 'if', or 'for', leave the opening
brace on the same line as the beginning of the codeblock. The closing brace brace on the same line as the beginning of the codeblock. The closing brace
@@ -189,3 +194,7 @@ For example, to run valgrind:
./src/pacman/pacman ./src/pacman/pacman
valgrind --leak-check=full -- src/pacman/.libs/lt-pacman -Syu valgrind --leak-check=full -- src/pacman/.libs/lt-pacman -Syu
/////
vim:set syntax=asciidoc noet spell spelllang=en_us:
/////

View File

@@ -3,14 +3,13 @@ if WANT_DOC
SUBDIRS += doc SUBDIRS += doc
endif endif
DIST_SUBDIRS = $(SUBDIRS) src/common DIST_SUBDIRS = $(SUBDIRS) contrib src/common
ACLOCAL_AMFLAGS = -I m4 --install ACLOCAL_AMFLAGS = -I m4 --install
AM_MAKEFLAGS = --no-print-directory AM_MAKEFLAGS = --no-print-directory
# Make sure we test and build manpages when doing distcheck # Make sure we test and build manpages when doing distcheck
DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version \ DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version
bashcompdir='$${prefix}/share/bash-completion/completions'
# Some files automatically included, so they aren't specified below: # Some files automatically included, so they aren't specified below:
# AUTHORS, COPYING, NEWS, README # AUTHORS, COPYING, NEWS, README
@@ -31,6 +30,7 @@ TESTS = test/scripts/parseopts_test.sh \
test/scripts/human_to_size_test.sh \ test/scripts/human_to_size_test.sh \
test/scripts/makepkg-template_test.sh \ test/scripts/makepkg-template_test.sh \
test/scripts/pacman-db-upgrade-v9.py \ test/scripts/pacman-db-upgrade-v9.py \
test/util/pacsorttest.sh \
test/util/vercmptest.sh test/util/vercmptest.sh
include $(top_srcdir)/test/pacman/tests/TESTS include $(top_srcdir)/test/pacman/tests/TESTS
@@ -39,8 +39,7 @@ TEST_EXTENSIONS = .py
AM_TESTS_ENVIRONMENT = \ AM_TESTS_ENVIRONMENT = \
PMTEST_UTIL_DIR=$(top_builddir)/src/util/; export PMTEST_UTIL_DIR; \ PMTEST_UTIL_DIR=$(top_builddir)/src/util/; export PMTEST_UTIL_DIR; \
PMTEST_SCRIPT_DIR=$(top_builddir)/scripts/; export PMTEST_SCRIPT_DIR; \ PMTEST_SCRIPT_DIR=$(top_builddir)/scripts/; export PMTEST_SCRIPT_DIR; \
PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR; \ PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR;
PMTEST_LIBMAKEPKG_DIR=$(top_builddir)/scripts/libmakepkg/; export PMTEST_LIBMAKEPKG_DIR;
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh $(top_srcdir)/build-aux/tap-driver.sh
PY_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ PY_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
@@ -51,12 +50,6 @@ AM_PY_LOG_FLAGS = \
--ldconfig $(LDCONFIG) \ --ldconfig $(LDCONFIG) \
--bindir $(top_builddir)/src/pacman \ --bindir $(top_builddir)/src/pacman \
--bindir $(top_builddir)/scripts --bindir $(top_builddir)/scripts
if !HAVE_LIBGPGME
AM_PY_LOG_FLAGS += --without-gpg
endif
if !HAVE_LIBCURL
AM_PY_LOG_FLAGS += --without-curl
endif
# create the pacman DB, cache, makepkg-template and system hook directories upon install # create the pacman DB, cache, makepkg-template and system hook directories upon install
install-data-local: install-data-local:
@@ -76,3 +69,5 @@ update-copyright:
done done
.PHONY: update-po update-copyright .PHONY: update-po update-copyright
# vim:set noet:

158
NEWS
View File

@@ -1,149 +1,5 @@
VERSION DESCRIPTION VERSION DESCRIPTION
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
5.1.2 - pacman-conf: add missing DisableDownloadTimeout support
- Include version when checking optdepend install status
during -Qi (FS#60106)
- Improve error message for unresolvable urls (FS#48285)
- Do not raise SIGINT when a downloaded file exceeds the expected
size
- Fix previous download interruption status carrying over to new
downloads
- Reset known signal handlers before running install scripts or
hooks (FS#56756)
- Properly handle signal interrupts while running install scripts
or hooks (FS#60396)
- Allow explicitly disabling signature checks when compiled
without signature support (FS#60880)
- makepkg: fix linting error on environment variables (FS#60681)
5.1.1 - Allow full path including root prefix to be passed to
--overwrite
- Revert deprecation of --root
- Document comment syntax restrictions in pacman.conf
- makepkg:
- handle pre-existing directories when checking for write
permissions
- reduce restrictions on pkgver in depends listings (FS#58776)
- permit versioned optdepends
- remove unintended chmod of $BUILDDIR (FS#58790)
- fix issue when $startdir was not an absolute path (FS#58865)
- fix syntax error when $pkgname is empty
- fix --nocolor being passed to pacman (FS#58820)
- fix issues with trap handling
- fix several issues with debug packages (signing, printing of
package names, clearing of global package options, source
file inclusion)
- fix --help text for --packagelist
- pacman-conf: Fix detection of Usage option
5.1.0 - Add new --overwrite option and deprecate --force. This accepts a
glob pattern with far more control than the widely abused force
option which mostly just causes issues (FS#31549)
- Add new --sysroot option and deprecate --root. This uses the
guest configuration instead of the host configuration, which is
what most people erroneously thought --root would do
- introduce a 'disable-download-timeout' option
- remove contrib - this is now maintained in a separate project
- report the owner of an existing file, if any, when erroring out
on a file conflict
- resolve cyclic dependencies when calculating unneeded dependency
trees (FS#41031)
- report the needed command to download missing databases for the
-F and -S actions
- don't error if -Qo cannot find the file it is querying on disk
(FS#55856)
- support new-style OpenPGP format packets lengths
- support EDDSA from gpgme 1.7.0
- fix continuously trying to open invalid databases and reporting
excessively excessive redundant error messages excessively
- fix the download callback erroneously reporting itself too many
times with --noprogressbar, or reporting inaccurate times for
small files (FS#56408, FS#56468)
- fix erroneous negative speed in download progressbar (FS#43434)
- parse stdin as newline-separated instead of whitespace-separated
(FS#52992)
- when printing urls in the package cache, print the file url
instead (FS#15868)
- add color to group selection dialogs and -{F,Q}o
- the -Q option now respects provides (FS#20650)
- remove notification of system upgrade when only printing URLs
- print replacements when using -Sup (FS#35812)
- fix -Qk and -r checking for the root prefix twice (FS#48563)
- Do not recognize # as a comment unless it is at the beginning of
a line. This allows using it as a value in ini files (FS#48702)
- ignore comments when examining INSTALL files (FS#51916)
- match multi-byte user input properly (FS#47992)
- abort transactions if even one database fails to sync (FS#47599)
- do not resolve uid/gid to names when extracting files with -r
- --dbonly now properly extracts metadata files (FS#52052)
- remove support for internal checksumming implementations, and
require at least one of openssl or nettle to exist
- consider provides to satisfy optdepends when warning for removal
or logging new optdepends during a transaction, as was already
the case for -Qi
- -Dk now reports if it is successful (FS#50087)
- consider version for optdepends (FS#44957)
- remove vim modelines in favor of EditorConfig
- implement pacman-conf, a new tool to safely parse pacman.conf,
and use it in internal scripts
- bash completion now completes -Qn
- various small documentation updates
- makepkg:
- Reproducible build support. makepkg now respects environment
SOURCE_DATE_EPOCH when creating package metadata, and unifies
source file timestamps to match
- add more info to .BUILDINFO to aid in reproducing the build
environment of a package
- it is now possible to check the signature of VCS sources
(currently only git is supported)
- use informative exit codes when exiting with errors (FS#54204)
- lint_pkgbuild has vastly improved linting of pkgname and
variables that can contain pkgname/pkgver (FS#57833)
- implement linting for makepkg.conf
- fix using libmakepkg in external scripts without extglob
- fix handling of configurable directories e.g. PKGDEST to align
with their documented behavior, and consistently check that
they can be used (FS#43537)
- parseopts, srcinfo, and integrity are now part of libmakepkg
- consistently use coreutils for checksumming instead of openssl
(which may be replaced by nettle in pacman)
- lint build_references now prints affected filenames (FS#31558)
- lint_package can now abort on fatal packaging errors
- lint_package now checks for filenames with newline characters
- lint_package now checks for root-level /.dotfiles
- debug packages are now per pkgbase, not per pkgname
- debug packages now contain source files to allow the debugger
to step through code
- remove optipng and upx support - these can now be plugged into
libmakepkg
- fix emptydirs support with newer findutils (FS#48515)
- ignore architecture for --printsrcinfo
- makepkg --printsrcinfo now correctly lists depends_$CARCH
instead of merging this into depends
- fix bug in is_array that broke packages with arch-dependent
sources only (FS#48340)
- move package signing outside of fakeroot which is incompatible
with recent gnupg versions (FS#49946)
- makepkg --clean now cleans up logfiles (FS#51039)
- when using $PKGDEST, do not symlink build artifacts into
current directory
- --packagelist now lists the built filenames, rather than all
possible basenames without extensions
- fix --geninteg not properly ignoring renamed signature files
- use localized date strings
- ensure sane umask is set both before and after installing deps
- adapt to file(1) changes in order to continue to strip PIE
executables
- repo-add:
- don't recreate the database when only verifying signature
(FS#48085)
- fix error when repo directory path contains spaces (FS#50285)
- pacman-key:
- reject armored signatures
- don't set a default keyserver, deferring to gpg's sane default
- disable scdaemon as we don't use it and it breaks --lsign when
a smartcard is plugged into the machine
- vercmp:
- remove duplicate, undocumented --usage option
- fail when the wrong number of arguments are used (FS#49093)
5.0.2 - fix database file checks with -Qkk and non-standard root 5.0.2 - fix database file checks with -Qkk and non-standard root
(FS#48563) (FS#48563)
- improve optdepend detection for status messages (FS#44957) - improve optdepend detection for status messages (FS#44957)
@@ -167,7 +23,7 @@ VERSION DESCRIPTION
- fix triggering of Install hooks (FS#47996) - fix triggering of Install hooks (FS#47996)
- fix handling of stdin scripts called by pacman - fix handling of stdin scripts called by pacman
- hook activity is logged - hook activity is logged
- documentation updates for alpm-hooks (FS#48080) - documentataion updates for alpm-hooks (FS#48080)
- makepkg: - makepkg:
- increase robustness of variable array checks - increase robustness of variable array checks
- makepkg -g does not perform current architecture checks - makepkg -g does not perform current architecture checks
@@ -259,9 +115,9 @@ VERSION DESCRIPTION
- Fix removal of static libraries when the shared library - Fix removal of static libraries when the shared library
uses the absolute path in symbolic links (FS#43395) uses the absolute path in symbolic links (FS#43395)
- Improve Bazaar cloning (FS#43448) - Improve Bazaar cloning (FS#43448)
- Fix issues with architecture dependent checksum - Fix issues with architecture dependant checksum
verification (FS#43192) verification (FS#43192)
- Fix .SRCINFO file with architecture dependent fields - Fix .SRCINFO file with architecture dependant fields
(FS#43247) (FS#43247)
- Fix compatibility with older bash versions - Fix compatibility with older bash versions
- Allow git checkouts to be downloaded into directory ending - Allow git checkouts to be downloaded into directory ending
@@ -351,7 +207,7 @@ VERSION DESCRIPTION
- checkupdates: rename CHECKUPDATE_DB to CHECKUPDATES_DB - checkupdates: rename CHECKUPDATE_DB to CHECKUPDATES_DB
- pacdiff: add a "Quit" option, and many other improvements - pacdiff: add a "Quit" option, and many other improvements
- pacsysclean is removed - pacsysclean is removed
4.1.2 - validate %FILEPATH% when parsing repos to prevent arbitrary 4.1.2 - validate %FILEPATH% when parsing repos to prevent arbitary
file overwrites from malicious databases file overwrites from malicious databases
- makepkg: - makepkg:
- restrict package name from starting with a dot - restrict package name from starting with a dot
@@ -816,7 +672,7 @@ VERSION DESCRIPTION
- repo-add: use openssl instead of md5sum - repo-add: use openssl instead of md5sum
- simplify doc building process for ease of development - simplify doc building process for ease of development
- ensure correct handling of syscall interruptions - ensure correct handling of syscall interruptions
- re-add missing newline on -Qi/-Si output (FS#11331) - readd missing newline on -Qi/-Si output (FS#11331)
- fix TotalDownload regression (FS#11339) - fix TotalDownload regression (FS#11339)
- makepkg: - makepkg:
- replace getopt with an internal function - replace getopt with an internal function
@@ -1262,7 +1118,7 @@ VERSION DESCRIPTION
external download utility like wget external download utility like wget
- added a license field to package meta-data - added a license field to package meta-data
- add url support to -A and -U operations (download packages) - add url support to -A and -U operations (download packages)
- -Ss now searches through provides fields - -Ss now searches thru provides fields
- added --dbonly option to -R - added --dbonly option to -R
2.7.6 - added --print-uris option 2.7.6 - added --print-uris option
- fixed an http download bug (FS#667) - fixed an http download bug (FS#667)
@@ -1420,3 +1276,5 @@ VERSION DESCRIPTION
backed up, then it will be copied to "file.save" backed up, then it will be copied to "file.save"
- Changed db_find_conflicts() to ignore directories - Changed db_find_conflicts() to ignore directories
1.0 - Initial Release 1.0 - Initial Release
vim: set et spell spelllang=en_us:

39
README
View File

@@ -592,42 +592,3 @@ API CHANGES BETWEEN 4.2 AND 5.0
- ALPM_EVENT_TRANSACTION_START, ALPM_EVENT_TRANSACTION_DONE - ALPM_EVENT_TRANSACTION_START, ALPM_EVENT_TRANSACTION_DONE
- database unlocking - database unlocking
- alpm_unlock() - alpm_unlock()
API CHANGES BETWEEN 5.0 AND 5.1
===============================
[CHANGED]
- alpm_errno_t - added member ALPM_ERR_OK
- alpm_siglevel_t - value of ALPM_SIG_USE_DEFAULT changed
- functions using bitfields return/pass an int instead of an enum
- alpm_option_get_default_siglevel()
- alpm_option_set_default_siglevel()
- alpm_option_get_remote_file_siglevel()
- alpm_option_set_remote_file_siglevel()
- alpm_register_syncdb()
- alpm_db_get_siglevel()
- alpm_db_set_usage()
- alpm_db_get_usage()
- alpm_pkg_load()
- alpm_pkg_get_validation()
- alpm_trans_get_flags()
- alpm_trans_init()
- alpm_option_get_local_file_siglevel()
- alpm_option_set_local_file_siglevel()
[ADDED]
- overwrite support
- alpm_option_get_overwrite_files()
- alpm_option_set_overwrite_files()
- alpm_option_add_overwrite_file()
- alpm_option_remove_overwrite_file()
- download timeout control
- alpm_option_set_disable_dl_timeout()
- access make/checkdepends info
- alpm_pkg_get_checkdepends()
- alpm_pkg_get_makedepends()
- check pacman capabilities
- alpm_capabilities()
- duplicate and add to list
- alpm_list_append_strdup()

23
RELEASE
View File

@@ -1,23 +0,0 @@
The following checklist should be used for making a pacman release.
- Ensure "make distcheck" succeeds
- Call a freeze to development.
- Send translation updates to Transifex at least two weeks before a major
release (see below). At this stage, strings can only be changed for a
major issue.
- Update NEWS and README files
- Pull translation updates from Transifex
- Update version in configure.ac as described in file
- Update doc/index.asciidoc
- Create a signed git tag (git tag -s vX.Y.Z -m "commit message")
- Create and sign release tarballs (generate with "make distcheck")
- Update pacman website
Transifex updates are handled using the transifex client. The basic process is:
- Pull updates from transifex ("tx pull -a -f --minimum-perc 75")
- Update po files ("make update-po")
- Fix all translation errors found
- Add any new locales to the relevant LINGUAS file
- Optional: Make any manual changes needed (e.g. fixing spacing in a string)
and update po files again
- Push updated po files to transifex ("tx push -s -t --skip")

View File

@@ -1,33 +0,0 @@
#!@BASH@
input=$1
output=$2
mode=$3
"@SED@" \
-e "s|@rootdir[@]|@ROOTDIR@|g" \
-e "s|@localedir[@]|@LOCALEDIR@|g" \
-e "s|@sysconfdir[@]|@sysconfdir@|g" \
-e "s|@localstatedir[@]|@localstatedir@|g" \
-e "s|@libmakepkgdir[@]|@LIBMAKEPKGDIR@|g" \
-e "s|@pkgdatadir[@]|@PKGDATADIR@|g" \
-e "s|@prefix[@]|@PREFIX@|g" \
-e "1s|#!/bin/bash|#!@BASH@|g" \
-e "s|@PACKAGE_VERSION[@]|@PACKAGE_VERSION@|g" \
-e "s|@PACKAGE_NAME[@]|@PACKAGE_NAME@|g" \
-e "s|@BUILDSCRIPT[@]|@BUILDSCRIPT@|g" \
-e "s|@TEMPLATE_DIR[@]|@TEMPLATE_DIR@|g" \
-e "s|@DEBUGSUFFIX[@]|@DEBUGSUFFIX@|g" \
-e "s|@INODECMD[@]|@INODECMD@|g" \
-e "s|@OWNERCMD[@]|@OWNERCMD@|g" \
-e "s|@MODECMD[@]|@MODECMD@|g" \
-e "s|@SEDINPLACEFLAGS[@]|@SEDINPLACEFLAGS@|g" \
-e "s|@SEDPATH[@]|@SEDPATH@|g" \
-e "s|@DUFLAGS[@]|@DUFLAGS@|g" \
-e "s|@DUPATH[@]|@DUPATH@|g" \
-e "s|@configure_input[@]|Generated from ${input##*/}; do not edit by hand.|g" \
"$input" >"$output"
if [[ $mode ]]; then
chmod "$mode" "$output"
fi

View File

@@ -1,6 +0,0 @@
#!/bin/sh
built_script=$1
dest_path=$2
install -Dm755 "$built_script" "$DESTDIR/$dest_path"

View File

@@ -1,12 +0,0 @@
#!/bin/sh
set -eu
# this is needed mostly because $DESTDIR is provided as a variable,
# and we need to create the target directory...
mkdir -vp "$(dirname "${DESTDIR:-}$2")"
if [ "$(dirname $1)" = . ]; then
ln -vfs -T "$1" "${DESTDIR:-}$2"
else
ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2"
fi

View File

@@ -1,6 +0,0 @@
#!/bin/bash
# This script serves as a trampoline for running scripts which depend on
# libmakepkg with the libmakepkg within the build tree.
LIBRARY=@BUILDDIR@/libmakepkg exec @BASH@ -$- @REAL_PROGPATH@ "$@"

View File

@@ -1,296 +0,0 @@
#!/usr/bin/env python3
# Adapted from tappy copyright (c) 2016, Matt Layman
# MIT license
# https://github.com/python-tap/tappy
import io
import re
import subprocess
import sys
class Directive(object):
"""A representation of a result line directive."""
skip_pattern = re.compile(
r"""^SKIP\S*
(?P<whitespace>\s*) # Optional whitespace.
(?P<reason>.*) # Slurp up the rest.""",
re.IGNORECASE | re.VERBOSE)
todo_pattern = re.compile(
r"""^TODO\b # The directive name
(?P<whitespace>\s*) # Immediately following must be whitespace.
(?P<reason>.*) # Slurp up the rest.""",
re.IGNORECASE | re.VERBOSE)
def __init__(self, text):
"""Initialize the directive by parsing the text.
The text is assumed to be everything after a '#\s*' on a result line.
"""
self._text = text
self._skip = False
self._todo = False
self._reason = None
match = self.skip_pattern.match(text)
if match:
self._skip = True
self._reason = match.group('reason')
match = self.todo_pattern.match(text)
if match:
if match.group('whitespace'):
self._todo = True
else:
# Catch the case where the directive has no descriptive text.
if match.group('reason') == '':
self._todo = True
self._reason = match.group('reason')
@property
def text(self):
"""Get the entire text."""
return self._text
@property
def skip(self):
"""Check if the directive is a SKIP type."""
return self._skip
@property
def todo(self):
"""Check if the directive is a TODO type."""
return self._todo
@property
def reason(self):
"""Get the reason for the directive."""
return self._reason
class Parser(object):
"""A parser for TAP files and lines."""
# ok and not ok share most of the same characteristics.
result_base = r"""
\s* # Optional whitespace.
(?P<number>\d*) # Optional test number.
\s* # Optional whitespace.
(?P<description>[^#]*) # Optional description before #.
\#? # Optional directive marker.
\s* # Optional whitespace.
(?P<directive>.*) # Optional directive text.
"""
ok = re.compile(r'^ok' + result_base, re.VERBOSE)
not_ok = re.compile(r'^not\ ok' + result_base, re.VERBOSE)
plan = re.compile(r"""
^1..(?P<expected>\d+) # Match the plan details.
[^#]* # Consume any non-hash character to confirm only
# directives appear with the plan details.
\#? # Optional directive marker.
\s* # Optional whitespace.
(?P<directive>.*) # Optional directive text.
""", re.VERBOSE)
diagnostic = re.compile(r'^#')
bail = re.compile(r"""
^Bail\ out!
\s* # Optional whitespace.
(?P<reason>.*) # Optional reason.
""", re.VERBOSE)
version = re.compile(r'^TAP version (?P<version>\d+)$')
TAP_MINIMUM_DECLARED_VERSION = 13
def parse(self, fh):
"""Generate tap.line.Line objects, given a file-like object `fh`.
`fh` may be any object that implements both the iterator and
context management protocol (i.e. it can be used in both a
"with" statement and a "for...in" statement.)
Trailing whitespace and newline characters will be automatically
stripped from the input lines.
"""
with fh:
for line in fh:
yield self.parse_line(line.rstrip())
def parse_line(self, text):
"""Parse a line into whatever TAP category it belongs."""
match = self.ok.match(text)
if match:
return self._parse_result(True, match)
match = self.not_ok.match(text)
if match:
return self._parse_result(False, match)
if self.diagnostic.match(text):
return ('diagnostic', text)
match = self.plan.match(text)
if match:
return self._parse_plan(match)
match = self.bail.match(text)
if match:
return ('bail', match.group('reason'))
match = self.version.match(text)
if match:
return self._parse_version(match)
return ('unknown',)
def _parse_plan(self, match):
"""Parse a matching plan line."""
expected_tests = int(match.group('expected'))
directive = Directive(match.group('directive'))
# Only SKIP directives are allowed in the plan.
if directive.text and not directive.skip:
return ('unknown',)
return ('plan', expected_tests, directive)
def _parse_result(self, ok, match):
"""Parse a matching result line into a result instance."""
return ('result', ok, match.group('number'),
match.group('description').strip(),
Directive(match.group('directive')))
def _parse_version(self, match):
version = int(match.group('version'))
if version < self.TAP_MINIMUM_DECLARED_VERSION:
raise ValueError('It is an error to explicitly specify '
'any version lower than 13.')
return ('version', version)
class Rules(object):
def __init__(self):
self._lines_seen = {'plan': [], 'test': 0, 'failed': 0, 'version': []}
self._errors = []
def check(self, final_line_count):
"""Check the status of all provided data and update the suite."""
if self._lines_seen['version']:
self._process_version_lines()
self._process_plan_lines(final_line_count)
def check_errors(self):
if self._lines_seen['failed'] > 0:
self._add_error('Tests failed.')
if self._errors:
for error in self._errors:
print(error)
return 1
return 0
def _process_version_lines(self):
"""Process version line rules."""
if len(self._lines_seen['version']) > 1:
self._add_error('Multiple version lines appeared.')
elif self._lines_seen['version'][0] != 1:
self._add_error('The version must be on the first line.')
def _process_plan_lines(self, final_line_count):
"""Process plan line rules."""
if not self._lines_seen['plan']:
self._add_error('Missing a plan.')
return
if len(self._lines_seen['plan']) > 1:
self._add_error('Only one plan line is permitted per file.')
return
expected_tests, at_line = self._lines_seen['plan'][0]
if not self._plan_on_valid_line(at_line, final_line_count):
self._add_error(
'A plan must appear at the beginning or end of the file.')
return
if expected_tests != self._lines_seen['test']:
self._add_error(
'Expected {expected_count} tests '
'but only {seen_count} ran.'.format(
expected_count=expected_tests,
seen_count=self._lines_seen['test']))
def _plan_on_valid_line(self, at_line, final_line_count):
"""Check if a plan is on a valid line."""
# Put the common cases first.
if at_line == 1 or at_line == final_line_count:
return True
# The plan may only appear on line 2 if the version is at line 1.
after_version = (
self._lines_seen['version'] and
self._lines_seen['version'][0] == 1 and
at_line == 2)
if after_version:
return True
return False
def handle_bail(self, reason):
"""Handle a bail line."""
self._add_error('Bailed: {reason}').format(reason=reason)
def handle_skipping_plan(self):
"""Handle a plan that contains a SKIP directive."""
sys.exit(77)
def saw_plan(self, expected_tests, at_line):
"""Record when a plan line was seen."""
self._lines_seen['plan'].append((expected_tests, at_line))
def saw_test(self, ok):
"""Record when a test line was seen."""
self._lines_seen['test'] += 1
if not ok:
self._lines_seen['failed'] += 1
def saw_version_at(self, line_counter):
"""Record when a version line was seen."""
self._lines_seen['version'].append(line_counter)
def _add_error(self, message):
self._errors += [message]
if __name__ == '__main__':
parser = Parser()
rules = Rules()
try:
out = subprocess.check_output(sys.argv[1:], universal_newlines=True)
except subprocess.CalledProcessError as e:
sys.stdout.write(e.output)
raise e
line_generator = parser.parse(io.StringIO(out))
line_counter = 0
for line in line_generator:
line_counter += 1
if line[0] == 'unknown':
continue
if line[0] == 'result':
rules.saw_test(line[1])
print('{okay} {num} {description} {directive}'.format(
okay=('' if line[1] else 'not ') + 'ok', num=line[2],
description=line[3], directive=line[4].text))
elif line[0] == 'plan':
if line[2].skip:
rules.handle_skipping_plan()
rules.saw_plan(line[1], line_counter)
elif line[0] == 'bail':
rules.handle_bail(line[1])
elif line[0] == 'version':
rules.saw_version_at(line_counter)
elif line[0] == 'diagnostic':
print(line[1])
rules.check(line_counter)
sys.exit(rules.check_errors())

652
build-aux/tap-driver.sh Executable file
View File

@@ -0,0 +1,652 @@
#! /bin/sh
# Copyright (C) 2011-2013 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
scriptversion=2011-12-27.17; # UTC
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
me=tap-driver.sh
fatal ()
{
echo "$me: fatal: $*" >&2
exit 1
}
usage_error ()
{
echo "$me: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
tap-driver.sh --test-name=NAME --log-file=PATH --trs-file=PATH
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--enable-hard-errors={yes|no}] [--ignore-exit]
[--diagnostic-string=STRING] [--merge|--no-merge]
[--comments|--no-comments] [--] TEST-COMMAND
The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory.
END
}
# TODO: better error handling in option parsing (in particular, ensure
# TODO: $log_file, $trs_file and $test_name are defined).
test_name= # Used for reporting.
log_file= # Where to save the result and output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=0
color_tests=0
merge=0
ignore_exit=0
comments=0
diag_string='#'
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "$me $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) shift;; # No-op.
--merge) merge=1;;
--no-merge) merge=0;;
--ignore-exit) ignore_exit=1;;
--comments) comments=1;;
--no-comments) comments=0;;
--diagnostic-string) diag_string=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
esac
shift
done
test $# -gt 0 || usage_error "missing test command"
case $expect_failure in
yes) expect_failure=1;;
*) expect_failure=0;;
esac
if test $color_tests = yes; then
init_colors='
color_map["red"]="" # Red.
color_map["grn"]="" # Green.
color_map["lgn"]="" # Light green.
color_map["blu"]="" # Blue.
color_map["mgn"]="" # Magenta.
color_map["std"]="" # No color.
color_for_result["ERROR"] = "mgn"
color_for_result["PASS"] = "grn"
color_for_result["XPASS"] = "red"
color_for_result["FAIL"] = "red"
color_for_result["XFAIL"] = "lgn"
color_for_result["SKIP"] = "blu"'
else
init_colors=''
fi
# :; is there to work around a bug in bash 3.2 (and earlier) which
# does not always set '$?' properly on redirection failure.
# See the Autoconf manual for more details.
:;{
(
# Ignore common signals (in this subshell only!), to avoid potential
# problems with Korn shells. Some Korn shells are known to propagate
# to themselves signals that have killed a child process they were
# waiting for; this is done at least for SIGINT (and usually only for
# it, in truth). Without the `trap' below, such a behaviour could
# cause a premature exit in the current subshell, e.g., in case the
# test command it runs gets terminated by a SIGINT. Thus, the awk
# script we are piping into would never seen the exit status it
# expects on its last input line (which is displayed below by the
# last `echo $?' statement), and would thus die reporting an internal
# error.
# For more information, see the Autoconf manual and the threads:
# <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
# <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
trap : 1 3 2 13 15
if test $merge -gt 0; then
exec 2>&1
else
exec 2>&3
fi
"$@"
echo $?
) | LC_ALL=C ${AM_TAP_AWK-awk} \
-v me="$me" \
-v test_script_name="$test_name" \
-v log_file="$log_file" \
-v trs_file="$trs_file" \
-v expect_failure="$expect_failure" \
-v merge="$merge" \
-v ignore_exit="$ignore_exit" \
-v comments="$comments" \
-v diag_string="$diag_string" \
'
# FIXME: the usages of "cat >&3" below could be optimized when using
# FIXME: GNU awk, and/on on systems that supports /dev/fd/.
# Implementation note: in what follows, `result_obj` will be an
# associative array that (partly) simulates a TAP result object
# from the `TAP::Parser` perl module.
## ----------- ##
## FUNCTIONS ##
## ----------- ##
function fatal(msg)
{
print me ": " msg | "cat >&2"
exit 1
}
function abort(where)
{
fatal("internal error " where)
}
# Convert a boolean to a "yes"/"no" string.
function yn(bool)
{
return bool ? "yes" : "no";
}
function add_test_result(result)
{
if (!test_results_index)
test_results_index = 0
test_results_list[test_results_index] = result
test_results_index += 1
test_results_seen[result] = 1;
}
# Whether the test script should be re-run by "make recheck".
function must_recheck()
{
for (k in test_results_seen)
if (k != "XFAIL" && k != "PASS" && k != "SKIP")
return 1
return 0
}
# Whether the content of the log file associated to this test should
# be copied into the "global" test-suite.log.
function copy_in_global_log()
{
for (k in test_results_seen)
if (k != "PASS")
return 1
return 0
}
# FIXME: this can certainly be improved ...
function get_global_test_result()
{
if ("ERROR" in test_results_seen)
return "ERROR"
if ("FAIL" in test_results_seen || "XPASS" in test_results_seen)
return "FAIL"
all_skipped = 1
for (k in test_results_seen)
if (k != "SKIP")
all_skipped = 0
if (all_skipped)
return "SKIP"
return "PASS";
}
function stringify_result_obj(result_obj)
{
if (result_obj["is_unplanned"] || result_obj["number"] != testno)
return "ERROR"
if (plan_seen == LATE_PLAN)
return "ERROR"
if (result_obj["directive"] == "TODO")
return result_obj["is_ok"] ? "XPASS" : "XFAIL"
if (result_obj["directive"] == "SKIP")
return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL;
if (length(result_obj["directive"]))
abort("in function stringify_result_obj()")
return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL
}
function decorate_result(result)
{
color_name = color_for_result[result]
if (color_name)
return color_map[color_name] "" result "" color_map["std"]
# If we are not using colorized output, or if we do not know how
# to colorize the given result, we should return it unchanged.
return result
}
function report(result, details)
{
if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/)
{
msg = ": " test_script_name
add_test_result(result)
}
else if (result == "#")
{
msg = " " test_script_name ":"
}
else
{
abort("in function report()")
}
if (length(details))
msg = msg " " details
# Output on console might be colorized.
print decorate_result(result) msg
# Log the result in the log file too, to help debugging (this is
# especially true when said result is a TAP error or "Bail out!").
print result msg | "cat >&3";
}
function testsuite_error(error_message)
{
report("ERROR", "- " error_message)
}
function handle_tap_result()
{
details = result_obj["number"];
if (length(result_obj["description"]))
details = details " " result_obj["description"]
if (plan_seen == LATE_PLAN)
{
details = details " # AFTER LATE PLAN";
}
else if (result_obj["is_unplanned"])
{
details = details " # UNPLANNED";
}
else if (result_obj["number"] != testno)
{
details = sprintf("%s # OUT-OF-ORDER (expecting %d)",
details, testno);
}
else if (result_obj["directive"])
{
details = details " # " result_obj["directive"];
if (length(result_obj["explanation"]))
details = details " " result_obj["explanation"]
}
report(stringify_result_obj(result_obj), details)
}
# `skip_reason` should be empty whenever planned > 0.
function handle_tap_plan(planned, skip_reason)
{
planned += 0 # Avoid getting confused if, say, `planned` is "00"
if (length(skip_reason) && planned > 0)
abort("in function handle_tap_plan()")
if (plan_seen)
{
# Error, only one plan per stream is acceptable.
testsuite_error("multiple test plans")
return;
}
planned_tests = planned
# The TAP plan can come before or after *all* the TAP results; we speak
# respectively of an "early" or a "late" plan. If we see the plan line
# after at least one TAP result has been seen, assume we have a late
# plan; in this case, any further test result seen after the plan will
# be flagged as an error.
plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN)
# If testno > 0, we have an error ("too many tests run") that will be
# automatically dealt with later, so do not worry about it here. If
# $plan_seen is true, we have an error due to a repeated plan, and that
# has already been dealt with above. Otherwise, we have a valid "plan
# with SKIP" specification, and should report it as a particular kind
# of SKIP result.
if (planned == 0 && testno == 0)
{
if (length(skip_reason))
skip_reason = "- " skip_reason;
report("SKIP", skip_reason);
}
}
function extract_tap_comment(line)
{
if (index(line, diag_string) == 1)
{
# Strip leading `diag_string` from `line`.
line = substr(line, length(diag_string) + 1)
# And strip any leading and trailing whitespace left.
sub("^[ \t]*", "", line)
sub("[ \t]*$", "", line)
# Return what is left (if any).
return line;
}
return "";
}
# When this function is called, we know that line is a TAP result line,
# so that it matches the (perl) RE "^(not )?ok\b".
function setup_result_obj(line)
{
# Get the result, and remove it from the line.
result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0)
sub("^(not )?ok[ \t]*", "", line)
# If the result has an explicit number, get it and strip it; otherwise,
# automatically assing the next progresive number to it.
if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/)
{
match(line, "^[0-9]+")
# The final `+ 0` is to normalize numbers with leading zeros.
result_obj["number"] = substr(line, 1, RLENGTH) + 0
line = substr(line, RLENGTH + 1)
}
else
{
result_obj["number"] = testno
}
if (plan_seen == LATE_PLAN)
# No further test results are acceptable after a "late" TAP plan
# has been seen.
result_obj["is_unplanned"] = 1
else if (plan_seen && testno > planned_tests)
result_obj["is_unplanned"] = 1
else
result_obj["is_unplanned"] = 0
# Strip trailing and leading whitespace.
sub("^[ \t]*", "", line)
sub("[ \t]*$", "", line)
# This will have to be corrected if we have a "TODO"/"SKIP" directive.
result_obj["description"] = line
result_obj["directive"] = ""
result_obj["explanation"] = ""
if (index(line, "#") == 0)
return # No possible directive, nothing more to do.
# Directives are case-insensitive.
rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*"
# See whether we have the directive, and if yes, where.
pos = match(line, rx "$")
if (!pos)
pos = match(line, rx "[^a-zA-Z0-9_]")
# If there was no TAP directive, we have nothing more to do.
if (!pos)
return
# Let`s now see if the TAP directive has been escaped. For example:
# escaped: ok \# SKIP
# not escaped: ok \\# SKIP
# escaped: ok \\\\\# SKIP
# not escaped: ok \ # SKIP
if (substr(line, pos, 1) == "#")
{
bslash_count = 0
for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--)
bslash_count += 1
if (bslash_count % 2)
return # Directive was escaped.
}
# Strip the directive and its explanation (if any) from the test
# description.
result_obj["description"] = substr(line, 1, pos - 1)
# Now remove the test description from the line, that has been dealt
# with already.
line = substr(line, pos)
# Strip the directive, and save its value (normalized to upper case).
sub("^[ \t]*#[ \t]*", "", line)
result_obj["directive"] = toupper(substr(line, 1, 4))
line = substr(line, 5)
# Now get the explanation for the directive (if any), with leading
# and trailing whitespace removed.
sub("^[ \t]*", "", line)
sub("[ \t]*$", "", line)
result_obj["explanation"] = line
}
function get_test_exit_message(status)
{
if (status == 0)
return ""
if (status !~ /^[1-9][0-9]*$/)
abort("getting exit status")
if (status < 127)
exit_details = ""
else if (status == 127)
exit_details = " (command not found?)"
else if (status >= 128 && status <= 255)
exit_details = sprintf(" (terminated by signal %d?)", status - 128)
else if (status > 256 && status <= 384)
# We used to report an "abnormal termination" here, but some Korn
# shells, when a child process die due to signal number n, can leave
# in $? an exit status of 256+n instead of the more standard 128+n.
# Apparently, both behaviours are allowed by POSIX (2008), so be
# prepared to handle them both. See also Austing Group report ID
# 0000051 <http://www.austingroupbugs.net/view.php?id=51>
exit_details = sprintf(" (terminated by signal %d?)", status - 256)
else
# Never seen in practice.
exit_details = " (abnormal termination)"
return sprintf("exited with status %d%s", status, exit_details)
}
function write_test_results()
{
print ":global-test-result: " get_global_test_result() > trs_file
print ":recheck: " yn(must_recheck()) > trs_file
print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file
for (i = 0; i < test_results_index; i += 1)
print ":test-result: " test_results_list[i] > trs_file
close(trs_file);
}
BEGIN {
## ------- ##
## SETUP ##
## ------- ##
'"$init_colors"'
# Properly initialized once the TAP plan is seen.
planned_tests = 0
COOKED_PASS = expect_failure ? "XPASS": "PASS";
COOKED_FAIL = expect_failure ? "XFAIL": "FAIL";
# Enumeration-like constants to remember which kind of plan (if any)
# has been seen. It is important that NO_PLAN evaluates "false" as
# a boolean.
NO_PLAN = 0
EARLY_PLAN = 1
LATE_PLAN = 2
testno = 0 # Number of test results seen so far.
bailed_out = 0 # Whether a "Bail out!" directive has been seen.
# Whether the TAP plan has been seen or not, and if yes, which kind
# it is ("early" is seen before any test result, "late" otherwise).
plan_seen = NO_PLAN
## --------- ##
## PARSING ##
## --------- ##
is_first_read = 1
while (1)
{
# Involutions required so that we are able to read the exit status
# from the last input line.
st = getline
if (st < 0) # I/O error.
fatal("I/O error while reading from input stream")
else if (st == 0) # End-of-input
{
if (is_first_read)
abort("in input loop: only one input line")
break
}
if (is_first_read)
{
is_first_read = 0
nextline = $0
continue
}
else
{
curline = nextline
nextline = $0
$0 = curline
}
# Copy any input line verbatim into the log file.
print | "cat >&3"
# Parsing of TAP input should stop after a "Bail out!" directive.
if (bailed_out)
continue
# TAP test result.
if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/)
{
testno += 1
setup_result_obj($0)
handle_tap_result()
}
# TAP plan (normal or "SKIP" without explanation).
else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/)
{
# The next two lines will put the number of planned tests in $0.
sub("^1\\.\\.", "")
sub("[^0-9]*$", "")
handle_tap_plan($0, "")
continue
}
# TAP "SKIP" plan, with an explanation.
else if ($0 ~ /^1\.\.0+[ \t]*#/)
{
# The next lines will put the skip explanation in $0, stripping
# any leading and trailing whitespace. This is a little more
# tricky in truth, since we want to also strip a potential leading
# "SKIP" string from the message.
sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "")
sub("[ \t]*$", "");
handle_tap_plan(0, $0)
}
# "Bail out!" magic.
# Older versions of prove and TAP::Harness (e.g., 3.17) did not
# recognize a "Bail out!" directive when preceded by leading
# whitespace, but more modern versions (e.g., 3.23) do. So we
# emulate the latter, "more modern" behaviour.
else if ($0 ~ /^[ \t]*Bail out!/)
{
bailed_out = 1
# Get the bailout message (if any), with leading and trailing
# whitespace stripped. The message remains stored in `$0`.
sub("^[ \t]*Bail out![ \t]*", "");
sub("[ \t]*$", "");
# Format the error message for the
bailout_message = "Bail out!"
if (length($0))
bailout_message = bailout_message " " $0
testsuite_error(bailout_message)
}
# Maybe we have too look for dianogtic comments too.
else if (comments != 0)
{
comment = extract_tap_comment($0);
if (length(comment))
report("#", comment);
}
}
## -------- ##
## FINISH ##
## -------- ##
# A "Bail out!" directive should cause us to ignore any following TAP
# error, as well as a non-zero exit status from the TAP producer.
if (!bailed_out)
{
if (!plan_seen)
{
testsuite_error("missing test plan")
}
else if (planned_tests != testno)
{
bad_amount = testno > planned_tests ? "many" : "few"
testsuite_error(sprintf("too %s tests run (expected %d, got %d)",
bad_amount, planned_tests, testno))
}
if (!ignore_exit)
{
# Fetch exit status from the last line.
exit_message = get_test_exit_message(nextline)
if (exit_message)
testsuite_error(exit_message)
}
}
write_test_results()
exit 0
} # End of "BEGIN" block.
'
# TODO: document that we consume the file descriptor 3 :-(
} 3>"$log_file"
test $? -eq 0 || fatal "I/O or internal error"
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View File

@@ -1,39 +0,0 @@
#!/bin/bash
find_build_directory() {
local build_dirs=(*/.ninja_log)
if [[ ! -e ${build_dirs[0]} ]]; then
echo "error: No build directory found. Have you run 'meson build' yet?" >&2
return 1
elif (( ${#build_dirs[*]} > 1 )); then
echo "error: Multiple build directories found. Unable to proceed." >&2
return 1
fi
printf '%s\n' "${build_dirs[0]%/*}"
}
filter_targets_by_name() {
if command -v jq &>/dev/null; then
jq --arg re "$1" -r 'map(.name)[] | select(match($re))'
else
json_pp | awk -v filter="$1" -F'[:"]' \
'$2 == "name" && $(NF - 1) ~ filter { print $(NF - 1) }'
fi
}
# Make things simple and require that we're in the build root rather than
# trying to chase down the location of this script and the relative build dir.
if [[ ! -d .git ]]; then
echo "This script must be run from the root of the repository" >&2
exit 1
fi
build_dir=$(find_build_directory) || exit 1
mapfile -t targets < \
<(meson introspect "$build_dir" --targets | filter_targets_by_name "-update-po$")
ninja -C "$build_dir" "${targets[@]}"

View File

@@ -1,7 +1,7 @@
# -*- Autoconf -*- # -*- Autoconf -*-
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
# Minimum version of autoconf required # Minimum version of autoconf required
AC_PREREQ(2.64) AC_PREREQ(2.62)
# UPDATING VERSION NUMBERS FOR RELEASES # UPDATING VERSION NUMBERS FOR RELEASES
# #
@@ -41,13 +41,13 @@ AC_PREREQ(2.64)
# Bugfix releases: # Bugfix releases:
# pacman_version_micro += 1 # pacman_version_micro += 1
m4_define([lib_current], [11]) m4_define([lib_current], [10])
m4_define([lib_revision], [1]) m4_define([lib_revision], [2])
m4_define([lib_age], [0]) m4_define([lib_age], [0])
m4_define([pacman_version_major], [5]) m4_define([pacman_version_major], [5])
m4_define([pacman_version_minor], [1]) m4_define([pacman_version_minor], [0])
m4_define([pacman_version_micro], [1]) m4_define([pacman_version_micro], [2])
m4_define([pacman_version], m4_define([pacman_version],
[pacman_version_major.pacman_version_minor.pacman_version_micro]) [pacman_version_major.pacman_version_minor.pacman_version_micro])
@@ -72,7 +72,7 @@ if test "x$CFLAGS" = "x"; then
CFLAGS="" CFLAGS=""
fi fi
# Set substitution values for version stuff in Makefiles and anywhere else, # Set subsitution values for version stuff in Makefiles and anywhere else,
# and put LIB_VERSION in config.h # and put LIB_VERSION in config.h
AC_SUBST(LIB_VERSION) AC_SUBST(LIB_VERSION)
AC_SUBST(LIB_VERSION_INFO) AC_SUBST(LIB_VERSION_INFO)
@@ -101,7 +101,7 @@ AC_ARG_WITH(buildscript,
# Help line for buildscript filename # Help line for buildscript filename
AC_ARG_WITH(makepkg-template-dir, AC_ARG_WITH(makepkg-template-dir,
AS_HELP_STRING([--with-makepkg-template-dir=name], [set the template dir used by makepkg-template]), AS_HELP_STRING([--with-makepkg-template-dir=name], [set the template dir used by makepkg-template]),
[TEMPLATE_DIR=$withval], [TEMPLATE_DIR=${datarootdir}/makepkg-template]) [TEMPLATE_DIR=$withval], [TEMPLATE_DIR=/usr/share/makepkg-template])
# Help line for debug package suffix # Help line for debug package suffix
AC_ARG_WITH(debug-suffix, AC_ARG_WITH(debug-suffix,
@@ -120,11 +120,10 @@ AC_ARG_WITH(ldconfig,
[set the full path to ldconfig]), [set the full path to ldconfig]),
[LDCONFIG=$withval], [LDCONFIG=/sbin/ldconfig]) [LDCONFIG=$withval], [LDCONFIG=/sbin/ldconfig])
# Help line for selecting a crypto library # Help line for using OpenSSL
AC_ARG_WITH(crypto, AC_ARG_WITH(openssl,
AS_HELP_STRING([--with-crypto={openssl|nettle}], AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]),
[select crypto implementation @<:@default=openssl@:>@]), [], [with_openssl=check])
[with_crypto=$withval], [with_crypto=openssl])
# Help line for using gpgme # Help line for using gpgme
AC_ARG_WITH(gpgme, AC_ARG_WITH(gpgme,
@@ -179,7 +178,7 @@ AC_SUBST(LFS_CFLAGS)
AC_PROG_AWK AC_PROG_AWK
AC_PROG_CC_C99 AC_PROG_CC_C99
AC_PROG_INSTALL AC_PROG_INSTALL
AC_CHECK_PROGS([PYTHON], [python3 python], [false]) AC_CHECK_PROGS([PYTHON], [python2.7 python2 python], [false])
AC_PATH_PROGS([BASH_SHELL], [bash bash4], [false]) AC_PATH_PROGS([BASH_SHELL], [bash bash4], [false])
# check for perl 5.10.1 (needed by makepkg-template) # check for perl 5.10.1 (needed by makepkg-template)
@@ -193,18 +192,18 @@ AC_DEFUN([AX_PROG_PERL_VERSION],
AX_PROG_PERL_VERSION([5.10.1], [], [AC_MSG_ERROR([perl is too old])]) AX_PROG_PERL_VERSION([5.10.1], [], [AC_MSG_ERROR([perl is too old])])
AS_IF([test "x$BASH_SHELL" = "xfalse"], AS_IF([test "x$BASH_SHELL" = "xfalse"],
AC_MSG_WARN([*** bash >= 4.4.0 is required for pacman scripts]), AC_MSG_WARN([*** bash >= 4.1.0 is required for pacman scripts]),
[bash_version_major=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[0]]}"'` [bash_version_major=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[0]]}"'`
bash_version_minor=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[1]]}"'` bash_version_minor=`$BASH_SHELL -c 'echo "${BASH_VERSINFO[[1]]}"'`
ok=yes ok=yes
if test "$bash_version_major" -lt 4; then if test "$bash_version_major" -lt 4; then
ok=no ok=no
fi fi
if test "$bash_version_major" -eq 4 && test "$bash_version_minor" -lt 4; then if test "$bash_version_major" -eq 4 && test "$bash_version_minor" -lt 1; then
ok=no ok=no
fi fi
if test "$ok" = "no"; then if test "$ok" = "no"; then
AC_MSG_ERROR([*** bash >= 4.4.0 is required for pacman scripts]) AC_MSG_ERROR([*** bash >= 4.1.0 is required for pacman scripts])
fi fi
unset bash_version_major bash_version_minor ok]) unset bash_version_major bash_version_minor ok])
@@ -215,51 +214,31 @@ AM_GNU_GETTEXT_VERSION(0.13.1)
AC_CHECK_LIB([m], [fabs], , AC_CHECK_LIB([m], [fabs], ,
AC_MSG_ERROR([libm is needed to compile pacman!])) AC_MSG_ERROR([libm is needed to compile pacman!]))
PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
bashcompdir="${datarootdir}/bash-completion/completions")
# Check for libarchive # Check for libarchive
PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 3.0.0], , PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], ,
AC_MSG_ERROR([*** libarchive >= 3.0.0 is needed to compile pacman!])) AC_MSG_ERROR([*** libarchive >= 2.8.0 is needed to compile pacman!]))
# Check for OpenSSL # Check for OpenSSL
have_openssl=no have_openssl=no
have_nettle=no if test "x$with_openssl" != "xno"; then
if test "x$with_crypto" = "xnettle"; then
AC_SUBST(pc_crypto, [nettle])
PKG_CHECK_MODULES(NETTLE, [nettle],
[AC_DEFINE(HAVE_LIBNETTLE, 1, [Define whether to use nettle]) have_nettle=yes], have_nettle=no)
if test "x$have_nettle" = xno -a "x$with_crypto" = xnettle; then
AC_MSG_ERROR([*** nettle support requested but libraries not found])
fi
else if test "x$with_crypto" = "xopenssl"; then
AC_SUBST(pc_crypto, [libcrypto])
PKG_CHECK_MODULES(LIBSSL, [libcrypto], PKG_CHECK_MODULES(LIBSSL, [libcrypto],
[AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) have_openssl=yes], have_openssl=no) [AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) have_openssl=yes], have_openssl=no)
if test "x$have_openssl" = xno; then if test "x$have_openssl" = xno -a "x$with_openssl" = xyes; then
AC_MSG_ERROR([*** openssl support requested but libraries not found]) AC_MSG_ERROR([*** openssl support requested but libraries not found])
fi fi
else
AC_MSG_ERROR([*** unknown crypto support library requested - $with_crypto])
fi
fi fi
AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"]) AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"])
AM_CONDITIONAL(HAVE_LIBNETTLE, [test "$have_nettle" = "yes"])
# Check for libcurl # Check for libcurl
have_libcurl=no have_libcurl=no
if test "x$with_libcurl" != "xno"; then if test "x$with_libcurl" != "xno"; then
PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.32.0], PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.19.4],
[AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) have_libcurl=yes], have_libcurl=no) [AC_DEFINE(HAVE_LIBCURL, 1, [Define if libcurl is available]) have_libcurl=yes], have_libcurl=no)
if test "x$have_libcurl" = xno -a "x$with_libcurl" = xyes; then if test "x$have_libcurl" = xno -a "x$with_libcurl" = xyes; then
AC_MSG_ERROR([*** libcurl >= 7.32.0 is required for internal downloader support]) AC_MSG_ERROR([*** libcurl >= 7.19.4 is required for internal downloader support])
fi fi
fi fi
AM_CONDITIONAL(HAVE_LIBCURL, [test "$have_libcurl" = "yes"]) AM_CONDITIONAL(HAVE_LIBCURL, [test "$have_libcurl" = "yes"])
# used to generate libalpm.pc
if test "x$have_libcurl" = xyes; then
AC_SUBST(pc_libcurl, [libcurl])
fi
# Check for gpgme # Check for gpgme
AC_MSG_CHECKING(whether to link with libgpgme) AC_MSG_CHECKING(whether to link with libgpgme)
@@ -329,6 +308,8 @@ PATH_MAX_DEFINED
AC_FUNC_FORK AC_FUNC_FORK
AC_FUNC_GETMNTENT AC_FUNC_GETMNTENT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MKTIME
AC_FUNC_STRCOLL
AC_CHECK_FUNCS([dup2 getcwd getmntinfo gettimeofday memmove memset \ AC_CHECK_FUNCS([dup2 getcwd getmntinfo gettimeofday memmove memset \
mkdir realpath regcomp rmdir setenv setlocale strcasecmp \ mkdir realpath regcomp rmdir setenv setlocale strcasecmp \
strchr strcspn strdup strerror strndup strnlen strrchr \ strchr strcspn strdup strerror strndup strnlen strrchr \
@@ -345,11 +326,12 @@ AC_CHECK_MEMBERS([struct statfs.f_flags],,,[[#include <sys/param.h>
GCC_VISIBILITY_CC GCC_VISIBILITY_CC
# Host-dependant definitions # Host-dependant definitions
DEFAULT_DUFLAGS=" -sk --apparent-size"
DEFAULT_SEDINPLACEFLAGS=" --follow-symlinks -i"
INODECMD="stat -c '%i %n'" INODECMD="stat -c '%i %n'"
OWNERCMD="stat -c '%u:%g'" OWNERCMD="stat -c '%u:%g'"
MODECMD="stat -c '%a'" MODECMD="stat -c '%a'"
SIZECMD="stat -c %s"
SEDINPLACE="sed --follow-symlinks -i"
DUFLAGS="-sk --apparent-size"
STRIP_BINARIES="--strip-all" STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded" STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug" STRIP_STATIC="--strip-debug"
@@ -358,43 +340,36 @@ case "${host_os}" in
INODECMD="stat -f '%i %N'" INODECMD="stat -f '%i %N'"
OWNERCMD="stat -f '%u:%g'" OWNERCMD="stat -f '%u:%g'"
MODECMD="stat -f '%Lp'" MODECMD="stat -f '%Lp'"
DEFAULT_SEDINPLACEFLAGS=" -i \"\"" SIZECMD="stat -f %z"
DEFAULT_DUFLAGS=" -sk" SEDINPLACE="sed -i \"\""
DUFLAGS="-sk"
;; ;;
darwin*) darwin*)
host_os_darwin=yes host_os_darwin=yes
INODECMD="/usr/bin/stat -f '%i %N'" INODECMD="/usr/bin/stat -f '%i %N'"
OWNERCMD="/usr/bin/stat -f '%u:%g'" OWNERCMD="/usr/bin/stat -f '%u:%g'"
MODECMD="/usr/bin/stat -f '%Lp'" MODECMD="/usr/bin/stat -f '%Lp'"
DEFAULT_SEDINPLACEFLAGS=" -i ''" SIZECMD="/usr/bin/stat -f %z"
DEFAULT_DUFLAGS=" -sk" SEDINPLACE="/usr/bin/sed -i ''"
DUFLAGS="-sk"
STRIP_BINARIES="" STRIP_BINARIES=""
STRIP_SHARED="-S" STRIP_SHARED="-S"
STRIP_STATIC="-S" STRIP_STATIC="-S"
;; ;;
esac esac
AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes") AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] ) AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
AC_PATH_PROGS([SEDPATH], [sed], [sed], [/usr/bin$PATH_SEPARATOR/bin] )
AC_SUBST(INODECMD) AC_SUBST(INODECMD)
AC_SUBST(OWNERCMD) AC_SUBST(OWNERCMD)
AC_SUBST(MODECMD) AC_SUBST(MODECMD)
AC_SUBST(SIZECMD)
AC_SUBST(SEDINPLACE)
AC_SUBST(DUFLAGS)
AC_SUBST(STRIP_BINARIES) AC_SUBST(STRIP_BINARIES)
AC_SUBST(STRIP_SHARED) AC_SUBST(STRIP_SHARED)
AC_SUBST(STRIP_STATIC) AC_SUBST(STRIP_STATIC)
# Flags for du
if test "${DUFLAGS+set}" != "set"; then
DUFLAGS="${DEFAULT_DUFLAGS}"
fi
AC_ARG_VAR(DUFLAGS, [flags for du, overriding the default])
# Flags for sed in place
if test "${SEDINPLACEFLAGS+set}" != "set"; then
SEDINPLACEFLAGS="${DEFAULT_SEDINPLACEFLAGS}"
fi
AC_ARG_VAR(SEDINPLACEFLAGS, [flags for sed, overriding the default])
# Variables plugged into makepkg.conf # Variables plugged into makepkg.conf
CARCH="${host%%-*}" CARCH="${host%%-*}"
CHOST="${host}" CHOST="${host}"
@@ -443,7 +418,6 @@ if test "x$debug" = "xyes" ; then
# Check for -fstack-protector availability # Check for -fstack-protector availability
GCC_STACK_PROTECT_LIB GCC_STACK_PROTECT_LIB
GCC_STACK_PROTECT_CC GCC_STACK_PROTECT_CC
GCC_STACK_CLASH_PROTECTION
GCC_FORTIFY_SOURCE_CC GCC_FORTIFY_SOURCE_CC
WARNING_CFLAGS="-g -Wall -Werror" WARNING_CFLAGS="-g -Wall -Werror"
else else
@@ -462,7 +436,6 @@ if test "x$warningflags" = "xyes" ; then
CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS]) CFLAGS_ADD([-Wformat-nonliteral], [WARNING_CFLAGS])
CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS]) CFLAGS_ADD([-Wformat-security], [WARNING_CFLAGS])
CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS]) CFLAGS_ADD([-Wignored-qualifiers], [WARNING_CFLAGS])
CFLAGS_ADD([-Wimplicit-fallthrough], [WARNING_CFLAGS])
CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS]) CFLAGS_ADD([-Winit-self], [WARNING_CFLAGS])
CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS]) CFLAGS_ADD([-Wlogical-op], [WARNING_CFLAGS])
CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS]) CFLAGS_ADD([-Wmissing-declarations], [WARNING_CFLAGS])
@@ -545,6 +518,7 @@ test/pacman/Makefile
test/pacman/tests/Makefile test/pacman/tests/Makefile
test/scripts/Makefile test/scripts/Makefile
test/util/Makefile test/util/Makefile
contrib/Makefile
Makefile Makefile
]) ])
AC_OUTPUT AC_OUTPUT
@@ -564,7 +538,7 @@ ${PACKAGE_NAME}:
compiler : ${CC} compiler : ${CC}
preprocessor flags : ${CPPFLAGS} preprocessor flags : ${CPPFLAGS}
compiler flags : ${WARNING_CFLAGS} ${CFLAGS} compiler flags : ${WARNING_CFLAGS} ${CFLAGS}
library flags : ${LIBS} ${LIBSSL_LIBS} ${NETTLE_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS} library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
linker flags : ${LDFLAGS} linker flags : ${LDFLAGS}
Architecture : ${CARCH} Architecture : ${CARCH}
@@ -572,7 +546,8 @@ ${PACKAGE_NAME}:
File inode command : ${INODECMD} File inode command : ${INODECMD}
File owner command : ${OWNERCMD} File owner command : ${OWNERCMD}
File mode command : ${MODECMD} File mode command : ${MODECMD}
In-place sed command : ${SEDPATH} ${SEDINPLACEFLAGS} Filesize command : ${SIZECMD}
In-place sed command : ${SEDINPLACE}
libalpm version : ${LIB_VERSION} libalpm version : ${LIB_VERSION}
libalpm version info : ${LIB_VERSION_INFO} libalpm version info : ${LIB_VERSION_INFO}
@@ -590,10 +565,11 @@ ${PACKAGE_NAME}:
Use libcurl : ${have_libcurl} Use libcurl : ${have_libcurl}
Use GPGME : ${have_gpgme} Use GPGME : ${have_gpgme}
Use OpenSSL : ${have_openssl} Use OpenSSL : ${have_openssl}
Use nettle : ${have_nettle}
Run make in doc/ dir : ${wantdoc} ${asciidoc} Run make in doc/ dir : ${wantdoc} ${asciidoc}
Doxygen support : ${usedoxygen} Doxygen support : ${usedoxygen}
debug support : ${debug} debug support : ${debug}
extra warning flags : ${warningflags} extra warning flags : ${warningflags}
use git version : ${wantgitver} use git version : ${wantgitver}
" "
# vim:set noet:

12
contrib/.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
bacman
bash_completion
checkupdates
paccache
pacdiff
paclist
paclog-pkglist
pacscripts
pacsearch
rankmirrors
updpkgsums
zsh_completion

89
contrib/Makefile.am Normal file
View File

@@ -0,0 +1,89 @@
# enforce that all scripts have a --help and --version option
AUTOMAKE_OPTIONS = std-options
bin_SCRIPTS = \
$(OURSCRIPTS)
BASHSCRIPTS = \
bacman \
checkupdates \
paccache \
pacdiff \
paclist \
paclog-pkglist \
pacscripts \
rankmirrors \
updpkgsums
OTHERSCRIPTS = \
pacsearch
OURSCRIPTS = \
$(BASHSCRIPTS) \
$(OTHERSCRIPTS)
EXTRA_DIST = \
PKGBUILD.vim \
bacman.sh.in \
checkupdates.sh.in \
paccache.sh.in \
paclog-pkglist.sh.in \
pacdiff.sh.in \
paclist.sh.in \
pacscripts.sh.in \
pacsearch.in \
rankmirrors.sh.in \
updpkgsums.sh.in \
vimprojects \
README
# Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = $(OURSCRIPTS) *.tmp
if USE_GIT_VERSION
GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
REAL_PACKAGE_VERSION = $(GIT_VERSION)
else
REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
endif
edit = sed \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
-e 's|@SIZECMD[@]|$(SIZECMD)|g' \
-e 's|@SCRIPTNAME[@]|$@|g' \
-e '1s|!/bin/bash|!$(BASH_SHELL)|g'
$(OTHERSCRIPTS): Makefile
$(AM_V_at)$(RM) $@ $@.tmp
$(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
$(AM_V_at)chmod +x,a-w $@.tmp
$(AM_V_at)mv $@.tmp $@
$(BASHSCRIPTS): Makefile
$(AM_V_at)$(RM) $@
$(AM_V_GEN)test -f $(srcdir)/$@.sh.in && m4 -P -I $(srcdir) $(srcdir)/$@.sh.in | $(edit) >$@
$(AM_V_at)chmod +x,a-w $@
@$(BASH_SHELL) -O extglob -n $@
$(OURFILES): Makefile
$(AM_V_at)$(RM) $@ $@.tmp
$(AM_V_GEN)$(edit) $(srcdir)/$@.in >$@.tmp
$(AM_V_at)chmod a-w $@.tmp
$(AM_V_at)mv $@.tmp $@
all-am: $(OURSCRIPTS)
bacman: $(srcdir)/bacman.sh.in
checkupdates: $(srcdir)/checkupdates.sh.in
paccache: $(srcdir)/paccache.sh.in $(top_srcdir)/scripts/library/parseopts.sh $(top_srcdir)/scripts/library/size_to_human.sh
pacdiff: $(srcdir)/pacdiff.sh.in
paclist: $(srcdir)/paclist.sh.in
paclog-pkglist: $(srcdir)/paclog-pkglist.sh.in
pacscripts: $(srcdir)/pacscripts.sh.in
pacsearch: $(srcdir)/pacsearch.in
rankmirrors: $(srcdir)/rankmirrors.sh.in
updpkgsums: $(srcdir)/updpkgsums.sh.in
# vim:set noet:

320
contrib/PKGBUILD.vim Normal file
View File

@@ -0,0 +1,320 @@
" Vim syntax file
" Language: PKGBUILD
" Maintainer: Alessio 'mOLOk' Bolognino <themolok at gmail.com>
" Last Change: 2007/05/08
" Version Info: PKGBUILD-0.2 (colorphobic)
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let b:main_syntax = "sh"
let b:is_bash = 1
runtime! syntax/sh.vim
" case on
syn case match
" pkgname
" FIXME if '=' is in pkgname/pkgver, it highlights whole string, not just '='
syn keyword pb_k_pkgname pkgname contained
syn match pbValidPkgname /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgname
syn match pbIllegalPkgname /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained
syn match pbPkgnameGroup /^pkgname=.*/ contains=pbIllegalPkgname,pb_k_pkgname,shDoubleQuote,shSingleQuote
" pkgbase
" FIXME if '=' is in pkgbase/pkgname/pkgver, it highlights whole string, not just '='
syn keyword pb_k_pkgbase pkgbase contained
syn match pbValidPkgbase /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgbase
syn match pbIllegalPkgbase /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained
syn match pbPkgbaseGroup /^pkgbase=.*/ contains=pbIllegalPkgbase,pb_k_pkgbase,shDoubleQuote,shSingleQuote
" pkgver
syn keyword pb_k_pkgver pkgver contained
syn match pbValidPkgver /\([[:alnum:]]\|\.\|+\|_\)/ contained contains=pbIllegalPkgver
syn match pbIllegalPkgver /[^[:alnum:]+=\.\_]\|=.*=/ contained
syn match pbPkgverGroup /^pkgver=.*/ contains=pbIllegalPkgver,pbValidPkgver,pb_k_pkgver,shDoubleQuote,shSingleQuote
" pkgrel
syn keyword pb_k_pkgrel pkgrel contained
syn match pbValidPkgrel /[[:digit:]]*/ contained contains=pbIllegalPkgrel
syn match pbIllegalPkgrel /[^[:digit:]=]\|=.*=/ contained
syn match pbPkgrelGroup /^pkgrel=.*/ contains=pbIllegalPkgrel,pbValidPkgrel,pb_k_pkgrel,shDoubleQuote,shSingleQuote
" pkgdesc
syn keyword pb_k_desc pkgdesc contained
" 90 chars: 80 for description, 8 for pkgdesc and 2 for ''
syn match pbIllegalPkgdesc /.\{90,}\|=['"]\?.*['" ]\+[iI][sS] [aA]/ contained contains=pbPkgdescSign
syn match pbValidPkgdesc /[^='"]\.\{,80}/ contained contains=pbIllegalPkgdesc
syn match pbPkgdescGroup /^pkgdesc=.*/ contains=pbIllegalPkgdesc,pb_k_desc,pbValidPkgdesc,shDoubleQuote,shSingleQuote
syn match pbPkgdescSign /[='"]/ contained
" epoch
syn keyword pb_k_epoch epoch contained
syn match pbValidEpoch /[[:digit:]]*/ contained contains=pbIllegalEpoch
syn match pbIllegalEpoch /[^[:digit:]=]\|=.*=/ contained
syn match pbEpochGroup /^epoch=.*/ contains=pbIllegalEpoch,pbValidEpoch,pb_k_epoch,shDoubleQuote,shSingleQuote
" url
syn keyword pb_k_url url contained
syn match pbValidUrl /['"]*\(https\|http\|ftp\)\:\/.*\.\+.*/ contained
syn match pbIllegalUrl /[^=]/ contained contains=pbValidUrl
syn match pbUrlGroup /^url=.*/ contains=pbValidUrl,pb_k_url,pbIllegalUrl,shDoubleQuote,shSingleQuote
" license
syn keyword pb_k_license license contained
" echo $(pacman -Ql licenses | grep '/usr/share/licenses/common/' | cut -d'/' -f6 | sort -u)
syn keyword pbLicense AGPL AGPL3 Apache APACHE Artistic2.0 CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PerlArtistic PHP PSF RUBY W3C ZPL contained
" special cases from https://wiki.archlinux.org/index.php/Arch_Packaging_Standards
syn keyword pbLicenseSpecial BSD MIT ZLIB Python contained
syn match pbLicenseCustom /custom\(:[[:alnum:]]*\)*/ contained
syn match pbIllegalLicense /[^='"() ]/ contained contains=pbLicenseCustom,pbLicenseSpecial,pbLicense
syn region pbLicenseGroup start=/^license=(/ end=/)/ contains=pb_k_license,pbLicenseCustom,pbLicenseSpecial,pbLicense,pbIllegalLicense
" backup
syn keyword pb_k_backup backup contained
syn match pbValidBackup /\.\?[[:alpha:]]*\/[[:alnum:]\{\}+._$-]*]*/ contained
syn region pbBackupGroup start=/^backup=(/ end=/)/ contains=pb_k_backup,pbValidBackup,shDoubleQuote,shSingleQuote
" arch
syn keyword pb_k_arch arch contained
syn keyword pbArch i686 x86_64 ppc any contained
syn match pbIllegalArch /[^='"() ]/ contained contains=pbArch
syn region pbArchGroup start=/^arch=(/ end=/)/ contains=pb_k_arch,pbArch,pbIllegalArch
" groups
syn keyword pb_k_groups groups contained
syn match pbValidGroups /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbGroupsGroup start=/^groups=(/ end=/)/ contains=pb_k_groups,pbValidGroups,shDoubleQuote,shSingleQuote
" depends
syn keyword pb_k_depends depends contained
syn match pbValidDepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbDependsGroup start=/^depends=(/ end=/)/ contains=pb_k_depends,pbValidDepends,shDoubleQuote,shSingleQuote
" makedepends
syn keyword pb_k_makedepends makedepends contained
syn match pbValidMakedepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbMakedependsGroup start=/^makedepends=(/ end=/)/ contains=pb_k_makedepends,pbValidMakedepends,shDoubleQuote,shSingleQuote
" optdepends
syn keyword pb_k_optdepends optdepends contained
syn match pbValidOptdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbOptdependsGroup start=/^optdepends=(/ end=/)/ contains=pb_k_optdepends,pbValidOptdepends,shDoubleQuote,shSingleQuote
" checkdepends
syn keyword pb_k_ckdepends checkdepends contained
syn match pbValidCkdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbCkdependsGroup start=/^checkdepends=(/ end=/)/ contains=pb_k_ckdepends,pbValidCkdepends,shDoubleQuote,shSingleQuote
" conflicts
syn keyword pb_k_conflicts conflicts contained
syn match pbValidConflicts /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbConflictsGroup start=/^conflicts=(/ end=/)/ contains=pb_k_conflicts,pbValidConflicts,shDoubleQuote,shSingleQuote
" provides
syn keyword pb_k_provides provides contained
syn match pbValidProvides /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbProvidesGroup start=/^provides=(/ end=/)/ contains=pb_k_provides,pbValidProvides,shDoubleQuote,shSingleQuote
" replaces
syn keyword pb_k_replaces replaces contained
syn match pbValidReplaces /\([[:alnum:]]\|+\|-\|_\)*/ contained
syn region pbReplacesGroup start=/^replaces=(/ end=/)/ contains=pb_k_replaces,pbValidReplaces,shDoubleQuote,shSingleQuote
" install
" XXX remove install from bashStatement, fix strange bug
syn clear bashStatement
syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch
syn keyword pb_k_install install contained
syn match pbValidInstall /\([[:alnum:]]\|\$\|+\|-\|_\)*\.install/ contained
syn match pbIllegalInstall /[^=]/ contained contains=pbValidInstall
syn match pbInstallGroup /^install=.*/ contains=pb_k_install,pbValidInstall,pbIllegalInstall,shDeref,shDoubleQuote,shSingleQuote
" changelog
syn keyword pb_k_changelog changelog contained
syn match pbValidChangelog /\([[:alnum:]]\|\$\|+\|-\|_\)*/ contained
syn match pbIllegalChangelog /[^=]/ contained contains=pbValidChangelog
syn match pbChangelogGroup /^changelog=.*/ contains=pb_k_changelog,pbValidChangelog,pbIllegalChangelog,shDeref,shDoubleQuote,shSingleQuote
" source:
" XXX remove source from shStatement, fix strange bug
syn clear shStatement
syn keyword shStatement xxx wait getopts return autoload whence printf true popd nohup enable r trap readonly fc fg kill ulimit umask disown stop pushd read history logout times local exit test pwd time eval integer suspend dirs shopt hash false newgrp bg print jobs continue functions exec help cd break unalias chdir type shift builtin let bind
syn keyword pb_k_source source contained
syn match pbIllegalSource /\(http\|ftp\|https\).*\.\+\(dl\|download.\?\)\.\(sourceforge\|sf\).net/
syn region pbSourceGroup start=/^source=(/ end=/)/ contains=pb_k_source,pbIllegalSource,shNumber,shDoubleQuote,shSingleQuote,pbDerefEmulation
syn match pbDerefEmulation /\$[{]\?[[:alnum:]_]*[}]\?/ contained
hi def link pbDerefEmulation PreProc
" md5sums
syn keyword pb_k_md5sums md5sums contained
syn match pbIllegalMd5sums /[^='"()\/ ]/ contained contains=pbValidMd5sums
syn match pbValidMd5sums /\x\{32\}/ contained
syn region pbMd5sumsGroup start=/^md5sums/ end=/)/ contains=pb_k_md5sums,pbMd5Quotes,pbMd5Hash,pbIllegalMd5sums keepend
syn match pbMd5Quotes /'.*'\|".*"/ contained contains=pbMd5Hash,pbIllegalMd5sums
syn match pbMd5Hash /\x\+/ contained contains=pbValidMd5sums
hi def link pbMd5Quotes Keyword
hi def link pbMd5Hash Error
hi def link pbValidMd5sums Number
" sha1sums
syn keyword pb_k_sha1sums sha1sums contained
syn match pbIllegalSha1sums /[^='"()\/ ]/ contained contains=pbValidSha1sums
syn match pbValidSha1sums /\x\{40\}/ contained
syn region pbSha1sumsGroup start=/^sha1sums/ end=/)/ contains=pb_k_sha1sums,pbSha1Quotes,pbSha1Hash,pbIllegalSha1sums keepend
syn match pbSha1Quotes /'.*'\|".*"/ contained contains=pbSha1Hash,pbIllegalSha1sums
syn match pbSha1Hash /\x\+/ contained contains=pbValidSha1sums
hi def link pbSha1Quotes Keyword
hi def link pbSha1Hash Error
hi def link pbValidSha1sums Number
" sha256sums
syn keyword pb_k_sha256sums sha256sums contained
syn match pbIllegalSha256sums /[^='"()\/ ]/ contained contains=pbValidSha256sums
syn match pbValidSha256sums /\x\{64\}/ contained
syn region pbSha256sumsGroup start=/^sha256sums/ end=/)/ contains=pb_k_sha256sums,pbSha256Quotes,pbSha256Hash,pbIllegalSha256sums keepend
syn match pbSha256Quotes /'.*'\|".*"/ contained contains=pbSha256Hash,pbIllegalSha256sums
syn match pbSha256Hash /\x\+/ contained contains=pbValidSha256sums
hi def link pbSha256Quotes Keyword
hi def link pbSha256Hash Error
hi def link pbValidSha256sums Number
" sha384sums
syn keyword pb_k_sha384sums sha384sums contained
syn match pbIllegalSha384sums /[^='"()\/ ]/ contained contains=pbValidSha384sums
syn match pbValidSha384sums /\x\{96\}/ contained
syn region pbSha384sumsGroup start=/^sha384sums/ end=/)/ contains=pb_k_sha384sums,pbSha384Quotes,pbSha384Hash,pbIllegalSha384sums keepend
syn match pbSha384Quotes /'.*'\|".*"/ contained contains=pbSha384Hash,pbIllegalSha384sums
syn match pbSha384Hash /\x\+/ contained contains=pbValidSha384sums
hi def link pbSha384Quotes Keyword
hi def link pbSha384Hash Error
hi def link pbValidSha384sums Number
" sha512sums
syn keyword pb_k_sha512sums sha512sums contained
syn match pbIllegalSha512sums /[^='"()\/ ]/ contained contains=pbValidSha512sums
syn match pbValidSha512sums /\x\{128\}/ contained
syn region pbSha512sumsGroup start=/^sha512sums/ end=/)/ contains=pb_k_sha512sums,pbSha512Quotes,pbSha512Hash,pbIllegalSha512sums keepend
syn match pbSha512Quotes /'.*'\|".*"/ contained contains=pbSha512Hash,pbIllegalSha512sums
syn match pbSha512Hash /\x\+/ contained contains=pbValidSha512sums
hi def link pbSha512Quotes Keyword
hi def link pbSha512Hash Error
hi def link pbValidSha512sums Number
" options
syn keyword pb_k_options options contained
syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|upx\|optipng\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained
syn match pbOptionsNeg /\!/ contained
syn match pbOptionsDeprec /no/ contained
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption
syn match pbIllegalOption /[^!"'()= ]/ contained contains=pbOptionsDeprec,pbOptions
" noextract
syn match pbNoextract /[[:alnum:]+._${}-]\+/ contained
syn keyword pb_k_noextract noextract contained
syn region pbNoextractGroup start=/^noextract=(/ end=/)/ contains=pb_k_noextract,pbNoextract,shDoubleQuote,shSingleQuote
" comments
syn keyword pb_k_maintainer Maintainer Contributor contained
syn match pbMaintainerGroup /Maintainer.*/ contains=pbMaintainer contained
syn match pbDate /[0-9]\{4}\/[0-9]\{2}\/[0-9]\{2}/ contained
syn cluster pbCommentGroup contains=pbTodo,pb_k_maintainer,pbMaintainerGroup,pbDate
syn keyword pbTodo contained COMBAK FIXME TODO XXX
syn match pbComment "^#.*$" contains=@pbCommentGroup
syn match pbComment "[^0-9]#.*$" contains=@pbCommentGroup
" quotes are handled by sh.vim
hi def link pbComment Comment
hi def link pbTodo Todo
hi def link pbIllegalPkgname Error
hi def link pb_k_pkgname pbKeywords
hi def link pbIllegalPkgbase Error
hi def link pb_k_pkgbase pbKeywords
hi def link pbIllegalPkgver Error
hi def link pb_k_pkgver pbKeywords
hi def link pbIllegalPkgrel Error
hi def link pb_k_pkgrel pbKeywords
hi def link pbIllegalPkgdesc Error
hi def link pb_k_desc pbKeywords
hi def link pbIllegalEpoch Error
hi def link pb_k_epoch pbKeywords
hi def link pbIllegalUrl Error
hi def link pb_k_url pbKeywords
hi def link pb_k_license pbKeywords
hi def link pbIllegalLicense Error
hi def link pb_k_backup pbKeywords
hi def link pb_k_arch pbKeywords
hi def link pbIllegalArch Error
hi def link pb_k_groups pbKeywords
hi def link pb_k_makedepends pbKeywords
hi def link pb_k_optdepends pbKeywords
hi def link pb_k_ckdepends pbKeywords
hi def link pb_k_depends pbKeywords
hi def link pb_k_replaces pbKeywords
hi def link pb_k_conflicts pbKeywords
hi def link pb_k_provides pbKeywords
hi def link pbIllegalInstall Error
hi def link pb_k_install pbKeywords
hi def link pbIllegalChangelog Error
hi def link pb_k_changelog pbKeywords
hi def link pb_k_source pbKeywords
hi def link pbIllegalSource Error
hi def link pb_k_md5sums pbKeywords
hi def link pbIllegalMd5sums Error
hi def link pb_k_sha1sums pbKeywords
hi def link pbIllegalSha1sums Error
hi def link pb_k_sha256sums pbKeywords
hi def link pbIllegalSha256sums Error
hi def link pb_k_sha384sums pbKeywords
hi def link pbIllegalSha384sums Error
hi def link pb_k_sha512sums pbKeywords
hi def link pbIllegalSha512sums Error
hi def link pb_k_options pbKeywords
hi def link pbOptionsDeprec Todo
hi def link pbIllegalOption Error
hi def link pb_k_noextract pbKeywords
hi def link pbNoextract Normal
hi def link pb_k_maintainer pbKeywords
hi def link pbKeywords Keyword
hi def link pbDate Special
"syntax include @SHELL syntax/sh.vim
"syntax region BUILD start=/^build()/ end=/^}/ contains=@SHELL
"let b:current_syntax = "PKGBUILD"
" vim: ft=vim

41
contrib/README Normal file
View File

@@ -0,0 +1,41 @@
Here is a brief description of the files included in this directory:
PKGBUILD.vim - a vim/gvim syntax file for PKGBUILDs. Colors known variable
names, highlights common errors such as invalid characters in pkgname or
pkgver, etc.
bacman - regenerate a pacman package based on installed files and the pacman
database entries. Useful for reuse, or possible config file extension.
bash_completion - a bash completion script for pacman, install in
/etc/bash_completion.d/ for use (but rename to something descriptive!).
checkupdates - print a list of pending updates without touching the system
sync databases (for safety on rolling release distributions).
paccache - a flexible package cache cleaning utility that allows greater
control over which packages are removed.
pacdiff - a simple pacnew/pacsave updater for /etc/.
paclist - list all packages installed from a given repository. Useful for
seeing which packages you may have installed from the testing repository,
for instance.
paclog-pkglist - lists currently installs packages based pacman's log.
pacscripts - tries to print out the {pre,post}_{install,remove,upgrade}
scripts of a given package.
pacsearch - a colorized search combining both -Ss and -Qs output. Installed
packages are easily identified with a *** and local-only packages are also
listed.
rankmirrors - ranks pacman mirrors by their connection and opening speed.
updpkgsums - performs an in place update of the checksums in a PKGBUILD.
vimprojects - a project file for the vim project plugin.
zsh_completion - a zsh completion script, install (with a rename) to
/usr/share/zsh/site-functions/.

358
contrib/bacman.sh.in Normal file
View File

@@ -0,0 +1,358 @@
#!/bin/bash
#
# bacman: recreate a package from a running system
# This script rebuilds an already installed package using metadata
# stored into the pacman database and system files
#
# Copyright (c) 2008 locci <carlocci_at_gmail_dot_com>
# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
shopt -s extglob
shopt -s nullglob
declare -r myname='bacman'
declare -r myver='@PACKAGE_VERSION@'
USE_COLOR='y'
INCLUDE_PACNEW='n'
# Required for fakeroot because options are shifted off the array.
ARGS=("$@")
m4_include(../scripts/library/output_format.sh)
#
# User Friendliness
#
usage() {
echo "${myname} (pacman) v${myver}"
echo
echo "Recreate a package using pacman's database and system files"
echo
echo "Usage: ${myname} [--nocolor] [--pacnew] <installed package name>"
echo
echo "Example: ${myname} linux-headers"
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>'
echo 'Copyright (C) 2008-2016 Pacman Development Team <pacman-dev@archlinux.org>'
}
while [[ ! -z $1 ]]; do
if [[ $1 == "--nocolor" ]]; then
USE_COLOR='n'
shift
elif [[ $1 == "--pacnew" ]]; then
INCLUDE_PACNEW='y'
shift
else
break
fi
done
m4_include(../scripts/library/term_colors.sh)
if (( $# != 1 )); then
usage
exit 1
fi
if [[ $1 = -@(h|-help) ]]; then
usage
exit 0
elif [[ $1 = -@(V|-version) ]]; then
version
exit 0
fi
#
# Fakeroot support
#
if (( EUID )); then
if [[ -f /usr/bin/fakeroot ]]; then
msg "Entering fakeroot environment"
export INFAKEROOT="1"
/usr/bin/fakeroot -u -- "$0" "${ARGS[@]}"
exit $?
else
warning "installing fakeroot or running $myname as root is required to"
plain " preserve the ownership permissions of files in some packages\n"
fi
fi
#
# Setting environmental variables
#
if [[ ! -r @sysconfdir@/pacman.conf ]]; then
error "unable to read @sysconfdir@/pacman.conf"
exit 1
fi
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
if [[ ! -r @sysconfdir@/makepkg.conf ]]; then
error "unable to read @sysconfdir@/makepkg.conf"
exit 1
fi
source "@sysconfdir@/makepkg.conf"
if [[ -r ~/.makepkg.conf ]]; then
source ~/.makepkg.conf
fi
pkg_dest="${PKGDEST:-$PWD}"
pkg_pkger=${PACKAGER:-'Unknown Packager'}
pkg_name="$1"
pkg_dir=("$pac_db/$pkg_name"-+([^-])-+([^-]))
pkg_namver=("${pkg_dir[@]##*/}")
#
# Checks everything is in place
#
if [[ ! -d $pac_db ]]; then
error "pacman database directory ${pac_db} not found"
exit 1
fi
if (( ${#pkg_dir[@]} != 1 )); then
error "%d entries for package %s found in pacman database" \
${#pkg_dir[@]} "${pkg_name}"
msg2 "%s" "${pkg_dir[@]}"
exit 1
fi
if [[ ! -d $pkg_dir ]]; then
error "package %s is found in pacman database," "${pkg_name}"
plain " but '%s' is not a directory" "${pkg_dir}"
exit 1
fi
#
# Begin
#
msg "Package: ${pkg_namver}"
work_dir=$(mktemp -d "${TMPDIR:-/tmp}/bacman.XXXXXXXXXX")
cd "$work_dir" || exit 1
#
# File copying
#
msg2 "Copying package files..."
while read i; do
if [[ -z $i ]]; then
continue
fi
if [[ $i == %+([A-Z])% ]]; then
current=$i
continue
fi
case "$current" in
%FILES%)
local_file="/$i"
package_file="$work_dir/$i"
if [[ ! -e $local_file ]]; then
warning "package file $local_file is missing"
continue
fi
;;
%BACKUP%)
# Get the MD5 checksum.
original_md5="${i##*$'\t'}"
# Strip the md5sum after the tab.
i="${i%$'\t'*}"
local_file="/$i.pacnew"
package_file="$work_dir/$i"
# Include unmodified .pacnew files.
local_md5="$(md5sum "$local_file" | cut -d' ' -f1)"
if [[ $INCLUDE_PACNEW == 'n' ]] \
|| [[ ! -e $local_file ]] \
|| [[ $local_md5 != $original_md5 ]]; then
# Warn about modified files.
local_md5="$(md5sum "/$i" | cut -d' ' -f1)"
if [[ $local_md5 != $original_md5 ]]; then
warning "package file /$i has been modified"
fi
# Let the normal file be included in the %FILES% list.
continue
fi
;;
*)
continue
;;
esac
ret=0
bsdtar -cnf - -s'/.pacnew$//' "$local_file" 2> /dev/null | bsdtar -xpf - 2> /dev/null
# Workaround to bsdtar not reporting a missing file as an error
if ! [[ -e $package_file || -L $package_file ]]; then
error "unable to add $local_file to the package"
plain " If your user does not have permission to read this file, then"
plain " you will need to run $myname as root."
rm -rf "$work_dir"
exit 1
fi
done < "$pkg_dir"/files
ret=$?
if (( ret )); then
rm -rf "$work_dir"
exit 1
fi
pkg_size=$(du -sk | awk '{print $1 * 1024}')
#
# .PKGINFO stuff
# TODO adopt makepkg's write_pkginfo() into this or scripts/library
#
msg2 "Generating .PKGINFO metadata..."
echo "# Generated by $myname $myver" > .PKGINFO
if [[ $INFAKEROOT == "1" ]]; then
echo "# Using $(fakeroot -v)" >> .PKGINFO
fi
echo "# $(LC_ALL=C date)" >> .PKGINFO
echo "#" >> .PKGINFO
while read i; do
if [[ -z $i ]]; then
continue;
fi
if [[ $i == %+([A-Z])% ]]; then
current=$i
continue
fi
case "$current" in
# desc
%NAME%)
echo "pkgname = $i" >> .PKGINFO
;;
%VERSION%)
echo "pkgver = $i" >> .PKGINFO
;;
%DESC%)
echo "pkgdesc = $i" >> .PKGINFO
;;
%URL%)
echo "url = $i" >> .PKGINFO
;;
%LICENSE%)
echo "license = $i" >> .PKGINFO
;;
%ARCH%)
echo "arch = $i" >> .PKGINFO
pkg_arch="$i"
;;
%BUILDDATE%)
echo "builddate = $(date -u "+%s")" >> .PKGINFO
;;
%PACKAGER%)
echo "packager = $pkg_pkger" >> .PKGINFO
;;
%SIZE%)
echo "size = $pkg_size" >> .PKGINFO
;;
%GROUPS%)
echo "group = $i" >> .PKGINFO
;;
%REPLACES%)
echo "replaces = $i" >> .PKGINFO
;;
%DEPENDS%)
echo "depend = $i" >> .PKGINFO
;;
%OPTDEPENDS%)
echo "optdepend = $i" >> .PKGINFO
;;
%CONFLICTS%)
echo "conflict = $i" >> .PKGINFO
;;
%PROVIDES%)
echo "provides = $i" >> .PKGINFO
;;
# files
%BACKUP%)
# Strip the md5sum after the tab
echo "backup = ${i%%$'\t'*}" >> .PKGINFO
;;
esac
done < <(cat "$pkg_dir"/{desc,files})
comp_files=".PKGINFO"
if [[ -f $pkg_dir/install ]]; then
cp "$pkg_dir/install" "$work_dir/.INSTALL"
comp_files+=" .INSTALL"
fi
if [[ -f $pkg_dir/changelog ]]; then
cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
comp_files+=" .CHANGELOG"
fi
#
# Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL
#
chown root:root "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
#
# Generate the package
#
msg2 "Generating the package..."
pkg_file="$pkg_dest/$pkg_namver-$pkg_arch${PKGEXT}"
ret=0
# TODO: Maybe this can be set globally for robustness
shopt -s -o pipefail
bsdtar -cf - $comp_files * |
case "$PKGEXT" in
*tar.gz) gzip -c -f -n ;;
*tar.bz2) bzip2 -c -f ;;
*tar.xz) xz -c -z - ;;
*tar.Z) compress -c -f ;;
*tar) cat ;;
*) warning "'%s' is not a valid archive extension." \
"$PKGEXT"; cat ;;
esac > "${pkg_file}"; ret=$?
if (( ret )); then
error "Unable to write package to $pkg_dest"
plain " Maybe the disk is full or you do not have write access"
rm -rf "$work_dir"
exit 1
fi
rm -rf "$work_dir"
msg "Done."
exit 0
# vim: set noet:

View File

@@ -0,0 +1,59 @@
#!/bin/bash
#
# checkupdates: Safely print a list of pending updates.
#
# Copyright (c) 2013 Kyle Keen <keenerd@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
declare -r myname='checkupdates'
declare -r myver='@PACKAGE_VERSION@'
m4_include(../scripts/library/output_format.sh)
m4_include(../scripts/library/term_colors.sh)
if (( $# > 0 )); then
echo "${myname} (pacman) v${myver}"
echo
echo "Safely print a list of pending updates"
echo
echo "Usage: ${myname}"
echo
echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.'
exit 0
fi
if ! type -P fakeroot >/dev/null; then
error 'Cannot find the fakeroot binary.'
exit 1
fi
if [[ -z $CHECKUPDATES_DB ]]; then
CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/"
fi
trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT
DBPath="${DBPath:-@localstatedir@/lib/pacman/}"
eval $(awk -F' *= *' '$1 ~ /DBPath/ { print $1 "=" $2 }' @sysconfdir@/pacman.conf)
mkdir -p "$CHECKUPDATES_DB"
ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null
fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null
pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
exit 0
# vim: set noet:

366
contrib/paccache.sh.in Normal file
View File

@@ -0,0 +1,366 @@
#!/bin/bash
#
# pacache - flexible pacman cache cleaning
#
# Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
shopt -s extglob
declare -r myname='paccache'
declare -r myver='@PACKAGE_VERSION@'
declare -a cachedirs=() candidates=() cmdopts=() whitelist=() blacklist=()
declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0
declare delim=$'\n' keep=3 movedir= scanarch=
QUIET=0
USE_COLOR='y'
m4_include(../scripts/library/output_format.sh)
m4_include(../scripts/library/parseopts.sh)
die() {
error "$@"
exit 1
}
get_cachedir_from_config() {
local key value
while IFS=$'= \t' read -r key value _; do
if [[ $key = CacheDir ]]; then
echo "$value"
return 0
fi
done <"$1"
return 1
}
# reads a list of files on stdin and prints out deletion candidates
pkgfilter() {
# there's whitelist and blacklist parameters passed to this
# script after the block of awk.
awk -v keep="$1" -v scanarch="$2" '
function basename(str) {
sub(".*/", "", str);
return str;
}
function parse_filename(filename, parts, count, i, pkgname, arch) {
count = split(basename(filename), parts, "-")
i = 1
pkgname = parts[i++]
while (i <= count - 3) {
pkgname = pkgname "-" parts[i++]
}
arch = substr(parts[count], 1, index(parts[count], ".") - 1)
# filter on whitelist or blacklist
if (wlen && !whitelist[pkgname]) return
if (blen && blacklist[pkgname]) return
if ("" == packages[pkgname,arch]) {
packages[pkgname,arch] = filename
} else {
packages[pkgname,arch] = packages[pkgname,arch] SUBSEP filename
}
}
BEGIN {
# create whitelist
wlen = ARGV[1]; delete ARGV[1]
for (i = 2; i < 2 + wlen; i++) {
whitelist[ARGV[i]] = 1
delete ARGV[i]
}
# create blacklist
blen = ARGV[i]; delete ARGV[i]
while (i++ < ARGC) {
blacklist[ARGV[i]] = 1
delete ARGV[i]
}
# read package filenames
while (getline < "/dev/stdin") {
parse_filename($0)
}
for (pkglist in packages) {
# idx[1,2] = idx[pkgname,arch]
split(pkglist, idx, SUBSEP)
# enforce architecture match if specified
if (!scanarch || scanarch == idx[2]) {
count = split(packages[idx[1], idx[2]], pkgs, SUBSEP)
for(i = 1; i <= count - keep; i++) {
print pkgs[i]
}
}
}
}' "${@:3}"
}
m4_include(../scripts/library/size_to_human.sh)
runcmd() {
if (( needsroot && EUID != 0 )); then
msg "Privilege escalation required"
if sudo -v &>/dev/null && sudo -l &>/dev/null; then
sudo "$@"
else
die 'Unable to escalate privileges using sudo'
fi
else
"$@"
fi
}
summarize() {
(( QUIET )) && return
local -i filecount=$1; shift
local seenarch= seen= arch= name=
local -r pkg_re='(.+)-[^-]+-[0-9]+-([^.]+)\.pkg.*'
if (( delete )); then
printf -v output 'finished: %d packages removed' "$filecount"
elif (( move )); then
printf -v output "finished: %d packages moved to '%s'" "$filecount" "$movedir"
elif (( dryrun )); then
if (( verbose )); then
msg "Candidate packages:"
while read -r pkg; do
if (( verbose >= 3 )); then
[[ $pkg =~ $pkg_re ]] && name=${BASH_REMATCH[1]} arch=${BASH_REMATCH[2]}
if [[ -z $seen || $seenarch != "$arch" || $seen != "$name" ]]; then
seen=$name seenarch=$arch
printf '%s (%s):\n' "${name##*/}" "$arch"
fi
printf ' %s\n' "${pkg##*/}"
elif (( verbose >= 2 )); then
printf "%s$delim" "$pkg"
else
printf "%s$delim" "${pkg##*/}"
fi
done < <(printf '%s\n' "$@" | pacsort --files)
fi
printf -v output 'finished dry run: %d candidates' "$filecount"
fi
echo
msg "$output (disk space saved: %s)" "$(size_to_human "$totalsaved")"
}
usage() {
cat <<EOF
${myname} (pacman) v${myver}
A flexible pacman cache cleaning utility.
Usage: ${myname} <operation> [options] [targets...]
Operations:
-d, --dryrun perform a dry run, only finding candidate packages.
-m, --move <dir> move candidate packages to "dir".
-r, --remove remove candidate packages.
Options:
-a, --arch <arch> scan for "arch" (default: all architectures).
-c, --cachedir <dir> scan "dir" for packages. can be used more than once.
(default: read from @sysconfdir@/pacman.conf).
-f, --force apply force to mv(1) and rm(1) operations.
-h, --help display this help message and exit.
-i, --ignore <pkgs> ignore "pkgs", comma-separated. Alternatively, specify
"-" to read package names from stdin, newline-
delimited.
-k, --keep <num> keep "num" of each package in the cache (default: 3).
--nocolor remove color from output.
-q, --quiet minimize output
-u, --uninstalled target uninstalled packages.
-v, --verbose increase verbosity. specify up to 3 times.
-z, --null use null delimiters for candidate names (only with -v
and -vv).
EOF
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
}
OPT_SHORT=':a:c:dfhi:k:m:qrsuVvz'
OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
'nocolor' 'quiet' 'remove' 'uninstalled' 'version' 'verbose' 'null')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1
fi
set -- "${OPTRET[@]}"
unset OPT_SHORT OPT_LONG OPTRET
while :; do
case $1 in
-a|--arch)
scanarch=$2
shift ;;
-c|--cachedir)
cachedirs+=("$2")
shift ;;
-d|--dryrun)
dryrun=1 ;;
-f|--force)
cmdopts=(-f) ;;
-h|--help)
usage
exit 0 ;;
-i|--ignore)
if [[ $2 = '-' ]]; then
[[ ! -t 0 ]] && IFS=$'\n' read -r -d '' -a ign
else
IFS=',' read -r -a ign <<< "$2"
fi
blacklist+=("${ign[@]}")
unset i ign
shift ;;
-k|--keep)
keep=$2
if [[ -z $keep || -n ${keep//[0-9]/} ]]; then
die 'argument to option -k must be a non-negative integer'
else
keep=$(( 10#$keep ))
fi
shift ;;
-m|--move)
move=1 movedir=$2
shift ;;
--nocolor)
USE_COLOR='n' ;;
-q|--quiet)
QUIET=1 ;;
-r|--remove)
delete=1 ;;
-u|--uninstalled)
IFS=$'\n' read -r -d '' -a ign < <(pacman -Qq)
# pacman -Qq may exit with an error, thus making ign an empty array
(( ${#ign[@]} )) || die 'failed to retrieve the list of installed packages'
blacklist+=("${ign[@]}")
unset ign ;;
-V|--version)
version
exit 0 ;;
-v|--verbose)
(( ++verbose )) ;;
-z|--null)
delim='\0' ;;
--)
shift
break 2 ;;
esac
shift
done
m4_include(../scripts/library/term_colors.sh)
# setting default cachedir
if [[ -z $cachedirs ]]; then
if cachedir=$(get_cachedir_from_config "@sysconfdir@/pacman.conf"); then
cachedirs=("$cachedir")
else
cachedirs=("${cachedirs[@]:-@localstatedir@/cache/pacman/pkg}")
fi
fi
# remaining args are a whitelist
whitelist=("$@")
# sanity checks
case $(( dryrun+delete+move )) in
0) die "no operation specified (use -h for help)" ;;
[^1]) die "only one operation may be used at a time" ;;
esac
[[ $movedir && ! -d $movedir ]] &&
die "destination directory '%s' does not exist or is not a directory" "$movedir"
if (( move || delete )); then
# make it an absolute path since we're about to chdir
[[ $movedir && ${movedir:0:1} != '/' ]] && movedir=$PWD/$movedir
[[ $movedir && ! -w $movedir ]] && needsroot=1
fi
for cachedir in "${cachedirs[@]}"; do
[[ -d $cachedir ]] ||
die "cachedir '%s' does not exist or is not a directory" "$cachedir"
if (( move || delete )); then
[[ ! -w $cachedir ]] && needsroot=1
fi
# unlikely that this will fail, but better make sure
pushd "$cachedir" &>/dev/null || die "failed to chdir to '%s'" "$cachedir"
# note that these results are returned in an arbitrary order from awk, but
# they'll be resorted (in summarize) iff we have a verbosity level set.
IFS=$'\n' read -r -d '' -a cand < \
<(printf '%s\n' "$PWD"/*.pkg.tar?(.+([^.])) | pacsort --files |
pkgfilter "$keep" "$scanarch" \
"${#whitelist[*]}" "${whitelist[@]}" \
"${#blacklist[*]}" "${blacklist[@]}")
candidates+=("${cand[@]}")
unset cand
popd &>/dev/null
done
if (( ! ${#candidates[*]} )); then
msg 'no candidate packages found for pruning'
exit 0
fi
# grab this prior to signature scavenging
pkgcount=${#candidates[*]}
# copy the list, merging in any found sigs
for cand in "${candidates[@]}"; do
candtemp+=("$cand")
[[ -f $cand.sig ]] && candtemp+=("$cand.sig")
done
candidates=("${candtemp[@]}")
unset candtemp
# do this before we destroy anything
totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END { print sum }')
# crush. kill. destroy.
(( verbose )) && cmdopts+=(-v)
if (( delete )); then
printf '%s\0' "${candidates[@]}" | runcmd xargs -0 rm "${cmdopts[@]}"
elif (( move )); then
printf '%s\0' "${candidates[@]}" | runcmd xargs -0 mv "${cmdopts[@]}" -t "$movedir"
fi
summarize "$pkgcount" "${candidates[@]}"
# vim: set noet:

194
contrib/pacdiff.sh.in Normal file
View File

@@ -0,0 +1,194 @@
#!/bin/bash
# pacdiff : a simple pacnew/pacsave updater
#
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
shopt -s extglob
declare -r myname='pacdiff'
declare -r myver='@PACKAGE_VERSION@'
diffprog=${DIFFPROG:-'vim -d'}
diffsearchpath=${DIFFSEARCHPATH:-/etc}
USE_COLOR='y'
declare -a oldsaves
declare -i USE_FIND=0 USE_LOCATE=0 USE_PACDB=0 OUTPUTONLY=0
m4_include(../scripts/library/output_format.sh)
usage() {
cat <<EOF
${myname} (pacman) v${myver}
A simple program to merge or remove pacnew/pacsave files.
Usage: $myname [-l | -f | -p] [--nocolor]
Search Options: select one (default: --pacmandb)
-l/--locate scan using locate
-f/--find scan using find
-p/--pacmandb scan active config files from pacman database
General Options:
-o/--output print files instead of merging them
--nocolor remove colors from output
Environment Variables:
DIFFPROG override the merge program: (default: 'vim -d')
DIFFSEARCHPATH override the search path. (only when using find)
(default: /etc)
Example: DIFFPROG=meld DIFFSEARCHPATH="/boot /etc /usr" $myname
Example: $myname --output --locate
EOF
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>'
echo 'Copyright (C) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>'
}
print_existing() {
[[ -f "$1" ]] && printf '%s\0' "$1"
}
print_existing_pacsave(){
for f in "${1}"?(.+([0-9])); do
[[ -f $f ]] && printf '%s\0' "$f"
done
}
cmd() {
if (( USE_LOCATE )); then
locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave '*.pacsave.[0-9]*'
elif (( USE_FIND )); then
find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave -o -name '*.pacsave.[0-9]*' \) -print0
elif (( USE_PACDB )); then
awk '/^%BACKUP%$/ {
while (getline) {
if (/^$/) { nextfile }
print $1
}
}' "${pac_db}"/*/files | while read -r bkup; do
print_existing "/$bkup.pacnew"
print_existing "/$bkup.pacorig"
print_existing_pacsave "/$bkup.pacsave"
done
fi
}
while [[ -n "$1" ]]; do
case "$1" in
-l|--locate)
USE_LOCATE=1;;
-f|--find)
USE_FIND=1;;
-p|--pacmandb)
USE_PACDB=1;;
-o|--output)
OUTPUTONLY=1;;
--nocolor)
USE_COLOR='n';;
-V|--version)
version; exit 0;;
-h|--help)
usage; exit 0;;
*)
usage; exit 1;;
esac
shift
done
m4_include(../scripts/library/term_colors.sh)
if ! type -p ${diffprog%% *} >/dev/null && (( ! OUTPUTONLY )); then
error "Cannot find the $diffprog binary required for viewing differences."
exit 1
fi
case $(( USE_FIND + USE_LOCATE + USE_PACDB )) in
0) USE_PACDB=1;; # set the default search option
[^1]) error "Only one search option may be used at a time"
usage; exit 1;;
esac
if (( USE_PACDB )); then
if [[ ! -r @sysconfdir@/pacman.conf ]]; then
error "unable to read @sysconfdir@/pacman.conf"
usage; exit 1
fi
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
pac_db="${DBPath:-@localstatedir@/lib/pacman/}local"
if [[ ! -d "${pac_db}" ]]; then
error "unable to read pacman database %s". "${pac_db}"
usage; exit 1
fi
fi
# see http://mywiki.wooledge.org/BashFAQ/020
while IFS= read -u 3 -r -d '' pacfile; do
file="${pacfile%.pac*}"
file_type="pac${pacfile##*.pac}"
if (( OUTPUTONLY )); then
echo "$pacfile"
continue
fi
# add matches for pacsave.N to oldsaves array, do not prompt
if [[ $file_type = pacsave.+([0-9]) ]]; then
oldsaves+=("$pacfile")
continue
fi
msg "%s file found for %s" "$file_type" "$file"
if [ ! -f "$file" ]; then
warning "$file does not exist"
rm -iv "$pacfile"
continue
fi
if cmp -s "$pacfile" "$file"; then
msg2 "Files are identical, removing..."
rm -v "$pacfile"
else
ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type"
while read c; do
case $c in
q|Q) exit 0;;
r|R) rm -v "$pacfile"; break ;;
o|O) mv -v "$pacfile" "$file"; break ;;
v|V)
$diffprog "$pacfile" "$file"
ask "(V)iew, (S)kip, (R)emove %s, (O)verwrite with %s, (Q)uit: [v/s/r/o/q] " "$file_type" "$file_type";
continue ;;
s|S) break ;;
*) ask "Invalid answer. Try again: [v/s/r/o/q] "; continue ;;
esac
done
fi
done 3< <(cmd)
(( ${#oldsaves[@]} )) && warning "Ignoring %s" "${oldsaves[@]}"
exit 0
# vim: set noet:

68
contrib/paclist.sh.in Normal file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
# paclist - List all packages installed from a given repo
#
# Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>
# Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
declare -r myname='paclist'
declare -r myver='@PACKAGE_VERSION@'
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='/usr/share/locale'
# determine whether we have gettext; make it a no-op if we do not
if ! type gettext &>/dev/null; then
gettext() {
echo "$@"
}
fi
usage() {
printf "%s (pacman) v%s\n" "${myname}" "${myver}"
echo
printf "List all packages installed from a given repository\n" "${myname}"
echo
printf "Usage: %s <repository>\n" "${myname}"
echo
printf "Example: %s testing\n" "${myname}"
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>'
echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>'
}
if [[ -z $1 ]]; then
usage
exit 1
fi
if [[ $1 = -@(h|-help) ]]; then
usage
exit 0
elif [[ $1 = -@(V|-version) ]]; then
version
exit 0
fi
printf -v installed '[%s]' "$(gettext installed)"
pacman -Sl $1 | awk -v i="$installed" '$NF == i { print $2,$3 }'
# exit with pacman's return value, not awk's
exit ${PIPESTATUS[0]}
# vim: set noet:

View File

@@ -0,0 +1,99 @@
#!/bin/bash
#
# paclog-pkglist - Parse a log file into a list of currently installed packages
#
# Copyright (C) 2011 Dave Reisner <dave@archlinux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
declare -r myname='paclog-pkglist'
declare -r myver='@PACKAGE_VERSION@'
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='/usr/share/locale'
declare logfile=${1:-@localstatedir@/log/pacman.log}
usage() {
printf "%s (pacman) v%s\n" "${myname}" "${myver}"
echo
echo "Parse a log file into a list of currently installed packages"
echo
printf "Usage: %s [path to pacman log]\n" "${myname}"
echo
printf "Example: %s @localstatedir@/log/pacman.log\n" "${myname}"
echo
echo 'Defaults to: @localstatedir@/log/pacman.log'
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2011 Dave Reisner <dave@archlinux.org>'
}
if [[ $1 ]]; then
if [[ $1 = -@(h|-help) ]]; then
usage
exit 0
elif [[ $1 = -@(V|-version) ]]; then
version
exit 0
elif [[ ! -e $logfile ]]; then
printf $"target not found: %s\n" "$1"
exit 1
fi
fi
<"$logfile" awk '
{
if ($3 ~ /^\[.*\]$/) {
# new style with caller name
action = $4
pkgname = $5
pkgver = $6
upgver = $8
nfields = NF
} else {
action = $3
pkgname = $4
pkgver = $5
upgver = $7
nfields = (NF + 1) # compensate for missing caller field
}
}
nfields == 6 && action == "installed" {
gsub(/[()]/, "", pkgver)
pkg[pkgname] = pkgver
next
}
nfields == 8 && (action == "upgraded" || action == "downgraded") {
sub(/\)/, "", upgver)
pkg[pkgname] = upgver
next
}
nfields == 6 && action == "removed" {
pkg[pkgname] = -1
}
END {
for (i in pkg) {
if (pkg[i] != -1) {
printf "%s %s\n",i,pkg[i]
}
}
}' | sort
# vim: set noet:

140
contrib/pacscripts.sh.in Normal file
View File

@@ -0,0 +1,140 @@
#!/bin/bash
#
# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
# scripts of a given package
#
# Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>
# Copyright (c) 2009-2016 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# bash options
set -o nounset
set -o errexit
declare -r myname='pacscripts'
declare -r myver='@PACKAGE_VERSION@'
conf="@sysconfdir@/pacman.conf"
if [ ! -r "$conf" ]; then
echo "ERROR: unable to read $conf"
exit 1
fi
eval $(awk '/DBPath/ {print $1$2$3}' "$conf")
eval $(awk '/CacheDir/ {print $1$2$3}' "$conf")
pac_db="${DBPath:-@localstatedir@/lib/pacman}/local"
pac_cache="${CacheDir:-@localstatedir@/cache/pacman/pkg}"
error() {
local mesg=$1; shift
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
}
usage() {
echo "${myname} (pacman) v${myver}"
echo
echo "Prints the {pre,post}_{install,remove,upgrade} scripts of a given package."
echo
echo "Usage: ${myname} <pkgname|pkgfile>"
echo
echo " Options:"
echo " -h, --help Print this help message"
echo " -v, --version Print program name and version"
echo
echo "Example: ${myname} gconf-editor"
echo "Example: ${myname} gconf-editor-3.0.1-3-x86_64.pkg.tar.xz"
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>'
echo 'Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>'
}
spacman() {
if [ $EUID -eq 0 ]; then
pacman "$@"
else
if ! type -p sudo; then
error "Cannot find the sudo binary!"
error "${myname} requires root privileges. Either install \"sudo\" or run as root."
exit 1
else
sudo pacman "$@"
fi
fi
}
print_db() {
pkg=$(pacman -Q "$1")
pkg=${pkg/ /-}
if [ -f $pac_db/$pkg*/install ]; then
cat $pac_db/$pkg*/install
echo
return 0
else
error "Package $1 does not include any .INSTALL script"
return 1
fi
}
print_pkg() {
if ! bsdtar -xqOf "$1" .INSTALL 2>/dev/null; then
error "Package $1 does not include any .INSTALL script"
return 1
fi
echo
}
print_scriptlet() {
if [ -f "$1" ]; then
if bsdtar tf "$1" .PKGINFO &>/dev/null; then
print_pkg "$1"
return
fi
fi
if pacman -Q "$1" &>/dev/null; then
print_db "$1"
return
fi
if ! pacman -Si $1 &>/dev/null; then
error "Package $1 not found"
return 1
fi
url=$(pacman -Sddp $1)
filename=$(basename $url)
if [ ! -f "$pac_cache/$filename" ]; then
if ! spacman -Sddw --noconfirm $1 >&2; then
error "Failed to download $1"
return 1
fi
echo >&2
fi
print_pkg "$pac_cache/$filename"
return
}
if [ $# -ne 1 ] ; then
usage
exit 1
fi
case "$1" in
--help|-h) usage; exit 0 ;;
--version|-V) version; exit 0 ;;
*) print_scriptlet $1 ;;
esac

125
contrib/pacsearch.in Normal file
View File

@@ -0,0 +1,125 @@
#!/usr/bin/perl
# pacsearch - Perform a pacman search using both the local and the sync databases
#
# Copyright (C) 2008-2014 Dan McGee <dan@archlinux.org>
#
# Based off original shell script version:
# Copyright (C) 2006-2007 Dan McGee <dan@archlinux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Term::ANSIColor;
my $myname = 'pacsearch';
my $myver = '@PACKAGE_VERSION@';
sub usage {
print "$myname (pacman) v$myver\n\n";
print "Perform a pacman search using both the local and the sync databases.\n\n";
print "Usage: $myname [-n] <pattern>\n\n";
print "Options:\n";
print " -n, --nocolor: turn off coloring\n\n";
print "Example: $myname ^gnome\n";
}
sub version {
printf "%s %s\n", $myname, $myver;
print "Copyright (C) 2008-2014 Dan McGee <dan\@archlinux.org>\n\n";
print "Based off original shell script version:\n";
print "Copyright (C) 2006-2007 Dan McGee <dan\@archlinux.org>\n";
}
if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
usage;
if ($#ARGV lt 0) {
exit 1;
}
exit 0;
}
if ($ARGV[0] eq "--version" || $ARGV[0] eq "-V") {
version;
exit 0;
}
# define formatting variables
my($BLUE, $CYAN, $GREEN, $MAGENTA, $RED, $YELLOW, $BOLD, $RESET);
if ($ARGV[0] eq "--nocolor" || $ARGV[0] eq "-n") {
shift;
$BLUE = "";
$CYAN = "";
$GREEN = "";
$MAGENTA = "";
$RED = "";
$YELLOW = "";
$BOLD = "";
$RESET = "";
} else {
$BLUE = color('blue');
$CYAN = color('cyan');
$GREEN = color('green');
$MAGENTA = color('magenta');
$RED = color('red');
$YELLOW = color('yellow');
$BOLD = color('bold');
$RESET = color('reset');
}
# localization
my $LC_INSTALLED = `gettext pacman installed`;
# Print a "repo/pkgname pkgver (groups) [installed]" line.
# We stick to pacman colors.
sub print_pkg {
my @v = @_;
print "$RESET$BOLD";
if ( "$v[0]" eq "local" ) {
print "$RED";
} else {
print "$MAGENTA";
}
print "$v[0]/$RESET$BOLD$v[1] $GREEN$v[2]$BLUE$v[3]$CYAN$v[4]$RESET\n";
print "$v[5]";
}
sub list_pkg {
my $db = shift;
open (my $out, '-|', 'pacman', $db, '--', @ARGV) or exit 1;
my @pkglist = ();
while ( readline($out) ) {
# We grab the following fields: repo, name, ver, group, installed, and
# desc. We grab leading space for 'group' and 'installed' so that we do
# not need to test if non-empty when printing.
my @pkgfields = /^(.*?)\/(.*?) (.*?)( \(.*?\))?( \[.*\])?$/s;
my $desc = readline($out);
# since 'group' and 'installed' are optional, we should fill it in if
# necessary
$pkgfields[3] = "" if not defined $pkgfields[3];
$pkgfields[4] = "" if not defined $pkgfields[4];
$pkgfields[5] = $desc;
push (@pkglist, \@pkgfields);
}
close ($out);
return @pkglist;
}
my @sync = list_pkg('-Ss', @ARGV);
my %allpkgs = map {$_->[1] . $_->[2] => 1} @sync;
my @query = grep { not $allpkgs{$_->[1] . $_->[2]}} list_pkg('-Qs', @ARGV);
$_->[4] = " [$LC_INSTALLED]" foreach @query;
print_pkg (@{$_}) foreach (@sync, @query);
#vim: set noet:

234
contrib/rankmirrors.sh.in Normal file
View File

@@ -0,0 +1,234 @@
#!/bin/bash
#
# rankmirrors - read a list of mirrors from a file and rank them by speed
# @configure_input@
#
# Copyright (c) 2009 Matthew Bruenig <matthewbruenig@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# traps interrupt key to spit out pre-interrupt info
trap finaloutput INT
declare -r myname='rankmirrors'
declare -r myver='@PACKAGE_VERSION@'
usage() {
echo "${myname} (pacman) v${myver}"
echo
echo "Ranks pacman mirrors by their connection and opening speed. Pacman mirror"
echo "files are located in @sysconfdir@/pacman.d/. It can also rank one mirror if the URL is"
echo "provided."
echo
echo "Usage: ${myname} [options] MIRRORFILE | URL"
echo
echo "Options:"
echo " --version show program's version number and exit"
echo " -h, --help show this help message and exit"
echo " -n NUM number of servers to output, 0 for all"
echo " -t, --times only output mirrors and their response times"
echo " -u, --url test a specific URL"
echo " -v, --verbose be verbose in ouptut"
echo " -r, --repo specify a repository name instead of guessing"
exit 0
}
version() {
echo "${myname} (pacman) ${myver}"
echo "Copyright (c) 2009 Matthew Bruenig <matthewbruenig@gmail.com>."
echo
echo "This is free software; see the source for copying conditions."
echo "There is NO WARRANTY, to the extent permitted by law."
exit 0
}
err() {
echo "$1" >&2
exit 1
}
# gettime fetchurl (e.g gettime http://foo.com/core/os/i686/core.db.tar.gz)
# returns the fetching time, or timeout, or unreachable
gettime() {
IFS=' ' output=( $(curl -s -m 10 -w "%{time_total} %{http_code}" "$1" -o/dev/null) )
(( $? == 28 )) && echo timeout && return
(( ${output[1]} >= 400 || ! ${output[1]} )) && echo unreachable && return
echo "${output[0]}"
}
# getfetchurl serverurl (e.g. getturl http://foo.com/core/os/i686)
# if $repo is in the line, then assumes core
# if $arch is in the line, then assumes $(uname -m)
# returns a fetchurl (e.g. http://foo.com/core/os/i686/core.db.tar.gz)
ARCH="$(uname -m)"
getfetchurl() {
local strippedurl="${1%/}"
local replacedurl="${strippedurl//'$arch'/$ARCH}"
if [[ ! $TARGETREPO ]]; then
replacedurl="${replacedurl//'$repo'/core}"
local tmp="${replacedurl%/*}"
tmp="${tmp%/*}"
local reponame="${tmp##*/}"
else
replacedurl="${replacedurl//'$repo'/$TARGETREPO}"
local reponame="$TARGETREPO"
fi
if [[ -z $reponame || $reponame = $replacedurl ]]; then
echo "fail"
else
local fetchurl="${replacedurl}/$reponame.db"
echo "$fetchurl"
fi
}
# This exists to remove the need for a separate interrupt function
finaloutput() {
IFS=$'\n' read -r -d '' -a sortedarray < \
<(printf '%s\n' "${timesarray[@]}" | LC_COLLATE=C sort)
# Final output for mirrorfile
numiterator="0"
if [[ $TIMESONLY ]]; then
echo
echo " Servers sorted by time (seconds):"
for line in "${sortedarray[@]}"; do
echo "${line#* } : ${line% *}"
((numiterator++))
(( NUM && numiterator >= NUM )) && break
done
else
for line in "${sortedarray[@]}"; do
echo "Server = ${line#* }"
((numiterator++))
(( NUM && numiterator >= NUM )) && break
done
fi
exit 0
}
# Argument parsing
[[ $1 ]] || usage
while [[ $1 ]]; do
if [[ ${1:0:2} = -- ]]; then
case "${1:2}" in
help) usage ;;
version) version ;;
times) TIMESONLY=1 ; shift ;;
verbose) VERBOSE=1 ; shift ;;
url)
CHECKURL=1;
[[ $2 ]] || err "Must specify URL.";
URL="$2";
shift 2;;
repo)
[[ $2 ]] || err "Must specify repository name.";
TARGETREPO="$2";
shift 2;;
*) err "'$1' is an invalid argument."
esac
elif [[ ${1:0:1} = - ]]; then
if [[ ! ${1:1:1} ]]; then
[[ -t 0 ]] && err "Stdin is empty."
IFS=$'\n' linearray=( $(</dev/stdin) )
STDIN=1
shift
else
snum=1
for ((i=1 ; i<${#1}; i++)); do
case ${1:$i:1} in
h) usage ;;
t) TIMESONLY=1 ;;
v) VERBOSE=1 ;;
u)
CHECKURL=1;
[[ $2 ]] || err "Must specify URL.";
URL="$2";
snum=2;;
r)
[[ $2 ]] || err "Must specify repository name.";
TARGETREPO="$2";
snum=2;;
n)
[[ $2 ]] || err "Must specify number.";
NUM="$2";
snum=2;;
*) err "'$1' is an invalid argument." ;;
esac
done
shift $snum
fi
elif [[ -f $1 ]]; then
FILE="1"
IFS=$'\n' linearray=( $(<$1) )
[[ $linearray ]] || err "File is empty."
shift
else
err "'$1' does not exist."
fi
done
# Some sanity checks
[[ $NUM ]] || NUM=0
[[ $FILE && $CHECKURL ]] && err "Cannot specify a URL and mirrorfile."
[[ $FILE || $CHECKURL || $STDIN ]] || err "Must specify URL, mirrorfile, or stdin."
# Single URL handling
if [[ $CHECKURL ]]; then
url="$(getfetchurl "$URL")"
[[ $url = fail ]] && err "URL '$URL' is malformed."
[[ $VERBOSE ]] && echo "Testing $url..."
time=$(gettime "$url")
echo "$URL : $time"
exit 0
fi
# Get URL results from mirrorfile, fill up the array, and so on
if [[ $TIMESONLY ]]; then
echo "Querying servers. This may take some time..."
elif [[ $FILE ]]; then
echo "# Server list generated by rankmirrors on $(date +%Y-%m-%d)"
fi
timesarray=()
for line in "${linearray[@]}"; do
if [[ $line =~ ^[[:space:]]*# ]]; then
[[ $TIMESONLY ]] || echo $line
elif [[ $line =~ ^[[:space:]]*Server ]]; then
# Getting values and times and such
server="${line#*= }"
server="${server%%#*}"
url="$(getfetchurl "$server")"
[[ $url = fail ]] && err "URL '$URL' is malformed."
time=$(gettime "$url")
timesarray+=("$time $server")
# Output
if [[ $VERBOSE && $TIMESONLY ]]; then
echo "$server ... $time"
elif [[ $VERBOSE ]]; then
echo "# $server ... $time"
elif [[ $TIMESONLY ]]; then
echo -n " *"
fi
fi
done
finaloutput
# vim: set noet:

106
contrib/updpkgsums.sh.in Normal file
View File

@@ -0,0 +1,106 @@
#!/bin/bash
#
# updpkgsums - update source checksums in-place in PKGBUILDs
#
# Copyright (C) 2012-2013 Dave Reisner <dreisner@archlinux.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
shopt -s extglob
declare -r myname='updpkgsums'
declare -r myver='@PACKAGE_VERSION@'
usage() {
printf "%s (pacman) v%s\n" "${myname}" "${myver}"
echo
printf "%s will perform an in place update of the checksums in the\n" "${myname}"
echo "path specified by [build file], defaulting to PKGBUILD in the current"
echo "working directory."
echo
printf "Usage: %s [build file]\n" "${myname}"
echo
echo " -h, --help display this help message and exit"
echo " -V, --version display version information and exit"
}
version() {
printf "%s %s\n" "$myname" "$myver"
echo 'Copyright (C) 2012-2013 Dave Reisner <dreisner@archlinux.org>'
}
die() {
printf "==> ERROR: $1\n" "${@:2}" >&2
exit 1
}
case $1 in
-h|--help) usage; exit ;;
-V|--version) version; exit ;;
esac
buildfile=${1:-PKGBUILD}
if [[ ! -f $buildfile ]]; then
die "%s not found or is not a file" "$buildfile"
fi
# Resolve any symlinks to avoid replacing the symlink with a file. But, we
# have to do this portably -- readlink's flags are inconsistent across OSes.
while [[ -L $buildfile ]]; do
buildfile=$(readlink "$buildfile")
if [[ $buildfile = */* ]]; then
cd "${buildfile%/*}"
buildfile=${buildfile##*/}
fi
done
# cd into the directory with the build file. This avoids creating random src/
# directories scattered about the filesystem, and avoids cases where we might
# not be able to write in the $PWD.
if [[ $buildfile = */* ]]; then
cd "${buildfile%/*}"
buildfile=${buildfile##*/}
fi
# Check $PWD/ for permission to unlink the $buildfile and write a new one
if [[ ! -w . ]]; then
die "No write permission in '%s'" "$PWD"
fi
# Generate the new sums
export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX")
newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX")
trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT
newsums=$(makepkg -g -p "$buildfile") || die 'Failed to generate new checksums'
awk -v newsums="$newsums" '
/^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ {
if (!w) {
print newsums
w++
}
next
}
1
END { if (!w) print newsums }
' "$buildfile" > "$newbuildfile" || die 'Failed to write new PKGBUILD'
# Rewrite the original buildfile. Use cat instead of mv/cp to preserve
# permissions implicitly.
if ! cat -- "$newbuildfile" >"$buildfile"; then
die "Failed to update %s. The file has not been modified." "$buildfile"
fi
# vim: set noet:

25
contrib/vimprojects Normal file
View File

@@ -0,0 +1,25 @@
This is a project file
for the vim-project plugin.
Save it as ~/.vimprojects
$ pacman -S vim-project
change the pacman path below
$ vim
:Project
Press \r in the project view
on a project name to generate
the list of files
pacman=~/devel/pacman/ CD=. filter="*.ac *.am" flags=S {
libalpm=lib/libalpm/ filter="*.c *.h *.am" {
}
pacman=src/pacman/ filter="*.c *.h *.am" {
}
scripts=scripts/ filter="*.sh.in *.py.in *.am" {
}
utils=src/util filter="*.c *.h *.am" {
}
contrib=contrib CD=. {
}
}

16
doc/.gitignore vendored
View File

@@ -1,4 +1,17 @@
*.[1-8] alpm-hooks.5
PKGBUILD.5
libalpm.3
makepkg.8
makepkg-template.1
makepkg.conf.5
pacman.8
pacman-key.8
pacman.conf.5
pactree.8
pkgdelta.8
repo-add.8
repo-remove.8
vercmp.8
asciidoc-manpage.css asciidoc-manpage.css
asciidoc.css asciidoc.css
asciidoc.js asciidoc.js
@@ -6,4 +19,3 @@ asciidoc.js
*.xml *.xml
man3 man3
website.tar.gz website.tar.gz
Doxyfile

View File

@@ -1,70 +0,0 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
BUILDINFO(5)
============
Name
----
BUILDINFO - Makepkg package build information file
Synopsis
--------
This manual page describes the format of a BUILDINFO file found in the root of
a package created by makepkg. The file contains a description of the package's
build environment. The information is formatted in key-value pairs separated by
a '=', one value per line. Arrays are represented multiple keys with the same
value.
Description
-----------
This is a description of the contents of version '1' of the
BUILDINFO file format.
*format*::
Denotes the file format version, represented by a plain positive integer.
*pkgname*::
The name of the package.
*pkgbase*::
The base name of a package, usually the same as the pkgname except for
split packages.
*pkgver*::
The version of the package including pkgrel and epoch.
*pkgarch*::
The architecture of the package.
*pkgbuild_sha256sum*::
The sha256sum in hex format of the PKGBUILD used to build the package.
*packager*::
The details of the packager that built the package.
*builddate*::
The build date of the package in epoch.
*builddir*::
The directory where the package was built.
*buildenv (array)*::
The build environment specified in makepkg.conf.
*options (array)*::
The options set specified when building the package.
*installed (array)*::
The installed packages at build time including the version information of
the package. Formatted as "$pkgname-$pkgver-$pkgrel-$pkgarch".
See Also
--------
linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
include::footer.asciidoc[]

View File

@@ -8,7 +8,7 @@ PROJECT_NAME = libalpm
PROJECT_NUMBER = PROJECT_NUMBER =
PROJECT_BRIEF = "Arch Linux Package Manager Library" PROJECT_BRIEF = "Arch Linux Package Manager Library"
PROJECT_LOGO = PROJECT_LOGO =
OUTPUT_DIRECTORY = @OUTPUT_DIRECTORY@ OUTPUT_DIRECTORY = ./
CREATE_SUBDIRS = NO CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES BRIEF_MEMBER_DESC = YES

View File

@@ -3,7 +3,7 @@
# files listed in EXTRA_DIST no matter what. However, we only add them to # files listed in EXTRA_DIST no matter what. However, we only add them to
# man_MANS if --enable-asciidoc and/or --enable-doxygen are used. # man_MANS if --enable-asciidoc and/or --enable-doxygen are used.
MANPAGES = \ ASCIIDOC_MANS = \
alpm-hooks.5 \ alpm-hooks.5 \
pacman.8 \ pacman.8 \
makepkg.8 \ makepkg.8 \
@@ -12,16 +12,28 @@ MANPAGES = \
vercmp.8 \ vercmp.8 \
pkgdelta.8 \ pkgdelta.8 \
pacman-key.8 \ pacman-key.8 \
pactree.8 \
PKGBUILD.5 \ PKGBUILD.5 \
makepkg.conf.5 \ makepkg.conf.5 \
pacman.conf.5 \ pacman.conf.5 \
libalpm.3 \ libalpm.3
BUILDINFO.5 \
pacman-conf.8
DOXYGEN_MANS = $(wildcard man3/*.3) DOXYGEN_MANS = $(wildcard man3/*.3)
HTML_MANPAGES = $(addsuffix .html,$(MANPAGES)) HTML_MANPAGES = \
alpm-hooks.5.html \
pacman.8.html \
makepkg.8.html \
makepkg-template.1.html \
repo-add.8.html \
vercmp.8.html \
pkgdelta.8.html \
pacman-key.8.html \
pactree.8.html \
PKGBUILD.5.html \
makepkg.conf.5.html \
pacman.conf.5.html \
libalpm.3.html
HTML_OTHER = \ HTML_OTHER = \
index.html \ index.html \
@@ -36,29 +48,30 @@ HTML_DOCS = \
EXTRA_DIST = \ EXTRA_DIST = \
asciidoc.conf \ asciidoc.conf \
asciidoc-override.css \ asciidoc-override.css \
alpm-hooks.5.asciidoc \ alpm-hooks.5.txt \
pacman.8.asciidoc \ pacman.8.txt \
makepkg.8.asciidoc \ makepkg.8.txt \
makepkg-template.1.asciidoc \ makepkg-template.1.txt \
repo-add.8.asciidoc \ repo-add.8.txt \
vercmp.8.asciidoc \ vercmp.8.txt \
pkgdelta.8.asciidoc \ pkgdelta.8.txt \
pacman-key.8.asciidoc \ pacman-key.8.txt \
PKGBUILD.5.asciidoc \ pactree.8.txt \
PKGBUILD.5.txt \
PKGBUILD-example.txt \ PKGBUILD-example.txt \
makepkg.conf.5.asciidoc \ makepkg.conf.5.txt \
pacman.conf.5.asciidoc \ pacman.conf.5.txt \
BUILDINFO.5.asciidoc \ libalpm.3.txt \
libalpm.3.asciidoc \ footer.txt \
footer.asciidoc \ index.txt \
index.asciidoc \ submitting-patches.txt \
submitting-patches.asciidoc \ translation-help.txt \
translation-help.asciidoc \ Doxyfile \
$(MANPAGES) \ $(ASCIIDOC_MANS) \
$(DOXYGEN_MANS) $(DOXYGEN_MANS)
# Files that should be removed, but which Automake does not know. # Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = *.xml $(MANPAGES) $(HTML_DOCS) repo-remove.8 website.tar.gz MOSTLYCLEANFILES = *.xml $(ASCIIDOC_MANS) $(HTML_DOCS) repo-remove.8 website.tar.gz
# Ensure manpages are fresh when building a dist tarball # Ensure manpages are fresh when building a dist tarball
dist-hook: dist-hook:
@@ -73,21 +86,17 @@ REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
endif endif
man_MANS = man_MANS =
dist_man_MANS = $(MANPAGES) dist_man_MANS = $(ASCIIDOC_MANS)
if USE_DOXYGEN if USE_DOXYGEN
man_MANS += $(DOXYGEN_MANS) man_MANS += $(DOXYGEN_MANS)
all-local: doxygen.in all-local: doxygen.in
Doxyfile: Doxyfile.in doxygen.in:
sed 's,@OUTPUT_DIRECTORY@,./,' Doxyfile.in >Doxyfile
doxygen.in: Doxyfile
$(DOXYGEN) $(srcdir)/Doxyfile $(DOXYGEN) $(srcdir)/Doxyfile
endif endif
man: $(MANPAGES)
html: $(HTML_DOCS) html: $(HTML_DOCS)
website: website.tar.gz website: website.tar.gz
@@ -113,8 +122,7 @@ ASCIIDOC_OPTS = \
-a pkgdatadir=$(pkgdatadir) \ -a pkgdatadir=$(pkgdatadir) \
-a localstatedir=$(localstatedir) \ -a localstatedir=$(localstatedir) \
-a sysconfdir=$(sysconfdir) \ -a sysconfdir=$(sysconfdir) \
-a datarootdir=$(datarootdir) \ -a datarootdir=$(datarootdir)
-a rootdir=$(ROOTDIR)
A2X_OPTS = \ A2X_OPTS = \
--no-xmllint \ --no-xmllint \
@@ -122,13 +130,12 @@ A2X_OPTS = \
-f manpage \ -f manpage \
--xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0' --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
# Generate manpages # These rules are due to the includes and files of the asciidoc text
%: %.asciidoc asciidoc.conf footer.asciidoc Makefile.am $(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile.am
$(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.asciidoc $(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.txt
# Generate HTML pages %.html: %.txt
%.html: %.asciidoc asciidoc.conf footer.asciidoc Makefile.am $(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - $*.txt | \
$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - $*.asciidoc | \
sed -e 's/\r$$//' > $@ sed -e 's/\r$$//' > $@
HACKING.html: ../HACKING HACKING.html: ../HACKING
@@ -136,15 +143,28 @@ HACKING.html: ../HACKING
sed -e 's/\r$$//' > $@ sed -e 's/\r$$//' > $@
# Customizations for certain HTML docs # Customizations for certain HTML docs
$(HTML_MANPAGES): asciidoc.conf footer.txt Makefile.am
$(HTML_OTHER): asciidoc.conf Makefile.am
%.html: ASCIIDOC_OPTS += -a linkcss -a toc -a icons -a max-width=960px -a stylesheet=asciidoc-override.css %.html: ASCIIDOC_OPTS += -a linkcss -a toc -a icons -a max-width=960px -a stylesheet=asciidoc-override.css
%.8.html: ASCIIDOC_OPTS += -d manpage %.8.html: ASCIIDOC_OPTS += -d manpage
%.5.html: ASCIIDOC_OPTS += -d manpage %.5.html: ASCIIDOC_OPTS += -d manpage
%.3.html: ASCIIDOC_OPTS += -d manpage %.3.html: ASCIIDOC_OPTS += -d manpage
# Custom dependency rules # Dependency rules
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.asciidoc PKGBUILD-example.txt alpm-hooks.5 alpm-hooks.5.html: alpm-hooks.5.txt
pacman.8 pacman.8.html: pacman.8.txt
# Manpages as symlinks makepkg.8 makepkg.8.html: makepkg.8.txt
makepkg-template.1 makepkg-template.1.html: makepkg-template.1.txt
repo-add.8 repo-add.8.html: repo-add.8.txt
vercmp.8 vercmp.8.html: vercmp.8.txt
pkgdelta.8 pkgdelta.8.html: pkgdelta.8.txt
pacman-key.8 pacman-key.8.html: pacman-key.8.txt
pactree.8 pactree.8.html: pactree.8.txt
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.txt PKGBUILD-example.txt
makepkg.conf.5 makepkg.conf.5.html: makepkg.conf.5.txt
pacman.conf.5 pacman.conf.5.html: pacman.conf.5.txt
libalpm.3 libalpm.3.html: libalpm.3.txt
# this one is just a symlink
repo-remove.8: repo-add.8 repo-remove.8: repo-add.8
$(RM) repo-remove.8 $(RM) repo-remove.8
$(LN_S) repo-add.8 repo-remove.8 $(LN_S) repo-add.8 repo-remove.8
@@ -158,3 +178,5 @@ install-data-hook:
uninstall-hook: uninstall-hook:
$(RM) $(DESTDIR)$(mandir)/man8/repo-remove.8 $(RM) $(DESTDIR)$(mandir)/man8/repo-remove.8
# vim:set noet:

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
PKGBUILD(5) PKGBUILD(5)
=========== ===========
@@ -18,9 +21,9 @@ PKGBUILD is written, the actual package is built using makepkg and installed
with pacman. with pacman.
NOTE: An example PKGBUILD, useful for reference, is located in '{pkgdatadir}' NOTE: An example PKGBUILD, useful for reference, is located in '{pkgdatadir}'
along with other example files such as an install script. You can copy the along with other example files such as a ChangeLog and an install
provided PKGBUILD.proto file to a new package build directory and make script. You can copy the provided PKGBUILD.proto file to a new package build
customizations to suit your needs. directory and make customizations to suit your needs.
Options and Directives Options and Directives
@@ -45,8 +48,7 @@ similar to `$_basekernver`.
*pkgver*:: *pkgver*::
The version of the software as released from the author (e.g., '2.7.1'). The version of the software as released from the author (e.g., '2.7.1').
The variable is not allowed to contain colons, forward slashes, hyphens The variable is not allowed to contain colons or hyphens.
or whitespace.
+ +
The `pkgver` variable can be automatically updated by providing a `pkgver()` The `pkgver` variable can be automatically updated by providing a `pkgver()`
function in the PKGBUILD that outputs the new package version. function in the PKGBUILD that outputs the new package version.
@@ -56,13 +58,11 @@ new `pkgver`. This is most useful when used with sources from version control
systems (see below). systems (see below).
*pkgrel*:: *pkgrel*::
This is the release number specific to the distribution. This This is the release number specific to the Arch Linux release. This
allows package maintainers to make updates to the package's configure allows package maintainers to make updates to the package's configure
flags, for example. This is typically set to '1' for each new upstream flags, for example. This is typically set to '1' for each new upstream
software release and incremented for intermediate PKGBUILD updates. The software release and incremented for intermediate PKGBUILD updates. The
variable is a positive integer, with an optional subrelease level variable is not allowed to contain hyphens.
specified by adding another positive integer separated by a period
(i.e. in the form x.y).
*epoch*:: *epoch*::
Used to force the package to be seen as newer than any previous versions Used to force the package to be seen as newer than any previous versions
@@ -154,7 +154,7 @@ contain whitespace characters.
be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''. be skipped. To easily generate md5sums, run ``makepkg -g >> PKGBUILD''.
If desired, move the md5sums line to an appropriate location. If desired, move the md5sums line to an appropriate location.
*sha1sums, sha224sums, sha256sums, sha384sums, sha512sums, b2sums (arrays)*:: *sha1sums, sha256sums, sha384sums, sha512sums (arrays)*::
Alternative integrity checks that makepkg supports; these all behave Alternative integrity checks that makepkg supports; these all behave
similar to the md5sums option described above. To enable use and generation similar to the md5sums option described above. To enable use and generation
of these checksums, be sure to set up the `INTEGRITY_CHECK` option in of these checksums, be sure to set up the `INTEGRITY_CHECK` option in
@@ -168,8 +168,7 @@ contain whitespace characters.
*arch (array)*:: *arch (array)*::
Defines on which architectures the given package is available (e.g., Defines on which architectures the given package is available (e.g.,
`arch=('i686' 'x86_64')`). Packages that contain no architecture specific `arch=('i686' 'x86_64')`). Packages that contain no architecture specific
files should use `arch=('any')`. Valid characters for members of this array files should use `arch=('any')`.
are alphanumerics and ```_`''.
*backup (array)*:: *backup (array)*::
An array of file names, without preceding slashes, that An array of file names, without preceding slashes, that
@@ -214,9 +213,8 @@ underscore and the architecture name e.g., 'checkdepends_x86_64=()'.
An array of packages (and accompanying reasons) that are not essential for An array of packages (and accompanying reasons) that are not essential for
base functionality, but may be necessary to make full use of the contents base functionality, but may be necessary to make full use of the contents
of this package. optdepends are currently for informational purposes only of this package. optdepends are currently for informational purposes only
and are not utilized by pacman during dependency resolution. Packages in and are not utilized by pacman during dependency resolution. The format
this list follow the same format as depends, with an optional description for specifying optdepends is:
appended. The format for specifying optdepends descriptions is:
optdepends=('python: for library bindings') optdepends=('python: for library bindings')
+ +
@@ -295,6 +293,12 @@ underscore and the architecture name e.g., 'replaces_x86_64=()'.
*zipman*;; *zipman*;;
Compress man and info pages with gzip. Compress man and info pages with gzip.
*upx*;;
Compress binary executable files using UPX.
*optipng*;;
Optimize PNG images with optipng.
*ccache*;; *ccache*;;
Allow the use of ccache during build. More useful in its negative Allow the use of ccache during build. More useful in its negative
form `!ccache` with select packages that have problems building form `!ccache` with select packages that have problems building
@@ -466,12 +470,12 @@ Using VCS Sources[[VCS]]
------------------------ ------------------------
Building a developmental version of a package using sources from a version Building a developmental version of a package using sources from a version
control system (VCS) is enabled by specifying the source in the form control system (VCS) is enabled by specifying the source in the form
`source=('directory::url#fragment?query')`. Currently makepkg supports the `source=('directory::url#fragment')`. Currently makepkg supports the Bazaar, Git,
Bazaar, Git, Subversion, and Mercurial version control systems. For other Subversion, and Mercurial version control systems. For other version control
version control systems, manual cloning of upstream repositories must be done systems, manual cloning of upstream repositories must be done in the `prepare()`
in the `prepare()` function. function.
The source URL is divided into four components: The source URL is divided into three components:
*directory*:: *directory*::
(optional) Specifies an alternate directory name for makepkg to download (optional) Specifies an alternate directory name for makepkg to download
@@ -503,11 +507,6 @@ The source URL is divided into four components:
*svn*;; *svn*;;
revision revision
*query*::
(optional) Allows specifying whether a VCS checkout should be checked for
PGP-signed revisions. The source line should have the format
`source=(url#fragment?signed)` or `source=(url?signed#fragment)`. Currently
only supported by Git.
Example Example
------- -------
@@ -525,4 +524,4 @@ See Also
-------- --------
linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5] linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
alpm-hooks(5) alpm-hooks(5)
============= =============
@@ -30,13 +33,9 @@ DESCRIPTION
libalpm provides the ability to specify hooks to run before or after libalpm provides the ability to specify hooks to run before or after
transactions based on the packages and/or files being modified. Hooks consist transactions based on the packages and/or files being modified. Hooks consist
of a single '[Action]' section describing the action to be run and one or more of a single '[Action]' section describing the action to be run and one or more
'[Trigger]' section describing which transactions it should be run for. '[Trigger]' section describing which transactions it should be run for. Hook
Hooks are read from files located in the system hook directory
+{datarootdir}/libalpm/hooks+, and additional custom directories specified in
linkman:pacman.conf[5] (the default is +{sysconfdir}/pacman.d/hooks+). The
file names are required to have the suffix ".hook". Hooks are run in file names are required to have the suffix ".hook". Hooks are run in
alphabetical order of their file name, where the ordering ignores the suffix. alphabetical order of their file name.
TRIGGERS TRIGGERS
-------- --------
@@ -129,4 +128,4 @@ or not they were actually present on the file system before package removal.
PostTransaction hooks will *not* run if the transaction fails to complete for PostTransaction hooks will *not* run if the transaction fails to complete for
any reason. any reason.
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
See the pacman website at https://www.archlinux.org/pacman/[] for current See the pacman website at https://www.archlinux.org/pacman/[] for current
information on pacman and its related tools. information on pacman and its related tools.

View File

@@ -43,11 +43,9 @@ There are several man pages available for the programs, utilities, and
configuration files dealing with pacman. configuration files dealing with pacman.
* linkman:alpm-hooks[5] * linkman:alpm-hooks[5]
* linkman:BUILDINFO[5]
* linkman:PKGBUILD[5] * linkman:PKGBUILD[5]
* linkman:libalpm[3] * linkman:libalpm[3]
* linkman:makepkg[8] * linkman:makepkg[8]
* linkman:makepkg-template[1]
* linkman:makepkg.conf[5] * linkman:makepkg.conf[5]
* linkman:pacman[8] * linkman:pacman[8]
* linkman:pacman-key[8] * linkman:pacman-key[8]
@@ -59,11 +57,11 @@ configuration files dealing with pacman.
Changelog Changelog
~~~~~~~~~ ~~~~~~~~~
For a good idea of what is going on in pacman development, take a look at the For a good idea of what is going on in pacman development, take a look at the
link:https://git.archlinux.org/pacman.git/[Git summary page] for the link:https://projects.archlinux.org/pacman.git/[Git summary page] for the
project. project.
See the most recent See the most recent
link:https://git.archlinux.org/pacman.git/tree/NEWS[NEWS] link:https://projects.archlinux.org/pacman.git/tree/NEWS[NEWS]
file for a not-as-frequently-updated list of changes. However, this should file for a not-as-frequently-updated list of changes. However, this should
contain the biggest changes in a format more concise than the commit log. contain the biggest changes in a format more concise than the commit log.
@@ -77,10 +75,7 @@ Releases
[frame="topbot",grid="none",options="header,autowidth"] [frame="topbot",grid="none",options="header,autowidth"]
!====== !======
!Version !Date !Version !Date
!5.1.2 !2018-12-25 !5.0.2 !2016-06-03
!5.1.1 !2018-07-27
!5.1.0 !2018-05-28
!5.0.2 !2017-06-03
!5.0.1 !2016-02-23 !5.0.1 !2016-02-23
!5.0.0 !2016-01-30 !5.0.0 !2016-01-30
!4.2.1 !2015-02-20 !4.2.1 !2015-02-20
@@ -203,8 +198,8 @@ Development
Mailing List Mailing List
~~~~~~~~~~~~ ~~~~~~~~~~~~
There is a mailing list devoted to pacman development, hosted by Arch Linux. There is a mailing list devoted to pacman development, hosted by Arch Linux.
link:https://lists.archlinux.org/listinfo/pacman-dev/[Subscribe] or link:https://mailman.archlinux.org/mailman/listinfo/pacman-dev/[Subscribe] or
link:https://lists.archlinux.org/pipermail/pacman-dev/[view the archives]. link:https://mailman.archlinux.org/pipermail/pacman-dev/[view the archives].
Source Code Source Code
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -215,11 +210,11 @@ these trees).
The current development tree can be fetched with the following command: The current development tree can be fetched with the following command:
git clone git://git.archlinux.org/pacman.git pacman git clone git://projects.archlinux.org/pacman.git pacman
which will fetch the full development history into a directory named pacman. which will fetch the full development history into a directory named pacman.
You can browse the source as well using You can browse the source as well using
link:https://git.archlinux.org/pacman.git/[cgit]. HTTP/HTTPS URLs are also link:https://projects.archlinux.org/pacman.git/[cgit]. HTTP/HTTPS URLs are also
available for cloning purposes; these URLs are listed at the above page. available for cloning purposes; these URLs are listed at the above page.
If you are interested in hacking on pacman, it is highly recommended you join If you are interested in hacking on pacman, it is highly recommended you join
@@ -238,13 +233,15 @@ Although the package manager itself is quite simple, many scripts have been
developed that help automate building and installing packages. These are used developed that help automate building and installing packages. These are used
extensively in link:https://www.archlinux.org/[Arch Linux]. Most of these utilities extensively in link:https://www.archlinux.org/[Arch Linux]. Most of these utilities
are available in the Arch Linux projects are available in the Arch Linux projects
link:https://git.archlinux.org/[code browser]. link:https://projects.archlinux.org/[code browser].
Utilities available: Utilities available:
* link:https://git.archlinux.org/dbscripts.git/[dbscripts] - scripts used by Arch Linux to manage the main package repositories * link:https://projects.archlinux.org/abs.git/[abs] - ABS (Arch Build System), scripts to download & use the Arch Linux PKGBUILD tree
* link:https://git.archlinux.org/devtools.git/[devtools] - tools to assist in packaging and dependency checking * link:https://projects.archlinux.org/dbscripts.git/[dbscripts] - scripts used by Arch Linux to manage the main package repositories
* link:https://git.archlinux.org/namcap.git/[namcap] - a package analysis utility written in python * link:https://projects.archlinux.org/devtools.git/[devtools] - tools to assist in packaging and dependency checking
* link:https://projects.archlinux.org/namcap.git/[namcap] - a package analysis utility written in python
* link:https://projects.archlinux.org/srcpac.git/[srcpac] - a bash build-from-source pacman wrapper
Bugs Bugs
---- ----
@@ -259,7 +256,11 @@ bugs under the Pacman project.
Copyright Copyright
--------- ---------
pacman is Copyright (C) 2006-2018 Pacman Development Team pacman is Copyright (C) 2006-2016 Pacman Development Team
<pacman-dev@archlinux.org> and Copyright (C) 2002-2006 Judd Vinet <pacman-dev@archlinux.org> and Copyright (C) 2002-2006 Judd Vinet
<jvinet@zeroflux.org> and is licensed through the GNU General Public License, <jvinet@zeroflux.org> and is licensed through the GNU General Public License,
version 2 or later. version 2 or later.
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
libalpm(3) libalpm(3)
========== ==========
@@ -34,4 +37,4 @@ See Also
linkman:alpm-hooks[5], linkman:makepkg[8], linkman:pacman[8], linkman:alpm-hooks[5], linkman:makepkg[8], linkman:pacman[8],
linkman:pacman.conf[5] linkman:pacman.conf[5]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
makepkg-template(1) makepkg-template(1)
=================== ===================
@@ -115,4 +118,4 @@ See Also
-------- --------
linkman:makepkg[8], linkman:PKGBUILD[5] linkman:makepkg[8], linkman:PKGBUILD[5]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
makepkg(8) makepkg(8)
========== ==========
@@ -197,13 +200,12 @@ Options
useful if you are redirecting makepkg output to file. useful if you are redirecting makepkg output to file.
*\--packagelist*:: *\--packagelist*::
List the package filenames that would be produced without building. Listed List the packages that would be produced without building. Listed
package filenames include PKGDEST and PKGEXT. package names do not include PKGEXT.
*\--printsrcinfo*:: *\--printsrcinfo*::
Generate and print the SRCINFO file to stdout. Generate and print the SRCINFO file to stdout.
Additional Features Additional Features
------------------- -------------------
makepkg supports building development versions of packages without having to makepkg supports building development versions of packages without having to
@@ -212,19 +214,6 @@ separate utility 'versionpkg'. See linkman:PKGBUILD[5] for details on how to
set up a development PKGBUILD. set up a development PKGBUILD.
Reproducibility
---------------
makepkg is designed to be compatible with
link:https://reproducible-builds.org/docs/[Reproducible Builds]. If the
**SOURCE_DATE_EPOCH** environment variable is set, it will be exported to
subprocesses, and source and package file modification times and package
metadata will be unified based on the timestamp specified.
If the **SOURCE_DATE_EPOCH** environment variable is not set, makepkg will use
its own start date for internal use, but will not unify source file timestamps
before building.
Environment Variables Environment Variables
--------------------- ---------------------
**PACMAN**:: **PACMAN**::
@@ -276,8 +265,6 @@ Environment Variables
Specify a key to use when signing packages, overriding the GPGKEY setting Specify a key to use when signing packages, overriding the GPGKEY setting
in linkman:makepkg.conf[5] in linkman:makepkg.conf[5]
**SOURCE_DATE_EPOCH=**"<date>"::
Used for link:https://reproducible-builds.org/docs/[Reproducible Builds].
Configuration Configuration
------------- -------------
@@ -285,65 +272,8 @@ See linkman:makepkg.conf[5] for more details on configuring makepkg using the
'makepkg.conf' file. 'makepkg.conf' file.
Errors
------
On exit, makepkg will return one of the following error codes.
0::
Normal exit condition.
1::
Unknown cause of failure.
2::
Error in configuration file.
3::
User specified an invalid option
4::
Error in user-supplied function in PKGBUILD.
5::
Failed to create a viable package.
6::
A source or auxiliary file specified in the PKGBUILD is
missing.
7::
The PKGDIR is missing.
8::
Failed to install dependencies.
9::
Failed to remove dependencies.
10::
User attempted to run makepkg as root.
11::
User lacks permissions to build or install to a given
location.
12::
Error parsing PKGBUILD.
13::
A package has already been built.
14::
The package failed to install.
15::
Programs necessary to run makepkg are missing.
16::
Specified GPG key does not exist.
See Also See Also
-------- --------
linkman:makepkg.conf[5], linkman:PKGBUILD[5], linkman:pacman[8] linkman:makepkg.conf[5], linkman:PKGBUILD[5], linkman:pacman[8]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
makepkg.conf(5) makepkg.conf(5)
=============== ===============
@@ -89,7 +92,7 @@ Options
**DEBUG_CXXFLAGS=**"debug_cxxflags":: **DEBUG_CXXFLAGS=**"debug_cxxflags"::
Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info. Debug flags used for the C++ compiler; see DEBUG_CFLAGS for more info.
**BUILDENV=(**!distcc !color !ccache check !sign**)**:: **BUILDENV=(**!distcc color !ccache check !sign**)**::
This array contains options that affect the build environment; the defaults This array contains options that affect the build environment; the defaults
are shown here. All options should always be left in the array; to enable are shown here. All options should always be left in the array; to enable
or disable an option, simply remove or add an ``!'' at the front of the or disable an option, simply remove or add an ``!'' at the front of the
@@ -138,7 +141,7 @@ Options
Specify a key to use for GPG signing instead of the default key in the Specify a key to use for GPG signing instead of the default key in the
keyring. Can be overridden with makepkg's '\--key' option. keyring. Can be overridden with makepkg's '\--key' option.
**OPTIONS=(**!strip docs libtool staticlibs emptydirs !zipman !purge !debug**)**:: **OPTIONS=(**strip docs libtool staticlibs emptydirs zipman purge !upx !optipng**)**::
This array contains options that affect default packaging. They are This array contains options that affect default packaging. They are
equivalent to options that can be placed in the PKGBUILD; the defaults are equivalent to options that can be placed in the PKGBUILD; the defaults are
shown here. All options should always be left in the array; to enable or shown here. All options should always be left in the array; to enable or
@@ -175,6 +178,14 @@ Options
Remove files specified by the `PURGE_TARGETS` variable from the Remove files specified by the `PURGE_TARGETS` variable from the
package. package.
*upx*;;
Compress binary executable files using UPX. Additional options
can be passed to UPX by specifying the `UPXFLAGS` array variable.
*optipng*;;
Optimize PNG images with optipng. Additional options can be passed
to optipng by specifying the `OPTIPNGFLAGS` array variable.
*debug*;; *debug*;;
Add the user-specified debug flags as specified in DEBUG_CFLAGS and Add the user-specified debug flags as specified in DEBUG_CFLAGS and
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
@@ -183,15 +194,15 @@ Options
**INTEGRITY_CHECK=(**check1 ...**)**:: **INTEGRITY_CHECK=(**check1 ...**)**::
File integrity checks to use. Multiple checks may be specified; this File integrity checks to use. Multiple checks may be specified; this
affects both generation and checking. The current valid options are: affects both generation and checking. The current valid options are:
`md5`, `sha1`, `sha224`, `sha256`, `sha384`, `sha512`, and `b2`. `md5`, `sha1`, `sha256`, `sha384`, and `sha512`.
**STRIP_BINARIES=**"--strip-all":: **STRIP_BINARIES=**"--strip-all"::
Options to be used when stripping binaries. See linkman:strip[1] Options to be used when stripping binaries. See linkman:strip[1]
for details. for details.
**STRIP_SHARED=**"--strip-unneeded":: **STRIP_SHARED=**"--strip-unneeded"::
Options to be used when stripping shared libraries or PIE executables. Options to be used when stripping shared libraries. See linkman:strip[1]
See linkman:strip[1] for details. for details.
**STRIP_STATIC=**"--strip-debug":: **STRIP_STATIC=**"--strip-debug"::
Options to be used when stripping static libraries. See linkman:strip[1] Options to be used when stripping static libraries. See linkman:strip[1]
@@ -215,12 +226,6 @@ Options
instruct makepkg which files to remove from the package. This is instruct makepkg which files to remove from the package. This is
useful for index files that are added by multiple packages. useful for index files that are added by multiple packages.
**DBGSRCDIR=**"/usr/src/debug"::
If `strip` and `debug` are specified in the `OPTIONS` array, this variable
will instruct makepkg where to place source files for installed binaries.
The binaries will be modified to link this directory for the debugger
search path.
**PKGDEST=**"/path/to/directory":: **PKGDEST=**"/path/to/directory"::
If this value is not set, packages will, by default, be placed in the If this value is not set, packages will, by default, be placed in the
current directory (location of the linkman:PKGBUILD[5]). Many people current directory (location of the linkman:PKGBUILD[5]). Many people
@@ -249,19 +254,16 @@ Options
**COMPRESSGZ=**"(gzip -c -f -n)":: **COMPRESSGZ=**"(gzip -c -f -n)"::
**COMPRESSBZ2=**"(bzip2 -c -f)":: **COMPRESSBZ2=**"(bzip2 -c -f)"::
**COMPRESSXZ=**"(xz -c -z -)":: **COMPRESSXZ=**"(xz -c -z -)"::
**COMPRESSZST=**"(zstd -c -z -)"::
**COMPRESSLZO**"(lzop -q)":: **COMPRESSLZO**"(lzop -q)"::
**COMPRESSLRZ=**"(lrzip -q)":: **COMPRESSLRZ=**"(lrzip -q)"::
**COMPRESSLZ4=**"(lz4 -q)"::
**COMPRESSZ=**"(compress -c -f)":: **COMPRESSZ=**"(compress -c -f)"::
**COMPRESSLZ=**"(lzip -c -f)"::
Sets the command and options used when compressing compiled or source Sets the command and options used when compressing compiled or source
packages in the named format. packages in the named format.
**PKGEXT=**".pkg.tar.gz", **SRCEXT=**".src.tar.gz":: **PKGEXT=**".pkg.tar.gz", **SRCEXT=**".src.tar.gz"::
Sets the compression used when making compiled or source packages. Sets the compression used when making compiled or source packages.
Valid suffixes are `.tar`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, `.tar.zst`, Valid suffixes are `.tar`, `.tar.gz`, `.tar.bz2`, `.tar.xz`,
`.tar.lzo`, `.tar.lrz`, `.tar.lz4`, `.tar.lz` and `.tar.Z`. `.tar.lzo`, `.tar.lrz`, and `.tar.Z`.
Do not touch these unless you know what you are doing. Do not touch these unless you know what you are doing.
@@ -269,4 +271,4 @@ See Also
-------- --------
linkman:makepkg[8], linkman:pacman[8], linkman:PKGBUILD[5] linkman:makepkg[8], linkman:pacman[8], linkman:PKGBUILD[5]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,149 +0,0 @@
manpages = [
{ 'name': 'alpm-hooks.5' },
{ 'name': 'pacman.8' },
{ 'name': 'makepkg.8' },
{ 'name': 'makepkg-template.1' },
{ 'name': 'repo-add.8' },
{ 'name': 'vercmp.8' },
{ 'name': 'pkgdelta.8' },
{ 'name': 'pacman-key.8' },
{ 'name': 'PKGBUILD.5', 'extra_depends' : [ 'PKGBUILD-example.txt' ] },
{ 'name': 'makepkg.conf.5' },
{ 'name': 'pacman.conf.5' },
{ 'name': 'libalpm.3' },
{ 'name': 'BUILDINFO.5' },
{ 'name': 'pacman-conf.8' },
]
sitepages = [
{ 'name': 'submitting-patches' },
{ 'name': 'translation-help' },
{ 'name': 'HACKING', 'source': '../HACKING' },
{ 'name': 'index' },
]
asciidoc_conf = join_paths(meson.current_source_dir(), 'asciidoc.conf')
asciidoc_opts = [
'-f', asciidoc_conf,
'-a', 'pacman_version="@0@"'.format(PACKAGE_VERSION),
'-a', 'pacman_date=@0@'.format(run_command('date', '+%Y-%m-%d').stdout().strip()),
'-a', 'pkgdatadir=@0@'.format(PKGDATADIR),
'-a', 'localstatedir=@0@'.format(LOCALSTATEDIR),
'-a', 'sysconfdir=@0@'.format(SYSCONFDIR),
'-a', 'datarootdir=@0@'.format(DATAROOTDIR),
'-a', 'rootdir=@0@'.format(ROOTDIR),
]
html_targets = []
html_files = []
foreach page : manpages
manpage = page['name']
htmlpage = '@0@.html'.format(manpage)
input = '@0@.asciidoc'.format(manpage)
section = page['name'].split('.')[-1]
mandirn = join_paths(MANDIR, 'man' + section)
custom_target(
manpage,
command : [
A2X,
'--no-xmllint',
'-d', 'manpage',
'-f', 'manpage',
'--xsltproc-opts', '-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0',
'-D', '@OUTDIR@',
'--asciidoc-opts', ' '.join(asciidoc_opts),
'@INPUT@',
],
input : input,
output : [manpage],
depend_files : [
asciidoc_conf,
] + page.get('extra_depends', []),
install : true,
install_dir : mandirn,
)
endforeach
foreach page: manpages + sitepages
manpage = page['name']
htmlpage = '@0@.html'.format(manpage)
input = page.get('source', '@0@.asciidoc'.format(manpage))
html = custom_target(
htmlpage,
command : [
ASCIIDOC,
] + asciidoc_opts + [
'-a', 'linkcss',
'-a', 'toc',
'-a', 'icons',
'-a', 'max-width=960px',
'-a', 'stylesheet=asciidoc-override.css',
'-o', '@OUTPUT@',
'@INPUT@',
],
input : input,
output : [htmlpage],
depend_files : [
asciidoc_conf,
'asciidoc-override.css',
] + page.get('extra_depends', []),
build_by_default : false,
install : false,
)
html_targets += [html]
html_files += [htmlpage]
endforeach
run_target('html',
command : ['/bin/true'],
depends : html_targets)
custom_target(
'website.tar.gz',
command : [
'bsdtar', 'czf', '@OUTPUT@',
'-C', meson.current_build_dir(),
] + html_files + [
'-C', meson.current_source_dir(),
'asciidoc-override.css',
'-C', '/etc/asciidoc/stylesheets/',
'asciidoc.css',
'-C', '/etc/asciidoc/javascripts/',
'asciidoc.js',
'-C', '/etc/asciidoc/',
'images',
],
output : ['website.tar.gz'],
build_by_default : false,
depends : html_targets,
)
meson.add_install_script(MESON_MAKE_SYMLINK,
'repo-add.8',
join_paths(MANDIR, 'man8/repo-remove.8'))
doxygen = find_program('doxygen', required : get_option('doxygen'))
if doxygen.found() and not get_option('doxygen').disabled()
doxyconf = configuration_data()
doxyconf.set('OUTPUT_DIRECTORY', meson.current_build_dir())
doxyfile = configure_file(
input : 'Doxyfile.in',
output : 'Doxyfile',
configuration : doxyconf,
install : false)
custom_target(
'doxygen',
input : doxyfile,
output : ['man3'],
command : [doxygen, doxyfile],
build_by_default : true,
install : true,
install_dir : MANDIR)
endif

View File

@@ -1,67 +0,0 @@
pacman-conf(8)
==============
Name
----
pacman-conf - query pacman's configuration file
Synopsis
--------
'pacman-conf' [options] [<directive> ...]
'pacman-conf' (--repo-list|--help|--version)
Description
-----------
'pacman-conf' is a utility for parsing the 'pacman' configuration file
and returning script-friendly output. It is designed to properly handle
non-trivial configuration features such as variable interpolation and
the use of the Include directive, and guarantees that it will return the
same configuration values which 'pacman' itself would use.
'pacman-conf' will output the fully-resolved contents of the
configuration file by default, or, if provided with the name of a
configuration directive, output the contents of the given directive alone.
Options
-------
*-c, \--config* <path>::
Specify an alternate configuration file.
*-R, \--rootdir* <path>::
Specify an alternate installation root (default is `/`).
*-r, \--repo* <remote>::
Query options for a specific repository.
*-v, \--verbose*::
Always shown directive names.
*-l, \--repo-list*::
List configured repositories.
*-h, \--help*::
Output syntax and command line options.
*-V, \--version*::
Display version and exit.
Examples
--------
pacman-conf -r core Usage::
Show the value of the Usage configuration option for core repository.
pacman-conf HoldPkg::
Show the value of the HoldPkg configuration option.
See Also
--------
linkman:pacman.conf[5]
include::footer.asciidoc[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pacman-key(8) pacman-key(8)
============= =============
@@ -97,13 +100,7 @@ Operations
Displays the program version. Displays the program version.
*-v, \--verify*:: *-v, \--verify*::
Assume that the first argument is a signature and verify it. If a second Verify the file(s) specified by the signature(s).
argument is provided, it is the file to be verified.
+
With only one argument given, assume that the signature is a detached
signature, and look for a matching data file to verify by stripping the file
extension. If no matching data file is found, fall back on GnuPG semantics and
attempt to verify a file with an embedded signature.
Options Options
@@ -148,4 +145,4 @@ See Also
-------- --------
linkman:pacman[8], linkman:pacman.conf[5] linkman:pacman[8], linkman:pacman.conf[5]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pacman(8) pacman(8)
========= =========
@@ -124,21 +127,20 @@ greater than `1:3.6-1`.
Options Options
------- -------
*-b, \--dbpath* <path>:: *-b, \--dbpath* <path>::
Specify an alternative database location (the default is Specify an alternative database location (a typical default is
+{localstatedir}/lib/pacman+). This should not be used unless you know what +{localstatedir}/lib/pacman+). This should not be used unless you know what
you are doing. you are doing.
*NOTE*: If specified, this is an absolute path, and the root path is *NOTE*: If specified, this is an absolute path, and the root path is
not automatically prepended. not automatically prepended.
*-r, \--root* <path>:: *-r, \--root* <path>::
Specify an alternative installation root (default is +{rootdir}+). This should Specify an alternative installation root (default is `/`). This should
not be used as a way to install software into `/usr/local` instead of not be used as a way to install software into `/usr/local` instead of
`/usr`. `/usr`. This option is used if you want to install a package on a
temporarily mounted partition that is "owned" by another system.
*NOTE*: If database path or log file are not specified on either the *NOTE*: If database path or log file are not specified on either the
command line or in linkman:pacman.conf[5], their default location will command line or in linkman:pacman.conf[5], their default location will
be inside this root path. be inside this root path.
*NOTE*: This option is not suitable for performing operations on a mounted
guest system. See '\--sysroot' instead.
*-v, \--verbose*:: *-v, \--verbose*::
Output paths such as as the Root, Conf File, DB Path, Cache Dirs, etc. Output paths such as as the Root, Conf File, DB Path, Cache Dirs, etc.
@@ -147,7 +149,7 @@ Options
Specify an alternate architecture. Specify an alternate architecture.
*\--cachedir* <dir>:: *\--cachedir* <dir>::
Specify an alternative package cache location (the default is Specify an alternative package cache location (a typical default is
+{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be +{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be
specified, and they are tried in the order they are passed to pacman. specified, and they are tried in the order they are passed to pacman.
*NOTE*: This is an absolute path, and the root path is not automatically *NOTE*: This is an absolute path, and the root path is not automatically
@@ -166,15 +168,15 @@ Options
to be used. to be used.
*\--gpgdir* <dir>:: *\--gpgdir* <dir>::
Specify a directory of files used by GnuPG to verify package signatures Specify a directory of files used by GnuPG to verify package signatures (a
(the default is +{sysconfdir}/pacman.d/gnupg+). This directory should contain typical default is +{sysconfdir}/pacman.d/gnupg+). This directory should contain
two files: `pubring.gpg` and `trustdb.gpg`. `pubring.gpg` holds the public keys two files: `pubring.gpg` and `trustdb.gpg`. `pubring.gpg` holds the public keys
of all packagers. `trustdb.gpg` contains a so-called trust database, which of all packagers. `trustdb.gpg` contains a so-called trust database, which
specifies that the keys are authentic and trusted. *NOTE*: This is an absolute specifies that the keys are authentic and trusted. *NOTE*: This is an absolute
path, and the root path is not automatically prepended. path, and the root path is not automatically prepended.
*\--hookdir* <dir>:: *\--hookdir* <dir>::
Specify a alternative directory containing hook files (the default is Specify a alternative directory containing hook files (a typical default is
+{sysconfdir}/pacman.d/hooks+). Multiple hook directories can be specified +{sysconfdir}/pacman.d/hooks+). Multiple hook directories can be specified
with hooks in later directories taking precedence over hooks in earlier with hooks in later directories taking precedence over hooks in earlier
directories. *NOTE*: This is an absolute path, and the root path is not directories. *NOTE*: This is an absolute path, and the root path is not
@@ -191,16 +193,6 @@ Options
*\--confirm*:: *\--confirm*::
Cancels the effects of a previous '\--noconfirm'. Cancels the effects of a previous '\--noconfirm'.
*\--disable-download-timeout*::
Disable defaults for low speed limit and timeout on downloads. Use this
if you have issues downloading files with proxy and/or security gateway.
*\--sysroot* <dir>::
Specify an alternative system root. Pacman will chroot and chdir into the
system root prior to running. This allows mounted guest systems to be
properly operated on. Any other paths given will be interpreted as relative
to the system root. Requires root privileges.
Transaction Options (apply to '-S', '-R' and '-U') Transaction Options (apply to '-S', '-R' and '-U')
-------------------------------------------------- --------------------------------------------------
@@ -240,7 +232,15 @@ Transaction Options (apply to '-S', '-R' and '-U')
Upgrade Options (apply to '-S' and '-U')[[UO]] Upgrade Options (apply to '-S' and '-U')[[UO]]
---------------------------------------------- --------------------------------------------
*\--force*::
Bypass file conflict checks and overwrite conflicting files. If the
package that is about to be installed contains files that are already
installed, this option will cause all those files to be overwritten.
Using '\--force' will not allow overwriting a directory with a file or
installing packages with conflicting files and directories.
This option should be used with care, ideally not at all.
*\--asdeps*:: *\--asdeps*::
Install packages non-explicitly; in other words, fake their install reason Install packages non-explicitly; in other words, fake their install reason
to be installed as a dependency. This is useful for makepkg and other to be installed as a dependency. This is useful for makepkg and other
@@ -266,21 +266,9 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
*\--needed*:: *\--needed*::
Do not reinstall the targets that are already up-to-date. Do not reinstall the targets that are already up-to-date.
*\--overwrite* <glob>::
Bypass file conflict checks and overwrite conflicting files. If the
package that is about to be installed contains files that are already
installed and match 'glob', this option will cause all those files to be
overwritten. Using '\--overwrite' will not allow overwriting a directory
with a file or installing packages with conflicting files and directories.
Multiple patterns can be specified by separating them with a comma. May be
specified multiple times. Patterns can be negated, such that files
matching them will not be overwritten, by prefixing them with an
exclamation mark. Subsequent matches will override previous ones. A leading
literal exclamation mark or backslash needs to be escaped.
Query Options[[QO]]
Query Options (apply to '-Q')[[QO]] -------------------
-----------------------------------
*-c, \--changelog*:: *-c, \--changelog*::
View the ChangeLog of a package if it exists. View the ChangeLog of a package if it exists.
@@ -305,7 +293,7 @@ Query Options (apply to '-Q')[[QO]]
'\--info' or '-i' flags will also display the list of backup files and '\--info' or '-i' flags will also display the list of backup files and
their modification states. their modification states.
*-k, \--check*:: *-k \--check*::
Check that all files owned by the given package(s) are present on the Check that all files owned by the given package(s) are present on the
system. If packages are not specified or filter flags are not provided, system. If packages are not specified or filter flags are not provided,
check all installed packages. Specifying this option twice will perform check all installed packages. Specifying this option twice will perform
@@ -350,10 +338,10 @@ Query Options (apply to '-Q')[[QO]]
with descriptions matching ALL of those terms are returned. with descriptions matching ALL of those terms are returned.
*-t, \--unrequired*:: *-t, \--unrequired*::
Restrict or filter output to print only packages neither required nor Restrict or filter output to packages not required or optionally required by
optionally required by any currently installed package. Specify this any currently installed package. Specify this option twice to only filter
option twice to include packages which are optionally, but not directly, packages that are direct dependencies (i.e. do not filter optional
required by another package. dependencies).
*-u, \--upgrades*:: *-u, \--upgrades*::
Restrict or filter output to packages that are out-of-date on the local Restrict or filter output to packages that are out-of-date on the local
@@ -362,8 +350,8 @@ Query Options (apply to '-Q')[[QO]]
database is refreshed using '-Sy'. database is refreshed using '-Sy'.
Remove Options (apply to '-R')[[RO]] Remove Options[[RO]]
------------------------------------ --------------------
*-c, \--cascade*:: *-c, \--cascade*::
Remove all target packages, as well as all packages that depend on one Remove all target packages, as well as all packages that depend on one
or more target packages. This operation is recursive and must be used or more target packages. This operation is recursive and must be used
@@ -387,8 +375,8 @@ Remove Options (apply to '-R')[[RO]]
to avoid breaking any dependencies. to avoid breaking any dependencies.
Sync Options (apply to '-S')[[SO]] Sync Options[[SO]]
---------------------------------- ------------------
*-c, \--clean*:: *-c, \--clean*::
Remove packages that are no longer installed from the cache as well as Remove packages that are no longer installed from the cache as well as
currently unused sync databases to free up disk space. When pacman currently unused sync databases to free up disk space. When pacman
@@ -456,8 +444,8 @@ system upgrade and install/upgrade the "foo" package in the same operation.
up-to-date. up-to-date.
Database Options (apply to '-D')[[QO]] Database Options[[QO]]
-------------------------------------- ----------------------
*\--asdeps* <package>:: *\--asdeps* <package>::
Mark a package as non-explicitly installed; in other words, set their install Mark a package as non-explicitly installed; in other words, set their install
reason to be installed as a dependency. reason to be installed as a dependency.
@@ -468,7 +456,7 @@ Database Options (apply to '-D')[[QO]]
package installed even when it was initially installed as a dependency package installed even when it was initially installed as a dependency
of another package. of another package.
*-k, \--check*:: *-k \--check*::
Check the local package database is internally consistent. This will Check the local package database is internally consistent. This will
check all required files are present and that installed packages have check all required files are present and that installed packages have
the required dependencies, do not conflict and that multiple packages the required dependencies, do not conflict and that multiple packages
@@ -476,11 +464,9 @@ Database Options (apply to '-D')[[QO]]
a check on the sync databases to ensure all specified dependencies a check on the sync databases to ensure all specified dependencies
are available. are available.
*-q, \--quiet*:: File Options[[FO]]
Suppress messages on successful completion of database operations. ------------------
File Options (apply to '-F')[[FO]]
----------------------------------
*-y, --refresh*:: *-y, --refresh*::
Download fresh package databases from the server. Use twice to force a Download fresh package databases from the server. Use twice to force a
refresh even if databases are up to date. refresh even if databases are up to date.
@@ -514,7 +500,7 @@ designated to be backed up. During an upgrade, three MD5 hashes are used for
each backup file to determine the required action: one for the original file each backup file to determine the required action: one for the original file
installed, one for the new file that is about to be installed, and one for the installed, one for the new file that is about to be installed, and one for the
actual file existing on the file system. After comparing these three hashes, the actual file existing on the file system. After comparing these three hashes, the
following scenarios can result: follow scenarios can result:
original=X, current=X, new=X:: original=X, current=X, new=X::
All three files are the same, so overwrites are not an issue. Install the All three files are the same, so overwrites are not an issue. Install the
@@ -575,4 +561,4 @@ See Also
linkman:alpm-hooks[5], linkman:libalpm[3], linkman:makepkg[8], linkman:alpm-hooks[5], linkman:libalpm[3], linkman:makepkg[8],
linkman:pacman.conf[5] linkman:pacman.conf[5]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pacman.conf(5) pacman.conf(5)
============== ==============
@@ -19,9 +22,6 @@ Each section defines a package repository that pacman can use when searching
for packages in '\--sync' mode. The exception to this is the options section, for packages in '\--sync' mode. The exception to this is the options section,
which defines global options. which defines global options.
Comments are only supported by beginning a line with the hash (#) symbol.
Comments cannot begin in the middle of a line.
Example Example
------- -------
@@ -48,7 +48,7 @@ work.
Options Options
------- -------
*RootDir =* /path/to/root/dir:: *RootDir =* path/to/root::
Set the default root directory for pacman to install to. This option is Set the default root directory for pacman to install to. This option is
used if you want to install a package on a temporary mounted partition used if you want to install a package on a temporary mounted partition
which is "owned" by another system, or for a chroot install. which is "owned" by another system, or for a chroot install.
@@ -56,32 +56,32 @@ Options
command line or in linkman:pacman.conf[5], their default location will command line or in linkman:pacman.conf[5], their default location will
be inside this root path. be inside this root path.
*DBPath =* /path/to/db/dir:: *DBPath =* path/to/db/dir::
Overrides the default location of the toplevel database directory. The Overrides the default location of the toplevel database directory. A
default is +{localstatedir}/lib/pacman/+. Most users will not need to set typical default is +{localstatedir}/lib/pacman/+. Most users will not need to set
this option. *NOTE*: if specified, this is an absolute path and the root this option. *NOTE*: if specified, this is an absolute path and the root
path is not automatically prepended. path is not automatically prepended.
*CacheDir =* /path/to/cache/dir:: *CacheDir =* path/to/cache/dir::
Overrides the default location of the package cache directory. The Overrides the default location of the package cache directory. A typical
default is +{localstatedir}/cache/pacman/pkg/+. Multiple cache directories can be default is +{localstatedir}/cache/pacman/pkg/+. Multiple cache directories can be
specified, and they are tried in the order they are listed in the config specified, and they are tried in the order they are listed in the config
file. If a file is not found in any cache directory, it will be downloaded file. If a file is not found in any cache directory, it will be downloaded
to the first cache directory with write access. *NOTE*: this is an absolute to the first cache directory with write access. *NOTE*: this is an absolute
path, the root path is not automatically prepended. path, the root path is not automatically prepended.
*HookDir =* /path/to/hook/dir:: *HookDir =* path/to/hook/dir::
Add directories to search for alpm hooks in addition to the system hook Add directories to search for alpm hooks in addition to the system hook
directory (+{datarootdir}/libalpm/hooks/+). The default is directory (+{datarootdir}/libalpm/hooks/+). A typical default is
+{sysconfdir}/pacman.d/hooks+. Multiple directories can be specified with +{sysconfdir}/pacman.d/hooks+. Multiple directories can be specified with
hooks in later directories taking precedence over hooks in earlier hooks in later directories taking precedence over hooks in earlier
directories. *NOTE*: this is an absolute path, the root path is not directories. *NOTE*: this is an absolute path, the root path is not
automatically prepended. For more information on the alpm hooks, see automatically prepended. For more information on the alpm hooks, see
linkman:alpm-hooks[5]. linkman:alpm-hooks[5].
*GPGDir =* /path/to/gpg/dir:: *GPGDir =* path/to/gpg/dir::
Overrides the default location of the directory containing configuration Overrides the default location of the directory containing configuration
files for GnuPG. The default is +{sysconfdir}/pacman.d/gnupg/+. files for GnuPG. A typical default is +{sysconfdir}/pacman.d/gnupg/+.
This directory should contain two files: `pubring.gpg` and `trustdb.gpg`. This directory should contain two files: `pubring.gpg` and `trustdb.gpg`.
`pubring.gpg` holds the public keys of all packagers. `trustdb.gpg` `pubring.gpg` holds the public keys of all packagers. `trustdb.gpg`
contains a so-called trust database, which specifies that the keys are contains a so-called trust database, which specifies that the keys are
@@ -89,8 +89,8 @@ Options
*NOTE*: this is an absolute path, the root path is not automatically *NOTE*: this is an absolute path, the root path is not automatically
prepended. prepended.
*LogFile =* /path/to/log/file:: *LogFile =* /path/to/file::
Overrides the default location of the pacman log file. The default Overrides the default location of the pacman log file. A typical default
is +{localstatedir}/log/pacman.log+. This is an absolute path and the root directory is +{localstatedir}/log/pacman.log+. This is an absolute path and the root directory
is not prepended. is not prepended.
@@ -108,7 +108,7 @@ Options
group when performing a '\--sysupgrade'. Shell-style glob patterns are group when performing a '\--sysupgrade'. Shell-style glob patterns are
allowed. allowed.
*Include =* /path/to/config/file:: *Include =* path::
Include another configuration file. This file can include repositories or Include another configuration file. This file can include repositories or
general configuration options. Wildcards in the specified paths will get general configuration options. Wildcards in the specified paths will get
expanded based on linkman:glob[7] rules. expanded based on linkman:glob[7] rules.
@@ -176,7 +176,7 @@ Options
operation on a local file. Uses the value from SigLevel as the default. operation on a local file. Uses the value from SigLevel as the default.
*RemoteFileSigLevel =* ...:: *RemoteFileSigLevel =* ...::
Set the signature verification level for installing packages using the "-U" Set the signature verification level for installing packages using the "-U"
operation on a remote file URL. Uses the value from SigLevel as the default. operation on a remote file URL. Uses the value from SigLevel as the default.
*UseSyslog*:: *UseSyslog*::
@@ -209,10 +209,6 @@ Options
Displays name, version and size of target packages formatted Displays name, version and size of target packages formatted
as a table for upgrade, sync and remove operations. as a table for upgrade, sync and remove operations.
*DisableDownloadTimeout*::
Disable defaults for low speed limit and timeout on downloads. Use this
if you have issues downloading files with proxy and/or security gateway.
Repository Sections Repository Sections
------------------- -------------------
@@ -371,4 +367,4 @@ See Also
-------- --------
linkman:pacman[8], linkman:libalpm[3] linkman:pacman[8], linkman:libalpm[3]
include::footer.asciidoc[] include::footer.txt[]

69
doc/pactree.8.txt Normal file
View File

@@ -0,0 +1,69 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pactree(8)
=========
Name
----
pactree - package dependency tree viewer
Synopsis
--------
'pactree' [options] package
Description
-----------
Pactree produces a dependency tree for a package.
By default, a tree-like output is generated, but with the '\--graph' option, a Graphviz
description is generated.
Options
-------
*-a, \--ascii*::
Use ASCII characters for tree formatting. By default, pactree will use Unicode
line drawing characters if it is able to detect that the locale supports them.
*-b, \--dbpath*::
Specify an alternative database location.
*-c, \--color*::
Colorize output.
*-d, \--depth <num>*::
Limits the number of levels of dependency to show. A zero means
show the named package only, one shows the packages that are directly
required.
*-g, \--graph*::
Generate a Graphviz description. If this option is given, the '\--color' and
'\--linear' options are ignored.
*-h, \--help*::
Output syntax and command-line options.
*-l, \--linear*::
Prints package names at the start of each line, one per line.
*-r, \--reverse*::
Show packages that depend on the named package.
*-s, \--sync*::
Read package data from sync databases instead of local database.
*-u, \--unique*::
List dependent packages once. Implies '\--linear'.
*\--config <file>*::
Specify an alternate pacman configuration file.
See Also
--------
linkman:pacman[8], linkman:pacman.conf[5], linkman:makepkg[8]
include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pkgdelta(8) pkgdelta(8)
========= =========
@@ -50,4 +53,4 @@ See Also
-------- --------
linkman:pacman[8], linkman:xdelta3[1] linkman:pacman[8], linkman:xdelta3[1]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
repo-add(8) repo-add(8)
========== ==========
@@ -91,4 +94,4 @@ See Also
-------- --------
linkman:makepkg[8], linkman:pacman[8], linkman:pkgdelta[8] linkman:makepkg[8], linkman:pacman[8], linkman:pkgdelta[8]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -20,7 +20,7 @@ started with GIT if you have not worked with it before.
The pacman code can be fetched using the following command: The pacman code can be fetched using the following command:
git clone git://git.archlinux.org/pacman.git git clone git://projects.archlinux.org/pacman.git
Creating your patch Creating your patch
@@ -39,7 +39,7 @@ address if you're afraid of spam.
* Describe your patch. * Describe your patch.
It helps if you describe the overview and goals of the patch in the git commit It helps if you describe the overview and goals of the patch in the git commit
log. This allows others to see what you intended so as to compare it to what log. This allows others to see what you intended so as to compare it to what
was actually done, and allows better feedback. was actually done, and allows better feedback.
@@ -99,3 +99,7 @@ aren't their own. When resubmitting patches, update the subject line to reflect
the version number ('[PATCHv2]'), and send it as a reply to the original thread. the version number ('[PATCHv2]'), and send it as a reply to the original thread.
-- --
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////

View File

@@ -4,10 +4,10 @@ Pacman - Translating
This document is here to guide you in helping translate pacman messages, This document is here to guide you in helping translate pacman messages,
libalpm messages, and the manual pages for the entire pacman package. libalpm messages, and the manual pages for the entire pacman package.
We are currently using https://www.transifex.com/[Transifex] as the translation We are currently using http://www.transifex.com/[Transifex] as the translation
platform for pacman and libalpm. You will need to sign up for an account there platform for pacman and libalpm. You will need to sign up for an account there
and then register with a translation team on the and then register with a translation team on the
https://www.transifex.com/projects/p/archlinux-pacman/[pacman project page]. http://www.transifex.com/projects/p/archlinux-pacman/[pacman project page].
NOTE: This may be old information due to our switch to Transifex, but the NOTE: This may be old information due to our switch to Transifex, but the
gettext website is a very useful guide to read before embarking on translation gettext website is a very useful guide to read before embarking on translation
@@ -31,7 +31,7 @@ either be hand-edited, or modified with a tool such as poedit, gtranslator or
kbabel. Using a translation tool tends to make the job easier. kbabel. Using a translation tool tends to make the job easier.
Please read up on Transifex usage using the Please read up on Transifex usage using the
https://docs.transifex.com/[Transifex Help] if you are not familiar. http://docs.transifex.com/[Transifex Help] if you are not familiar.
Transifex provides a command-line client to help with translations. Here is Transifex provides a command-line client to help with translations. Here is
an example set of commands if you have a source code checkout and are not an example set of commands if you have a source code checkout and are not
@@ -78,7 +78,7 @@ Incremental Updates
If you have more advanced needs you will have to get a copy of the pacman If you have more advanced needs you will have to get a copy of the pacman
repository. repository.
git clone git://git.archlinux.org/pacman.git pacman git clone git://projects.archlinux.org/pacman.git pacman
Next, you will need to run `./autogen.sh` and `./configure` in the base Next, you will need to run `./autogen.sh` and `./configure` in the base
directory to generate the correct Makefiles. At this point, all necessary directory to generate the correct Makefiles. At this point, all necessary
@@ -151,3 +151,7 @@ the pacman codebase. However, this is not to say translations are unwelcome. If
someone has experience with i18n man pages and how to best include them with our someone has experience with i18n man pages and how to best include them with our
source, please contact the pacman-dev mailing list at source, please contact the pacman-dev mailing list at
mailto:pacman-dev@archlinux.org[]. mailto:pacman-dev@archlinux.org[].
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////

View File

@@ -1,3 +1,6 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
vercmp(8) vercmp(8)
========= =========
@@ -8,7 +11,7 @@ vercmp - version comparison utility
Synopsis Synopsis
-------- --------
'vercmp' [-h] [--help] <version1> <version2> 'vercmp' <version1> <version2>
Description Description
@@ -41,9 +44,8 @@ mainly for supporting versioned dependencies that do not include the 'pkgrel'.
Options Options
------- -------
*-h, \--help*:: *-h, \--help*::
Display syntax for the given operation. If no operation was supplied,
Display summary of the available return codes. Must be the first option then the general syntax is shown.
specified.
Examples Examples
@@ -65,8 +67,13 @@ Examples
-1 -1
Configuration
-------------
There is none.
See Also See Also
-------- --------
linkman:pacman[8], linkman:makepkg[8], linkman:libalpm[3] linkman:pacman[8], linkman:makepkg[8], linkman:libalpm[3]
include::footer.asciidoc[] include::footer.txt[]

View File

@@ -25,3 +25,5 @@ SED_PROCESS = \
%.conf: %.conf.in Makefile %.conf: %.conf.in Makefile
$(SED_PROCESS) $(SED_PROCESS)
# vim:set noet:

View File

@@ -1,4 +1,3 @@
#!/hint/bash
# #
# @sysconfdir@/makepkg.conf # @sysconfdir@/makepkg.conf
# #
@@ -9,8 +8,7 @@
# #
#-- The download utilities that makepkg should use to acquire sources #-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent' # Format: 'protocol::agent'
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u' DLAGENTS=('ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -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' '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' 'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o' 'rsync::/usr/bin/rsync --no-motd -z %u %o'
@@ -50,7 +48,7 @@ CHOST="@CHOST@"
# BUILD ENVIRONMENT # BUILD ENVIRONMENT
######################################################################### #########################################################################
# #
# Defaults: BUILDENV=(!distcc !color !ccache check !sign) # Defaults: BUILDENV=(!distcc color !ccache check !sign)
# A negated environment option will do the opposite of the comments below. # A negated environment option will do the opposite of the comments below.
# #
#-- distcc: Use the Distributed C/C++/ObjC compiler #-- distcc: Use the Distributed C/C++/ObjC compiler
@@ -73,7 +71,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings # These are default values for the options=() settings
######################################################################### #########################################################################
# #
# Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug) # Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug)
# A negated option will do the opposite of the comments below. # A negated option will do the opposite of the comments below.
# #
#-- strip: Strip symbols from binaries/libraries #-- strip: Strip symbols from binaries/libraries
@@ -83,11 +81,13 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- emptydirs: Leave empty directories in packages #-- emptydirs: Leave empty directories in packages
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge: Remove files specified by PURGE_TARGETS #-- purge: Remove files specified by PURGE_TARGETS
#-- upx: Compress binary executable files using UPX
#-- optipng: Optimize PNG images with optipng
#-- debug: Add debugging flags as specified in DEBUG_* variables #-- debug: Add debugging flags as specified in DEBUG_* variables
# #
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug) OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !optipng !debug)
#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2 #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5) INTEGRITY_CHECK=(md5)
#-- Options to be used when stripping binaries. See `man strip' for details. #-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="@STRIP_BINARIES@" STRIP_BINARIES="@STRIP_BINARIES@"
@@ -101,8 +101,6 @@ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc}) DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified) #-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod) PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"
######################################################################### #########################################################################
# PACKAGE OUTPUT # PACKAGE OUTPUT
@@ -130,12 +128,9 @@ DBGSRCDIR="/usr/src/debug"
COMPRESSGZ=(gzip -c -f -n) COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f) COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -) COMPRESSXZ=(xz -c -z -)
COMPRESSZST=(zstd -c -z -q -)
COMPRESSLRZ=(lrzip -q) COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q) COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f) COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)
######################################################################### #########################################################################
# EXTENSION DEFAULTS # EXTENSION DEFAULTS
@@ -146,3 +141,5 @@ COMPRESSLZ=(lzip -c -f)
# #
PKGEXT='@PKGEXT@' PKGEXT='@PKGEXT@'
SRCEXT='@SRCEXT@' SRCEXT='@SRCEXT@'
# vim: set ft=sh ts=2 sw=2 et:

View File

@@ -16,7 +16,7 @@
#GPGDir = @sysconfdir@/pacman.d/gnupg/ #GPGDir = @sysconfdir@/pacman.d/gnupg/
#HookDir = @sysconfdir@/pacman.d/hooks/ #HookDir = @sysconfdir@/pacman.d/hooks/
HoldPkg = pacman glibc HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u #XferCommand = /usr/bin/curl -C - -f %u > %o
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled #CleanMethod = KeepInstalled
#UseDelta = 0.7 #UseDelta = 0.7

View File

@@ -58,6 +58,12 @@ libalpm_la_SOURCES = \
util-common.h util-common.c \ util-common.h util-common.c \
version.c version.c
if !HAVE_LIBSSL
libalpm_la_SOURCES += \
md5.h md5.c \
sha2.h sha2.c
endif
libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO)
libalpm_la_CFLAGS = \ libalpm_la_CFLAGS = \
@@ -65,13 +71,13 @@ libalpm_la_CFLAGS = \
$(GPGME_CFLAGS) \ $(GPGME_CFLAGS) \
$(LIBARCHIVE_CFLAGS) \ $(LIBARCHIVE_CFLAGS) \
$(LIBCURL_CFLAGS) \ $(LIBCURL_CFLAGS) \
$(LIBSSL_CFLAGS) \ $(LIBSSL_CFLAGS)
$(NETTLE_CFLAGS)
libalpm_la_LIBADD = \ libalpm_la_LIBADD = \
$(LTLIBINTL) \ $(LTLIBINTL) \
$(GPGME_LIBS) \ $(GPGME_LIBS) \
$(LIBARCHIVE_LIBS) \ $(LIBARCHIVE_LIBS) \
$(LIBCURL_LIBS) \ $(LIBCURL_LIBS) \
$(LIBSSL_LIBS) \ $(LIBSSL_LIBS)
$(NETTLE_LIBS)
# vim:set noet:

View File

@@ -1,7 +1,7 @@
/* /*
* add.c * add.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -53,7 +53,6 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
const char *pkgname, *pkgver; const char *pkgname, *pkgver;
alpm_trans_t *trans; alpm_trans_t *trans;
alpm_pkg_t *local; alpm_pkg_t *local;
alpm_pkg_t *dup;
/* Sanity checks */ /* Sanity checks */
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
@@ -71,16 +70,12 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
_alpm_log(handle, ALPM_LOG_DEBUG, "adding package '%s'\n", pkgname); _alpm_log(handle, ALPM_LOG_DEBUG, "adding package '%s'\n", pkgname);
if((dup = alpm_pkg_find(trans->add, pkgname))) { if(alpm_pkg_find(trans->add, pkgname)) {
if(dup == pkg) {
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping duplicate target: %s\n", pkgname);
return 0;
}
/* error for separate packages with the same name */
RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1); RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
} }
if((local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname))) { local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname);
if(local) {
const char *localpkgname = local->name; const char *localpkgname = local->name;
const char *localpkgver = local->version; const char *localpkgver = local->version;
int cmp = _alpm_pkg_compare_versions(pkg, local); int cmp = _alpm_pkg_compare_versions(pkg, local);
@@ -432,7 +427,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
ASSERT(trans != NULL, return -1); ASSERT(trans != NULL, return -1);
/* see if this is an upgrade. if so, remove the old package first */ /* see if this is an upgrade. if so, remove the old package first */
if(_alpm_db_get_pkgfromcache(db, newpkg->name) && (oldpkg = newpkg->oldpkg)) { if((oldpkg = newpkg->oldpkg)) {
int cmp = _alpm_pkg_compare_versions(newpkg, oldpkg); int cmp = _alpm_pkg_compare_versions(newpkg, oldpkg);
if(cmp < 0) { if(cmp < 0) {
log_msg = "downgrading"; log_msg = "downgrading";
@@ -699,3 +694,5 @@ int _alpm_upgrade_packages(alpm_handle_t *handle)
return ret; return ret;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* add.h * add.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -27,3 +27,5 @@
int _alpm_upgrade_packages(alpm_handle_t *handle); int _alpm_upgrade_packages(alpm_handle_t *handle);
#endif /* ALPM_ADD_H */ #endif /* ALPM_ADD_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* alpm.c * alpm.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -64,7 +64,7 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
goto cleanup; goto cleanup;
} }
/* to concatenate myhandle->root (ends with a slash) with SYSHOOKDIR (starts /* to contatenate myhandle->root (ends with a slash) with SYSHOOKDIR (starts
* with a slash) correctly, we skip SYSHOOKDIR[0]; the regular +1 therefore * with a slash) correctly, we skip SYSHOOKDIR[0]; the regular +1 therefore
* disappears from the allocation */ * disappears from the allocation */
MALLOC(hookdir, strlen(myhandle->root) + strlen(SYSHOOKDIR), goto nomem); MALLOC(hookdir, strlen(myhandle->root) + strlen(SYSHOOKDIR), goto nomem);
@@ -152,7 +152,7 @@ const char SYMEXPORT *alpm_version(void)
/** Get the capabilities of the library. /** Get the capabilities of the library.
* @return a bitmask of the capabilities * @return a bitmask of the capabilities
* */ * */
int SYMEXPORT alpm_capabilities(void) enum alpm_caps SYMEXPORT alpm_capabilities(void)
{ {
return 0 return 0
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
@@ -166,3 +166,5 @@ int SYMEXPORT alpm_capabilities(void)
#endif #endif
| 0; | 0;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* alpm.h * alpm.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -53,8 +53,7 @@ typedef struct __alpm_trans_t alpm_trans_t;
* @{ * @{
*/ */
typedef enum _alpm_errno_t { typedef enum _alpm_errno_t {
ALPM_ERR_OK = 0, ALPM_ERR_MEMORY = 1,
ALPM_ERR_MEMORY,
ALPM_ERR_SYSTEM, ALPM_ERR_SYSTEM,
ALPM_ERR_BADPERMS, ALPM_ERR_BADPERMS,
ALPM_ERR_NOT_A_FILE, ALPM_ERR_NOT_A_FILE,
@@ -118,9 +117,7 @@ typedef enum _alpm_errno_t {
ALPM_ERR_LIBARCHIVE, ALPM_ERR_LIBARCHIVE,
ALPM_ERR_LIBCURL, ALPM_ERR_LIBCURL,
ALPM_ERR_EXTERNAL_DOWNLOAD, ALPM_ERR_EXTERNAL_DOWNLOAD,
ALPM_ERR_GPGME, ALPM_ERR_GPGME
/* Missing compile-time features */
ALPM_ERR_MISSING_CAPABILITY_SIGNATURES
} alpm_errno_t; } alpm_errno_t;
/** Returns the current error code from the handle. */ /** Returns the current error code from the handle. */
@@ -832,11 +829,6 @@ int alpm_option_add_hookdir(alpm_handle_t *handle, const char *hookdir);
int alpm_option_remove_hookdir(alpm_handle_t *handle, const char *hookdir); int alpm_option_remove_hookdir(alpm_handle_t *handle, const char *hookdir);
/** @} */ /** @} */
alpm_list_t *alpm_option_get_overwrite_files(alpm_handle_t *handle);
int alpm_option_set_overwrite_files(alpm_handle_t *handle, alpm_list_t *globs);
int alpm_option_add_overwrite_file(alpm_handle_t *handle, const char *glob);
int alpm_option_remove_overwrite_file(alpm_handle_t *handle, const char *glob);
/** Returns the logfile name. */ /** Returns the logfile name. */
const char *alpm_option_get_logfile(alpm_handle_t *handle); const char *alpm_option_get_logfile(alpm_handle_t *handle);
/** Sets the logfile name. */ /** Sets the logfile name. */
@@ -924,16 +916,14 @@ int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
const char *alpm_option_get_dbext(alpm_handle_t *handle); const char *alpm_option_get_dbext(alpm_handle_t *handle);
int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext); int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext);
int alpm_option_get_default_siglevel(alpm_handle_t *handle); alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle);
int alpm_option_set_default_siglevel(alpm_handle_t *handle, int level); int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
int alpm_option_get_local_file_siglevel(alpm_handle_t *handle); alpm_siglevel_t alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int level); int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
int alpm_option_get_remote_file_siglevel(alpm_handle_t *handle); alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level); int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
int alpm_option_set_disable_dl_timeout(alpm_handle_t *handle, unsigned short disable_dl_timeout);
/** @} */ /** @} */
@@ -966,7 +956,7 @@ alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle);
* @return an alpm_db_t* on success (the value), NULL on error * @return an alpm_db_t* on success (the value), NULL on error
*/ */
alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename, alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename,
int level); alpm_siglevel_t level);
/** Unregister all package databases. /** Unregister all package databases.
* @param handle the context handle * @param handle the context handle
@@ -992,7 +982,7 @@ const char *alpm_db_get_name(const alpm_db_t *db);
* @param db pointer to the package database * @param db pointer to the package database
* @return the signature verification level * @return the signature verification level
*/ */
int alpm_db_get_siglevel(alpm_db_t *db); alpm_siglevel_t alpm_db_get_siglevel(alpm_db_t *db);
/** Check the validity of a database. /** Check the validity of a database.
* This is most useful for sync databases and verifying signature status. * This is most useful for sync databases and verifying signature status.
@@ -1046,7 +1036,7 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db);
*/ */
alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles); alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
typedef enum _alpm_db_usage_t { typedef enum _alpm_db_usage_ {
ALPM_DB_USAGE_SYNC = 1, ALPM_DB_USAGE_SYNC = 1,
ALPM_DB_USAGE_SEARCH = (1 << 1), ALPM_DB_USAGE_SEARCH = (1 << 1),
ALPM_DB_USAGE_INSTALL = (1 << 2), ALPM_DB_USAGE_INSTALL = (1 << 2),
@@ -1059,14 +1049,14 @@ typedef enum _alpm_db_usage_t {
* @param usage a bitmask of alpm_db_usage_t values * @param usage a bitmask of alpm_db_usage_t values
* @return 0 on success, or -1 on error * @return 0 on success, or -1 on error
*/ */
int alpm_db_set_usage(alpm_db_t *db, int usage); int alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage);
/** Gets the usage of a database. /** Gets the usage of a database.
* @param db pointer to the package database to get the status of * @param db pointer to the package database to get the status of
* @param usage pointer to an alpm_db_usage_t to store db's status * @param usage pointer to an alpm_db_usage_t to store db's status
* @return 0 on success, or -1 on error * @return 0 on success, or -1 on error
*/ */
int alpm_db_get_usage(alpm_db_t *db, int *usage); int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
/** @} */ /** @} */
@@ -1090,7 +1080,7 @@ int alpm_db_get_usage(alpm_db_t *db, int *usage);
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full, int alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
int level, alpm_pkg_t **pkg); alpm_siglevel_t level, alpm_pkg_t **pkg);
/** Find a package in a list by name. /** Find a package in a list by name.
* @param haystack a list of alpm_pkg_t * @param haystack a list of alpm_pkg_t
@@ -1270,18 +1260,6 @@ alpm_list_t *alpm_pkg_get_depends(alpm_pkg_t *pkg);
*/ */
alpm_list_t *alpm_pkg_get_optdepends(alpm_pkg_t *pkg); alpm_list_t *alpm_pkg_get_optdepends(alpm_pkg_t *pkg);
/** Returns a list of package check dependencies
* @param pkg a pointer to package
* @return a reference to an internal list of alpm_depend_t structures.
*/
alpm_list_t *alpm_pkg_get_checkdepends(alpm_pkg_t *pkg);
/** Returns a list of package make dependencies
* @param pkg a pointer to package
* @return a reference to an internal list of alpm_depend_t structures.
*/
alpm_list_t *alpm_pkg_get_makedepends(alpm_pkg_t *pkg);
/** Returns the list of packages conflicting with pkg. /** Returns the list of packages conflicting with pkg.
* @param pkg a pointer to package * @param pkg a pointer to package
* @return a reference to an internal list of alpm_depend_t structures. * @return a reference to an internal list of alpm_depend_t structures.
@@ -1339,7 +1317,7 @@ const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
* @param pkg a pointer to package * @param pkg a pointer to package
* @return an enum member giving the validation method * @return an enum member giving the validation method
*/ */
int alpm_pkg_get_validation(alpm_pkg_t *pkg); alpm_pkgvalidation_t alpm_pkg_get_validation(alpm_pkg_t *pkg);
/* End of alpm_pkg_t accessors */ /* End of alpm_pkg_t accessors */
/* @} */ /* @} */
@@ -1452,7 +1430,7 @@ alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name);
* Sync * Sync
*/ */
alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync); alpm_pkg_t *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
/** @addtogroup alpm_api_trans Transaction Functions /** @addtogroup alpm_api_trans Transaction Functions
* Functions to manipulate libalpm transactions * Functions to manipulate libalpm transactions
@@ -1463,7 +1441,8 @@ alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync);
typedef enum _alpm_transflag_t { typedef enum _alpm_transflag_t {
/** Ignore dependency checks. */ /** Ignore dependency checks. */
ALPM_TRANS_FLAG_NODEPS = 1, ALPM_TRANS_FLAG_NODEPS = 1,
/* (1 << 1) flag can go here */ /** Ignore file conflicts and overwrite files. */
ALPM_TRANS_FLAG_FORCE = (1 << 1),
/** Delete files even if they are tagged as backup. */ /** Delete files even if they are tagged as backup. */
ALPM_TRANS_FLAG_NOSAVE = (1 << 2), ALPM_TRANS_FLAG_NOSAVE = (1 << 2),
/** Ignore version numbers when checking dependencies. */ /** Ignore version numbers when checking dependencies. */
@@ -1500,7 +1479,7 @@ typedef enum _alpm_transflag_t {
* @param handle the context handle * @param handle the context handle
* @return the bitfield of transaction flags * @return the bitfield of transaction flags
*/ */
int alpm_trans_get_flags(alpm_handle_t *handle); alpm_transflag_t alpm_trans_get_flags(alpm_handle_t *handle);
/** Returns a list of packages added by the transaction. /** Returns a list of packages added by the transaction.
* @param handle the context handle * @param handle the context handle
@@ -1516,10 +1495,10 @@ alpm_list_t *alpm_trans_get_remove(alpm_handle_t *handle);
/** Initialize the transaction. /** Initialize the transaction.
* @param handle the context handle * @param handle the context handle
* @param flags flags of the transaction (like nodeps, etc; see alpm_transflag_t) * @param flags flags of the transaction (like nodeps, etc)
* @return 0 on success, -1 on error (pm_errno is set accordingly) * @return 0 on success, -1 on error (pm_errno is set accordingly)
*/ */
int alpm_trans_init(alpm_handle_t *handle, int flags); int alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags);
/** Prepare a transaction. /** Prepare a transaction.
* @param handle the context handle * @param handle the context handle
@@ -1633,8 +1612,7 @@ enum alpm_caps {
}; };
const char *alpm_version(void); const char *alpm_version(void);
/* Return a bitfield of capabilities using values from 'enum alpm_caps' */ enum alpm_caps alpm_capabilities(void);
int alpm_capabilities(void);
void alpm_fileconflict_free(alpm_fileconflict_t *conflict); void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
void alpm_depmissing_free(alpm_depmissing_t *miss); void alpm_depmissing_free(alpm_depmissing_t *miss);
@@ -1647,3 +1625,5 @@ void alpm_conflict_free(alpm_conflict_t *conflict);
} }
#endif #endif
#endif /* ALPM_H */ #endif /* ALPM_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* alpm_list.c * alpm_list.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -131,26 +131,6 @@ alpm_list_t SYMEXPORT *alpm_list_append(alpm_list_t **list, void *data)
return ptr; return ptr;
} }
/**
* @brief Duplicate and append a string to a list.
*
* @param list the list to append to
* @param data the string to duplicate and append
*
* @return the newly added item
*/
alpm_list_t SYMEXPORT *alpm_list_append_strdup(alpm_list_t **list, const char *data)
{
alpm_list_t *ret;
char *dup;
if((dup = strdup(data)) && (ret = alpm_list_append(list, dup))) {
return ret;
} else {
free(dup);
return NULL;
}
}
/** /**
* @brief Add items to a list in sorted order. * @brief Add items to a list in sorted order.
* *
@@ -461,10 +441,7 @@ alpm_list_t SYMEXPORT *alpm_list_remove_dupes(const alpm_list_t *list)
alpm_list_t *newlist = NULL; alpm_list_t *newlist = NULL;
while(lp) { while(lp) {
if(!alpm_list_find_ptr(newlist, lp->data)) { if(!alpm_list_find_ptr(newlist, lp->data)) {
if(alpm_list_append(&newlist, lp->data) == NULL) { newlist = alpm_list_add(newlist, lp->data);
alpm_list_free(newlist);
return NULL;
}
} }
lp = lp->next; lp = lp->next;
} }
@@ -483,10 +460,7 @@ alpm_list_t SYMEXPORT *alpm_list_strdup(const alpm_list_t *list)
const alpm_list_t *lp = list; const alpm_list_t *lp = list;
alpm_list_t *newlist = NULL; alpm_list_t *newlist = NULL;
while(lp) { while(lp) {
if(alpm_list_append_strdup(&newlist, lp->data) == NULL) { newlist = alpm_list_add(newlist, strdup(lp->data));
FREELIST(newlist);
return NULL;
}
lp = lp->next; lp = lp->next;
} }
return newlist; return newlist;
@@ -504,10 +478,7 @@ alpm_list_t SYMEXPORT *alpm_list_copy(const alpm_list_t *list)
const alpm_list_t *lp = list; const alpm_list_t *lp = list;
alpm_list_t *newlist = NULL; alpm_list_t *newlist = NULL;
while(lp) { while(lp) {
if(alpm_list_append(&newlist, lp->data) == NULL) { newlist = alpm_list_add(newlist, lp->data);
alpm_list_free(newlist);
return NULL;
}
lp = lp->next; lp = lp->next;
} }
return newlist; return newlist;
@@ -532,15 +503,8 @@ alpm_list_t SYMEXPORT *alpm_list_copy_data(const alpm_list_t *list,
void *newdata = malloc(size); void *newdata = malloc(size);
if(newdata) { if(newdata) {
memcpy(newdata, lp->data, size); memcpy(newdata, lp->data, size);
if(alpm_list_append(&newlist, newdata) == NULL) { newlist = alpm_list_add(newlist, newdata);
free(newdata);
FREELIST(newlist);
return NULL;
}
lp = lp->next; lp = lp->next;
} else {
FREELIST(newlist);
return NULL;
} }
} }
return newlist; return newlist;
@@ -568,10 +532,7 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
list->prev = NULL; list->prev = NULL;
while(lp) { while(lp) {
if(alpm_list_append(&newlist, lp->data) == NULL) { newlist = alpm_list_add(newlist, lp->data);
alpm_list_free(newlist);
return NULL;
}
lp = lp->prev; lp = lp->prev;
} }
list->prev = backup; /* restore tail pointer */ list->prev = backup; /* restore tail pointer */
@@ -842,3 +803,5 @@ void SYMEXPORT *alpm_list_to_array(const alpm_list_t *list, size_t n,
} }
/** @} */ /** @} */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* alpm_list.h * alpm_list.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -58,7 +58,6 @@ void alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn);
/* item mutators */ /* item mutators */
alpm_list_t *alpm_list_add(alpm_list_t *list, void *data); alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
alpm_list_t *alpm_list_append(alpm_list_t **list, void *data); alpm_list_t *alpm_list_append(alpm_list_t **list, void *data);
alpm_list_t *alpm_list_append_strdup(alpm_list_t **list, const char *data);
alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn); alpm_list_t *alpm_list_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_join(alpm_list_t *first, alpm_list_t *second); alpm_list_t *alpm_list_join(alpm_list_t *first, alpm_list_t *second);
alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn); alpm_list_t *alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
@@ -92,3 +91,5 @@ void *alpm_list_to_array(const alpm_list_t *list, size_t n, size_t size);
} }
#endif #endif
#endif /* ALPM_LIST_H */ #endif /* ALPM_LIST_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* backup.c * backup.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -98,3 +98,5 @@ error:
free(newbackup); free(newbackup);
return NULL; return NULL;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* backup.h * backup.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -29,3 +29,5 @@ void _alpm_backup_free(alpm_backup_t *backup);
alpm_backup_t *_alpm_backup_dup(const alpm_backup_t *backup); alpm_backup_t *_alpm_backup_dup(const alpm_backup_t *backup);
#endif /* ALPM_BACKUP_H */ #endif /* ALPM_BACKUP_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* be_local.c : backend for the local database * be_local.c : backend for the local database
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -47,9 +47,9 @@
/* local database format version */ /* local database format version */
size_t ALPM_LOCAL_DB_VERSION = 9; size_t ALPM_LOCAL_DB_VERSION = 9;
static int local_db_read(alpm_pkg_t *info, int inforeq); static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
#define LAZY_LOAD(info) \ #define LAZY_LOAD(info, errret) \
do { \ do { \
if(!(pkg->infolevel & info)) { \ if(!(pkg->infolevel & info)) { \
local_db_read(pkg, info); \ local_db_read(pkg, info); \
@@ -65,133 +65,121 @@ static int local_db_read(alpm_pkg_t *info, int inforeq);
static const char *_cache_get_base(alpm_pkg_t *pkg) static const char *_cache_get_base(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->base; return pkg->base;
} }
static const char *_cache_get_desc(alpm_pkg_t *pkg) static const char *_cache_get_desc(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->desc; return pkg->desc;
} }
static const char *_cache_get_url(alpm_pkg_t *pkg) static const char *_cache_get_url(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->url; return pkg->url;
} }
static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg) static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, 0);
return pkg->builddate; return pkg->builddate;
} }
static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg) static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, 0);
return pkg->installdate; return pkg->installdate;
} }
static const char *_cache_get_packager(alpm_pkg_t *pkg) static const char *_cache_get_packager(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->packager; return pkg->packager;
} }
static const char *_cache_get_arch(alpm_pkg_t *pkg) static const char *_cache_get_arch(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->arch; return pkg->arch;
} }
static off_t _cache_get_isize(alpm_pkg_t *pkg) static off_t _cache_get_isize(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, -1);
return pkg->isize; return pkg->isize;
} }
static alpm_pkgreason_t _cache_get_reason(alpm_pkg_t *pkg) static alpm_pkgreason_t _cache_get_reason(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, -1);
return pkg->reason; return pkg->reason;
} }
static int _cache_get_validation(alpm_pkg_t *pkg) static alpm_pkgvalidation_t _cache_get_validation(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, -1);
return pkg->validation; return pkg->validation;
} }
static alpm_list_t *_cache_get_licenses(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_licenses(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->licenses; return pkg->licenses;
} }
static alpm_list_t *_cache_get_groups(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_groups(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->groups; return pkg->groups;
} }
static int _cache_has_scriptlet(alpm_pkg_t *pkg) static int _cache_has_scriptlet(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_SCRIPTLET); LAZY_LOAD(INFRQ_SCRIPTLET, NULL);
return pkg->scriptlet; return pkg->scriptlet;
} }
static alpm_list_t *_cache_get_depends(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_depends(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->depends; return pkg->depends;
} }
static alpm_list_t *_cache_get_optdepends(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_optdepends(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->optdepends; return pkg->optdepends;
} }
static alpm_list_t *_cache_get_makedepends(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC);
return pkg->makedepends;
}
static alpm_list_t *_cache_get_checkdepends(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC);
return pkg->checkdepends;
}
static alpm_list_t *_cache_get_conflicts(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_conflicts(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->conflicts; return pkg->conflicts;
} }
static alpm_list_t *_cache_get_provides(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_provides(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->provides; return pkg->provides;
} }
static alpm_list_t *_cache_get_replaces(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_replaces(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_DESC); LAZY_LOAD(INFRQ_DESC, NULL);
return pkg->replaces; return pkg->replaces;
} }
static alpm_filelist_t *_cache_get_files(alpm_pkg_t *pkg) static alpm_filelist_t *_cache_get_files(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_FILES); LAZY_LOAD(INFRQ_FILES, NULL);
return &(pkg->files); return &(pkg->files);
} }
static alpm_list_t *_cache_get_backup(alpm_pkg_t *pkg) static alpm_list_t *_cache_get_backup(alpm_pkg_t *pkg)
{ {
LAZY_LOAD(INFRQ_FILES); LAZY_LOAD(INFRQ_FILES, NULL);
return pkg->backup; return pkg->backup;
} }
@@ -315,38 +303,36 @@ static int _cache_force_load(alpm_pkg_t *pkg)
* logic. * logic.
*/ */
static struct pkg_operations local_pkg_ops = { static struct pkg_operations local_pkg_ops = {
.get_base = _cache_get_base, .get_base = _cache_get_base,
.get_desc = _cache_get_desc, .get_desc = _cache_get_desc,
.get_url = _cache_get_url, .get_url = _cache_get_url,
.get_builddate = _cache_get_builddate, .get_builddate = _cache_get_builddate,
.get_installdate = _cache_get_installdate, .get_installdate = _cache_get_installdate,
.get_packager = _cache_get_packager, .get_packager = _cache_get_packager,
.get_arch = _cache_get_arch, .get_arch = _cache_get_arch,
.get_isize = _cache_get_isize, .get_isize = _cache_get_isize,
.get_reason = _cache_get_reason, .get_reason = _cache_get_reason,
.get_validation = _cache_get_validation, .get_validation = _cache_get_validation,
.has_scriptlet = _cache_has_scriptlet, .has_scriptlet = _cache_has_scriptlet,
.get_licenses = _cache_get_licenses, .get_licenses = _cache_get_licenses,
.get_groups = _cache_get_groups, .get_groups = _cache_get_groups,
.get_depends = _cache_get_depends, .get_depends = _cache_get_depends,
.get_optdepends = _cache_get_optdepends, .get_optdepends = _cache_get_optdepends,
.get_makedepends = _cache_get_makedepends, .get_conflicts = _cache_get_conflicts,
.get_checkdepends = _cache_get_checkdepends, .get_provides = _cache_get_provides,
.get_conflicts = _cache_get_conflicts, .get_replaces = _cache_get_replaces,
.get_provides = _cache_get_provides, .get_files = _cache_get_files,
.get_replaces = _cache_get_replaces, .get_backup = _cache_get_backup,
.get_files = _cache_get_files,
.get_backup = _cache_get_backup,
.changelog_open = _cache_changelog_open, .changelog_open = _cache_changelog_open,
.changelog_read = _cache_changelog_read, .changelog_read = _cache_changelog_read,
.changelog_close = _cache_changelog_close, .changelog_close = _cache_changelog_close,
.mtree_open = _cache_mtree_open, .mtree_open = _cache_mtree_open,
.mtree_next = _cache_mtree_next, .mtree_next = _cache_mtree_next,
.mtree_close = _cache_mtree_close, .mtree_close = _cache_mtree_close,
.force_load = _cache_force_load, .force_load = _cache_force_load,
}; };
static int checkdbdir(alpm_db_t *db) static int checkdbdir(alpm_db_t *db)
@@ -615,10 +601,7 @@ static int local_db_populate(alpm_db_t *db)
/* add to the collection */ /* add to the collection */
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", _alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename); pkg->name, db->treename);
if(_alpm_pkghash_add(&db->pkgcache, pkg) == NULL) { db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
_alpm_pkg_free(pkg);
RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
}
count++; count++;
} }
@@ -677,7 +660,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info,
f = alpm_list_add(f, alpm_dep_from_string(line)); \ f = alpm_list_add(f, alpm_dep_from_string(line)); \
} while(1) /* note the while(1) and not (0) */ } while(1) /* note the while(1) and not (0) */
static int local_db_read(alpm_pkg_t *info, int inforeq) static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
{ {
FILE *fp = NULL; FILE *fp = NULL;
char line[1024]; char line[1024];
@@ -787,10 +770,6 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
READ_AND_SPLITDEP(info->depends); READ_AND_SPLITDEP(info->depends);
} else if(strcmp(line, "%OPTDEPENDS%") == 0) { } else if(strcmp(line, "%OPTDEPENDS%") == 0) {
READ_AND_SPLITDEP(info->optdepends); READ_AND_SPLITDEP(info->optdepends);
} else if(strcmp(line, "%MAKEDEPENDS%") == 0) {
READ_AND_SPLITDEP(info->makedepends);
} else if(strcmp(line, "%CHECKDEPENDS%") == 0) {
READ_AND_SPLITDEP(info->checkdepends);
} else if(strcmp(line, "%CONFLICTS%") == 0) { } else if(strcmp(line, "%CONFLICTS%") == 0) {
READ_AND_SPLITDEP(info->conflicts); READ_AND_SPLITDEP(info->conflicts);
} else if(strcmp(line, "%PROVIDES%") == 0) { } else if(strcmp(line, "%PROVIDES%") == 0) {
@@ -838,12 +817,14 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
if(newfiles != NULL) { if(newfiles != NULL) {
files = newfiles; files = newfiles;
} }
/* make sure the list is sorted */
qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
} else { } else {
FREE(files); FREE(files);
} }
info->files.count = files_count; info->files.count = files_count;
info->files.files = files; info->files.files = files;
_alpm_filelist_sort(&info->files);
continue; continue;
nomem: nomem:
while(files_count > 0) { while(files_count > 0) {
@@ -929,7 +910,7 @@ static void write_deps(FILE *fp, const char *header, alpm_list_t *deplist)
fputc('\n', fp); fputc('\n', fp);
} }
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq) int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
{ {
FILE *fp = NULL; FILE *fp = NULL;
mode_t oldmask; mode_t oldmask;
@@ -1184,3 +1165,5 @@ alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle)
handle->db_local = db; handle->db_local = db;
return db; return db;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* be_package.c : backend for packages * be_package.c : backend for packages
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -223,11 +223,9 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
alpm_depend_t *optdep = alpm_dep_from_string(ptr); alpm_depend_t *optdep = alpm_dep_from_string(ptr);
newpkg->optdepends = alpm_list_add(newpkg->optdepends, optdep); newpkg->optdepends = alpm_list_add(newpkg->optdepends, optdep);
} else if(strcmp(key, "makedepend") == 0) { } else if(strcmp(key, "makedepend") == 0) {
alpm_depend_t *makedep = alpm_dep_from_string(ptr); /* not used atm */
newpkg->makedepends = alpm_list_add(newpkg->makedepends, makedep);
} else if(strcmp(key, "checkdepend") == 0) { } else if(strcmp(key, "checkdepend") == 0) {
alpm_depend_t *checkdep = alpm_dep_from_string(ptr); /* not used atm */
newpkg->checkdepends = alpm_list_add(newpkg->checkdepends, checkdep);
} else if(strcmp(key, "conflict") == 0) { } else if(strcmp(key, "conflict") == 0) {
alpm_depend_t *conflict = alpm_dep_from_string(ptr); alpm_depend_t *conflict = alpm_dep_from_string(ptr);
newpkg->conflicts = alpm_list_add(newpkg->conflicts, conflict); newpkg->conflicts = alpm_list_add(newpkg->conflicts, conflict);
@@ -272,11 +270,11 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
* @return 0 if package is fully valid, -1 and pm_errno otherwise * @return 0 if package is fully valid, -1 and pm_errno otherwise
*/ */
int _alpm_pkg_validate_internal(alpm_handle_t *handle, int _alpm_pkg_validate_internal(alpm_handle_t *handle,
const char *pkgfile, alpm_pkg_t *syncpkg, int level, const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
alpm_siglist_t **sigdata, int *validation) alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation)
{ {
int has_sig; int has_sig;
handle->pm_errno = ALPM_ERR_OK; handle->pm_errno = 0;
if(pkgfile == NULL || strlen(pkgfile) == 0) { if(pkgfile == NULL || strlen(pkgfile) == 0) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
@@ -678,7 +676,8 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"sorting package filelist for %s\n", pkgfile); "sorting package filelist for %s\n", pkgfile);
_alpm_filelist_sort(&newpkg->files); qsort(newpkg->files.files, newpkg->files.count,
sizeof(alpm_file_t), _alpm_files_cmp);
} }
newpkg->infolevel |= INFRQ_FILES; newpkg->infolevel |= INFRQ_FILES;
} }
@@ -727,9 +726,9 @@ static int read_sigfile(const char *sigpath, unsigned char **sig)
} }
int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full, int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int full,
int level, alpm_pkg_t **pkg) alpm_siglevel_t level, alpm_pkg_t **pkg)
{ {
int validation = 0; alpm_pkgvalidation_t validation = 0;
char *sigpath; char *sigpath;
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
@@ -788,3 +787,5 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
return 0; return 0;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* be_sync.c : backend for sync databases * be_sync.c : backend for sync databases
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -71,7 +71,7 @@ static char *get_sync_dir(alpm_handle_t *handle)
static int sync_db_validate(alpm_db_t *db) static int sync_db_validate(alpm_db_t *db)
{ {
int siglevel; alpm_siglevel_t level;
const char *dbpath; const char *dbpath;
if(db->status & DB_STATUS_VALID || db->status & DB_STATUS_MISSING) { if(db->status & DB_STATUS_VALID || db->status & DB_STATUS_MISSING) {
@@ -104,20 +104,20 @@ static int sync_db_validate(alpm_db_t *db)
/* this takes into account the default verification level if UNKNOWN /* this takes into account the default verification level if UNKNOWN
* was assigned to this db */ * was assigned to this db */
siglevel = alpm_db_get_siglevel(db); level = alpm_db_get_siglevel(db);
if(siglevel & ALPM_SIG_DATABASE) { if(level & ALPM_SIG_DATABASE) {
int retry, ret; int retry, ret;
do { do {
retry = 0; retry = 0;
alpm_siglist_t *siglist; alpm_siglist_t *siglist;
ret = _alpm_check_pgp_helper(db->handle, dbpath, NULL, ret = _alpm_check_pgp_helper(db->handle, dbpath, NULL,
siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK, level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK,
siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist); level & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist);
if(ret) { if(ret) {
retry = _alpm_process_siglist(db->handle, db->treename, siglist, retry = _alpm_process_siglist(db->handle, db->treename, siglist,
siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK, level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK,
siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK); level & ALPM_SIG_DATABASE_UNKNOWN_OK);
} }
alpm_siglist_cleanup(siglist); alpm_siglist_cleanup(siglist);
free(siglist); free(siglist);
@@ -181,12 +181,12 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
int ret = -1; int ret = -1;
mode_t oldmask; mode_t oldmask;
alpm_handle_t *handle; alpm_handle_t *handle;
int siglevel; alpm_siglevel_t level;
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
handle = db->handle; handle = db->handle;
handle->pm_errno = ALPM_ERR_OK; handle->pm_errno = 0;
ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); ASSERT(db != handle->db_local, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1)); ASSERT(db->servers != NULL, RET_ERR(handle, ALPM_ERR_SERVER_NONE, -1));
@@ -207,7 +207,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* make sure we have a sane umask */ /* make sure we have a sane umask */
oldmask = umask(0022); oldmask = umask(0022);
siglevel = alpm_db_get_siglevel(db); level = alpm_db_get_siglevel(db);
/* attempt to grab a lock */ /* attempt to grab a lock */
if(_alpm_handle_lock(handle)) { if(_alpm_handle_lock(handle)) {
@@ -247,7 +247,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
_alpm_dload_payload_reset(&payload); _alpm_dload_payload_reset(&payload);
updated = (updated || ret == 0); updated = (updated || ret == 0);
if(ret != -1 && updated && (siglevel & ALPM_SIG_DATABASE)) { if(ret != -1 && updated && (level & ALPM_SIG_DATABASE)) {
/* an existing sig file is no good at this point */ /* an existing sig file is no good at this point */
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db)); char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
if(!sigpath) { if(!sigpath) {
@@ -292,7 +292,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.handle = handle; payload.handle = handle;
payload.force = 1; payload.force = 1;
payload.errors_ok = (siglevel & ALPM_SIG_DATABASE_OPTIONAL); payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL);
/* set hard upper limit of 16KiB */ /* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024; payload.max_size = 16 * 1024;
@@ -330,7 +330,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
alpm_strerror(handle->pm_errno)); alpm_strerror(handle->pm_errno));
} else { } else {
handle->pm_errno = ALPM_ERR_OK; handle->pm_errno = 0;
} }
_alpm_handle_unlock(handle); _alpm_handle_unlock(handle);
@@ -343,7 +343,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
static int sync_db_read(alpm_db_t *db, struct archive *archive, static int sync_db_read(alpm_db_t *db, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t **likely_pkg); struct archive_entry *entry, alpm_pkg_t **likely_pkg);
static int _sync_get_validation(alpm_pkg_t *pkg) static alpm_pkgvalidation_t _sync_get_validation(alpm_pkg_t *pkg)
{ {
if(pkg->validation) { if(pkg->validation) {
return pkg->validation; return pkg->validation;
@@ -413,10 +413,7 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
/* add to the collection */ /* add to the collection */
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n", _alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename); pkg->name, db->treename);
if(_alpm_pkghash_add(&db->pkgcache, pkg) == NULL) { db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
_alpm_pkg_free(pkg);
RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL);
}
} else { } else {
free(pkgname); free(pkgname);
free(pkgver); free(pkgver);
@@ -468,7 +465,6 @@ static int sync_db_populate(alpm_db_t *db)
size_t est_count, count; size_t est_count, count;
int fd; int fd;
int ret = 0; int ret = 0;
int archive_ret;
struct stat buf; struct stat buf;
struct archive *archive; struct archive *archive;
struct archive_entry *entry; struct archive_entry *entry;
@@ -489,8 +485,6 @@ static int sync_db_populate(alpm_db_t *db)
fd = _alpm_open_archive(db->handle, dbpath, &buf, fd = _alpm_open_archive(db->handle, dbpath, &buf,
&archive, ALPM_ERR_DB_OPEN); &archive, ALPM_ERR_DB_OPEN);
if(fd < 0) { if(fd < 0) {
db->status &= ~DB_STATUS_VALID;
db->status |= DB_STATUS_INVALID;
return -1; return -1;
} }
est_count = estimate_package_count(&buf, archive); est_count = estimate_package_count(&buf, archive);
@@ -508,26 +502,20 @@ static int sync_db_populate(alpm_db_t *db)
goto cleanup; goto cleanup;
} }
while((archive_ret = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) { while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
mode_t mode = archive_entry_mode(entry); mode_t mode = archive_entry_mode(entry);
if(!S_ISDIR(mode)) { if(S_ISDIR(mode)) {
continue;
} else {
/* we have desc, depends or deltas - parse it */ /* we have desc, depends or deltas - parse it */
if(sync_db_read(db, archive, entry, &pkg) != 0) { if(sync_db_read(db, archive, entry, &pkg) != 0) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _alpm_log(db->handle, ALPM_LOG_ERROR,
_("could not parse package description file '%s' from db '%s'\n"), _("could not parse package description file '%s' from db '%s'\n"),
archive_entry_pathname(entry), db->treename); archive_entry_pathname(entry), db->treename);
ret = -1; continue;
} }
} }
} }
if(archive_ret != ARCHIVE_EOF) {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("could not read db '%s' (%s)\n"),
db->treename, archive_error_string(archive));
_alpm_db_free_pkgcache(db);
db->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
ret = -1;
goto cleanup;
}
count = alpm_list_count(db->pkgcache->list); count = alpm_list_count(db->pkgcache->list);
if(count > 0) { if(count > 0) {
@@ -623,7 +611,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(pkg == NULL) { if(pkg == NULL) {
_alpm_log(db->handle, ALPM_LOG_DEBUG, _alpm_log(db->handle, ALPM_LOG_DEBUG,
"entry %s could not be loaded into %s sync database\n", "entry %s could not be loaded into %s sync database",
entryname, db->treename); entryname, db->treename);
return -1; return -1;
} }
@@ -632,7 +620,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
/* A file exists outside of a subdirectory. This isn't a read error, so return /* A file exists outside of a subdirectory. This isn't a read error, so return
* success and try to continue on. */ * success and try to continue on. */
_alpm_log(db->handle, ALPM_LOG_WARNING, _("unknown database file: %s\n"), _alpm_log(db->handle, ALPM_LOG_WARNING, _("unknown database file: %s\n"),
entryname); filename);
return 0; return 0;
} }
@@ -700,9 +688,17 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
} else if(strcmp(line, "%OPTDEPENDS%") == 0) { } else if(strcmp(line, "%OPTDEPENDS%") == 0) {
READ_AND_SPLITDEP(pkg->optdepends); READ_AND_SPLITDEP(pkg->optdepends);
} else if(strcmp(line, "%MAKEDEPENDS%") == 0) { } else if(strcmp(line, "%MAKEDEPENDS%") == 0) {
READ_AND_SPLITDEP(pkg->makedepends); /* currently unused */
while(1) {
READ_NEXT();
if(strlen(line) == 0) break;
}
} else if(strcmp(line, "%CHECKDEPENDS%") == 0) { } else if(strcmp(line, "%CHECKDEPENDS%") == 0) {
READ_AND_SPLITDEP(pkg->checkdepends); /* currently unused */
while(1) {
READ_NEXT();
if(strlen(line) == 0) break;
}
} else if(strcmp(line, "%CONFLICTS%") == 0) { } else if(strcmp(line, "%CONFLICTS%") == 0) {
READ_AND_SPLITDEP(pkg->conflicts); READ_AND_SPLITDEP(pkg->conflicts);
} else if(strcmp(line, "%PROVIDES%") == 0) { } else if(strcmp(line, "%PROVIDES%") == 0) {
@@ -739,12 +735,13 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
/* attempt to hand back any memory we don't need */ /* attempt to hand back any memory we don't need */
if(files_count > 0) { if(files_count > 0) {
files = realloc(files, sizeof(alpm_file_t) * files_count); files = realloc(files, sizeof(alpm_file_t) * files_count);
/* make sure the list is sorted */
qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
} else { } else {
FREE(files); FREE(files);
} }
pkg->files.count = files_count; pkg->files.count = files_count;
pkg->files.files = files; pkg->files.files = files;
_alpm_filelist_sort(&pkg->files);
} }
} }
if(ret != ARCHIVE_EOF) { if(ret != ARCHIVE_EOF) {
@@ -772,15 +769,15 @@ struct db_operations sync_db_ops = {
}; };
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
int level) alpm_siglevel_t level)
{ {
alpm_db_t *db; alpm_db_t *db;
_alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename); _alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename);
#ifndef HAVE_LIBGPGME #ifndef HAVE_LIBGPGME
if(level != 0 && level != ALPM_SIG_USE_DEFAULT) { if(level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_MISSING_CAPABILITY_SIGNATURES, NULL); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
} }
#endif #endif
@@ -797,3 +794,5 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
handle->dbs_sync = alpm_list_add(handle->dbs_sync, db); handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
return db; return db;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* conflict.c * conflict.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org> * Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -278,15 +278,12 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
STRDUP(conflict->target, pkg1->name, goto error); STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error); STRDUP(conflict->file, filestr, goto error);
if(!pkg2) { if(pkg2) {
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
STRDUP(conflict->ctarget, "", goto error);
} else if(pkg2->origin == ALPM_PKG_FROM_LOCALDB) {
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
STRDUP(conflict->ctarget, pkg2->name, goto error);
} else {
conflict->type = ALPM_FILECONFLICT_TARGET; conflict->type = ALPM_FILECONFLICT_TARGET;
STRDUP(conflict->ctarget, pkg2->name, goto error); STRDUP(conflict->ctarget, pkg2->name, goto error);
} else {
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
STRDUP(conflict->ctarget, "", goto error);
} }
conflicts = alpm_list_add(conflicts, conflict); conflicts = alpm_list_add(conflicts, conflict);
@@ -388,23 +385,6 @@ static alpm_list_t *alpm_db_find_file_owners(alpm_db_t* db, const char *path)
return owners; return owners;
} }
static alpm_pkg_t *_alpm_find_file_owner(alpm_handle_t *handle, const char *path)
{
alpm_list_t *i;
for(i = alpm_db_get_pkgcache(handle->db_local); i; i = i->next) {
if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) {
return i->data;
}
}
return NULL;
}
static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path, const char *rootedpath)
{
return _alpm_fnmatch_patterns(handle->overwrite_files, path) == 0
|| _alpm_fnmatch_patterns(handle->overwrite_files, rootedpath) == 0;
}
/** /**
* @brief Find file conflicts that may occur during the transaction. * @brief Find file conflicts that may occur during the transaction.
* *
@@ -439,7 +419,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
for(current = 0, i = upgrade; i; i = i->next, current++) { for(current = 0, i = upgrade; i; i = i->next, current++) {
alpm_pkg_t *p1 = i->data; alpm_pkg_t *p1 = i->data;
alpm_list_t *j; alpm_list_t *j;
alpm_list_t *newfiles = NULL; alpm_list_t *tmpfiles = NULL;
alpm_pkg_t *dbpkg; alpm_pkg_t *dbpkg;
int percent = (current * 100) / numtargs; int percent = (current * 100) / numtargs;
@@ -468,8 +448,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* can skip file-file conflicts when forced * /* can skip file-file conflicts when forced *
* checking presence in p2_files detects dir-file or file-dir * checking presence in p2_files detects dir-file or file-dir
* conflicts as the path from p1 is returned */ * conflicts as the path from p1 is returned */
if(_alpm_can_overwrite_file(handle, filename, path) if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
&& alpm_filelist_contains(p2_files, filename)) { alpm_filelist_contains(p2_files, filename)) {
_alpm_log(handle, ALPM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"%s exists in both '%s' and '%s'\n", filename, "%s exists in both '%s' and '%s'\n", filename,
p1->name, p2->name); p1->name, p2->name);
@@ -503,18 +483,18 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
* be freed. */ * be freed. */
if(dbpkg) { if(dbpkg) {
/* older ver of package currently installed */ /* older ver of package currently installed */
newfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1), tmpfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
alpm_pkg_get_files(dbpkg)); alpm_pkg_get_files(dbpkg));
} else { } else {
/* no version of package currently installed */ /* no version of package currently installed */
alpm_filelist_t *fl = alpm_pkg_get_files(p1); alpm_filelist_t *fl = alpm_pkg_get_files(p1);
size_t filenum; size_t filenum;
for(filenum = 0; filenum < fl->count; filenum++) { for(filenum = 0; filenum < fl->count; filenum++) {
newfiles = alpm_list_add(newfiles, fl->files[filenum].name); tmpfiles = alpm_list_add(tmpfiles, fl->files[filenum].name);
} }
} }
for(j = newfiles; j; j = j->next) { for(j = tmpfiles; j; j = j->next) {
const char *filestr = j->data; const char *filestr = j->data;
const char *relative_path; const char *relative_path;
alpm_list_t *k; alpm_list_t *k;
@@ -523,7 +503,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
struct stat lsbuf; struct stat lsbuf;
char path[PATH_MAX]; char path[PATH_MAX];
size_t pathlen; size_t pathlen;
int pfile_isdir;
pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr); pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
relative_path = path + rootlen; relative_path = path + rootlen;
@@ -535,8 +514,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path); _alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
pfile_isdir = path[pathlen - 1] == '/'; if(path[pathlen - 1] == '/') {
if(pfile_isdir) {
if(S_ISDIR(lsbuf.st_mode)) { if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
continue; continue;
@@ -573,18 +551,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"local file will be removed, not a conflict\n"); "local file will be removed, not a conflict\n");
resolved_conflict = 1; resolved_conflict = 1;
if(pfile_isdir) {
/* go ahead and skip any files inside filestr as they will
* necessarily be resolved by replacing the file with a dir
* NOTE: afterward, j will point to the last file inside filestr */
size_t fslen = strlen(filestr);
for( ; j->next; j = j->next) {
const char *filestr2 = j->next->data;
if(strncmp(filestr, filestr2, fslen) != 0) {
break;
}
}
}
} }
} }
@@ -674,29 +640,30 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
} }
/* skip file-file conflicts when being forced */ /* skip file-file conflicts when being forced */
if(!S_ISDIR(lsbuf.st_mode) if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
&& _alpm_can_overwrite_file(handle, filestr, path)) { !S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"conflict with file on filesystem being forced\n"); "conflict with file on filesystem being forced\n");
resolved_conflict = 1; resolved_conflict = 1;
} }
if(!resolved_conflict) { if(!resolved_conflict) {
conflicts = add_fileconflict(handle, conflicts, path, p1, conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
_alpm_find_file_owner(handle, relative_path));
if(handle->pm_errno == ALPM_ERR_MEMORY) { if(handle->pm_errno == ALPM_ERR_MEMORY) {
alpm_list_free_inner(conflicts, alpm_list_free_inner(conflicts,
(alpm_list_fn_free) alpm_conflict_free); (alpm_list_fn_free) alpm_conflict_free);
alpm_list_free(conflicts); alpm_list_free(conflicts);
alpm_list_free(newfiles); alpm_list_free(tmpfiles);
return NULL; return NULL;
} }
} }
} }
alpm_list_free(newfiles); alpm_list_free(tmpfiles);
} }
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100, PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current); numtargs, current);
return conflicts; return conflicts;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* conflict.h * conflict.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -31,3 +31,5 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
alpm_list_t *upgrade, alpm_list_t *remove); alpm_list_t *upgrade, alpm_list_t *remove);
#endif /* ALPM_CONFLICT_H */ #endif /* ALPM_CONFLICT_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* db.c * db.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -44,7 +44,7 @@
/** Register a sync database of packages. */ /** Register a sync database of packages. */
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle, alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
const char *treename, int siglevel) const char *treename, alpm_siglevel_t level)
{ {
alpm_list_t *i; alpm_list_t *i;
@@ -67,7 +67,7 @@ alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
} }
} }
return _alpm_db_register_sync(handle, treename, siglevel); return _alpm_db_register_sync(handle, treename, level);
} }
/* Helper function for alpm_db_unregister{_all} */ /* Helper function for alpm_db_unregister{_all} */
@@ -112,7 +112,7 @@ int SYMEXPORT alpm_db_unregister(alpm_db_t *db)
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
/* Do not unregister a database if a transaction is on-going */ /* Do not unregister a database if a transaction is on-going */
handle = db->handle; handle = db->handle;
handle->pm_errno = ALPM_ERR_OK; handle->pm_errno = 0;
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1)); ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
if(db == handle->db_local) { if(db == handle->db_local) {
@@ -179,7 +179,7 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1)); ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url); newurl = sanitize_url(url);
@@ -206,7 +206,7 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
/* Sanity checks */ /* Sanity checks */
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1)); ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url); newurl = sanitize_url(url);
@@ -235,7 +235,7 @@ const char SYMEXPORT *alpm_db_get_name(const alpm_db_t *db)
} }
/** Get the signature verification level for a database. */ /** Get the signature verification level for a database. */
int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db) alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
if(db->siglevel & ALPM_SIG_USE_DEFAULT) { if(db->siglevel & ALPM_SIG_USE_DEFAULT) {
@@ -249,7 +249,7 @@ int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
int SYMEXPORT alpm_db_get_valid(alpm_db_t *db) int SYMEXPORT alpm_db_get_valid(alpm_db_t *db)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
return db->ops->validate(db); return db->ops->validate(db);
} }
@@ -258,7 +258,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
{ {
alpm_pkg_t *pkg; alpm_pkg_t *pkg;
ASSERT(db != NULL, return NULL); ASSERT(db != NULL, return NULL);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
ASSERT(name != NULL && strlen(name) != 0, ASSERT(name != NULL && strlen(name) != 0,
RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL)); RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, NULL));
@@ -273,7 +273,7 @@ alpm_pkg_t SYMEXPORT *alpm_db_get_pkg(alpm_db_t *db, const char *name)
alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db) alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db)
{ {
ASSERT(db != NULL, return NULL); ASSERT(db != NULL, return NULL);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
return _alpm_db_get_pkgcache(db); return _alpm_db_get_pkgcache(db);
} }
@@ -292,7 +292,7 @@ alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name)
alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db) alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
{ {
ASSERT(db != NULL, return NULL); ASSERT(db != NULL, return NULL);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
return _alpm_db_get_groupcache(db); return _alpm_db_get_groupcache(db);
} }
@@ -301,13 +301,13 @@ alpm_list_t SYMEXPORT *alpm_db_get_groupcache(alpm_db_t *db)
alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles) alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
{ {
ASSERT(db != NULL, return NULL); ASSERT(db != NULL, return NULL);
db->handle->pm_errno = ALPM_ERR_OK; db->handle->pm_errno = 0;
return _alpm_db_search(db, needles); return _alpm_db_search(db, needles);
} }
/** Sets the usage bitmask for a repo */ /** Sets the usage bitmask for a repo */
int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage) int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
db->usage = usage; db->usage = usage;
@@ -315,7 +315,7 @@ int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage)
} }
/** Gets the usage bitmask for a repo */ /** Gets the usage bitmask for a repo */
int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage) int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage)
{ {
ASSERT(db != NULL, return -1); ASSERT(db != NULL, return -1);
ASSERT(usage != NULL, return -1); ASSERT(usage != NULL, return -1);
@@ -589,10 +589,7 @@ int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
? ALPM_PKG_FROM_LOCALDB ? ALPM_PKG_FROM_LOCALDB
: ALPM_PKG_FROM_SYNCDB; : ALPM_PKG_FROM_SYNCDB;
newpkg->origin_data.db = db; newpkg->origin_data.db = db;
if(_alpm_pkghash_add_sorted(&db->pkgcache, newpkg) == NULL) { db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg);
_alpm_pkg_free(newpkg);
RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
}
free_groupcache(db); free_groupcache(db);
@@ -726,3 +723,5 @@ alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target)
return NULL; return NULL;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* db.h * db.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org> * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -71,14 +71,10 @@ struct __alpm_db_t {
alpm_list_t *grpcache; alpm_list_t *grpcache;
alpm_list_t *servers; alpm_list_t *servers;
struct db_operations *ops; struct db_operations *ops;
/* flags determining validity, local, loaded caches, etc. */
/* bitfields for validity, local, loaded caches, etc. */ enum _alpm_dbstatus_t status;
/* From _alpm_dbstatus_t */ alpm_siglevel_t siglevel;
int status; alpm_db_usage_t usage;
/* alpm_siglevel_t */
int siglevel;
/* alpm_db_usage_t */
int usage;
}; };
@@ -90,12 +86,12 @@ int _alpm_db_cmp(const void *d1, const void *d2);
alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles); alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles);
alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle); alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle);
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename, alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
int level); alpm_siglevel_t level);
void _alpm_db_unregister(alpm_db_t *db); void _alpm_db_unregister(alpm_db_t *db);
/* be_*.c, backend specific calls */ /* be_*.c, backend specific calls */
int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info); int _alpm_local_db_prepare(alpm_db_t *db, alpm_pkg_t *info);
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq); int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info); int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info);
char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename); char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info, const char *filename);
@@ -112,3 +108,5 @@ alpm_list_t *_alpm_db_get_groupcache(alpm_db_t *db);
alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target); alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target);
#endif /* ALPM_DB_H */ #endif /* ALPM_DB_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* delta.c * delta.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -71,7 +71,7 @@ static alpm_list_t *graph_init(alpm_list_t *deltas, int reverse)
v_i->children = alpm_list_add(v_i->children, v_j); v_i->children = alpm_list_add(v_i->children, v_j);
} }
} }
v_i->iterator = v_i->children; v_i->childptr = v_i->children;
} }
return vertices; return vertices;
} }
@@ -130,7 +130,7 @@ static void dijkstra(alpm_list_t *vertices)
for(i = vertices; i; i = i->next) { for(i = vertices; i; i = i->next) {
alpm_graph_t *v_i = i->data; alpm_graph_t *v_i = i->data;
if(v_i->state == ALPM_GRAPH_STATE_PROCESSING) { if(v_i->state == -1) {
continue; continue;
} }
@@ -142,18 +142,18 @@ static void dijkstra(alpm_list_t *vertices)
break; break;
} }
v->state = ALPM_GRAPH_STATE_PROCESSING; v->state = -1;
v->iterator = v->children; v->childptr = v->children;
while(v->iterator) { while(v->childptr) {
alpm_graph_t *v_c = v->iterator->data; alpm_graph_t *v_c = v->childptr->data;
alpm_delta_t *d_c = v_c->data; alpm_delta_t *d_c = v_c->data;
if(v_c->weight > v->weight + d_c->download_size) { if(v_c->weight > v->weight + d_c->download_size) {
v_c->weight = v->weight + d_c->download_size; v_c->weight = v->weight + d_c->download_size;
v_c->parent = v; v_c->parent = v;
} }
v->iterator = (v->iterator)->next; v->childptr = (v->childptr)->next;
} }
} }
@@ -238,7 +238,8 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota
for(i = vertices; i; i = i->next) { for(i = vertices; i; i = i->next) {
alpm_graph_t *v = i->data; alpm_graph_t *v = i->data;
alpm_delta_t *vdelta = v->data; alpm_delta_t *vdelta = v->data;
if(strcmp(vdelta->to, to) == 0) { if(strcmp(vdelta->to, to) == 0)
{
v->weight = vdelta->download_size; v->weight = vdelta->download_size;
} }
} }
@@ -359,3 +360,5 @@ error:
_alpm_delta_free(newdelta); _alpm_delta_free(newdelta);
return NULL; return NULL;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* delta.h * delta.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -31,3 +31,5 @@ off_t _alpm_shortest_delta_path(alpm_handle_t *handle, alpm_list_t *deltas,
const char *to, alpm_list_t **path); const char *to, alpm_list_t **path);
#endif /* ALPM_DELTA_H */ #endif /* ALPM_DELTA_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* deps.c * deps.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org> * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -152,48 +152,12 @@ static alpm_list_t *dep_graph_init(alpm_handle_t *handle,
j = next; j = next;
} }
vertex_i->iterator = vertex_i->children; vertex_i->childptr = vertex_i->children;
} }
alpm_list_free(localpkgs); alpm_list_free(localpkgs);
return vertices; return vertices;
} }
static void _alpm_warn_dep_cycle(alpm_handle_t *handle, alpm_list_t *targets,
alpm_graph_t *ancestor, alpm_graph_t *vertex, int reverse)
{
/* vertex depends on and is required by ancestor */
if(!alpm_list_find_ptr(targets, vertex->data)) {
/* child is not part of the transaction, not a problem */
return;
}
/* find the nearest ancestor that's part of the transaction */
while(ancestor) {
if(alpm_list_find_ptr(targets, ancestor->data)) {
break;
}
ancestor = ancestor->parent;
}
if(!ancestor || ancestor == vertex) {
/* no transaction package in our ancestry or the package has
* a circular dependency with itself, not a problem */
} else {
alpm_pkg_t *ancestorpkg = ancestor->data;
alpm_pkg_t *childpkg = vertex->data;
_alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n"));
if(reverse) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("%s will be removed after its %s dependency\n"),
ancestorpkg->name, childpkg->name);
} else {
_alpm_log(handle, ALPM_LOG_WARNING,
_("%s will be installed before its %s dependency\n"),
ancestorpkg->name, childpkg->name);
}
}
}
/* Re-order a list of target packages with respect to their dependencies. /* Re-order a list of target packages with respect to their dependencies.
* *
* Example (reverse == 0): * Example (reverse == 0):
@@ -215,7 +179,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
{ {
alpm_list_t *newtargs = NULL; alpm_list_t *newtargs = NULL;
alpm_list_t *vertices = NULL; alpm_list_t *vertices = NULL;
alpm_list_t *i; alpm_list_t *vptr;
alpm_graph_t *vertex; alpm_graph_t *vertex;
if(targets == NULL) { if(targets == NULL) {
@@ -226,35 +190,67 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
vertices = dep_graph_init(handle, targets, ignore); vertices = dep_graph_init(handle, targets, ignore);
i = vertices; vptr = vertices;
vertex = vertices->data; vertex = vertices->data;
while(i) { while(vptr) {
/* mark that we touched the vertex */ /* mark that we touched the vertex */
vertex->state = ALPM_GRAPH_STATE_PROCESSING; vertex->state = -1;
int switched_to_child = 0; int found = 0;
while(vertex->iterator && !switched_to_child) { while(vertex->childptr && !found) {
alpm_graph_t *nextchild = vertex->iterator->data; alpm_graph_t *nextchild = vertex->childptr->data;
vertex->iterator = vertex->iterator->next; vertex->childptr = vertex->childptr->next;
if(nextchild->state == ALPM_GRAPH_STATE_UNPROCESSED) { if(nextchild->state == 0) {
switched_to_child = 1; found = 1;
nextchild->parent = vertex; nextchild->parent = vertex;
vertex = nextchild; vertex = nextchild;
} else if(nextchild->state == ALPM_GRAPH_STATE_PROCESSING) { } else if(nextchild->state == -1) {
_alpm_warn_dep_cycle(handle, targets, vertex, nextchild, reverse); /* child is an ancestor of vertex */
alpm_graph_t *transvertex = vertex;
if(!alpm_list_find_ptr(targets, nextchild->data)) {
/* child is not part of the transaction, not a problem */
continue;
}
/* find the nearest parent that's part of the transaction */
while(transvertex) {
if(alpm_list_find_ptr(targets, transvertex->data)) {
break;
}
transvertex = transvertex->parent;
}
if(!transvertex || transvertex == nextchild) {
/* no transaction package in our ancestry or the package has
* a circular dependency with itself, not a problem */
} else {
alpm_pkg_t *transpkg = transvertex->data;
alpm_pkg_t *childpkg = nextchild->data;
_alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n"));
if(reverse) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("%s will be removed after its %s dependency\n"),
transpkg->name, childpkg->name);
} else {
_alpm_log(handle, ALPM_LOG_WARNING,
_("%s will be installed before its %s dependency\n"),
transpkg->name, childpkg->name);
}
}
} }
} }
if(!switched_to_child) { if(!found) {
if(alpm_list_find_ptr(targets, vertex->data)) { if(alpm_list_find_ptr(targets, vertex->data)) {
newtargs = alpm_list_add(newtargs, vertex->data); newtargs = alpm_list_add(newtargs, vertex->data);
} }
/* mark that we've left this vertex */ /* mark that we've left this vertex */
vertex->state = ALPM_GRAPH_STATE_PROCESSED; vertex->state = 1;
vertex = vertex->parent; vertex = vertex->parent;
if(!vertex) { if(!vertex) {
/* top level vertex reached, move to the next unprocessed vertex */ /* top level vertex reached, move to the next unprocessed vertex */
for(i = i->next; i; i = i->next) { for( vptr = vptr->next; vptr; vptr = vptr->next) {
vertex = i->data; vertex = vptr->data;
if(vertex->state == ALPM_GRAPH_STATE_UNPROCESSED) { if(vertex->state == 0) {
break; break;
} }
} }
@@ -698,8 +694,10 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
} }
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) { for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
alpm_pkg_t *pkg = j->data; alpm_pkg_t *pkg = j->data;
if((pkg->name_hash != dep->name_hash || strcmp(pkg->name, dep->name) != 0) /* with hash != hash, we can even skip the strcmp() as we know they can't
&& _alpm_depcmp(pkg, dep) && !alpm_pkg_find(excluding, pkg->name)) { * possibly be the same string */
if(pkg->name_hash != dep->name_hash && _alpm_depcmp(pkg, dep)
&& !alpm_pkg_find(excluding, pkg->name)) {
if(alpm_pkg_should_ignore(handle, pkg)) { if(alpm_pkg_should_ignore(handle, pkg)) {
alpm_question_install_ignorepkg_t question = { alpm_question_install_ignorepkg_t question = {
.type = ALPM_QUESTION_INSTALL_IGNOREPKG, .type = ALPM_QUESTION_INSTALL_IGNOREPKG,
@@ -954,3 +952,4 @@ char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
return str; return str;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* deps.h * deps.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org> * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -39,3 +39,5 @@ int _alpm_depcmp_provides(alpm_depend_t *dep, alpm_list_t *provisions);
int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep); int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep);
#endif /* ALPM_DEPS_H */ #endif /* ALPM_DEPS_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* diskspace.c * diskspace.c
* *
* Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -500,3 +500,5 @@ finish:
return 0; return 0;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* diskspace.h * diskspace.h
* *
* Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2010-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -61,3 +61,5 @@ int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
size_t num_files, off_t *file_sizes); size_t num_files, off_t *file_sizes);
#endif /* ALPM_DISKSPACE_H */ #endif /* ALPM_DISKSPACE_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* dload.c * download.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -90,8 +90,8 @@ static void inthandler(int UNUSED signum)
dload_interrupted = ABORT_SIGINT; dload_interrupted = ABORT_SIGINT;
} }
static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow, static int dload_progress_cb(void *file, double dltotal, double dlnow,
curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow) double UNUSED ultotal, double UNUSED ulnow)
{ {
struct dload_payload *payload = (struct dload_payload *)file; struct dload_payload *payload = (struct dload_payload *)file;
off_t current_size, total_size; off_t current_size, total_size;
@@ -106,7 +106,7 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
return 1; return 1;
} }
current_size = payload->initial_size + dlnow; current_size = payload->initial_size + (off_t)dlnow;
/* is our filesize still under any set limit? */ /* is our filesize still under any set limit? */
if(payload->max_size && current_size > payload->max_size) { if(payload->max_size && current_size > payload->max_size) {
@@ -119,31 +119,21 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
return 0; return 0;
} }
total_size = payload->initial_size + dltotal; total_size = payload->initial_size + (off_t)dltotal;
if(dltotal == 0 || payload->prevprogress == total_size) { if(DOUBLE_EQ(dltotal, 0.0) || payload->prevprogress == total_size) {
return 0; return 0;
} }
/* initialize the progress bar here to avoid displaying it when /* initialize the progress bar here to avoid displaying it when
* a repo is up to date and nothing gets downloaded. * a repo is up to date and nothing gets downloaded */
* payload->handle->dlcb will receive the remote_name if(payload->prevprogress == 0) {
* and the following arguments: payload->handle->dlcb(payload->remote_name, 0, (off_t)dltotal);
* 0, -1: download initialized
* 0, 0: non-download event
* x {x>0}, x: download complete
* x {x>0, x<y}, y {y > 0}: download progress, expected total is known */
if(!payload->cb_initialized) {
payload->handle->dlcb(payload->remote_name, 0, -1);
payload->cb_initialized = 1;
} }
if(payload->prevprogress == current_size) {
payload->handle->dlcb(payload->remote_name, 0, 0);
} else {
/* do NOT include initial_size since it wasn't part of the package's /* do NOT include initial_size since it wasn't part of the package's
* download_size (nor included in the total download size callback) */ * download_size (nor included in the total download size callback) */
payload->handle->dlcb(payload->remote_name, dlnow, dltotal); payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal);
}
payload->prevprogress = current_size; payload->prevprogress = current_size;
@@ -246,6 +236,47 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
return realsize; return realsize;
} }
static int dload_sockopt_cb(void *userdata, curl_socket_t curlfd,
curlsocktype purpose)
{
alpm_handle_t *handle = userdata;
int optval = 1;
/* this whole method is to prevent FTP control connections from going sour
* during a long data transfer; crappy firewalls love to drop otherwise idle
* connections if there is no traffic. */
if(purpose != CURLSOCKTYPE_IPCXN) {
return 0;
}
/* don't abort operation if any setsockopt fails, just log to debug */
if(setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval,
sizeof(optval)) < 0) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"Failed to set SO_KEEPALIVE on fd %d\n", curlfd);
}
else {
#ifdef TCP_KEEPIDLE
optval = 60;
if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&optval,
sizeof(optval)) < 0) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"Failed to set TCP_KEEPIDLE on fd %d\n", curlfd);
}
#endif
#ifdef TCP_KEEPINTVL
optval = 60;
if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&optval,
sizeof(optval)) < 0) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"Failed to set TCP_KEEPINTVL on fd %d\n", curlfd);
}
#endif
}
return 0;
}
static void curl_set_handle_opts(struct dload_payload *payload, static void curl_set_handle_opts(struct dload_payload *payload,
CURL *curl, char *error_buffer) CURL *curl, char *error_buffer)
{ {
@@ -259,22 +290,18 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_URL, payload->fileurl); curl_easy_setopt(curl, CURLOPT_URL, payload->fileurl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 10L);
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload);
if(!handle->disable_dl_timeout) { curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
}
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *)payload); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload);
curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, dload_sockopt_cb);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L); curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, (void *)handle);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
_alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl); _alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl);
@@ -375,7 +402,7 @@ static int curl_download_internal(struct dload_payload *payload,
/* shortcut to our handle within the payload */ /* shortcut to our handle within the payload */
alpm_handle_t *handle = payload->handle; alpm_handle_t *handle = payload->handle;
CURL *curl = get_libcurl_handle(handle); CURL *curl = get_libcurl_handle(handle);
handle->pm_errno = ALPM_ERR_OK; handle->pm_errno = 0;
/* make sure these are NULL */ /* make sure these are NULL */
FREE(payload->tempfile_name); FREE(payload->tempfile_name);
@@ -432,7 +459,6 @@ static int curl_download_internal(struct dload_payload *payload,
/* Ignore any SIGPIPE signals. With libcurl, these shouldn't be happening, /* Ignore any SIGPIPE signals. With libcurl, these shouldn't be happening,
* but better safe than sorry. Store the old signal handler first. */ * but better safe than sorry. Store the old signal handler first. */
mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe); mask_signal(SIGPIPE, SIG_IGN, &orig_sig_pipe);
dload_interrupted = 0;
mask_signal(SIGINT, &inthandler, &orig_sig_int); mask_signal(SIGINT, &inthandler, &orig_sig_int);
/* perform transfer */ /* perform transfer */
@@ -475,13 +501,6 @@ static int curl_download_internal(struct dload_payload *payload,
payload->remote_name, hostname); payload->remote_name, hostname);
} }
goto cleanup; goto cleanup;
case CURLE_COULDNT_RESOLVE_HOST:
payload->unlink_on_fail = 1;
handle->pm_errno = ALPM_ERR_SERVER_BAD_URL;
_alpm_log(handle, ALPM_LOG_ERROR,
_("failed retrieving file '%s' from %s : %s\n"),
payload->remote_name, hostname, error_buffer);
goto cleanup;
default: default:
/* delete zero length downloads */ /* delete zero length downloads */
if(fstat(fileno(localf), &st) == 0 && st.st_size == 0) { if(fstat(fileno(localf), &st) == 0 && st.st_size == 0) {
@@ -535,8 +554,7 @@ static int curl_download_internal(struct dload_payload *payload,
if(payload->content_disp_name) { if(payload->content_disp_name) {
/* content-disposition header has a better name for our file */ /* content-disposition header has a better name for our file */
free(payload->destfile_name); free(payload->destfile_name);
payload->destfile_name = get_fullpath(localpath, payload->destfile_name = get_fullpath(localpath, payload->content_disp_name, "");
get_filename(payload->content_disp_name), "");
} else { } else {
const char *effective_filename = strrchr(effective_url, '/'); const char *effective_filename = strrchr(effective_url, '/');
if(effective_filename && strlen(effective_filename) > 2) { if(effective_filename && strlen(effective_filename) > 2) {
@@ -588,7 +606,7 @@ cleanup:
unmask_signal(SIGINT, &orig_sig_int); unmask_signal(SIGINT, &orig_sig_int);
unmask_signal(SIGPIPE, &orig_sig_pipe); unmask_signal(SIGPIPE, &orig_sig_pipe);
/* if we were interrupted, trip the old handler */ /* if we were interrupted, trip the old handler */
if(dload_interrupted == ABORT_SIGINT) { if(dload_interrupted) {
raise(SIGINT); raise(SIGINT);
} }
@@ -684,7 +702,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
size_t len; size_t len;
len = strlen(final_pkg_url) + 5; len = strlen(final_pkg_url) + 5;
MALLOC(payload.fileurl, len, free(final_file); RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
snprintf(payload.fileurl, len, "%s.sig", final_pkg_url); snprintf(payload.fileurl, len, "%s.sig", final_pkg_url);
sig_filepath = filecache_find_url(handle, payload.fileurl); sig_filepath = filecache_find_url(handle, payload.fileurl);
@@ -734,13 +752,4 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
memset(payload, '\0', sizeof(*payload)); memset(payload, '\0', sizeof(*payload));
} }
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload) /* vim: set noet: */
{
ASSERT(payload, return);
FREE(payload->fileurl);
payload->initial_size += payload->prevprogress;
payload->prevprogress = 0;
payload->unlink_on_fail = 0;
payload->cb_initialized = 0;
}

View File

@@ -1,7 +1,7 @@
/* /*
* dload.h * dload.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -41,16 +41,16 @@ struct dload_payload {
int errors_ok; int errors_ok;
int unlink_on_fail; int unlink_on_fail;
int trust_remote_name; int trust_remote_name;
int cb_initialized;
#ifdef HAVE_LIBCURL #ifdef HAVE_LIBCURL
CURLcode curlerr; /* last error produced by curl */ CURLcode curlerr; /* last error produced by curl */
#endif #endif
}; };
void _alpm_dload_payload_reset(struct dload_payload *payload); void _alpm_dload_payload_reset(struct dload_payload *payload);
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload);
int _alpm_download(struct dload_payload *payload, const char *localpath, int _alpm_download(struct dload_payload *payload, const char *localpath,
char **final_file, const char **final_url); char **final_file, const char **final_url);
#endif /* ALPM_DLOAD_H */ #endif /* ALPM_DLOAD_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* error.c * error.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -159,11 +159,10 @@ const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
return _("gpgme error"); return _("gpgme error");
case ALPM_ERR_EXTERNAL_DOWNLOAD: case ALPM_ERR_EXTERNAL_DOWNLOAD:
return _("error invoking external downloader"); return _("error invoking external downloader");
/* Missing compile-time features */
case ALPM_ERR_MISSING_CAPABILITY_SIGNATURES:
return _("compiled without signature support");
/* Unknown error! */ /* Unknown error! */
default: default:
return _("unexpected error"); return _("unexpected error");
} }
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* filelist.c * filelist.c
* *
* Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2012-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -111,7 +111,7 @@ alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
/* Helper function for comparing files list entries /* Helper function for comparing files list entries
*/ */
static int _alpm_files_cmp(const void *f1, const void *f2) int _alpm_files_cmp(const void *f1, const void *f2)
{ {
const alpm_file_t *file1 = f1; const alpm_file_t *file1 = f1;
const alpm_file_t *file2 = f2; const alpm_file_t *file2 = f2;
@@ -133,15 +133,4 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
sizeof(alpm_file_t), _alpm_files_cmp); sizeof(alpm_file_t), _alpm_files_cmp);
} }
void _alpm_filelist_sort(alpm_filelist_t *filelist) /* vim: set noet: */
{
size_t i;
for(i = 1; i < filelist->count; i++) {
if(strcmp(filelist->files[i - 1].name, filelist->files[i].name) > 0) {
/* filelist is not pre-sorted */
qsort(filelist->files, filelist->count,
sizeof(alpm_file_t), _alpm_files_cmp);
return;
}
}
}

View File

@@ -1,7 +1,7 @@
/* /*
* filelist.h * filelist.h
* *
* Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2012-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -27,6 +27,8 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA, alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
alpm_filelist_t *filesB); alpm_filelist_t *filesB);
void _alpm_filelist_sort(alpm_filelist_t *filelist); int _alpm_files_cmp(const void *f1, const void *f2);
#endif /* ALPM_FILELIST_H */ #endif /* ALPM_FILELIST_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* graph.c - helpful graph structure and setup/teardown methods * graph.c - helpful graph structure and setup/teardown methods
* *
* Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2007-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -36,3 +36,5 @@ void _alpm_graph_free(void *data)
alpm_list_free(graph->children); alpm_list_free(graph->children);
free(graph); free(graph);
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* graph.h - helpful graph structure and setup/teardown methods * graph.h - helpful graph structure and setup/teardown methods
* *
* Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2007-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -23,22 +23,18 @@
#include "alpm_list.h" #include "alpm_list.h"
enum __alpm_graph_vertex_state {
ALPM_GRAPH_STATE_UNPROCESSED,
ALPM_GRAPH_STATE_PROCESSING,
ALPM_GRAPH_STATE_PROCESSED
};
typedef struct __alpm_graph_t { typedef struct __alpm_graph_t {
void *data; void *data;
struct __alpm_graph_t *parent; /* where did we come from? */ struct __alpm_graph_t *parent; /* where did we come from? */
alpm_list_t *children; alpm_list_t *children;
alpm_list_t *iterator; /* used for DFS without recursion */ alpm_list_t *childptr; /* points to a child in children list */
off_t weight; /* weight of the node */ off_t weight; /* weight of the node */
enum __alpm_graph_vertex_state state; signed char state; /* 0: untouched, -1: entered, other: leaving time */
} alpm_graph_t; } alpm_graph_t;
alpm_graph_t *_alpm_graph_new(void); alpm_graph_t *_alpm_graph_new(void);
void _alpm_graph_free(void *data); void _alpm_graph_free(void *data);
#endif /* ALPM_GRAPH_H */ #endif /* ALPM_GRAPH_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* group.c * group.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -49,3 +49,5 @@ void _alpm_group_free(alpm_group_t *grp)
alpm_list_free(grp->packages); alpm_list_free(grp->packages);
FREE(grp); FREE(grp);
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* group.h * group.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -26,3 +26,5 @@ alpm_group_t *_alpm_group_new(const char *name);
void _alpm_group_free(alpm_group_t *grp); void _alpm_group_free(alpm_group_t *grp);
#endif /* ALPM_GROUP_H */ #endif /* ALPM_GROUP_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* handle.c * handle.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org> * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -92,7 +92,6 @@ void _alpm_handle_free(alpm_handle_t *handle)
FREELIST(handle->noextract); FREELIST(handle->noextract);
FREELIST(handle->ignorepkg); FREELIST(handle->ignorepkg);
FREELIST(handle->ignoregroup); FREELIST(handle->ignoregroup);
FREELIST(handle->overwrite_files);
alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free); alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
alpm_list_free(handle->assumeinstalled); alpm_list_free(handle->assumeinstalled);
@@ -135,7 +134,6 @@ int _alpm_handle_lock(alpm_handle_t *handle)
*/ */
int SYMEXPORT alpm_unlock(alpm_handle_t *handle) int SYMEXPORT alpm_unlock(alpm_handle_t *handle)
{ {
ASSERT(handle != NULL, return -1);
ASSERT(handle->lockfile != NULL, return 0); ASSERT(handle->lockfile != NULL, return 0);
ASSERT(handle->lockfd >= 0, return 0); ASSERT(handle->lockfd >= 0, return 0);
@@ -285,12 +283,6 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregroups(alpm_handle_t *handle)
return handle->ignoregroup; return handle->ignoregroup;
} }
alpm_list_t SYMEXPORT *alpm_option_get_overwrite_files(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->overwrite_files;
}
alpm_list_t SYMEXPORT *alpm_option_get_assumeinstalled(alpm_handle_t *handle) alpm_list_t SYMEXPORT *alpm_option_get_assumeinstalled(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return NULL); CHECK_HANDLE(handle, return NULL);
@@ -665,21 +657,6 @@ int SYMEXPORT alpm_option_remove_ignoregroup(alpm_handle_t *handle, const char *
return _alpm_option_strlist_rem(handle, &(handle->ignoregroup), grp); return _alpm_option_strlist_rem(handle, &(handle->ignoregroup), grp);
} }
int SYMEXPORT alpm_option_add_overwrite_file(alpm_handle_t *handle, const char *glob)
{
return _alpm_option_strlist_add(handle, &(handle->overwrite_files), glob);
}
int SYMEXPORT alpm_option_set_overwrite_files(alpm_handle_t *handle, alpm_list_t *globs)
{
return _alpm_option_strlist_set(handle, &(handle->overwrite_files), globs);
}
int SYMEXPORT alpm_option_remove_overwrite_file(alpm_handle_t *handle, const char *glob)
{
return _alpm_option_strlist_rem(handle, &(handle->overwrite_files), glob);
}
int SYMEXPORT alpm_option_add_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep) int SYMEXPORT alpm_option_add_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep)
{ {
alpm_depend_t *depcpy; alpm_depend_t *depcpy;
@@ -800,43 +777,40 @@ int SYMEXPORT alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext)
} }
int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle, int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
int level) alpm_siglevel_t level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(level == ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
}
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
handle->siglevel = level; handle->siglevel = level;
#else #else
if(level != 0) { if(level != 0 && level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_MISSING_CAPABILITY_SIGNATURES, -1); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
} }
#endif #endif
return 0; return 0;
} }
int SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle) alpm_siglevel_t SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
return handle->siglevel; return handle->siglevel;
} }
int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
int level) alpm_siglevel_t level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
handle->localfilesiglevel = level; handle->localfilesiglevel = level;
#else #else
if(level != 0 && level != ALPM_SIG_USE_DEFAULT) { if(level != 0 && level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_MISSING_CAPABILITY_SIGNATURES, -1); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
} }
#endif #endif
return 0; return 0;
} }
int SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle) alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(handle->localfilesiglevel & ALPM_SIG_USE_DEFAULT) { if(handle->localfilesiglevel & ALPM_SIG_USE_DEFAULT) {
@@ -847,20 +821,20 @@ int SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
} }
int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
int level) alpm_siglevel_t level)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
handle->remotefilesiglevel = level; handle->remotefilesiglevel = level;
#else #else
if(level != 0 && level != ALPM_SIG_USE_DEFAULT) { if(level != 0 && level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_MISSING_CAPABILITY_SIGNATURES, -1); RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
} }
#endif #endif
return 0; return 0;
} }
int SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle) alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
{ {
CHECK_HANDLE(handle, return -1); CHECK_HANDLE(handle, return -1);
if(handle->remotefilesiglevel & ALPM_SIG_USE_DEFAULT) { if(handle->remotefilesiglevel & ALPM_SIG_USE_DEFAULT) {
@@ -870,14 +844,4 @@ int SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
} }
} }
int SYMEXPORT alpm_option_set_disable_dl_timeout(alpm_handle_t *handle, /* vim: set noet: */
unsigned short disable_dl_timeout)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBCURL
handle->disable_dl_timeout = disable_dl_timeout;
#else
(void)disable_dl_timeout; /* silence unused variable warnings */
#endif
return 0;
}

View File

@@ -1,7 +1,7 @@
/* /*
* handle.h * handle.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -60,7 +60,6 @@ struct __alpm_handle_t {
#ifdef HAVE_LIBCURL #ifdef HAVE_LIBCURL
/* libcurl handle */ /* libcurl handle */
CURL *curl; /* reusable curl_easy handle */ CURL *curl; /* reusable curl_easy handle */
unsigned short disable_dl_timeout;
#endif #endif
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
@@ -84,7 +83,6 @@ struct __alpm_handle_t {
char *gpgdir; /* Directory where GnuPG files are stored */ char *gpgdir; /* Directory where GnuPG files are stored */
alpm_list_t *cachedirs; /* Paths to pacman cache directories */ alpm_list_t *cachedirs; /* Paths to pacman cache directories */
alpm_list_t *hookdirs; /* Paths to hook directories */ alpm_list_t *hookdirs; /* Paths to hook directories */
alpm_list_t *overwrite_files; /* Paths that may be overwritten */
/* package lists */ /* package lists */
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */ alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
@@ -99,10 +97,10 @@ struct __alpm_handle_t {
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */ int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
int checkspace; /* Check disk space before installing */ int checkspace; /* Check disk space before installing */
char *dbext; /* Sync DB extension */ char *dbext; /* Sync DB extension */
int siglevel; /* Default signature verification level */ alpm_siglevel_t siglevel; /* Default signature verification level */
int localfilesiglevel; /* Signature verification level for local file alpm_siglevel_t localfilesiglevel; /* Signature verification level for local file
upgrade operations */ upgrade operations */
int remotefilesiglevel; /* Signature verification level for remote file alpm_siglevel_t remotefilesiglevel; /* Signature verification level for remote file
upgrade operations */ upgrade operations */
/* error code */ /* error code */
@@ -126,3 +124,5 @@ alpm_errno_t _alpm_set_directory_option(const char *value,
char **storage, int must_exist); char **storage, int must_exist);
#endif /* ALPM_HANDLE_H */ #endif /* ALPM_HANDLE_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* hook.c * hook.c
* *
* Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -267,7 +267,6 @@ static int _alpm_hook_parse_cb(const char *file, int line,
struct _alpm_hook_t *hook = ctx->hook; struct _alpm_hook_t *hook = ctx->hook;
#define error(...) _alpm_log(handle, ALPM_LOG_ERROR, __VA_ARGS__); return 1; #define error(...) _alpm_log(handle, ALPM_LOG_ERROR, __VA_ARGS__); return 1;
#define warning(...) _alpm_log(handle, ALPM_LOG_WARNING, __VA_ARGS__);
if(!section && !key) { if(!section && !key) {
error(_("error while reading hook %s: %s\n"), file, strerror(errno)); error(_("error while reading hook %s: %s\n"), file, strerror(errno));
@@ -297,9 +296,6 @@ static int _alpm_hook_parse_cb(const char *file, int line,
error(_("hook %s line %d: invalid value %s\n"), file, line, value); error(_("hook %s line %d: invalid value %s\n"), file, line, value);
} }
} else if(strcmp(key, "Type") == 0) { } else if(strcmp(key, "Type") == 0) {
if(t->type != 0) {
warning(_("hook %s line %d: overwriting previous definition of %s\n"), file, line, "Type");
}
if(strcmp(value, "Package") == 0) { if(strcmp(value, "Package") == 0) {
t->type = ALPM_HOOK_TYPE_PACKAGE; t->type = ALPM_HOOK_TYPE_PACKAGE;
} else if(strcmp(value, "File") == 0) { } else if(strcmp(value, "File") == 0) {
@@ -316,9 +312,6 @@ static int _alpm_hook_parse_cb(const char *file, int line,
} }
} else if(strcmp(section, "Action") == 0) { } else if(strcmp(section, "Action") == 0) {
if(strcmp(key, "When") == 0) { if(strcmp(key, "When") == 0) {
if(hook->when != 0) {
warning(_("hook %s line %d: overwriting previous definition of %s\n"), file, line, "When");
}
if(strcmp(value, "PreTransaction") == 0) { if(strcmp(value, "PreTransaction") == 0) {
hook->when = ALPM_HOOK_PRE_TRANSACTION; hook->when = ALPM_HOOK_PRE_TRANSACTION;
} else if(strcmp(value, "PostTransaction") == 0) { } else if(strcmp(value, "PostTransaction") == 0) {
@@ -327,10 +320,6 @@ static int _alpm_hook_parse_cb(const char *file, int line,
error(_("hook %s line %d: invalid value %s\n"), file, line, value); error(_("hook %s line %d: invalid value %s\n"), file, line, value);
} }
} else if(strcmp(key, "Description") == 0) { } else if(strcmp(key, "Description") == 0) {
if(hook->desc != NULL) {
warning(_("hook %s line %d: overwriting previous definition of %s\n"), file, line, "Description");
FREE(hook->desc);
}
STRDUP(hook->desc, value, return 1); STRDUP(hook->desc, value, return 1);
} else if(strcmp(key, "Depends") == 0) { } else if(strcmp(key, "Depends") == 0) {
char *val; char *val;
@@ -341,10 +330,6 @@ static int _alpm_hook_parse_cb(const char *file, int line,
} else if(strcmp(key, "NeedsTargets") == 0) { } else if(strcmp(key, "NeedsTargets") == 0) {
hook->needs_targets = 1; hook->needs_targets = 1;
} else if(strcmp(key, "Exec") == 0) { } else if(strcmp(key, "Exec") == 0) {
if(hook->cmd != NULL) {
warning(_("hook %s line %d: overwriting previous definition of %s\n"), file, line, "Exec");
_alpm_wordsplit_free(hook->cmd);
}
if((hook->cmd = _alpm_wordsplit(value)) == NULL) { if((hook->cmd = _alpm_wordsplit(value)) == NULL) {
if(errno == EINVAL) { if(errno == EINVAL) {
error(_("hook %s line %d: invalid value %s\n"), file, line, value); error(_("hook %s line %d: invalid value %s\n"), file, line, value);
@@ -359,7 +344,6 @@ static int _alpm_hook_parse_cb(const char *file, int line,
} }
#undef error #undef error
#undef warning
return 0; return 0;
} }
@@ -551,16 +535,7 @@ static int _alpm_hook_triggered(alpm_handle_t *handle, struct _alpm_hook_t *hook
static int _alpm_hook_cmp(struct _alpm_hook_t *h1, struct _alpm_hook_t *h2) static int _alpm_hook_cmp(struct _alpm_hook_t *h1, struct _alpm_hook_t *h2)
{ {
size_t suflen = strlen(ALPM_HOOK_SUFFIX), l1, l2; return strcmp(h1->name, h2->name);
int ret;
l1 = strlen(h1->name) - suflen;
l2 = strlen(h2->name) - suflen;
/* exclude the suffixes from comparison */
ret = strncmp(h1->name, h2->name, l1 <= l2 ? l1 : l2);
if(ret == 0 && l1 != l2) {
return l1 < l2 ? -1 : 1;
}
return ret;
} }
static alpm_list_t *find_hook(alpm_list_t *haystack, const void *needle) static alpm_list_t *find_hook(alpm_list_t *haystack, const void *needle)
@@ -643,7 +618,8 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
alpm_event_hook_t event = { .when = when }; alpm_event_hook_t event = { .when = when };
alpm_event_hook_run_t hook_event; alpm_event_hook_run_t hook_event;
alpm_list_t *i, *hooks = NULL, *hooks_triggered = NULL; alpm_list_t *i, *hooks = NULL, *hooks_triggered = NULL;
size_t suflen = strlen(ALPM_HOOK_SUFFIX), triggered = 0; const char *suffix = ".hook";
size_t suflen = strlen(suffix), triggered = 0;
int ret = 0; int ret = 0;
for(i = alpm_list_last(handle->hookdirs); i; i = alpm_list_previous(i)) { for(i = alpm_list_last(handle->hookdirs); i; i = alpm_list_previous(i)) {
@@ -689,7 +665,7 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
memcpy(path + dirlen, entry->d_name, name_len + 1); memcpy(path + dirlen, entry->d_name, name_len + 1);
if(name_len < suflen if(name_len < suflen
|| strcmp(entry->d_name + name_len - suflen, ALPM_HOOK_SUFFIX) != 0) { || strcmp(entry->d_name + name_len - suflen, suffix) != 0) {
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping non-hook file %s\n", path); _alpm_log(handle, ALPM_LOG_DEBUG, "skipping non-hook file %s\n", path);
continue; continue;
} }
@@ -790,3 +766,5 @@ cleanup:
return ret; return ret;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* hook.h * hook.h
* *
* Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2015-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -22,8 +22,8 @@
#include "alpm.h" #include "alpm.h"
#define ALPM_HOOK_SUFFIX ".hook"
int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when); int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when);
#endif /* ALPM_HOOK_H */ #endif /* ALPM_HOOK_H */
/* vim: set noet: */

View File

@@ -7,7 +7,6 @@ Name: libalpm
Description: Arch Linux package management library Description: Arch Linux package management library
URL: http://www.archlinux.org/pacman/ URL: http://www.archlinux.org/pacman/
Version: @LIB_VERSION@ Version: @LIB_VERSION@
Requires.private: libarchive @pc_crypto@ @pc_libcurl@
Cflags: -I${includedir} @LFS_CFLAGS@ Cflags: -I${includedir} @LFS_CFLAGS@
Libs: -L${libdir} -lalpm Libs: -L${libdir} -lalpm
Libs.private: @LIBS@ @GPGME_LIBS@ Libs.private: @LIBS@ @LIBARCHIVE_LIBS@ @LIBSSL_LIBS@ @LIBCURL_LIBS@ @GPGME_LIBS@

View File

@@ -4,7 +4,7 @@
/* /*
* libarchive-compat.h * libarchive-compat.h
* *
* Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -69,3 +69,5 @@ static inline int _alpm_archive_read_support_filter_all(struct archive *archive)
} }
#endif /* LIBARCHIVE_COMPAT_H */ #endif /* LIBARCHIVE_COMPAT_H */
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* log.c * log.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -121,3 +121,5 @@ void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag, const char *fmt, ...
handle->logcb(flag, fmt, args); handle->logcb(flag, fmt, args);
va_end(args); va_end(args);
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* log.h * log.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -28,3 +28,5 @@ void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag,
const char *fmt, ...) __attribute__((format(printf,3,4))); const char *fmt, ...) __attribute__((format(printf,3,4)));
#endif /* ALPM_LOG_H */ #endif /* ALPM_LOG_H */
/* vim: set noet: */

333
lib/libalpm/md5.c Normal file
View File

@@ -0,0 +1,333 @@
/*
* RFC 1321 compliant MD5 implementation
*
* Copyright (C) 2006-2010, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* The MD5 algorithm was designed by Ron Rivest in 1991.
*
* http://www.ietf.org/rfc/rfc1321.txt
*/
/*
* Pacman Notes:
*
* Taken from the PolarSSL project at http://polarssl.org under terms of the
* GPL. This is from version 1.0.0 of the library, and has been modified
* as following, which may be helpful for future updates:
* * remove "polarssl/config.h" include
* * change include from "polarssl/md5.h" to "md5.h"
* * removal of HMAC code
* * removal of SELF_TEST code
* * removal of ipad and opad from the md5_context struct in md5.h
* * increase the size of buffer for performance reasons
* * change 'unsigned long' to uint32_t
*/
#include <stdio.h>
#include <stdint.h>
#include "md5.h"
/*
* 32-bit integer manipulation macros (little endian)
*/
#ifndef GET_U32_LE
#define GET_U32_LE(n,b,i) \
{ \
(n) = ( (uint32_t) (b)[(i) ] ) \
| ( (uint32_t) (b)[(i) + 1] << 8 ) \
| ( (uint32_t) (b)[(i) + 2] << 16 ) \
| ( (uint32_t) (b)[(i) + 3] << 24 ); \
}
#endif
#ifndef PUT_U32_LE
#define PUT_U32_LE(n,b,i) \
{ \
(b)[(i) ] = (unsigned char) ( (n) ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \
(b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \
}
#endif
/*
* MD5 context setup
*/
static void md5_starts( md5_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xEFCDAB89;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
}
static void md5_process( md5_context *ctx, const unsigned char data[64] )
{
uint32_t X[16], A, B, C, D;
GET_U32_LE( X[ 0], data, 0 );
GET_U32_LE( X[ 1], data, 4 );
GET_U32_LE( X[ 2], data, 8 );
GET_U32_LE( X[ 3], data, 12 );
GET_U32_LE( X[ 4], data, 16 );
GET_U32_LE( X[ 5], data, 20 );
GET_U32_LE( X[ 6], data, 24 );
GET_U32_LE( X[ 7], data, 28 );
GET_U32_LE( X[ 8], data, 32 );
GET_U32_LE( X[ 9], data, 36 );
GET_U32_LE( X[10], data, 40 );
GET_U32_LE( X[11], data, 44 );
GET_U32_LE( X[12], data, 48 );
GET_U32_LE( X[13], data, 52 );
GET_U32_LE( X[14], data, 56 );
GET_U32_LE( X[15], data, 60 );
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define P(a,b,c,d,k,s,t) \
{ \
a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \
}
A = ctx->state[0];
B = ctx->state[1];
C = ctx->state[2];
D = ctx->state[3];
#define F(x,y,z) (z ^ (x & (y ^ z)))
P( A, B, C, D, 0, 7, 0xD76AA478 );
P( D, A, B, C, 1, 12, 0xE8C7B756 );
P( C, D, A, B, 2, 17, 0x242070DB );
P( B, C, D, A, 3, 22, 0xC1BDCEEE );
P( A, B, C, D, 4, 7, 0xF57C0FAF );
P( D, A, B, C, 5, 12, 0x4787C62A );
P( C, D, A, B, 6, 17, 0xA8304613 );
P( B, C, D, A, 7, 22, 0xFD469501 );
P( A, B, C, D, 8, 7, 0x698098D8 );
P( D, A, B, C, 9, 12, 0x8B44F7AF );
P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
P( B, C, D, A, 11, 22, 0x895CD7BE );
P( A, B, C, D, 12, 7, 0x6B901122 );
P( D, A, B, C, 13, 12, 0xFD987193 );
P( C, D, A, B, 14, 17, 0xA679438E );
P( B, C, D, A, 15, 22, 0x49B40821 );
#undef F
#define F(x,y,z) (y ^ (z & (x ^ y)))
P( A, B, C, D, 1, 5, 0xF61E2562 );
P( D, A, B, C, 6, 9, 0xC040B340 );
P( C, D, A, B, 11, 14, 0x265E5A51 );
P( B, C, D, A, 0, 20, 0xE9B6C7AA );
P( A, B, C, D, 5, 5, 0xD62F105D );
P( D, A, B, C, 10, 9, 0x02441453 );
P( C, D, A, B, 15, 14, 0xD8A1E681 );
P( B, C, D, A, 4, 20, 0xE7D3FBC8 );
P( A, B, C, D, 9, 5, 0x21E1CDE6 );
P( D, A, B, C, 14, 9, 0xC33707D6 );
P( C, D, A, B, 3, 14, 0xF4D50D87 );
P( B, C, D, A, 8, 20, 0x455A14ED );
P( A, B, C, D, 13, 5, 0xA9E3E905 );
P( D, A, B, C, 2, 9, 0xFCEFA3F8 );
P( C, D, A, B, 7, 14, 0x676F02D9 );
P( B, C, D, A, 12, 20, 0x8D2A4C8A );
#undef F
#define F(x,y,z) (x ^ y ^ z)
P( A, B, C, D, 5, 4, 0xFFFA3942 );
P( D, A, B, C, 8, 11, 0x8771F681 );
P( C, D, A, B, 11, 16, 0x6D9D6122 );
P( B, C, D, A, 14, 23, 0xFDE5380C );
P( A, B, C, D, 1, 4, 0xA4BEEA44 );
P( D, A, B, C, 4, 11, 0x4BDECFA9 );
P( C, D, A, B, 7, 16, 0xF6BB4B60 );
P( B, C, D, A, 10, 23, 0xBEBFBC70 );
P( A, B, C, D, 13, 4, 0x289B7EC6 );
P( D, A, B, C, 0, 11, 0xEAA127FA );
P( C, D, A, B, 3, 16, 0xD4EF3085 );
P( B, C, D, A, 6, 23, 0x04881D05 );
P( A, B, C, D, 9, 4, 0xD9D4D039 );
P( D, A, B, C, 12, 11, 0xE6DB99E5 );
P( C, D, A, B, 15, 16, 0x1FA27CF8 );
P( B, C, D, A, 2, 23, 0xC4AC5665 );
#undef F
#define F(x,y,z) (y ^ (x | ~z))
P( A, B, C, D, 0, 6, 0xF4292244 );
P( D, A, B, C, 7, 10, 0x432AFF97 );
P( C, D, A, B, 14, 15, 0xAB9423A7 );
P( B, C, D, A, 5, 21, 0xFC93A039 );
P( A, B, C, D, 12, 6, 0x655B59C3 );
P( D, A, B, C, 3, 10, 0x8F0CCC92 );
P( C, D, A, B, 10, 15, 0xFFEFF47D );
P( B, C, D, A, 1, 21, 0x85845DD1 );
P( A, B, C, D, 8, 6, 0x6FA87E4F );
P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
P( C, D, A, B, 6, 15, 0xA3014314 );
P( B, C, D, A, 13, 21, 0x4E0811A1 );
P( A, B, C, D, 4, 6, 0xF7537E82 );
P( D, A, B, C, 11, 10, 0xBD3AF235 );
P( C, D, A, B, 2, 15, 0x2AD7D2BB );
P( B, C, D, A, 9, 21, 0xEB86D391 );
#undef F
ctx->state[0] += A;
ctx->state[1] += B;
ctx->state[2] += C;
ctx->state[3] += D;
}
/*
* MD5 process buffer
*/
static void md5_update( md5_context *ctx, const unsigned char *input, size_t ilen )
{
size_t fill;
uint32_t left;
if( ilen <= 0 )
return;
left = ctx->total[0] & 0x3F;
fill = 64 - left;
ctx->total[0] += (uint32_t) ilen;
ctx->total[0] &= 0xFFFFFFFF;
if( ctx->total[0] < (uint32_t) ilen )
ctx->total[1]++;
if( left && ilen >= fill )
{
memcpy( (void *) (ctx->buffer + left),
(void *) input, fill );
md5_process( ctx, ctx->buffer );
input += fill;
ilen -= fill;
left = 0;
}
while( ilen >= 64 )
{
md5_process( ctx, input );
input += 64;
ilen -= 64;
}
if( ilen > 0 )
{
memcpy( (void *) (ctx->buffer + left),
(void *) input, ilen );
}
}
static const unsigned char md5_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*
* MD5 final digest
*/
static void md5_finish( md5_context *ctx, unsigned char output[16] )
{
uint32_t last, padn;
uint32_t high, low;
unsigned char msglen[8];
high = ( ctx->total[0] >> 29 )
| ( ctx->total[1] << 3 );
low = ( ctx->total[0] << 3 );
PUT_U32_LE( low, msglen, 0 );
PUT_U32_LE( high, msglen, 4 );
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
md5_update( ctx, (unsigned char *) md5_padding, padn );
md5_update( ctx, msglen, 8 );
PUT_U32_LE( ctx->state[0], output, 0 );
PUT_U32_LE( ctx->state[1], output, 4 );
PUT_U32_LE( ctx->state[2], output, 8 );
PUT_U32_LE( ctx->state[3], output, 12 );
}
/*
* output = MD5( input buffer )
*/
void md5( const unsigned char *input, size_t ilen, unsigned char output[16] )
{
md5_context ctx;
md5_starts( &ctx );
md5_update( &ctx, input, ilen );
md5_finish( &ctx, output );
memset( &ctx, 0, sizeof( md5_context ) );
}
/*
* output = MD5( file contents )
*/
int md5_file( const char *path, unsigned char output[16] )
{
FILE *f;
size_t n;
md5_context ctx;
unsigned char buf[4096];
if( ( f = fopen( path, "rb" ) ) == NULL )
return( 1 );
md5_starts( &ctx );
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
md5_update( &ctx, buf, n );
md5_finish( &ctx, output );
memset( &ctx, 0, sizeof( md5_context ) );
if( ferror( f ) != 0 )
{
fclose( f );
return( 2 );
}
fclose( f );
return( 0 );
}

60
lib/libalpm/md5.h Normal file
View File

@@ -0,0 +1,60 @@
/*
* RFC 1321 compliant MD5 implementation
*
* Copyright (C) 2006-2010, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MD5_H
#define MD5_H
#include <string.h>
/**
* \brief MD5 context structure
*/
typedef struct
{
unsigned long total[2]; /*!< number of bytes processed */
unsigned long state[4]; /*!< intermediate digest state */
unsigned char buffer[64]; /*!< data block being processed */
}
md5_context;
/**
* \brief Output = MD5( input buffer )
*
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD5 checksum result
*/
void md5( const unsigned char *input, size_t ilen, unsigned char output[16] );
/**
* \brief Output = MD5( file contents )
*
* \param path input file name
* \param output MD5 checksum result
*
* \return 0 if successful, 1 if fopen failed,
* or 2 if fread failed
*/
int md5_file( const char *path, unsigned char output[16] );
#endif /* md5.h */

View File

@@ -1,33 +0,0 @@
libalpm_sources = files('''
add.h add.c
alpm.h alpm.c
alpm_list.h alpm_list.c
backup.h backup.c
base64.h base64.c
be_local.c
be_package.c
be_sync.c
conflict.h conflict.c
db.h db.c
delta.h delta.c
deps.h deps.c
diskspace.h diskspace.c
dload.h dload.c
error.c
filelist.h filelist.c
graph.h graph.c
group.h group.c
handle.h handle.c
hook.h hook.c
libarchive-compat.h
log.h log.c
package.h package.c
pkghash.h pkghash.c
rawstr.c
remove.h remove.c
signing.c signing.h
sync.h sync.c
trans.h trans.c
util.h util.c
version.c
'''.split())

View File

@@ -1,7 +1,7 @@
/* /*
* package.c * package.c
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu> * Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
@@ -60,7 +60,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
int retval; int retval;
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
/* We only inspect packages from sync repositories */ /* We only inspect packages from sync repositories */
ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB, ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1)); RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
@@ -69,9 +69,9 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM); retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
FREE(fpath); if(retval == 0) {
return 0;
if(retval == 1) { } else if(retval == 1) {
pkg->handle->pm_errno = ALPM_ERR_PKG_INVALID; pkg->handle->pm_errno = ALPM_ERR_PKG_INVALID;
retval = -1; retval = -1;
} }
@@ -92,15 +92,13 @@ static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager;
static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; } static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; }
static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; } static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; }
static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; } static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
static int _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; } static alpm_pkgvalidation_t _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; } static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; }
static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; } static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; }
static alpm_list_t *_pkg_get_groups(alpm_pkg_t *pkg) { return pkg->groups; } static alpm_list_t *_pkg_get_groups(alpm_pkg_t *pkg) { return pkg->groups; }
static alpm_list_t *_pkg_get_depends(alpm_pkg_t *pkg) { return pkg->depends; } static alpm_list_t *_pkg_get_depends(alpm_pkg_t *pkg) { return pkg->depends; }
static alpm_list_t *_pkg_get_optdepends(alpm_pkg_t *pkg) { return pkg->optdepends; } static alpm_list_t *_pkg_get_optdepends(alpm_pkg_t *pkg) { return pkg->optdepends; }
static alpm_list_t *_pkg_get_checkdepends(alpm_pkg_t *pkg) { return pkg->checkdepends; }
static alpm_list_t *_pkg_get_makedepends(alpm_pkg_t *pkg) { return pkg->makedepends; }
static alpm_list_t *_pkg_get_conflicts(alpm_pkg_t *pkg) { return pkg->conflicts; } static alpm_list_t *_pkg_get_conflicts(alpm_pkg_t *pkg) { return pkg->conflicts; }
static alpm_list_t *_pkg_get_provides(alpm_pkg_t *pkg) { return pkg->provides; } static alpm_list_t *_pkg_get_provides(alpm_pkg_t *pkg) { return pkg->provides; }
static alpm_list_t *_pkg_get_replaces(alpm_pkg_t *pkg) { return pkg->replaces; } static alpm_list_t *_pkg_get_replaces(alpm_pkg_t *pkg) { return pkg->replaces; }
@@ -163,8 +161,6 @@ struct pkg_operations default_pkg_ops = {
.get_groups = _pkg_get_groups, .get_groups = _pkg_get_groups,
.get_depends = _pkg_get_depends, .get_depends = _pkg_get_depends,
.get_optdepends = _pkg_get_optdepends, .get_optdepends = _pkg_get_optdepends,
.get_checkdepends = _pkg_get_checkdepends,
.get_makedepends = _pkg_get_makedepends,
.get_conflicts = _pkg_get_conflicts, .get_conflicts = _pkg_get_conflicts,
.get_provides = _pkg_get_provides, .get_provides = _pkg_get_provides,
.get_replaces = _pkg_get_replaces, .get_replaces = _pkg_get_replaces,
@@ -188,210 +184,196 @@ struct pkg_operations default_pkg_ops = {
const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->filename; return pkg->filename;
} }
const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_base(pkg); return pkg->ops->get_base(pkg);
} }
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->name; return pkg->name;
} }
const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->version; return pkg->version;
} }
alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg) alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->origin; return pkg->origin;
} }
const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_desc(pkg); return pkg->ops->get_desc(pkg);
} }
const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_url(pkg); return pkg->ops->get_url(pkg);
} }
alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg) alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_builddate(pkg); return pkg->ops->get_builddate(pkg);
} }
alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg) alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_installdate(pkg); return pkg->ops->get_installdate(pkg);
} }
const char SYMEXPORT *alpm_pkg_get_packager(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_packager(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_packager(pkg); return pkg->ops->get_packager(pkg);
} }
const char SYMEXPORT *alpm_pkg_get_md5sum(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_md5sum(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->md5sum; return pkg->md5sum;
} }
const char SYMEXPORT *alpm_pkg_get_sha256sum(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_sha256sum(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->sha256sum; return pkg->sha256sum;
} }
const char SYMEXPORT *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->base64_sig; return pkg->base64_sig;
} }
const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg) const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_arch(pkg); return pkg->ops->get_arch(pkg);
} }
off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg) off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->size; return pkg->size;
} }
off_t SYMEXPORT alpm_pkg_get_isize(alpm_pkg_t *pkg) off_t SYMEXPORT alpm_pkg_get_isize(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_isize(pkg); return pkg->ops->get_isize(pkg);
} }
alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg) alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_reason(pkg); return pkg->ops->get_reason(pkg);
} }
int SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg) alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_validation(pkg); return pkg->ops->get_validation(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_licenses(pkg); return pkg->ops->get_licenses(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_groups(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_groups(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_groups(pkg); return pkg->ops->get_groups(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_depends(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_depends(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_depends(pkg); return pkg->ops->get_depends(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_optdepends(pkg); return pkg->ops->get_optdepends(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_checkdepends(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_checkdepends(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_makedepends(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_makedepends(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_conflicts(pkg); return pkg->ops->get_conflicts(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_provides(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_provides(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_provides(pkg); return pkg->ops->get_provides(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_replaces(pkg); return pkg->ops->get_replaces(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->deltas; return pkg->deltas;
} }
alpm_filelist_t SYMEXPORT *alpm_pkg_get_files(alpm_pkg_t *pkg) alpm_filelist_t SYMEXPORT *alpm_pkg_get_files(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_files(pkg); return pkg->ops->get_files(pkg);
} }
alpm_list_t SYMEXPORT *alpm_pkg_get_backup(alpm_pkg_t *pkg) alpm_list_t SYMEXPORT *alpm_pkg_get_backup(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->get_backup(pkg); return pkg->ops->get_backup(pkg);
} }
@@ -400,7 +382,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
/* Sanity checks */ /* Sanity checks */
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL); ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->origin_data.db; return pkg->origin_data.db;
} }
@@ -409,7 +391,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg) void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->changelog_open(pkg); return pkg->ops->changelog_open(pkg);
} }
@@ -418,7 +400,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
const alpm_pkg_t *pkg, void *fp) const alpm_pkg_t *pkg, void *fp)
{ {
ASSERT(pkg != NULL, return 0); ASSERT(pkg != NULL, return 0);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->changelog_read(ptr, size, pkg, fp); return pkg->ops->changelog_read(ptr, size, pkg, fp);
} }
@@ -426,7 +408,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp) int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->changelog_close(pkg, fp); return pkg->ops->changelog_close(pkg, fp);
} }
@@ -434,7 +416,7 @@ int SYMEXPORT alpm_pkg_changelog_close(const alpm_pkg_t *pkg, void *fp)
struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg) struct archive SYMEXPORT *alpm_pkg_mtree_open(alpm_pkg_t * pkg)
{ {
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->mtree_open(pkg); return pkg->ops->mtree_open(pkg);
} }
@@ -443,7 +425,7 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
struct archive_entry **entry) struct archive_entry **entry)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->mtree_next(pkg, archive, entry); return pkg->ops->mtree_next(pkg, archive, entry);
} }
@@ -451,14 +433,14 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive) int SYMEXPORT alpm_pkg_mtree_close(const alpm_pkg_t * pkg, struct archive *archive)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->mtree_close(pkg, archive); return pkg->ops->mtree_close(pkg, archive);
} }
int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg) int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
{ {
ASSERT(pkg != NULL, return -1); ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
return pkg->ops->has_scriptlet(pkg); return pkg->ops->has_scriptlet(pkg);
} }
@@ -466,7 +448,7 @@ static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs,
int optional) int optional)
{ {
const alpm_list_t *i; const alpm_list_t *i;
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) { for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
alpm_pkg_t *cachepkg = i->data; alpm_pkg_t *cachepkg = i->data;
@@ -496,7 +478,7 @@ static alpm_list_t *compute_requiredby(alpm_pkg_t *pkg, int optional)
alpm_db_t *db; alpm_db_t *db;
ASSERT(pkg != NULL, return NULL); ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK; pkg->handle->pm_errno = 0;
if(pkg->origin == ALPM_PKG_FROM_FILE) { if(pkg->origin == ALPM_PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */ /* The sane option; search locally for things that require this. */
@@ -805,3 +787,5 @@ int SYMEXPORT alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
return 0; return 0;
} }
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/* /*
* package.h * package.h
* *
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org> * Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -38,7 +38,7 @@
/** Package operations struct. This struct contains function pointers to /** Package operations struct. This struct contains function pointers to
* all methods used to access data in a package to allow for things such * all methods used to access data in a package to allow for things such
* as lazy package initialization (such as used by the file backend). Each * as lazy package initialization (such as used by the file backend). Each
* backend is free to define a struct containing pointers to a specific * backend is free to define a stuct containing pointers to a specific
* implementation of these methods. Some backends may find using the * implementation of these methods. Some backends may find using the
* defined default_pkg_ops struct to work just fine for their needs. * defined default_pkg_ops struct to work just fine for their needs.
*/ */
@@ -52,15 +52,13 @@ struct pkg_operations {
const char *(*get_arch) (alpm_pkg_t *); const char *(*get_arch) (alpm_pkg_t *);
off_t (*get_isize) (alpm_pkg_t *); off_t (*get_isize) (alpm_pkg_t *);
alpm_pkgreason_t (*get_reason) (alpm_pkg_t *); alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
int (*get_validation) (alpm_pkg_t *); alpm_pkgvalidation_t (*get_validation) (alpm_pkg_t *);
int (*has_scriptlet) (alpm_pkg_t *); int (*has_scriptlet) (alpm_pkg_t *);
alpm_list_t *(*get_licenses) (alpm_pkg_t *); alpm_list_t *(*get_licenses) (alpm_pkg_t *);
alpm_list_t *(*get_groups) (alpm_pkg_t *); alpm_list_t *(*get_groups) (alpm_pkg_t *);
alpm_list_t *(*get_depends) (alpm_pkg_t *); alpm_list_t *(*get_depends) (alpm_pkg_t *);
alpm_list_t *(*get_optdepends) (alpm_pkg_t *); alpm_list_t *(*get_optdepends) (alpm_pkg_t *);
alpm_list_t *(*get_checkdepends) (alpm_pkg_t *);
alpm_list_t *(*get_makedepends) (alpm_pkg_t *);
alpm_list_t *(*get_conflicts) (alpm_pkg_t *); alpm_list_t *(*get_conflicts) (alpm_pkg_t *);
alpm_list_t *(*get_provides) (alpm_pkg_t *); alpm_list_t *(*get_provides) (alpm_pkg_t *);
alpm_list_t *(*get_replaces) (alpm_pkg_t *); alpm_list_t *(*get_replaces) (alpm_pkg_t *);
@@ -114,8 +112,6 @@ struct __alpm_pkg_t {
alpm_list_t *backup; alpm_list_t *backup;
alpm_list_t *depends; alpm_list_t *depends;
alpm_list_t *optdepends; alpm_list_t *optdepends;
alpm_list_t *checkdepends;
alpm_list_t *makedepends;
alpm_list_t *conflicts; alpm_list_t *conflicts;
alpm_list_t *provides; alpm_list_t *provides;
alpm_list_t *deltas; alpm_list_t *deltas;
@@ -134,14 +130,11 @@ struct __alpm_pkg_t {
char *file; char *file;
} origin_data; } origin_data;
alpm_dbinfrq_t infolevel;
alpm_pkgvalidation_t validation;
alpm_pkgfrom_t origin; alpm_pkgfrom_t origin;
alpm_pkgreason_t reason; alpm_pkgreason_t reason;
int scriptlet; int scriptlet;
/* Bitfield from alpm_dbinfrq_t */
int infolevel;
/* Bitfield from alpm_pkgvalidation_t */
int validation;
}; };
alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src); alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src);
@@ -152,8 +145,8 @@ void _alpm_pkg_free(alpm_pkg_t *pkg);
void _alpm_pkg_free_trans(alpm_pkg_t *pkg); void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
int _alpm_pkg_validate_internal(alpm_handle_t *handle, int _alpm_pkg_validate_internal(alpm_handle_t *handle,
const char *pkgfile, alpm_pkg_t *syncpkg, int level, const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
alpm_siglist_t **sigdata, int *validation); alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation);
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
const char *pkgfile, int full); const char *pkgfile, int full);
@@ -161,3 +154,5 @@ int _alpm_pkg_cmp(const void *p1, const void *p2);
int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg); int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg);
#endif /* ALPM_PACKAGE_H */ #endif /* ALPM_PACKAGE_H */
/* vim: set noet: */

Some files were not shown because too many files have changed in this diff Show More