Compare commits

...

631 Commits

Author SHA1 Message Date
Allan McRae
be4c491ceb Release v.5.1.0
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-28 09:38:29 +10:00
Allan McRae
ca128f2eff Pull updated translations from Transifex
Also remove any translations that are less than 75% complete.  These will
be readded once translation completion passes our minimum threshold.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-28 09:25:04 +10:00
Allan McRae
3b2e09740c Translations need to be 75% completed to be included
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-28 09:14:45 +10:00
Allan McRae
eeb228c32e Update README for pacman-5.1
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-28 08:47:27 +10:00
Eli Schwartz
64e3a462c6 Update NEWS for pacman-5.1 release
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-28 08:47:27 +10:00
Eli Schwartz
ab6d8614d5 fix typo in editorconfig resulting in ignored options
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-28 08:47:27 +10:00
Eli Schwartz
6341e5ce23 Fix using run_pacman to invoke -Qi with sudo
In commit 5698d7b66d a new non-root use of
pacman was added -- previously we used -T or -Qq, and run_pacman did not
know how to special-case -Qi to skip being prepended with sudo.

The result is:

  -> Generating .BUILDINFO file...
ERROR: ld.so: object 'libfakeroot.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
[sudo] password for eschwartz:
  -> Adding changelog file...

Fix this by using a more generic glob since neither -Q nor -T will ever
need sudo or PACMAN_OPTS

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-16 14:44:16 +10:00
Allan McRae
652438772e Pull translations from Transifex and regenerate
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-15 11:03:42 +10:00
Eli Schwartz
1e7a191136 Add http://EditorConfig.org configuration
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-14 09:59:20 +10:00
Eli Schwartz
076b6184de Ensure better text editor automatic filetype detection
Since we no longer use vim-specific modelines, use the .asciidoc file
extension which is, well, reserved for asciidoc formatted files. This
should presumably work everywhere without needing editor-specific
workarounds and configuration.

Also add a shebang to makepkg.conf to indicate it contains bash content.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-14 09:59:17 +10:00
Eli Schwartz
860e4c4943 Remove all modelines from the project
Many of these are pointless (e.g. there is no need to explicitly turn on
spellchecking and language dictionaries for the manpages by default).

The only useful modelines are the ones enforcing the project coding
standards for indentation style (and "maybe" filetype/syntax, but
everything except the asciidoc manpages and makepkg.conf is already
autodetected), and indent style can be applied more easily with
.editorconfig

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-14 09:59:15 +10:00
Eli Schwartz
9aec7c3c72 makepkg.conf: add default protocol handler for file:// urls.
This is a common URI scheme (in general if not in makepg) and we should
provide a handler for it. We already allow its use for locally sourced
git repositories, so it makes sense to not leave files out.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-14 09:58:16 +10:00
Jan Alexander Steffens (heftig)
03272ad571 libmakepkg: Support file 5.33's application/x-pie-executable
file 5.33 introduces a new MIME type "application/x-pie-executable",
which is used for relocatable binaries. makepkg ignored these binaries
and did not attempt to strip them.

Handle the new MIME type like the old "application/x-sharedlib".
Stripping the binaries with --strip-unneeded to keep relocation
information should be the correct thing to do.

file 5.33 also misidentifies actual libraries as PIE executables, so we
didn't strip any shared libraries, either. We now work around this bug.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 22:57:47 +10:00
Andrew Gregory
40937b381a util/pkgbuild: fix broken indentation
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 22:22:54 +10:00
Eli Schwartz
af6125fbcc Fix gcc8 warnings.
Attempting to compile pacman with gcc8 results in several warnings like:

remove.c: In function ‘unlink_file.isra.4’:
remove.c:407:34: warning: ‘.pacsave.’ directive output may be truncated writing 9 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]

Fix by adding checks to error out if snprintf tries to reserve a
truncated filename. Because the return values are checked, gcc delegates
the truncation response to our code instead of throwing warnings.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:36:35 +10:00
Eli Schwartz
0d356c27c1 Fix regression that broke repo-add aborting on failures
In commit cb0f2bd038 the changes from
commit 81d233b793 seem to have been
inadvertently backed out.

Right now the current check doesn't do anything, since "fail" is always
nothing and therefore successful.

Fixes FS#58505

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:34:54 +10:00
Eli Schwartz
1741bdaf81 libmakepkg/integrity: determine what is a signature preferring local filename
Checking the file extension to determine if something is a signature is
currently done in three places:
- verify_file_signature: uses $file to print status, reuses it for
  comparison
- source_has_signatures: uses $netfile, but removes url component if
  filename component exists
- generate_one_checksum: uses $netfile and fails to detect renamed files

This leads to inconsistent behavior when trying to use a signature of
the form "foo-1.0.tar.gz.asc::https://example.com/foo-1.0.tar.gz.pgp"

Fix this by treating the third case like the second case.

Reported-by: Giancarlo Razzolini <grazzolini@archlinux.org>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:30:51 +10:00
Simon Linden
828f305023 bash_completion.in - consider option "-n --native" in operation "-Q --query"
Signed-off-by: Simon Linden <xhi2018@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:29:12 +10:00
Robin Broda
5698d7b66d Append architecture information to 'installed' elements in .BUILDINFO
Adding the architecture to the 'installed' elements of the .BUILDINFO
file makes it easier to retrieve the packages needed to reconstruct
the build environment.

Signed-off-by: Robin Broda <robin@broda.me>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:25:51 +10:00
Robin Broda
f173f6d0da Add pkgarch to .BUILDINFO
Architecture information is required for repro tooling

This is a revised version of https://patchwork.archlinux.org/patch/475/

Signed-off-by: Robin Broda <robin@broda.me>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:22:46 +10:00
Eli Schwartz
2b4c996b86 libmakepkg: don't save/set/restore extglob in bash [[ tests
Since bash 4.1 extglobs can be used within [[ ... ]] regardless of
whether the shopt is set. Our configure.ac requires bash 4.1.0 at a
minimum for pacman scripts.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:16:03 +10:00
Eli Schwartz
542c3cf812 libmakepkg: only save the shellopts we need
micro-optimization: We only care about temporarily enforcing extglob, so
that is the only one we need to explicitly restore.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:11:52 +10:00
Eli Schwartz
2c94118dc1 libmakepkg/lint_pkgbuild: fix regression in linting depends=(foo=$epoch:$pkgver-$pkgrel)
In commit 91b72cc386 support was added for
linting depends/etc. to ensure they contain only valid dependency
specifiers. However it did not properly take into account the
possibility of dependencies linked to a specific pkgrel or epoch, which
promptly failed to build because "-" and ":" is not allowed in a pkgver.

pkgrel is something supported by pacman and useful for e.g. split packages
which cannot be mismatched even if the pkgver is the same. Fix by
removing an optional suffixed "-$decimal" when checking for a valid
pkgver.

epoch is kind of difficult to do without :D so likewise fix by removing
an optional prefixed "$integer:"

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:10:44 +10:00
Rafael Ascensão
fa8b99189e remove unneeded break argument from option parsing
Some scripts are using `break 2` to break out of the option parsing
loop.

Since a single `break` is sufficient in these cases, remove the extra
argument.

Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12 21:09:37 +10:00
Allan McRae
77986af9b7 makepkg: Fix listing of uninstalled deps
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-30 00:46:02 +10:00
Allan McRae
c3402ab44e add missing newline to error message
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-30 00:43:06 +10:00
Allan McRae
4d1e27957d Initial translation preparation for pacman-5.1
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-29 23:56:07 +10:00
Allan McRae
254a8e2e05 Import updated translations from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-29 23:43:07 +10:00
Allan McRae
6018063ef6 Update POTFILES.in
Add all files to the relevant POTFILES.in.  This avoids missing
translations added to old files.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-29 22:44:46 +10:00
Eli Schwartz
ab7393c53e libalpm.pc: migrate to Requires.private
pkg-config has built-in dependency handling, but we currently insert the
raw $LIBS into libalpm's own linker flags and fail to handle Cflags at
all.

For dependencies which support pkg-config, simply use that instead.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-29 21:57:17 +10:00
Eli Schwartz
91b72cc386 libmakepkg/lint_pkgbuild: lint depends/etc. as if they are pkgname
depends, provides, conflicts, replaces, and other variables that are
meant to contain package names, are now checked to ensure

1) the name component contains only characters that would equate to
   a valid pkgname.
2) the version component contains only characters that would equate
   to a valid pkgver.
3) comparison operator is a valid comparison operator (e.g. provides
   only allows exact = while optdepends doesn't allow anything)

This also refactors pkgname into a shared utility function, wires up
pkgbase optdepends and provides to use it, and gives pkgver a touchup
to allow referencing where it was called from.

Fixes FS#57833 and a bit of extra.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-29 21:49:05 +10:00
Eli Schwartz
bcaf1b84ff libmakepkg/util/pkgbuild.sh: fix missing extglob
We use an extended glob here, but were relying on having it globally set
in makepkg. This causes it to fail when used in scripts.

Since scripts using libmakepkg may not want extglob to be set, save and
restore the environment while explicitly setting extglob only where we
need it.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-04-29 21:34:43 +10:00
Christian Hesse
27f64e3789 pacman.conf.5: use consistent presentation for paths
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-18 12:48:10 +10:00
Eli Schwartz
9ca88575e6 makepkg --packagelist: fix listing debug packages with makepkg.conf
print_all_package_names used in_opt_array to check whether or not the
PKGBUILD itself has options=('debug' 'split') -- while checking to see
if it was enabled per split package which doesn't make sense as these
options apply globally. This prevented debug packages from being listed
if enabled via makepkg.conf rather than per PKGBUILD.

Instead, use check_option to determine whether makepkg actually thinks
it is meant to try creating a split debug package.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-18 12:47:44 +10:00
Eli Schwartz
9e52a36794 makepkg: use the declare builtin when backing up variables to eval
Rather than manually crafting foo_backup in a loop and eval'ing them
with a complicated escape pattern, store every splitpkg_overrides
element into a single variable via the eval-friendly `declare` builtin.

An alternative to eval would be using `printf -v` but this does not work
for arrays.

This has the additional benefit of reducing the number of
variables/arrays floating around in the environment.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-15 14:39:31 +10:00
Eli Schwartz
f054351e52 libmakepkg: Add basic rules to lint makepkg.conf variables
Currently the only things we check are:

- Things that should be arrays, are not strings, and vice versa (this
  was mostly copy-pasted from the similar code in lint_pkgbuild).
- Variables that are meant to contain pathname components cannot contain
  a newline character, because newline characters in pathnames are weird
  and also don't play well with future changes intended for the
  --packagelist option.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-15 14:34:13 +10:00
Eli Schwartz
9c8d7a8093 libmakepkg/integrity: fix regression that broke --install
In commit c6b04c0465 package signing was
moved out of fakeroot, and as part of this process, the global pkgname
variable was modified in order to extract the built package names.

However, if a debug package was not available and added to the list of
packages, the function was aborted early, before the pkgname array was
restored, thereby corrupting the later stages of makepkg and
specifically the install_package function which needs to know which
pkgnames to install.

Fix this by inlining the debug package signing inside the `if` check,
and as added security switch to using `for pkg in "${pkgname[@]}"` as is
done in many other parts of makepkg, since package signing does not
depend on the value of pkgname for anything.

Additionally, since debug packages may not actually exist, check if the
package file exists first.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-15 11:30:20 +10:00
Eli Schwartz
c54621d819 makepkg: avoid false "Signing package(s)" msg when signing is disabled
Followup on c6b04c0465 which refactored
the signing function to run outside of fakeroot, and in the process
moved the status message to outside the $SIGNPKG check.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-15 11:16:00 +10:00
Eli Schwartz
d8717a6a96 makepkg: refactor checking for write permissions into a utility function
Additionally provide a separate error for failure to create the
directory vs lack of write permissions on a pre-existing directory.

This also means we now consistently try to create any nonexistent *DEST
directories as needed before aborting with E_FS_PERMISSIONS. Previously
only $BUILDDIR received that kindness.

Fixes FS#43537

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 17:47:51 +10:00
Eric Renfro via pacman-dev
0565cebfc3 Added gpg-agent.conf to disable the gnupg scdaemon
This fixes an issue where smartcards, such a Yubikey, would cause the
keyring to fail locally signing, thus also failing to verify signed
packages.

Signed-off-by: Eric Renfro <psi-jack@linux-help.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 17:45:08 +10:00
Allan McRae
3e619ccffe make_aligned_titles: initialise wbuf
This prevents a valgrind warning from deep inside wcstombs.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 15:08:36 +10:00
Rikard Falkeborn
1b288bae1f PKGBUILD.5: Mention valid characters for arch
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 14:54:57 +10:00
Allan McRae
b6bb8cb7dc Update coyrights for 2018
make update-copyright OLD=2017 NEW=201

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 13:31:31 +10:00
Stefan Klinger
d884a791b9 hooks: Complain if hook parameters are overwritten. Fixed 2 space leaks.
Signed-off-by: Stefan Klinger <git@stefan-klinger.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:53:52 +10:00
Felix Glaser
a5dd5d4141 makepkg: set umask 0022 again after syncing deps
makepkg configures the umask 0022 as a sane default for building
packages. After installing dependencies, it sources `/etc/profile`
again. If the user configured a umask other than Arch's default of
0022 (or 022) in `/etc/profile`, this sane default is now gone and
needs to be set again.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:52:09 +10:00
Rikard Falkeborn
5c1853124d Fix linting of whitespace in pkgver
In order to detect if pkgver contains whitespace, we need to quote it.
Previously, only the characters up to the first whitespace was checked.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:45:13 +10:00
Rikard Falkeborn
55092d0fa7 PKGBUILD.5: Mention that pkgver can't contain whitespace
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:44:31 +10:00
Yen Chi Hsuan
e4e0add629 makepkg: use localized date strings
Before this change, LC_TIME=zh_TW.UTF-8 makepkg has the following line:

==> Making package: foobar 1-1 (日  2月 11 01:13:42 CST 2018)

With this patch, this line becomes:

==> Making package: foobar 1-1 (西元2018年02月11日 (週日) 01時13分57秒)

The latter is more natural for a Chinese native speaker.

Signed-off-by: Chih-Hsuan Yen <yan12125@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:29:40 +10:00
Huáng Jùnliàng
03ce7cc4eb autoconf: bump AC_PREREQ to 2.64
The acinclude.m4 uses AS_VAR_APPEND macro. This marco is introduced in 2.64[1], hence we bump AC_PREREQ to 2.64 to avoid undefined marco on 2.63 autoconf.

[1] https://lists.gnu.org/archive/html/autoconf/2009-07/msg00079.html

Signed-off-by: Huáng Jùnliàng <i@jhuang.me>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:29:14 +10:00
Huáng Jùnliàng
b3a1f89611 configure: bump libarchive requirements
bump libarchive requirement to >= 3.0.0 as we use `archive_write_free` available from 3.0.0

Signed-off-by: Huáng Jùnliàng <i@jhuang.me>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:28:46 +10:00
Ivy Foster
df0a8f7406 doc/.gitignore: ignore all manpages
They're all generated during make.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:17:08 +10:00
Ivy Foster
c968e625e8 pacman-conf.c: exit if cannot set rootdir or parse config file
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:16:58 +10:00
Ivy Foster
0e260f9335 pacman-conf.c: exit if cannot create config data structure
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:16:58 +10:00
Ivy Foster
2dd8b88d5c pacman-conf.c: add short options
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:16:58 +10:00
Eli Schwartz
d8591dd341 makepkg --packagelist: just list the built package files we will build
Currently this seems to be only theoretically useful. The most likely
reason for wanting a packagelist is in order to script makepkg and
derive the filenames for the packages we want to install or repo-add,
but in the current implementation this requires a lot of additional
post-processing which must be duplicated in every utility to wrap
makepkg.

- It is of minimal use to know what packages might get created on some
  other device utilizing a different CPU/OS architecture, so don't list
  them.
- It is non-trivial to reimplement makepkg's logic for sourcing any of
  several makepkg.conf configuration files, then applying environment
  overrides in order to get the PKGDEST and PKGEXT, so include them
  directly in the returned filenames.
- Output is delimited by newlines, for readability. For maximum
  parsing reliability, libmakepkg needs to learn how to lint the PKGDEST
  and PKGEXT variables to ensure they do not contain newlines, which
  will be submitted in a separate patch.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14 12:16:58 +10:00
Ivy Foster
a100cd6bca src/pacman/query.c: do not exit -Qo with error if file does not exist
Query operations act on the local db, not the filesystem. Also, a
valid use case for -Qo is to discover what package owns a deleted file
so it can be reinstalled.

Closes FS#55856.

Signed-off-by: Ivy Foster <iff@escondida.tk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-02-06 11:16:17 +10:00
Ivy Foster
640c2462bb pacman/query.c: in query_fileowner, make is_dir an int
S_ISDIR is int and "returns non-zero" if the file is a directory.

Signed-off-by: Ivy Foster <iff@escondida.tk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-02-06 11:11:44 +10:00
Allan McRae
a278356f75 Deprecate --root in favour of --sysroot
The --root option was widely misunderstood, and is now replaced by
--sysroot.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 21:47:26 +10:00
Jelle van der Waa
a7dbe4635b Add BUILDINFO man page
Add a new man page which describes the structure of a BUILDINFO file
included in a package produced by makepkg.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:10:17 +10:00
Eli Schwartz
9058d7fe9a pacman-key: do not set a default keyserver
Recent versions of GnuPG are perfectly capable of using sane defaults,
and the default SKS keyserver over hkps:// is better than hardcoding the
same keyserver over hkp:// anyway.

Fixes FS#55278

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:05:58 +10:00
Eli Schwartz
d911438352 vercmp: fail when the wrong number of arguments are provided
Fixes FS#49093

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:05:39 +10:00
Eli Schwartz
19dabcc19a Fix usage of install_package
In commit ab2be5794d return codes were
implemented, and the output of install_package was improperly assigned
to a variable when the return code was wanted.

All we need to do is restore the previous exit handling, but return $?
instead of hardcoding "0".

Reported-by: xftroxgpx <xftroxgpx@protonmail.com>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:05:18 +10:00
Joel Teichroeb
b2e088e42c use pacman-conf in bash completion
Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:04:45 +10:00
Andrew Gregory
d9eda13fc6 use pacman-conf in scripts
Because parsing pacman.conf is so difficult that even we can't do it
right.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:02:11 +10:00
Andrew Gregory
170bb80a1f add pacman-conf utility
Parsing pacman's configuration file is non-trivial and extremely
difficult to do correctly from scripts; even our own do it incorrectly.
pacman-conf is a dedicated tool specifically to allow scripts to parse
config files, getting the same value that pacman itself would use.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-19 12:02:07 +10:00
Andrew Gregory
fa745fb467 extract default settings to separate function
Default values for configuration settings were being set during alpm
setup and in some cases were never saved back to the original config
struct.  Refactoring all default settings into a separate function and
saving them onto the original config struct will allow pacman-conf to
resolve the defaults without having to setup alpm.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-18 13:43:08 +10:00
Andrew Gregory
0bbf9ddf9d extract raw config file parser
To allow pacman-conf to parse the configuration file without having to
also setup alpm.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-18 13:42:57 +10:00
Allan McRae
e8462a4f88 Support new OpenPGP format packets lengths
RFC 4880 defines two packet formats for OpenPGP.  Pacman aborted its key
in keyring check with an error message if it encountered the new format.
This was fine until some annoying Arch Trusted User generated a key
using the new format!

Implement the new format.  This also required parsing the hashed sub
packets. requiring the parsing code to moved to its own function.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-11 15:58:05 +10:00
Allan McRae
653d2dc86d Fix moving source files into debug packages
Commit 8bec63bf92 attempted to switch to
using -fdebug-prefix-map to set file locations in debug packages.  It
make a few mistakes...

1) Adding debug C{,XX}FLAGS only worked if DBGSRCDIR was defined in
makepkg.conf.  Fix this by falling back to the default value.

2) Using -fdebug-prefix-map altered a lot of assumptions about file
locations when copying source files into debug packages. This resulted
in lots of messages of failed cp in packaging output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-10 10:53:15 +10:00
Andrew Gregory
4d80d87f90 add missing newline to debug message
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-10 10:53:15 +10:00
Andrew Gregory
2bda849bf9 detect pkghash allocation failure
If rehash ever failed with a full hash it would return the old hash
that is already full.  get_hash_position would then loop forever
because it would never find an empty bucket.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-10 10:52:26 +10:00
Allan McRae
59b6fdeee1 Do not continuously try to open an invalid database
If you manage to download a bad database (e.g. an html file when
behind a proxy or with a badly configured webserver), pacman makes
sure you know about it.  Here is some example output:

error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format
error: could not open file /var/lib/pacman/sync/extra.db: Unrecognized archive format

I don't know how many times that gets printed because it goes beyond my scrollback
buffer.

Flag a database that we can "open" and "fstat" but not read from as invalid to avoid
this.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-10 09:53:40 +10:00
Allan McRae
24ab8717d4 Handle empty string passed to query_owner
Passing an empty string to pacman -Qo results in:
error: No package owns <first directory in $PATH>

Catch empty strings and report an error.

Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-09 20:48:35 +10:00
Andrew Gregory
3a9a510ca8 do not rely on name hashes for matching
6cfc4757b9 was overzealous in attempting
to optimize away a call to strcmp based on a comparison of hashes.  The
call can be skipped if the hashes are different, but different strings
could have the same hash.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 13:35:48 +10:00
Eli Schwartz
8bf972824a vercmp: fix incorrect info in the manpage
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 13:23:54 +10:00
Eli Schwartz
eba623b443 vercmp: remove --usage variant of the -help option
I think two ways to ask for this are enough for everyone, and we have
never documented this anyway.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 13:23:05 +10:00
Andrew Gregory
59bb21fce3 dload: ensure callback is always initialized once
Frontends rely on an initialization call for setup between downloads.
Checking for intialization after checking for a completed download can
skip initialization in cases where files are small enough to be
downloaded all at once (FS#56408).  Relying on previous download size
can result in multiple initializations if there are multiple
non-transfer events prior to the download starting (fS#56468).

Introduce a new cb_initialized variable to the payload struct and use it
to ensure that the callback is initialized exactly once prior to any
actual events.

Fixes FS#56408, FS#56468

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 12:59:32 +10:00
Andrew Gregory
d0981d4c5b avoid printing NULL string
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 12:56:54 +10:00
Eli Schwartz
3d4e95e526 libmakepkg/integrity: fix git signatures not seen with multiple files
In eaa82b4d07 source_has_signature() was
modified to check if git repositories are marked as signed. However, due
to a typo the unused variable $netfile was checked. This worked as long
as the last source element was marked as signed, due to $netfile being
mistakenly set as a global in check_vcs_software(), but usually failed
with multiple sources.

Break this more consistently by properly declaring $netfile as a local
variable in check_vcs_software() which it should be regardless. Fix it
again by completely moving over to $netfile in source_has_signature()
as netfile is more descriptive of the current state.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 12:40:07 +10:00
Eli Schwartz
135f4397c2 libmakepkg/integrity: fix regression that broke invalid file sigs
In 42e7020281 creating the gpg statusfile
for a source file was split into a separate function, which used the
return code to indicate unsigned files and proto-specific errors.
However, the fallback return code was set by the final gpg invocation,
which would be 1 if the signature was somehow broken (for example, the
key was not available in the gpg keyring). As a result makepkg thought
that file did not have a signature and skipped over it rather than
erroring out.

Fix this by explicitly setting the return code for all
verify_*_signature() functions.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2018-01-06 12:38:05 +10:00
Eli Schwartz
8bec63bf92 makepkg: tell the compiler to record debugging info for debug packages
In commit 8b0d59b83a support was added for
storing the source files of binaries in debug packages. This made use of
the debugedit program which is part of the RPM package manager, which is
not very standalone.

The same effect can be achieved using -fdebug-prefix-map, an option
accepted by both the gcc and clang compilers which modifies how the
compiler itself stores the references to the source files rather than
requiring us to later edit the produced binaries. This also removes the
dependency on external programs like debugedit.

As a result of this change, source files will only be effectively added
for programs which actually use the exported CFLAGS. This is a reasonable
tradeoff as we expect our CFLAGS to be used rather than ignored. Upstream
software which do not produce useful debug packages are expected to fix
their build systems to respect the environment CFLAGS.

As a result of this change, the routine for extracting source filenames
from binaries had to be modified to derive the source file from the
final debug location, rather than the other way around.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 15:54:16 +10:00
Eli Schwartz
259d521e37 makepkg: Add a config option to specify the location of debug sources
In commit 8b0d59b83a support was added for
storing the source files of binaries in debug packages. Allow the user
to specify where those source files should be stored via makepkg.conf

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 15:52:39 +10:00
Eli Schwartz
1825bd6716 makepkg: refactor archive compression for reusability
This allows for more easily extending the list of allowed compression
methods, as it has to be modified in only one place.

Also allow the user to specify their own preferred command + options for
source packages in addition to compiled packages. Currently,
makepkg.conf(5) erroneously claims this is already possible.
2017-12-07 15:46:04 +10:00
Eli Schwartz
2fb8081d05 libmakepkg: fix .gitignore to simply ignore all generated .sh files
Prior to commit aca153bfa6 some .sh files
were not generated and simply included directly, and it was necessary to
explicitly iterate all ignored files to prevent git from ignoring the
directly-included files. However, now all .sh files are in fact
generated so it makes no sense to list each one separately in the
.gitignore file.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 15:37:20 +10:00
Eli Schwartz
c50ce453dc makepkg: reorganize the restoration of settings by precedence
The extra variables on the commandline were inconsistently applied. They
should override anything else, instead, most were overridden by
environment variables with the exception of BUILDDIR (and this was not
sanity-checked to see if it had write permissions).

e.g. given the commandline:
`PKGDEST="$(pwd)"` BUILDDIR="$(pwd)" makepkg PKGDEST=/doesnt/exist BUILDDIR=/doesnt/exist`

We would incorrectly use the current working directory for PKGDEST.
Meanwhile, we checked the wrong directory for BUILDDIR, and later
errored when we tried to create $srcdir inside the non-writable
directory "/doesnt/exist".

In order to fix this, use the preferred bash builtin for saving variable
definitions, similar to how we restore traps etc. rather than tediously
redefining each one by hand, and restore this immediately after
makepkg.conf is sourced. Finally, the `make`-style commandline overrides
are applied.

Also canonicalize_path is applied only on the final paths we try to use.
While it is unlikely the value in makepkg.conf will be a relative path,
since we now properly respect commandline overrides, they should be
canonicalized as well.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 15:06:10 +10:00
Nils Freydank
ad0517d371 Fix CVE-2016-5434 (DoS/loop and out of boundary read)
This is a rewrite of Tobias Stoeckmann’s patch from June 2016[1] using
functions instead of macros. (Thanks to Tobias for explanations of his patch.)
A short question on Freenode IRC showed that macros are generally discouraged
and functions should be used.

The patch introduces a static size_t length_check() in libalpm/signing.c.

[1] Original patch:
https://lists.archlinux.org/pipermail/pacman-dev/2016-June/021148.html
CVE request (and assignment):
http://seclists.org/oss-sec/2016/q2/526

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 14:59:26 +10:00
Eli Schwartz
44f3a15798 makepkg.conf: correct the documentation on the default options
The documentation for OPTIONS and BUILDENV listed some incorrect
defaults for undefined options. The defaults are implementation-defined
in the source code for makepkg itself (e.g. it depends whether we use
`check_option "opt" "y"` or `check_option "opt" "n"`) but were
erroneously declared to be "whatever we *define* in the default
makepkg.conf".

Fixes FS#55754

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 14:58:53 +10:00
Ivy Foster
ab2be5794d makepkg: implement error codes
For your convenience, makepkg now has 16 distinct ways to fail.
Also closes FS#54204.

Signed-off-by: Ivy Foster <iff@escondida.tk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 14:55:35 +10:00
Ivy Foster
67ce123457 makepkg: clarify error when user passes -F
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-12-07 14:29:03 +10:00
Allan McRae
e4f13e62cf libmakepkg: only output package file names when checking for build references
The leading directory is distraction from identifying the files containing
build references.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-10-17 20:31:06 +10:00
Alastair Hughes
62bfba53db Make the flags used for sed -i configurable
Not all sed implementations on linux accept the --follow-symlinks
argument, so let the user configure the arguments passed to sed if
required.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>

[Allan: fixed configure summary output]
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-14 13:03:44 +10:00
Allan McRae
2ddbc6964b libmakepkg: grammar fix
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-14 09:45:53 +10:00
Eli Schwartz
4dae3fde17 makepkg: respect $SOURCE_DATE_EPOCH to activate reproducible builds
If SOURCE_DATE_EPOCH is set, `touch` all source files between the (optional)
prepare() and build() functions to unify the modification times. This works
around build systems and compilers that embed the file modification times
into the file contents of release artifacts.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-13 14:21:34 +10:00
Eli Schwartz
39319c1860 libmakepkg: check for invalid tags in git
As per https://lists.archlinux.org/pipermail/arch-general/2017-July/043876.html
git doesn't check that the tag name matches what an annotated tag object
*thinks* it should be called. This is a bit of a theoretical attack and
some would argue that we should always use commits since upstream can
legitimately change a tag, but nevertheless this can result in a
downgrade attack if the git download transport was manipulated or the
upstream repository hacked.

So, check the tag blob to make sure the tag actually matches the name we
used for `git checkout`.

This really should be fixed in git itself, rather than forcing all
downstream users of git verify-tag to implement their own checks, but
the git developers disagree, see the discussion surrounding
https://public-inbox.org/git/xmqqk2hzldx8.fsf@gitster.mtv.corp.google.com/

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-09-13 14:20:35 +10:00
Michael Straube
64b7edd2fe Fix brace coding style issues
- Add missing braces to one-line if blocks
- Move opening brace to line end

Signed-off-by: Michael Straube <straubem@gmx.de>
2017-07-28 12:34:03 +10:00
Michael Straube
064e7280cb Fix coding style issue in pacman/util.c
Add missing braces to some one-line if blocks.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-28 12:33:24 +10:00
Michael Straube
b4a197a615 test/pacman: fix spelling of distribution name and another typo
Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-11 11:37:23 +10:00
Andrew Gregory
2b1b7b7075 clarify broken dependency error messages
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-11 11:36:16 +10:00
Andrew Gregory
fa8419a0b5 provide command for downloading missing databases
This is primarily to help users who are not aware that -F operations use
a separate set of databases that need to be separately downloaded.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-11 11:35:57 +10:00
Andrew Gregory
bcc9c417ae alpm_list: abort on memory allocation failure
This makes it possible to detect a failure in several alpm_list
functions.  Previously these functions would continue after a failure,
returning partial results and potentially leaking memory.
Unfortunately, NULL is a valid return value for the affected functions
if the input list is empty, so they still do not have a dedicated error
value.  Callers can at least detect an error by checking if the input
list was empty.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 14:48:03 +10:00
Levente Polyak
c44c649a52 makepkg: add more information to .BUILDINFO
The .BUILDINFO file should retain all the information needed to reproducibly
build a package.  Add some extra information to the file and also provide a
version number to keep track of future changes.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:57:27 +10:00
Allan McRae
9ab44178f4 makepkg: set default value for PACKAGER
In write_pkginfo, we checked if $PACKAGER was undefined, and gave a default
value if not.  Just do this upfront to simplify this function.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:34:31 +10:00
Allan McRae
1c8b3f2562 makepkg: always write pkgbase
There is little savings in only writing pkgbase when different to pkgname, and
it makes determining the pkgbase by parsing .PKGINFO slightly easier. Lets just
write it...

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:27:22 +10:00
Allan McRae
d170c4580c makepkg: do not write basever
Since 8a02abcf19, this attribute will never exist.  Remove check to write it.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:26:04 +10:00
Eli Schwartz
b14ff66038 libmakepkg: Fix improperly spelled local variable declaration
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 13:21:42 +10:00
Eli Schwartz
d4193d43cf libmakepkg/integrity: Fix error message not sent to stderr
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 12:55:45 +10:00
Eli Schwartz
9c604af0a0 libmakepkg: fix unsanitized source filenames
There were a couple places where filenames beginning with "-" were not
properly guarded against by passing them after "--". Some PKGBUILD
authors are crazy, but we still take those into account.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 12:55:25 +10:00
Christian Hesse
3c433abb54 fix typo in libalpm comment
contatenate -> concatenate

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-07-06 12:54:34 +10:00
Allan McRae
d30878763c makepkg: introduce SOURCE_DATE_EPOCH
This patch introduces the SOURCE_DATE_EPOCH environmental variable.  All files
in a package are adjusted to have their modification dates set to the value
of SOURCE_DATE_EPOCH, which defaults to "date +%s".

Setting this variable allows a package that is built twice in the same
environment to be (potentially) reproducible in that the checksum of the
generated package file will be the same.

Also adjust the compression of the mtree file to avoid gzip embedding a
timestamp.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2017-05-16 12:54:01 +10:00
Allan McRae
5f38128686 makepkg: remove build date from .PKGINFO header
This information is duplicated (in less friendly format) in the "builddate"
entry and removing it improves reproducible packaging.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
2017-05-16 12:47:01 +10:00
Andrew Gregory
5a1bf3d803 remove unused byte from user agent buffer
snprintf prints at most n bytes including the terminating '\0'.  The
extra reserved byte was never being used.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:44:08 +10:00
Andrew Gregory
63087c31b5 check for overflow when setting HTTP_USER_AGENT
gcc7 issues a warning about a potential overflow if left unchecked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:43:17 +10:00
Andrew Gregory
a2b776f6c9 query_fileowner: avoid buffer overflow
Copying a string into a buffer that  has just been determined to not be
able to hold it is obviously incorrect.  The actual error handling
appears to have been unintentionally removed in
47762ab687.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:39:39 +10:00
Andrew Gregory
1bc79cb9a5 alpm_unlock: check handle before dereferencing
Prevents SIGSEGV if we catch SIGINT or SIGHUP before initializing alpm.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-16 12:38:58 +10:00
Michael Straube
f4e2009e9b pacman.8: fix typo in query options
Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:55 +10:00
Andrew Gregory
bf468c0956 free memory for --overwrite lists
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:55 +10:00
Andrew Gregory
12f74fd895 add send_fakem to valgrind.supp
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:54 +10:00
Andrew Gregory
bf23f85d4a be_sync: error out if a db cannot be parsed
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:54 +10:00
Allan McRae
c6b04c0465 makepkg: create signature files outside of fakeroot
With recent version of gpg, signing within fakeroot works on the first
invocation, but fails on later runs.  Sign all packages outside of fakeroot
to avoid this issue.

Fixes FS#49946.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-05-08 18:53:53 +10:00
Allan McRae
c0a5884b18 makepkg: do not create symlinks in build directory
Setting PKGDEST and friends enables us to keep all built packages in a single
location.  Symlinking these files into the build directory creates unnecessary
clutter and requires clean-up in multiple places when removing old version.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-17 18:33:52 +10:00
Michael Straube
4f2fea240d makepkg: clean up pkgver and prepare log files
Delete log files for the pkgver and prepare functions if -c,--clean is
passed.

Fixes FS#51039 and FS#51075

Includes patch submitted by Christian Braun.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-17 10:50:41 +10:00
Andrew Gregory
3c013f68ac run_chroot: label pipe endpoints for readability
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
fae33a1faf add --sysroot option
--root is not sufficient to properly operate on a mounted guest system.
Using --root still uses the host system's configuration and there is no
way to correctly use the guest configuration without manually modifying
any Include directives.  --sysroot provides an easier way to operate on
a guest system by chrooting immediately after option parsing before
configuration parsing or performing any operations.  It is currently
limited to the root user, but that's enough for restoring a guest system
to a working state, which is the primary intended use case.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
6a4c6a02de use sockets for scriptlet/hook communication
If a scriptlet/hook dies at the wrong moment it can trigger SIGPIPE,
terminating the process.  For pipes, there is no way to prevent SIGPIPE
other than ignoring it process-wide.  This can have unintended
consequences in a multi-threaded process.  Using send(2) with sockets,
however, allows ignoring SIGPIPE on a per-call basis, leaving other
threads able to make use of SIGPIPE.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
6d1dcf7937 conflict: include owner for filesystem conflicts
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 19:41:35 -04:00
Andrew Gregory
16b91f798f 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>
2017-04-16 19:41:35 -04:00
Andrew Gregory
f9de3b22ad sortbydeps: rename vptr -> i
vptr is a simple list iterator, which are typically named i.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:55 -04:00
Andrew Gregory
a8670304c9 sortbydeps: rename found -> switched_to_child
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:55 -04:00
Andrew Gregory
098e114f58 sortbydeps: factor out dep cycle warning
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:55 -04:00
Andrew Gregory
1550938ce1 graph.h: rename childptr -> iterator
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:29:54 -04:00
Andrew Gregory
9c763a0d1b graph.h: replace hardcoded values with an enum
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-04-16 08:26:13 -04:00
Andrew Gregory
13ec13c85e deprecate --force in favor of --overwrite
--force is widely misunderstood and the same effect can now be achieved
with --overwrite, which is better named and can be used more safely.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-12 11:47:44 +10:00
Andrew Gregory
04d211effa add --overwrite option to ignore file conflicts
Allows for safer, more fine-grained control for overwriting files than
--force's all-or-nothing approach.

Implements FS#31549.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-12 11:47:33 +10:00
Armin K
86f5c74694 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>
2017-04-12 11:44:56 +10:00
Drew DeVault
1af766987f Replace @SIZECMD@ with POSIX-compatible command
Now uses wc -c $file | cut -d' ' -f1, which works using only POSIX
commands and removes the need for any platform-specific usages.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 12:21:20 +10:00
Andrew Gregory
d9908fc1f2 parse stdin as newline-separated
Newline-separated input is more reliable because most of the arguments
we accept over stdin can validly contain spaces but not newlines.

Resolves FS#52992

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 12:04:16 +10:00
Andrew Gregory
a138db3c07 add alpm_list_append_strdup
Makes error detection and handling easier for a common operation.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 12:03:22 +10:00
Andrew Gregory
a202959a19 pactest: add --review option
Opens the test file(s), test output, and any log files in the test
environment in an editor after the tests run for review.  Simplifies
debugging tests by avoiding the need to use --keep-root and manually
opening the relevant files.  The editor used can be set with --editor or
$EDITOR, falling back to vim.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 11:55:31 +10:00
Michael Straube
5678298f7d Ignore comments in INSTALL files (FS#51916)
If a comment in an INSTALL file contains the name of a valid
INSTALL file function but the function itself is not present,
pacman tries to execute that function. That leads to an error.

Ignore comments in the grep function in libalpm/trans.c to
avoid such errors.

Signed-off-by: Michael Straube <straubem@gmx.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-04 11:54:36 +10:00
Christian Hesse
c635f185ba Introduce a 'disable-download-timeout' option
Add command line option ('--disable-download-timeout') and config file
option ('DisableDownloadTimeout') to disable defaults for low speed
limit and timeout on downloads. Use this if you have issues downloading
files with proxy and/or security gateway.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-13 12:52:50 +10:00
Allan McRae
64bd242863 alpm_fetch_pkgurl: fix memory leak
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 15:32:14 +10:00
Allan McRae
008fe7b24f Fix memory leak in alpm_pkg_checkmd5sum
Also remove redundant additional return path.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 15:24:23 +10:00
Rikard Falkeborn
9ad7cda9d8 Suppress valgrind error in fakechroot
This was spotted on Arch Linux, most likely it was introduced
when fakechroot was updated to 2.19-1.

Valgrind suggests to add the following suppression, which can be
tweaked to fit an already existing one.

  {
     <insert_a_suppression_name_here>
     Memcheck:Leak
     match-leak-kinds: reachable
     fun:calloc
     obj:/usr/lib/libdl-2.24.so
     fun:dlsym
     obj:/usr/lib/libfakeroot/fakechroot/libfakechroot.so
     fun:bindtextdomain
     obj:/usr/lib/libgpg-error.so.0.20.0
     fun:call_init.part.0
     fun:_dl_init
     obj:/usr/lib/ld-2.24.so
     obj:*
     obj:*
     obj:*
  }

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 14:49:35 +10:00
Allan McRae
8b0d59b83a Provide source files for useful debug packages
Debug packages are fairly useless currently because the soucre files needed
for stepping through code etc are not packaged with them. This patch adds the
needed source files to the debug package and adjusts the debug info to look at
the /usr/src/debug/ directory for them rather than the build location.  This
requires using the "debugedit" program which is provided as part of the RPM
sources.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 14:02:28 +10:00
Eli Schwartz
37a89e2fac Document the new query parameter for VCS sources
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Eli Schwartz
eaa82b4d07 makepkg: Verify git signatures
A git repository is marked as signed if it contains the query "signed"
as defined by https://tools.ietf.org/html/rfc3986

Adds two utility functions in util/source.sh.in to extract fragments and
queries, and modifies source/git.sh.in to use them.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Eli Schwartz
42e7020281 libmakepkg/integrity: Verify file signatures in a separate function
This makes it easier to add signature verification for new protos.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Mark Weiman
0994893b0e Add alpm_pkg_get_makedepends and alpm_pkg_get_checkdepends
makepkg adds makedepends and checkdepends to a package's .PKGINFO file.
Add functions that allow use of these from libalpm.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
aa44824788 filelist_sort: check if filelist is presorted
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
6444ccbaf0 add _alpm_filelist_sort
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
585bd89803 repo-add: sort file list entries
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
01a6502169 makepkg: sort package contents
By passing a NUL-separated filelist, this also fixes a bug where files
that look like bsdtar options in the package root could break the
package ("-C" was particularly troublesome because bsdtar interprets it
as an option anywhere in the file list, even following "--").

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
9c3bf2988f find_fileconflicts: rename tmpfiles -> newfiles
The files belong to the new version of a package being installed, they
are not temporary in any way.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
b6753eeb7e conflict: skip dir children when replacing a file
When replacing a file with a directory, any files under that directory
do not need to be checked for conflicts.  This prevents possible
false-positive conflicts where the file being replaced is a symlink.

We were already skipping the directory children when the file was owned
by the previous version of a package being upgraded.  This extends that
to other packages being removed.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Andrew Gregory
8a19c4a782 ini: only recognize comments at beginning of line
Allows the hash sign to be used in values in config files and hooks.

Fixes #48702

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:15 +10:00
Dave Reisner
67602c4cf7 dload: s/CURLOPT_WRITEHEADER/CURLOPT_HEADERDATA/
The former is really old, and should be avoided.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Dave Reisner
d8367162e8 pacman: ensure linkage against libarchive
Fixes build on ubuntu/debian platforms.

Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Dave Reisner
d0a5766e24 configure.ac: Use POSIX compatible equality checks
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Andrew Gregory
36eb35cacd makepkg: warn about dotfiles in package root
libalpm reserves paths starting with '.' for its own use and will not
extract any other than those it recognizes.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Andrew Gregory
2c4511bdbe 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>
2017-01-04 13:59:14 +10:00
Allan McRae
1a2d5bee3b Update copyright years
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Allan McRae
3a4623b10a Fix documentation of -Dq
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Steef Hegeman
5dfa3c8f6a makepkg: Disallow forward slashes in pkgver
scripts/libmakepkg/lint_pkgbuild/pkgver.sh.in now raises an error when
pkgver contains forward slashes.

pkgver containing a forward slash results in a package filename
containing a forward slash, which isn't a valid filename.

Signed-off-by: Steef Hegeman <steefhegeman@hotmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2017-01-04 13:59:14 +10:00
Allan McRae
9a4d616220 Build a single debug package for all packages from a PKGBUILD
We want to provide source files with debug symbol packages to allow easy
stepping through the program.  This becomes difficult with split packages due
to the binaries in many of these sharing source files across packages.

There are (at least) two solutions to this problem. #1: ensure common source
files are located in the debug package for the package lowest in the dependency
chain and add dependencies to the debug packages so all require source files
are present, or #2: create one debug package for all split packages in a
PKGBUILD.  The second is a more robust approach despite potentially creating
very large debug packages.

This patch creates a single $pkgbase-debug package and adds provides such that
installing $pkgname-debug will always work.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:23:44 +10:00
Andrew Gregory
c40ee73bc4 be_local: remove unused error return
LAZY_LOAD has completely ignored the errret value since commit
307a6de17a in 2011.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:09 +10:00
Christian Hesse
fc756c3c70 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>
2016-12-05 15:20:09 +10:00
Alastair Hughes
36f456ccae Make DUFLAGS be overrideable during configure
Not all du implementations on linux accept --apparent-size, so let the
user configure the arguments passed to du if required.

This fixes FS#47943.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Allan McRae
97459e9eb7 Suppress more output messages on successful -D options with -q
Suppress output on successful use of --asdeps and --asexplicit.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Patrick Eigensatz
46324d9b26 Give a "success!" message on database check
'pacman -Dk' prints a "success!" message if there were no errors.
It is possible to suppress the output using the '-q / --quiet' flag.

This implements the feature discussed at https://bugs.archlinux.org/task/50087

Signed-off-by: Patrick Eigensatz <patrick.eigensatz@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Martin Kühne
e83e868a77 Parametrise the different ways in which the payload is reset
In FS#43434, Downloads which fail and are restarted on a different server
will resume and may display a negative download speed. The payload's progress
in libalpm was not properly reset which ultimately caused terminal noise
because the line width calculation assumes positive download speeds.

This patch fixes the incomplete reset of the payload by mimicing what
be_sync.c:alpm_db_update() does over in sync.c:download_single_file().
The new dload.c:_alpm_dload_payload_reset_for_retry() extends beyond the
current behavior by updating initial_size and prevprogress for this case.
This makes pacman reset the progress properly in the next invocation of the
callback and display positive download speeds.

Fixes FS#43434.

Signed-off-by: Martin Kühne <mysatyre@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Christian Hesse
c3b954e7b9 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>
2016-12-05 15:20:08 +10:00
Andrew Gregory
e3e9cc14a5 makepkg: reject packages with newlines in paths
libalpm's local database format does not support paths with newlines.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Andrew Gregory
5dd764eb47 makepkg: abort on lint_package errors
Allows lint_package to prevent makepkg from creating an invalid package.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Andrew Gregory
46101bea1c makepkg: reject package data with newlines
The PKGINFO format cannot handle values that contain newlines.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Andrew Gregory
d3dc200263 makepkg: fix find_lib{depends, provides} results
Neither function was checking for the existence of actual results before
calling printf, resulting in them returning a list with a single empty
value if there were no depends/provides.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Dave Reisner
7114ca6208 dload: use curl's keepalive mechanism
This does exactly the same thing as it code it replaces, but punt to
curl to do it for brevity. Requires curl 7.25.0, which we already cover.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Dave Reisner
263e65dbb3 makepkg: unset potentially architecture-specific vars
I'm not convinced this is a worthwhile goal, but let's follow suit.
Since we can't know the names of all the vars that might exist, unset
them by pattern.
2016-12-05 15:20:08 +10:00
Dave Reisner
0b30edacd4 makepkg: fix quoting in calls to dependency checking 2016-12-05 15:20:08 +10:00
Dave Reisner
90f1dd1657 makepkg: fix quoting in calls to check_deps
The inside needs quoting, and this is separate from the declartion,
which does not (in these cases).
2016-12-05 15:20:08 +10:00
Dave Reisner
9ce2c9b187 makepkg: make run_function_safe more robust
Use shopt to set/reset errexit and errtrace, which lets us:

1) be more vigilant, resetting anything the user might do to us in
PKGBUILD functions.
2) use human-readable words (errexit vs. -e)

On top of this, introduce a new save/restore for the shell's other
shopts. A user should not have any expectations that what happens in
one function is available in another function, if it isn't explicitly
defined in the PKGBUILD. While this change does not make that
assertion, it gets us closer.

We also replace a variable which comes from out of nowhere (pkgfunc)
with the positional parameter containing the same value. Quoting is
adjusted to make the expansion happen at the time the trap is set,
rather than later on.
2016-12-05 15:20:08 +10:00
Dave Reisner
cef0d726b4 makepkg: remove vestiges of global errexit
These 'set +E' diversions haven't been needed since global errexit was
disabled in dca10b062f (January 2012).
2016-12-05 15:20:08 +10:00
Dave Reisner
e7fc560866 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.
2016-12-05 15:20:08 +10:00
Johannes Löthberg
37b73fe4fb Make sure all proper scripts are installed instead of the wrappers
After 1f8f0bd9ac all scripts that were
changed to using the wrapper for in-tree use have the wrappers installed
to the system instead of the actual script, so change the install
command to support all wrapped scripts instead of just makepkg.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Allan McRae
0dbc55a357 Remove pacsort
Moved to the pacman-contrib project

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-12-05 15:20:08 +10:00
Allan McRae
5fbb361261 Revert "[RFC] Provide source files for useful debug packages"
This reverts commit a79c0038ae.

I merged the wrong branch into master...
2016-12-05 15:12:03 +10:00
Allan McRae
a79c0038ae [RFC] Provide source files for useful debug packages
Debug packages are fairly useless currently because the soucre files
needed for stepping through code etc are not packaged with them. This
patch adds the needed source files to the debug package and adjusts
the debug info to look at the /usr/src/debug/ directory for them rather
than the build location.  This requires using the "debugedit" program
which is provided as part of the RPM sources.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-11-02 15:03:57 +10:00
Ivy Foster
fa06951d90 Represent bitfields as ints, not enums
Many bitfield variables are declared to be enums, because they are
generated using bitwise operations on enums such. However, their
actual values aren't necessary members of their parent enum, so
declaring them 'int' is more accurate.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Ivy Foster
a55adb81d0 Add ALPM_ERR_OK to _alpm_errno_t
This allows functions which return an _alpm_errno_t to always return a
genuine _alpm_errno_t for consistency, even in cases where there are
no errors. Since ALPM_ERR_OK = 0, their callers can still simply check
'err = some_fn(); if (!err) { ... }'.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Ivy Foster
a79be86f57 doc/pacman.8.txt: improve description of -Qt
Though correct, the wording of the description of Query's
-t/--unrequired option was confusing. Closes FS#48144.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Ivy Foster
e8c35bea2b makepkg: print files with refs to $srcdir/$pkgdir
Since rewriting build_references() anyway, tweaked quoting.
Implements FS#31558.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Allan McRae
4c4ce473d6 Remove pactree
This has been moved to the pacman-contrib project.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Allan McRae
577701250d Use coreutils binaries for checking/generating checksums
If pacman is build against a crypto library other than openssl, it makes no
sense to require makepkg to use it.

The only currently considered alternative to openssl is nettle, which has no
binary for base64 encode/decode. This means that we could replace the hashing
cacluations with nettle-hash, but would require base64 from coreutils.

Given makepkg already relies heavily on coreutils, we might as well use all
the coreutils hashing binaries too.

This patch also improves the checking of required binaries for hashing
operations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Florian Weigelt
603f087cd7 Allow replacing libcrypto with libnettle in pacman
Add a --with-nettle configure option that directs pacman to use the libnettle
hashing functions. Only one of the --with-libssl and --with-nettle configure
options can be specified.

[Allan: rewrote configure check]
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:55 +10:00
Alad Wenter
1f8f0bd9ac makepkg: Move parseopts from library to libmakepkg
parseopts is used in makepkg and other scripts such as pacman-key as a
getopt replacement.

Instead of including it in those scripts via a macro, move it to
libmakepkg/util/parseopts.sh and have scripts source this file where
appropriate.

To keep the parseopts test, a new variable was introduced:
PM_LIBMAKEPKG_DIR

Signed-off-by: Alad Wenter <alad@archlinux.info>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:54 +10:00
Allan McRae
dfc78129be Generalise makepkg-wrapper to handle any script using libmakepkg
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-22 20:50:29 +10:00
Alad Wenter
aca153bfa6 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>
2016-10-22 20:50:28 +10:00
Martin Kühne
8c55c0096c 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>
2016-10-12 19:48:29 +10:00
Allan McRae
ad27aa30fb 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>
2016-10-11 15:43:25 +10:00
Christian Hesse
e2b4e220bc lint_pkgbuild/pkgname: pkgname is not allowed to be empty
We checked for empty array elements, but did not catch empty array. Add
a check for that case as well.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-10 10:38:05 +10:00
Allan McRae
0c99eabd50 Remove contrib
The contrib directory takes too much of the pacman developer's limited time,
which could be better spent developing and reviewing patches for the primary
projects. The community can pick this up in a separate repository if wanted.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-10 10:38:05 +10:00
Allan McRae
2e76c184aa Move bash/zsh completion out of contrib
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-10 10:38:05 +10:00
Allan McRae
d590a45795 Remove pacman-optimize
The people who believe that pacman-optimize is actually doing something
useful are the same people who are voting for Trump.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-10 10:38:05 +10:00
Levente Polyak
3190b87b65 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>
2016-10-10 10:38:04 +10:00
Allan McRae
87ee9693bd Remove SHA224 support
This was included due to use of PolarSSL's implementation for our internal
SHA2 support.  As our internal checksum calculations are now removed, we
can also remove this unused code path.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-10 10:38:04 +10:00
Allan McRae
05e1b8de1a Remove internal md5 and sha2 implementations
The internal implementations for md5 and sha256 checksums have not been merged
from upstream sources for a long time.  Instead of us carrying copies of code
from other projects, we should just support building against multiple libraries
that provide such functionality.

This patch removes the md5 and sha2 code (originally obtained from PolarSSL)
from our repository.  The configure script will now error unless at least one
library supporting checksum generation is present, with the only library
currently supported being openssl.  It will be relatively simple for other
such libraries (e.g. nettle) to be supported if anyone wishes to add them.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-10-10 10:37:21 +10:00
Ivy Foster
0d2ba870c9 Do not #define _RESERVED_IDENTIFIERS
Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 18:04:57 +10:00
Gordian Edenhofer
ae56a32273 bacman: add manual page
Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
5fcc054421 bacman: add option to alter the output directory
Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
130c0d5496 bacman: add option to print fewer status updates
Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
8f4a67bda9 bacman: quote pkg_pkger variable
Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
c7da5a6ef2 bacman: code structuring
Adding and clarifying comments.
Adding and removing some new lines.

Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
3a00bc31f2 bacman: rewrite usage function
Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
5c549b0e1d bacman: proper option handling
Switch to parseopts instead of merely checking the first argument.

Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
52ec8dfffe bacman: handle SIGHUP, SIGINT, SIGTERM signals
Trap SIGHUP, SIGINT, SIGTERM and remove working directories accordingly.

Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Gordian Edenhofer
7568928e71 bacman: allow for multiple packages as arguments
To enable the creation of multiple packages with one command move the
assembly process into its own function.

Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-25 17:41:10 +10:00
Alastair Hughes
45b6a3074a 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>
2016-09-25 17:40:49 +10:00
Rikard Falkeborn
6a5156eedc 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>
2016-09-25 17:33:09 +10:00
Rikard Falkeborn
85171807c1 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>
2016-09-25 17:32:20 +10:00
Rikard Falkeborn
34f3f1e7a6 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>
2016-09-20 22:48:00 +10:00
Fabio Castell
07d1e0441b repo-add: fix error in directories with a space in their name
Fixes FS#50285

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-09 15:40:20 +10:00
Ivy Foster
900a22b90c 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>
2016-09-09 14:59:58 +10:00
Eli Schwartz
38e229e4db 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>
2016-09-03 20:38:13 +10:00
Allan McRae
fac4831a09 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>
2016-09-03 20:38:13 +10:00
Allan McRae
d560a9aecd Fix typo in pacman-db-upgrade usage message
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-02 23:26:02 +10:00
Alastair Hughes
1dbfef7b1c 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>
2016-08-31 13:05:25 +10:00
Ivy Foster
e28c5803bb Replace CURLOPT_PROGRESSFUNCTION with CURLOPT_XFERINFOFUNCTION
Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION, which deprecates
CURLOPT_PROGRESSFUNCTION and means less casting doubles to size_ts for
alpm. This change has no user-facing nor frontend-facing effects.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-31 13:01:07 +10:00
Lukas Fleischer
1e2b398406 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>
2016-08-30 20:18:44 +10:00
Florian Pritz
406c9b66b4 Document contrib/verify-pacman-repo-db.pl
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2016-08-30 20:08:34 +10:00
Florian Pritz
6c15cc4d22 contrib: Add documentation Makefile
Makefile.am is mostly copied from ./doc/Makefile.am

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2016-08-30 20:08:34 +10:00
Florian Pritz
6d8e3d2a91 contrib: Add verify-pacman-repo-db.pl
From the documentation:

verify-pacman-repo-db looks at a pacman repo database and verifies its
content with the actual package files. The database is expected to be in
the same directory as the packages (or symlinks to the packages).

The following properties are verified for each package in the database:

    - existence of the package file
    - file size
    - MD5 and SHA256 checksum (--checksum)

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2016-08-30 20:08:33 +10:00
Allan McRae
1ec7fa89ad Fix file name in scripts potfile 2016-08-30 20:08:18 +10:00
Giulio Fidente
69aee3e391 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>
2016-08-30 18:10:40 +10:00
Ivy Foster
58140dba74 Normalize alpm download callback's frontend cb arguments
When curl calls alpm's dlcb, alpm calls the frontend's cb with the
following (dlsize, totalsize) arguments:

0, -1: initialize
0, 0: no change since last call
x {x>0, x<y}, y {y>0}: data downloaded, total size known
x {x>0}, x: download finished

If total size is not known, do not call frontend cb (no change to
original behavior); alpm's callback shouldn't be called if there is a
download error.

See agregory's original spec here:
https://wiki.archlinux.org/index.php/User:Apg#download_callback

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Jack O'Connor
56de155296 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>
2016-08-30 18:10:40 +10:00
Allan McRae
5b839c58ee Add newline to the end of error messages for signature format issues
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Olivier Brunel
56ae960376 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>
2016-08-30 18:10:40 +10:00
Andrew Gregory
be1ffedaf6 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>
2016-08-30 18:10:40 +10:00
Andrew Gregory
c981f5ad76 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>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
af83a58574 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>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
5fcd60e264 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>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
681509fd44 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>
2016-08-30 18:10:40 +10:00
Allan McRae
1291c04961 pacman-key: reject armored signatures
pacman expects an unarmored signature.  makepkg forces the generation of
unarmored signatures, and repo-add will reject any armored signature.
For consistency pacman-key should also reject armored signatures.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
80d97fcf75 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>
2016-08-30 18:10:40 +10:00
Allan McRae
0f0b192d8a Remove obsolete TODO
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Andrew Gregory
6ac2ee21b3 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>
2016-08-30 18:10:40 +10:00
Allan McRae
7a9d8b7001 Turn off colours once finished using them
The colour of the package version could leak onto the next line in both
-Qo and -Fo.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Christian Hesse
839417e8c6 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>
2016-05-18 15:45:56 +10:00
Christian Hesse
f018317f48 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>
2016-05-18 15:45:56 +10:00
Ashley Whetter
4f114f3817 libmakepkg: extract functions for integrity checking
Signed-off-by: Ashley Whetter <ashley@awhetter.co.uk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-18 15:45:56 +10:00
Leonid Isaev
892a1076c0 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>
2016-05-18 15:45:56 +10:00
Alastair Hughes
87082e3f44 makepkg: ignore the architecture for --printsrcinfo
Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-18 15:45:55 +10:00
Allan McRae
7bebe4deff Report local file URL for -Sp operations if package is in cache
When using "pacman -Sp" operation to get URLs of packages to download, it is
useful to know which packages are already in the file cache and do not need
downloaded.  Print packages in the cache with a file:// prefix.

e.g
$ pacman -Sp glibc
file:///var/cache/pacman/glibc-2.23-1-x86_64.pkg.tar.xz

Also use package locations in case statements rather than opersations. This
allows the ALPM_PKG_SYNCDB to fall thorough to just printing the package name
for weird serverless repo setups.

Fixes FS#15868

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-18 15:45:55 +10:00
Allan McRae
02a0bf550a makepkg: move build enviroment set-up to function
This is a requirement to split the preparation of the build environment
into libmakepkg, which will allow dropping in extensions (e.g. to allow PGO).

After this patch, disabling buildflags or makeflags and enabling debug
CFLAGS will only effect the build(), check() and package() functions.  The
relevant variables are no longer exported for the prepare() function.  This
should have zero impact for the prepare() function of a properly written
PKGBUILD, as no building/linking is done there...

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-18 15:45:07 +10:00
Allan McRae
3729ef7a9a 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>
2016-05-05 13:52:23 +10:00
Ashley Whetter
b012da645e Add -m/--nocolor options to updpkgsums
Fixes FS#43346

Signed-off-by: Ashley Whetter <ashley@awhetter.co.uk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Ashley Whetter
6c96ad36e0 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>
2016-05-05 13:52:23 +10:00
Allan McRae
5b9bc6024c 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>
2016-05-05 13:52:23 +10:00
Eric Engestrom
2694d17ad9 fix spelling mistakes
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Xavion
0088a7ab1c Add colour to the output of the "-{F, Q}o" operations.
Matching output for -s operations, the repository is coloured 'magenta', the
package name is 'bold', and the version is outputted in 'green'.

Signed-off-by: Xavion <Xavion (dot) 0 (at) Gmail (dot) com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Xavion
7e7c64f513 Add colour to group selection dialog
Colour the group name in 'blue' and the repository names in 'magenta'.

Signed-off-by: Xavion <Xavion (dot) 0 (at) Gmail (dot) com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae
7d1ea0b814 Handle provides with -Q
It is useful to be able to use "pacman -Qi" on any dependency, even if that
dependency is a provide.  For example, on Arch Linux systems, "sh" is provided
by the "bash" package, and many packages depend on "sh". Querying the
package that provides the "sh" dependency currently requires first searching
for "sh".

This patch allows the use of "pacman -Qi" on a provide.

Fixes FS#20650.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae
502e0d1db0 pacman_query: move error messages into relevant if statements
This ensures any additions to these test do not have to rely on the correct
error condition being set by libalpm.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Christian Hesse
a194fb434e pacman.8: add actual operation to captions for easy searching
I caught myself searching for operations when in need for an option.
However this made me find transaction and update options only. So add
the actual operations to captions for easy searching.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae
ee960048b2 Remove notification of system upgrade when only printing URLs
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae
3ed57be450 Print replacements when using -Sup
When printing a list of URLs of packages to be updated, pacman was ignoring any
replacements that would be made in the update process.

Fixes FS#35812

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Alastair Hughes
4960be7764 Changed documentation to use 'the default' instead of 'a typical default'
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-03-28 17:17:17 +10:00
Allan McRae
5901038610 PKGBUILD.5: document that the pkgver() function runs after prepare()
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-03-28 17:17:17 +10:00
Allan McRae
2ee1706a72 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>
2016-03-28 17:16:27 +10:00
Ashley Whetter
4cad2423a3 libmakepkg: extract functions for writing .SRCINFO files
Signed-off-by: Ashley Whetter <ashley@awhetter.co.uk>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-03-28 16:26:12 +10:00
Allan McRae
baf1ff64e6 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>
2016-03-21 13:14:56 +10:00
Andrew Gregory
02731189f1 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>
2016-02-26 15:52:25 +10:00
Allan McRae
1a94c00e36 Add release instructions
This serves as a release checklist for anyone making a pacman release.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:20:02 +10:00
Allan McRae
f363cf7857 repo-add: do not alter the database if only verifying signature
Fixes FS#48085.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:44 +10:00
Allan McRae
af5d69d59d Failed database downloads cause transaction to stop
Previously, we errored only if all databases failed to download. If any
database downloads fail, we are unable to determine whether an update is
still considered safe. So now if any database download fails, the transaction
is aborted (after attempting all database downloads).

Fixes FS#47599.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
3da06c3519 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>
2016-02-26 15:18:43 +10:00
Allan McRae
59112e186b Consider provides when warning about optdepnd removal
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
76a7d2293c Consider provides when labelling optdepends status as pending install
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Xyne
8ff03868a3 makepkg: Turn PACMAN_OPTS into an array
Avoid potential word expansion with future inclusions

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
1a29744d0d makepkg: Remove upx and optipng support
These options were added before libmakepkg allowed passes like this to be
dropped in.  I prefer only real core packaging tasks to be included in
makepkg and additional things like this to be dropped in by a user or
distribution that wants to support them.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
d4f499f563 libmakepkg: fix is_array function
This happened to work for the majority of cases because the only calling
function used a variable named "i" that was related to the variable being
passed to the function.

Fixes FS#48340.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
df5dc0c9de Update NEWS for pacman-5.0.1
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
f38de43eb6 Release 5.0.1
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 13:46:25 +10:00
Allan McRae
9375715ae4 Regenerate translations for 5.0.1 2016-02-23 13:09:39 +10:00
Allan McRae
e2ca25623b Manually fix space before ellipses in translations
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 13:05:02 +10:00
Stefan Tatschner
cd4a3d03a0 Fix inconsistent status messages
This patch fixes an inconsistency in the status messages.

    :: Proceed with installation? [Y/n]
    :: Retrieving packages ...         <--- Space before "...".
     blas-3.6.0-4-x86_64
     cblas-3.6.0-4-x86_64
     lapack-3.6.0-4-x86_64
    (3/3) checking keys in keyring
    (3/3) checking package integrity
    (3/3) loading package files
    (3/3) checking for file conflicts
    (3/3) checking available disk space
    :: Processing package changes...  <--- No space before "..."
    (1/3) upgrading blas
    (2/3) upgrading cblas
    (3/3) upgrading lapack

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:56:52 +10:00
Allan McRae
5c136d85db Pull translation updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:56:40 +10:00
Evangelos Foutras
c034a3322b makepkg: do not run prepare() with --noextract
This is partial revert of 8454daa7fe (makepkg: run pkgver() and
prepare() with --noextract).

Reasoning for the reversion (copied from FS#43498):

    Running prepare() when --noextract is used no longer allows running
    'makepkg -o && makepkg -e' with any PKGBUILD that applies patches in
    prepare(). [1]

    Sure there's --noprepare which restores the old behavior, but that's
    a lot of extra typing for what I believe is a much more common use
    of --noextract.

    For OP's use case of doing git bisects, you can specify the commit
    in the source array and thus skip --noextract since makepkg will
    checkout the correct commit each time.

    [1] I often extract the sources using 'makepkg -o', manually edit
    some source files, and then use 'makepkg -e' to package it (while
    possibly repeating the edit/package steps).

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:50:04 +10:00
Andrew Gregory
a724235b61 make alpm_unlock and trans_interrupt async safe
RET_ERR calls _alpm_log which includes calls that are not safe for use
in asynchronous signal handlers (see signal(7)).  Replace it in
functions called from our signal handlers with a new macro
RET_ERR_ASYNC_SAFE which is identical except that it lacks the call to
_alpm_log.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2016-02-23 12:41:36 +10:00
Andrew Gregory
1d6583a58d alpm_run_chroot: always connect parent2child pipe
Commit e374e6829c closed stdin before
running scripts/hooks.  This left the exec'd process with no file
descriptor 0.  If the process subsequently opened a file it would be
assigned fd 0, and could potentially be confused for stdin.  Connecting
and immediately closing the parent2child pipe ensures that the child has
an fd 0 and that it is empty.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:33:04 +10:00
Andrew Gregory
ce1f453b74 ensure gpgdir has a trailing slash
init_gpgme checks for various paths under gpgdir by concatenating them
directly, giving warning messages incorrectly if gpgdir does not end
with '/'.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:32:54 +10:00
Andrew Gregory
2ee7a8d89a do not rely on localdb for hook matching
Relying on localdb to determine which trigger operations should match is
completely broken for PostTransaction hooks because the localdb has
already been updated.  Store a copy of the old version of any packages
being updated to use instead.

Fixes FS#47996

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:15:43 +10:00
Dominik Fischer
f63854fa96 only include .SRCINFO comments in source tarball
This avoids introducing unnecessary changes to the time stamp into
package repositories that regularly use --printsrcinfo to update the
.SRCINFO file.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-21 17:10:11 +10:00
Allan McRae
83c7dc80cb alpm-hooks.5: document hook running order
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-21 17:10:11 +10:00
Andrew Gregory
fd936c9e73 only remove pacnew file if it is new
Check if we overwrote an exiting pacnew file before unlinking it.
Otherwise, updating to a version with an unchanged file would delete
existing pacnew files.

FS#47993

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-21 17:10:11 +10:00
Allan McRae
169287e494 makepkg: remove pkg from OPT_LONG array
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Allan McRae
7624101e18 Revert "makepkg: Empty/create only $pkgdir's relevant to current PKGBUILD"
This reverts commit f9423cfa5d.

This created issue when building packages with debug info multiple times.
It could be fixed, but it confirmed my initial opinion that keeping other
directories in $pkgdirbase was wrong. Use different BUILDDIRs if you want
to build different things from a single PKGBUILD.
2016-02-20 14:01:53 +10:00
Olivier Brunel
a1a8d067e0 Log to file when running hooks
Useful if there's some output (to know where it comes from), or in case of
failure.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Allan McRae
7cf5e1aebf doc/alpm-hooks: mention that hooks must have a ".hooks" suffix.
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Alastair Hughes
c72ca3d539 Make "makepkg -g" ignore the current architecture.
Commit 663c74150a
(makepkg: merge arch dependent variables after PKGBUILD linting) broke
"makepkg -g" on a PKGBUILD which did not include the current architecture, by
moving the lint_pkgbuild call before GENINTEG was processed.
Fix that by setting IGNOREARCH for the "-g" option.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Allan McRae
3cb1669e07 libmakepkg: increase robustness of the detection of array variables
Extract array detection into its own utility function that ensures
extglob is enabled.

Suggested-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Allan McRae
0fa695d0e3 repo-remove: fix checking for non-existent .db database
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Alastair Hughes
50a2db4834 Add the missing limits.h include to hook.c
PATH_MAX is only defined in limits.h in musl libc, so ensure that it is
included. Presumably this is also required on other platforms.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Andrew Gregory
fb72eede20 doc/index.txt: update for pacman 5.0
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:52 +10:00
Andrew Gregory
c1bb41a037 dump_pkg_info: fix wide character title alignment
The padding added to the end of the title was based on the return value
of mbstowcs which is the number of characters.  This caused alignment
issues for languages with characters that span multiple columns.
Instead, base the padding on the number of columns needed by the
translated string as returned by wcswidth.

Fixes #47980

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:52 +10:00
Doug Newgard
252183b409 Bring makepkg zsh completions up to date
Signed-off-by: Doug Newgard <scimmia@archlinux.info>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:52 +10:00
Allan McRae
fea9abc8db Release 5.0.0
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-30 10:16:36 +10:00
Allan McRae
e910d45ac0 Update translations
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-30 10:13:55 +10:00
Daniel Wallace
9604570add Update zsh completion for pacman 5
also include updates from pacman 4.2

https://bugs.archlinux.org/task/47559

Original-patch-by: Boris Staletic <bstaletic@archlinux.net>
Signed-off-by: Daniel Wallace <danielwallace@gtmanfred.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-29 09:50:11 +10:00
Allan McRae
6ea97963b3 Create makepkg-template and system hook directories upon install
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-29 09:50:11 +10:00
Allan McRae
5343ec7661 Add HookDir to example pacman.conf
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-29 09:50:11 +10:00
Allan McRae
43a09d1663 bash_completion: update pacman completion
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-29 09:50:09 +10:00
Allan McRae
b65c7afc17 bash_completion: update makepkg completion
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-27 12:40:15 +10:00
Allan McRae
c781a85387 pacman.conf.5: document system hook directory
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-27 12:40:13 +10:00
Allan McRae
a5a9080219 pacman.8: document --hookdir
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-27 12:39:22 +10:00
Allan McRae
18d00097a2 makepkg.conf.5: document option arguments in DLAGENTS need spaces escaped
Fixes FS#43304.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-26 18:41:56 +10:00
Allan McRae
599520e489 PKGBUILD.5: document split package depends are not used during packaging
makepkg only considers global {make,}depends when checking require packages
are installed before building.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-26 18:34:33 +10:00
Allan McRae
4291500c82 Remove spacing when outputting package sizes
This spacing appears to have been added to align sizes.  It sometimes worked...

$ pacman -Si glibc | grep Size
Download Size   :   8.03 MiB
Installed Size  :  35.08 MiB

And it sometimes failed...

$ pacman -Si pacman | grep Size
Download Size   : 662.82 KiB
Installed Size  : 4045.00 KiB

Remove the spaces for a consistent output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-25 15:30:56 +10:00
Allan McRae
47ea63ff3b makepkg: do not run prepare() and pkgver() with --repackage
Bug introduced with commit 8454daa7.

Reported-by: Zuyi Hu <hzy068808@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-25 15:23:16 +10:00
Zuyi Hu
765e29b67c Fix testing of arrays status for arch specific variables
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-25 12:36:50 +10:00
Allan McRae
ad65462a05 Pull translations updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-17 13:39:02 +10:00
Johannes Löthberg
9ff29545e5 doc: alpm-hooks.5: Remove extra space in alpm-hooks man page
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-15 15:01:31 +10:00
Allan McRae
8d9890d3f4 Cast events to void* before passing to callback
Silence warnings from clang about typecasting alignment.

Reported-by: Rikard Falkeborn
Original-patch-by: Olivier Brunel
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-15 14:52:05 +10:00
Andrew Gregory
ab50864a75 add alpm_list_append
alpm_list_add always returns the provided list making it impossible for
callers to check whether or not the operation actually succeeded without
manually comparing the list length before and after.  alpm_list_append
instead returns a pointer to the newly created list item so that success
can be checked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-15 14:47:36 +10:00
Dominik Fischer
9813107c33 test version range restrictions corner case
The test introduced herein illustrates a behavior that may be unexpected
to package writers.

It creates a package "pkg3" that is configured to depend on a
"dependency" which version is between 3 and 4, inclusive. Two other
packages are already present, providing "dependency" in version 2 and 5,
respectively. So, the situation looks roughly like this:

                 pkg1               pkg3                pkg2
               provides          depends on           provides
                  |            <------------>            |
version __________2____________3____________4____________5___________...

This seems to be enough to satisfy pacman when installing "pkg3". From
an iterative standpoint, this is completely logical: First, the
requirement "dependency>=3" is checked. There is a package that
satisfies this restriction, it is called "pkg2". Afterwards,
"dependency<=4" is covered in the same way by "pkg1".

Nonetheless, what a package writer intends when specifying

   depends=('dependency>=3' 'dependency<=4')

is most probably that pacman should only allow this package to be
installed when there indeed is a package present that provides a version
of "dependency" that lies _between_ 3 and 5.

Signed-off-by: Dominik Fischer <d dot f dot fischer at web dot de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-15 14:47:36 +10:00
Rikard Falkeborn
00c0329531 Add pacsort tests with invalid input
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 14:05:31 +10:00
Rikard Falkeborn
88f348f2b1 pacsort, introduce define for escape_char error code
The signedness of char is implementation defined. On systems where
char is unsigned, comparing a variable of type char with -1 is never
true, due to integer promotion rules. To avoid this, introduce a
define for invalid field separators where -1 is cast to char. This will
ensure that the return value check works for both unsigned and signed char.

Fixes one warning [-Wtype-limits] for comparissons with -1 when compiling
with -funsigned-char.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 14:05:28 +10:00
Rikard Falkeborn
875c017e4d Make alpm_graph state signedness explicit
The signedness of char is implementation defined. Since the
alpm_graph state is clearly meant to be signed, make the
signedness explicit.

This fixes bugs on systems where char is unsigned, in comparissons
of the following type:

  if(v.state == -1)

which, if state is unsigned, will never be true due to integer
promotion rules.

Fixes failing test/pacman/tests/sync012.py when compiling with -funsigned-char.

Fixes two warnings [-Wtype-limits] for comparissons with -1 when compiling
with -funsigned-char.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:59:19 +10:00
Allan McRae
2a0d188d6b Update NEWS for pacman-5.0
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Allan McRae
fa72c2cdc2 Update README for pacman-5.0
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Allan McRae
4742f5929d Update copyright years for 2016
make update-copyright OLD=2015 NEW=2016

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Daniel Hahler
8ca96447dd zsh_completion: add -q/--quiet for -Q/-S
This should also be added for "-Fh", but that is missing completely in
zsh_completion.

1: https://lists.archlinux.org/pipermail/pacman-dev/2015-November/020538.html

Signed-off-by: Daniel Hahler <git@thequod.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Alastair Hughes
6aee32102f Replace mktemp's --tmpdir option with shell code.
bacman and updpkgsums used GNU mktemp's --tmpdir option, which is not
supported by some other implementations (including busybox). Replace that with
shell code.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Allan McRae
774c7eb24d Do not warn about missing files in NoExtract
The CheckSpace option checks the size of all files in a package being replaced
and gives a warning when it can not read the file.  However, files in NoExtract
are expected to be missing and should not be warned about.

Fixes FS#47470.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Florian Pritz
a671fa497c makepkg: Output full URL in case of download failure
Most entries in $sources contain variables so finding out why a URL
fails to download is hard because one has to manually replace the
variables when looking at the PKGBUILD. Simply output the full URL here
so that it can be easily seen what is wrong.

Old:
==> ERROR: Failure while downloading example-1.2.4.tar.gz

New:
==> ERROR: Failure while downloading http://example.org/releases/1.1/example-1.2.4.tar.gz

With the new format it is much more obvious that the directory name is
the culprint (1.1 vs 1.2) while the old one would not display that
information.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:34:30 +10:00
Olivier Brunel
eadf389607 alpm: Abort ASAP on failure in pre-transaction hooks
There is no need to run any/remaining pre-transaction hooks as soon as a failure
has occured, which will lead to aborting the transaction.

So if an error occured during the first phase (reading directories/parsing
files), or as soon as a hook flagged abort_on_fail does fail, we stop processing
them and return.

(For post-transaction hooks, all hooks are run regardless since there's no
aborting.)

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:33:26 +10:00
Allan McRae
8454daa7fe makepkg: run pkgver() and prepare() with --noextract
Modifications made to the source before running with --noextract may alter
the version string returned by pkgver(). Always run this function if present
and check build status before proceeding.  Fixes FS#46800.

Also run prepare() when --noextract is used (unless --noprepare is specified).

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:28:48 +10:00
Allan McRae
686fae6d74 Give error message when --files will do nothing
Point people towards the help when using "pacman -F" or "pacman -F foo".

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:15:04 +10:00
Allan McRae
d721bae443 alpm-hooks: add Description field
The "Description" field allows a hook to provide a some text for frontends
to use in describing what the hook is doing.  For example:

Description = updating info page directory

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:15:02 +10:00
Allan McRae
760bea5432 Show progress processing hooks
Introduces the ALPM_EVENT_HOOK_RUN_{START,DONE} events that are triggered
at the start and end of running an individual hook.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:12:23 +10:00
Allan McRae
8d3bd4ec13 Add ALPM_EVENT_TRANSACTION_{START,DONE} events
This provides a way to detect when the processing of package changes starts,
allowing pacman to delineate hook output and package installation/removal
output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 15:12:32 +10:00
Olivier Brunel
132ec4c3b9 Add events ALPM_EVENT_HOOK_{START,DONE}
Add events to let frontends know when hooks are being processed (and when it's
done), as that might be useful to update the UI.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
2015-12-15 15:09:28 +10:00
Allan McRae
3802cab563 Collect all triggered hooks before running them
Having a first pass that checks which hooks are triggered followed by a
second pass of the triggered hooks allows us to only provide output when
a hook is actually triggered.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 15:03:14 +10:00
Allan McRae
f98541400b Pull translations from Transifex and prepare for next release
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-09 16:11:58 +10:00
Andrew Gregory
2015f0d1d9 alpm_run_chroot: remove dead code
Removes a leftover error message from when fdopen and fgets were used to
read from the pipe.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 10:34:31 +10:00
Allan McRae
137ea39fa1 makepkg: record build information in .BUILDINFO
This information can be used to reproduce build conditions, which can then be
used to determine if a package builds reproducibly.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 10:20:53 +10:00
Luke
9cdfd18739 makepkg: add whirlpool to the list of hashing algorithms
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 10:11:33 +10:00
David Macek
71f9de64c6 alpm_initialize: Fix double slash in sys hook dir path
The path of the default system hook directory was created
by concatenating `myhandle->root` (usually "/"), and
SYSHOOKDIR (usually "/usr/share/libalpm/hooks/"), resulting
in "//usr/share/libalpm/hooks/". Fix this by skipping the
initial slash from SYSHOOKDIR.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 00:22:40 +10:00
Andrew Gregory
8ee084dbb3 db_update: always clear db flags after update
Signature downloading and DB validation was being based on the most
recent download status for the DB.  If a DB successfully downloaded but
a signature did not, db_update would move to the next server.  If the
next server tried does not have a more recent copy of the DB, db_update
would not download the DB again and would forget that the DB had
previously been updated.  In this case it would skip validation
entirely, leaving an updated DB with the original validation status.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 00:15:35 +10:00
Alastair Hughes
d069d9714a Updated the documentation for makepkg's -L option.
At some point back in 2009, logging was expanded to cover all of the packaging
functions, but the man page was not updated to reflect that. Fix that!

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 00:04:49 +10:00
Andrew Gregory
a8e2578feb remove soft interrupt handler before cleanup
The soft interrupt handler dereferences config, causing a segfault if
it is called during cleanup.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:10:43 +10:00
Andrew Gregory
b8a7277061 extract soft interrupt handlers
Delays handler setup until after config is set to a valid
value to avoid a segmentation fault.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:10:23 +10:00
Andrew Gregory
8089081ef9 extract SIGSEGV handler
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:10:06 +10:00
Andrew Gregory
c74495a3b2 extract SIGWINCH handler
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:09:53 +10:00
Andrew Gregory
4d2317dafb move signal handlers to sighandler.[ch]
Signals are special because they run asynchronously, making them
non-trivial to handle correctly.  Move the handlers a separate file to
offset them from the normal code and make them easier to separate into
individual functions without further cluttering pacman.c

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:09:39 +10:00
Andrew Gregory
220a3ce2b8 avoid unsafe functions in signal handler
signal(7) lists a set of functions that can safely be called from within
a signal handler.  Even fileno and strlen are not guaranteed to be safe.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:08:43 +10:00
Andrew Gregory
8d11aa3cdf remove SIG_IGN check when setting signal handler
Our signal handler provides a way to gracefully interrupt a transaction
and should always be set.

The check appears to have originally been copied directly from the glibc
manual.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:08:05 +10:00
Andrew Gregory
85508b478e do not catch SIGTERM
On SIGTERM pacman was exiting immediately, even in the middle of
a transaction.  In this case we should leave the lock file in place as
an indication that the database may not be in a consistent state.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 18:07:24 +10:00
Andrew Gregory
7fb8a299c2 pacman: exit without memory cleanup on signals
Memory allocation/deallocation functions are not safe to call from
signal handlers.  Just remove the lock file if there is one and exit
immediately.

Fixes: FS#46375, FS#45995, FS#47011

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:57:49 +10:00
Andrew Gregory
7b6f7bbe09 add and expose alpm_unlock
alpm_unlock is a limited version of alpm_release that does nothing but
the actual unlinking of the lock file and is therefore safe to call from
signal handlers.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:53:37 +10:00
Andrew Gregory
16623a7ea5 handle_unlock: return 0 if lockfile == NULL
Returning -1 is useless since we don't provide any way
to determine why it failed.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:52:16 +10:00
Andrew Gregory
4838d250e5 skip conflicts resolved by file replacement
When replacing a file with a directory, any files inside the new
directory cannot possibly exist on the filesystem and can be skipped.
This allows cross-package symlink-to-directory transitions when there
are files with the same name under both the symlinked directory and the
new directory.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:46:22 +10:00
Andrew Gregory
bb5e6c3b76 always unlink files before extraction
libarchive will not extract a directory over an existing directory
symlink, making it impossible to replace a symlink with a directory
across packages.  Adding the ARCHIVE_EXTRACT_UNLINK and
ARCHIVE_EXTRACT_SECURE_SYMLINKS causes libarchive to unlink the existing
symlink and prevents it from extracting any paths that contain
a symlink, which we should not be doing anyway.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:46:12 +10:00
Allan McRae
8a373096f5 Detect potential conflict when symlink to directory is changing to directory
When a symlink to a directory is changing to a directory, any package file
inside the new directory can create an unexpected conflict with the filesystem.

Reported by Neofytos and Luca from Chakra.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:46:11 +10:00
Allan McRae
088649534e Add large file support CFLAGS to pkgconfig file
Large file support is enabled by our configure script as required.  If anything
linking to libalpm does not also define large file support, there will be
differences in the size of off_t which are not caught until runtime.

Add the required CFLAGS to the pkg-config file so that users of libalpm know
what flags are required.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-04 11:06:49 +10:00
Andrew Gregory
dfa4dcb16d run_chroot: always clear script output buffer
If the script output does not end in a newline there could still be data
in the buffer after the poll loop.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-29 08:12:44 +10:00
Evangelos Foutras
34bbe4cf7b pacdiff: do not require DIFFPROG for -o/--output
Signed-off-by: Evangelos Foutras <evangelos@foutrelis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 22:57:24 +10:00
Andrew Gregory
5312e683fc hooks: pass matched targets to hooks
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 22:53:24 +10:00
Andrew Gregory
8ad893732d allow specifying input to scriptlets
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 22:52:11 +10:00
Andrew Gregory
b42d0852f3 allow arguments in hook Exec fields
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 16:26:51 +10:00
Andrew Gregory
e0607f6ae2 tap.py: replace newlines with escape sequence
Newlines clutter tap output and can potentially confuse TAP parsers.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 16:23:56 +10:00
Andrew Gregory
e03fa67445 pmrule.py: add FILE_CONTENTS rule
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 16:23:08 +10:00
Allan McRae
23f128ad5e lint_pkgbuild/variable: increase robustness
Approach the detection of variables of the wrong type using an approach
similar to that used for construction of .SRCINFO files. While doing silly
things in bash could still result in false negatives, this approach should
be very robust to generatinf false positives results.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-23 16:03:33 +10:00
Allan McRae
663c74150a makepkg: merge arch dependent variables after PKGBUILD linting
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-23 16:02:32 +10:00
Allan McRae
ef1fb0ef81 makepkg: remove obsolete comment
Behaviour changed in commit dce82f9d.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-23 11:13:39 +10:00
Allan McRae
c26e5b81e5 lint_pkgbuild: explicitly return value
Set the return value to be local and always explictly returns it.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-23 11:13:39 +10:00
Silvan Jegen
947dfda515 Refactor strtrim function
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-11 14:03:49 +10:00
Rikard Falkeborn
9e22e75fa1 Use correct format specifiers
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-11 13:47:08 +10:00
Aaron Campbell
bf0e8e6b43 Refactor lint_source to work with earlier versions of Bash
Negative subscripts to indexed arrays are not supported before 4.2.  However,
since substring expansion works on arrays, we can specify an offset of -1 to
be taken relative to one greater than the maximum index of the specified
array (see Parameter Expansion section of the bash man page).  This works with
both Bash 4.1 and 4.2, and 4.1 is already the oldest supported by pacman.

Signed-off-by: Aaron Campbell <aaron@monkey.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-05 11:55:17 +10:00
Andrew Gregory
8fa02036c3 files_search: reset found for each target
Otherwise any invalid targets following a successful match will not get
an error message.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 15:06:21 +10:00
Andrew Gregory
726712aa08 files_search: free compiled regex
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 15:06:08 +10:00
Andrew Gregory
978b197120 files: do not unnecessarily strdup targets
Targets are never modified so we can just use the original copy.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 15:05:52 +10:00
Andrew Gregory
0d877ec429 files.c: add vim modeline
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 14:51:49 +10:00
Andrew Gregory
08b0b6de96 add detail to broken dependency errors
The difference between a sync target having an unmet dependency and
breaking a dependency for an installed package is a common source of
confusion.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 14:50:57 +10:00
Andrew Gregory
556c56d4d5 add --quiet to -Fh
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-04 14:50:57 +10:00
Andrew Gregory
6eac7258cd ensure realloc has a positive size
If given size 0 POSIX allows realloc to return a pointer that is not
suitable for use.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-03 21:45:09 +10:00
Mohammad Alsaleh
0fd6d354a6 zsh_completion: Handle --ignore/--ignoregroup correctly
Completion now works as expected with a comma-separated sequence.

Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-03 15:07:11 +10:00
Pierre Neidhardt
d5b0f0c26f package.c: Fix incorrect buffersize and constant-folding
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-03 14:41:25 +10:00
Florian Pritz
906dc0ce24 Add -F --machinereadable option
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-03 14:36:59 +10:00
Florian Pritz
697377aae3 Document pacman -F
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-03 14:36:53 +10:00
Allan McRae
d8621b981e scripts/po: fix translated file name
This file was renamed during review and its entry in POTFILES.in was not
updated.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-28 17:04:08 +10:00
Andrew Gregory
dcc1b22cb3 _alpm_hook_run: check path length before copying
If a hook path equals or exceeds PATH_MAX characters the path will be
left unterminated.  Pre-calculating the path length also allows us to
use the more efficient memcpy over strncpy.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-28 14:22:09 +10:00
Benjamin Yates
1142a32c7f makepkg: fix $pkgname element duplication
run_split_packaging did not preserve the $pkgname array correctly, and
would create duplicate entries in the list during restore.

After restoring the backup (a b c) would become (a b c b c).

This probably went unnoticed because during --install, pacman would
reconcile the duplicates.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-28 13:26:25 +10:00
Allan McRae
960b64553d libmakepkg: fix pkgver checking
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 20:44:57 +10:00
Andrew Gregory
6fdc589fc6 add alpm-hooks man page
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 19:39:22 +10:00
Andrew Gregory
5b6526a2ad hook.c: print invalid option name
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 19:38:57 +10:00
Andrew Gregory
b46bdeea14 order hooks by file name
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 19:38:32 +10:00
Pierre Neidhardt
3c67127018 Align titles automatically in information display
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 18:52:05 +10:00
Rikard Falkeborn
0c5dbdbfec Alpm, check for NULL in free-functions
Also, use FREE() instead of free() in _alpm_backup_free()
to set the pointers to NULL.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 14:22:30 +10:00
Mohammad Alsaleh
4c5bf09eec zsh_completion: Add --asdeps/--asexplicit to -U options
Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 14:03:15 +10:00
Pierre Neidhardt
456ebe8f8e Use ARRAYSIZE macro for non-string array size computation
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-27 13:53:18 +10:00
Mohammad Alsaleh
9809102237 makepkg: Fix hard-coded debug suffix
Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-22 09:40:37 +10:00
Rikard Falkeborn
e28aff4d87 pacsort: clean up if error
* free memory
* close open file

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-21 15:12:25 +10:00
Rikard Falkeborn
aa8a674b6b pacsort: don't overwrite memory if realloc fails
That makes it impossible to free it later.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-21 15:11:27 +10:00
Rikard Falkeborn
19d373c9b9 pacsort: handle failing list_add
Since it can fail, check the return value.
If it fails, we need to free the memory of the object we wanted
to add to the list.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-21 15:06:25 +10:00
Pierre Neidhardt
4b3df10d5d HACKING: Allow the use of 'sizeof' on values
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-21 14:50:56 +10:00
Jan Alexander Steffens (heftig)
2c72c8b822 makepkg: Set CCACHE_BASEDIR to make paths in $srcdir relative
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 14:33:30 +10:00
Jan Alexander Steffens (heftig)
2627b423ff makepkg: Correctly layer distcc and ccache
ccache expects further compiler wrappers to be specified via
CCACHE_PREFIX. Otherwise, ccache will hash the wrapper executable
instead of the real one.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 14:33:17 +10:00
Jan Alexander Steffens (heftig)
70e6875ad9 libmakepkg: Add check_buildoption for distcc and ccache
makepkg used to check OPTIONS too, which could override
BUILDENV. Implement a new function that handles these
options more like OPTIONS.

This also reduces code duplication a bit.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 14:32:59 +10:00
Allan McRae
5d4a3f101c makepkg: separate "sourcefile" into two words
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 14:25:35 +10:00
Allan McRae
5301d3fe8f Remove space before ellipses
Makes all use of ellipses consistent...

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 13:48:56 +10:00
Allan McRae
29d4dcf767 Pluralize malloc failure string
Not particularly useful in English (will always be plural), but useful in
languages that have multiple plural forms.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 13:48:56 +10:00
Allan McRae
501242a35b Ignore cov-int directory for Coverity scan
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-19 13:48:56 +10:00
Allan McRae
0ee1beca12 contrib/checkupdates: separate fakeroot call and command
Separating the fakeroot command and the pacman call with "--" prevents weird
interactions with some locales.  See FS#46405.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 11:27:56 +10:00
Pierre Neidhardt
c99ebca83e package.c: Comment style
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 11:24:31 +10:00
Allan McRae
002acb4674 Do not print any root prefix in files database operations
Combining with the --root flag and outputing a consistent root prefix leads
to many situations that make no sense.  Instead, do not print any prefix for
any --files operations.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 11:16:44 +10:00
Pierre Neidhardt
cbb7e180c7 package.c: Remove obsolete param from doc
Signed-off-by: Pierre Neidhardt <ambrevar@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:24 +10:00
Andrew Gregory
a5759cb0d7 add hook tests
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:24 +10:00
Andrew Gregory
b76409609c pactest: add hook/script support
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:24 +10:00
Andrew Gregory
4ceb1c5bf9 util.py: return the created path
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Andrew Gregory
60ebee7a6e pactest: use pacman --hookdir option
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Andrew Gregory
7000bf9198 pacman: add user hook directories
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Andrew Gregory
e8e872c8f9 validate hooks after parsing
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Andrew Gregory
16718a216e run hooks during trans_commit
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Andrew Gregory
568a89d580 add hook data types and parser
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Andrew Gregory
c261210ccf handle: add hookdirs option
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Pierre Neidhardt
46a1ac6429 PKGBUILD.5: post_*() are functions, not scripts
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-10-18 10:59:23 +10:00
Allan McRae
e8deba3b87 makepkg: remove ability to build individual packages
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-23 01:02:23 +10:00
Allan McRae
0adb74b293 libmakepkg: remove declaration of unused local variables
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-22 16:11:32 +10:00
Allan McRae
dd3fe853b3 libmakepkg: return 1 on error in arch array
The return value was being assigned when an error was found in a PKGBUILD's
arch array but it never was returned.

Also remove error message explaining about adding the arch array to a PKGBUILD.
That was added a long time ago when the arch array first became compulsory.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-22 16:06:29 +10:00
Allan McRae
19e61a9e07 libmakepkg: update .gitignore
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-22 15:11:52 +10:00
Allan McRae
be503c6eac makepkg: remove FORCE_VER variable
This variable is no longer in VCS building.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-22 14:54:03 +10:00
Andrew Gregory
6946d7d1b7 check fileconflicts and diskspace outside commit
This is necessary in order to be able to run PreTransaction hooks as
close to the actual commit as possible so that we don't prematurely run
hooks for a transaction that ultimately never happens.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-20 17:36:53 +10:00
Andrew Gregory
af747ef34a move ini parser into common
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-20 17:36:53 +10:00
Andrew Gregory
edbe6c2bdc move strtrim to util-common
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-20 17:36:27 +10:00
Andrew Gregory
75fe6ef104 sortbydeps: skip local packages being updated
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-19 15:12:35 +10:00
Allan McRae
486643083c libmakepkg: check if PKGBUILD variables are arrays or not as appropriate
When extracting variables from PKGBUILD (e.g. for .SRCINFO creation) we make
assumptions about whether variables are arrays or not.  This adds a check to
the PKGBUILD linter to ensure variables are arrays or not as appropriate.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-07 11:22:00 +10:00
Allan McRae
1586b23080 libmakepkg: util/pkgbuild.sh needs processing on build
pkgbuild.sh contained @DEBUGSUFFIX@ and so needs to be run through the sed
command on build.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-07 11:21:59 +10:00
Allan McRae
ec50ec8a15 pacman.8: Consistently refer to the package database
We use "package database" everywhere apart from in the description of "-y".

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-09-07 11:21:58 +10:00
Sebastian Lackner
5780350751 libalpm: Force update when database is marked as corrupted.
When a database and its signature is updated non-atomically on a server,
there is a window where a user may update the database but grab the old
signature.  The database is marked as invalid by libalpm, which can be
fixed by forcing a refresh (assuming the server has caught up and the
user realizes what has happened) or with a future update of the repo.
Work around this by forcing a repository refresh whenever a database is
invalid.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:45:09 +10:00
Andrew Gregory
ae97082e98 fill in name_hash for assumeinstalled options
alpm_depend_t is an exposed data type.  Front-ends may opt for alloc'ing
one and filling the fields manually, but alpm's _alpm_hash_sdbm is not
exposed, making it impossible for them to fill in the name_hash field.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:42:26 +10:00
Andrew Gregory
48f4efd9a1 copy assumeinstalled options
All other option setters copy their input.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:41:14 +10:00
Andrew Gregory
ccd3a3eb9f check assumeinstalled for meaningful mod
assumeinstalled options are used as provisions for which MOD_EQ and
MOD_ANY are the only meaningful settings.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:40:00 +10:00
Andrew Gregory
1ee2032b7f check dep versions before calling strcmp
Fixes a segfault when trying to remove an assumeinstalled
option without a version.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:39:15 +10:00
Rikard Falkeborn
2d0e2bf255 pacman/util.c: Fix memory leak if realloc fails
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:36:21 +10:00
Allan McRae
b8c9385b8b Remove ko_KR translation
The "ko_KR" locale is the same as the "ko" locale.  Remove the "ko_KR" variant
as it is incomplete and has been superseded by "ko" on transifex.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-08-08 10:36:03 +10:00
Allan McRae
877578762c libmakepkg: move color settings to function
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-20 14:56:12 +10:00
Allan McRae
8566034866 pacman/files.c: fix memory leak on regex error
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-20 13:41:36 +10:00
Levente Polyak
deac973188 ensure matching database and package version
While loading each package ensure that the internal version matches the
expected database version to avoid the possibility to circumvent the
version check.
This issue can be used by an attacker to trick the software into
installing an older version. The behavior can be  exploited by a
man-in-the-middle attack through specially crafted  database tarball
containing a higher version, yet actually delivering an  older and
vulnerable version, which was previously shipped.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Signed-off-by: Remi Gacogne <rgacogne@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-20 12:50:39 +10:00
Dave Reisner
445aa3b52c dont remove x bit when marking pkgdir RO
f170a94c13 potentially causes $pkgdirbase/$pkg to be undeleteable
with -R or -C if a previous build was interrupted. We simply can't
traverse to this directory, and rm blows up.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-20 12:50:25 +10:00
Allan McRae
bbab90836b libmakepkg: lint_package requires cd_safe
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-20 11:43:27 +10:00
Allan McRae
3c41030964 Handle repo/pkg style arguments to sync repo file listing
Passing "-Fl pkg" will print the filelist for the first occurance of "pkg"
in the sync repos. Other version of the package can be printed using
"-Fl repo/pkg".

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:31 +10:00
Allan McRae
fd9ff672b0 Add regex search option to sync database file searching
e.g. pacman -Fsx kcm.*print.*\.so

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:31 +10:00
Allan McRae
acf95f6b3b Implement searching for a file in the sync databases
Locates all packages that contain the listed file
e.g. pacman -Fs libpng.so

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:31 +10:00
Allan McRae
137a4086de Implement listing files from sync packages
Does the equivalent of the -Ql option for local packages

e.g. pacman -Fl glibc

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae
488ca24265 Implement locating file owner in sync files database
Equivalent to -Qo but for packages in the sync database
e.g.  pacman -Fo /usr/bin/pacman

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae
5782b8356c Prototype pacman files database operations
Add the -F/--files operations, -s/--sync support and nd provide dummy
functions for -s/--search, -l/-list and -o/--owns.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae
e49abc9860 pacman: move database syncing to util.c
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae
b0dac754d2 Add pacman support for .files databases
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae
289fdf0d1d Read file lists from databases
If a sync database contains a "files" file, the file list will be read.

Currently, there is no known demand for the file list to be lazy loaded by
any libalpm frontend, so these files are read whenever present. Lazy loading
can be implemented when a demand exists.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:30 +10:00
Allan McRae
f6c55b3c3f Allow frontends to specify the sync database extension
This allows frontends to select between the .db and .files databases
currently supplied by repo-add or any other compatible database.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-15 10:57:29 +10:00
Allan McRae
1ada16f017 Fix formatting in parsearg_upgrade
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-14 20:46:03 +10:00
Allan McRae
2d7a41539b Simplify sync_cleandb
1) Remove checks for removing pre-tardb files
2) Remove the long redundant keep_used parameter
3) Fix pacman error due to removing .sig file along with database

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-14 20:45:55 +10:00
Allan McRae
94204d1089 Do not warn about packages that optionally require a removal when ignoring deps
If a transaction is removing a package while ignoring all dependencies, there
should not be any warning about other packages optionally requiring it.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-14 17:15:33 +10:00
Allan McRae
ff487212a2 Do not warn about downgrades when only downloading package
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-12 16:23:25 +10:00
Andrew Gregory
2e5e496eb0 Fix overflow warnings
Fix new warnings generated by gcc-5 about potential overflows.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-12 16:23:18 +10:00
Lukas Fleischer
a187fa4562 Match providers when showing optdep install status
Use alpm_find_satisfier() instead of alpm_db_get_pkg() when retrieving
the install status of a package to make sure we spot providers as well.

Fixes FS#36412

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Johannes Löthberg
4b0bc2cf97 repo-add: Reject armored signatures
Pacman cannot handle armored signatures, so make repo-add error out if
one is detected.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Johannes Löthberg
aa9aa343cb makepkg: Add flag for printing SRCINFO to stdout
This commit adds a makepkg option to generate and print the SRCINFO file
for a PKGBUILD, required by the new AUR, to stdout.

AUR 4.0 will use Git instead of source tarballs for uploading packages,
so making makepkg capable of printing the SRCINFO would simplify package
management, instead of having to extract it from a source tarball.

It is also useful for scripting other things, so that instead of having
to parse PKGBUILDs, one can make makepkg generate the SRCINFO and then
you can parse that instead, which is much simpler and less error-prone.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Johannes Löthberg
2bed2090fb repo-add: Generate unarmored DB signature
Pacman cannot handle armored signatures, so use gpg's --no-armor flag to
force an unarmored signature.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Johannes Löthberg
53d9633449 util.c: table_display: Fix incorrect docstring
Commit 7b8f8753 removed the title parameter but forgot to remove it
from the docstring.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-06-20 17:32:57 +10:00
Wieland Hoffmann
0f302df5ed makepkg-template.1: Clarify which file version-less markers use
The old text could be interpreted such that makepkg-template compares
the version numbers of the templates to find the most recent
one. Rephrase this to make it explicit that "$template_name.template" is
used.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-06-20 17:32:56 +10:00
Allan McRae
3d4529335c libmakepkg: extract functions for source download and extraction
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-19 23:43:00 +10:00
Allan McRae
1a17249159 libmakepkg: extract functions for handling source URLs
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-19 23:43:00 +10:00
Allan McRae
366adc3bb0 libmakepkg: fix test style
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-19 23:43:00 +10:00
Allan McRae
23e3c48526 libmakepkg: move more functions for extracting information from PKGBIULDs
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-19 23:43:00 +10:00
Allan McRae
15b6cecdd5 libmakepkg: extract more utility functions
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-19 23:43:00 +10:00
Allan McRae
8ab106eb9b libmakepkg: extract get_full_version and get_pkg_arch
These functions group in with other functions that extract PKGBUILD
information.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-16 14:10:42 +10:00
Allan McRae
61dd7e03be Simplify libmakepkg .gitignore 2015-05-16 14:10:42 +10:00
Allan McRae
dbbe76b83d makepkg: put further restrictions on pkgbase
pkgbase should be subject to the same restrictions as pkgname

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-16 14:10:42 +10:00
Allan McRae
9302593cfb makepkg: merge validate_pkgver into check_pkgver
The check that pkgver is non-empty done in check_pkgver should also be
performed after running the pkgver() function.  Merge validate_pkgver
into check_pkgver and run check_pkgver after updating pkgver.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-16 14:10:42 +10:00
Allan McRae
c9a7b7e0bf libmakepkg: extract PKGBUILD linting functions
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-16 14:10:42 +10:00
Allan McRae
d38c098787 libmakepkg: extract in_array 2015-05-16 14:10:42 +10:00
Allan McRae
83b734a103 libmakepkg: move functions for extracting pkgbuild attributes
Also rename some functions for clarity:
funcgrep -> grep_function
extract_global_var -> extract_global_variable
extract_function_var -> extract_function_variable
pkgbuild_get_attribute -> get_pkgbuild_attribute

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-16 14:10:42 +10:00
David Macek
d5536d3eb3 libalpm: Do a sanity check before manipulating final DB URL
The change in commit 9d96bed9d6 causes download errors for the .db.sig file
in case the final URL for the .db file contains query strings or other
unexpected stuff. This commit isn't intended to be a total solution, but it
should eliminate the problem in the most obvious cases.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:55 +10:00
David Macek
d568a4335b Fix comment in alpm_db_update
Fix comment to better explain the magic constant used when allocating a buffer
for ".db.sig" URL.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:55 +10:00
Allan McRae
99c7b1b088 libmakepkg: fix test bracket style
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:55 +10:00
Andrew Gregory
9a9e0203de alpm_logaction: implement documented return value
"return 0 on success, -1 on error (pm_errno is set accordingly)"

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:55 +10:00
Andrew Gregory
1545a04253 alpm_logaction: allow falling back to syslog
Even if opening the log file fails, if a user has enabled syslog we may
still be able to log to that.  Set the error return value and continue
instead of bailing out.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Andrew Gregory
e4af5e3c97 alpm_logaction: check logfile before opening
valgrind does not like calling open(NULL, ...).  This also makes the
return value 0 if logfile has not been set.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Andrew Gregory
ae7067440c merge _alpm_logaction into alpm_logaction
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
David Macek
f9423cfa5d makepkg: Empty/create only $pkgdir's relevant to current PKGBUILD
Currently makepkg clears the whole $pkgbasedir which is needless. Moreover,
in the obscure case of multiple makepkg runs (with different $pkgname) that
share a $pkgdirbase, only $pkgdir's from the last run will remain. Since
I consider the contents of $pkgdir an important artifact, this commit restricts
the deletion to individual $pkgdir's.

When CLEANUP is set, the behavior is unchanged.

Discussed in:
https://lists.archlinux.org/pipermail/pacman-dev/2015-February/019939.html

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Charles Duffy
1040ad4e71 Fix compilation if libarchive headers are not in standard location
With commit 097d5a478b, including alpm.h also drags in archive.h.
Ensure the tools we build that depend on ALPM also include the necessary
flags to find libarchive headers if they are not installed in a standard
location.

[Dan: Add commit message]
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Dominik Fischer
b0ae59724e makepkg-template: support multiple --template-dirs
Especially when maintaining local templates in addition to the ones
stored in /usr/share/makepkg-template, it can be useful to include
templates stored in multiple different locations into one PKGBUILD. This
patch makes this possible by allowing --template-dir to be specified
multiple times.

This also introduces a dedicated error message when a template cannot be
found, in contrast to the already existing "Couldn't detect version for
template '%s'".

If a template of the same name is present in more than one of the given
directories, the last one always takes precedence.

Neither the default behaviour without the option given, nor the handling
of a single template dir is changed.

Signed-off-by: Dominik Fischer <d.f.fischer@web.de>
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Andrew Gregory
d4e5de4bf6 pacsort: fix warning about signed overflow potential during comparison.
Some crazy person assumed we would have fewer than INT_MAX columns.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Allan McRae
54067c390f Silence warning from clang
clang is wrong - dbfile is always used initialized in that function.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Allan McRae
4dbac804a3 Pluralize callback string
In English, this string only has it plural form. However, we need to use the
pluralized translation as some languages can have multiple plural formats.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Allan McRae
4e6848dbea Update source URL
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-05-12 14:00:54 +10:00
Andrew Gregory
e374e6829c close stdin before running install scripts
libalpm does not guarantee that script output will be presented to the
user or that stdin will be connected to a terminal.  Close stdin so that
scripts do not attempt to use it for user interaction.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:44:14 +10:00
Andrew Gregory
721b785e73 be_package: fallback to standard filelist loading
In order to work properly, loading the filelist from an mtree file
requires a libarchive patch that has not yet been included in an
official release.[1]  Under certain circumstances, an unpatched
libarchive may refuse to read the mtree file due to inconsistencies
between it and the user's file system.  In order to allow alpm to
recover in this situation, read the mtree data into a temporary filelist
that is only copied over to the package if the entire read is
successful.

[1] 661684170b

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:44:13 +10:00
Andrew Gregory
edeafcc988 add_entry_to_files_list: pass filelist directly
Allows entries to be added to arbitrary filelists not connected to
a package.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:44:13 +10:00
Ivy Foster
bf3aec8c32 Add makepkg option --packagelist
makepkg --packagelist prints the name of each package that would
normally be produced, minus $PKGEXT, and exits.

Implements FS#42150

Signed-off-by: Ivy Foster <joyfulgirl@archlinux.us>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:44:10 +10:00
Allan McRae
b520c6312f repo-add: merge desc and depends files
There is little point in these two files being separated as the whole sync db
is parsed at once.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
2408d46c1b makepkg: write validpgpkeys to .SRCINFO
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
eb5da52c0e PKGBUILD.5: have epoch directly following pkgver/pkgrel
These three fields should be grouped together.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
b630f455d2 update repo-add documentation for removal of -f flag
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
cb0f2bd038 Always create files database
Both the "db" and "files" databases are created in one call to repo-add.
Only the "foo.db.tar.xz" name is passed to repo-add.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
30c9dbcdeb repo-add: remove duplication finding old package details
The information needed to create a delta entry and remove the old package from
the filesystem are the same.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
6aef45ee1a repo-add: check early for xdelta if it is needed
The check for xdelta3 was done as needed (and not in all cases).  Do this
check early so that repo-add does not abort part way through.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
81d233b793 repo-add: only update database if entire command succeeded
It is not hard to think of situations where the repo database should not
be updated unless the whole operation succeeds.  Error out before a partial
database update occurs.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
d2cb52de12 repo-add: move database creation into its own function
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
f3fc9af2b7 repo-add: move database rotation into its own function
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:43:37 +10:00
Allan McRae
e7e0c13762 Merge branch 'maint' 2015-03-26 14:43:13 +10:00
Ivy Foster
b543c055b9 Make get_pkg_arch treat arch as an array
We use the get_pkg_arch function with the package name parameter in two places:
1) checking if the package is already built
2) installing build packages

Currently this failed when a package override for "arch" was an array, despite
all our documentation stating that it is indeed an array.  This change makes
these two places fail if there is package override for arch that is not an
array - i.e. of the form arch='i686'.

Signed-off-by: Ivy Foster <joyfulgirl@archlinux.us>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:42:22 +10:00
Allan McRae
b8f2d713e0 Update PKGBUILD-split.proto allowed overrides
Commit 8a02abcf19 disallowed overridding pkgver/pkgrel/epoch.  Update the
split package prototype to refelct this change.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:42:10 +10:00
Christian Hesse
eb21e9eb93 fix source package signing with SRCPKGDIR set
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-26 14:41:26 +10:00
Charles Pigott
f34e48a988 Actually return the error value of check_db_local
Signed-off-by: Charles Pigott <charlespigott@googlemail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-15 15:32:58 +10:00
Allan McRae
f9cb4f3b9c libmakepkg: move helper functions into tidy/strip
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-15 15:32:58 +10:00
Johannes Löthberg
22a5128985 PKGBUILD.5.txt: Clarify note about variables available
Reported-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-15 15:32:58 +10:00
Johannes Löthberg
0aded7487f PKGBUILD.5.txt: Add note about functions starting in $srcdir
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-15 15:32:58 +10:00
Andrew Gregory
156d41a186 remove: use strcmp for files in skip_remove
Paths from noupgrade, the transaction skip_remove, and package backup
lists were combined into a single list matched using fnmatch causing
paths with glob characters to match unrelated files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Andrew Gregory
ba532bda6b sync_prepare: exclude removals from resolvedeps
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
David Macek
ff8de12151 Allow UPX compression for DOS/Win executables
Hi. This change allows makepkg to UPX-compress executables on Windows, but will probably affect some Linux packages as well (I'm guessing gdbserver, wine, mingw-w64).

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Will Miles
965539adbf common: Avoid errors on systems that define strnlen but not strndup
Add a configure test for a system library supplied strnlen, and disable
the embedded version in common if one is found.

Signed-off-by: Will Miles <wmiles@sgl.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Will Miles
bb94729c09 util: Use util-common for strndup in pacsort and pactree
This small refactor reduces the number of replications of the local
imeplementation of strndup.

Signed-off-by: Will Miles <wmiles@sgl.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
8f92fe47a7 calculate_removed_size: ensure llstat succeeds
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
578ceb29fa sync_cleandb: ensure stat call succeeds
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
9f1c5f0251 pacsort: test string is not NULL before strlen
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
d9b5cb238d Abort of failure to add version file to empty local database
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
fc5be14dac parse_descfile: fix memory leak in error case
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
2108d95526 Fix memory leaks in dump_pkg_full
Leaks when using -Sii with package signatures

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03 16:54:17 +10:00
Allan McRae
008bd33e38 Merge branch 'maint' 2015-03-03 14:47:50 +10:00
Allan McRae
92b8c09000 Update release history
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-02 01:36:33 +10:00
Allan McRae
7879a5b3e5 Merge branch 'maint' 2015-02-20 10:36:18 +10:00
Allan McRae
adc6ca1f2c libmakepkg: make package checking functions extendable
To add a new package check, drop a file in libmakepkg/lint and add the
function to the "lint_functions" array.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 14:00:57 +10:00
Allan McRae
00da25a5ea libmakepkg: make package tidy functions extendable
To add a new packaging option, drop a file into libmakepkg/tidy that contains
a 'packaging_options+=('<option>') and a function that implements that
option. The function needs added to the 'tidy_remove' array if it removes
files or the 'tidy_modify' array otherwise.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 14:00:57 +10:00
Allan McRae
bfe9b56e1f libmakepkg: move package checking out of tidy_install
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 14:00:55 +10:00
Maxim Andersson
68602f4931 paccache: added --quiet option
Less output, although errors and warnings will still be printed
(scripts/library/output_format.sh).

Cleaner to have -q,--quiet than >/dev/null in cron.

Signed-off-by: Maxim Andersson <thesilentboatman@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 13:45:03 +10:00
Allan McRae
dff6982c83 repo-add: improve delta file detection on removal
This allows use to remove a package with the name "foo.delta" from the
repos.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 13:35:48 +10:00
Allan McRae
660bd1caa1 repo-add: only backup database signature if database was backed up
Ensures the backed update database and its signature are always consistent.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 13:35:31 +10:00
Allan McRae
3c46420367 repo-add: unify checking gpg keys
Move the PGP key checking into the check_gpg function.  This also results in
error messages being in colour.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 13:35:19 +10:00
Allan McRae
cf3d5e4830 repo-add: clarify invalid repo extension message
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 13:35:09 +10:00
Allan McRae
b5b2f0b1bf repo-add: improve removing old packages
The -R/--remove option left the old package in place when delta packages
were to be generated.  It was also removed before we ensure the generation
of the entry for the new package was generated without error.

Remove the old package at the end of database entry and delta generation. Also
improve the help message to clarify it is the old package that is removed.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-12 13:35:01 +10:00
Allan McRae
27e3125c8d Merge branch 'maint' 2015-02-12 13:33:20 +10:00
Allan McRae
295a3491ad makepkg: split package tidying into libmakepkg
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:20:08 +10:00
Allan McRae
33466000d6 makepkg: split PKGBUILD/makepkg.conf option checking to libmakepkg
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:20:08 +10:00
Allan McRae
c8574baa7c makepkg: rename other_options to build_options
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:20:08 +10:00
Allan McRae
7885931c96 makepkg: split message functions into libmakepkg
This performs all the needed work for libmakepkg to be included in
tarballs, installed into the correct place, and read into makepkg.

Also change the install root for libmakepkg to an architecture independant
location.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:20:08 +10:00
Christian Hesse
9917930ae1 add option to optimize PNG images with optipng
This can decrease package size by optimizing PNG image size. Images are
just stored with better compression and/or filter options. The actual
image content is not altered.

Additionally this can automatically fix broken PNG images which caused
some trouble lately.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
Christian Hesse
bd2e95b00b remove globbing for upx and make UPXFLAGS an array variable
Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
Allan McRae
2e48101999 Update copyright notices for 2015
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
Allan McRae
325be32acd pmenv.py: Fix typo in copyright assignment
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:04 +10:00
Allan McRae
bbac318d7a Add make rule to update copyright years
Usage: make update-copyright OLD=2014 NEW=2015

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01 21:19:03 +10:00
Allan McRae
54c630f6ec Merge branch 'maint' 2015-02-01 21:18:31 +10:00
Andrew Gregory
5167160c0c extract_single_file: consolidate extraction logic
Also adds checks that the filename does not exceed PATH_MAX.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
ba0d225d93 extract_single_file: use .pacnew for check files
Prevents the need to rename the file if we end up keeping it and ensures
that pacnew files always reflect the most recent version by overwriting
stale copies.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
926280cfc7 remove support for .pacorig files
Leave user files in place and save new config files with a .pacnew
extension.  This reduces the complexity of file extraction and respects
the principle that pacman shouldn't modify files it didn't create.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
a82a5cf3f7 extract_single_file: use full path in messages
If an error occurs the actual path being extracted is more useful than
the original path from the package file list.  The original path is
still used for checks that use it directly.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
4ba0561fe7 extract_single_file: factor out db file extraction
alpm's database files (.INSTALL, .MTREE, etc.) should be extracted no
matter what; skip mtree/needbackup/noextract/noupgrade checks for them.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
f917a4a55a extract_single_file: reduce indentation
Puts all of the conflict cases at the same level.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
63660afbc7 extract_single_file: consolidate needbackup checks
We need to know if a file needs to be backed up for all extracted files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
3b20561748 ini.c: move error output into conf.c
Move the remaining output into conf.c by notifying the callback of read
errors.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
ea96b56722 ini.c: remove useless key check
key points to a statically allocated string so it can't be NULL and
empty keys are rejected by the callback.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:47 +10:00
Andrew Gregory
e7d8e2b5ac ini.c: remove empty section name restriction
alpm will reject empty database names already.  Reduces error handling
in the ini parser.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Andrew Gregory
4ccafc484d ini.c: remove unnecessary helper function
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Andrew Gregory
09cfe2a4c0 ini.c: move Include parsing to conf.c
Reduces the number of errors the ini parser must handle to make it more
suitable for sharing with the backend.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Andrew Gregory
9eb07a81fa ini.c: remove final callback call
Storing repo information removes the need for the final callback.  This
allows the call signature to be re-purposed for indicating read errors.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Andrew Gregory
7ed0d60a0d conf.c: parse config in a single pass
Fixes FS#28255

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Andrew Gregory
95121cc4f1 conf.c: use masks for siglevel inheritance
This will allow pacman to parse its config file in a single pass and
removes the need for the *_SET siglevels in alpm that were only required
for pacman's siglevel inheritance.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Andrew Gregory
2aa85c3bfd conf.c: store repo settings in dedicated struct
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2015-01-21 14:27:46 +10:00
Allan McRae
92febc847c Merge branch 'maint' 2015-01-21 14:27:25 +10:00
Allan McRae
018fa2b48c Merge branch 'maint' 2015-01-12 15:23:30 +10:00
Florian Pritz
0108884952 test makepkg-template: Add update-version-with-newest-option
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:25 +10:00
Florian Pritz
d5f703729f test makepkg-template: Add template-without-version
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:25 +10:00
Florian Pritz
bd2473797e test makepkg-template: Add name-charset-valid
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:25 +10:00
Florian Pritz
6201f6e5ac test makepkg-template: Add name-charset-invalid
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
4dd9ccbc78 test makepkg-template: Add missing-template-symlink
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
17ad845c41 test makepkg-template: Add missing-template-file
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
287f7a575e test makepkg-template: Add keep-old-version
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
dfacd8473e test makepkg-template: Add invalid-template-line-unknown-marker
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
107eabdfb3 test makepkg-template: Add invalid-template-line-missing-name
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
207ba1e05f test makepkg-template: Add invalid-key
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
ca5af32b99 Add testrunner for makepkg-template
Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Florian Pritz
f617b6acd4 makepkg-template: Remove linenumber/file from errors
die prints "at $scriptname line $linenumber." if the string does not
end with "\n". This information is not of much use for us and it makes
testing harder because we'd to remove it there.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
2015-01-11 18:58:24 +10:00
Allan McRae
77ca6e4062 Merge branch 'maint' 2015-01-11 18:57:54 +10:00
Mohammad Alsaleh
95da285f56 pkgdelta: Use high compression options offered by xdelta3
* Add -9 which is the highest compression level.
 * Use lzma for secondary compression.

 Decompression speed is largely unaffected as most cycles are consumed
 by xz for re-compression.

 Some numbers:

 clang x86_64 [3.5.0-2.1 to 3.5.0-3]
 17.21MiB      default      (0.73)
 15.67MiB      -9           (0.67)
 13.59MiB      -9 -S djw    (0.58)
 12.01MiB      -9 -S lzma   (0.51)

 inkscape x86_64 [0.48.5-3 to 0.48.5-4]
 02.69MiB      default      (0.21)
 01.64MiB      -9           (0.13)
 01.30MiB      -9 -S djw    (0.10)
 01.01MiB      -9 -S lzma   (0.08)

Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:48:59 +10:00
Andrew Gregory
8da9be0955 initialize pointers passed to _alpm_pkg_dup
_alpm_pkg_dup leaves the destination pointer unaltered in case of fatal
errors, so when commits 2f0ca00e and be4198b3 freed the pointer, they
fixed a memory leak on non-fatal errors by replacing it with
a segmentation fault on fatal errors.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:48:59 +10:00
Andrew Gregory
4060c5c77f be_package.c: fix style violation
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:48:59 +10:00
Allan McRae
0acd794226 add alpm_pkg_get_base() to README
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:59 +10:00
Allan McRae
62d5a71fba Remove testdb
Replaced by pacman -Dk / -Dkk

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:59 +10:00
Allan McRae
aa4c61f999 Document database checking options
The required adding a Database Option section to the pacman man page
and adding more complete documentation for --asdeps and --asexplicit
as well.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:58 +10:00
Allan McRae
e8a3e3d81a Integrate testdb into pacman
The functionality of testdb is now available in pacman. pacman -Dk will
check the local database for consistency, and pacman -Dkk will check the
sync databases.

Note that unlike testdb, you can not specify individual sync databases to
check as sync databases act as a whole and not individually. A single database
can be checked using an alternative pacman.conf file.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:58 +10:00
Allan McRae
194dea2de1 Split install reason changing into its own function
Prepare for other functions to be added to the --database option.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-01-02 21:44:58 +10:00
Allan McRae
fafcbdeb8c Merge branch 'maint' 2015-01-02 21:43:56 +10:00
Andrew Gregory
f1e010a5a7 add tap_ prefix to test helper functions
Allows tap.sh to show the line number where the helper function was
called on failures.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-28 13:06:39 +10:00
Andrew Gregory
29c0d8233b use tap.sh for bash tests
tap.sh is a reusable TAP library that handles test counting and provides
useful diagnostic messages on test failures.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-28 13:06:28 +10:00
Allan McRae
4c4890dd1c Clarify "assume installed" error message
The error message on failing to add an "assume installed" entry to the backend
was not clear.  Clarify by making "assume-installed" none translatable and
adding a hyphen to match calling flag.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-28 13:06:15 +10:00
Allan McRae
2759858e8c Merge branch 'maint' 2014-12-28 13:06:04 +10:00
Dave Reisner
6356567ae0 makepkg: print the name of the source array being checked
I don't see an easy fix to avoid printing this more than once, so let's
at least differentiate the messaging so that it's more clear what's
going on.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:33 +10:00
Dave Reisner
7c0ff7f4b7 makepkg: call out the source array(s) missing checksums
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:33 +10:00
Allan McRae
763fb3d9e7 Remove logically dead code in _alpm_local_db_write
We can only get to cleanup: through fp being NULL due to fopen failing or
normal execution when fclose is called.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
804688ab6a _alpm_run_chroot: only close working directory if it was opened
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
2f0ca00e55 _alpm_db_add_pkgincache: free potential memory leak
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
60d958c78b Initialize memory to prevent issues when freeing on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
be4198b34e _alpm_recursedeps: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
32413213cb apply_deltas: fix memory leak on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
d5e93e895b pacsort: fix memory leak
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-27 17:08:32 +10:00
Allan McRae
25b492aab6 Merge branch 'maint' 2014-12-27 17:07:04 +10:00
Johannes Löthberg
1f1e53c208 libalpm: Add accessors for the base field
This commit adds the necessary accessor functions to get the PKGBASE of
a package, forcing the desc file to be parsed.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Johannes Löthberg
9f527d2de4 libalpm: Parse and write PKGBASEs
This commit adds support to libalpm to parse the pkgbase present in
packages .PKGINFO files, writing the PKGBASE to the %BASE% section of
the local DBs desc files and for parsing it again when loading the local
DB

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Andrew Gregory
fda599df37 add vim modeline to test files
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Allan McRae
21faf1682e mount_point_list: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Allan McRae
2114ef1874 conflict_new: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Allan McRae
9cf1b2c004 _alpm_runscriptlet: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Allan McRae
88eedef6c6 add_fileconflict: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Allan McRae
52d2ff648d create_tempfile: fix memory leak on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:30 +10:00
Allan McRae
123ecb8e07 _alpm_split_backup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
c6dd581ec5 alpm_dep_from_string: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
27506aba8f _alpm_conflict_dup: fix memory leak on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
46459da39b local_db_read: fix memory leak on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
895780bd9a _alpm_db_new: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
87e55a4ee7 _alpm_db_get_pkgcache_hash: check for error when loading pkgcache
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
cd5e4b89f4 _alpm_delta_parse: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
e892234207 _alpm_dep_dup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
f4796c905c pacman/util.c: fix potential memory leak in indentprint 2014-12-24 11:19:29 +10:00
Allan McRae
eac09e1d9f Fix memory leak in ALPM_EVENT_OPTDEP_REMOVAL callback
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
c0d9d26070 build_payload: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
32ebd7ad5d depmiss_new: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:29 +10:00
Allan McRae
bf06efaa78 _alpm_delta_dup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:28 +10:00
Evangelos Foutras
eb7cc246c6 checkupdates: include package versions in output
Especially useful now that pacman -Qu will also show the new version.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:28 +10:00
Evangelos Foutras
c9ca363431 checkupdates: show error when fakeroot is missing
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:28 +10:00
Allan McRae
863cfb5808 Improve db upgrade error message
This message is clearer without (another) error prefix.

Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-24 11:19:28 +10:00
470 changed files with 98948 additions and 96554 deletions

20
.editorconfig Normal file
View File

@@ -0,0 +1,20 @@
# 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

1
.gitignore vendored
View File

@@ -10,6 +10,7 @@ config.status
config.status.lineno
configure
configure.lineno
cov-int
cscope.in.out
cscope.out
cscope.po.out

27
HACKING
View File

@@ -11,13 +11,8 @@ Coding Style
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,
which should be a maximum of 80 characters. By default, source files
contain the following Vim modeline:
+
[source,C]
-------------------------------------------
/* vim: set noet: */
-------------------------------------------
which should be a maximum of 80 characters. An EditorConfig file is used
to set this project-wide default.
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
@@ -75,15 +70,7 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
NOT
return(0);
6. The sizeof() operator should accept a type, not a value. (TODO: in certain
cases, it may be better- should this be a set guideline? Read "The Practice
of Programming")
sizeof(alpm_list_t);
NOT
sizeof(*mylist);
7. When using strcmp() (or any function that returns 0 on success) in a
6. When using strcmp() (or any function that returns 0 on success) in a
conditional statement, use != 0 or == 0 and not the negation (!) operator.
It reads much cleaner for humans (using a negative to check for success is
confusing) and the compiler will treat it correctly anyway.
@@ -92,7 +79,7 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
NOT
if(!strcmp(a, b))
8. Use spaces around almost all arithmetic, comparison and assignment
7. Use spaces around almost all arithmetic, comparison and assignment
operators and after all ',;:' separators.
foobar[2 * size + 1] = function(a, 6);
@@ -103,7 +90,7 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data)
NOT
for(a=0;a<n&&n>0;a++,n--) {}
9. Declare all variables at the start of the block.
8. Declare all variables at the start of the block.
[source,C]
-------------------------------------------
int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
@@ -202,7 +189,3 @@ For example, to run valgrind:
./src/pacman/pacman
valgrind --leak-check=full -- src/pacman/.libs/lt-pacman -Syu
/////
vim:set syntax=asciidoc noet spell spelllang=en_us:
/////

View File

@@ -3,7 +3,7 @@ if WANT_DOC
SUBDIRS += doc
endif
DIST_SUBDIRS = $(SUBDIRS) contrib src/common
DIST_SUBDIRS = $(SUBDIRS) src/common
ACLOCAL_AMFLAGS = -I m4 --install
AM_MAKEFLAGS = --no-print-directory
@@ -13,7 +13,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-doc --disable-git-version
# Some files automatically included, so they aren't specified below:
# AUTHORS, COPYING, NEWS, README
EXTRA_DIST = HACKING
EXTRA_DIST = HACKING test/tap.sh
# Sample makepkg prototype files
pkgdatadir = ${datadir}/${PACKAGE}
@@ -28,8 +28,8 @@ $(top_srcdir)/test/pacman/tests/TESTS: $(wildcard test/pacman/tests/*.py)
TESTS = test/scripts/parseopts_test.sh \
test/scripts/human_to_size_test.sh \
test/scripts/makepkg-template_test.sh \
test/scripts/pacman-db-upgrade-v9.py \
test/util/pacsorttest.sh \
test/util/vercmptest.sh
include $(top_srcdir)/test/pacman/tests/TESTS
@@ -37,7 +37,9 @@ TEST_SUITE_LOG = test/test-suite.log
TEST_EXTENSIONS = .py
AM_TESTS_ENVIRONMENT = \
PMTEST_UTIL_DIR=$(top_builddir)/src/util/; export PMTEST_UTIL_DIR; \
PMTEST_SCRIPTLIB_DIR=$(top_srcdir)/scripts/library/; export PMTEST_SCRIPTLIB_DIR;
PMTEST_SCRIPT_DIR=$(top_builddir)/scripts/; export PMTEST_SCRIPT_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) \
$(top_srcdir)/build-aux/tap-driver.sh
PY_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
@@ -49,9 +51,10 @@ AM_PY_LOG_FLAGS = \
--bindir $(top_builddir)/src/pacman \
--bindir $(top_builddir)/scripts
# create the pacman DB and cache directories upon install
# create the pacman DB, cache, makepkg-template and system hook directories upon install
install-data-local:
for dir in "$(DESTDIR)$(localstatedir)/lib/pacman" "$(DESTDIR)$(localstatedir)/cache/pacman/pkg"; do \
for dir in "$(DESTDIR)$(localstatedir)/lib/pacman" "$(DESTDIR)$(localstatedir)/cache/pacman/pkg" \
"$(DESTDIR)$(datarootdir)/makepkg-template" "$(DESTDIR)$(datarootdir)/libalpm/hooks"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
@@ -60,6 +63,9 @@ update-po:
$(MAKE) -C scripts/po update-po
$(MAKE) -C src/pacman/po update-po
.PHONY: update-po
update-copyright:
for file in $(shell sh -c 'git grep -l "Copyright .* Pacman Development" | grep -v "\.po"'); do \
sed -i -e "/Copyright (/s/-$(OLD)/-$(NEW)/" -e "/Copyright (/s/ $(OLD)/ $(OLD)-$(NEW)/" "$$file"; \
done
# vim:set noet:
.PHONY: update-po update-copyright

192
NEWS
View File

@@ -1,5 +1,195 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
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.1 - fix alignment issues with wide character locales (FS#47980)
- fix removal of .pacnew files (FS#47993)
- fix triggering of Install hooks (FS#47996)
- fix handling of stdin scripts called by pacman
- hook activity is logged
- documentataion updates for alpm-hooks (FS#48080)
- makepkg:
- increase robustness of variable array checks
- makepkg -g does not perform current architecture checks
- do not run prepare() with --noextract
- all directories in the packaging directory are cleared
before each build
- fix translations issues (FS#48057, FS#48298)
- repo-add:
- fix checking for non-existent database
- contrib:
- zsh_completion: updated makepkg options
5.0.0 - pacman can run hooks pre- and post-transaction. See the
alpm-hooks(5) man page for details and an example hook (FS#2985)
- pacman can now sync and read .files databases (-Fy) and do basic
searching for files in sync repos (-Fs, -Fo) (FS#23787)
- pacman can check the validity of the local and sync databases
(-Dk and -Dkk respectively). This replaces the 'testdb'
software (FS#42444)
- the package description output (-Si ,-Qi) is now correctly
aligned regardless of locale (FS#43983, FS#45997)
- ensure internal package version matches database version after
downloading (FS#45687)
- improved signal handling and lock file removal (FS#45995,
FS#46375, FS#47011)
- print more information when encountering dependency errors
- improved configuration parsing with a new ini parser
- handle a symlink to a directory being replaced by a directory
- The 'pkgbase' variable is now recorded in the local package db
- Remove support for ".pacorig" files. Instead, packages files
are extracted as a ".pacnew" and the original stays in place
- prevent install scriptlets using stdin for user interaction
- provides are considered when displaying optdepends install
status (FS#36412)
- always update corrupt database whether or not a newer version
is found on the remote server
- fix build issues when libarchive was in a non-standard location
- Many issues found using Coverity were address (primarily freeing
memory on error conditions)
- The pactest suite was upgraded to allow parallel testing using
the tap.sh library
- makepkg:
- makepkg is in the process of being split into a library. This
allows various areas to be extended by adding a file into
libmakepkg (e.g. package/PKGBUILD checking, adjusting
files before creating the final package).
- PKGBUILD variables checked to be arrays or not as appropriate
- pkgver() and prepare() are now run with --noextract (FS#43498,
FS#46800)
- the ability to build a single package in a PKGBUILD has been
removed
- the output when checking checksums for architecture specific
sources is improved (FS#43444)
- improved handling of bazaar sources (FS#43448)
- fix source package signing with SRCPKGDIR set
- add option to compress png images with optipng
- add --packagelist option, which lists all packages build from
a PKGBUILD
- add --printsrcinfo flag to print SRCINFO file for a PKGBUILD
- record build information in a .BUILDINFO file
- add whirlpool to list of hashing options (FS#45859)
- makepkg-template:
- support multiple --template-dir
- added a testsuite
- repo-add:
- Always generate the .files database
- Only update database if the entire operation succeeds
- unarmored package signatures are rejected
- contrib:
- checkupdates: give error when fakeroot is missing
- checkupdates: provide packages versions in output
- checkupdates: fix failure in some locales (FS#40405)
- paccache: Add -q/--quiet
- pacdiff: do not require DIFFPROG for -o/--output (FS#46184)
- zsh_completion: updated to fix many missing options
4.2.1 - Remove warnings about incorrect directory ownership until
packaging files with dynamic users/groups is improved
- Do not require a specific automake version when building from
@@ -1178,5 +1368,3 @@ VERSION DESCRIPTION
backed up, then it will be copied to "file.save"
- Changed db_find_conflicts() to ignore directories
1.0 - Initial Release
vim: set et spell spelllang=en_us:

71
README
View File

@@ -560,3 +560,74 @@ API CHANGES BETWEEN 4.1 AND 4.2
- ALPM_EVENT_RETRIEVE_DONE, ALPM_EVENT_RETRIEVE_FAILED, ALPM_EVENT_PKGDOWNLOAD_START,
ALPM_EVENT_PKGDOWNLOAD_DONE, ALPM_EVENT_PKGDOWNLOAD_FAILED, ALPM_EVENT_OPTDEP_REMOVAL,
ALPM_EVENT_PACNEW_CREATED, ALPM_EVENT_PACSVAE_CREATED, ALPM_EVENT_PACORIG_CREATED
API CHANGES BETWEEN 4.2 AND 5.0
===============================
[REMOVED]
- alpm_siglevel_t - removed members ALPM_SIG_PACKAGE_SET, ALPM_SIG_PACKAGE_TRUST_SET
- removed .pacorig generation
- ALPM_EVENT_PACORIG_CREATED
- alpm_event_pacorig_created_t
- alpm_event_t.pacorig_created
[ADDED]
- hook support
- alpm_option_get_hookdirs()
- alpm_option_set_hookdirs()
- alpm_option_add_hookdir()
- alpm_option_remove_hookdir()
- alpm_event_hook_t, alpm_event_hook_run_t
- alpm_hook_when_t
- ALPM_EVENT_HOOK_START, ALPM_EVENT_HOOK_DONE
- ALPM_EVENT_HOOK_RUN_START, ALPM_EVENT_HOOK_RUN_DONE
- ALPM_ERR_TRANS_HOOK_FAILED
- different database extension support
- alpm_option_get_dbext()
- alpm_option_set_dbext()
- pkgbase accessor
- alpm_pkg_get_base()
- transaction events
- ALPM_EVENT_TRANSACTION_START, ALPM_EVENT_TRANSACTION_DONE
- database unlocking
- 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 Normal file
View File

@@ -0,0 +1,23 @@
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,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Minimum version of autoconf required
AC_PREREQ(2.62)
AC_PREREQ(2.64)
# UPDATING VERSION NUMBERS FOR RELEASES
#
@@ -41,13 +41,13 @@ AC_PREREQ(2.62)
# Bugfix releases:
# pacman_version_micro += 1
m4_define([lib_current], [9])
m4_define([lib_revision], [1])
m4_define([lib_current], [11])
m4_define([lib_revision], [0])
m4_define([lib_age], [0])
m4_define([pacman_version_major], [4])
m4_define([pacman_version_minor], [2])
m4_define([pacman_version_micro], [1])
m4_define([pacman_version_major], [5])
m4_define([pacman_version_minor], [1])
m4_define([pacman_version_micro], [0])
m4_define([pacman_version],
[pacman_version_major.pacman_version_minor.pacman_version_micro])
@@ -120,10 +120,11 @@ AC_ARG_WITH(ldconfig,
[set the full path to ldconfig]),
[LDCONFIG=$withval], [LDCONFIG=/sbin/ldconfig])
# Help line for using OpenSSL
AC_ARG_WITH(openssl,
AS_HELP_STRING([--with-openssl], [use OpenSSL crypto implementations instead of internal routines]),
[], [with_openssl=check])
# Help line for selecting a crypto library
AC_ARG_WITH(crypto,
AS_HELP_STRING([--with-crypto={openssl|nettle}],
[select crypto implementation @<:@default=openssl@:>@]),
[with_crypto=$withval], [with_crypto=openssl])
# Help line for using gpgme
AC_ARG_WITH(gpgme,
@@ -131,9 +132,9 @@ AC_ARG_WITH(gpgme,
[], [with_gpgme=check])
# Help line for using libcurl
AC_ARG_WITH(curl,
AC_ARG_WITH(libcurl,
AS_HELP_STRING([--with-libcurl], [use libcurl for the internal downloader]),
[], [with_curl=check])
[], [with_libcurl=check])
# Help line for documentation
AC_ARG_ENABLE(doc,
@@ -165,6 +166,15 @@ AC_ARG_ENABLE(git-version,
# testing compilation against gpgme).
AC_SYS_LARGEFILE
# Record large file flags in pkgconfig file
if test "$enable_largefile" != no; then
if test "$ac_cv_sys_file_offset_bits" != 'no'; then
LFS_CFLAGS="-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
fi
fi
AC_SUBST(LFS_CFLAGS)
# Checks for programs.
AC_PROG_AWK
AC_PROG_CC_C99
@@ -206,30 +216,47 @@ AC_CHECK_LIB([m], [fabs], ,
AC_MSG_ERROR([libm is needed to compile pacman!]))
# Check for libarchive
PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], ,
AC_MSG_ERROR([*** libarchive >= 2.8.0 is needed to compile pacman!]))
PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 3.0.0], ,
AC_MSG_ERROR([*** libarchive >= 3.0.0 is needed to compile pacman!]))
# Check for OpenSSL
have_openssl=no
if test "x$with_openssl" != "xno"; then
have_nettle=no
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],
[AC_DEFINE(HAVE_LIBSSL, 1, [Define if libcrypto is available]) have_openssl=yes], have_openssl=no)
if test "x$have_openssl" = xno -a "x$with_openssl" = xyes; then
if test "x$have_openssl" = xno; then
AC_MSG_ERROR([*** openssl support requested but libraries not found])
fi
else
AC_MSG_ERROR([*** unknown crypto support library requested - $with_crypto])
fi
fi
AM_CONDITIONAL(HAVE_LIBSSL, [test "$have_openssl" = "yes"])
AM_CONDITIONAL(HAVE_LIBNETTLE, [test "$have_nettle" = "yes"])
# Check for libcurl
have_libcurl=no
if test "x$with_libcurl" != "xno"; then
PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.19.4],
PKG_CHECK_MODULES(LIBCURL, [libcurl >= 7.32.0],
[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
AC_MSG_ERROR([*** libcurl >= 7.19.4 is required for internal downloader support])
AC_MSG_ERROR([*** libcurl >= 7.32.0 is required for internal downloader support])
fi
fi
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
AC_MSG_CHECKING(whether to link with libgpgme)
@@ -299,13 +326,12 @@ PATH_MAX_DEFINED
AC_FUNC_FORK
AC_FUNC_GETMNTENT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_STRCOLL
AC_CHECK_FUNCS([dup2 getcwd getmntinfo gettimeofday memmove memset \
mkdir realpath regcomp rmdir setenv setlocale strcasecmp \
strchr strcspn strdup strerror strndup strrchr strsep strstr \
strtol swprintf tcflush wcwidth uname])
strchr strcspn strdup strerror strndup strnlen strrchr \
strsep strstr strtol swprintf tcflush wcwidth uname])
AC_CHECK_MEMBERS([struct stat.st_blksize],,,[[#include <sys/stat.h>]])
# For the diskspace code
@@ -318,12 +344,11 @@ AC_CHECK_MEMBERS([struct statfs.f_flags],,,[[#include <sys/param.h>
GCC_VISIBILITY_CC
# Host-dependant definitions
DEFAULT_DUFLAGS=" -sk --apparent-size"
DEFAULT_SEDINPLACEFLAGS=" --follow-symlinks -i"
INODECMD="stat -c '%i %n'"
OWNERCMD="stat -c '%u:%g'"
MODECMD="stat -c '%a'"
SIZECMD="stat -c %s"
SEDINPLACE="sed --follow-symlinks -i"
DUFLAGS="-sk --apparent-size"
STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug"
@@ -332,36 +357,43 @@ case "${host_os}" in
INODECMD="stat -f '%i %N'"
OWNERCMD="stat -f '%u:%g'"
MODECMD="stat -f '%Lp'"
SIZECMD="stat -f %z"
SEDINPLACE="sed -i \"\""
DUFLAGS="-sk"
DEFAULT_SEDINPLACEFLAGS=" -i \"\""
DEFAULT_DUFLAGS=" -sk"
;;
darwin*)
host_os_darwin=yes
INODECMD="/usr/bin/stat -f '%i %N'"
OWNERCMD="/usr/bin/stat -f '%u:%g'"
MODECMD="/usr/bin/stat -f '%Lp'"
SIZECMD="/usr/bin/stat -f %z"
SEDINPLACE="/usr/bin/sed -i ''"
DUFLAGS="-sk"
DEFAULT_SEDINPLACEFLAGS=" -i ''"
DEFAULT_DUFLAGS=" -sk"
STRIP_BINARIES=""
STRIP_SHARED="-S"
STRIP_STATIC="-S"
;;
esac
AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
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(OWNERCMD)
AC_SUBST(MODECMD)
AC_SUBST(SIZECMD)
AC_SUBST(SEDINPLACE)
AC_SUBST(DUFLAGS)
AC_SUBST(STRIP_BINARIES)
AC_SUBST(STRIP_SHARED)
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
CARCH="${host%%-*}"
CHOST="${host}"
@@ -510,7 +542,6 @@ test/pacman/Makefile
test/pacman/tests/Makefile
test/scripts/Makefile
test/util/Makefile
contrib/Makefile
Makefile
])
AC_OUTPUT
@@ -530,7 +561,7 @@ ${PACKAGE_NAME}:
compiler : ${CC}
preprocessor flags : ${CPPFLAGS}
compiler flags : ${WARNING_CFLAGS} ${CFLAGS}
library flags : ${LIBS} ${LIBSSL_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
library flags : ${LIBS} ${LIBSSL_LIBS} ${NETTLE_LIBS} ${LIBARCHIVE_LIBS} ${LIBCURL_LIBS} ${GPGME_LIBS}
linker flags : ${LDFLAGS}
Architecture : ${CARCH}
@@ -538,8 +569,7 @@ ${PACKAGE_NAME}:
File inode command : ${INODECMD}
File owner command : ${OWNERCMD}
File mode command : ${MODECMD}
Filesize command : ${SIZECMD}
In-place sed command : ${SEDINPLACE}
In-place sed command : ${SEDPATH} ${SEDINPLACEFLAGS}
libalpm version : ${LIB_VERSION}
libalpm version info : ${LIB_VERSION_INFO}
@@ -557,11 +587,10 @@ ${PACKAGE_NAME}:
Use libcurl : ${have_libcurl}
Use GPGME : ${have_gpgme}
Use OpenSSL : ${have_openssl}
Use nettle : ${have_nettle}
Run make in doc/ dir : ${wantdoc} ${asciidoc}
Doxygen support : ${usedoxygen}
debug support : ${debug}
extra warning flags : ${warningflags}
use git version : ${wantgitver}
"
# vim:set noet:

12
contrib/.gitignore vendored
View File

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

View File

@@ -1,107 +0,0 @@
# 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)
OURFILES = \
bash_completion \
zsh_completion
EXTRA_DIST = \
PKGBUILD.vim \
bacman.sh.in \
bash_completion.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 \
zsh_completion.in \
README
# Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES = $(OURSCRIPTS) $(OURFILES) *.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) $(OURFILES)
install-data-local:
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d/
$(INSTALL_DATA) bash_completion $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
$(MKDIR_P) $(DESTDIR)$(datarootdir)/zsh/site-functions/
$(INSTALL_DATA) zsh_completion $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
uninstall-local:
$(RM) $(DESTDIR)$(sysconfdir)/bash_completion.d/pacman
$(RM) $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
bacman: $(srcdir)/bacman.sh.in
bash_completion: $(srcdir)/bash_completion.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
zsh_completion: $(srcdir)/zsh_completion.in
# vim:set noet:

View File

@@ -1,320 +0,0 @@
" 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\|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

View File

@@ -1,41 +0,0 @@
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/pacorig/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/.

View File

@@ -1,358 +0,0 @@
#!/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-2014 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-2014 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 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

@@ -1,51 +0,0 @@
#!/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@'
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 [[ -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 -Qqu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]'
exit 0
# vim: set noet:

View File

@@ -1,360 +0,0 @@
#!/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=
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() {
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.
-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:rsuVvz'
OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move'
'nocolor' '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 ;;
--nocolor)
USE_COLOR='n' ;;
-m|--move)
move=1 movedir=$2
shift ;;
-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:

View File

@@ -1,194 +0,0 @@
#!/bin/bash
# pacdiff : a simple pacnew/pacorig/pacsave updater
#
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
# Copyright (c) 2013-2014 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/pacorig/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-2014 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; 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:

View File

@@ -1,68 +0,0 @@
#!/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

@@ -1,99 +0,0 @@
#!/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
printf '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:

View File

@@ -1,141 +0,0 @@
#!/bin/bash
#
# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
# scripts of a given package
#
# Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>
# Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>
# Copyright (c) 2009-2014 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

View File

@@ -1,125 +0,0 @@
#!/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:

View File

@@ -1,234 +0,0 @@
#!/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:

View File

@@ -1,106 +0,0 @@
#!/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 updpkgsums.XXXXXX)
newbuildfile=$(mktemp --tmpdir 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:

View File

@@ -1,25 +0,0 @@
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=. {
}
}

14
doc/.gitignore vendored
View File

@@ -1,16 +1,4 @@
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
*.[1-8]
asciidoc-manpage.css
asciidoc.css
asciidoc.js

70
doc/BUILDINFO.5.asciidoc Normal file
View File

@@ -0,0 +1,70 @@
/////
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

@@ -4,6 +4,7 @@
# man_MANS if --enable-asciidoc and/or --enable-doxygen are used.
ASCIIDOC_MANS = \
alpm-hooks.5 \
pacman.8 \
makepkg.8 \
makepkg-template.1 \
@@ -11,15 +12,16 @@ ASCIIDOC_MANS = \
vercmp.8 \
pkgdelta.8 \
pacman-key.8 \
pactree.8 \
PKGBUILD.5 \
makepkg.conf.5 \
pacman.conf.5 \
libalpm.3
libalpm.3 \
BUILDINFO.5
DOXYGEN_MANS = $(wildcard man3/*.3)
HTML_MANPAGES = \
alpm-hooks.5.html \
pacman.8.html \
makepkg.8.html \
makepkg-template.1.html \
@@ -27,7 +29,6 @@ HTML_MANPAGES = \
vercmp.8.html \
pkgdelta.8.html \
pacman-key.8.html \
pactree.8.html \
PKGBUILD.5.html \
makepkg.conf.5.html \
pacman.conf.5.html \
@@ -46,23 +47,24 @@ HTML_DOCS = \
EXTRA_DIST = \
asciidoc.conf \
asciidoc-override.css \
pacman.8.txt \
makepkg.8.txt \
makepkg-template.1.txt \
repo-add.8.txt \
vercmp.8.txt \
pkgdelta.8.txt \
pacman-key.8.txt \
pactree.8.txt \
PKGBUILD.5.txt \
alpm-hooks.5.asciidoc \
pacman.8.asciidoc \
makepkg.8.asciidoc \
makepkg-template.1.asciidoc \
repo-add.8.asciidoc \
vercmp.8.asciidoc \
pkgdelta.8.asciidoc \
pacman-key.8.asciidoc \
PKGBUILD.5.asciidoc \
PKGBUILD-example.txt \
makepkg.conf.5.txt \
pacman.conf.5.txt \
libalpm.3.txt \
footer.txt \
index.txt \
submitting-patches.txt \
translation-help.txt \
makepkg.conf.5.asciidoc \
pacman.conf.5.asciidoc \
BUILDINFO.5.asciidoc \
libalpm.3.asciidoc \
footer.asciidoc \
index.asciidoc \
submitting-patches.asciidoc \
translation-help.asciidoc \
Doxyfile \
$(ASCIIDOC_MANS) \
$(DOXYGEN_MANS)
@@ -118,7 +120,8 @@ ASCIIDOC_OPTS = \
-a pacman_date="`date +%Y-%m-%d`" \
-a pkgdatadir=$(pkgdatadir) \
-a localstatedir=$(localstatedir) \
-a sysconfdir=$(sysconfdir)
-a sysconfdir=$(sysconfdir) \
-a datarootdir=$(datarootdir)
A2X_OPTS = \
--no-xmllint \
@@ -127,11 +130,11 @@ A2X_OPTS = \
--xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
# These rules are due to the includes and files of the asciidoc text
$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile.am
$(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.txt
$(ASCIIDOC_MANS): asciidoc.conf footer.asciidoc Makefile.am
$(AM_V_GEN)a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS) --out-file=./$@.xml" $(srcdir)/$@.asciidoc
%.html: %.txt
$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - $*.txt | \
%.html: %.asciidoc
$(AM_V_GEN)asciidoc $(ASCIIDOC_OPTS) -o - $*.asciidoc | \
sed -e 's/\r$$//' > $@
HACKING.html: ../HACKING
@@ -139,7 +142,7 @@ HACKING.html: ../HACKING
sed -e 's/\r$$//' > $@
# Customizations for certain HTML docs
$(HTML_MANPAGES): asciidoc.conf footer.txt Makefile.am
$(HTML_MANPAGES): asciidoc.conf footer.asciidoc 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
%.8.html: ASCIIDOC_OPTS += -d manpage
@@ -147,18 +150,18 @@ $(HTML_OTHER): asciidoc.conf Makefile.am
%.3.html: ASCIIDOC_OPTS += -d manpage
# Dependency rules
pacman.8 pacman.8.html: pacman.8.txt
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
alpm-hooks.5 alpm-hooks.5.html: alpm-hooks.5.asciidoc
pacman.8 pacman.8.html: pacman.8.asciidoc
makepkg.8 makepkg.8.html: makepkg.8.asciidoc
makepkg-template.1 makepkg-template.1.html: makepkg-template.1.asciidoc
repo-add.8 repo-add.8.html: repo-add.8.asciidoc
vercmp.8 vercmp.8.html: vercmp.8.asciidoc
pkgdelta.8 pkgdelta.8.html: pkgdelta.8.asciidoc
pacman-key.8 pacman-key.8.html: pacman-key.8.asciidoc
PKGBUILD.5 PKGBUILD.5.html: PKGBUILD.5.asciidoc PKGBUILD-example.txt
makepkg.conf.5 makepkg.conf.5.html: makepkg.conf.5.asciidoc
pacman.conf.5 pacman.conf.5.html: pacman.conf.5.asciidoc
libalpm.3 libalpm.3.html: libalpm.3.asciidoc
# this one is just a symlink
repo-remove.8: repo-add.8
$(RM) repo-remove.8
@@ -173,5 +176,3 @@ install-data-hook:
uninstall-hook:
$(RM) $(DESTDIR)$(mandir)/man8/repo-remove.8
# vim:set noet:

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
PKGBUILD(5)
===========
@@ -48,14 +45,15 @@ similar to `$_basekernver`.
*pkgver*::
The version of the software as released from the author (e.g., '2.7.1').
The variable is not allowed to contain colons or hyphens.
The variable is not allowed to contain colons, forward slashes, hyphens
or whitespace.
+
The `pkgver` variable can be automatically updated by providing a `pkgver()`
function in the PKGBUILD that outputs the new package version.
This is run after downloading and extracting the sources so it can use those
files in determining the new `pkgver`.
This is most useful when used with sources from version control systems (see
below).
This is run after downloading and extracting the sources and running the
`prepare()` function (if present), so it can use those files in determining the
new `pkgver`. This is most useful when used with sources from version control
systems (see below).
*pkgrel*::
This is the release number specific to the Arch Linux release. This
@@ -64,11 +62,6 @@ below).
software release and incremented for intermediate PKGBUILD updates. The
variable is not allowed to contain hyphens.
*pkgdesc*::
This should be a brief description of the package and its functionality.
Try to keep the description to one line of text and to not use the package's
name.
*epoch*::
Used to force the package to be seen as newer than any previous versions
with a lower epoch, even if the version number would normally not trigger
@@ -78,6 +71,11 @@ below).
version comparison logic. See linkman:pacman[8] for more information on
version comparisons.
*pkgdesc*::
This should be a brief description of the package and its functionality.
Try to keep the description to one line of text and to not use the package's
name.
*url*::
This field contains a URL that is associated with the software being
packaged. This is typically the project's web site.
@@ -168,7 +166,8 @@ contain whitespace characters.
*arch (array)*::
Defines on which architectures the given package is available (e.g.,
`arch=('i686' 'x86_64')`). Packages that contain no architecture specific
files should use `arch=('any')`.
files should use `arch=('any')`. Valid characters for members of this array
are alphanumerics and ```_`''.
*backup (array)*::
An array of file names, without preceding slashes, that
@@ -293,9 +292,6 @@ underscore and the architecture name e.g., 'replaces_x86_64=()'.
*zipman*;;
Compress man and info pages with gzip.
*upx*;;
Compress binary executable files using UPX.
*ccache*;;
Allow the use of ccache during build. More useful in its negative
form `!ccache` with select packages that have problems building
@@ -365,12 +361,14 @@ the `build()` function.
`checkdepends` array.
All of the above variables such as `$pkgname` and `$pkgver` are available for
use in the `build()` function. In addition, makepkg defines the following
variables for use during the build and install process:
use in the packaging functions. In addition, makepkg defines the following
variables:
*srcdir*::
This contains the directory where makepkg extracts, or copies, all source
files.
+
All of the packaging functions defined above are run starting inside `$srcdir`
*pkgdir*::
This contains the directory where makepkg bundles the installed package.
@@ -397,13 +395,20 @@ each split package's packaging function:
`provides`, `conflicts`, `replaces`, `backup`, `options`, `install`, and
`changelog`.
Note that makepkg does not consider split package `depends` when checking
if dependencies are installed before package building and with `--syncdeps`.
All packages required to make the package are required to be specified in
the global `depends` and `makedepends` arrays.
An optional global directive is available when building a split package:
*pkgbase*::
The name used to refer to the group of packages in the output of makepkg
and in the naming of source-only tarballs. If not specified, the first
element in the `pkgname` array is used. The variable is not allowed to
begin with a hyphen.
element in the `pkgname` array is used. Valid characters for this
variable are alphanumerics, and any of the following characters:
```@ . _ + -`''. Additionally, the variable is not allowed to start with
hyphens or dots.
Install/Upgrade/Remove Scripting
@@ -414,7 +419,7 @@ itself after installation and perform an opposite action upon removal.
The exact time the script is run varies with each operation, and should be
self-explanatory. Note that during an upgrade operation, none of the install
or remove scripts will be called.
or remove functions will be called.
Scripts are passed either one or two ``full version strings'', where a full
version string is either 'pkgver-pkgrel' or 'epoch:pkgver-pkgrel', if epoch is
@@ -458,12 +463,12 @@ Using VCS Sources[[VCS]]
------------------------
Building a developmental version of a package using sources from a version
control system (VCS) is enabled by specifying the source in the form
`source=('directory::url#fragment')`. Currently makepkg supports the Bazaar, Git,
Subversion, and Mercurial version control systems. For other version control
systems, manual cloning of upstream repositories must be done in the `prepare()`
function.
`source=('directory::url#fragment?query')`. Currently makepkg supports the
Bazaar, Git, Subversion, and Mercurial version control systems. For other
version control systems, manual cloning of upstream repositories must be done
in the `prepare()` function.
The source URL is divided into three components:
The source URL is divided into four components:
*directory*::
(optional) Specifies an alternate directory name for makepkg to download
@@ -495,6 +500,11 @@ The source URL is divided into three components:
*svn*;;
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
-------
@@ -512,4 +522,4 @@ See Also
--------
linkman:makepkg[8], linkman:pacman[8], linkman:makepkg.conf[5]
include::footer.txt[]
include::footer.asciidoc[]

128
doc/alpm-hooks.5.asciidoc Normal file
View File

@@ -0,0 +1,128 @@
alpm-hooks(5)
=============
NAME
----
alpm-hooks - alpm hook file format
SYNOPSIS
--------
--------
[Trigger] (Required, Repeatable)
Operation = Install|Upgrade|Remove (Required, Repeatable)
Type = File|Package (Required)
Target = <Path|PkgName> (Required, Repeatable)
[Action] (Required)
Description = ... (Optional)
When = PreTransaction|PostTransaction (Required)
Exec = <Command> (Required)
Depends = <PkgName> (Optional)
AbortOnFail (Optional, PreTransaction only)
NeedsTargets (Optional)
--------
DESCRIPTION
-----------
libalpm provides the ability to specify hooks to run before or after
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
'[Trigger]' section describing which transactions it should be run for. Hook
file names are required to have the suffix ".hook". Hooks are run in
alphabetical order of their file name.
TRIGGERS
--------
Hooks must contain at least one '[Trigger]' section that determines which
transactions will cause the hook to run. If multiple trigger sections are
defined the hook will run if the transaction matches *any* of the triggers.
*Operation =* Install|Upgrade|Remove::
Select the type of operation to match targets against. May be specified
multiple times. Installations are considered an upgrade if the package or
file is already present on the system regardless of whether the new package
version is actually greater than the currently installed version. For File
triggers, this is true even if the file changes ownership from one package
to another. Required.
*Type =* File|Package::
Select whether targets are matched against transaction packages or files.
See CAVEATS for special notes regarding File triggers. Required.
*Target =* <path|package>::
The file path or package name to match against the active transaction.
File paths refer to the files in the package archive; the installation root
should *not* be included in the path. Shell-style glob patterns are
allowed. It is possible to invert matches by prepending a file with an
exclamation mark. May be specified multiple times. Required.
ACTIONS
-------
*Description =* ...::
An optional description that describes the action being taken by the
hook for use in front-end output.
*Exec =* <command>::
Command to run. Command arguments are split on whitespace. Values
containing whitespace should be enclosed in quotes. Required.
*When =* PreTransaction|PostTransaction::
When to run the hook. Required.
*Depends =* <package>::
Packages that must be installed for the hook to run. May be specified
multiple times.
*AbortOnFail*::
Causes the transaction to be aborted if the hook exits non-zero. Only
applies to PreTransaction hooks.
*NeedsTargets*::
Causes the list of matched trigger targets to be passed to the running hook
on 'stdin'.
OVERRIDING HOOKS
----------------
Hooks may be overridden by placing a file with the same name in a higher
priority hook directory. Hooks may be disabled by overriding them with
a symlink to '/dev/null'.
EXAMPLES
--------
--------
# Force disks to sync to reduce the risk of data corruption
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *
[Action]
Depends = coreutils
When = PostTransaction
Exec = /usr/bin/sync
--------
CAVEATS
-------
There are situations when file triggers may act in unexpected ways. Hooks are
triggered using the file list of the installed, upgraded, or removed package.
When installing or upgrading a file that is extracted with a '.pacnew'
extension, the original file name is used in triggering the hook. When
removing a package, all files owned by that package can trigger a hook whether
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
any reason.
include::footer.asciidoc[]

View File

@@ -1,6 +1,3 @@
/////
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
information on pacman and its related tools.

View File

@@ -31,6 +31,9 @@ alternative front ends.
Version 4.0 added package signing and verification capabilities to the entire
makepkg/repo-add/pacman toolchain via GnuPG and GPGME.
Version 5.0 added support for pre/post-transaction hooks and sync database file
list operations.
Documentation
-------------
@@ -39,6 +42,7 @@ Man Pages
There are several man pages available for the programs, utilities, and
configuration files dealing with pacman.
* linkman:alpm-hooks[5]
* linkman:PKGBUILD[5]
* linkman:libalpm[3]
* linkman:makepkg[8]
@@ -71,6 +75,11 @@ Releases
[frame="topbot",grid="none",options="header,autowidth"]
!======
!Version !Date
!5.1.0 !2017-05-28
!5.0.1 !2016-02-23
!5.0.0 !2016-01-30
!4.2.1 !2015-02-20
!4.2.0 !2014-12-19
!4.1.2 !2013-06-18
!4.1.1 !2013-05-07
!4.1.0 !2013-04-01
@@ -98,14 +107,14 @@ Releases
!3.2.1 !2008-08-26
!3.2.0 !2008-07-30
!3.1.4 !2008-04-01
!3.1.3 !2008-03-06
!3.1.2 !2008-02-20
!3.1.1 !2008-01-20
!======
|
[frame="topbot",grid="none",options="header,autowidth"]
!======
!Version !Date
!3.1.3 !2008-03-06
!3.1.2 !2008-02-20
!3.1.1 !2008-01-20
!3.1.0 !2008-01-09
!3.0.6 !2007-09-16
!3.0.5 !2007-06-17
@@ -133,12 +142,12 @@ Releases
!2.8 !2004-07-03
!2.7.9 !2004-04-30
!2.7.8 !2004-04-29
!2.7.7 !2004-04-15
!======
|
[frame="topbot",grid="none",options="header,autowidth"]
!======
!Version !Date
!2.7.7 !2004-04-15
!2.7.6 !2004-04-04
!2.7.5 !2004-03-02
!2.7.4 !2004-02-18
@@ -172,7 +181,7 @@ Releases
|======
Source code for all releases is available at
link:ftp://ftp.archlinux.org/other/pacman/[]. To install, download the newest
link:https://sources.archlinux.org/other/pacman/[]. To install, download the newest
available source tarball, unpack it in a directory, and run the three magic
commands:
@@ -247,11 +256,7 @@ bugs under the Pacman project.
Copyright
---------
pacman is Copyright (C) 2006-2014 Pacman Development Team
pacman is Copyright (C) 2006-2018 Pacman Development Team
<pacman-dev@archlinux.org> and Copyright (C) 2002-2006 Judd Vinet
<jvinet@zeroflux.org> and is licensed through the GNU General Public License,
version 2 or later.
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////

View File

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

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
makepkg-template(1)
===================
@@ -47,8 +44,8 @@ and end markers and the template code on the first run.
Template files should be stored in one directory and filenames should be
"$template_name-$version.template" with a symlink "$template_name.template"
pointing to the most recent template. If the version is not set in the marker,
'makepkg-template' will automatically use the most recent version of the
template, otherwise the specified version will be used. This allows for easier
'makepkg-template' will automatically use the target of "$template_name.template",
otherwise the specified version will be used. This allows for easier
verification of untrusted PKGBUILDs if the template is trusted. You verify the
non-template code and then use a command similar to this:
@@ -72,7 +69,9 @@ Options
Always use the newest available template file.
*\--template-dir* <dir>::
Change the dir where we are looking for template files.
Change the dir where we are looking for template files. This option may be
given multiple times in which case files found in directory given last will
take precedence.
Example PKGBUILD
@@ -116,4 +115,4 @@ See Also
--------
linkman:makepkg[8], linkman:PKGBUILD[5]
include::footer.txt[]
include::footer.asciidoc[]

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
makepkg(8)
==========
@@ -103,11 +100,11 @@ Options
linkman:pacman[8].
*-L, \--log*::
Enable makepkg build logging. This will use the *tee* program to send
output of the `build()` function to both the console and to a text file in
the build directory named `pkgname-pkgver-pkgrel-arch.log`. As mentioned
above, the build log will be localized so you may want to set your locale
accordingly if sharing the log output with others.
Enable logging. This will use the *tee* program to send the output of each
of the PKGBUILD functions to both the console and to a text file in the
build directory named `pkgbase-pkgver-pkgrel-arch-<function>.log`.
As mentioned above, the logs will be localized so you may want to set your
locale accordingly if sharing the log output with others.
*-m, \--nocolor*::
Disable color in output messages.
@@ -156,10 +153,6 @@ Options
such as a chroot or remote builder. It will also satisfy requirements of
the GPL when distributing binary packages.
*\--pkg* <list>::
Only build listed packages from a split package. Multiple packages should
be comma separated in the list. This option can be specified multiple times.
*\--check*::
Run the check() function in the PKGBUILD, overriding the setting in
linkman:makepkg.conf[5].
@@ -203,6 +196,13 @@ Options
(Passed to pacman) Prevent pacman from displaying a progress bar;
useful if you are redirecting makepkg output to file.
*\--packagelist*::
List the package filenames that would be produced without building. Listed
package filenames include PKGDEST and PKGEXT.
*\--printsrcinfo*::
Generate and print the SRCINFO file to stdout.
Additional Features
-------------------
@@ -212,6 +212,19 @@ separate utility 'versionpkg'. See linkman:PKGBUILD[5] for details on how to
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
---------------------
**PACMAN**::
@@ -263,6 +276,8 @@ Environment Variables
Specify a key to use when signing packages, overriding the GPGKEY setting
in linkman:makepkg.conf[5]
**SOURCE_DATE_EPOCH=**"<date>"::
Used for link:https://reproducible-builds.org/docs/[Reproducible Builds].
Configuration
-------------
@@ -270,8 +285,65 @@ See linkman:makepkg.conf[5] for more details on configuring makepkg using the
'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
--------
linkman:makepkg.conf[5], linkman:PKGBUILD[5], linkman:pacman[8]
include::footer.txt[]
include::footer.asciidoc[]

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
makepkg.conf(5)
===============
@@ -39,8 +36,9 @@ Options
**DLAGENTS=(**\'protocol::/path/to/command [options]' ...**)**::
Sets the download agents used to fetch source files specified with a URL in
the linkman:PKGBUILD[5] file. Options can be specified for each command as
well, and any protocol can have a download agent. Several examples are provided
in the default makepkg.conf.
well, and any protocol can have a download agent. Any spaces in option
arguments are required to be escaped to avoid being split. Several
examples are provided in the default makepkg.conf.
+
If present, `%u` will be replaced with the download URL. Otherwise, the
download URL will be placed on the end of the command. If present, `%o` will
@@ -91,7 +89,7 @@ Options
**DEBUG_CXXFLAGS=**"debug_cxxflags"::
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
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
@@ -140,7 +138,7 @@ Options
Specify a key to use for GPG signing instead of the default key in the
keyring. Can be overridden with makepkg's '\--key' option.
**OPTIONS=(**strip docs libtool staticlibs emptydirs zipman purge !upx**)**::
**OPTIONS=(**!strip docs libtool staticlibs emptydirs !zipman !purge !debug**)**::
This array contains options that affect default packaging. They 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
@@ -177,10 +175,6 @@ Options
Remove files specified by the `PURGE_TARGETS` variable from the
package.
*upx*;;
Compress binary executable files using UPX. Additional options
can be passed to UPX by specifying the `UPXFLAGS` variable.
*debug*;;
Add the user-specified debug flags as specified in DEBUG_CFLAGS and
DEBUG_CXXFLAGS to their counterpart buildflags. Creates a separate
@@ -196,8 +190,8 @@ Options
for details.
**STRIP_SHARED=**"--strip-unneeded"::
Options to be used when stripping shared libraries. See linkman:strip[1]
for details.
Options to be used when stripping shared libraries or PIE executables.
See linkman:strip[1] for details.
**STRIP_STATIC=**"--strip-debug"::
Options to be used when stripping static libraries. See linkman:strip[1]
@@ -221,6 +215,12 @@ Options
instruct makepkg which files to remove from the package. This is
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"::
If this value is not set, packages will, by default, be placed in the
current directory (location of the linkman:PKGBUILD[5]). Many people
@@ -266,4 +266,4 @@ See Also
--------
linkman:makepkg[8], linkman:pacman[8], linkman:PKGBUILD[5]
include::footer.txt[]
include::footer.asciidoc[]

View File

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

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pacman(8)
=========
@@ -35,10 +32,10 @@ as an argument, targets will be read from stdin.
Operations
----------
*-D, \--database*::
Modify the package database. This operation allows you to modify certain
attributes of the installed packages in pacman's database. At the
moment, you can only change the install reason using '\--asdeps' and
'\--asexplicit' options.
Operate on the package database. This operation allows you to modify
certain attributes of the installed packages in pacman's database. It
also allows you to check the databases for internal consistency.
See <<DO,Database Options>> below.
*-Q, \--query*::
Query the package database. This operation allows you to view installed
@@ -110,6 +107,12 @@ greater than `1:3.6-1`.
Options>> below; also see <<HCF,Handling Config Files>> for an explanation
on how pacman takes care of configuration files.
*-F, \--files*::
Query the files database. This operation allows you to look for packages
owning certain files or display files owned by certain packages. Only
packages that are part of your sync databases are searched. See
<<FO,File Options>> below.
*-V, \--version*::
Display version and exit.
@@ -121,21 +124,12 @@ greater than `1:3.6-1`.
Options
-------
*-b, \--dbpath* <path>::
Specify an alternative database location (a typical default is
Specify an alternative database location (the default is
+{localstatedir}/lib/pacman+). This should not be used unless you know what
you are doing.
*NOTE*: If specified, this is an absolute path, and the root path is
not automatically prepended.
*-r, \--root* <path>::
Specify an alternative installation root (default is `/`). This should
not be used as a way to install software into `/usr/local` instead of
`/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
command line or in linkman:pacman.conf[5], their default location will
be inside this root path.
*-v, \--verbose*::
Output paths such as as the Root, Conf File, DB Path, Cache Dirs, etc.
@@ -143,7 +137,7 @@ Options
Specify an alternate architecture.
*\--cachedir* <dir>::
Specify an alternative package cache location (a typical default is
Specify an alternative package cache location (the default is
+{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be
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
@@ -162,13 +156,20 @@ Options
to be used.
*\--gpgdir* <dir>::
Specify a directory of files used by GnuPG to verify package signatures (a
typical default is +{sysconfdir}/pacman.d/gnupg+). This directory should contain
Specify a directory of files used by GnuPG to verify package signatures
(the default is +{sysconfdir}/pacman.d/gnupg+). This directory should contain
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
specifies that the keys are authentic and trusted. *NOTE*: This is an absolute
path, and the root path is not automatically prepended.
*\--hookdir* <dir>::
Specify a alternative directory containing hook files (the default is
+{sysconfdir}/pacman.d/hooks+). Multiple hook directories can be specified
with hooks in later directories taking precedence over hooks in earlier
directories. *NOTE*: This is an absolute path, and the root path is not
automatically prepended.
*\--logfile* <file>::
Specify an alternate log file. This is an absolute path, regardless of
the installation root setting.
@@ -180,6 +181,16 @@ Options
*\--confirm*::
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')
--------------------------------------------------
@@ -219,15 +230,7 @@ Transaction Options (apply to '-S', '-R' and '-U')
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*::
Install packages non-explicitly; in other words, fake their install reason
to be installed as a dependency. This is useful for makepkg and other
@@ -253,9 +256,21 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
*\--needed*::
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*::
View the ChangeLog of a package if it exists.
@@ -280,7 +295,7 @@ Query Options[[QO]]
'\--info' or '-i' flags will also display the list of backup files and
their modification states.
*-k \--check*::
*-k, \--check*::
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,
check all installed packages. Specifying this option twice will perform
@@ -325,10 +340,10 @@ Query Options[[QO]]
with descriptions matching ALL of those terms are returned.
*-t, \--unrequired*::
Restrict or filter output to packages not required or optionally required by
any currently installed package. Specify this option twice to only filter
packages that are direct dependencies (i.e. do not filter optional
dependencies).
Restrict or filter output to print only packages neither required nor
optionally required by any currently installed package. Specify this
option twice to include packages which are optionally, but not directly,
required by another package.
*-u, \--upgrades*::
Restrict or filter output to packages that are out-of-date on the local
@@ -337,8 +352,8 @@ Query Options[[QO]]
database is refreshed using '-Sy'.
Remove Options[[RO]]
--------------------
Remove Options (apply to '-R')[[RO]]
------------------------------------
*-c, \--cascade*::
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
@@ -362,8 +377,8 @@ Remove Options[[RO]]
to avoid breaking any dependencies.
Sync Options[[SO]]
------------------
Sync Options (apply to '-S')[[SO]]
----------------------------------
*-c, \--clean*::
Remove packages that are no longer installed from the cache as well as
currently unused sync databases to free up disk space. When pacman
@@ -424,13 +439,64 @@ system upgrade and install/upgrade the "foo" package in the same operation.
Retrieve all packages from the server, but do not install/upgrade anything.
*-y, \--refresh*::
Download a fresh copy of the master package list from the server(s)
Download a fresh copy of the master package database from the server(s)
defined in linkman:pacman.conf[5]. This should typically be used each time
you use '\--sysupgrade' or '-u'. Passing two '\--refresh' or '-y' flags
will force a refresh of all package lists, even if they appear to be up-
to-date.
will force a refresh of all package databases, even if they appear to be
up-to-date.
Database Options (apply to '-D')[[QO]]
--------------------------------------
*\--asdeps* <package>::
Mark a package as non-explicitly installed; in other words, set their install
reason to be installed as a dependency.
*\--asexplicit* <package>::
Mark a package as explicitly installed; in other words, set their install
reason to be explicitly installed. This is useful it you want to keep a
package installed even when it was initially installed as a dependency
of another package.
*-k, \--check*::
Check the local package database is internally consistent. This will
check all required files are present and that installed packages have
the required dependencies, do not conflict and that multiple packages
do not own the same file. Specifying this option twice will perform
a check on the sync databases to ensure all specified dependencies
are available.
*-q, \--quiet*::
Suppress messages on successful completion of database operations.
File Options (apply to '-F')[[FO]]
----------------------------------
*-y, --refresh*::
Download fresh package databases from the server. Use twice to force a
refresh even if databases are up to date.
*-l, \--list*::
List the files owned by the queried package.
*-s, \--search*::
Search package file names for matching strings.
*-x, --regex*::
Treat arguments to '--search' as regular expressions.
*-o, \--owns*::
Search for packages that own a particular file.
*-q, \--quiet*::
Show less information for certain file operations. This is useful when
pacman's output is processed in a script, however, you may want to use
'--machinereadable' instead.
*--machinereadable*::
Use a machine readable output format for '--list', '--search' and
'--owns'. The format is 'repository\0pkgname\0pkgver\0path\n' with '\0'
being the NULL character and '\n' a linefeed.
Handling Config Files[[HCF]]
----------------------------
Pacman uses the same logic as 'rpm' to determine action against files that are
@@ -463,8 +529,9 @@ original=X, current=Y, new=Z::
original=NULL, current=Y, new=Z::
The package was not previously installed, and the file already exists on the
file system. Save the current file with a '.pacorig' extension, install the
new file, and warn the user.
file system. Install the new file with a '.pacnew' extension and warn the
user. The user must then manually merge any necessary changes into the
original file.
Examples
@@ -495,6 +562,7 @@ See linkman:pacman.conf[5] for more details on configuring pacman using the
See Also
--------
linkman:pacman.conf[5], linkman:makepkg[8], linkman:libalpm[3]
linkman:alpm-hooks[5], linkman:libalpm[3], linkman:makepkg[8],
linkman:pacman.conf[5]
include::footer.txt[]
include::footer.asciidoc[]

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
pacman.conf(5)
==============
@@ -48,7 +45,7 @@ work.
Options
-------
*RootDir =* path/to/root::
*RootDir =* /path/to/root/dir::
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
which is "owned" by another system, or for a chroot install.
@@ -56,23 +53,32 @@ Options
command line or in linkman:pacman.conf[5], their default location will
be inside this root path.
*DBPath =* path/to/db/dir::
Overrides the default location of the toplevel database directory. A
typical default is +{localstatedir}/lib/pacman/+. Most users will not need to set
*DBPath =* /path/to/db/dir::
Overrides the default location of the toplevel database directory. The
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
path is not automatically prepended.
*CacheDir =* path/to/cache/dir::
Overrides the default location of the package cache directory. A typical
*CacheDir =* /path/to/cache/dir::
Overrides the default location of the package cache directory. The
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
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
path, the root path is not automatically prepended.
*GPGDir =* path/to/gpg/dir::
*HookDir =* /path/to/hook/dir::
Add directories to search for alpm hooks in addition to the system hook
directory (+{datarootdir}/libalpm/hooks/+). The default is
+{sysconfdir}/pacman.d/hooks+. Multiple directories can be specified with
hooks in later directories taking precedence over hooks in earlier
directories. *NOTE*: this is an absolute path, the root path is not
automatically prepended. For more information on the alpm hooks, see
linkman:alpm-hooks[5].
*GPGDir =* /path/to/gpg/dir::
Overrides the default location of the directory containing configuration
files for GnuPG. A typical default is +{sysconfdir}/pacman.d/gnupg/+.
files for GnuPG. The default is +{sysconfdir}/pacman.d/gnupg/+.
This directory should contain 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 specifies that the keys are
@@ -80,8 +86,8 @@ Options
*NOTE*: this is an absolute path, the root path is not automatically
prepended.
*LogFile =* /path/to/file::
Overrides the default location of the pacman log file. A typical default
*LogFile =* /path/to/log/file::
Overrides the default location of the pacman log file. The default
is +{localstatedir}/log/pacman.log+. This is an absolute path and the root directory
is not prepended.
@@ -99,7 +105,7 @@ Options
group when performing a '\--sysupgrade'. Shell-style glob patterns are
allowed.
*Include =* path::
*Include =* /path/to/config/file::
Include another configuration file. This file can include repositories or
general configuration options. Wildcards in the specified paths will get
expanded based on linkman:glob[7] rules.
@@ -200,6 +206,10 @@ Options
Displays name, version and size of target packages formatted
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
-------------------
@@ -358,4 +368,4 @@ See Also
--------
linkman:pacman[8], linkman:libalpm[3]
include::footer.txt[]
include::footer.asciidoc[]

View File

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

View File

@@ -1,6 +1,3 @@
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////
repo-add(8)
==========
@@ -34,9 +31,9 @@ delta specified on the command line. Multiple packages and/or delta to remove
can be specified on the command line.
A package database is a tar file, optionally compressed. Valid extensions are
``.db'' or ``.files'' followed by an archive extension of ``.tar'',
``.tar.gz'', ``.tar.bz2'', ``.tar.xz'', or ``.tar.Z''. The file does not need
to exist, but all parent directories must exist.
``.db'' followed by an archive extension of ``.tar'', ``.tar.gz'', ``.tar.bz2'',
``.tar.xz'', or ``.tar.Z''. The file does not need to exist, but all parent
directories must exist.
Common Options
@@ -71,11 +68,6 @@ repo-add Options
Automatically generate and add a delta file between the old entry and the
new one, if the old package file is found next to the new one.
*-f, \--files*::
Tells 'repo-add' also to create and include a list of the files in the
specified packages. This is useful for creating databases listing all files
in a given sync repository for tools that may use this information.
*-n, \--new*::
Only add packages that are not already in the database. Warnings will be
printed upon detection of existing packages, but they will not be re-added.
@@ -87,19 +79,16 @@ repo-add Options
Example
-------
'repo-add' is often invoked twice to create two separate databases; a smaller
database used by pacman and a large database containing package file lists for
use by other utilities.
'repo-add' foo.db.tar.xz <pkg1> [<pkg2> ...]
'repo-add' -f foo.files.tar.xz <pkg1> [<pkg2> ...]
While pacman can use the large database (if given a db.tar* extension), there
is currently no additional benefit for the larger download.
This creates two separate databases; a smaller database ``foo.db.tar.xz'' used by
pacman and a large database containing package file lists ``foo.files.tar.xz'' for
use by other utilities. While pacman can use the large database (if renamed with a
db.tar* extension), there is currently no additional benefit for the larger download.
See Also
--------
linkman:makepkg[8], linkman:pacman[8], linkman:pkgdelta[8]
include::footer.txt[]
include::footer.asciidoc[]

View File

@@ -99,7 +99,3 @@ 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.
--
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////

View File

@@ -151,7 +151,3 @@ 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
source, please contact the pacman-dev mailing list at
mailto:pacman-dev@archlinux.org[].
/////
vim:set ts=4 sw=4 syntax=asciidoc noet spell spelllang=en_us:
/////

View File

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

View File

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

View File

@@ -1,3 +1,4 @@
#!/hint/bash
#
# @sysconfdir@/makepkg.conf
#
@@ -8,9 +9,10 @@
#
#-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent'
DLAGENTS=('ftp::/usr/bin/curl -qfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
'http::/usr/bin/curl -qb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'https::/usr/bin/curl -qb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o')
@@ -48,7 +50,7 @@ CHOST="@CHOST@"
# 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.
#
#-- distcc: Use the Distributed C/C++/ObjC compiler
@@ -71,7 +73,7 @@ BUILDENV=(!distcc color !ccache check !sign)
# These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
# Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
@@ -81,10 +83,9 @@ BUILDENV=(!distcc color !ccache check !sign)
#-- emptydirs: Leave empty directories in packages
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge: Remove files specified by PURGE_TARGETS
#-- upx: Compress binary executable files using UPX
#-- debug: Add debugging flags as specified in DEBUG_* variables
#
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug)
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
@@ -100,6 +101,8 @@ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"
#########################################################################
# PACKAGE OUTPUT
@@ -140,5 +143,3 @@ COMPRESSZ=(compress -c -f)
#
PKGEXT='@PKGEXT@'
SRCEXT='@SRCEXT@'
# vim: set ft=sh ts=2 sw=2 et:

View File

@@ -14,6 +14,7 @@
#CacheDir = @localstatedir@/cache/pacman/pkg/
#LogFile = @localstatedir@/log/pacman.log
#GPGDir = @sysconfdir@/pacman.d/gnupg/
#HookDir = @sysconfdir@/pacman.d/hooks/
HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -C - -f %u > %o
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u

View File

@@ -7,6 +7,7 @@ include_HEADERS = alpm_list.h alpm.h
AM_CPPFLAGS = \
-imacros $(top_builddir)/config.h \
-DSYSHOOKDIR=\"@datarootdir@/libalpm/hooks/\" \
-DLOCALEDIR=\"@localedir@\"
AM_CFLAGS = -pedantic -D_GNU_SOURCE $(WARNING_CFLAGS)
@@ -42,6 +43,8 @@ libalpm_la_SOURCES = \
graph.h graph.c \
group.h group.c \
handle.h handle.c \
hook.h hook.c \
ini.h ini.c \
libarchive-compat.h \
log.h log.c \
package.h package.c \
@@ -55,12 +58,6 @@ libalpm_la_SOURCES = \
util-common.h util-common.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_CFLAGS = \
@@ -68,13 +65,13 @@ libalpm_la_CFLAGS = \
$(GPGME_CFLAGS) \
$(LIBARCHIVE_CFLAGS) \
$(LIBCURL_CFLAGS) \
$(LIBSSL_CFLAGS)
$(LIBSSL_CFLAGS) \
$(NETTLE_CFLAGS)
libalpm_la_LIBADD = \
$(LTLIBINTL) \
$(GPGME_LIBS) \
$(LIBARCHIVE_LIBS) \
$(LIBCURL_LIBS) \
$(LIBSSL_LIBS)
# vim:set noet:
$(LIBSSL_LIBS) \
$(NETTLE_LIBS)

View File

@@ -1,7 +1,7 @@
/*
* add.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -90,7 +90,7 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
_alpm_log(handle, ALPM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"),
localpkgname, localpkgver);
}
} else if(cmp < 0) {
} else if(cmp < 0 && !(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY)) {
/* local version is newer */
_alpm_log(handle, ALPM_LOG_WARNING, _("downgrading package %s (%s => %s)\n"),
localpkgname, localpkgver, pkgver);
@@ -107,26 +107,42 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
}
static int perform_extraction(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, const char *filename, const char *origname)
struct archive_entry *entry, const char *filename)
{
int ret;
struct archive *archive_writer;
const int archive_flags = ARCHIVE_EXTRACT_OWNER |
ARCHIVE_EXTRACT_PERM |
ARCHIVE_EXTRACT_TIME;
ARCHIVE_EXTRACT_TIME |
ARCHIVE_EXTRACT_UNLINK |
ARCHIVE_EXTRACT_SECURE_SYMLINKS;
archive_entry_set_pathname(entry, filename);
ret = archive_read_extract(archive, entry, archive_flags);
archive_writer = archive_write_disk_new();
if (archive_writer == NULL) {
_alpm_log(handle, ALPM_LOG_ERROR, _("cannot allocate disk archive object"));
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: cannot allocate disk archive object");
return 1;
}
archive_write_disk_set_options(archive_writer, archive_flags);
ret = archive_read_extract2(archive, entry, archive_writer);
archive_write_free(archive_writer);
if(ret == ARCHIVE_WARN && archive_errno(archive) != ENOSPC) {
/* operation succeeded but a "non-critical" error was encountered */
_alpm_log(handle, ALPM_LOG_WARNING, _("warning given when extracting %s (%s)\n"),
origname, archive_error_string(archive));
filename, archive_error_string(archive));
} else if(ret != ARCHIVE_OK) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not extract %s (%s)\n"),
origname, archive_error_string(archive));
filename, archive_error_string(archive));
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: could not extract %s (%s)\n",
origname, archive_error_string(archive));
filename, archive_error_string(archive));
return 1;
}
return 0;
@@ -144,49 +160,59 @@ static int try_rename(alpm_handle_t *handle, const char *src, const char *dest)
return 0;
}
static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t *newpkg, alpm_pkg_t *oldpkg)
static int extract_db_file(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t *newpkg, const char *entryname)
{
const char *entryname;
mode_t entrymode;
char filename[PATH_MAX]; /* the actual file we're extracting */
int needbackup = 0, notouch = 0;
const char *hash_orig = NULL;
char *entryname_orig = NULL;
int errors = 0;
entryname = archive_entry_pathname(entry);
entrymode = archive_entry_mode(entry);
const char *dbfile = NULL;
if(strcmp(entryname, ".INSTALL") == 0) {
/* the install script goes inside the db */
snprintf(filename, PATH_MAX, "%s%s-%s/install",
_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
archive_entry_set_perm(entry, 0644);
dbfile = "install";
} else if(strcmp(entryname, ".CHANGELOG") == 0) {
/* the changelog goes inside the db */
snprintf(filename, PATH_MAX, "%s%s-%s/changelog",
_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
archive_entry_set_perm(entry, 0644);
dbfile = "changelog";
} else if(strcmp(entryname, ".MTREE") == 0) {
/* the mtree file goes inside the db */
snprintf(filename, PATH_MAX, "%s%s-%s/mtree",
_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
archive_entry_set_perm(entry, 0644);
dbfile = "mtree";
} else if(*entryname == '.') {
/* for now, ignore all files starting with '.' that haven't
* already been handled (for future possibilities) */
/* reserve all files starting with '.' for future possibilities */
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping extraction of '%s'\n", entryname);
archive_read_data_skip(archive);
return 0;
} else {
if (!alpm_filelist_contains(&newpkg->files, entryname)) {
_alpm_log(handle, ALPM_LOG_WARNING, _("file not found in file list for package %s. skipping extraction of %s\n"),
newpkg->name, entryname);
return 0;
}
/* build the new entryname relative to handle->root */
snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
}
archive_entry_set_perm(entry, 0644);
snprintf(filename, PATH_MAX, "%s%s-%s/%s",
_alpm_db_path(handle->db_local), newpkg->name, newpkg->version, dbfile);
return perform_extraction(handle, archive, entry, filename);
}
static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t *newpkg, alpm_pkg_t *oldpkg)
{
const char *entryname = archive_entry_pathname(entry);
mode_t entrymode = archive_entry_mode(entry);
alpm_backup_t *backup = _alpm_needbackup(entryname, newpkg);
char filename[PATH_MAX]; /* the actual file we're extracting */
int needbackup = 0, notouch = 0;
const char *hash_orig = NULL;
int isnewfile = 0, errors = 0;
struct stat lsbuf;
size_t filename_len;
if(*entryname == '.') {
return extract_db_file(handle, archive, entry, newpkg, entryname);
}
if (!alpm_filelist_contains(&newpkg->files, entryname)) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("file not found in file list for package %s. skipping extraction of %s\n"),
newpkg->name, entryname);
return 0;
}
/* build the new entryname relative to handle->root */
filename_len = snprintf(filename, PATH_MAX, "%s%s", handle->root, entryname);
if(filename_len >= PATH_MAX) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("unable to extract %s%s: path too long"), handle->root, entryname);
return 1;
}
/* if a file is in NoExtract then we never extract it */
@@ -214,123 +240,119 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
* 6- skip extraction, dir already exists.
*/
struct stat lsbuf;
if(llstat(filename, &lsbuf) != 0) {
isnewfile = llstat(filename, &lsbuf) != 0;
if(isnewfile) {
/* cases 1,2: file doesn't exist, skip all backup checks */
} else if(S_ISDIR(lsbuf.st_mode) && S_ISDIR(entrymode)) {
#if 0
uid_t entryuid = archive_entry_uid(entry);
gid_t entrygid = archive_entry_gid(entry);
#endif
/* case 6: existing dir, ignore it */
if(lsbuf.st_mode != entrymode) {
/* if filesystem perms are different than pkg perms, warn user */
mode_t mask = 07777;
_alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
"filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
entrymode & mask);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: directory permissions differ on %s\n"
"filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
entrymode & mask);
}
#if 0
/* Disable this warning until our user management in packages has improved.
Currently many packages have to create users in post_install and chown the
directories. These all resulted in "false-positive" warnings. */
if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
_alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
"filesystem: %u:%u package: %u:%u\n"), filename,
lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: directory ownership differs on %s\n"
"filesystem: %u:%u package: %u:%u\n", filename,
lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
}
#endif
_alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
filename);
archive_read_data_skip(archive);
return 0;
} else if(S_ISDIR(lsbuf.st_mode)) {
/* case 5: trying to overwrite dir with file, don't allow it */
_alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
filename);
archive_read_data_skip(archive);
return 1;
} else if(S_ISDIR(entrymode)) {
/* case 4: trying to overwrite file with dir */
_alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
filename);
} else {
if(S_ISDIR(lsbuf.st_mode)) {
if(S_ISDIR(entrymode)) {
#if 0
uid_t entryuid = archive_entry_uid(entry);
gid_t entrygid = archive_entry_gid(entry);
#endif
/* case 6: existing dir, ignore it */
if(lsbuf.st_mode != entrymode) {
/* if filesystem perms are different than pkg perms, warn user */
mode_t mask = 07777;
_alpm_log(handle, ALPM_LOG_WARNING, _("directory permissions differ on %s\n"
"filesystem: %o package: %o\n"), filename, lsbuf.st_mode & mask,
entrymode & mask);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: directory permissions differ on %s\n"
"filesystem: %o package: %o\n", filename, lsbuf.st_mode & mask,
entrymode & mask);
}
#if 0
/* Disable this warning until our user management in packages has improved.
Currently many packages have to create users in post_install and chown the
directories. These all resulted in "false-positive" warnings. */
if((entryuid != lsbuf.st_uid) || (entrygid != lsbuf.st_gid)) {
_alpm_log(handle, ALPM_LOG_WARNING, _("directory ownership differs on %s\n"
"filesystem: %u:%u package: %u:%u\n"), filename,
lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: directory ownership differs on %s\n"
"filesystem: %u:%u package: %u:%u\n", filename,
lsbuf.st_uid, lsbuf.st_gid, entryuid, entrygid);
}
#endif
_alpm_log(handle, ALPM_LOG_DEBUG, "extract: skipping dir extraction of %s\n",
filename);
archive_read_data_skip(archive);
return 0;
} else {
/* case 5: trying to overwrite dir with file, don't allow it */
_alpm_log(handle, ALPM_LOG_ERROR, _("extract: not overwriting dir with file %s\n"),
filename);
archive_read_data_skip(archive);
return 1;
}
} else if(S_ISDIR(entrymode)) {
/* case 4: trying to overwrite file with dir */
_alpm_log(handle, ALPM_LOG_DEBUG, "extract: overwriting file with dir %s\n",
filename);
/* case 3: trying to overwrite file with file */
/* if file is in NoUpgrade, don't touch it */
if(_alpm_fnmatch_patterns(handle->noupgrade, entryname) == 0) {
notouch = 1;
} else {
/* case 3: */
/* if file is in NoUpgrade, don't touch it */
if(_alpm_fnmatch_patterns(handle->noupgrade, entryname) == 0) {
notouch = 1;
} else {
alpm_backup_t *backup;
/* go to the backup array and see if our conflict is there */
/* check newpkg first, so that adding backup files is retroactive */
backup = _alpm_needbackup(entryname, newpkg);
if(backup) {
needbackup = 1;
}
/* check oldpkg for a backup entry, store the hash if available */
if(oldpkg) {
backup = _alpm_needbackup(entryname, oldpkg);
if(backup) {
hash_orig = backup->hash;
needbackup = 1;
}
}
alpm_backup_t *oldbackup;
if(oldpkg && (oldbackup = _alpm_needbackup(entryname, oldpkg))) {
hash_orig = oldbackup->hash;
needbackup = 1;
} else if(backup) {
/* allow adding backup files retroactively */
needbackup = 1;
}
}
}
/* we need access to the original entryname later after calls to
* archive_entry_set_pathname(), so we need to dupe it and free() later */
STRDUP(entryname_orig, entryname, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
if(notouch || needbackup) {
if(filename_len + strlen(".pacnew") >= PATH_MAX) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("unable to extract %s.pacnew: path too long"), filename);
return 1;
}
strcpy(filename + filename_len, ".pacnew");
isnewfile = (llstat(filename, &lsbuf) != 0 && errno == ENOENT);
}
if(needbackup) {
char *checkfile;
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
if(perform_extraction(handle, archive, entry, filename)) {
errors++;
return errors;
}
if(backup) {
FREE(backup->hash);
backup->hash = alpm_compute_md5sum(filename);
}
if(notouch) {
alpm_event_pacnew_created_t event = {
.type = ALPM_EVENT_PACNEW_CREATED,
.from_noupgrade = 1,
.oldpkg = oldpkg,
.newpkg = newpkg,
.file = filename
};
/* "remove" the .pacnew suffix */
filename[filename_len] = '\0';
EVENT(handle, &event);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: %s installed as %s.pacnew\n", filename, filename);
} else if(needbackup) {
char *hash_local = NULL, *hash_pkg = NULL;
size_t len;
char origfile[PATH_MAX] = "";
len = strlen(filename) + 10;
MALLOC(checkfile, len,
errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
snprintf(checkfile, len, "%s.paccheck", filename);
strncat(origfile, filename, filename_len);
if(perform_extraction(handle, archive, entry, checkfile, entryname_orig)) {
errors++;
goto needbackup_cleanup;
}
hash_local = alpm_compute_md5sum(origfile);
hash_pkg = backup ? backup->hash : alpm_compute_md5sum(filename);
hash_local = alpm_compute_md5sum(filename);
hash_pkg = alpm_compute_md5sum(checkfile);
/* update the md5 hash in newpkg's backup (it will be the new original) */
alpm_list_t *i;
for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) {
alpm_backup_t *backup = i->data;
char *newhash;
if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
continue;
}
STRDUP(newhash, hash_pkg, errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
FREE(backup->hash);
backup->hash = newhash;
}
_alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", entryname_orig);
_alpm_log(handle, ALPM_LOG_DEBUG, "checking hashes for %s\n", origfile);
_alpm_log(handle, ALPM_LOG_DEBUG, "current: %s\n", hash_local);
_alpm_log(handle, ALPM_LOG_DEBUG, "new: %s\n", hash_pkg);
_alpm_log(handle, ALPM_LOG_DEBUG, "original: %s\n", hash_orig);
@@ -339,8 +361,8 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
/* local and new files are the same, updating anyway to get
* correct timestamps */
_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
entryname_orig);
if(try_rename(handle, checkfile, filename)) {
origfile);
if(try_rename(handle, filename, origfile)) {
errors++;
}
} else if(hash_orig && hash_pkg && strcmp(hash_orig, hash_pkg) == 0) {
@@ -348,146 +370,40 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
* including any user changes */
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: leaving existing file in place\n");
unlink(checkfile);
if(isnewfile) {
unlink(filename);
}
} else if(hash_orig && hash_local && strcmp(hash_orig, hash_local) == 0) {
/* installed file has NOT been changed by user,
* update to the new version */
_alpm_log(handle, ALPM_LOG_DEBUG, "action: installing new file: %s\n",
entryname_orig);
if(try_rename(handle, checkfile, filename)) {
origfile);
if(try_rename(handle, filename, origfile)) {
errors++;
}
} else {
/* none of the three files matched another, unpack the new file alongside
* the local file */
if(oldpkg) {
char *newpath;
size_t newlen = strlen(filename) + strlen(".pacnew") + 1;
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: keeping current file and installing"
" new one with .pacnew ending\n");
MALLOC(newpath, newlen,
errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
snprintf(newpath, newlen, "%s.pacnew", filename);
if(try_rename(handle, checkfile, newpath)) {
errors++;
} else {
alpm_event_pacnew_created_t event = {
.type = ALPM_EVENT_PACNEW_CREATED,
.from_noupgrade = 0,
.oldpkg = oldpkg,
.newpkg = newpkg,
.file = filename
};
EVENT(handle, &event);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: %s installed as %s\n", filename, newpath);
}
free(newpath);
} else {
char *newpath;
size_t newlen = strlen(filename) + strlen(".pacorig") + 1;
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: saving existing file with a .pacorig ending"
" and installing a new one\n");
MALLOC(newpath, newlen,
errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
snprintf(newpath, newlen, "%s.pacorig", filename);
/* move the existing file to the "pacorig" */
if(try_rename(handle, filename, newpath)) {
errors++; /* failed rename filename -> filename.pacorig */
errors++; /* failed rename checkfile -> filename */
} else {
/* rename the file we extracted to the real name */
if(try_rename(handle, checkfile, filename)) {
errors++;
} else {
alpm_event_pacorig_created_t event = {
.type = ALPM_EVENT_PACORIG_CREATED,
.newpkg = newpkg,
.file = filename
};
EVENT(handle, &event);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: %s saved as %s\n", filename, newpath);
}
}
free(newpath);
}
}
needbackup_cleanup:
free(checkfile);
free(hash_local);
free(hash_pkg);
} else {
size_t len;
/* we didn't need a backup */
if(notouch) {
/* change the path to a .pacnew extension */
_alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoUpgrade -- skipping\n", filename);
/* remember len so we can get the old filename back for the event */
len = strlen(filename);
strncat(filename, ".pacnew", PATH_MAX - len);
} else {
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
}
if(handle->trans->flags & ALPM_TRANS_FLAG_FORCE) {
/* if FORCE was used, unlink() each file (whether it's there
* or not) before extracting. This prevents the old "Text file busy"
* error that crops up if forcing a glibc or pacman upgrade. */
unlink(filename);
}
if(perform_extraction(handle, archive, entry, filename, entryname_orig)) {
/* error */
free(entryname_orig);
errors++;
return errors;
}
if(notouch) {
/* none of the three files matched another, leave the unpacked
* file alongside the local file */
alpm_event_pacnew_created_t event = {
.type = ALPM_EVENT_PACNEW_CREATED,
.from_noupgrade = 1,
.from_noupgrade = 0,
.oldpkg = oldpkg,
.newpkg = newpkg,
.file = filename
.file = origfile
};
/* "remove" the .pacnew suffix */
filename[len] = '\0';
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: keeping current file and installing"
" new one with .pacnew ending\n");
EVENT(handle, &event);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: %s installed as %s.pacnew\n", filename, filename);
/* restore */
filename[len] = '.';
"warning: %s installed as %s\n", origfile, filename);
}
/* calculate an hash if this is in newpkg's backup */
alpm_list_t *i;
for(i = alpm_pkg_get_backup(newpkg); i; i = i->next) {
alpm_backup_t *backup = i->data;
char *newhash;
if(!backup->name || strcmp(backup->name, entryname_orig) != 0) {
continue;
}
_alpm_log(handle, ALPM_LOG_DEBUG, "appending backup entry for %s\n", entryname_orig);
newhash = alpm_compute_md5sum(filename);
FREE(backup->hash);
backup->hash = newhash;
free(hash_local);
if(!backup) {
free(hash_pkg);
}
}
free(entryname_orig);
return errors;
}
@@ -503,13 +419,16 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
alpm_event_package_operation_t event;
const char *log_msg = "adding";
const char *pkgfile;
struct archive *archive;
struct archive_entry *entry;
int fd, cwdfd;
struct stat buf;
ASSERT(trans != NULL, return -1);
/* see if this is an upgrade. if so, remove the old package first */
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db, newpkg->name);
if(local) {
int cmp = _alpm_pkg_compare_versions(newpkg, local);
if((oldpkg = newpkg->oldpkg)) {
int cmp = _alpm_pkg_compare_versions(newpkg, oldpkg);
if(cmp < 0) {
log_msg = "downgrading";
progress = ALPM_PROGRESS_DOWNGRADE_START;
@@ -525,14 +444,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
}
is_upgrade = 1;
/* we'll need to save some record for backup checks later */
if(_alpm_pkg_dup(local, &oldpkg) == -1) {
ret = -1;
goto cleanup;
}
/* copy over the install reason */
newpkg->reason = alpm_pkg_get_reason(local);
newpkg->reason = alpm_pkg_get_reason(oldpkg);
} else {
event.operation = ALPM_PACKAGE_INSTALL;
}
@@ -571,7 +484,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
}
}
/* prepare directory for database entries so permission are correct after
/* prepare directory for database entries so permissions are correct after
changelog/install script installation */
if(_alpm_local_db_prepare(db, newpkg)) {
alpm_logaction(handle, ALPM_CALLER_PREFIX,
@@ -582,37 +495,45 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
goto cleanup;
}
if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
struct archive *archive;
struct archive_entry *entry;
struct stat buf;
int fd, cwdfd;
fd = _alpm_open_archive(db->handle, pkgfile, &buf,
&archive, ALPM_ERR_PKG_OPEN);
if(fd < 0) {
ret = -1;
goto cleanup;
}
/* save the cwd so we can restore it later */
OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC);
if(cwdfd < 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n"));
}
/* libarchive requires this for extracting hard links */
if(chdir(handle->root) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno));
_alpm_archive_read_free(archive);
if(cwdfd >= 0) {
close(cwdfd);
}
close(fd);
ret = -1;
goto cleanup;
}
if(trans->flags & ALPM_TRANS_FLAG_DBONLY) {
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting db files\n");
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
const char *entryname = archive_entry_pathname(entry);
if(entryname[0] == '.') {
errors += extract_db_file(handle, archive, entry, newpkg, entryname);
} else {
archive_read_data_skip(archive);
}
}
} else {
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting files\n");
fd = _alpm_open_archive(db->handle, pkgfile, &buf,
&archive, ALPM_ERR_PKG_OPEN);
if(fd < 0) {
ret = -1;
goto cleanup;
}
/* save the cwd so we can restore it later */
OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC);
if(cwdfd < 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n"));
}
/* libarchive requires this for extracting hard links */
if(chdir(handle->root) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno));
_alpm_archive_read_free(archive);
close(fd);
ret = -1;
goto cleanup;
}
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
PROGRESS(handle, progress, newpkg->name, 0, pkg_count, pkg_current);
@@ -637,33 +558,34 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* extract the next file from the archive */
errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
}
_alpm_archive_read_free(archive);
close(fd);
}
/* restore the old cwd if we have it */
if(cwdfd >= 0) {
if(fchdir(cwdfd) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not restore working directory (%s)\n"), strerror(errno));
}
close(cwdfd);
_alpm_archive_read_free(archive);
close(fd);
/* restore the old cwd if we have it */
if(cwdfd >= 0) {
if(fchdir(cwdfd) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not restore working directory (%s)\n"), strerror(errno));
}
close(cwdfd);
}
if(errors) {
ret = -1;
if(is_upgrade) {
_alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
newpkg->name);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: problem occurred while upgrading %s\n",
newpkg->name);
} else {
_alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while installing %s\n"),
newpkg->name);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: problem occurred while installing %s\n",
newpkg->name);
}
if(errors) {
ret = -1;
if(is_upgrade) {
_alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while upgrading %s\n"),
newpkg->name);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: problem occurred while upgrading %s\n",
newpkg->name);
} else {
_alpm_log(handle, ALPM_LOG_ERROR, _("problem occurred while installing %s\n"),
newpkg->name);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"error: problem occurred while installing %s\n",
newpkg->name);
}
}
@@ -728,7 +650,6 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
EVENT(handle, &event);
cleanup:
_alpm_pkg_free(oldpkg);
return ret;
}
@@ -773,5 +694,3 @@ int _alpm_upgrade_packages(alpm_handle_t *handle)
return ret;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* add.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_ADD_H
#define _ALPM_ADD_H
#ifndef ALPM_ADD_H
#define ALPM_ADD_H
#include "db.h"
#include "alpm_list.h"
@@ -26,6 +26,4 @@
int _alpm_upgrade_packages(alpm_handle_t *handle);
#endif /* _ALPM_ADD_H */
/* vim: set noet: */
#endif /* ALPM_ADD_H */

View File

@@ -1,7 +1,7 @@
/*
* alpm.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -50,12 +50,12 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
{
alpm_errno_t myerr;
const char *lf = "db.lck";
char *hookdir;
size_t lockfilelen;
alpm_handle_t *myhandle = _alpm_handle_new();
if(myhandle == NULL) {
myerr = ALPM_ERR_MEMORY;
goto cleanup;
goto nomem;
}
if((myerr = _alpm_set_directory_option(root, &(myhandle->root), 1))) {
goto cleanup;
@@ -64,8 +64,18 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
goto cleanup;
}
/* to concatenate myhandle->root (ends with a slash) with SYSHOOKDIR (starts
* with a slash) correctly, we skip SYSHOOKDIR[0]; the regular +1 therefore
* disappears from the allocation */
MALLOC(hookdir, strlen(myhandle->root) + strlen(SYSHOOKDIR), goto nomem);
sprintf(hookdir, "%s%s", myhandle->root, SYSHOOKDIR + 1);
myhandle->hookdirs = alpm_list_add(NULL, hookdir);
/* set default database extension */
STRDUP(myhandle->dbext, ".db", goto nomem);
lockfilelen = strlen(myhandle->dbpath) + strlen(lf) + 1;
myhandle->lockfile = calloc(lockfilelen, sizeof(char));
MALLOC(myhandle->lockfile, lockfilelen, goto nomem);
snprintf(myhandle->lockfile, lockfilelen, "%s%s", myhandle->dbpath, lf);
if(_alpm_db_register_local(myhandle) == NULL) {
@@ -79,9 +89,11 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
return myhandle;
nomem:
myerr = ALPM_ERR_MEMORY;
cleanup:
_alpm_handle_free(myhandle);
if(err && myerr) {
if(err) {
*err = myerr;
}
return NULL;
@@ -140,7 +152,7 @@ const char SYMEXPORT *alpm_version(void)
/** Get the capabilities of the library.
* @return a bitmask of the capabilities
* */
enum alpm_caps SYMEXPORT alpm_capabilities(void)
int SYMEXPORT alpm_capabilities(void)
{
return 0
#ifdef ENABLE_NLS
@@ -154,5 +166,3 @@ enum alpm_caps SYMEXPORT alpm_capabilities(void)
#endif
| 0;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* alpm.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -20,8 +20,8 @@
* 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 _ALPM_H
#define _ALPM_H
#ifndef ALPM_H
#define ALPM_H
#ifdef __cplusplus
extern "C" {
@@ -53,7 +53,8 @@ typedef struct __alpm_trans_t alpm_trans_t;
* @{
*/
typedef enum _alpm_errno_t {
ALPM_ERR_MEMORY = 1,
ALPM_ERR_OK = 0,
ALPM_ERR_MEMORY,
ALPM_ERR_SYSTEM,
ALPM_ERR_BADPERMS,
ALPM_ERR_NOT_A_FILE,
@@ -87,6 +88,7 @@ typedef enum _alpm_errno_t {
ALPM_ERR_TRANS_ABORT,
ALPM_ERR_TRANS_TYPE,
ALPM_ERR_TRANS_NOT_LOCKED,
ALPM_ERR_TRANS_HOOK_FAILED,
/* Packages */
ALPM_ERR_PKG_NOT_FOUND,
ALPM_ERR_PKG_IGNORED,
@@ -202,10 +204,7 @@ typedef enum _alpm_siglevel_t {
ALPM_SIG_DATABASE_MARGINAL_OK = (1 << 12),
ALPM_SIG_DATABASE_UNKNOWN_OK = (1 << 13),
ALPM_SIG_PACKAGE_SET = (1 << 27),
ALPM_SIG_PACKAGE_TRUST_SET = (1 << 28),
ALPM_SIG_USE_DEFAULT = (1 << 31)
ALPM_SIG_USE_DEFAULT = (1 << 30)
} alpm_siglevel_t;
/** PGP signature verification status return codes */
@@ -339,6 +338,16 @@ typedef struct _alpm_siglist_t {
alpm_sigresult_t *results;
} alpm_siglist_t;
/*
* Hooks
*/
typedef enum _alpm_hook_when_t {
ALPM_HOOK_PRE_TRANSACTION = 1,
ALPM_HOOK_POST_TRANSACTION
} alpm_hook_when_t;
/*
* Logging facilities
*/
@@ -376,6 +385,10 @@ typedef enum _alpm_event_type_t {
ALPM_EVENT_INTERCONFLICTS_START,
/** Inter-conflicts were checked for target package. */
ALPM_EVENT_INTERCONFLICTS_DONE,
/** Processing the package transaction is starting. */
ALPM_EVENT_TRANSACTION_START,
/** Processing the package transaction is finished. */
ALPM_EVENT_TRANSACTION_DONE,
/** Package will be installed/upgraded/downgraded/re-installed/removed; See
* alpm_event_package_operation_t for arguments. */
ALPM_EVENT_PACKAGE_OPERATION_START,
@@ -446,9 +459,14 @@ typedef enum _alpm_event_type_t {
/** A .pacsave file was created; See alpm_event_pacsave_created_t for
* arguments */
ALPM_EVENT_PACSAVE_CREATED,
/** A .pacorig file was created; See alpm_event_pacorig_created_t for
* arguments */
ALPM_EVENT_PACORIG_CREATED
/** Processing hooks will be started. */
ALPM_EVENT_HOOK_START,
/** Processing hooks is finished. */
ALPM_EVENT_HOOK_DONE,
/** A hook is starting */
ALPM_EVENT_HOOK_RUN_START,
/** A hook has finished running */
ALPM_EVENT_HOOK_RUN_DONE
} alpm_event_type_t;
typedef struct _alpm_event_any_t {
@@ -539,14 +557,25 @@ typedef struct _alpm_event_pacsave_created_t {
const char *file;
} alpm_event_pacsave_created_t;
typedef struct _alpm_event_pacorig_created_t {
/** Type of event. */
typedef struct _alpm_event_hook_t {
/** Type of event.*/
alpm_event_type_t type;
/** New package. */
alpm_pkg_t *newpkg;
/** Filename of the file without the .pacorig suffix. */
const char *file;
} alpm_event_pacorig_created_t;
/** Type of hooks. */
alpm_hook_when_t when;
} alpm_event_hook_t;
typedef struct _alpm_event_hook_run_t {
/** Type of event.*/
alpm_event_type_t type;
/** Name of hook */
const char *name;
/** Description of hook to be outputted */
const char *desc;
/** position of hook being run */
size_t position;
/** total hooks being run */
size_t total;
} alpm_event_hook_run_t;
/** Events.
* This is an union passed to the callback, that allows the frontend to know
@@ -564,7 +593,8 @@ typedef union _alpm_event_t {
alpm_event_pkgdownload_t pkgdownload;
alpm_event_pacnew_created_t pacnew_created;
alpm_event_pacsave_created_t pacsave_created;
alpm_event_pacorig_created_t pacorig_created;
alpm_event_hook_t hook;
alpm_event_hook_run_t hook_run;
} alpm_event_t;
/** Event callback. */
@@ -791,6 +821,20 @@ int alpm_option_add_cachedir(alpm_handle_t *handle, const char *cachedir);
int alpm_option_remove_cachedir(alpm_handle_t *handle, const char *cachedir);
/** @} */
/** @name Accessors to the list of package hook directories.
* @{
*/
alpm_list_t *alpm_option_get_hookdirs(alpm_handle_t *handle);
int alpm_option_set_hookdirs(alpm_handle_t *handle, alpm_list_t *hookdirs);
int alpm_option_add_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. */
const char *alpm_option_get_logfile(alpm_handle_t *handle);
/** Sets the logfile name. */
@@ -875,14 +919,19 @@ int alpm_option_set_deltaratio(alpm_handle_t *handle, double ratio);
int alpm_option_get_checkspace(alpm_handle_t *handle);
int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle);
int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
const char *alpm_option_get_dbext(alpm_handle_t *handle);
int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext);
alpm_siglevel_t alpm_option_get_local_file_siglevel(alpm_handle_t *handle);
int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
int alpm_option_get_default_siglevel(alpm_handle_t *handle);
int alpm_option_set_default_siglevel(alpm_handle_t *handle, int level);
alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle);
int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
int 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_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_disable_dl_timeout(alpm_handle_t *handle, unsigned short disable_dl_timeout);
/** @} */
@@ -915,7 +964,7 @@ alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle);
* @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_siglevel_t level);
int level);
/** Unregister all package databases.
* @param handle the context handle
@@ -941,7 +990,7 @@ const char *alpm_db_get_name(const alpm_db_t *db);
* @param db pointer to the package database
* @return the signature verification level
*/
alpm_siglevel_t alpm_db_get_siglevel(alpm_db_t *db);
int alpm_db_get_siglevel(alpm_db_t *db);
/** Check the validity of a database.
* This is most useful for sync databases and verifying signature status.
@@ -1008,14 +1057,14 @@ typedef enum _alpm_db_usage_ {
* @param usage a bitmask of alpm_db_usage_t values
* @return 0 on success, or -1 on error
*/
int alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage);
int alpm_db_set_usage(alpm_db_t *db, int usage);
/** Gets the usage of a database.
* @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
* @return 0 on success, or -1 on error
*/
int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
int alpm_db_get_usage(alpm_db_t *db, int *usage);
/** @} */
@@ -1039,7 +1088,7 @@ int alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage);
* @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,
alpm_siglevel_t level, alpm_pkg_t **pkg);
int level, alpm_pkg_t **pkg);
/** Find a package in a list by name.
* @param haystack a list of alpm_pkg_t
@@ -1101,6 +1150,12 @@ int alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg);
*/
const char *alpm_pkg_get_filename(alpm_pkg_t *pkg);
/** Returns the package base name.
* @param pkg a pointer to package
* @return a reference to an internal string
*/
const char *alpm_pkg_get_base(alpm_pkg_t *pkg);
/** Returns the package name.
* @param pkg a pointer to package
* @return a reference to an internal string
@@ -1213,6 +1268,18 @@ alpm_list_t *alpm_pkg_get_depends(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.
* @param pkg a pointer to package
* @return a reference to an internal list of alpm_depend_t structures.
@@ -1270,7 +1337,7 @@ const char *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg);
* @param pkg a pointer to package
* @return an enum member giving the validation method
*/
alpm_pkgvalidation_t alpm_pkg_get_validation(alpm_pkg_t *pkg);
int alpm_pkg_get_validation(alpm_pkg_t *pkg);
/* End of alpm_pkg_t accessors */
/* @} */
@@ -1432,7 +1499,7 @@ typedef enum _alpm_transflag_t {
* @param handle the context handle
* @return the bitfield of transaction flags
*/
alpm_transflag_t alpm_trans_get_flags(alpm_handle_t *handle);
int alpm_trans_get_flags(alpm_handle_t *handle);
/** Returns a list of packages added by the transaction.
* @param handle the context handle
@@ -1448,10 +1515,10 @@ alpm_list_t *alpm_trans_get_remove(alpm_handle_t *handle);
/** Initialize the transaction.
* @param handle the context handle
* @param flags flags of the transaction (like nodeps, etc)
* @param flags flags of the transaction (like nodeps, etc; see alpm_transflag_t)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int alpm_trans_init(alpm_handle_t *handle, alpm_transflag_t flags);
int alpm_trans_init(alpm_handle_t *handle, int flags);
/** Prepare a transaction.
* @param handle the context handle
@@ -1556,6 +1623,7 @@ char *alpm_compute_sha256sum(const char *filename);
alpm_handle_t *alpm_initialize(const char *root, const char *dbpath,
alpm_errno_t *err);
int alpm_release(alpm_handle_t *handle);
int alpm_unlock(alpm_handle_t *handle);
enum alpm_caps {
ALPM_CAPABILITY_NLS = (1 << 0),
@@ -1564,7 +1632,8 @@ enum alpm_caps {
};
const char *alpm_version(void);
enum alpm_caps alpm_capabilities(void);
/* Return a bitfield of capabilities using values from 'enum alpm_caps' */
int alpm_capabilities(void);
void alpm_fileconflict_free(alpm_fileconflict_t *conflict);
void alpm_depmissing_free(alpm_depmissing_t *miss);
@@ -1576,6 +1645,4 @@ void alpm_conflict_free(alpm_conflict_t *conflict);
#ifdef __cplusplus
}
#endif
#endif /* _ALPM_H */
/* vim: set noet: */
#endif /* ALPM_H */

View File

@@ -1,7 +1,7 @@
/*
* alpm_list.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -93,28 +93,62 @@ void SYMEXPORT alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn)
*/
alpm_list_t SYMEXPORT *alpm_list_add(alpm_list_t *list, void *data)
{
alpm_list_t *ptr, *lp;
alpm_list_append(&list, data);
return list;
}
/**
* @brief Add a new item to the end of the list.
*
* @param list the list to add to
* @param data the new item to be added to the list
*
* @return the newly added item
*/
alpm_list_t SYMEXPORT *alpm_list_append(alpm_list_t **list, void *data)
{
alpm_list_t *ptr;
ptr = malloc(sizeof(alpm_list_t));
if(ptr == NULL) {
return list;
return NULL;
}
ptr->data = data;
ptr->next = NULL;
/* Special case: the input list is empty */
if(list == NULL) {
if(*list == NULL) {
*list = ptr;
ptr->prev = ptr;
return ptr;
} else {
alpm_list_t *lp = alpm_list_last(*list);
lp->next = ptr;
ptr->prev = lp;
(*list)->prev = ptr;
}
lp = alpm_list_last(list);
lp->next = ptr;
ptr->prev = lp;
list->prev = ptr;
return ptr;
}
return list;
/**
* @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;
}
}
/**
@@ -427,7 +461,10 @@ alpm_list_t SYMEXPORT *alpm_list_remove_dupes(const alpm_list_t *list)
alpm_list_t *newlist = NULL;
while(lp) {
if(!alpm_list_find_ptr(newlist, lp->data)) {
newlist = alpm_list_add(newlist, lp->data);
if(alpm_list_append(&newlist, lp->data) == NULL) {
alpm_list_free(newlist);
return NULL;
}
}
lp = lp->next;
}
@@ -446,7 +483,10 @@ alpm_list_t SYMEXPORT *alpm_list_strdup(const alpm_list_t *list)
const alpm_list_t *lp = list;
alpm_list_t *newlist = NULL;
while(lp) {
newlist = alpm_list_add(newlist, strdup(lp->data));
if(alpm_list_append_strdup(&newlist, lp->data) == NULL) {
FREELIST(newlist);
return NULL;
}
lp = lp->next;
}
return newlist;
@@ -464,7 +504,10 @@ alpm_list_t SYMEXPORT *alpm_list_copy(const alpm_list_t *list)
const alpm_list_t *lp = list;
alpm_list_t *newlist = NULL;
while(lp) {
newlist = alpm_list_add(newlist, lp->data);
if(alpm_list_append(&newlist, lp->data) == NULL) {
alpm_list_free(newlist);
return NULL;
}
lp = lp->next;
}
return newlist;
@@ -489,8 +532,15 @@ alpm_list_t SYMEXPORT *alpm_list_copy_data(const alpm_list_t *list,
void *newdata = malloc(size);
if(newdata) {
memcpy(newdata, lp->data, size);
newlist = alpm_list_add(newlist, newdata);
if(alpm_list_append(&newlist, newdata) == NULL) {
free(newdata);
FREELIST(newlist);
return NULL;
}
lp = lp->next;
} else {
FREELIST(newlist);
return NULL;
}
}
return newlist;
@@ -518,7 +568,10 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
list->prev = NULL;
while(lp) {
newlist = alpm_list_add(newlist, lp->data);
if(alpm_list_append(&newlist, lp->data) == NULL) {
alpm_list_free(newlist);
return NULL;
}
lp = lp->prev;
}
list->prev = backup; /* restore tail pointer */
@@ -789,5 +842,3 @@ 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
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_LIST_H
#define _ALPM_LIST_H
#ifndef ALPM_LIST_H
#define ALPM_LIST_H
#include <stdlib.h> /* size_t */
@@ -57,6 +57,8 @@ void alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn);
/* item mutators */
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_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_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);
@@ -89,6 +91,4 @@ void *alpm_list_to_array(const alpm_list_t *list, size_t n, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* _ALPM_LIST_H */
/* vim: set noet: */
#endif /* ALPM_LIST_H */

View File

@@ -1,7 +1,7 @@
/*
* backup.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -47,8 +47,8 @@ int _alpm_split_backup(const char *string, alpm_backup_t **backup)
*ptr = '\0';
ptr++;
/* now str points to the filename and ptr points to the hash */
STRDUP((*backup)->name, str, return -1);
STRDUP((*backup)->hash, ptr, return -1);
STRDUP((*backup)->name, str, FREE(str); return -1);
STRDUP((*backup)->hash, ptr, FREE((*backup)->name); FREE(str); return -1);
FREE(str);
return 0;
}
@@ -77,9 +77,10 @@ alpm_backup_t *_alpm_needbackup(const char *file, alpm_pkg_t *pkg)
void _alpm_backup_free(alpm_backup_t *backup)
{
free(backup->name);
free(backup->hash);
free(backup);
ASSERT(backup != NULL, return);
FREE(backup->name);
FREE(backup->hash);
FREE(backup);
}
alpm_backup_t *_alpm_backup_dup(const alpm_backup_t *backup)
@@ -97,5 +98,3 @@ error:
free(newbackup);
return NULL;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* backup.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_BACKUP_H
#define _ALPM_BACKUP_H
#ifndef ALPM_BACKUP_H
#define ALPM_BACKUP_H
#include "alpm_list.h"
#include "alpm.h"
@@ -28,6 +28,4 @@ alpm_backup_t *_alpm_needbackup(const char *file, alpm_pkg_t *pkg);
void _alpm_backup_free(alpm_backup_t *backup);
alpm_backup_t *_alpm_backup_dup(const alpm_backup_t *backup);
#endif /* _ALPM_BACKUP_H */
/* vim: set noet: */
#endif /* ALPM_BACKUP_H */

View File

@@ -22,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _BASE64_H
#define _BASE64_H
#ifndef BASE64_H
#define BASE64_H
#include <string.h>

View File

@@ -1,7 +1,7 @@
/*
* be_local.c : backend for the local database
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -47,9 +47,9 @@
/* local database format version */
size_t ALPM_LOCAL_DB_VERSION = 9;
static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
static int local_db_read(alpm_pkg_t *info, int inforeq);
#define LAZY_LOAD(info, errret) \
#define LAZY_LOAD(info) \
do { \
if(!(pkg->infolevel & info)) { \
local_db_read(pkg, info); \
@@ -63,117 +63,123 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq);
* initialized.
*/
static const char *_cache_get_base(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC);
return pkg->base;
}
static const char *_cache_get_desc(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->desc;
}
static const char *_cache_get_url(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->url;
}
static alpm_time_t _cache_get_builddate(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, 0);
LAZY_LOAD(INFRQ_DESC);
return pkg->builddate;
}
static alpm_time_t _cache_get_installdate(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, 0);
LAZY_LOAD(INFRQ_DESC);
return pkg->installdate;
}
static const char *_cache_get_packager(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->packager;
}
static const char *_cache_get_arch(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->arch;
}
static off_t _cache_get_isize(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, -1);
LAZY_LOAD(INFRQ_DESC);
return pkg->isize;
}
static alpm_pkgreason_t _cache_get_reason(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, -1);
LAZY_LOAD(INFRQ_DESC);
return pkg->reason;
}
static alpm_pkgvalidation_t _cache_get_validation(alpm_pkg_t *pkg)
static int _cache_get_validation(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, -1);
LAZY_LOAD(INFRQ_DESC);
return pkg->validation;
}
static alpm_list_t *_cache_get_licenses(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->licenses;
}
static alpm_list_t *_cache_get_groups(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->groups;
}
static int _cache_has_scriptlet(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_SCRIPTLET, NULL);
LAZY_LOAD(INFRQ_SCRIPTLET);
return pkg->scriptlet;
}
static alpm_list_t *_cache_get_depends(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->depends;
}
static alpm_list_t *_cache_get_optdepends(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->optdepends;
}
static alpm_list_t *_cache_get_conflicts(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->conflicts;
}
static alpm_list_t *_cache_get_provides(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->provides;
}
static alpm_list_t *_cache_get_replaces(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
LAZY_LOAD(INFRQ_DESC);
return pkg->replaces;
}
static alpm_filelist_t *_cache_get_files(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_FILES, NULL);
LAZY_LOAD(INFRQ_FILES);
return &(pkg->files);
}
static alpm_list_t *_cache_get_backup(alpm_pkg_t *pkg)
{
LAZY_LOAD(INFRQ_FILES, NULL);
LAZY_LOAD(INFRQ_FILES);
return pkg->backup;
}
@@ -297,6 +303,7 @@ static int _cache_force_load(alpm_pkg_t *pkg)
* logic.
*/
static struct pkg_operations local_pkg_ops = {
.get_base = _cache_get_base,
.get_desc = _cache_get_desc,
.get_url = _cache_get_url,
.get_builddate = _cache_get_builddate,
@@ -377,6 +384,11 @@ static int local_db_add_version(alpm_db_t UNUSED *db, const char *dbpath)
snprintf(dbverpath, PATH_MAX, "%sALPM_DB_VERSION", dbpath);
dbverfile = fopen(dbverpath, "w");
if(dbverfile == NULL) {
return 1;
}
fprintf(dbverfile, "%zu\n", ALPM_LOCAL_DB_VERSION);
fclose(dbverfile);
@@ -390,7 +402,10 @@ static int local_db_create(alpm_db_t *db, const char *dbpath)
dbpath, strerror(errno));
RET_ERR(db->handle, ALPM_ERR_DB_CREATE, -1);
}
local_db_add_version(db, dbpath);
if(local_db_add_version(db, dbpath) != 0) {
return 1;
}
return 0;
}
@@ -452,7 +467,9 @@ static int local_db_validate(alpm_db_t *db)
}
}
local_db_add_version(db, dbpath);
if(local_db_add_version(db, dbpath) != 0) {
goto version_error;
}
goto version_latest;
}
@@ -484,7 +501,7 @@ version_error:
static int local_db_populate(alpm_db_t *db)
{
size_t est_count;
int count = 0;
size_t count = 0;
struct stat buf;
struct dirent *ent = NULL;
const char *dbpath;
@@ -584,18 +601,21 @@ static int local_db_populate(alpm_db_t *db)
/* add to the collection */
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename);
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
if(_alpm_pkghash_add(&db->pkgcache, pkg) == NULL) {
_alpm_pkg_free(pkg);
RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
}
count++;
}
closedir(dbdir);
if(count > 0) {
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, (size_t)count, _alpm_pkg_cmp);
db->pkgcache->list = alpm_list_msort(db->pkgcache->list, count, _alpm_pkg_cmp);
}
_alpm_log(db->handle, ALPM_LOG_DEBUG, "added %d packages to package cache for db '%s'\n",
_alpm_log(db->handle, ALPM_LOG_DEBUG, "added %zu packages to package cache for db '%s'\n",
count, db->treename);
return count;
return 0;
}
/* Note: the return value must be freed by the caller */
@@ -643,7 +663,7 @@ char *_alpm_local_db_pkgpath(alpm_db_t *db, alpm_pkg_t *info,
f = alpm_list_add(f, alpm_dep_from_string(line)); \
} while(1) /* note the while(1) and not (0) */
static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
static int local_db_read(alpm_pkg_t *info, int inforeq)
{
FILE *fp = NULL;
char line[1024];
@@ -701,6 +721,8 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
_alpm_log(db->handle, ALPM_LOG_ERROR, _("%s database is inconsistent: version "
"mismatch on package %s\n"), db->treename, info->name);
}
} else if(strcmp(line, "%BASE%") == 0) {
READ_AND_STORE(info->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(info->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -781,26 +803,42 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
(len = _alpm_strip_newline(line, 0))) {
if(!_alpm_greedy_grow((void **)&files, &files_size,
(files_count ? (files_count + 1) * sizeof(alpm_file_t) : 8 * sizeof(alpm_file_t)))) {
goto error;
goto nomem;
}
/* since we know the length of the file string already,
* we can do malloc + memcpy rather than strdup */
len += 1;
MALLOC(files[files_count].name, len, goto error);
MALLOC(files[files_count].name, len, goto nomem);
memcpy(files[files_count].name, line, len);
files_count++;
}
/* attempt to hand back any memory we don't need */
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);
if(files_count > 0) {
alpm_file_t *newfiles;
newfiles = realloc(files, sizeof(alpm_file_t) * files_count);
if(newfiles != NULL) {
files = newfiles;
}
} else {
FREE(files);
}
info->files.count = files_count;
info->files.files = files;
_alpm_filelist_sort(&info->files);
continue;
nomem:
while(files_count > 0) {
FREE(files[--files_count].name);
}
FREE(files);
goto error;
} else if(strcmp(line, "%BACKUP%") == 0) {
while(safe_fgets(line, sizeof(line), fp) && _alpm_strip_newline(line, 0)) {
alpm_backup_t *backup;
CALLOC(backup, 1, sizeof(alpm_backup_t), goto error);
if(_alpm_split_backup(line, &backup)) {
FREE(backup);
goto error;
}
info->backup = alpm_list_add(info->backup, backup);
@@ -873,7 +911,7 @@ static void write_deps(FILE *fp, const char *header, alpm_list_t *deplist)
fputc('\n', fp);
}
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq)
{
FILE *fp = NULL;
mode_t oldmask;
@@ -904,6 +942,10 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
free(path);
fprintf(fp, "%%NAME%%\n%s\n\n"
"%%VERSION%%\n%s\n\n", info->name, info->version);
if(info->base) {
fprintf(fp, "%%BASE%%\n"
"%s\n\n", info->base);
}
if(info->desc) {
fprintf(fp, "%%DESC%%\n"
"%s\n\n", info->desc);
@@ -1022,11 +1064,6 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
cleanup:
umask(oldmask);
if(fp) {
fclose(fp);
}
return retval;
}
@@ -1129,5 +1166,3 @@ alpm_db_t *_alpm_db_register_local(alpm_handle_t *handle)
handle->db_local = db;
return db;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* be_package.c : backend for packages
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
/* libarchive */
#include <archive.h>
@@ -193,7 +194,7 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
STRDUP(newpkg->name, ptr, return -1);
newpkg->name_hash = _alpm_hash_sdbm(newpkg->name);
} else if(strcmp(key, "pkgbase") == 0) {
/* not used atm */
STRDUP(newpkg->base, ptr, return -1);
} else if(strcmp(key, "pkgver") == 0) {
STRDUP(newpkg->version, ptr, return -1);
} else if(strcmp(key, "basever") == 0) {
@@ -222,9 +223,11 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
alpm_depend_t *optdep = alpm_dep_from_string(ptr);
newpkg->optdepends = alpm_list_add(newpkg->optdepends, optdep);
} else if(strcmp(key, "makedepend") == 0) {
/* not used atm */
alpm_depend_t *makedep = alpm_dep_from_string(ptr);
newpkg->makedepends = alpm_list_add(newpkg->makedepends, makedep);
} else if(strcmp(key, "checkdepend") == 0) {
/* not used atm */
alpm_depend_t *checkdep = alpm_dep_from_string(ptr);
newpkg->checkdepends = alpm_list_add(newpkg->checkdepends, checkdep);
} else if(strcmp(key, "conflict") == 0) {
alpm_depend_t *conflict = alpm_dep_from_string(ptr);
newpkg->conflicts = alpm_list_add(newpkg->conflicts, conflict);
@@ -237,7 +240,7 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
} else if(strcmp(key, "backup") == 0) {
alpm_backup_t *backup;
CALLOC(backup, 1, sizeof(alpm_backup_t), return -1);
STRDUP(backup->name, ptr, return -1);
STRDUP(backup->name, ptr, FREE(backup); return -1);
newpkg->backup = alpm_list_add(newpkg->backup, backup);
} else if(strcmp(key, "force") == 0) {
/* deprecated, skip it */
@@ -269,11 +272,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
*/
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation)
const char *pkgfile, alpm_pkg_t *syncpkg, int level,
alpm_siglist_t **sigdata, int *validation)
{
int has_sig;
handle->pm_errno = 0;
handle->pm_errno = ALPM_ERR_OK;
if(pkgfile == NULL || strlen(pkgfile) == 0) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1);
@@ -356,7 +359,7 @@ int _alpm_pkg_validate_internal(alpm_handle_t *handle,
}
/**
* Handle the existance of simple paths for _alpm_load_pkg_internal()
* Handle the existence of simple paths for _alpm_load_pkg_internal()
* @param pkg package to change
* @param path path to examine
* @return 0 if path doesn't match any rule, 1 if it has been handled
@@ -384,15 +387,16 @@ static int handle_simple_path(alpm_pkg_t *pkg, const char *path)
* @param path path of the file to be added
* @return <0 on error, 0 on success
*/
static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size,
struct archive_entry *entry, const char *path)
static int add_entry_to_files_list(alpm_filelist_t *filelist,
size_t *files_size, struct archive_entry *entry, const char *path)
{
const size_t files_count = pkg->files.count;
const size_t files_count = filelist->count;
alpm_file_t *current_file;
mode_t type;
size_t pathlen;
if(!_alpm_greedy_grow((void **)&pkg->files.files, files_size, (files_count + 1) * sizeof(alpm_file_t))) {
if(!_alpm_greedy_grow((void **)&filelist->files,
files_size, (files_count + 1) * sizeof(alpm_file_t))) {
return -1;
}
@@ -400,7 +404,7 @@ static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size,
pathlen = strlen(path);
current_file = pkg->files.files + files_count;
current_file = filelist->files + files_count;
/* mtree paths don't contain a tailing slash, those we get from
* the archive directly do (expensive way)
@@ -418,7 +422,7 @@ static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size,
}
current_file->size = archive_entry_size(entry);
current_file->mode = archive_entry_mode(entry);
pkg->files.count++;
filelist->count++;
return 0;
}
@@ -437,23 +441,19 @@ static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size,
static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, struct archive *archive)
{
int ret = 0;
size_t i;
size_t mtree_maxsize = 0;
size_t mtree_cursize = 0;
size_t files_size = 0; /* we clean up the existing array so this is fine */
char *mtree_data = NULL;
struct archive *mtree;
struct archive_entry *mtree_entry = NULL;
alpm_filelist_t filelist;
_alpm_log(handle, ALPM_LOG_DEBUG,
"found mtree for package %s, getting file list\n", pkg->filename);
/* throw away any files we might have already found */
for (size_t i = 0; i < pkg->files.count; i++) {
free(pkg->files.files[i].name);
}
free(pkg->files.files);
pkg->files.files = NULL;
pkg->files.count = 0;
memset(&filelist, 0, sizeof(alpm_filelist_t));
/* create a new archive to parse the mtree and load it from archive into memory */
/* TODO: split this into a function */
@@ -476,7 +476,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
size = archive_read_data(archive, mtree_data + mtree_cursize, ALPM_BUFFER_SIZE);
if(size < 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("error while reading package %s: %s\n"),
_alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading package %s: %s\n"),
pkg->filename, archive_error_string(archive));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
@@ -489,7 +489,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
}
if(archive_read_open_memory(mtree, mtree_data, mtree_cursize)) {
_alpm_log(handle, ALPM_LOG_ERROR,
_alpm_log(handle, ALPM_LOG_DEBUG,
_("error while reading mtree of package %s: %s\n"),
pkg->filename, archive_error_string(mtree));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
@@ -508,23 +508,38 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str
continue;
}
if(add_entry_to_files_list(pkg, &files_size, mtree_entry, path) < 0) {
if(add_entry_to_files_list(&filelist, &files_size, mtree_entry, path) < 0) {
goto error;
}
}
if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occurred */
_alpm_log(handle, ALPM_LOG_ERROR, _("error while reading mtree of package %s: %s\n"),
_alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading mtree of package %s: %s\n"),
pkg->filename, archive_error_string(mtree));
handle->pm_errno = ALPM_ERR_LIBARCHIVE;
goto error;
}
/* throw away any files we loaded directly from the archive */
for(i = 0; i < pkg->files.count; i++) {
free(pkg->files.files[i].name);
}
free(pkg->files.files);
/* copy over new filelist */
memcpy(&pkg->files, &filelist, sizeof(alpm_filelist_t));
free(mtree_data);
_alpm_archive_read_free(mtree);
_alpm_log(handle, ALPM_LOG_DEBUG, "finished mtree reading for %s\n", pkg->filename);
return 0;
error:
/* throw away any files we loaded from the mtree */
for(i = 0; i < filelist.count; i++) {
free(filelist.files[i].name);
}
free(filelist.files);
free(mtree_data);
_alpm_archive_read_free(mtree);
return -1;
@@ -607,16 +622,13 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
/* building the file list: cheap way
* get the filelist from the mtree file rather than scanning
* the whole archive */
if(build_filelist_from_mtree(handle, newpkg, archive) < 0) {
goto error;
}
hit_mtree = 1;
hit_mtree = build_filelist_from_mtree(handle, newpkg, archive) == 0;
continue;
} else if(handle_simple_path(newpkg, entry_name)) {
continue;
} else if(full && !hit_mtree) {
/* building the file list: expensive way */
if(add_entry_to_files_list(newpkg, &files_size, entry, entry_name) < 0) {
if(add_entry_to_files_list(&newpkg->files, &files_size, entry, entry_name) < 0) {
goto error;
}
}
@@ -666,8 +678,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG,
"sorting package filelist for %s\n", pkgfile);
qsort(newpkg->files.files, newpkg->files.count,
sizeof(alpm_file_t), _alpm_files_cmp);
_alpm_filelist_sort(&newpkg->files);
}
newpkg->infolevel |= INFRQ_FILES;
}
@@ -686,22 +697,25 @@ error:
return NULL;
}
/* adopted limit from repo-add */
#define MAX_SIGFILE_SIZE 16384
static int read_sigfile(const char *sigpath, unsigned char **sig)
{
struct stat st;
FILE *fp;
if(stat(sigpath, &st) != 0) {
return -1;
}
MALLOC(*sig, st.st_size, return -1);
if((fp = fopen(sigpath, "rb")) == NULL) {
free(*sig);
return -1;
}
if(fstat(fileno(fp), &st) != 0 || st.st_size > MAX_SIGFILE_SIZE) {
fclose(fp);
return -1;
}
MALLOC(*sig, st.st_size, fclose(fp); return -1);
if(fread(*sig, st.st_size, 1, fp) != 1) {
free(*sig);
fclose(fp);
@@ -713,9 +727,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,
alpm_siglevel_t level, alpm_pkg_t **pkg)
int level, alpm_pkg_t **pkg)
{
alpm_pkgvalidation_t validation = 0;
int validation = 0;
char *sigpath;
CHECK_HANDLE(handle, return -1);
@@ -753,6 +767,7 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
if(fail) {
_alpm_log(handle, ALPM_LOG_ERROR, _("required key missing from keyring\n"));
free(sigpath);
return -1;
}
}
@@ -773,5 +788,3 @@ int SYMEXPORT alpm_pkg_load(alpm_handle_t *handle, const char *filename, int ful
return 0;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* be_sync.c : backend for sync databases
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -40,6 +40,7 @@
#include "delta.h"
#include "deps.h"
#include "dload.h"
#include "filelist.h"
static char *get_sync_dir(alpm_handle_t *handle)
{
@@ -70,7 +71,7 @@ static char *get_sync_dir(alpm_handle_t *handle)
static int sync_db_validate(alpm_db_t *db)
{
alpm_siglevel_t level;
int siglevel;
const char *dbpath;
if(db->status & DB_STATUS_VALID || db->status & DB_STATUS_MISSING) {
@@ -103,20 +104,20 @@ static int sync_db_validate(alpm_db_t *db)
/* this takes into account the default verification level if UNKNOWN
* was assigned to this db */
level = alpm_db_get_siglevel(db);
siglevel = alpm_db_get_siglevel(db);
if(level & ALPM_SIG_DATABASE) {
if(siglevel & ALPM_SIG_DATABASE) {
int retry, ret;
do {
retry = 0;
alpm_siglist_t *siglist;
ret = _alpm_check_pgp_helper(db->handle, dbpath, NULL,
level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK,
level & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist);
siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK,
siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK, &siglist);
if(ret) {
retry = _alpm_process_siglist(db->handle, db->treename, siglist,
level & ALPM_SIG_DATABASE_OPTIONAL, level & ALPM_SIG_DATABASE_MARGINAL_OK,
level & ALPM_SIG_DATABASE_UNKNOWN_OK);
siglevel & ALPM_SIG_DATABASE_OPTIONAL, siglevel & ALPM_SIG_DATABASE_MARGINAL_OK,
siglevel & ALPM_SIG_DATABASE_UNKNOWN_OK);
}
alpm_siglist_cleanup(siglist);
free(siglist);
@@ -174,16 +175,18 @@ valid:
int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
{
char *syncpath;
const char *dbext;
alpm_list_t *i;
int updated = 0;
int ret = -1;
mode_t oldmask;
alpm_handle_t *handle;
alpm_siglevel_t level;
int siglevel;
/* Sanity checks */
ASSERT(db != NULL, return -1);
handle = db->handle;
handle->pm_errno = 0;
handle->pm_errno = ALPM_ERR_OK;
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));
@@ -196,10 +199,15 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
return -1;
}
/* force update of invalid databases to fix potential mismatched database/signature */
if(db->status & DB_STATUS_INVALID) {
force = 1;
}
/* make sure we have a sane umask */
oldmask = umask(0022);
level = alpm_db_get_siglevel(db);
siglevel = alpm_db_get_siglevel(db);
/* attempt to grab a lock */
if(_alpm_handle_lock(handle)) {
@@ -208,6 +216,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
RET_ERR(handle, ALPM_ERR_HANDLE_LOCK, -1);
}
dbext = db->handle->dbext;
for(i = db->servers; i; i = i->next) {
const char *server = i->data, *final_db_url = NULL;
struct dload_payload payload;
@@ -220,18 +230,24 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.max_size = 25 * 1024 * 1024;
/* print server + filename into a buffer */
len = strlen(server) + strlen(db->treename) + 5;
/* TODO fix leak syncpath and umask unset */
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
snprintf(payload.fileurl, len, "%s/%s.db", server, db->treename);
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2;
MALLOC(payload.fileurl, len,
{
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
);
snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext);
payload.handle = handle;
payload.force = force;
payload.unlink_on_fail = 1;
ret = _alpm_download(&payload, syncpath, NULL, &final_db_url);
_alpm_dload_payload_reset(&payload);
updated = (updated || ret == 0);
if(ret == 0 && (level & ALPM_SIG_DATABASE)) {
if(ret != -1 && updated && (siglevel & ALPM_SIG_DATABASE)) {
/* an existing sig file is no good at this point */
char *sigpath = _alpm_sigpath(handle, _alpm_db_path(db));
if(!sigpath) {
@@ -241,28 +257,42 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
unlink(sigpath);
free(sigpath);
/* if we downloaded a DB, we want the .sig from the same server -
this information is only available from the internal downloader */
if(handle->fetchcb == NULL) {
/* check if the final URL from internal downloader looks reasonable */
if(final_db_url != NULL) {
if(strlen(final_db_url) < 3
|| strcmp(final_db_url + strlen(final_db_url) - strlen(dbext),
dbext) != 0) {
final_db_url = NULL;
}
}
/* if we downloaded a DB, we want the .sig from the same server */
if(final_db_url != NULL) {
/* print final_db_url into a buffer (leave space for .sig) */
len = strlen(final_db_url) + 5;
} else {
/* print server + filename into a buffer (leave space for .sig) */
len = strlen(server) + strlen(db->treename) + 9;
/* print server + filename into a buffer (leave space for separator and .sig) */
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6;
}
/* TODO fix leak syncpath and umask unset */
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
MALLOC(payload.fileurl, len,
{
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
);
if(handle->fetchcb == NULL) {
if(final_db_url != NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url);
} else {
snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
snprintf(payload.fileurl, len, "%s/%s%s.sig", server, db->treename, dbext);
}
payload.handle = handle;
payload.force = 1;
payload.errors_ok = (level & ALPM_SIG_DATABASE_OPTIONAL);
payload.errors_ok = (siglevel & ALPM_SIG_DATABASE_OPTIONAL);
/* set hard upper limit of 16KiB */
payload.max_size = 16 * 1024;
@@ -278,32 +308,31 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
}
}
if(ret == 1) {
/* files match, do nothing */
handle->pm_errno = 0;
goto cleanup;
} else if(ret == -1) {
if(updated) {
/* Cache needs to be rebuilt */
_alpm_db_free_pkgcache(db);
/* clear all status flags regarding validity/existence */
db->status &= ~DB_STATUS_VALID;
db->status &= ~DB_STATUS_INVALID;
db->status &= ~DB_STATUS_EXISTS;
db->status &= ~DB_STATUS_MISSING;
/* if the download failed skip validation to preserve the download error */
if(ret != -1 && sync_db_validate(db) != 0) {
/* pm_errno should be set */
ret = -1;
}
}
if(ret == -1) {
/* pm_errno was set by the download code */
_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
alpm_strerror(handle->pm_errno));
goto cleanup;
} else {
handle->pm_errno = ALPM_ERR_OK;
}
/* Cache needs to be rebuilt */
_alpm_db_free_pkgcache(db);
/* clear all status flags regarding validity/existence */
db->status &= ~DB_STATUS_VALID;
db->status &= ~DB_STATUS_INVALID;
db->status &= ~DB_STATUS_EXISTS;
db->status &= ~DB_STATUS_MISSING;
if(sync_db_validate(db)) {
/* pm_errno should be set */
ret = -1;
}
cleanup:
_alpm_handle_unlock(handle);
free(syncpath);
umask(oldmask);
@@ -314,7 +343,7 @@ cleanup:
static int sync_db_read(alpm_db_t *db, struct archive *archive,
struct archive_entry *entry, alpm_pkg_t **likely_pkg);
static alpm_pkgvalidation_t _sync_get_validation(alpm_pkg_t *pkg)
static int _sync_get_validation(alpm_pkg_t *pkg)
{
if(pkg->validation) {
return pkg->validation;
@@ -384,7 +413,10 @@ static alpm_pkg_t *load_pkg_for_entry(alpm_db_t *db, const char *entryname,
/* add to the collection */
_alpm_log(db->handle, ALPM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename);
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
if(_alpm_pkghash_add(&db->pkgcache, pkg) == NULL) {
_alpm_pkg_free(pkg);
RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL);
}
} else {
free(pkgname);
free(pkgver);
@@ -426,14 +458,17 @@ static size_t estimate_package_count(struct stat *st, struct archive *archive)
/* assume it is at least somewhat compressed */
per_package = 500;
}
return (size_t)((st->st_size / per_package) + 1);
}
static int sync_db_populate(alpm_db_t *db)
{
const char *dbpath;
size_t est_count;
int count, fd;
size_t est_count, count;
int fd;
int ret = 0;
int archive_ret;
struct stat buf;
struct archive *archive;
struct archive_entry *entry;
@@ -454,39 +489,53 @@ static int sync_db_populate(alpm_db_t *db)
fd = _alpm_open_archive(db->handle, dbpath, &buf,
&archive, ALPM_ERR_DB_OPEN);
if(fd < 0) {
db->status &= ~DB_STATUS_VALID;
db->status |= DB_STATUS_INVALID;
return -1;
}
est_count = estimate_package_count(&buf, archive);
/* currently only .files dbs contain file lists - make flexible when required*/
if(strcmp(db->handle->dbext, ".files") == 0) {
/* files databases are about four times larger on average */
est_count /= 4;
}
db->pkgcache = _alpm_pkghash_create(est_count);
if(db->pkgcache == NULL) {
db->handle->pm_errno = ALPM_ERR_MEMORY;
count = -1;
ret = -1;
goto cleanup;
}
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
while((archive_ret = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) {
mode_t mode = archive_entry_mode(entry);
if(S_ISDIR(mode)) {
continue;
} else {
if(!S_ISDIR(mode)) {
/* we have desc, depends or deltas - parse it */
if(sync_db_read(db, archive, entry, &pkg) != 0) {
_alpm_log(db->handle, ALPM_LOG_ERROR,
_("could not parse package description file '%s' from db '%s'\n"),
archive_entry_pathname(entry), db->treename);
continue;
ret = -1;
}
}
}
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);
if(count > 0) {
db->pkgcache->list = alpm_list_msort(db->pkgcache->list,
(size_t)count, _alpm_pkg_cmp);
count, _alpm_pkg_cmp);
}
_alpm_log(db->handle, ALPM_LOG_DEBUG,
"added %d packages to package cache for db '%s'\n",
"added %zu packages to package cache for db '%s'\n",
count, db->treename);
cleanup:
@@ -494,7 +543,7 @@ cleanup:
if(fd >= 0) {
close(fd);
}
return count;
return ret;
}
/* This function validates %FILENAME%. filename must be between 3 and
@@ -574,7 +623,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(pkg == NULL) {
_alpm_log(db->handle, ALPM_LOG_DEBUG,
"entry %s could not be loaded into %s sync database",
"entry %s could not be loaded into %s sync database\n",
entryname, db->treename);
return -1;
}
@@ -583,11 +632,12 @@ 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
* success and try to continue on. */
_alpm_log(db->handle, ALPM_LOG_WARNING, _("unknown database file: %s\n"),
filename);
entryname);
return 0;
}
if(strcmp(filename, "desc") == 0 || strcmp(filename, "depends") == 0
|| strcmp(filename, "files") == 0
|| (strcmp(filename, "deltas") == 0 && db->handle->deltaratio > 0.0) ) {
int ret;
while((ret = _alpm_archive_fgets(archive, &buf)) == ARCHIVE_OK) {
@@ -614,6 +664,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(_alpm_validate_filename(db, pkg->name, pkg->filename) < 0) {
return -1;
}
} else if(strcmp(line, "%BASE%") == 0) {
READ_AND_STORE(pkg->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(pkg->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -671,6 +723,36 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
pkg->deltas = alpm_list_add(pkg->deltas,
_alpm_delta_parse(db->handle, line));
}
} else if(strcmp(line, "%FILES%") == 0) {
/* TODO: this could lazy load if there is future demand */
size_t files_count = 0, files_size = 0;
alpm_file_t *files = NULL;
while(1) {
if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) {
goto error;
}
line = buf.line;
if(_alpm_strip_newline(line, buf.real_line_size) == 0) {
break;
}
if(!_alpm_greedy_grow((void **)&files, &files_size,
(files_count ? (files_count + 1) * sizeof(alpm_file_t) : 8 * sizeof(alpm_file_t)))) {
goto error;
}
STRDUP(files[files_count].name, line, goto error);
files_count++;
}
/* attempt to hand back any memory we don't need */
if(files_count > 0) {
files = realloc(files, sizeof(alpm_file_t) * files_count);
} else {
FREE(files);
}
pkg->files.count = files_count;
pkg->files.files = files;
_alpm_filelist_sort(&pkg->files);
}
}
if(ret != ARCHIVE_EOF) {
@@ -679,8 +761,6 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
*likely_pkg = pkg;
} else if(strcmp(filename, "deltas") == 0) {
/* skip reading delta files if UseDelta is unset */
} else if(strcmp(filename, "files") == 0) {
/* currently do nothing with this file */
} else {
/* unknown database file */
_alpm_log(db->handle, ALPM_LOG_DEBUG, "unknown database file: %s\n", filename);
@@ -700,14 +780,14 @@ struct db_operations sync_db_ops = {
};
alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
alpm_siglevel_t level)
int level)
{
alpm_db_t *db;
_alpm_log(handle, ALPM_LOG_DEBUG, "registering sync database '%s'\n", treename);
#ifndef HAVE_LIBGPGME
if((level &= ~ALPM_SIG_PACKAGE_SET) != 0 && level != ALPM_SIG_USE_DEFAULT) {
if(level != ALPM_SIG_USE_DEFAULT) {
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, NULL);
}
#endif
@@ -725,5 +805,3 @@ alpm_db_t *_alpm_db_register_sync(alpm_handle_t *handle, const char *treename,
handle->dbs_sync = alpm_list_add(handle->dbs_sync, db);
return db;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* conflict.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -48,15 +48,19 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
{
alpm_conflict_t *conflict;
MALLOC(conflict, sizeof(alpm_conflict_t), return NULL);
CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
conflict->package1_hash = pkg1->name_hash;
conflict->package2_hash = pkg2->name_hash;
STRDUP(conflict->package1, pkg1->name, return NULL);
STRDUP(conflict->package2, pkg2->name, return NULL);
STRDUP(conflict->package1, pkg1->name, goto error);
STRDUP(conflict->package2, pkg2->name, goto error);
conflict->reason = reason;
return conflict;
error:
alpm_conflict_free(conflict);
return NULL;
}
/**
@@ -64,6 +68,7 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
*/
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
{
ASSERT(conflict != NULL, return);
FREE(conflict->package2);
FREE(conflict->package1);
FREE(conflict);
@@ -79,11 +84,15 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
newconflict->package1_hash = conflict->package1_hash;
newconflict->package2_hash = conflict->package2_hash;
STRDUP(newconflict->package1, conflict->package1, return NULL);
STRDUP(newconflict->package2, conflict->package2, return NULL);
STRDUP(newconflict->package1, conflict->package1, goto error);
STRDUP(newconflict->package2, conflict->package2, goto error);
newconflict->reason = conflict->reason;
return newconflict;
error:
alpm_conflict_free(newconflict);
return NULL;
}
/**
@@ -265,16 +274,19 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
{
alpm_fileconflict_t *conflict;
MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
CALLOC(conflict, 1, sizeof(alpm_fileconflict_t), goto error);
STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error);
if(pkg2) {
conflict->type = ALPM_FILECONFLICT_TARGET;
STRDUP(conflict->ctarget, pkg2->name, goto error);
} else {
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;
STRDUP(conflict->ctarget, pkg2->name, goto error);
}
conflicts = alpm_list_add(conflicts, conflict);
@@ -284,6 +296,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
return conflicts;
error:
alpm_fileconflict_free(conflict);
RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
}
@@ -292,6 +305,7 @@ error:
*/
void SYMEXPORT alpm_fileconflict_free(alpm_fileconflict_t *conflict)
{
ASSERT(conflict != NULL, return);
FREE(conflict->ctarget);
FREE(conflict->file);
FREE(conflict->target);
@@ -374,6 +388,23 @@ static alpm_list_t *alpm_db_find_file_owners(alpm_db_t* db, const char *path)
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)
{
return handle->trans->flags & ALPM_TRANS_FLAG_FORCE
|| _alpm_fnmatch_patterns(handle->overwrite_files, path) == 0;
}
/**
* @brief Find file conflicts that may occur during the transaction.
*
@@ -408,7 +439,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
for(current = 0, i = upgrade; i; i = i->next, current++) {
alpm_pkg_t *p1 = i->data;
alpm_list_t *j;
alpm_list_t *tmpfiles = NULL;
alpm_list_t *newfiles = NULL;
alpm_pkg_t *dbpkg;
int percent = (current * 100) / numtargs;
@@ -437,8 +468,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* can skip file-file conflicts when forced *
* checking presence in p2_files detects dir-file or file-dir
* conflicts as the path from p1 is returned */
if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
alpm_filelist_contains(p2_files, filename)) {
if(_alpm_can_overwrite_file(handle, filename)
&& alpm_filelist_contains(p2_files, filename)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s exists in both '%s' and '%s'\n", filename,
p1->name, p2->name);
@@ -472,18 +503,18 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
* be freed. */
if(dbpkg) {
/* older ver of package currently installed */
tmpfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
newfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
alpm_pkg_get_files(dbpkg));
} else {
/* no version of package currently installed */
alpm_filelist_t *fl = alpm_pkg_get_files(p1);
size_t filenum;
for(filenum = 0; filenum < fl->count; filenum++) {
tmpfiles = alpm_list_add(tmpfiles, fl->files[filenum].name);
newfiles = alpm_list_add(newfiles, fl->files[filenum].name);
}
}
for(j = tmpfiles; j; j = j->next) {
for(j = newfiles; j; j = j->next) {
const char *filestr = j->data;
const char *relative_path;
alpm_list_t *k;
@@ -492,6 +523,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
struct stat lsbuf;
char path[PATH_MAX];
size_t pathlen;
int pfile_isdir;
pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
relative_path = path + rootlen;
@@ -503,7 +535,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
if(path[pathlen - 1] == '/') {
pfile_isdir = path[pathlen - 1] == '/';
if(pfile_isdir) {
if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
continue;
@@ -540,6 +573,18 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG,
"local file will be removed, not a conflict\n");
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;
}
}
}
}
}
@@ -555,6 +600,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* localp2->files will be removed (target conflicts are handled by CHECK 1) */
if(localp2 && alpm_filelist_contains(alpm_pkg_get_files(localp2), relative_path)) {
size_t fslen = strlen(filestr);
/* skip removal of file, but not add. this will prevent a second
* package from removing the file when it was already installed
* by its new owner (whether the file is in backup array or not */
@@ -563,6 +610,19 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG,
"file changed packages, adding to remove skiplist\n");
resolved_conflict = 1;
if(filestr[fslen - 1] == '/') {
/* replacing a file with a directory:
* 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 */
for( ; j->next; j = j->next) {
const char *filestr2 = j->next->data;
if(strncmp(filestr, filestr2, fslen) != 0) {
break;
}
}
}
}
}
@@ -614,30 +674,29 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
}
/* skip file-file conflicts when being forced */
if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
!S_ISDIR(lsbuf.st_mode)) {
if(!S_ISDIR(lsbuf.st_mode)
&& _alpm_can_overwrite_file(handle, filestr)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"conflict with file on filesystem being forced\n");
resolved_conflict = 1;
}
if(!resolved_conflict) {
conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
conflicts = add_fileconflict(handle, conflicts, path, p1,
_alpm_find_file_owner(handle, relative_path));
if(handle->pm_errno == ALPM_ERR_MEMORY) {
alpm_list_free_inner(conflicts,
(alpm_list_fn_free) alpm_conflict_free);
alpm_list_free(conflicts);
alpm_list_free(tmpfiles);
alpm_list_free(newfiles);
return NULL;
}
}
}
alpm_list_free(tmpfiles);
alpm_list_free(newfiles);
}
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current);
return conflicts;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* conflict.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_CONFLICT_H
#define _ALPM_CONFLICT_H
#ifndef ALPM_CONFLICT_H
#define ALPM_CONFLICT_H
#include "alpm.h"
#include "db.h"
@@ -30,6 +30,4 @@ alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages);
alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
alpm_list_t *upgrade, alpm_list_t *remove);
#endif /* _ALPM_CONFLICT_H */
/* vim: set noet: */
#endif /* ALPM_CONFLICT_H */

View File

@@ -1,7 +1,7 @@
/*
* db.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
@@ -44,7 +44,7 @@
/** Register a sync database of packages. */
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
const char *treename, alpm_siglevel_t level)
const char *treename, int siglevel)
{
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, level);
return _alpm_db_register_sync(handle, treename, siglevel);
}
/* 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);
/* Do not unregister a database if a transaction is on-going */
handle = db->handle;
handle->pm_errno = 0;
handle->pm_errno = ALPM_ERR_OK;
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, -1));
if(db == handle->db_local) {
@@ -179,7 +179,7 @@ int SYMEXPORT alpm_db_add_server(alpm_db_t *db, const char *url)
/* Sanity checks */
ASSERT(db != NULL, return -1);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
newurl = sanitize_url(url);
@@ -206,7 +206,7 @@ int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url)
/* Sanity checks */
ASSERT(db != NULL, return -1);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
ASSERT(url != NULL && strlen(url) != 0, RET_ERR(db->handle, ALPM_ERR_WRONG_ARGS, -1));
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. */
alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
int SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
{
ASSERT(db != NULL, return -1);
if(db->siglevel & ALPM_SIG_USE_DEFAULT) {
@@ -249,7 +249,7 @@ alpm_siglevel_t SYMEXPORT alpm_db_get_siglevel(alpm_db_t *db)
int SYMEXPORT alpm_db_get_valid(alpm_db_t *db)
{
ASSERT(db != NULL, return -1);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
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;
ASSERT(db != NULL, return NULL);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
ASSERT(name != NULL && strlen(name) != 0,
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)
{
ASSERT(db != NULL, return NULL);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
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)
{
ASSERT(db != NULL, return NULL);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
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)
{
ASSERT(db != NULL, return NULL);
db->handle->pm_errno = 0;
db->handle->pm_errno = ALPM_ERR_OK;
return _alpm_db_search(db, needles);
}
/** Sets the usage bitmask for a repo */
int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, int usage)
{
ASSERT(db != NULL, return -1);
db->usage = usage;
@@ -315,7 +315,7 @@ int SYMEXPORT alpm_db_set_usage(alpm_db_t *db, alpm_db_usage_t usage)
}
/** Gets the usage bitmask for a repo */
int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, alpm_db_usage_t *usage)
int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage)
{
ASSERT(db != NULL, return -1);
ASSERT(usage != NULL, return -1);
@@ -331,7 +331,7 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local)
alpm_db_t *db;
CALLOC(db, 1, sizeof(alpm_db_t), return NULL);
STRDUP(db->treename, treename, return NULL);
STRDUP(db->treename, treename, FREE(db); return NULL);
if(is_local) {
db->status |= DB_STATUS_LOCAL;
} else {
@@ -344,6 +344,7 @@ alpm_db_t *_alpm_db_new(const char *treename, int is_local)
void _alpm_db_free(alpm_db_t *db)
{
ASSERT(db != NULL, return);
/* cleanup pkgcache */
_alpm_db_free_pkgcache(db);
/* cleanup server list */
@@ -375,10 +376,12 @@ const char *_alpm_db_path(alpm_db_t *db)
CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
sprintf(db->_path, "%s%s/", dbpath, db->treename);
} else {
pathsize = strlen(dbpath) + 5 + strlen(db->treename) + 4;
const char *dbext = db->handle->dbext;
pathsize = strlen(dbpath) + 5 + strlen(db->treename) + strlen(dbext) + 1;
CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
/* all sync DBs now reside in the sync/ subdir of the dbpath */
sprintf(db->_path, "%ssync/%s.db", dbpath, db->treename);
sprintf(db->_path, "%ssync/%s%s", dbpath, db->treename, dbext);
}
_alpm_log(db->handle, ALPM_LOG_DEBUG, "database path for tree %s set to %s\n",
db->treename, db->_path);
@@ -542,7 +545,10 @@ alpm_pkghash_t *_alpm_db_get_pkgcache_hash(alpm_db_t *db)
}
if(!(db->status & DB_STATUS_PKGCACHE)) {
load_pkgcache(db);
if(load_pkgcache(db)) {
/* handle->error set in local/sync-db-populate */
return NULL;
}
}
return db->pkgcache;
@@ -562,13 +568,15 @@ alpm_list_t *_alpm_db_get_pkgcache(alpm_db_t *db)
/* "duplicate" pkg then add it to pkgcache */
int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
{
alpm_pkg_t *newpkg;
alpm_pkg_t *newpkg = NULL;
if(db == NULL || pkg == NULL || !(db->status & DB_STATUS_PKGCACHE)) {
return -1;
}
if(_alpm_pkg_dup(pkg, &newpkg)) {
/* we return memory on "non-fatal" error in _alpm_pkg_dup */
_alpm_pkg_free(newpkg);
return -1;
}
@@ -581,7 +589,10 @@ int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
? ALPM_PKG_FROM_LOCALDB
: ALPM_PKG_FROM_SYNCDB;
newpkg->origin_data.db = db;
db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg);
if(_alpm_pkghash_add_sorted(&db->pkgcache, newpkg) == NULL) {
_alpm_pkg_free(newpkg);
RET_ERR(db->handle, ALPM_ERR_MEMORY, -1);
}
free_groupcache(db);
@@ -715,5 +726,3 @@ alpm_group_t *_alpm_db_get_groupfromcache(alpm_db_t *db, const char *target)
return NULL;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* db.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -19,8 +19,8 @@
* 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 _ALPM_DB_H
#define _ALPM_DB_H
#ifndef ALPM_DB_H
#define ALPM_DB_H
/* libarchive */
#include <archive.h>
@@ -40,7 +40,7 @@ typedef enum _alpm_dbinfrq_t {
/* ALL should be info stored in the package or database */
INFRQ_ALL = INFRQ_BASE | INFRQ_DESC | INFRQ_FILES |
INFRQ_SCRIPTLET | INFRQ_DSIZE,
INFRQ_ERROR = (1 << 31)
INFRQ_ERROR = (1 << 30)
} alpm_dbinfrq_t;
/** Database status. Bitflags. */
@@ -71,10 +71,14 @@ struct __alpm_db_t {
alpm_list_t *grpcache;
alpm_list_t *servers;
struct db_operations *ops;
/* flags determining validity, local, loaded caches, etc. */
enum _alpm_dbstatus_t status;
alpm_siglevel_t siglevel;
alpm_db_usage_t usage;
/* bitfields for validity, local, loaded caches, etc. */
/* From _alpm_dbstatus_t */
int status;
/* alpm_siglevel_t */
int siglevel;
/* alpm_db_usage_t */
int usage;
};
@@ -86,12 +90,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_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_siglevel_t level);
int level);
void _alpm_db_unregister(alpm_db_t *db);
/* be_*.c, backend specific calls */
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, alpm_dbinfrq_t inforeq);
int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, int inforeq);
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);
@@ -107,6 +111,4 @@ alpm_pkg_t *_alpm_db_get_pkgfromcache(alpm_db_t *db, const char *target);
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);
#endif /* _ALPM_DB_H */
/* vim: set noet: */
#endif /* ALPM_DB_H */

View File

@@ -1,7 +1,7 @@
/*
* delta.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* 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->childptr = v_i->children;
v_i->iterator = v_i->children;
}
return vertices;
}
@@ -130,7 +130,7 @@ static void dijkstra(alpm_list_t *vertices)
for(i = vertices; i; i = i->next) {
alpm_graph_t *v_i = i->data;
if(v_i->state == -1) {
if(v_i->state == ALPM_GRAPH_STATE_PROCESSING) {
continue;
}
@@ -142,18 +142,18 @@ static void dijkstra(alpm_list_t *vertices)
break;
}
v->state = -1;
v->state = ALPM_GRAPH_STATE_PROCESSING;
v->childptr = v->children;
while(v->childptr) {
alpm_graph_t *v_c = v->childptr->data;
v->iterator = v->children;
while(v->iterator) {
alpm_graph_t *v_c = v->iterator->data;
alpm_delta_t *d_c = v_c->data;
if(v_c->weight > v->weight + d_c->download_size) {
v_c->weight = v->weight + d_c->download_size;
v_c->parent = v;
}
v->childptr = (v->childptr)->next;
v->iterator = (v->iterator)->next;
}
}
@@ -238,8 +238,7 @@ static alpm_list_t *find_unused(alpm_list_t *deltas, const char *to, off_t quota
for(i = vertices; i; i = i->next) {
alpm_graph_t *v = i->data;
alpm_delta_t *vdelta = v->data;
if(strcmp(vdelta->to, to) == 0)
{
if(strcmp(vdelta->to, to) == 0) {
v->weight = vdelta->download_size;
}
}
@@ -306,10 +305,10 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
/* start at index 1 -- match 0 is the entire match */
len = pmatch[1].rm_eo - pmatch[1].rm_so;
STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, return NULL);
STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, goto error);
len = pmatch[2].rm_eo - pmatch[2].rm_so;
STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, return NULL);
STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, goto error);
len = pmatch[3].rm_eo - pmatch[3].rm_so;
if(len < sizeof(filesize)) {
@@ -319,18 +318,23 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
}
len = pmatch[4].rm_eo - pmatch[4].rm_so;
STRNDUP(delta->from, &line[pmatch[4].rm_so], len, return NULL);
STRNDUP(delta->from, &line[pmatch[4].rm_so], len, goto error);
len = pmatch[5].rm_eo - pmatch[5].rm_so;
STRNDUP(delta->to, &line[pmatch[5].rm_so], len, return NULL);
STRNDUP(delta->to, &line[pmatch[5].rm_so], len, goto error);
return delta;
error:
_alpm_delta_free(delta);
return NULL;
}
#undef NUM_MATCHES
void _alpm_delta_free(alpm_delta_t *delta)
{
ASSERT(delta != NULL, return);
FREE(delta->delta);
FREE(delta->delta_md5);
FREE(delta->from);
@@ -342,14 +346,16 @@ alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta)
{
alpm_delta_t *newdelta;
CALLOC(newdelta, 1, sizeof(alpm_delta_t), return NULL);
STRDUP(newdelta->delta, delta->delta, return NULL);
STRDUP(newdelta->delta_md5, delta->delta_md5, return NULL);
STRDUP(newdelta->from, delta->from, return NULL);
STRDUP(newdelta->to, delta->to, return NULL);
STRDUP(newdelta->delta, delta->delta, goto error);
STRDUP(newdelta->delta_md5, delta->delta_md5, goto error);
STRDUP(newdelta->from, delta->from, goto error);
STRDUP(newdelta->to, delta->to, goto error);
newdelta->delta_size = delta->delta_size;
newdelta->download_size = delta->download_size;
return newdelta;
}
/* vim: set noet: */
error:
_alpm_delta_free(newdelta);
return NULL;
}

View File

@@ -1,7 +1,7 @@
/*
* delta.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_DELTA_H
#define _ALPM_DELTA_H
#ifndef ALPM_DELTA_H
#define ALPM_DELTA_H
#include <sys/types.h> /* off_t */
@@ -30,6 +30,4 @@ alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta);
off_t _alpm_shortest_delta_path(alpm_handle_t *handle, alpm_list_t *deltas,
const char *to, alpm_list_t **path);
#endif /* _ALPM_DELTA_H */
/* vim: set noet: */
#endif /* ALPM_DELTA_H */

View File

@@ -1,7 +1,7 @@
/*
* deps.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -37,6 +37,7 @@
void SYMEXPORT alpm_dep_free(alpm_depend_t *dep)
{
ASSERT(dep != NULL, return);
FREE(dep->name);
FREE(dep->version);
FREE(dep->desc);
@@ -48,17 +49,22 @@ static alpm_depmissing_t *depmiss_new(const char *target, alpm_depend_t *dep,
{
alpm_depmissing_t *miss;
MALLOC(miss, sizeof(alpm_depmissing_t), return NULL);
CALLOC(miss, 1, sizeof(alpm_depmissing_t), return NULL);
STRDUP(miss->target, target, return NULL);
STRDUP(miss->target, target, goto error);
miss->depend = _alpm_dep_dup(dep);
STRDUP(miss->causingpkg, causingpkg, return NULL);
STRDUP(miss->causingpkg, causingpkg, goto error);
return miss;
error:
alpm_depmissing_free(miss);
return NULL;
}
void SYMEXPORT alpm_depmissing_free(alpm_depmissing_t *miss)
{
ASSERT(miss != NULL, return);
alpm_dep_free(miss->depend);
FREE(miss->target);
FREE(miss->causingpkg);
@@ -101,7 +107,13 @@ static alpm_list_t *dep_graph_init(alpm_handle_t *handle,
alpm_list_t *i, *j;
alpm_list_t *vertices = NULL;
alpm_list_t *localpkgs = alpm_list_diff(
alpm_db_get_pkgcache(handle->db_local), ignore, _alpm_pkg_cmp);
alpm_db_get_pkgcache(handle->db_local), targets, _alpm_pkg_cmp);
if(ignore) {
alpm_list_t *oldlocal = localpkgs;
localpkgs = alpm_list_diff(oldlocal, ignore, _alpm_pkg_cmp);
alpm_list_free(oldlocal);
}
/* We create the vertices */
for(i = targets; i; i = i->next) {
@@ -133,20 +145,55 @@ static alpm_list_t *dep_graph_init(alpm_handle_t *handle,
alpm_graph_t *vertex_j = _alpm_graph_new();
vertex_j->data = (void *)j->data;
vertices = alpm_list_add(vertices, vertex_j);
vertex_i->children =
alpm_list_add(vertex_i->children, vertex_j);
vertex_i->children = alpm_list_add(vertex_i->children, vertex_j);
localpkgs = alpm_list_remove_item(localpkgs, j);
free(j);
}
j = next;
}
vertex_i->childptr = vertex_i->children;
vertex_i->iterator = vertex_i->children;
}
alpm_list_free(localpkgs);
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.
*
* Example (reverse == 0):
@@ -168,7 +215,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
{
alpm_list_t *newtargs = NULL;
alpm_list_t *vertices = NULL;
alpm_list_t *vptr;
alpm_list_t *i;
alpm_graph_t *vertex;
if(targets == NULL) {
@@ -179,67 +226,35 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
vertices = dep_graph_init(handle, targets, ignore);
vptr = vertices;
i = vertices;
vertex = vertices->data;
while(vptr) {
while(i) {
/* mark that we touched the vertex */
vertex->state = -1;
int found = 0;
while(vertex->childptr && !found) {
alpm_graph_t *nextchild = vertex->childptr->data;
vertex->childptr = vertex->childptr->next;
if(nextchild->state == 0) {
found = 1;
vertex->state = ALPM_GRAPH_STATE_PROCESSING;
int switched_to_child = 0;
while(vertex->iterator && !switched_to_child) {
alpm_graph_t *nextchild = vertex->iterator->data;
vertex->iterator = vertex->iterator->next;
if(nextchild->state == ALPM_GRAPH_STATE_UNPROCESSED) {
switched_to_child = 1;
nextchild->parent = vertex;
vertex = nextchild;
} else if(nextchild->state == -1) {
/* 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);
}
}
} else if(nextchild->state == ALPM_GRAPH_STATE_PROCESSING) {
_alpm_warn_dep_cycle(handle, targets, vertex, nextchild, reverse);
}
}
if(!found) {
if(!switched_to_child) {
if(alpm_list_find_ptr(targets, vertex->data)) {
newtargs = alpm_list_add(newtargs, vertex->data);
}
/* mark that we've left this vertex */
vertex->state = 1;
vertex->state = ALPM_GRAPH_STATE_PROCESSED;
vertex = vertex->parent;
if(!vertex) {
/* top level vertex reached, move to the next unprocessed vertex */
for( vptr = vptr->next; vptr; vptr = vptr->next) {
vertex = vptr->data;
if(vertex->state == 0) {
for(i = i->next; i; i = i->next) {
vertex = i->data;
if(vertex->state == ALPM_GRAPH_STATE_UNPROCESSED) {
break;
}
}
@@ -421,7 +436,7 @@ int _alpm_depcmp_literal(alpm_pkg_t *pkg, alpm_depend_t *dep)
}
/**
* @param dep dependency to check agains the provision list
* @param dep dependency to check against the provision list
* @param provisions provision list
* @return 1 if provider is found, 0 otherwise
*/
@@ -465,11 +480,11 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
return NULL;
}
MALLOC(depend, sizeof(alpm_depend_t), return NULL);
CALLOC(depend, 1, sizeof(alpm_depend_t), return NULL);
/* Note the extra space in ": " to avoid matching the epoch */
if((desc = strstr(depstring, ": ")) != NULL) {
STRDUP(depend->desc, desc + 2, return NULL);
STRDUP(depend->desc, desc + 2, goto error);
deplen = desc - depstring;
} else {
/* no description- point desc at NULL at end of string for later use */
@@ -509,13 +524,17 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
}
/* copy the right parts to the right places */
STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
STRNDUP(depend->name, depstring, ptr - depstring, goto error);
depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) {
STRNDUP(depend->version, version, desc - version, return NULL);
STRNDUP(depend->version, version, desc - version, goto error);
}
return depend;
error:
alpm_dep_free(depend);
return NULL;
}
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
@@ -523,53 +542,42 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
alpm_depend_t *newdep;
CALLOC(newdep, 1, sizeof(alpm_depend_t), return NULL);
STRDUP(newdep->name, dep->name, return NULL);
STRDUP(newdep->version, dep->version, return NULL);
STRDUP(newdep->desc, dep->desc, return NULL);
STRDUP(newdep->name, dep->name, goto error);
STRDUP(newdep->version, dep->version, goto error);
STRDUP(newdep->desc, dep->desc, goto error);
newdep->name_hash = dep->name_hash;
newdep->mod = dep->mod;
return newdep;
error:
alpm_dep_free(newdep);
return NULL;
}
/* These parameters are messy. We check if this package, given a list of
* targets and a db is safe to remove. We do NOT remove it if it is in the
* target list, or if the package was explicitly installed and
* include_explicit == 0 */
static int can_remove_package(alpm_db_t *db, alpm_pkg_t *pkg,
alpm_list_t *targets, int include_explicit)
/** Move package dependencies from one list to another
* @param from list to scan for dependencies
* @param to list to add dependencies to
* @param pkg package whose dependencies are moved
* @param explicit if 0, explicitly installed packages are not moved
*/
static void _alpm_select_depends(alpm_list_t **from, alpm_list_t **to,
alpm_pkg_t *pkg, int explicit)
{
alpm_list_t *i;
if(alpm_pkg_find(targets, pkg->name)) {
return 0;
alpm_list_t *i, *next;
if(!alpm_pkg_get_depends(pkg)) {
return;
}
if(!include_explicit) {
/* see if it was explicitly installed */
if(alpm_pkg_get_reason(pkg) == ALPM_PKG_REASON_EXPLICIT) {
_alpm_log(db->handle, ALPM_LOG_DEBUG,
"excluding %s -- explicitly installed\n", pkg->name);
return 0;
for(i = *from; i; i = next) {
alpm_pkg_t *deppkg = i->data;
next = i->next;
if((explicit || alpm_pkg_get_reason(deppkg) != ALPM_PKG_REASON_EXPLICIT)
&& _alpm_pkg_depends_on(pkg, deppkg)) {
*to = alpm_list_add(*to, deppkg);
*from = alpm_list_remove_item(*from, i);
free(i);
}
}
/* TODO: checkdeps could be used here, it handles multiple providers
* better, but that also makes it slower.
* Also this would require to first add the package to the targets list,
* then call checkdeps with it, then remove the package from the targets list
* if checkdeps detected it would break something */
/* see if other packages need it */
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
alpm_pkg_t *lpkg = i->data;
if(_alpm_pkg_depends_on(lpkg, pkg) && !alpm_pkg_find(targets, lpkg->name)) {
return 0;
}
}
/* it's ok to remove */
return 1;
}
/**
@@ -585,29 +593,46 @@ static int can_remove_package(alpm_db_t *db, alpm_pkg_t *pkg,
*/
int _alpm_recursedeps(alpm_db_t *db, alpm_list_t **targs, int include_explicit)
{
alpm_list_t *i, *j;
alpm_list_t *i, *keep, *rem = NULL;
if(db == NULL || targs == NULL) {
return -1;
}
keep = alpm_list_copy(_alpm_db_get_pkgcache(db));
for(i = *targs; i; i = i->next) {
alpm_pkg_t *pkg = i->data;
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
alpm_pkg_t *deppkg = j->data;
if(_alpm_pkg_depends_on(pkg, deppkg)
&& can_remove_package(db, deppkg, *targs, include_explicit)) {
alpm_pkg_t *copy;
_alpm_log(db->handle, ALPM_LOG_DEBUG, "adding '%s' to the targets\n",
deppkg->name);
/* add it to the target list */
if(_alpm_pkg_dup(deppkg, &copy)) {
return -1;
}
*targs = alpm_list_add(*targs, copy);
}
}
keep = alpm_list_remove(keep, i->data, _alpm_pkg_cmp, NULL);
}
/* recursively select all dependencies for removal */
for(i = *targs; i; i = i->next) {
_alpm_select_depends(&keep, &rem, i->data, include_explicit);
}
for(i = rem; i; i = i->next) {
_alpm_select_depends(&keep, &rem, i->data, include_explicit);
}
/* recursively select any still needed packages to keep */
for(i = keep; i && rem; i = i->next) {
_alpm_select_depends(&rem, &keep, i->data, 1);
}
alpm_list_free(keep);
/* copy selected packages into the target list */
for(i = rem; i; i = i->next) {
alpm_pkg_t *pkg = i->data, *copy = NULL;
_alpm_log(db->handle, ALPM_LOG_DEBUG,
"adding '%s' to the targets\n", pkg->name);
if(_alpm_pkg_dup(pkg, &copy)) {
/* we return memory on "non-fatal" error in _alpm_pkg_dup */
_alpm_pkg_free(copy);
alpm_list_free(rem);
return -1;
}
*targs = alpm_list_add(*targs, copy);
}
alpm_list_free(rem);
return 0;
}
@@ -673,10 +698,8 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
}
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
alpm_pkg_t *pkg = j->data;
/* with hash != hash, we can even skip the strcmp() as we know they can't
* possibly be the same string */
if(pkg->name_hash != dep->name_hash && _alpm_depcmp(pkg, dep)
&& !alpm_pkg_find(excluding, pkg->name)) {
if((pkg->name_hash != dep->name_hash || strcmp(pkg->name, dep->name) != 0)
&& _alpm_depcmp(pkg, dep) && !alpm_pkg_find(excluding, pkg->name)) {
if(alpm_pkg_should_ignore(handle, pkg)) {
alpm_question_install_ignorepkg_t question = {
.type = ALPM_QUESTION_INSTALL_IGNOREPKG,
@@ -931,4 +954,3 @@ char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
return str;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* deps.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -19,8 +19,8 @@
* 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 _ALPM_DEPS_H
#define _ALPM_DEPS_H
#ifndef ALPM_DEPS_H
#define ALPM_DEPS_H
#include "db.h"
#include "sync.h"
@@ -38,6 +38,4 @@ int _alpm_depcmp_literal(alpm_pkg_t *pkg, alpm_depend_t *dep);
int _alpm_depcmp_provides(alpm_depend_t *dep, alpm_list_t *provisions);
int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep);
#endif /* _ALPM_DEPS_H */
/* vim: set noet: */
#endif /* ALPM_DEPS_H */

View File

@@ -1,7 +1,7 @@
/*
* diskspace.c
*
* Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2010-2018 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
@@ -112,7 +112,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((mnt = getmntent(fp))) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(mp->mount_dir, mnt->mnt_dir, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(mp->mount_dir, mnt->mnt_dir, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -135,7 +135,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
while((ret = getmntent(fp, &mnt)) == 0) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(mp->mount_dir, mnt->mnt_mountp, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(mp->mount_dir, mnt->mnt_mountp, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
mount_points = alpm_list_add(mount_points, mp);
@@ -162,7 +162,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
for(; entries-- > 0; fsp++) {
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(mp->mount_dir, fsp->f_mntonname, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
STRDUP(mp->mount_dir, fsp->f_mntonname, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
mp->mount_dir_len = strlen(mp->mount_dir);
memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
#if defined(HAVE_GETMNTINFO_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FLAG)
@@ -235,7 +235,14 @@ static int calculate_removed_size(alpm_handle_t *handle,
const char *filename = file->name;
snprintf(path, PATH_MAX, "%s%s", handle->root, filename);
llstat(path, &st);
if(llstat(path, &st) == -1) {
if(alpm_option_match_noextract(handle, filename)) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("could not get file information for %s\n"), filename);
}
continue;
}
/* skip directories and symlinks to be consistent with libarchive that
* reports them to be zero size */
@@ -341,11 +348,11 @@ static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp)
_alpm_log(handle, ALPM_LOG_DEBUG,
"partition %s, needed %jd, cushion %ju, free %ju\n",
mp->mount_dir, (intmax_t)mp->max_blocks_needed,
(uintmax_t)cushion, (uintmax_t)mp->fsp.f_bfree);
if(needed >= 0 && (fsblkcnt_t)needed > mp->fsp.f_bfree) {
(uintmax_t)cushion, (uintmax_t)mp->fsp.f_bavail);
if(needed >= 0 && (fsblkcnt_t)needed > mp->fsp.f_bavail) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("Partition %s too full: %jd blocks needed, %jd blocks free\n"),
mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bfree);
_("Partition %s too full: %jd blocks needed, %ju blocks free\n"),
mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bavail);
return 1;
}
return 0;
@@ -493,5 +500,3 @@ finish:
return 0;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* diskspace.h
*
* Copyright (c) 2010-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2010-2018 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
@@ -17,8 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ALPM_DISKSPACE_H
#define _ALPM_DISKSPACE_H
#ifndef ALPM_DISKSPACE_H
#define ALPM_DISKSPACE_H
#if defined(HAVE_SYS_MOUNT_H)
#include <sys/mount.h>
@@ -60,6 +60,4 @@ int _alpm_check_diskspace(alpm_handle_t *handle);
int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
size_t num_files, off_t *file_sizes);
#endif /* _ALPM_DISKSPACE_H */
/* vim: set noet: */
#endif /* ALPM_DISKSPACE_H */

View File

@@ -1,7 +1,7 @@
/*
* download.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* 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;
}
static int dload_progress_cb(void *file, double dltotal, double dlnow,
double UNUSED ultotal, double UNUSED ulnow)
static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t UNUSED ultotal, curl_off_t UNUSED ulnow)
{
struct dload_payload *payload = (struct dload_payload *)file;
off_t current_size, total_size;
@@ -106,7 +106,7 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow,
return 1;
}
current_size = payload->initial_size + (off_t)dlnow;
current_size = payload->initial_size + dlnow;
/* is our filesize still under any set limit? */
if(payload->max_size && current_size > payload->max_size) {
@@ -119,21 +119,31 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow,
return 0;
}
total_size = payload->initial_size + (off_t)dltotal;
total_size = payload->initial_size + dltotal;
if(DOUBLE_EQ(dltotal, 0.0) || payload->prevprogress == total_size) {
if(dltotal == 0 || payload->prevprogress == total_size) {
return 0;
}
/* initialize the progress bar here to avoid displaying it when
* a repo is up to date and nothing gets downloaded */
if(payload->prevprogress == 0) {
payload->handle->dlcb(payload->remote_name, 0, (off_t)dltotal);
* a repo is up to date and nothing gets downloaded.
* payload->handle->dlcb will receive the remote_name
* and the following arguments:
* 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
* download_size (nor included in the total download size callback) */
payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal);
payload->handle->dlcb(payload->remote_name, dlnow, dltotal);
}
payload->prevprogress = current_size;
@@ -236,47 +246,6 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
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,
CURL *curl, char *error_buffer)
{
@@ -293,15 +262,18 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload);
if(!handle->disable_dl_timeout) {
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
}
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *)payload);
curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, dload_sockopt_cb);
curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, (void *)handle);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
_alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl);
@@ -323,7 +295,7 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, (long)st.st_mtime);
_alpm_log(handle, ALPM_LOG_DEBUG,
"using time condition: %lu\n", (long)st.st_mtime);
"using time condition: %ld\n", (long)st.st_mtime);
} else if(stat(payload->tempfile_name, &st) == 0 && payload->allow_resume) {
/* a previous partial download exists, resume from end of file. */
payload->tempfile_openmode = "ab";
@@ -379,7 +351,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
payload->tempfile_name = randpath;
free(payload->remote_name);
STRDUP(payload->remote_name, strrchr(randpath, '/') + 1,
RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL));
fclose(fp); RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL));
return fp;
}
@@ -402,7 +374,7 @@ static int curl_download_internal(struct dload_payload *payload,
/* shortcut to our handle within the payload */
alpm_handle_t *handle = payload->handle;
CURL *curl = get_libcurl_handle(handle);
handle->pm_errno = 0;
handle->pm_errno = ALPM_ERR_OK;
/* make sure these are NULL */
FREE(payload->tempfile_name);
@@ -702,7 +674,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
size_t len;
len = strlen(final_pkg_url) + 5;
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
MALLOC(payload.fileurl, len, free(final_file); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
snprintf(payload.fileurl, len, "%s.sig", final_pkg_url);
sig_filepath = filecache_find_url(handle, payload.fileurl);
@@ -752,4 +724,13 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
memset(payload, '\0', sizeof(*payload));
}
/* vim: set noet: */
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload)
{
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
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_DLOAD_H
#define _ALPM_DLOAD_H
#ifndef ALPM_DLOAD_H
#define ALPM_DLOAD_H
#include "alpm_list.h"
#include "alpm.h"
@@ -41,16 +41,16 @@ struct dload_payload {
int errors_ok;
int unlink_on_fail;
int trust_remote_name;
int cb_initialized;
#ifdef HAVE_LIBCURL
CURLcode curlerr; /* last error produced by curl */
#endif
};
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,
char **final_file, const char **final_url);
#endif /* _ALPM_DLOAD_H */
/* vim: set noet: */
#endif /* ALPM_DLOAD_H */

View File

@@ -1,7 +1,7 @@
/*
* error.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -100,6 +100,8 @@ const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
return _("operation not compatible with the transaction type");
case ALPM_ERR_TRANS_NOT_LOCKED:
return _("transaction commit attempt when database is not locked");
case ALPM_ERR_TRANS_HOOK_FAILED:
return _("failed to run transaction hooks");
/* Packages */
case ALPM_ERR_PKG_NOT_FOUND:
return _("could not find or read package");
@@ -162,5 +164,3 @@ const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
return _("unexpected error");
}
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* filelist.c
*
* Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2012-2018 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
@@ -111,7 +111,7 @@ alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
/* Helper function for comparing files list entries
*/
int _alpm_files_cmp(const void *f1, const void *f2)
static int _alpm_files_cmp(const void *f1, const void *f2)
{
const alpm_file_t *file1 = f1;
const alpm_file_t *file2 = f2;
@@ -133,4 +133,15 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
sizeof(alpm_file_t), _alpm_files_cmp);
}
/* vim: set noet: */
void _alpm_filelist_sort(alpm_filelist_t *filelist)
{
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
*
* Copyright (c) 2012-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2012-2018 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
@@ -16,8 +16,8 @@
* 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 _ALPM_FILELIST_H
#define _ALPM_FILELIST_H
#ifndef ALPM_FILELIST_H
#define ALPM_FILELIST_H
#include "alpm.h"
@@ -27,8 +27,6 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
alpm_filelist_t *filesB);
int _alpm_files_cmp(const void *f1, const void *f2);
void _alpm_filelist_sort(alpm_filelist_t *filelist);
#endif /* _ALPM_FILELIST_H */
/* vim: set noet: */
#endif /* ALPM_FILELIST_H */

View File

@@ -1,7 +1,7 @@
/*
* graph.c - helpful graph structure and setup/teardown methods
*
* Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2018 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
@@ -31,9 +31,8 @@ alpm_graph_t *_alpm_graph_new(void)
void _alpm_graph_free(void *data)
{
ASSERT(data != NULL, return);
alpm_graph_t *graph = data;
alpm_list_free(graph->children);
free(graph);
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* graph.h - helpful graph structure and setup/teardown methods
*
* Copyright (c) 2007-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2007-2018 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
@@ -16,25 +16,29 @@
* 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 _ALPM_GRAPH_H
#define _ALPM_GRAPH_H
#ifndef ALPM_GRAPH_H
#define ALPM_GRAPH_H
#include <sys/types.h> /* off_t */
#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 {
void *data;
struct __alpm_graph_t *parent; /* where did we come from? */
alpm_list_t *children;
alpm_list_t *childptr; /* points to a child in children list */
alpm_list_t *iterator; /* used for DFS without recursion */
off_t weight; /* weight of the node */
char state; /* 0: untouched, -1: entered, other: leaving time */
enum __alpm_graph_vertex_state state;
} alpm_graph_t;
alpm_graph_t *_alpm_graph_new(void);
void _alpm_graph_free(void *data);
#endif /* _ALPM_GRAPH_H */
/* vim: set noet: */
#endif /* ALPM_GRAPH_H */

View File

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

View File

@@ -1,7 +1,7 @@
/*
* group.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,14 +17,12 @@
* 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 _ALPM_GROUP_H
#define _ALPM_GROUP_H
#ifndef ALPM_GROUP_H
#define ALPM_GROUP_H
#include "alpm.h"
alpm_group_t *_alpm_group_new(const char *name);
void _alpm_group_free(alpm_group_t *grp);
#endif /* _ALPM_GROUP_H */
/* vim: set noet: */
#endif /* ALPM_GROUP_H */

View File

@@ -1,7 +1,7 @@
/*
* handle.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -81,7 +81,9 @@ void _alpm_handle_free(alpm_handle_t *handle)
_alpm_trans_free(handle->trans);
FREE(handle->root);
FREE(handle->dbpath);
FREE(handle->dbext);
FREELIST(handle->cachedirs);
FREELIST(handle->hookdirs);
FREE(handle->logfile);
FREE(handle->lockfile);
FREE(handle->arch);
@@ -90,6 +92,7 @@ void _alpm_handle_free(alpm_handle_t *handle)
FREELIST(handle->noextract);
FREELIST(handle->ignorepkg);
FREELIST(handle->ignoregroup);
FREELIST(handle->overwrite_files);
alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
alpm_list_free(handle->assumeinstalled);
@@ -124,16 +127,31 @@ int _alpm_handle_lock(alpm_handle_t *handle)
return (handle->lockfd >= 0 ? 0 : -1);
}
/** Remove a lock file */
int _alpm_handle_unlock(alpm_handle_t *handle)
/** Remove the database lock file
* @param handle the context handle
* @return 0 on success, -1 on error
*
* @note Safe to call from inside signal handlers.
*/
int SYMEXPORT alpm_unlock(alpm_handle_t *handle)
{
ASSERT(handle->lockfile != NULL, return -1);
ASSERT(handle != NULL, return -1);
ASSERT(handle->lockfile != NULL, return 0);
ASSERT(handle->lockfd >= 0, return 0);
close(handle->lockfd);
handle->lockfd = -1;
if(unlink(handle->lockfile) != 0) {
RET_ERR_ASYNC_SAFE(handle, ALPM_ERR_SYSTEM, -1);
} else {
return 0;
}
}
int _alpm_handle_unlock(alpm_handle_t *handle)
{
if(alpm_unlock(handle) != 0) {
if(errno == ENOENT) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("lock file missing %s\n"), handle->lockfile);
@@ -148,6 +166,7 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
return -1;
}
}
return 0;
}
@@ -206,6 +225,12 @@ const char SYMEXPORT *alpm_option_get_dbpath(alpm_handle_t *handle)
return handle->dbpath;
}
alpm_list_t SYMEXPORT *alpm_option_get_hookdirs(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->hookdirs;
}
alpm_list_t SYMEXPORT *alpm_option_get_cachedirs(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
@@ -260,6 +285,12 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregroups(alpm_handle_t *handle)
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)
{
CHECK_HANDLE(handle, return NULL);
@@ -284,6 +315,12 @@ int SYMEXPORT alpm_option_get_checkspace(alpm_handle_t *handle)
return handle->checkspace;
}
const char SYMEXPORT *alpm_option_get_dbext(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->dbext;
}
int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb)
{
CHECK_HANDLE(handle, return -1);
@@ -380,6 +417,58 @@ alpm_errno_t _alpm_set_directory_option(const char *value,
return 0;
}
int SYMEXPORT alpm_option_add_hookdir(alpm_handle_t *handle, const char *hookdir)
{
char *newhookdir;
CHECK_HANDLE(handle, return -1);
ASSERT(hookdir != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
newhookdir = canonicalize_path(hookdir);
if(!newhookdir) {
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
handle->hookdirs = alpm_list_add(handle->hookdirs, newhookdir);
_alpm_log(handle, ALPM_LOG_DEBUG, "option 'hookdir' = %s\n", newhookdir);
return 0;
}
int SYMEXPORT alpm_option_set_hookdirs(alpm_handle_t *handle, alpm_list_t *hookdirs)
{
alpm_list_t *i;
CHECK_HANDLE(handle, return -1);
if(handle->hookdirs) {
FREELIST(handle->hookdirs);
}
for(i = hookdirs; i; i = i->next) {
int ret = alpm_option_add_hookdir(handle, i->data);
if(ret) {
return ret;
}
}
return 0;
}
int SYMEXPORT alpm_option_remove_hookdir(alpm_handle_t *handle, const char *hookdir)
{
char *vdata = NULL;
char *newhookdir;
CHECK_HANDLE(handle, return -1);
ASSERT(hookdir != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
newhookdir = canonicalize_path(hookdir);
if(!newhookdir) {
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
handle->hookdirs = alpm_list_remove_str(handle->hookdirs, newhookdir, &vdata);
FREE(newhookdir);
if(vdata != NULL) {
FREE(vdata);
return 1;
}
return 0;
}
int SYMEXPORT alpm_option_add_cachedir(alpm_handle_t *handle, const char *cachedir)
{
char *newcachedir;
@@ -461,17 +550,11 @@ int SYMEXPORT alpm_option_set_logfile(alpm_handle_t *handle, const char *logfile
int SYMEXPORT alpm_option_set_gpgdir(alpm_handle_t *handle, const char *gpgdir)
{
int err;
CHECK_HANDLE(handle, return -1);
if(!gpgdir) {
handle->pm_errno = ALPM_ERR_WRONG_ARGS;
return -1;
if((err = _alpm_set_directory_option(gpgdir, &(handle->gpgdir), 0))) {
RET_ERR(handle, err, -1);
}
if(handle->gpgdir) {
FREE(handle->gpgdir);
}
STRDUP(handle->gpgdir, gpgdir, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
_alpm_log(handle, ALPM_LOG_DEBUG, "option 'gpgdir' = %s\n", handle->gpgdir);
return 0;
}
@@ -582,11 +665,32 @@ int SYMEXPORT alpm_option_remove_ignoregroup(alpm_handle_t *handle, const char *
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)
{
alpm_depend_t *depcpy;
CHECK_HANDLE(handle, return -1);
ASSERT(dep->mod == ALPM_DEP_MOD_EQ || dep->mod == ALPM_DEP_MOD_ANY,
RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
ASSERT((depcpy = _alpm_dep_dup(dep)), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
handle->assumeinstalled = alpm_list_add(handle->assumeinstalled, (void *)dep);
/* fill in name_hash in case dep was built by hand */
depcpy->name_hash = _alpm_hash_sdbm(dep->name);
handle->assumeinstalled = alpm_list_add(handle->assumeinstalled, depcpy);
return 0;
}
@@ -597,7 +701,12 @@ int SYMEXPORT alpm_option_set_assumeinstalled(alpm_handle_t *handle, alpm_list_t
alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
alpm_list_free(handle->assumeinstalled);
}
handle->assumeinstalled = deps;
while(deps) {
if(alpm_option_add_assumeinstalled(handle, deps->data) != 0) {
return -1;
}
deps = deps->next;
}
return 0;
}
@@ -606,10 +715,21 @@ static int assumeinstalled_cmp(const void *d1, const void *d2)
const alpm_depend_t *dep1 = d1;
const alpm_depend_t *dep2 = d2;
if(strcmp(dep1->name, dep2->name) == 0 && strcmp(dep1->version, dep2->version) == 0) {
if(dep1->name_hash != dep2->name_hash
|| strcmp(dep1->name, dep2->name) != 0) {
return -1;
}
if(dep1->version && dep2->version
&& strcmp(dep1->version, dep2->version) == 0) {
return 0;
}
if(dep1->version == NULL && dep2->version == NULL) {
return 0;
}
return -1;
}
@@ -664,8 +784,23 @@ int SYMEXPORT alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace)
return 0;
}
int SYMEXPORT alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext)
{
CHECK_HANDLE(handle, return -1);
ASSERT(dbext, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
if(handle->dbext) {
FREE(handle->dbext);
}
STRDUP(handle->dbext, dbext, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
_alpm_log(handle, ALPM_LOG_DEBUG, "option 'dbext' = %s\n", handle->dbext);
return 0;
}
int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level)
int level)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME
@@ -678,14 +813,14 @@ int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
return 0;
}
alpm_siglevel_t SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle)
int SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
return handle->siglevel;
}
int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level)
int level)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME
@@ -698,7 +833,7 @@ int SYMEXPORT alpm_option_set_local_file_siglevel(alpm_handle_t *handle,
return 0;
}
alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
int SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
if(handle->localfilesiglevel & ALPM_SIG_USE_DEFAULT) {
@@ -709,7 +844,7 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_local_file_siglevel(alpm_handle_t *han
}
int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level)
int level)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBGPGME
@@ -722,7 +857,7 @@ int SYMEXPORT alpm_option_set_remote_file_siglevel(alpm_handle_t *handle,
return 0;
}
alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
int SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return -1);
if(handle->remotefilesiglevel & ALPM_SIG_USE_DEFAULT) {
@@ -732,4 +867,12 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *ha
}
}
/* vim: set noet: */
int SYMEXPORT alpm_option_set_disable_dl_timeout(alpm_handle_t *handle,
unsigned short disable_dl_timeout)
{
CHECK_HANDLE(handle, return -1);
#ifdef HAVE_LIBCURL
handle->disable_dl_timeout = disable_dl_timeout;
#endif
return 0;
}

View File

@@ -1,7 +1,7 @@
/*
* handle.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_HANDLE_H
#define _ALPM_HANDLE_H
#ifndef ALPM_HANDLE_H
#define ALPM_HANDLE_H
#include <stdio.h>
#include <sys/types.h>
@@ -60,6 +60,7 @@ struct __alpm_handle_t {
#ifdef HAVE_LIBCURL
/* libcurl handle */
CURL *curl; /* reusable curl_easy handle */
unsigned short disable_dl_timeout;
#endif
#ifdef HAVE_LIBGPGME
@@ -82,6 +83,8 @@ struct __alpm_handle_t {
char *lockfile; /* Name of the lock file */
char *gpgdir; /* Directory where GnuPG files are stored */
alpm_list_t *cachedirs; /* Paths to pacman cache directories */
alpm_list_t *hookdirs; /* Paths to hook directories */
alpm_list_t *overwrite_files; /* Paths that may be overwritten */
/* package lists */
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
@@ -95,10 +98,11 @@ struct __alpm_handle_t {
double deltaratio; /* Download deltas if possible; a ratio value */
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
int checkspace; /* Check disk space before installing */
alpm_siglevel_t siglevel; /* Default signature verification level */
alpm_siglevel_t localfilesiglevel; /* Signature verification level for local file
char *dbext; /* Sync DB extension */
int siglevel; /* Default signature verification level */
int localfilesiglevel; /* Signature verification level for local file
upgrade operations */
alpm_siglevel_t remotefilesiglevel; /* Signature verification level for remote file
int remotefilesiglevel; /* Signature verification level for remote file
upgrade operations */
/* error code */
@@ -121,6 +125,4 @@ int _alpm_handle_unlock(alpm_handle_t *handle);
alpm_errno_t _alpm_set_directory_option(const char *value,
char **storage, int must_exist);
#endif /* _ALPM_HANDLE_H */
/* vim: set noet: */
#endif /* ALPM_HANDLE_H */

784
lib/libalpm/hook.c Normal file
View File

@@ -0,0 +1,784 @@
/*
* hook.c
*
* Copyright (c) 2015-2018 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/>.
*/
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#include "handle.h"
#include "hook.h"
#include "ini.h"
#include "log.h"
#include "trans.h"
#include "util.h"
enum _alpm_hook_op_t {
ALPM_HOOK_OP_INSTALL = (1 << 0),
ALPM_HOOK_OP_UPGRADE = (1 << 1),
ALPM_HOOK_OP_REMOVE = (1 << 2),
};
enum _alpm_trigger_type_t {
ALPM_HOOK_TYPE_PACKAGE = 1,
ALPM_HOOK_TYPE_FILE,
};
struct _alpm_trigger_t {
enum _alpm_hook_op_t op;
enum _alpm_trigger_type_t type;
alpm_list_t *targets;
};
struct _alpm_hook_t {
char *name;
char *desc;
alpm_list_t *triggers;
alpm_list_t *depends;
char **cmd;
alpm_list_t *matches;
alpm_hook_when_t when;
int abort_on_fail, needs_targets;
};
struct _alpm_hook_cb_ctx {
alpm_handle_t *handle;
struct _alpm_hook_t *hook;
};
static void _alpm_trigger_free(struct _alpm_trigger_t *trigger)
{
if(trigger) {
FREELIST(trigger->targets);
free(trigger);
}
}
static void _alpm_wordsplit_free(char **ws)
{
if(ws) {
char **c;
for(c = ws; *c; c++) {
free(*c);
}
free(ws);
}
}
static void _alpm_hook_free(struct _alpm_hook_t *hook)
{
if(hook) {
free(hook->name);
free(hook->desc);
_alpm_wordsplit_free(hook->cmd);
alpm_list_free_inner(hook->triggers, (alpm_list_fn_free) _alpm_trigger_free);
alpm_list_free(hook->triggers);
alpm_list_free(hook->matches);
FREELIST(hook->depends);
free(hook);
}
}
static int _alpm_trigger_validate(alpm_handle_t *handle,
struct _alpm_trigger_t *trigger, const char *file)
{
int ret = 0;
if(trigger->targets == NULL) {
ret = -1;
_alpm_log(handle, ALPM_LOG_ERROR,
_("Missing trigger targets in hook: %s\n"), file);
}
if(trigger->type == 0) {
ret = -1;
_alpm_log(handle, ALPM_LOG_ERROR,
_("Missing trigger type in hook: %s\n"), file);
}
if(trigger->op == 0) {
ret = -1;
_alpm_log(handle, ALPM_LOG_ERROR,
_("Missing trigger operation in hook: %s\n"), file);
}
return ret;
}
static int _alpm_hook_validate(alpm_handle_t *handle,
struct _alpm_hook_t *hook, const char *file)
{
alpm_list_t *i;
int ret = 0;
if(hook->triggers == NULL) {
/* special case: allow triggerless hooks as a way of creating dummy
* hooks that can be used to mask lower priority hooks */
return 0;
}
for(i = hook->triggers; i; i = i->next) {
if(_alpm_trigger_validate(handle, i->data, file) != 0) {
ret = -1;
}
}
if(hook->cmd == NULL) {
ret = -1;
_alpm_log(handle, ALPM_LOG_ERROR,
_("Missing Exec option in hook: %s\n"), file);
}
if(hook->when == 0) {
ret = -1;
_alpm_log(handle, ALPM_LOG_ERROR,
_("Missing When option in hook: %s\n"), file);
} else if(hook->when != ALPM_HOOK_PRE_TRANSACTION && hook->abort_on_fail) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("AbortOnFail set for PostTransaction hook: %s\n"), file);
}
return ret;
}
static char **_alpm_wordsplit(char *str)
{
char *c = str, *end;
char **out = NULL, **outsave;
size_t count = 0;
if(str == NULL) {
errno = EINVAL;
return NULL;
}
for(c = str; isspace(*c); c++);
while(*c) {
size_t wordlen = 0;
/* extend our array */
outsave = out;
if((out = realloc(out, (count + 1) * sizeof(char*))) == NULL) {
out = outsave;
goto error;
}
/* calculate word length and check for unbalanced quotes */
for(end = c; *end && !isspace(*end); end++) {
if(*end == '\'' || *end == '"') {
char quote = *end;
while(*(++end) && *end != quote) {
if(*end == '\\' && *(end + 1) == quote) {
end++;
}
wordlen++;
}
if(*end != quote) {
errno = EINVAL;
goto error;
}
} else {
if(*end == '\\' && (end[1] == '\'' || end[1] == '"')) {
end++; /* skip the '\\' */
}
wordlen++;
}
}
if(wordlen == (size_t) (end - c)) {
/* no internal quotes or escapes, copy it the easy way */
if((out[count++] = strndup(c, wordlen)) == NULL) {
goto error;
}
} else {
/* manually copy to remove quotes and escapes */
char *dest = out[count++] = malloc(wordlen + 1);
if(dest == NULL) { goto error; }
while(c < end) {
if(*c == '\'' || *c == '"') {
char quote = *c;
/* we know there must be a matching end quote,
* no need to check for '\0' */
for(c++; *c != quote; c++) {
if(*c == '\\' && *(c + 1) == quote) {
c++;
}
*(dest++) = *c;
}
c++;
} else {
if(*c == '\\' && (c[1] == '\'' || c[1] == '"')) {
c++; /* skip the '\\' */
}
*(dest++) = *(c++);
}
}
*dest = '\0';
}
if(*end == '\0') {
break;
} else {
for(c = end + 1; isspace(*c); c++);
}
}
outsave = out;
if((out = realloc(out, (count + 1) * sizeof(char*))) == NULL) {
out = outsave;
goto error;
}
out[count++] = NULL;
return out;
error:
/* can't use wordsplit_free here because NULL has not been appended */
while(count) {
free(out[--count]);
}
free(out);
return NULL;
}
static int _alpm_hook_parse_cb(const char *file, int line,
const char *section, char *key, char *value, void *data)
{
struct _alpm_hook_cb_ctx *ctx = data;
alpm_handle_t *handle = ctx->handle;
struct _alpm_hook_t *hook = ctx->hook;
#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) {
error(_("error while reading hook %s: %s\n"), file, strerror(errno));
} else if(!section) {
error(_("hook %s line %d: invalid option %s\n"), file, line, key);
} else if(!key) {
/* beginning a new section */
if(strcmp(section, "Trigger") == 0) {
struct _alpm_trigger_t *t;
CALLOC(t, sizeof(struct _alpm_trigger_t), 1, return 1);
hook->triggers = alpm_list_add(hook->triggers, t);
} else if(strcmp(section, "Action") == 0) {
/* no special processing required */
} else {
error(_("hook %s line %d: invalid section %s\n"), file, line, section);
}
} else if(strcmp(section, "Trigger") == 0) {
struct _alpm_trigger_t *t = hook->triggers->prev->data;
if(strcmp(key, "Operation") == 0) {
if(strcmp(value, "Install") == 0) {
t->op |= ALPM_HOOK_OP_INSTALL;
} else if(strcmp(value, "Upgrade") == 0) {
t->op |= ALPM_HOOK_OP_UPGRADE;
} else if(strcmp(value, "Remove") == 0) {
t->op |= ALPM_HOOK_OP_REMOVE;
} else {
error(_("hook %s line %d: invalid value %s\n"), file, line, value);
}
} 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) {
t->type = ALPM_HOOK_TYPE_PACKAGE;
} else if(strcmp(value, "File") == 0) {
t->type = ALPM_HOOK_TYPE_FILE;
} else {
error(_("hook %s line %d: invalid value %s\n"), file, line, value);
}
} else if(strcmp(key, "Target") == 0) {
char *val;
STRDUP(val, value, return 1);
t->targets = alpm_list_add(t->targets, val);
} else {
error(_("hook %s line %d: invalid option %s\n"), file, line, key);
}
} else if(strcmp(section, "Action") == 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) {
hook->when = ALPM_HOOK_PRE_TRANSACTION;
} else if(strcmp(value, "PostTransaction") == 0) {
hook->when = ALPM_HOOK_POST_TRANSACTION;
} else {
error(_("hook %s line %d: invalid value %s\n"), file, line, value);
}
} 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);
} else if(strcmp(key, "Depends") == 0) {
char *val;
STRDUP(val, value, return 1);
hook->depends = alpm_list_add(hook->depends, val);
} else if(strcmp(key, "AbortOnFail") == 0) {
hook->abort_on_fail = 1;
} else if(strcmp(key, "NeedsTargets") == 0) {
hook->needs_targets = 1;
} 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(errno == EINVAL) {
error(_("hook %s line %d: invalid value %s\n"), file, line, value);
} else {
error(_("hook %s line %d: unable to set option (%s)\n"),
file, line, strerror(errno));
}
}
} else {
error(_("hook %s line %d: invalid option %s\n"), file, line, key);
}
}
#undef error
#undef warning
return 0;
}
static int _alpm_hook_trigger_match_file(alpm_handle_t *handle,
struct _alpm_hook_t *hook, struct _alpm_trigger_t *t)
{
alpm_list_t *i, *j, *install = NULL, *upgrade = NULL, *remove = NULL;
size_t isize = 0, rsize = 0;
int ret = 0;
/* check if file will be installed */
for(i = handle->trans->add; i; i = i->next) {
alpm_pkg_t *pkg = i->data;
alpm_filelist_t filelist = pkg->files;
size_t f;
for(f = 0; f < filelist.count; f++) {
if(alpm_option_match_noextract(handle, filelist.files[f].name) == 0) {
continue;
}
if(_alpm_fnmatch_patterns(t->targets, filelist.files[f].name) == 0) {
install = alpm_list_add(install, filelist.files[f].name);
isize++;
}
}
}
/* check if file will be removed due to package upgrade */
for(i = handle->trans->add; i; i = i->next) {
alpm_pkg_t *spkg = i->data;
alpm_pkg_t *pkg = spkg->oldpkg;
if(pkg) {
alpm_filelist_t filelist = pkg->files;
size_t f;
for(f = 0; f < filelist.count; f++) {
if(_alpm_fnmatch_patterns(t->targets, filelist.files[f].name) == 0) {
remove = alpm_list_add(remove, filelist.files[f].name);
rsize++;
}
}
}
}
/* check if file will be removed due to package removal */
for(i = handle->trans->remove; i; i = i->next) {
alpm_pkg_t *pkg = i->data;
alpm_filelist_t filelist = pkg->files;
size_t f;
for(f = 0; f < filelist.count; f++) {
if(_alpm_fnmatch_patterns(t->targets, filelist.files[f].name) == 0) {
remove = alpm_list_add(remove, filelist.files[f].name);
rsize++;
}
}
}
i = install = alpm_list_msort(install, isize, (alpm_list_fn_cmp)strcmp);
j = remove = alpm_list_msort(remove, rsize, (alpm_list_fn_cmp)strcmp);
while(i) {
while(j && strcmp(i->data, j->data) > 0) {
j = j->next;
}
if(j == NULL) {
break;
}
if(strcmp(i->data, j->data) == 0) {
char *path = i->data;
upgrade = alpm_list_add(upgrade, path);
while(i && strcmp(i->data, path) == 0) {
alpm_list_t *next = i->next;
install = alpm_list_remove_item(install, i);
free(i);
i = next;
}
while(j && strcmp(j->data, path) == 0) {
alpm_list_t *next = j->next;
remove = alpm_list_remove_item(remove, j);
free(j);
j = next;
}
} else {
i = i->next;
}
}
ret = (t->op & ALPM_HOOK_OP_INSTALL && install)
|| (t->op & ALPM_HOOK_OP_UPGRADE && upgrade)
|| (t->op & ALPM_HOOK_OP_REMOVE && remove);
if(hook->needs_targets) {
#define _save_matches(_op, _matches) \
if(t->op & _op && _matches) { \
hook->matches = alpm_list_join(hook->matches, _matches); \
} else { \
alpm_list_free(_matches); \
}
_save_matches(ALPM_HOOK_OP_INSTALL, install);
_save_matches(ALPM_HOOK_OP_UPGRADE, upgrade);
_save_matches(ALPM_HOOK_OP_REMOVE, remove);
#undef _save_matches
} else {
alpm_list_free(install);
alpm_list_free(upgrade);
alpm_list_free(remove);
}
return ret;
}
static int _alpm_hook_trigger_match_pkg(alpm_handle_t *handle,
struct _alpm_hook_t *hook, struct _alpm_trigger_t *t)
{
alpm_list_t *install = NULL, *upgrade = NULL, *remove = NULL;
if(t->op & ALPM_HOOK_OP_INSTALL || t->op & ALPM_HOOK_OP_UPGRADE) {
alpm_list_t *i;
for(i = handle->trans->add; i; i = i->next) {
alpm_pkg_t *pkg = i->data;
if(_alpm_fnmatch_patterns(t->targets, pkg->name) == 0) {
if(pkg->oldpkg) {
if(t->op & ALPM_HOOK_OP_UPGRADE) {
if(hook->needs_targets) {
upgrade = alpm_list_add(upgrade, pkg->name);
} else {
return 1;
}
}
} else {
if(t->op & ALPM_HOOK_OP_INSTALL) {
if(hook->needs_targets) {
install = alpm_list_add(install, pkg->name);
} else {
return 1;
}
}
}
}
}
}
if(t->op & ALPM_HOOK_OP_REMOVE) {
alpm_list_t *i;
for(i = handle->trans->remove; i; i = i->next) {
alpm_pkg_t *pkg = i->data;
if(pkg && _alpm_fnmatch_patterns(t->targets, pkg->name) == 0) {
if(!alpm_list_find(handle->trans->add, pkg, _alpm_pkg_cmp)) {
if(hook->needs_targets) {
remove = alpm_list_add(remove, pkg->name);
} else {
return 1;
}
}
}
}
}
/* if we reached this point we either need the target lists or we didn't
* match anything and the following calls will all be no-ops */
hook->matches = alpm_list_join(hook->matches, install);
hook->matches = alpm_list_join(hook->matches, upgrade);
hook->matches = alpm_list_join(hook->matches, remove);
return install || upgrade || remove;
}
static int _alpm_hook_trigger_match(alpm_handle_t *handle,
struct _alpm_hook_t *hook, struct _alpm_trigger_t *t)
{
return t->type == ALPM_HOOK_TYPE_PACKAGE
? _alpm_hook_trigger_match_pkg(handle, hook, t)
: _alpm_hook_trigger_match_file(handle, hook, t);
}
static int _alpm_hook_triggered(alpm_handle_t *handle, struct _alpm_hook_t *hook)
{
alpm_list_t *i;
int ret = 0;
for(i = hook->triggers; i; i = i->next) {
if(_alpm_hook_trigger_match(handle, hook, i->data)) {
if(!hook->needs_targets) {
return 1;
} else {
ret = 1;
}
}
}
return ret;
}
static int _alpm_hook_cmp(struct _alpm_hook_t *h1, struct _alpm_hook_t *h2)
{
return strcmp(h1->name, h2->name);
}
static alpm_list_t *find_hook(alpm_list_t *haystack, const void *needle)
{
while(haystack) {
struct _alpm_hook_t *h = haystack->data;
if(h && strcmp(h->name, needle) == 0) {
return haystack;
}
haystack = haystack->next;
}
return NULL;
}
static ssize_t _alpm_hook_feed_targets(char *buf, ssize_t needed, alpm_list_t **pos)
{
size_t remaining = needed, written = 0;;
size_t len;
while(*pos && (len = strlen((*pos)->data)) + 1 <= remaining) {
memcpy(buf, (*pos)->data, len);
buf[len++] = '\n';
*pos = (*pos)->next;
buf += len;
remaining -= len;
written += len;
}
if(*pos && remaining) {
memcpy(buf, (*pos)->data, remaining);
(*pos)->data = (char*) (*pos)->data + remaining;
written += remaining;
}
return written;
}
static alpm_list_t *_alpm_strlist_dedup(alpm_list_t *list)
{
alpm_list_t *i = list;
while(i) {
alpm_list_t *next = i->next;
while(next && strcmp(i->data, next->data) == 0) {
list = alpm_list_remove_item(list, next);
free(next);
next = i->next;
}
i = next;
}
return list;
}
static int _alpm_hook_run_hook(alpm_handle_t *handle, struct _alpm_hook_t *hook)
{
alpm_list_t *i, *pkgs = _alpm_db_get_pkgcache(handle->db_local);
for(i = hook->depends; i; i = i->next) {
if(!alpm_find_satisfier(pkgs, i->data)) {
_alpm_log(handle, ALPM_LOG_ERROR, _("unable to run hook %s: %s\n"),
hook->name, _("could not satisfy dependencies"));
return -1;
}
}
if(hook->needs_targets) {
alpm_list_t *ctx;
hook->matches = alpm_list_msort(hook->matches,
alpm_list_count(hook->matches), (alpm_list_fn_cmp)strcmp);
/* hooks with multiple triggers could have duplicate matches */
ctx = hook->matches = _alpm_strlist_dedup(hook->matches);
return _alpm_run_chroot(handle, hook->cmd[0], hook->cmd,
(_alpm_cb_io) _alpm_hook_feed_targets, &ctx);
} else {
return _alpm_run_chroot(handle, hook->cmd[0], hook->cmd, NULL, NULL);
}
}
int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
{
alpm_event_hook_t event = { .when = when };
alpm_event_hook_run_t hook_event;
alpm_list_t *i, *hooks = NULL, *hooks_triggered = NULL;
const char *suffix = ".hook";
size_t suflen = strlen(suffix), triggered = 0;
int ret = 0;
for(i = alpm_list_last(handle->hookdirs); i; i = alpm_list_previous(i)) {
char path[PATH_MAX];
size_t dirlen;
struct dirent *entry;
DIR *d;
if((dirlen = strlen(i->data)) >= PATH_MAX) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not open directory: %s: %s\n"),
(char *)i->data, strerror(ENAMETOOLONG));
ret = -1;
continue;
}
memcpy(path, i->data, dirlen + 1);
if(!(d = opendir(path))) {
if(errno == ENOENT) {
continue;
} else {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not open directory: %s: %s\n"), path, strerror(errno));
ret = -1;
continue;
}
}
while((errno = 0, entry = readdir(d))) {
struct _alpm_hook_cb_ctx ctx = { handle, NULL };
struct stat buf;
size_t name_len;
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
continue;
}
if((name_len = strlen(entry->d_name)) >= PATH_MAX - dirlen) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not open file: %s%s: %s\n"),
path, entry->d_name, strerror(ENAMETOOLONG));
ret = -1;
continue;
}
memcpy(path + dirlen, entry->d_name, name_len + 1);
if(name_len < suflen
|| strcmp(entry->d_name + name_len - suflen, suffix) != 0) {
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping non-hook file %s\n", path);
continue;
}
if(find_hook(hooks, entry->d_name)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping overridden hook %s\n", path);
continue;
}
if(stat(path, &buf) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not stat file %s: %s\n"), path, strerror(errno));
ret = -1;
continue;
}
if(S_ISDIR(buf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "skipping directory %s\n", path);
continue;
}
CALLOC(ctx.hook, sizeof(struct _alpm_hook_t), 1,
ret = -1; closedir(d); goto cleanup);
_alpm_log(handle, ALPM_LOG_DEBUG, "parsing hook file %s\n", path);
if(parse_ini(path, _alpm_hook_parse_cb, &ctx) != 0
|| _alpm_hook_validate(handle, ctx.hook, path)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "parsing hook file %s failed\n", path);
_alpm_hook_free(ctx.hook);
ret = -1;
continue;
}
STRDUP(ctx.hook->name, entry->d_name, ret = -1; closedir(d); goto cleanup);
hooks = alpm_list_add(hooks, ctx.hook);
}
if(errno != 0) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not read directory: %s: %s\n"),
(char *) i->data, strerror(errno));
ret = -1;
}
closedir(d);
}
if(ret != 0 && when == ALPM_HOOK_PRE_TRANSACTION) {
goto cleanup;
}
hooks = alpm_list_msort(hooks, alpm_list_count(hooks),
(alpm_list_fn_cmp)_alpm_hook_cmp);
for(i = hooks; i; i = i->next) {
struct _alpm_hook_t *hook = i->data;
if(hook && hook->when == when && _alpm_hook_triggered(handle, hook)) {
hooks_triggered = alpm_list_add(hooks_triggered, hook);
triggered++;
}
}
if(hooks_triggered != NULL) {
event.type = ALPM_EVENT_HOOK_START;
EVENT(handle, (void *)&event);
hook_event.position = 1;
hook_event.total = triggered;
for(i = hooks_triggered; i; i = i->next, hook_event.position++) {
struct _alpm_hook_t *hook = i->data;
alpm_logaction(handle, ALPM_CALLER_PREFIX, "running '%s'...\n", hook->name);
hook_event.type = ALPM_EVENT_HOOK_RUN_START;
hook_event.name = hook->name;
hook_event.desc = hook->desc;
EVENT(handle, &hook_event);
if(_alpm_hook_run_hook(handle, hook) != 0 && hook->abort_on_fail) {
ret = -1;
}
hook_event.type = ALPM_EVENT_HOOK_RUN_DONE;
EVENT(handle, &hook_event);
if(ret != 0 && when == ALPM_HOOK_PRE_TRANSACTION) {
break;
}
}
alpm_list_free(hooks_triggered);
event.type = ALPM_EVENT_HOOK_DONE;
EVENT(handle, (void *)&event);
}
cleanup:
alpm_list_free_inner(hooks, (alpm_list_fn_free) _alpm_hook_free);
alpm_list_free(hooks);
return ret;
}

27
lib/libalpm/hook.h Normal file
View File

@@ -0,0 +1,27 @@
/*
* hook.h
*
* Copyright (c) 2015-2018 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/>.
*/
#ifndef ALPM_HOOK_H
#define ALPM_HOOK_H
#include "alpm.h"
int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when);
#endif /* ALPM_HOOK_H */

1
lib/libalpm/ini.c Symbolic link
View File

@@ -0,0 +1 @@
../../src/common/ini.c

1
lib/libalpm/ini.h Symbolic link
View File

@@ -0,0 +1 @@
../../src/common/ini.h

View File

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

View File

@@ -1,10 +1,10 @@
#ifndef _LIBARCHIVE_COMPAT_H
#define _LIBARCHIVE_COMPAT_H
#ifndef LIBARCHIVE_COMPAT_H
#define LIBARCHIVE_COMPAT_H
/*
* libarchive-compat.h
*
* Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2013-2018 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
@@ -68,6 +68,4 @@ static inline int _alpm_archive_read_support_filter_all(struct archive *archive)
#endif
}
#endif /* _LIBARCHIVE_COMPAT_H */
/* vim: set noet: */
#endif /* LIBARCHIVE_COMPAT_H */

View File

@@ -1,7 +1,7 @@
/*
* log.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <syslog.h>
/* libalpm */
#include "log.h"
@@ -33,6 +34,17 @@
* @{
*/
static int _alpm_log_leader(FILE *f, const char *prefix)
{
time_t t = time(NULL);
struct tm *tm = localtime(&t);
/* Use ISO-8601 date format */
return fprintf(f, "[%04d-%02d-%02d %02d:%02d] [%s] ",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, prefix);
}
/** A printf-like function for logging.
* @param handle the context handle
* @param prefix caller-specific prefix for the log
@@ -42,23 +54,24 @@
int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix,
const char *fmt, ...)
{
int ret;
int ret = 0;
va_list args;
ASSERT(handle != NULL, return -1);
if(!(prefix && *prefix)) {
prefix = "UNKNOWN";
}
/* check if the logstream is open already, opening it if needed */
if(handle->logstream == NULL) {
if(handle->logstream == NULL && handle->logfile != NULL) {
int fd;
do {
fd = open(handle->logfile, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC,
0644);
} while(fd == -1 && errno == EINTR);
if(fd >= 0) {
handle->logstream = fdopen(fd, "a");
}
/* if we couldn't open it, we have an issue */
if(fd < 0 || handle->logstream == NULL) {
if(fd < 0 || (handle->logstream = fdopen(fd, "a")) == NULL) {
if(errno == EACCES) {
handle->pm_errno = ALPM_ERR_BADPERMS;
} else if(errno == ENOENT) {
@@ -66,14 +79,31 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix,
} else {
handle->pm_errno = ALPM_ERR_SYSTEM;
}
return -1;
ret = -1;
}
}
va_start(args, fmt);
ret = _alpm_logaction(handle, prefix, fmt, args);
va_end(args);
if(handle->usesyslog) {
/* we can't use a va_list more than once, so we need to copy it
* so we can use the original when calling vfprintf below. */
va_list args_syslog;
va_copy(args_syslog, args);
vsyslog(LOG_WARNING, fmt, args_syslog);
va_end(args_syslog);
}
if(handle->logstream) {
if(_alpm_log_leader(handle->logstream, prefix) < 0
|| vfprintf(handle->logstream, fmt, args) < 0) {
ret = -1;
handle->pm_errno = ALPM_ERR_SYSTEM;
}
fflush(handle->logstream);
}
va_end(args);
return ret;
}
@@ -91,5 +121,3 @@ void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag, const char *fmt, ...
handle->logcb(flag, fmt, args);
va_end(args);
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* log.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 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 _ALPM_LOG_H
#define _ALPM_LOG_H
#ifndef ALPM_LOG_H
#define ALPM_LOG_H
#include "alpm.h"
@@ -27,6 +27,4 @@
void _alpm_log(alpm_handle_t *handle, alpm_loglevel_t flag,
const char *fmt, ...) __attribute__((format(printf,3,4)));
#endif /* _ALPM_LOG_H */
/* vim: set noet: */
#endif /* ALPM_LOG_H */

View File

@@ -1,333 +0,0 @@
/*
* 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 );
}

View File

@@ -1,60 +0,0 @@
/*
* 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,7 +1,7 @@
/*
* package.c
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* 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;
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
/* We only inspect packages from sync repositories */
ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
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);
if(retval == 0) {
return 0;
} else if(retval == 1) {
FREE(fpath);
if(retval == 1) {
pkg->handle->pm_errno = ALPM_ERR_PKG_INVALID;
retval = -1;
}
@@ -83,6 +83,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
* backend logic that needs lazy access, such as the local database through
* a lazy-load cache. However, the defaults will work just fine for fully-
* populated package structures. */
static const char *_pkg_get_base(alpm_pkg_t *pkg) { return pkg->base; }
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
@@ -91,13 +92,15 @@ 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 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_pkgvalidation_t _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
static int _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
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_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_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_provides(alpm_pkg_t *pkg) { return pkg->provides; }
static alpm_list_t *_pkg_get_replaces(alpm_pkg_t *pkg) { return pkg->replaces; }
@@ -144,6 +147,7 @@ static int _pkg_force_load(alpm_pkg_t UNUSED *pkg) { return 0; }
* struct itself with no abstraction layer or any type of lazy loading.
*/
struct pkg_operations default_pkg_ops = {
.get_base = _pkg_get_base,
.get_desc = _pkg_get_desc,
.get_url = _pkg_get_url,
.get_builddate = _pkg_get_builddate,
@@ -159,6 +163,8 @@ struct pkg_operations default_pkg_ops = {
.get_groups = _pkg_get_groups,
.get_depends = _pkg_get_depends,
.get_optdepends = _pkg_get_optdepends,
.get_checkdepends = _pkg_get_checkdepends,
.get_makedepends = _pkg_get_makedepends,
.get_conflicts = _pkg_get_conflicts,
.get_provides = _pkg_get_provides,
.get_replaces = _pkg_get_replaces,
@@ -182,189 +188,210 @@ struct pkg_operations default_pkg_ops = {
const char SYMEXPORT *alpm_pkg_get_filename(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->filename;
}
const char SYMEXPORT *alpm_pkg_get_base(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_base(pkg);
}
const char SYMEXPORT *alpm_pkg_get_name(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->name;
}
const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->version;
}
alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->origin;
}
const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_desc(pkg);
}
const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_url(pkg);
}
alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_builddate(pkg);
}
alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_installdate(pkg);
}
const char SYMEXPORT *alpm_pkg_get_packager(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_packager(pkg);
}
const char SYMEXPORT *alpm_pkg_get_md5sum(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->md5sum;
}
const char SYMEXPORT *alpm_pkg_get_sha256sum(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->sha256sum;
}
const char SYMEXPORT *alpm_pkg_get_base64_sig(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->base64_sig;
}
const char SYMEXPORT *alpm_pkg_get_arch(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_arch(pkg);
}
off_t SYMEXPORT alpm_pkg_get_size(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->size;
}
off_t SYMEXPORT alpm_pkg_get_isize(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_isize(pkg);
}
alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_reason(pkg);
}
alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
int SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_validation(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_licenses(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_groups(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_groups(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_depends(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_depends(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_optdepends(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
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)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_conflicts(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_provides(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_provides(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_replaces(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_deltas(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->deltas;
}
alpm_filelist_t SYMEXPORT *alpm_pkg_get_files(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_files(pkg);
}
alpm_list_t SYMEXPORT *alpm_pkg_get_backup(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->get_backup(pkg);
}
@@ -373,7 +400,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
/* Sanity checks */
ASSERT(pkg != NULL, return NULL);
ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->origin_data.db;
}
@@ -382,7 +409,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
void SYMEXPORT *alpm_pkg_changelog_open(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->changelog_open(pkg);
}
@@ -391,7 +418,7 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size,
const alpm_pkg_t *pkg, void *fp)
{
ASSERT(pkg != NULL, return 0);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->changelog_read(ptr, size, pkg, fp);
}
@@ -399,7 +426,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)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->changelog_close(pkg, fp);
}
@@ -407,7 +434,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)
{
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->mtree_open(pkg);
}
@@ -416,7 +443,7 @@ int SYMEXPORT alpm_pkg_mtree_next(const alpm_pkg_t * pkg, struct archive *archiv
struct archive_entry **entry)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->mtree_next(pkg, archive, entry);
}
@@ -424,14 +451,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)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->mtree_close(pkg, archive);
}
int SYMEXPORT alpm_pkg_has_scriptlet(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
return pkg->ops->has_scriptlet(pkg);
}
@@ -439,7 +466,7 @@ static void find_requiredby(alpm_pkg_t *pkg, alpm_db_t *db, alpm_list_t **reqs,
int optional)
{
const alpm_list_t *i;
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
alpm_pkg_t *cachepkg = i->data;
@@ -469,7 +496,7 @@ static alpm_list_t *compute_requiredby(alpm_pkg_t *pkg, int optional)
alpm_db_t *db;
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
pkg->handle->pm_errno = ALPM_ERR_OK;
if(pkg->origin == ALPM_PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */
@@ -566,6 +593,7 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
newpkg->name_hash = pkg->name_hash;
STRDUP(newpkg->filename, pkg->filename, goto cleanup);
STRDUP(newpkg->base, pkg->base, goto cleanup);
STRDUP(newpkg->name, pkg->name, goto cleanup);
STRDUP(newpkg->version, pkg->version, goto cleanup);
STRDUP(newpkg->desc, pkg->desc, goto cleanup);
@@ -641,6 +669,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
}
FREE(pkg->filename);
FREE(pkg->base);
FREE(pkg->name);
FREE(pkg->version);
FREE(pkg->desc);
@@ -671,6 +700,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
alpm_list_free(pkg->deltas);
alpm_list_free(pkg->delta_path);
alpm_list_free(pkg->removes);
_alpm_pkg_free(pkg->oldpkg);
if(pkg->origin == ALPM_PKG_FROM_FILE) {
FREE(pkg->origin_data.file);
@@ -696,6 +726,8 @@ void _alpm_pkg_free_trans(alpm_pkg_t *pkg)
alpm_list_free(pkg->removes);
pkg->removes = NULL;
_alpm_pkg_free(pkg->oldpkg);
pkg->oldpkg = NULL;
}
/* Is spkg an upgrade for localpkg? */
@@ -773,5 +805,3 @@ int SYMEXPORT alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
return 0;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* package.h
*
* Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -21,8 +21,8 @@
* 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 _ALPM_PACKAGE_H
#define _ALPM_PACKAGE_H
#ifndef ALPM_PACKAGE_H
#define ALPM_PACKAGE_H
#include <sys/types.h> /* off_t */
@@ -37,12 +37,13 @@
/** Package operations struct. This struct contains function pointers to
* all methods used to access data in a package to allow for things such
* as lazy package intialization (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 stuct containing pointers to a specific
* implementation of these methods. Some backends may find using the
* defined default_pkg_ops struct to work just fine for their needs.
*/
struct pkg_operations {
const char *(*get_base) (alpm_pkg_t *);
const char *(*get_desc) (alpm_pkg_t *);
const char *(*get_url) (alpm_pkg_t *);
alpm_time_t (*get_builddate) (alpm_pkg_t *);
@@ -51,13 +52,15 @@ struct pkg_operations {
const char *(*get_arch) (alpm_pkg_t *);
off_t (*get_isize) (alpm_pkg_t *);
alpm_pkgreason_t (*get_reason) (alpm_pkg_t *);
alpm_pkgvalidation_t (*get_validation) (alpm_pkg_t *);
int (*get_validation) (alpm_pkg_t *);
int (*has_scriptlet) (alpm_pkg_t *);
alpm_list_t *(*get_licenses) (alpm_pkg_t *);
alpm_list_t *(*get_groups) (alpm_pkg_t *);
alpm_list_t *(*get_depends) (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_provides) (alpm_pkg_t *);
alpm_list_t *(*get_replaces) (alpm_pkg_t *);
@@ -85,6 +88,7 @@ extern struct pkg_operations default_pkg_ops;
struct __alpm_pkg_t {
unsigned long name_hash;
char *filename;
char *base;
char *name;
char *version;
char *desc;
@@ -110,11 +114,14 @@ struct __alpm_pkg_t {
alpm_list_t *backup;
alpm_list_t *depends;
alpm_list_t *optdepends;
alpm_list_t *checkdepends;
alpm_list_t *makedepends;
alpm_list_t *conflicts;
alpm_list_t *provides;
alpm_list_t *deltas;
alpm_list_t *delta_path;
alpm_list_t *removes; /* in transaction targets only */
alpm_pkg_t *oldpkg; /* in transaction targets only */
struct pkg_operations *ops;
@@ -127,11 +134,14 @@ struct __alpm_pkg_t {
char *file;
} origin_data;
alpm_dbinfrq_t infolevel;
alpm_pkgvalidation_t validation;
alpm_pkgfrom_t origin;
alpm_pkgreason_t reason;
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);
@@ -142,14 +152,12 @@ void _alpm_pkg_free(alpm_pkg_t *pkg);
void _alpm_pkg_free_trans(alpm_pkg_t *pkg);
int _alpm_pkg_validate_internal(alpm_handle_t *handle,
const char *pkgfile, alpm_pkg_t *syncpkg, alpm_siglevel_t level,
alpm_siglist_t **sigdata, alpm_pkgvalidation_t *validation);
const char *pkgfile, alpm_pkg_t *syncpkg, int level,
alpm_siglist_t **sigdata, int *validation);
alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
const char *pkgfile, int full);
int _alpm_pkg_cmp(const void *p1, const void *p2);
int _alpm_pkg_compare_versions(alpm_pkg_t *local_pkg, alpm_pkg_t *pkg);
#endif /* _ALPM_PACKAGE_H */
/* vim: set noet: */
#endif /* ALPM_PACKAGE_H */

View File

@@ -1,7 +1,7 @@
/*
* pkghash.c
*
* Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2011-2018 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
@@ -66,7 +66,7 @@ alpm_pkghash_t *_alpm_pkghash_create(unsigned int size)
CALLOC(hash, 1, sizeof(alpm_pkghash_t), return NULL);
size = size / initial_hash_load + 1;
loopsize = sizeof(prime_list) / sizeof(*prime_list);
loopsize = ARRAYSIZE(prime_list);
for(i = 0; i < loopsize; i++) {
if(prime_list[i] > size) {
hash->buckets = prime_list[i];
@@ -132,8 +132,7 @@ static alpm_pkghash_t *rehash(alpm_pkghash_t *oldhash)
newhash = _alpm_pkghash_create(newsize);
if(newhash == NULL) {
/* creation of newhash failed, stick with old one... */
return oldhash;
return NULL;
}
newhash->list = oldhash->list;
@@ -156,23 +155,29 @@ static alpm_pkghash_t *rehash(alpm_pkghash_t *oldhash)
return newhash;
}
static alpm_pkghash_t *pkghash_add_pkg(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
static alpm_pkghash_t *pkghash_add_pkg(alpm_pkghash_t **hashref, alpm_pkg_t *pkg,
int sorted)
{
alpm_list_t *ptr;
unsigned int position;
alpm_pkghash_t *hash;
if(pkg == NULL || hash == NULL) {
return hash;
if(pkg == NULL || hashref == NULL || *hashref == NULL) {
return NULL;
}
hash = *hashref;
if(hash->entries >= hash->limit) {
hash = rehash(hash);
if((hash = rehash(hash)) == NULL) {
/* resizing failed and there are no more open buckets */
return NULL;
}
*hashref = hash;
}
position = get_hash_position(pkg->name_hash, hash);
MALLOC(ptr, sizeof(alpm_list_t), return hash);
MALLOC(ptr, sizeof(alpm_list_t), return NULL);
ptr->data = pkg;
ptr->prev = ptr;
@@ -189,12 +194,12 @@ static alpm_pkghash_t *pkghash_add_pkg(alpm_pkghash_t *hash, alpm_pkg_t *pkg,
return hash;
}
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg)
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t **hash, alpm_pkg_t *pkg)
{
return pkghash_add_pkg(hash, pkg, 0);
}
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg)
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t **hash, alpm_pkg_t *pkg)
{
return pkghash_add_pkg(hash, pkg, 1);
}
@@ -344,5 +349,3 @@ alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name)
return NULL;
}
/* vim: set noet: */

View File

@@ -1,7 +1,7 @@
/*
* pkghash.h
*
* Copyright (c) 2011-2014 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2011-2018 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
@@ -17,8 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ALPM_PKGHASH_H
#define _ALPM_PKGHASH_H
#ifndef ALPM_PKGHASH_H
#define ALPM_PKGHASH_H
#include <stdlib.h>
@@ -49,12 +49,12 @@ typedef struct __alpm_pkghash_t alpm_pkghash_t;
alpm_pkghash_t *_alpm_pkghash_create(unsigned int size);
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t *hash, alpm_pkg_t *pkg);
alpm_pkghash_t *_alpm_pkghash_add(alpm_pkghash_t **hash, alpm_pkg_t *pkg);
alpm_pkghash_t *_alpm_pkghash_add_sorted(alpm_pkghash_t **hash, alpm_pkg_t *pkg);
alpm_pkghash_t *_alpm_pkghash_remove(alpm_pkghash_t *hash, alpm_pkg_t *pkg, alpm_pkg_t **data);
void _alpm_pkghash_free(alpm_pkghash_t *hash);
alpm_pkg_t *_alpm_pkghash_find(alpm_pkghash_t *hash, const char *name);
#endif /* _ALPM_PKGHASH_H */
#endif /* ALPM_PKGHASH_H */

View File

@@ -1,13 +1,19 @@
# Set of available languages.
ar
ast
bg
br
ca
cs
da
de
el
en_GB
eo
es
es_419
eu
eu_ES
fi
fr
gl
@@ -18,7 +24,6 @@ it
ja
kk
ko
ko_KR
lt
nb
nl

View File

@@ -17,15 +17,18 @@ lib/libalpm/deps.c
lib/libalpm/diskspace.c
lib/libalpm/dload.c
lib/libalpm/error.c
lib/libalpm/filelist.c
lib/libalpm/graph.c
lib/libalpm/group.c
lib/libalpm/handle.c
lib/libalpm/hook.c
#lib/libalpm/ini.c
lib/libalpm/log.c
#lib/libalpm/md5.c
lib/libalpm/package.c
lib/libalpm/pkghash.c
#lib/libalpm/rawstr.c
lib/libalpm/remove.c
#lib/libalpm/sha2.c
lib/libalpm/signing.c
lib/libalpm/sync.c
lib/libalpm/trans.c
lib/libalpm/util.c

View File

@@ -9,15 +9,17 @@
# kraim <biskraim@gmail.com>, 2013
# Mosaab Alzoubi <moceap@hotmail.com>, 2013
# Mosaab Alzoubi <moceap@hotmail.com>, 2013
# Mutaz ismail <m3taz.ismail@gmail.com>, 2015
# سند <0otibi0@gmail.com>, 2013
# صفا الفليج <safaalfulaij@hotmail.com>, 2016-2017
msgid ""
msgstr ""
"Project-Id-Version: Arch Linux Pacman package manager\n"
"Report-Msgid-Bugs-To: http://bugs.archlinux.org/index.php?project=3\n"
"POT-Creation-Date: 2015-02-14 11:13+1000\n"
"PO-Revision-Date: 2014-11-18 05:16+0000\n"
"POT-Creation-Date: 2018-05-15 10:34+1000\n"
"PO-Revision-Date: 2018-05-15 01:05+0000\n"
"Last-Translator: Allan McRae <allan@archlinux.org>\n"
"Language-Team: Arabic (http://www.transifex.com/projects/p/archlinux-pacman/"
"Language-Team: Arabic (http://www.transifex.com/toofishes/archlinux-pacman/"
"language/ar/)\n"
"Language: ar\n"
"MIME-Version: 1.0\n"
@@ -29,39 +31,49 @@ msgstr ""
#: lib/libalpm/add.c:86
#, c-format
msgid "%s-%s is up to date -- skipping\n"
msgstr "%s-%s أحدث نسخة بالفعل -- يجري التجاوز\n"
msgstr "%s-%s محدّثة -- سأتجاوزها\n"
#: lib/libalpm/add.c:90
#, c-format
msgid "%s-%s is up to date -- reinstalling\n"
msgstr "%s-%s أحدث نسخة بالفعل -- تجري إعادة التثبيت\n"
msgstr "%s-%s محدّثة -- سأعيد تثبيتها\n"
#: lib/libalpm/add.c:95
#, c-format
msgid "downgrading package %s (%s => %s)\n"
msgstr "إعادة الحزمة إلى إصدار سابق %s (%s => %s)\n"
msgstr "سأُنزِل الحزمة %s (من %s إلى %s)\n"
#: lib/libalpm/add.c:122 lib/libalpm/util.c:379
#: lib/libalpm/add.c:124
#, c-format
msgid "cannot allocate disk archive object"
msgstr ""
#: lib/libalpm/add.c:138 lib/libalpm/util.c:382
#, c-format
msgid "warning given when extracting %s (%s)\n"
msgstr "تحذير عند الاستخراج %s (%s)\n"
#: lib/libalpm/add.c:125 lib/libalpm/util.c:382
#: lib/libalpm/add.c:141 lib/libalpm/util.c:385
#, c-format
msgid "could not extract %s (%s)\n"
msgstr "تعذر إستخراج %s (%s)\n"
msgstr "تعذّر استخراج %s (%s)\n"
#: lib/libalpm/add.c:138 lib/libalpm/dload.c:589 lib/libalpm/remove.c:536
#: lib/libalpm/add.c:154 lib/libalpm/dload.c:561 lib/libalpm/remove.c:541
#, c-format
msgid "could not rename %s to %s (%s)\n"
msgstr "تعذر إعادة تسمية %s إلى %s (%s)\n"
#: lib/libalpm/add.c:184
#: lib/libalpm/add.c:205
#, c-format
msgid "file not found in file list for package %s. skipping extraction of %s\n"
msgstr "لم يتم العثور على قائمة الملفات في الحزمة %s. تم تخطي الاستخراج %s\n"
#: lib/libalpm/add.c:214
#, c-format
msgid "unable to extract %s%s: path too long"
msgstr ""
#: lib/libalpm/add.c:232
#: lib/libalpm/add.c:256
#, c-format
msgid ""
"directory permissions differ on %s\n"
@@ -70,109 +82,116 @@ msgstr ""
"صلاحيات المجلد تختلف عن %s\n"
"نظام الملفات: %o الحزمة: %o\n"
#: lib/libalpm/add.c:247
#: lib/libalpm/add.c:271
#, c-format
msgid ""
"directory ownership differs on %s\n"
"filesystem: %u:%u package: %u:%u\n"
msgstr ""
"ملكية المجلد تختلف عن %s\n"
"ملفات النظام: %u:%u الحزمة: %u:%u\n"
#: lib/libalpm/add.c:263
#: lib/libalpm/add.c:287
#, c-format
msgid "extract: not overwriting dir with file %s\n"
msgstr "الاستخراج: عدم الكتابة فوق المجلد بالملف %s\n"
#: lib/libalpm/add.c:603 lib/libalpm/util.c:331 lib/libalpm/util.c:507
#: lib/libalpm/add.c:315
#, c-format
msgid "unable to extract %s.pacnew: path too long"
msgstr ""
#: lib/libalpm/add.c:508 lib/libalpm/util.c:334 lib/libalpm/util.c:573
#, c-format
msgid "could not get current working directory\n"
msgstr "غير قادر على جلب مجلد العمل الحالي\n"
#: lib/libalpm/add.c:608 lib/libalpm/util.c:336 lib/libalpm/util.c:512
#: lib/libalpm/util.c:553
#: lib/libalpm/add.c:513 lib/libalpm/util.c:339 lib/libalpm/util.c:578
#: lib/libalpm/util.c:631
#, c-format
msgid "could not change directory to %s (%s)\n"
msgstr "غير قادر على تحويل المجلد إلى %s (%s)\n"
#: lib/libalpm/add.c:647 lib/libalpm/util.c:400 lib/libalpm/util.c:624
#: lib/libalpm/add.c:570 lib/libalpm/util.c:403 lib/libalpm/util.c:738
#, c-format
msgid "could not restore working directory (%s)\n"
msgstr "تعذر استعادة مجلد العمل (%s)\n"
#: lib/libalpm/add.c:655
#: lib/libalpm/add.c:578
#, c-format
msgid "problem occurred while upgrading %s\n"
msgstr "حدثت مشكلة أثناء ترقية %s\n"
#: lib/libalpm/add.c:661
#: lib/libalpm/add.c:584
#, c-format
msgid "problem occurred while installing %s\n"
msgstr "حدثت مشكلة أثناء تثبيت %s\n"
#: lib/libalpm/add.c:677
#: lib/libalpm/add.c:599
#, c-format
msgid "could not update database entry %s-%s\n"
msgstr "غير قادر على تحديث مدخل قاعدة البيانات %s-%s\n"
#: lib/libalpm/add.c:688
#: lib/libalpm/add.c:610
#, c-format
msgid "could not add entry '%s' in cache\n"
msgstr "غير قادر على إضافة المدخل '%s' إلى المخبئيات\n"
#: lib/libalpm/be_local.c:249
#: lib/libalpm/be_local.c:255
#, c-format
msgid "error while reading file %s: %s\n"
msgstr "خطأ أثناء قراءة الملف %s: %s\n"
#: lib/libalpm/be_local.c:343
#: lib/libalpm/be_local.c:350
#, c-format
msgid "removing invalid database: %s\n"
msgstr "تجري إزالة قاعدة البيانات الغير صالحة: %s\n"
#: lib/libalpm/be_local.c:389 lib/libalpm/be_local.c:849
#: lib/libalpm/be_local.c:401 lib/libalpm/be_local.c:887
#, c-format
msgid "could not create directory %s: %s\n"
msgstr "غير قادر على إنشاء الدليل %s : %s\n"
#: lib/libalpm/be_local.c:559 lib/libalpm/be_sync.c:358
#: lib/libalpm/be_local.c:576 lib/libalpm/be_sync.c:387
#, c-format
msgid "invalid name for database entry '%s'\n"
msgstr "مدخل قاعدة بيانات غير صالح '%s'\n"
#: lib/libalpm/be_local.c:567
#: lib/libalpm/be_local.c:584
#, c-format
msgid "duplicated database entry '%s'\n"
msgstr "مدخل قاعدة بيانات مكرر '%s'\n"
#: lib/libalpm/be_local.c:579
#: lib/libalpm/be_local.c:596
#, c-format
msgid "corrupted database entry '%s'\n"
msgstr "مدخل قاعدة بيانات معطوب '%s'\n"
#: lib/libalpm/be_local.c:679 lib/libalpm/be_local.c:769
#: lib/libalpm/be_local.c:898 lib/libalpm/be_local.c:991
#: lib/libalpm/diskspace.c:131 lib/libalpm/dload.c:447 lib/libalpm/util.c:250
#: lib/libalpm/util.c:266
#: lib/libalpm/be_local.c:699 lib/libalpm/be_local.c:791
#: lib/libalpm/be_local.c:936 lib/libalpm/be_local.c:1033
#: lib/libalpm/diskspace.c:131 lib/libalpm/dload.c:419 lib/libalpm/util.c:253
#: lib/libalpm/util.c:269
#, c-format
msgid "could not open file %s: %s\n"
msgstr "غير قادر على فتح اللمف %s: %s\n"
#: lib/libalpm/be_local.c:695 lib/libalpm/be_sync.c:603
#: lib/libalpm/be_local.c:715 lib/libalpm/be_sync.c:653
#, c-format
msgid "%s database is inconsistent: name mismatch on package %s\n"
msgstr "%s قاعدة البيانات غير متناسقة : اسم الحزمة غير مطابق %s\n"
#: lib/libalpm/be_local.c:701 lib/libalpm/be_sync.c:609
#: lib/libalpm/be_local.c:721 lib/libalpm/be_sync.c:659
#, c-format
msgid "%s database is inconsistent: version mismatch on package %s\n"
msgstr "%s قاعدة البيانات غير متناسقة : إصدار الحزمة غير مطابق %s\n"
#: lib/libalpm/be_local.c:740
#: lib/libalpm/be_local.c:762
#, c-format
msgid "unknown validation type for package %s: %s\n"
msgstr "نوع التّحقق غير مألوف في الحزمة %s: %s\n"
#: lib/libalpm/be_package.c:479 lib/libalpm/be_package.c:625
#: lib/libalpm/be_package.c:638
#: lib/libalpm/be_package.c:479 lib/libalpm/be_package.c:637
#: lib/libalpm/be_package.c:650
#, c-format
msgid "error while reading package %s: %s\n"
msgstr "خطأ أثناء قراءة الحزمة %s: %s\n"
@@ -180,94 +199,99 @@ msgstr "خطأ أثناء قراءة الحزمة %s: %s\n"
#: lib/libalpm/be_package.c:493 lib/libalpm/be_package.c:517
#, c-format
msgid "error while reading mtree of package %s: %s\n"
msgstr ""
msgstr "خطأ أثناء قراءة mtree في الحزمة %s: %s\n"
#: lib/libalpm/be_package.c:588
#: lib/libalpm/be_package.c:603
#, c-format
msgid "could not parse package description file in %s\n"
msgstr "تعذّر تحليل ملف وصف الحزمة في %s\n"
#: lib/libalpm/be_package.c:593
#: lib/libalpm/be_package.c:608
#, c-format
msgid "missing package name in %s\n"
msgstr "اسم الحزمة مفقود في %s\n"
#: lib/libalpm/be_package.c:597
#: lib/libalpm/be_package.c:612
#, c-format
msgid "missing package version in %s\n"
msgstr "إصدارة الحزمة مفقودة في %s\n"
#: lib/libalpm/be_package.c:601
#: lib/libalpm/be_package.c:616
#, c-format
msgid "invalid package version in %s\n"
msgstr ""
msgstr "إصدارة الحزمة غير صالح في %s\n"
#: lib/libalpm/be_package.c:645
#: lib/libalpm/be_package.c:657
#, c-format
msgid "missing package metadata in %s\n"
msgstr "معلومات الحزمة مفقودة في %s\n"
#: lib/libalpm/be_package.c:734
#: lib/libalpm/be_package.c:748
#, c-format
msgid "failed to read signature file: %s\n"
msgstr "فشل في قراءة ملف التّوقيع: %s\n"
#: lib/libalpm/be_package.c:755 lib/libalpm/sync.c:1108
#: lib/libalpm/be_package.c:769 lib/libalpm/sync.c:1113
#, c-format
msgid "required key missing from keyring\n"
msgstr "مفتاح ضروري غير موجود في حلقة المفاتيح\n"
#: lib/libalpm/be_sync.c:61
#: lib/libalpm/be_sync.c:62
#, c-format
msgid "removing invalid file: %s\n"
msgstr "يجري حذف ملف غير صالح: %s\n"
#: lib/libalpm/be_sync.c:476
#: lib/libalpm/be_sync.c:517
#, c-format
msgid "could not parse package description file '%s' from db '%s'\n"
msgstr "تعذّر تحليل ملف وصف الحزمة '%s' من قاعدة البيانات '%s'\n"
#: lib/libalpm/be_sync.c:509 lib/libalpm/be_sync.c:514
#: lib/libalpm/be_sync.c:524
#, c-format
msgid "could not read db '%s' (%s)\n"
msgstr ""
#: lib/libalpm/be_sync.c:558 lib/libalpm/be_sync.c:563
#, c-format
msgid "%s database is inconsistent: filename of package %s is illegal\n"
msgstr "%s قاعدة البيانات غير متناسقة : اسم ملف الحزمة غير قانوني %s\n"
#: lib/libalpm/be_sync.c:519
#: lib/libalpm/be_sync.c:568
#, c-format
msgid "%s database is inconsistent: filename of package %s is too long\n"
msgstr "%s قاعدة البيانات غير متناسقة : اسم ملف الحزمة طويل جدًا %s\n"
#: lib/libalpm/be_sync.c:585
#: lib/libalpm/be_sync.c:634
#, c-format
msgid "unknown database file: %s\n"
msgstr ""
msgstr "ملف قاعدة البيانات مجهول : %s\n"
#: lib/libalpm/db.c:369
#: lib/libalpm/db.c:370
#, c-format
msgid "database path is undefined\n"
msgstr "مسار قاعدة البيانات غير معروف\n"
#: lib/libalpm/deps.c:218
#: lib/libalpm/deps.c:184
#, c-format
msgid "dependency cycle detected:\n"
msgstr "اكتشفت دورة اعتمادية:\n"
#: lib/libalpm/deps.c:221
#: lib/libalpm/deps.c:187
#, c-format
msgid "%s will be removed after its %s dependency\n"
msgstr "%s سيتم إزالتها بعد %s اعتمادياتها\n"
#: lib/libalpm/deps.c:225
#: lib/libalpm/deps.c:191
#, c-format
msgid "%s will be installed before its %s dependency\n"
msgstr "%s سيتم تثبيتها قبل %s اعتمادياتها\n"
#: lib/libalpm/deps.c:657 lib/libalpm/deps.c:689
#: lib/libalpm/deps.c:682 lib/libalpm/deps.c:712
#, c-format
msgid "ignoring package %s-%s\n"
msgstr "تجاهل الحزمة %s-%s\n"
#: lib/libalpm/deps.c:844
#: lib/libalpm/deps.c:867
#, c-format
msgid "cannot resolve \"%s\", a dependency of \"%s\"\n"
msgstr "تعذّر تحليل \"%s\"، اعتمادية لـ \"%s\"\n"
@@ -287,67 +311,72 @@ msgstr "تعذر فتح الملف: %s: %s\n"
msgid "could not get filesystem information\n"
msgstr "غير قادر على جلب معلومات نظام الملفات\n"
#: lib/libalpm/diskspace.c:249 lib/libalpm/diskspace.c:308
#: lib/libalpm/diskspace.c:242
#, c-format
msgid "could not get file information for %s\n"
msgstr ""
#: lib/libalpm/diskspace.c:256 lib/libalpm/diskspace.c:315
#, c-format
msgid "could not determine mount point for file %s\n"
msgstr "تعذّر تحديد نقطة الوصل من أجل الملف %s\n"
#: lib/libalpm/diskspace.c:347
#: lib/libalpm/diskspace.c:354
#, c-format
msgid "Partition %s too full: %jd blocks needed, %jd blocks free\n"
msgstr "القسم %s ممتلئ بالكامل: %jd كتل مطلوبة ، فقط %jd كتل حرّة\n"
msgid "Partition %s too full: %jd blocks needed, %ju blocks free\n"
msgstr ""
#: lib/libalpm/diskspace.c:372 lib/libalpm/diskspace.c:426
#: lib/libalpm/diskspace.c:379 lib/libalpm/diskspace.c:433
#, c-format
msgid "could not determine filesystem mount points\n"
msgstr "تعذّر تحديد نقاط وصل أنظمة الملفات\n"
#: lib/libalpm/diskspace.c:378
#: lib/libalpm/diskspace.c:385
#, c-format
msgid "could not determine cachedir mount point %s\n"
msgstr "تعذّر تحديد نقطة وصل مجلد المخبئيات %s\n"
#: lib/libalpm/diskspace.c:431
#: lib/libalpm/diskspace.c:438
#, c-format
msgid "could not determine root mount point %s\n"
msgstr "غير قادر على تحديد نقطة وصل الجذر %s\n"
#: lib/libalpm/diskspace.c:479
#: lib/libalpm/diskspace.c:486
#, c-format
msgid "Partition %s is mounted read only\n"
msgstr "القسم %s موصول بصفة القراءة فقط\n"
#: lib/libalpm/dload.c:149
#: lib/libalpm/dload.c:159
#, c-format
msgid "disk"
msgstr "القرص"
#: lib/libalpm/dload.c:373
#: lib/libalpm/dload.c:345
#, c-format
msgid "failed to create temporary file for download\n"
msgstr "غير قادر على إنشاء ملف مؤقت للتحميل\n"
#: lib/libalpm/dload.c:418
#: lib/libalpm/dload.c:390
#, c-format
msgid "url '%s' is invalid\n"
msgstr "العنوان '%s' غير صالح\n"
#: lib/libalpm/dload.c:487 lib/libalpm/dload.c:512
#: lib/libalpm/dload.c:459 lib/libalpm/dload.c:484
#, c-format
msgid "failed retrieving file '%s' from %s : %s\n"
msgstr "فشل في استقبال الملف '%s' من %s : %s\n"
#: lib/libalpm/dload.c:500
#: lib/libalpm/dload.c:472
#, c-format
msgid "failed retrieving file '%s' from %s : expected download size exceeded\n"
msgstr ""
msgstr "فشل في استقبال الملف '%s' من %s : تم تجاوز حجم التحميل\n"
#: lib/libalpm/dload.c:548
#: lib/libalpm/dload.c:520
#, c-format
msgid "%s appears to be truncated: %jd/%jd bytes\n"
msgstr "%s يبدو غير موثوقًا: %jd/%jd بايت\n"
#: lib/libalpm/dload.c:692 lib/libalpm/dload.c:721
#: lib/libalpm/dload.c:664 lib/libalpm/dload.c:693
#, c-format
msgid "failed to download %s\n"
msgstr "tag td jpldg %s\n"
@@ -497,142 +526,234 @@ msgstr "العملية غير متوافقة مع نوع المُبادلة"
msgid "transaction commit attempt when database is not locked"
msgstr "تتم محاولة بدء المُبادلة عند إلغاء قفل قاعدة البيانات"
#: lib/libalpm/error.c:105
#: lib/libalpm/error.c:104
#, c-format
msgid "failed to run transaction hooks"
msgstr ""
#: lib/libalpm/error.c:107
#, c-format
msgid "could not find or read package"
msgstr "غير قادر على إيجاد أو قراءة الحزمة"
#: lib/libalpm/error.c:107
#: lib/libalpm/error.c:109
#, c-format
msgid "operation cancelled due to ignorepkg"
msgstr "ألغيت العملية بسبب حزمة متجاهلة"
#: lib/libalpm/error.c:109
#: lib/libalpm/error.c:111
#, c-format
msgid "invalid or corrupted package"
msgstr "حزمة غير صالحة أو معطوبة"
#: lib/libalpm/error.c:111
#: lib/libalpm/error.c:113
#, c-format
msgid "invalid or corrupted package (checksum)"
msgstr "حزمة معطوبة أو غير صالحة (البصمة)"
#: lib/libalpm/error.c:113
#: lib/libalpm/error.c:115
#, c-format
msgid "invalid or corrupted package (PGP signature)"
msgstr "حزمة معطوبة أو غير صالحة (توقيع PGP)"
#: lib/libalpm/error.c:115
#: lib/libalpm/error.c:117
#, c-format
msgid "package missing required signature"
msgstr ""
msgstr "الحزمة مفقودة مطلوب توقيع"
#: lib/libalpm/error.c:117
#: lib/libalpm/error.c:119
#, c-format
msgid "cannot open package file"
msgstr "غير قادر على فتح ملف الحزمة"
#: lib/libalpm/error.c:119
#: lib/libalpm/error.c:121
#, c-format
msgid "cannot remove all files for package"
msgstr "غير قادر على مسح جميع ملفات الجزمة"
#: lib/libalpm/error.c:121
#: lib/libalpm/error.c:123
#, c-format
msgid "package filename is not valid"
msgstr "اسم ملف الحزمة غير سليم"
#: lib/libalpm/error.c:123
#: lib/libalpm/error.c:125
#, c-format
msgid "package architecture is not valid"
msgstr "معمارية الحزمة غير سليمة"
#: lib/libalpm/error.c:125
#: lib/libalpm/error.c:127
#, c-format
msgid "could not find repository for target"
msgstr "تعذّر العثور على المستودع الهدف"
#: lib/libalpm/error.c:128
#: lib/libalpm/error.c:130
#, c-format
msgid "missing PGP signature"
msgstr "توقيع PGP مفقود"
#: lib/libalpm/error.c:130
#: lib/libalpm/error.c:132
#, c-format
msgid "invalid PGP signature"
msgstr "توقيع PGP غير سليم"
#: lib/libalpm/error.c:133
#: lib/libalpm/error.c:135
#, c-format
msgid "invalid or corrupted delta"
msgstr "فروقات غير سليمة أو معطوبة"
#: lib/libalpm/error.c:135
#: lib/libalpm/error.c:137
#, c-format
msgid "delta patch failed"
msgstr "فشل تطبيق الفروقات"
#: lib/libalpm/error.c:138
#: lib/libalpm/error.c:140 lib/libalpm/hook.c:614
#, c-format
msgid "could not satisfy dependencies"
msgstr "غير قادر على استيفاء الاعتماديات"
#: lib/libalpm/error.c:140
#: lib/libalpm/error.c:142
#, c-format
msgid "conflicting dependencies"
msgstr "اعتماديات متضاربة"
#: lib/libalpm/error.c:142
#: lib/libalpm/error.c:144
#, c-format
msgid "conflicting files"
msgstr "ملفات متضاربة"
#: lib/libalpm/error.c:145
#: lib/libalpm/error.c:147
#, c-format
msgid "failed to retrieve some files"
msgstr "فشل في استقبال بعض الملفات"
#: lib/libalpm/error.c:147
#: lib/libalpm/error.c:149
#, c-format
msgid "invalid regular expression"
msgstr "تعبير غير نظامي"
#: lib/libalpm/error.c:153
#: lib/libalpm/error.c:155
#, c-format
msgid "libarchive error"
msgstr "خطا في مكتبة الارشيف"
#: lib/libalpm/error.c:155
#: lib/libalpm/error.c:157
#, c-format
msgid "download library error"
msgstr "خطأ في مكتبة التحميل"
#: lib/libalpm/error.c:157
#: lib/libalpm/error.c:159
#, c-format
msgid "gpgme error"
msgstr "خطأ gpgme"
#: lib/libalpm/error.c:159
#: lib/libalpm/error.c:161
#, c-format
msgid "error invoking external downloader"
msgstr "خطأ في استحضار المحمّل الخارجي"
#: lib/libalpm/error.c:162
#: lib/libalpm/error.c:164
#, c-format
msgid "unexpected error"
msgstr "خطأ غير متوقع"
#: lib/libalpm/handle.c:139
#: lib/libalpm/handle.c:157
#, c-format
msgid "lock file missing %s\n"
msgstr ""
msgstr "الملف المغلق مفقود %s\n"
#: lib/libalpm/handle.c:145
#: lib/libalpm/handle.c:163
#, c-format
msgid "could not remove lock file %s\n"
msgstr "تعذّر إزالة ملف القفل %s\n"
#: lib/libalpm/package.c:559
#: lib/libalpm/hook.c:107
#, c-format
msgid "Missing trigger targets in hook: %s\n"
msgstr ""
#: lib/libalpm/hook.c:113
#, c-format
msgid "Missing trigger type in hook: %s\n"
msgstr ""
#: lib/libalpm/hook.c:119
#, c-format
msgid "Missing trigger operation in hook: %s\n"
msgstr ""
#: lib/libalpm/hook.c:146
#, c-format
msgid "Missing Exec option in hook: %s\n"
msgstr ""
#: lib/libalpm/hook.c:152
#, c-format
msgid "Missing When option in hook: %s\n"
msgstr ""
#: lib/libalpm/hook.c:155
#, c-format
msgid "AbortOnFail set for PostTransaction hook: %s\n"
msgstr ""
#: lib/libalpm/hook.c:273
#, c-format
msgid "error while reading hook %s: %s\n"
msgstr ""
#: lib/libalpm/hook.c:275 lib/libalpm/hook.c:315 lib/libalpm/hook.c:357
#, c-format
msgid "hook %s line %d: invalid option %s\n"
msgstr ""
#: lib/libalpm/hook.c:285
#, c-format
msgid "hook %s line %d: invalid section %s\n"
msgstr ""
#: lib/libalpm/hook.c:297 lib/libalpm/hook.c:308 lib/libalpm/hook.c:327
#: lib/libalpm/hook.c:350
#, c-format
msgid "hook %s line %d: invalid value %s\n"
msgstr ""
#: lib/libalpm/hook.c:301 lib/libalpm/hook.c:320 lib/libalpm/hook.c:331
#: lib/libalpm/hook.c:345
#, c-format
msgid "hook %s line %d: overwriting previous definition of %s\n"
msgstr ""
#: lib/libalpm/hook.c:352
#, c-format
msgid "hook %s line %d: unable to set option (%s)\n"
msgstr ""
#: lib/libalpm/hook.c:613
#, c-format
msgid "unable to run hook %s: %s\n"
msgstr ""
#: lib/libalpm/hook.c:648 lib/libalpm/hook.c:660 lib/libalpm/remove.c:385
#, c-format
msgid "could not open directory: %s: %s\n"
msgstr "تعذّر فتح المجلد: %s: %s\n"
#: lib/libalpm/hook.c:676
#, c-format
msgid "could not open file: %s%s: %s\n"
msgstr ""
#: lib/libalpm/hook.c:696 lib/libalpm/util.c:259
#, c-format
msgid "could not stat file %s: %s\n"
msgstr "تعذّر إحصاء الملف %s: %s\n"
#: lib/libalpm/hook.c:722
#, c-format
msgid "could not read directory: %s: %s\n"
msgstr ""
#: lib/libalpm/package.c:586
#, c-format
msgid "could not fully load metadata for package %s-%s\n"
msgstr "غير قادر على استيراد معلومات الميتا للحزمة %s-%s\n"
@@ -647,33 +768,115 @@ msgstr "لم يعثر على %s في قاعدة البيانات -- يجري ا
msgid "removing %s from target list\n"
msgstr "يجري حذف %s من قائمة الأهداف\n"
#: lib/libalpm/remove.c:348
#: lib/libalpm/remove.c:345
#, c-format
msgid "cannot remove file '%s': %s\n"
msgstr ""
"تعذر إزالة الملف '%s': %s\n"
"\n"
#: lib/libalpm/remove.c:388
#: lib/libalpm/remove.c:410 lib/libalpm/remove.c:419
#, c-format
msgid "could not open directory: %s: %s\n"
msgstr "تعذّر فتح المجلد: %s: %s\n"
msgid "could not backup %s due to PATH_MAX overflow\n"
msgstr ""
#: lib/libalpm/remove.c:556
#: lib/libalpm/remove.c:561
#, c-format
msgid "cannot remove %s (%s)\n"
msgstr "تعذّر إزالة %s (%s)\n"
#: lib/libalpm/remove.c:727
#: lib/libalpm/remove.c:734
#, c-format
msgid "could not remove database entry %s-%s\n"
msgstr "تعذّر إزالة مدخل قاعدة البيانات %s-%s\n"
#: lib/libalpm/remove.c:732
#: lib/libalpm/remove.c:739
#, c-format
msgid "could not remove entry '%s' from cache\n"
msgstr "تعذر إزالة المدخل '%s' من المخبئيات\n"
#: lib/libalpm/signing.c:171
#, c-format
msgid "Public keyring not found; have you run '%s'?\n"
msgstr ""
#: lib/libalpm/signing.c:207 lib/libalpm/signing.c:705
#, c-format
msgid "GPGME error: %s\n"
msgstr ""
#: lib/libalpm/signing.c:402
#, c-format
msgid "keyring is not writable\n"
msgstr ""
#: lib/libalpm/signing.c:460
#, c-format
msgid "key \"%s\" could not be imported\n"
msgstr ""
#: lib/libalpm/signing.c:466
#, c-format
msgid "key %s, \"%s\" found on keyserver, keyring is not writable\n"
msgstr ""
#: lib/libalpm/signing.c:471
#, c-format
msgid "key \"%s\" could not be looked up remotely\n"
msgstr ""
#: lib/libalpm/signing.c:859 lib/libalpm/sync.c:1181
#, c-format
msgid "%s: missing required signature\n"
msgstr "التوقيع المطلوب مفقود :%s\n"
#: lib/libalpm/signing.c:874
#, c-format
msgid "%s: signature from \"%s\" is marginal trust\n"
msgstr ""
#: lib/libalpm/signing.c:882
#, c-format
msgid "%s: signature from \"%s\" is unknown trust\n"
msgstr ""
#: lib/libalpm/signing.c:889
#, c-format
msgid "%s: signature from \"%s\" should never be trusted\n"
msgstr ""
#: lib/libalpm/signing.c:901
#, c-format
msgid "%s: key \"%s\" is unknown\n"
msgstr ""
#: lib/libalpm/signing.c:910
#, c-format
msgid "%s: key \"%s\" is disabled\n"
msgstr ""
#: lib/libalpm/signing.c:914
#, c-format
msgid "%s: signature from \"%s\" is expired\n"
msgstr ""
#: lib/libalpm/signing.c:918
#, c-format
msgid "%s: signature from \"%s\" is invalid\n"
msgstr ""
#: lib/libalpm/signing.c:995 lib/libalpm/signing.c:1063
#: lib/libalpm/signing.c:1142
#, c-format
msgid "%s: signature format error\n"
msgstr ""
#: lib/libalpm/signing.c:1095 lib/libalpm/signing.c:1128
#: lib/libalpm/signing.c:1136
#, c-format
msgid "%s: unsupported signature format\n"
msgstr ""
#: lib/libalpm/sync.c:98
#, c-format
msgid "%s: ignoring package upgrade (%s => %s)\n"
@@ -704,119 +907,114 @@ msgstr "يجري تجاهل استبدال الحزمة (%s-%s => %s-%s)\n"
msgid "cannot replace %s by %s\n"
msgstr "تعذر استبدال %s بـ %s\n"
#: lib/libalpm/sync.c:536 lib/libalpm/sync.c:606
#: lib/libalpm/sync.c:538 lib/libalpm/sync.c:608
#, c-format
msgid "unresolvable package conflicts detected\n"
msgstr "حدثت تعارضات حزميّة تعذّر تحليلها\n"
#: lib/libalpm/sync.c:556
#: lib/libalpm/sync.c:558
#, c-format
msgid "removing '%s' from target list because it conflicts with '%s'\n"
msgstr " يجري حذف '%s' من قائمة الأهداف بسبب تعارضها مع '%s'\n"
#: lib/libalpm/sync.c:1014
#: lib/libalpm/sync.c:1019
#, c-format
msgid "failed to retrieve some files\n"
msgstr "تعذّر استقبال بعض الملفات\n"
#: lib/libalpm/sync.c:1176
#, c-format
msgid "%s: missing required signature\n"
msgstr ""
#: lib/libalpm/sync.c:1357
#: lib/libalpm/sync.c:1384
#, c-format
msgid "not enough free disk space\n"
msgstr "لا توجد مساحة خالية كافية على القرص\n"
#: lib/libalpm/sync.c:1370
#: lib/libalpm/sync.c:1406
#, c-format
msgid "could not commit removal transaction\n"
msgstr "تعذّر بدء مُبادلة الإزالة\n"
#: lib/libalpm/sync.c:1378
#: lib/libalpm/sync.c:1414
#, c-format
msgid "could not commit transaction\n"
msgstr "فشل في بدء المُبادلة\n"
#: lib/libalpm/trans.c:343
#: lib/libalpm/trans.c:364
#, c-format
msgid "could not create temp directory\n"
msgstr "تعذّر إنشاء مجلد مؤقت\n"
#: lib/libalpm/trans.c:358
#: lib/libalpm/trans.c:379
#, c-format
msgid "could not copy tempfile to %s (%s)\n"
msgstr "تعذّر نسخ الملف المؤقّت إلى %s (%s)\n"
#: lib/libalpm/trans.c:389
#: lib/libalpm/trans.c:410
#, c-format
msgid "could not remove %s\n"
msgstr ""
"تعذر إزالة %s\n"
"\n"
#: lib/libalpm/trans.c:393
#: lib/libalpm/trans.c:414
#, c-format
msgid "could not remove tmpdir %s\n"
msgstr "تعذّر إزالة المجلد المؤقّت %s\n"
#: lib/libalpm/util.c:256
#: lib/libalpm/util.c:486
#, c-format
msgid "could not stat file %s: %s\n"
msgstr "تعذّر إحصاء الملف %s: %s\n"
msgid "unable to write to pipe (%s)\n"
msgstr "تعذّرت الكتابة إلى الأنبوب (%s)\n"
#: lib/libalpm/util.c:524
#: lib/libalpm/util.c:545
#, c-format
msgid "unable to read from pipe (%s)\n"
msgstr "تعذّرت القراءة من الأنبوب (%s)\n"
#: lib/libalpm/util.c:590 lib/libalpm/util.c:596
#, c-format
msgid "could not create pipe (%s)\n"
msgstr "غير قادر على إنشاء العبارة (%s)\n"
#: lib/libalpm/util.c:532
#: lib/libalpm/util.c:604
#, c-format
msgid "could not fork a new process (%s)\n"
msgstr "تعذّر تفريع العملية إلى عملية جديدة (%s)\n"
#: lib/libalpm/util.c:549
#: lib/libalpm/util.c:627
#, c-format
msgid "could not change the root directory (%s)\n"
msgstr "تعذّر التعديل على مجلد الجذر (%s)\n"
#: lib/libalpm/util.c:560
#: lib/libalpm/util.c:638
#, c-format
msgid "call to execv failed (%s)\n"
msgstr "تعذّر مخاطبة execv (%s)\n"
#: lib/libalpm/util.c:590
#: lib/libalpm/util.c:709
#, c-format
msgid "call to waitpid failed (%s)\n"
msgstr "تعذّر مخاطبةwaitpid (%s)\n"
#: lib/libalpm/util.c:598
#, c-format
msgid "could not open pipe (%s)\n"
msgstr "تعذّر فتح العبّارة (%s)\n"
#: lib/libalpm/util.c:605
#: lib/libalpm/util.c:719
#, c-format
msgid "command failed to execute correctly\n"
msgstr "فشل تطبيق الأمر بشكل صحيح\n"
#: lib/libalpm/util.c:612
#: lib/libalpm/util.c:726
#, c-format
msgid "Unknown signal"
msgstr ""
msgstr "إشارة مجهوله"
#: lib/libalpm/util.c:614
#: lib/libalpm/util.c:728
#, c-format
msgid "command terminated by signal %d: %s\n"
msgstr ""
msgstr "تم انهاء الامر بواسطة الاشارة %d: %s\n"
#: lib/libalpm/util.c:711
#: lib/libalpm/util.c:825
#, c-format
msgid "no %s cache exists, creating...\n"
msgstr "لا يوجد %s مخبئي، يجري الإنشاء...\n"
#: lib/libalpm/util.c:742
#: lib/libalpm/util.c:856
#, c-format
msgid "couldn't find or create package cache, using %s instead\n"
msgstr "تعذّر إيجاد أو إنشاء مخبئية للحزم ، استخدم %s بدلًا عنها\n"

File diff suppressed because it is too large Load Diff

View File

@@ -3,19 +3,21 @@
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
# Ivailo Monev <xakepa10@gmail.com>, 2014
# Galin Iskrenov <loot270@abv.bg>, 2017-2018
# Ivailo Monev <xakepa10@gmail.com>, 2014-2016
msgid ""
msgstr ""
"Project-Id-Version: Arch Linux Pacman package manager\n"
"Report-Msgid-Bugs-To: http://bugs.archlinux.org/index.php?project=3\n"
"POT-Creation-Date: 2015-02-14 11:13+1000\n"
"PO-Revision-Date: 2014-11-29 17:01+0000\n"
"Last-Translator: Alexander Angelov Nestorov <alexandernst@gmail.com>\n"
"Language-Team: Bulgarian (http://www.transifex.com/projects/p/archlinux-pacman/language/bg/)\n"
"POT-Creation-Date: 2018-05-15 10:34+1000\n"
"PO-Revision-Date: 2018-05-15 12:11+0000\n"
"Last-Translator: Galin Iskrenov <loot270@abv.bg>\n"
"Language-Team: Bulgarian (http://www.transifex.com/toofishes/archlinux-"
"pacman/language/bg/)\n"
"Language: bg\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: bg\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: lib/libalpm/add.c:86
@@ -33,136 +35,157 @@ msgstr "%s-%s е актуален -- преинсталиране\n"
msgid "downgrading package %s (%s => %s)\n"
msgstr "понижаване на пакет %s (%s => %s)\n"
#: lib/libalpm/add.c:122 lib/libalpm/util.c:379
#: lib/libalpm/add.c:124
#, c-format
msgid "cannot allocate disk archive object"
msgstr "не се открие указания архив на диск"
#: lib/libalpm/add.c:138 lib/libalpm/util.c:382
#, c-format
msgid "warning given when extracting %s (%s)\n"
msgstr "има предупреждение при извличане %s (%s)\n"
#: lib/libalpm/add.c:125 lib/libalpm/util.c:382
#: lib/libalpm/add.c:141 lib/libalpm/util.c:385
#, c-format
msgid "could not extract %s (%s)\n"
msgstr "не може да се извлече %s (%s)\n"
#: lib/libalpm/add.c:138 lib/libalpm/dload.c:589 lib/libalpm/remove.c:536
#: lib/libalpm/add.c:154 lib/libalpm/dload.c:561 lib/libalpm/remove.c:541
#, c-format
msgid "could not rename %s to %s (%s)\n"
msgstr "не може да се преименува %s на %s (%s)\n"
#: lib/libalpm/add.c:184
#: lib/libalpm/add.c:205
#, c-format
msgid "file not found in file list for package %s. skipping extraction of %s\n"
msgstr "файл не е намерен в листа с файлове на пекет %s. пропускане извличането на %s\n"
msgstr ""
"файл не е намерен в листа с файлове на пекет %s. пропускане извличането на "
"%s\n"
#: lib/libalpm/add.c:232
#: lib/libalpm/add.c:214
#, c-format
msgid "unable to extract %s%s: path too long"
msgstr "неспешно извличането на %s%s: пътят е твърде дълъг"
#: lib/libalpm/add.c:256
#, c-format
msgid ""
"directory permissions differ on %s\n"
"filesystem: %o package: %o\n"
msgstr "разлика в правата на папка за %s\nfilesystem: %o пакет: %o\n"
msgstr ""
"разлика в правата на папка за %s\n"
"filesystem: %o пакет: %o\n"
#: lib/libalpm/add.c:247
#: lib/libalpm/add.c:271
#, c-format
msgid ""
"directory ownership differs on %s\n"
"filesystem: %u:%u package: %u:%u\n"
msgstr "правата на директория се различава от %s\nfilesystem: %u:%u пакет: %u:%u\n"
msgstr ""
"правата на директория се различава от %s\n"
"filesystem: %u:%u пакет: %u:%u\n"
#: lib/libalpm/add.c:263
#: lib/libalpm/add.c:287
#, c-format
msgid "extract: not overwriting dir with file %s\n"
msgstr "извличане: не се презаписва папка с файл %s\n"
#: lib/libalpm/add.c:603 lib/libalpm/util.c:331 lib/libalpm/util.c:507
#: lib/libalpm/add.c:315
#, c-format
msgid "unable to extract %s.pacnew: path too long"
msgstr "неспешно извличането на %s.pacnew: пътят е твърде дълъг"
#: lib/libalpm/add.c:508 lib/libalpm/util.c:334 lib/libalpm/util.c:573
#, c-format
msgid "could not get current working directory\n"
msgstr "не може да се разбере текущата директория\n"
#: lib/libalpm/add.c:608 lib/libalpm/util.c:336 lib/libalpm/util.c:512
#: lib/libalpm/util.c:553
#: lib/libalpm/add.c:513 lib/libalpm/util.c:339 lib/libalpm/util.c:578
#: lib/libalpm/util.c:631
#, c-format
msgid "could not change directory to %s (%s)\n"
msgstr "не може да се смени директория на %s (%s)\n"
#: lib/libalpm/add.c:647 lib/libalpm/util.c:400 lib/libalpm/util.c:624
#: lib/libalpm/add.c:570 lib/libalpm/util.c:403 lib/libalpm/util.c:738
#, c-format
msgid "could not restore working directory (%s)\n"
msgstr "не може да се възстанови работната директория (%s)\n"
#: lib/libalpm/add.c:655
#: lib/libalpm/add.c:578
#, c-format
msgid "problem occurred while upgrading %s\n"
msgstr "възникнал проблем при подновяване %s\n"
#: lib/libalpm/add.c:661
#: lib/libalpm/add.c:584
#, c-format
msgid "problem occurred while installing %s\n"
msgstr "възникнал проблем при инсталиране %s\n"
#: lib/libalpm/add.c:677
#: lib/libalpm/add.c:599
#, c-format
msgid "could not update database entry %s-%s\n"
msgstr "не може да се поднови запис в базата %s-%s\n"
#: lib/libalpm/add.c:688
#: lib/libalpm/add.c:610
#, c-format
msgid "could not add entry '%s' in cache\n"
msgstr "не може да се добави запис '%s' в кеша\n"
#: lib/libalpm/be_local.c:249
#: lib/libalpm/be_local.c:255
#, c-format
msgid "error while reading file %s: %s\n"
msgstr "грешка при четене на файл %s: %s\n"
#: lib/libalpm/be_local.c:343
#: lib/libalpm/be_local.c:350
#, c-format
msgid "removing invalid database: %s\n"
msgstr "премахване на невалидна база: %s\n"
#: lib/libalpm/be_local.c:389 lib/libalpm/be_local.c:849
#: lib/libalpm/be_local.c:401 lib/libalpm/be_local.c:887
#, c-format
msgid "could not create directory %s: %s\n"
msgstr "не се създава директория %s: %s\n"
#: lib/libalpm/be_local.c:559 lib/libalpm/be_sync.c:358
#: lib/libalpm/be_local.c:576 lib/libalpm/be_sync.c:387
#, c-format
msgid "invalid name for database entry '%s'\n"
msgstr "невалидно име за запис в базата '%s'\n"
#: lib/libalpm/be_local.c:567
#: lib/libalpm/be_local.c:584
#, c-format
msgid "duplicated database entry '%s'\n"
msgstr "дублиран запис в базата '%s'\n"
#: lib/libalpm/be_local.c:579
#: lib/libalpm/be_local.c:596
#, c-format
msgid "corrupted database entry '%s'\n"
msgstr "повреден запис в базата '%s'\n"
#: lib/libalpm/be_local.c:679 lib/libalpm/be_local.c:769
#: lib/libalpm/be_local.c:898 lib/libalpm/be_local.c:991
#: lib/libalpm/diskspace.c:131 lib/libalpm/dload.c:447 lib/libalpm/util.c:250
#: lib/libalpm/util.c:266
#: lib/libalpm/be_local.c:699 lib/libalpm/be_local.c:791
#: lib/libalpm/be_local.c:936 lib/libalpm/be_local.c:1033
#: lib/libalpm/diskspace.c:131 lib/libalpm/dload.c:419 lib/libalpm/util.c:253
#: lib/libalpm/util.c:269
#, c-format
msgid "could not open file %s: %s\n"
msgstr "не се отваря файл %s: %s\n"
#: lib/libalpm/be_local.c:695 lib/libalpm/be_sync.c:603
#: lib/libalpm/be_local.c:715 lib/libalpm/be_sync.c:653
#, c-format
msgid "%s database is inconsistent: name mismatch on package %s\n"
msgstr "%s несъответствие в базата: името не съответства на пакета %s\n"
#: lib/libalpm/be_local.c:701 lib/libalpm/be_sync.c:609
#: lib/libalpm/be_local.c:721 lib/libalpm/be_sync.c:659
#, c-format
msgid "%s database is inconsistent: version mismatch on package %s\n"
msgstr "%s несъответствие в базата: версията не съответства на пакета %s\n"
#: lib/libalpm/be_local.c:740
#: lib/libalpm/be_local.c:762
#, c-format
msgid "unknown validation type for package %s: %s\n"
msgstr "непознат валидиращ тип на пакета %s: %s\n"
#: lib/libalpm/be_package.c:479 lib/libalpm/be_package.c:625
#: lib/libalpm/be_package.c:638
#: lib/libalpm/be_package.c:479 lib/libalpm/be_package.c:637
#: lib/libalpm/be_package.c:650
#, c-format
msgid "error while reading package %s: %s\n"
msgstr "грешка при четене на пакет %s: %s\n"
@@ -172,92 +195,97 @@ msgstr "грешка при четене на пакет %s: %s\n"
msgid "error while reading mtree of package %s: %s\n"
msgstr "грешка при зареждане на mtree на пакет %s: %s\n"
#: lib/libalpm/be_package.c:588
#: lib/libalpm/be_package.c:603
#, c-format
msgid "could not parse package description file in %s\n"
msgstr "не може да се анализира описателния файл в %s\n"
#: lib/libalpm/be_package.c:593
#: lib/libalpm/be_package.c:608
#, c-format
msgid "missing package name in %s\n"
msgstr "липсващо име на пакет в %s\n"
#: lib/libalpm/be_package.c:597
#: lib/libalpm/be_package.c:612
#, c-format
msgid "missing package version in %s\n"
msgstr "липсваща версия на пакет в %s\n"
#: lib/libalpm/be_package.c:601
#: lib/libalpm/be_package.c:616
#, c-format
msgid "invalid package version in %s\n"
msgstr "невалидна версия на пакет в %s\n"
#: lib/libalpm/be_package.c:645
#: lib/libalpm/be_package.c:657
#, c-format
msgid "missing package metadata in %s\n"
msgstr "липсват метаданни за пакета %s\n"
#: lib/libalpm/be_package.c:734
#: lib/libalpm/be_package.c:748
#, c-format
msgid "failed to read signature file: %s\n"
msgstr "не се чете подписващият файл: %s\n"
#: lib/libalpm/be_package.c:755 lib/libalpm/sync.c:1108
#: lib/libalpm/be_package.c:769 lib/libalpm/sync.c:1113
#, c-format
msgid "required key missing from keyring\n"
msgstr "нужния ключ липсва от keyring\n"
#: lib/libalpm/be_sync.c:61
#: lib/libalpm/be_sync.c:62
#, c-format
msgid "removing invalid file: %s\n"
msgstr "премахване невалиден файл: %s\n"
#: lib/libalpm/be_sync.c:476
#: lib/libalpm/be_sync.c:517
#, c-format
msgid "could not parse package description file '%s' from db '%s'\n"
msgstr "не може да се анализира описателния файл '%s' от db '%s'\n"
#: lib/libalpm/be_sync.c:509 lib/libalpm/be_sync.c:514
#: lib/libalpm/be_sync.c:524
#, c-format
msgid "could not read db '%s' (%s)\n"
msgstr "не да се прочете db '%s' (%s)\n"
#: lib/libalpm/be_sync.c:558 lib/libalpm/be_sync.c:563
#, c-format
msgid "%s database is inconsistent: filename of package %s is illegal\n"
msgstr "%s базата е непълна: името на пакета %s е недопустимо\n"
#: lib/libalpm/be_sync.c:519
#: lib/libalpm/be_sync.c:568
#, c-format
msgid "%s database is inconsistent: filename of package %s is too long\n"
msgstr "%s базата е непълна: името на пакета %s е твърде дълго\n"
#: lib/libalpm/be_sync.c:585
#: lib/libalpm/be_sync.c:634
#, c-format
msgid "unknown database file: %s\n"
msgstr "непознат датабаза файл: %s\n"
#: lib/libalpm/db.c:369
#: lib/libalpm/db.c:370
#, c-format
msgid "database path is undefined\n"
msgstr "пътя към базата е неопределен\n"
#: lib/libalpm/deps.c:218
#: lib/libalpm/deps.c:184
#, c-format
msgid "dependency cycle detected:\n"
msgstr "открит цикъл на зависимост:\n"
#: lib/libalpm/deps.c:221
#: lib/libalpm/deps.c:187
#, c-format
msgid "%s will be removed after its %s dependency\n"
msgstr "%s ще бъде премахната след зависимостта %s\n"
#: lib/libalpm/deps.c:225
#: lib/libalpm/deps.c:191
#, c-format
msgid "%s will be installed before its %s dependency\n"
msgstr "%s ще бъде инсталиран преди зависимостта %s\n"
#: lib/libalpm/deps.c:657 lib/libalpm/deps.c:689
#: lib/libalpm/deps.c:682 lib/libalpm/deps.c:712
#, c-format
msgid "ignoring package %s-%s\n"
msgstr "пренебрегване на пакет %s-%s\n"
#: lib/libalpm/deps.c:844
#: lib/libalpm/deps.c:867
#, c-format
msgid "cannot resolve \"%s\", a dependency of \"%s\"\n"
msgstr "не може да се разреши \"%s\", зависи от \"%s\"\n"
@@ -275,69 +303,78 @@ msgstr "не се отворя файл: %s: %s\n"
#: lib/libalpm/diskspace.c:146 lib/libalpm/diskspace.c:159
#, c-format
msgid "could not get filesystem information\n"
msgstr "не се получава системна информация\n\n"
msgstr ""
"не се получава системна информация\n"
"\n"
#: lib/libalpm/diskspace.c:249 lib/libalpm/diskspace.c:308
#: lib/libalpm/diskspace.c:242
#, c-format
msgid "could not get file information for %s\n"
msgstr "неможе да се вземе информация отностно %s\n"
#: lib/libalpm/diskspace.c:256 lib/libalpm/diskspace.c:315
#, c-format
msgid "could not determine mount point for file %s\n"
msgstr "не може да се определи точката за монтиране на %s\n"
#: lib/libalpm/diskspace.c:347
#: lib/libalpm/diskspace.c:354
#, c-format
msgid "Partition %s too full: %jd blocks needed, %jd blocks free\n"
msgstr "Дялът %s е пълен: %jd необходими блока, %jd свободни блока\n"
msgid "Partition %s too full: %jd blocks needed, %ju blocks free\n"
msgstr "Партишанът %s е твърде пълен: %jd блока са нужни, %ju блока свободни\n"
#: lib/libalpm/diskspace.c:372 lib/libalpm/diskspace.c:426
#: lib/libalpm/diskspace.c:379 lib/libalpm/diskspace.c:433
#, c-format
msgid "could not determine filesystem mount points\n"
msgstr "не може да се опреди filesystem mount points\n"
#: lib/libalpm/diskspace.c:378
#: lib/libalpm/diskspace.c:385
#, c-format
msgid "could not determine cachedir mount point %s\n"
msgstr "не може да се определи cachedir mount point %s\n"
#: lib/libalpm/diskspace.c:431
#: lib/libalpm/diskspace.c:438
#, c-format
msgid "could not determine root mount point %s\n"
msgstr "не може да се определи root mount point %s\n"
#: lib/libalpm/diskspace.c:479
#: lib/libalpm/diskspace.c:486
#, c-format
msgid "Partition %s is mounted read only\n"
msgstr "Дялът %s е монтиран само за четене\n"
#: lib/libalpm/dload.c:149
#: lib/libalpm/dload.c:159
#, c-format
msgid "disk"
msgstr "диск"
#: lib/libalpm/dload.c:373
#: lib/libalpm/dload.c:345
#, c-format
msgid "failed to create temporary file for download\n"
msgstr "не може да се създаде временен файл за сваляне\n"
#: lib/libalpm/dload.c:418
#: lib/libalpm/dload.c:390
#, c-format
msgid "url '%s' is invalid\n"
msgstr "url '%s' е невалиден\n"
#: lib/libalpm/dload.c:487 lib/libalpm/dload.c:512
#: lib/libalpm/dload.c:459 lib/libalpm/dload.c:484
#, c-format
msgid "failed retrieving file '%s' from %s : %s\n"
msgstr "неуспех при извличане на файл '%s' от %s : %s\n"
#: lib/libalpm/dload.c:500
#: lib/libalpm/dload.c:472
#, c-format
msgid "failed retrieving file '%s' from %s : expected download size exceeded\n"
msgstr "неуспех при получаването на файл '%s' от %s : очакваният размер за сваляне е надвишен\n"
msgstr ""
"неуспех при получаването на файл '%s' от %s : очакваният размер за сваляне е "
"надвишен\n"
#: lib/libalpm/dload.c:548
#: lib/libalpm/dload.c:520
#, c-format
msgid "%s appears to be truncated: %jd/%jd bytes\n"
msgstr "%s appears to be truncated: %jd/%jd bytes\n"
msgstr "%s изглежда частичен: %jd/%jd bytes\n"
#: lib/libalpm/dload.c:692 lib/libalpm/dload.c:721
#: lib/libalpm/dload.c:664 lib/libalpm/dload.c:693
#, c-format
msgid "failed to download %s\n"
msgstr "неуспех при сваляне на %s\n"
@@ -380,12 +417,12 @@ msgstr "няма достатъчно място на диска"
#: lib/libalpm/error.c:55
#, c-format
msgid "library not initialized"
msgstr "library not initialized"
msgstr "библиотеката не е инициализирана"
#: lib/libalpm/error.c:57
#, c-format
msgid "library already initialized"
msgstr "library already initialized"
msgstr "библиотеката вече е инициализирана"
#: lib/libalpm/error.c:59
#, c-format
@@ -487,142 +524,234 @@ msgstr "операцията е несъвместима с типа транз
msgid "transaction commit attempt when database is not locked"
msgstr "транзакцията иска достъп до незаключена база"
#: lib/libalpm/error.c:105
#: lib/libalpm/error.c:104
#, c-format
msgid "failed to run transaction hooks"
msgstr "неуспех при пускането на транзакционни куки"
#: lib/libalpm/error.c:107
#, c-format
msgid "could not find or read package"
msgstr "няма или не се чете пакет"
#: lib/libalpm/error.c:107
#: lib/libalpm/error.c:109
#, c-format
msgid "operation cancelled due to ignorepkg"
msgstr "отменена операция според ignorepkg"
#: lib/libalpm/error.c:109
#: lib/libalpm/error.c:111
#, c-format
msgid "invalid or corrupted package"
msgstr "невалиден или повреден пакет"
#: lib/libalpm/error.c:111
#: lib/libalpm/error.c:113
#, c-format
msgid "invalid or corrupted package (checksum)"
msgstr "невалиден или повреден пакет (checksum)"
#: lib/libalpm/error.c:113
#: lib/libalpm/error.c:115
#, c-format
msgid "invalid or corrupted package (PGP signature)"
msgstr "невалиден или повреден пакет (PGP signature)"
#: lib/libalpm/error.c:115
#: lib/libalpm/error.c:117
#, c-format
msgid "package missing required signature"
msgstr "липсва изискващ се подпис на пакет"
#: lib/libalpm/error.c:117
#: lib/libalpm/error.c:119
#, c-format
msgid "cannot open package file"
msgstr "не се отваря пакетен файл"
#: lib/libalpm/error.c:119
#: lib/libalpm/error.c:121
#, c-format
msgid "cannot remove all files for package"
msgstr "не се премахват всички файлове на пакета"
#: lib/libalpm/error.c:121
#: lib/libalpm/error.c:123
#, c-format
msgid "package filename is not valid"
msgstr "името на пакета не е валидно"
#: lib/libalpm/error.c:123
#: lib/libalpm/error.c:125
#, c-format
msgid "package architecture is not valid"
msgstr "архитектурата на пакета не е валидна"
#: lib/libalpm/error.c:125
#: lib/libalpm/error.c:127
#, c-format
msgid "could not find repository for target"
msgstr "не може да се открие източник за целта"
#: lib/libalpm/error.c:128
#: lib/libalpm/error.c:130
#, c-format
msgid "missing PGP signature"
msgstr "липса на PGP подпис"
msgstr "липсва PGP подпис"
#: lib/libalpm/error.c:130
#: lib/libalpm/error.c:132
#, c-format
msgid "invalid PGP signature"
msgstr "невалиден PGP подпис"
#: lib/libalpm/error.c:133
#: lib/libalpm/error.c:135
#, c-format
msgid "invalid or corrupted delta"
msgstr "невалидна или повредена delta"
#: lib/libalpm/error.c:135
#: lib/libalpm/error.c:137
#, c-format
msgid "delta patch failed"
msgstr "delta patch failed"
msgstr "делта пач се провали"
#: lib/libalpm/error.c:138
#: lib/libalpm/error.c:140 lib/libalpm/hook.c:614
#, c-format
msgid "could not satisfy dependencies"
msgstr "зависимостите не са решени"
#: lib/libalpm/error.c:140
#: lib/libalpm/error.c:142
#, c-format
msgid "conflicting dependencies"
msgstr "зависимости в конфликт"
#: lib/libalpm/error.c:142
#: lib/libalpm/error.c:144
#, c-format
msgid "conflicting files"
msgstr "файлове в конфликт"
#: lib/libalpm/error.c:145
#: lib/libalpm/error.c:147
#, c-format
msgid "failed to retrieve some files"
msgstr "не могат да се извлекат файлове"
#: lib/libalpm/error.c:147
#: lib/libalpm/error.c:149
#, c-format
msgid "invalid regular expression"
msgstr "невалиден регулярен израз"
#: lib/libalpm/error.c:153
#, c-format
msgid "libarchive error"
msgstr "libarchive error"
#: lib/libalpm/error.c:155
#, c-format
msgid "download library error"
msgstr "download library error"
msgid "libarchive error"
msgstr "грешка в libarchive"
#: lib/libalpm/error.c:157
#, c-format
msgid "gpgme error"
msgstr "gpgme error"
msgid "download library error"
msgstr "грешка в библиотеката за сваляне"
#: lib/libalpm/error.c:159
#, c-format
msgid "error invoking external downloader"
msgstr "error invoking external downloader"
msgid "gpgme error"
msgstr "грешка в gpgme"
#: lib/libalpm/error.c:162
#: lib/libalpm/error.c:161
#, c-format
msgid "error invoking external downloader"
msgstr "грешка при извикването на външен downloader"
#: lib/libalpm/error.c:164
#, c-format
msgid "unexpected error"
msgstr "неочаквана грешка"
#: lib/libalpm/handle.c:139
#: lib/libalpm/handle.c:157
#, c-format
msgid "lock file missing %s\n"
msgstr "липсва заключващ файл %s\n"
#: lib/libalpm/handle.c:145
#: lib/libalpm/handle.c:163
#, c-format
msgid "could not remove lock file %s\n"
msgstr "не се премахва заключен файл %s\n"
#: lib/libalpm/package.c:559
#: lib/libalpm/hook.c:107
#, c-format
msgid "Missing trigger targets in hook: %s\n"
msgstr "Липсва цели на спусъка в куката: %s\n"
#: lib/libalpm/hook.c:113
#, c-format
msgid "Missing trigger type in hook: %s\n"
msgstr "Липсва тип на спусъка в куката: %s\n"
#: lib/libalpm/hook.c:119
#, c-format
msgid "Missing trigger operation in hook: %s\n"
msgstr "Липсва операция на спусъка в куката: %s\n"
#: lib/libalpm/hook.c:146
#, c-format
msgid "Missing Exec option in hook: %s\n"
msgstr "Липсва Exec опция в куката: %s\n"
#: lib/libalpm/hook.c:152
#, c-format
msgid "Missing When option in hook: %s\n"
msgstr "Липсва When опция в куката: %s\n"
#: lib/libalpm/hook.c:155
#, c-format
msgid "AbortOnFail set for PostTransaction hook: %s\n"
msgstr "AbortOnFail е зададен за PostTransaction кука: %s\n"
#: lib/libalpm/hook.c:273
#, c-format
msgid "error while reading hook %s: %s\n"
msgstr "грешка при четене на куката %s: %s\n"
#: lib/libalpm/hook.c:275 lib/libalpm/hook.c:315 lib/libalpm/hook.c:357
#, c-format
msgid "hook %s line %d: invalid option %s\n"
msgstr "кука %s ред %d: невалидна опция %s\n"
#: lib/libalpm/hook.c:285
#, c-format
msgid "hook %s line %d: invalid section %s\n"
msgstr "кука %s ред %d: невалидна секция %s\n"
#: lib/libalpm/hook.c:297 lib/libalpm/hook.c:308 lib/libalpm/hook.c:327
#: lib/libalpm/hook.c:350
#, c-format
msgid "hook %s line %d: invalid value %s\n"
msgstr "кука %s ред %d: невалидна стойност %s\n"
#: lib/libalpm/hook.c:301 lib/libalpm/hook.c:320 lib/libalpm/hook.c:331
#: lib/libalpm/hook.c:345
#, c-format
msgid "hook %s line %d: overwriting previous definition of %s\n"
msgstr "кука %s ред %d: пренаписва предишната дефиниция на %s\n"
#: lib/libalpm/hook.c:352
#, c-format
msgid "hook %s line %d: unable to set option (%s)\n"
msgstr "кука %s ред %d: невъзможно да се зададе опцията (%s)\n"
#: lib/libalpm/hook.c:613
#, c-format
msgid "unable to run hook %s: %s\n"
msgstr "невъзможно е пускане на куката %s: %s\n"
#: lib/libalpm/hook.c:648 lib/libalpm/hook.c:660 lib/libalpm/remove.c:385
#, c-format
msgid "could not open directory: %s: %s\n"
msgstr "не се отваря папка: %s: %s\n"
#: lib/libalpm/hook.c:676
#, c-format
msgid "could not open file: %s%s: %s\n"
msgstr "не може да се отвори файл: %s%s: %s\n"
#: lib/libalpm/hook.c:696 lib/libalpm/util.c:259
#, c-format
msgid "could not stat file %s: %s\n"
msgstr "не се коригира %s: %s\n"
#: lib/libalpm/hook.c:722
#, c-format
msgid "could not read directory: %s: %s\n"
msgstr "не може да се прочете папката: %s: %s\n"
#: lib/libalpm/package.c:586
#, c-format
msgid "could not fully load metadata for package %s-%s\n"
msgstr "не пълно извеждане на метаданни за пакет %s-%s\n"
@@ -637,31 +766,113 @@ msgstr "няма %s в базата -- пропускане\n"
msgid "removing %s from target list\n"
msgstr "премахване %s от списъка с целите\n"
#: lib/libalpm/remove.c:348
#: lib/libalpm/remove.c:345
#, c-format
msgid "cannot remove file '%s': %s\n"
msgstr "не се премахва файла '%s': %s\n"
#: lib/libalpm/remove.c:388
#: lib/libalpm/remove.c:410 lib/libalpm/remove.c:419
#, c-format
msgid "could not open directory: %s: %s\n"
msgstr "не се отваря папка: %s: %s\n"
msgid "could not backup %s due to PATH_MAX overflow\n"
msgstr "не може да се архивира %s поради препълване на PATH_MAX\n"
#: lib/libalpm/remove.c:556
#: lib/libalpm/remove.c:561
#, c-format
msgid "cannot remove %s (%s)\n"
msgstr "не се премахва %s (%s)\n"
#: lib/libalpm/remove.c:727
#: lib/libalpm/remove.c:734
#, c-format
msgid "could not remove database entry %s-%s\n"
msgstr "не може да се премахне запис в базата %s-%s\n"
#: lib/libalpm/remove.c:732
#: lib/libalpm/remove.c:739
#, c-format
msgid "could not remove entry '%s' from cache\n"
msgstr "не може да се премахне '%s' от кеша\n"
#: lib/libalpm/signing.c:171
#, c-format
msgid "Public keyring not found; have you run '%s'?\n"
msgstr "Публичният ключодържател не е открит; Ще пуснете ли '%s'?\n"
#: lib/libalpm/signing.c:207 lib/libalpm/signing.c:705
#, c-format
msgid "GPGME error: %s\n"
msgstr "GPGME грешка: %s\n"
#: lib/libalpm/signing.c:402
#, c-format
msgid "keyring is not writable\n"
msgstr "ключодържателя не се записва\n"
#: lib/libalpm/signing.c:460
#, c-format
msgid "key \"%s\" could not be imported\n"
msgstr "ключ \"%s\" не може да се внесе\n"
#: lib/libalpm/signing.c:466
#, c-format
msgid "key %s, \"%s\" found on keyserver, keyring is not writable\n"
msgstr "ключ %s, \"%s\" е открит в сървъра с ключове, ключ не се записва\n"
#: lib/libalpm/signing.c:471
#, c-format
msgid "key \"%s\" could not be looked up remotely\n"
msgstr "ключ \"%s\" не може да се прегледа отдалечено\n"
#: lib/libalpm/signing.c:859 lib/libalpm/sync.c:1181
#, c-format
msgid "%s: missing required signature\n"
msgstr "%s: липсва изискващ се подпис\n"
#: lib/libalpm/signing.c:874
#, c-format
msgid "%s: signature from \"%s\" is marginal trust\n"
msgstr "%s: подписът от \"%s\" е изрично доверен\n"
#: lib/libalpm/signing.c:882
#, c-format
msgid "%s: signature from \"%s\" is unknown trust\n"
msgstr "%s: подписът от \"%s\" е с непознато доверие\n"
#: lib/libalpm/signing.c:889
#, c-format
msgid "%s: signature from \"%s\" should never be trusted\n"
msgstr "%s: подписът от \"%s\" никога да не се му вярва\n"
#: lib/libalpm/signing.c:901
#, c-format
msgid "%s: key \"%s\" is unknown\n"
msgstr "%s: ключ \"%s\" е непознат\n"
#: lib/libalpm/signing.c:910
#, c-format
msgid "%s: key \"%s\" is disabled\n"
msgstr "%s: ключа е \"%s\" е негоден\n"
#: lib/libalpm/signing.c:914
#, c-format
msgid "%s: signature from \"%s\" is expired\n"
msgstr "%s: подписът от \"%s\" е изтекъл\n"
#: lib/libalpm/signing.c:918
#, c-format
msgid "%s: signature from \"%s\" is invalid\n"
msgstr "%s: подписът от \"%s\" е невалиден\n"
#: lib/libalpm/signing.c:995 lib/libalpm/signing.c:1063
#: lib/libalpm/signing.c:1142
#, c-format
msgid "%s: signature format error\n"
msgstr "%s: грешен формат на подписа\n"
#: lib/libalpm/signing.c:1095 lib/libalpm/signing.c:1128
#: lib/libalpm/signing.c:1136
#, c-format
msgid "%s: unsupported signature format\n"
msgstr "%s: неподдържан формат на подписа\n"
#: lib/libalpm/sync.c:98
#, c-format
msgid "%s: ignoring package upgrade (%s => %s)\n"
@@ -692,117 +903,112 @@ msgstr "игнориране замяната на пакет (%s-%s => %s-%s)\n
msgid "cannot replace %s by %s\n"
msgstr "не може да се замести %s от %s\n"
#: lib/libalpm/sync.c:536 lib/libalpm/sync.c:606
#: lib/libalpm/sync.c:538 lib/libalpm/sync.c:608
#, c-format
msgid "unresolvable package conflicts detected\n"
msgstr "засечени нерешени пакетни конфликти\n"
#: lib/libalpm/sync.c:556
#: lib/libalpm/sync.c:558
#, c-format
msgid "removing '%s' from target list because it conflicts with '%s'\n"
msgstr "премахване '%s' от целевия списък заради конфликт с '%s'\n"
#: lib/libalpm/sync.c:1014
#: lib/libalpm/sync.c:1019
#, c-format
msgid "failed to retrieve some files\n"
msgstr "неуспех при извличане на файлове\n"
#: lib/libalpm/sync.c:1176
#, c-format
msgid "%s: missing required signature\n"
msgstr "%s: липсва изискващ се подпис\n"
#: lib/libalpm/sync.c:1357
#: lib/libalpm/sync.c:1384
#, c-format
msgid "not enough free disk space\n"
msgstr "няма свободно място на диска\n"
msgstr "няма достатъчно свободно място на диска\n"
#: lib/libalpm/sync.c:1370
#: lib/libalpm/sync.c:1406
#, c-format
msgid "could not commit removal transaction\n"
msgstr "не се потвърждава транзакцията по премахване\n"
#: lib/libalpm/sync.c:1378
#: lib/libalpm/sync.c:1414
#, c-format
msgid "could not commit transaction\n"
msgstr "не се потвърждава транзакцията\n"
#: lib/libalpm/trans.c:343
#: lib/libalpm/trans.c:364
#, c-format
msgid "could not create temp directory\n"
msgstr "не се създава temp папка\n"
#: lib/libalpm/trans.c:358
#: lib/libalpm/trans.c:379
#, c-format
msgid "could not copy tempfile to %s (%s)\n"
msgstr "не се копира tempfile в %s (%s)\n"
#: lib/libalpm/trans.c:389
#: lib/libalpm/trans.c:410
#, c-format
msgid "could not remove %s\n"
msgstr "не се премахва %s\n"
#: lib/libalpm/trans.c:393
#: lib/libalpm/trans.c:414
#, c-format
msgid "could not remove tmpdir %s\n"
msgstr "не се премахва tmpdir %s\n"
#: lib/libalpm/util.c:256
#: lib/libalpm/util.c:486
#, c-format
msgid "could not stat file %s: %s\n"
msgstr "не се коригира %s: %s\n"
msgid "unable to write to pipe (%s)\n"
msgstr "неъспешно записването в тръбата (%s)\n"
#: lib/libalpm/util.c:524
#: lib/libalpm/util.c:545
#, c-format
msgid "unable to read from pipe (%s)\n"
msgstr "неуспешно четенето от тръбата (%s)\n"
#: lib/libalpm/util.c:590 lib/libalpm/util.c:596
#, c-format
msgid "could not create pipe (%s)\n"
msgstr "не се създава pipe (%s)\n"
#: lib/libalpm/util.c:532
#: lib/libalpm/util.c:604
#, c-format
msgid "could not fork a new process (%s)\n"
msgstr "could not fork a new process (%s)\n"
#: lib/libalpm/util.c:549
#: lib/libalpm/util.c:627
#, c-format
msgid "could not change the root directory (%s)\n"
msgstr "не може да се промени root папката (%s)\n"
#: lib/libalpm/util.c:560
#: lib/libalpm/util.c:638
#, c-format
msgid "call to execv failed (%s)\n"
msgstr "неуспех при извикване execv (%s)\n"
#: lib/libalpm/util.c:590
#: lib/libalpm/util.c:709
#, c-format
msgid "call to waitpid failed (%s)\n"
msgstr "неуспех при извикване на waitpid (%s)\n"
#: lib/libalpm/util.c:598
#, c-format
msgid "could not open pipe (%s)\n"
msgstr "не може да се отвори pipe (%s)\n"
#: lib/libalpm/util.c:605
#: lib/libalpm/util.c:719
#, c-format
msgid "command failed to execute correctly\n"
msgstr "неуспешно правилно изпълнение на команда\n"
#: lib/libalpm/util.c:612
#: lib/libalpm/util.c:726
#, c-format
msgid "Unknown signal"
msgstr "Неизвестен сигнал"
#: lib/libalpm/util.c:614
#: lib/libalpm/util.c:728
#, c-format
msgid "command terminated by signal %d: %s\n"
msgstr "командата прекратена от сигнал %d: %s\n"
#: lib/libalpm/util.c:711
#: lib/libalpm/util.c:825
#, c-format
msgid "no %s cache exists, creating...\n"
msgstr "не %s съществуваш кеш, създаване...\n"
#: lib/libalpm/util.c:742
#: lib/libalpm/util.c:856
#, c-format
msgid "couldn't find or create package cache, using %s instead\n"
msgstr "не се открива или създава пакетен кеш, използва се %s\n"

1023
lib/libalpm/po/br.po Normal file

File diff suppressed because it is too large Load Diff

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