Commit Graph

4338 Commits

Author SHA1 Message Date
Dan McGee afdbfc05f7 Extract an _alpm_pkg_validate_internal() method
_alpm_pkg_load_internal() was becoming a monster. Extract the top bit of
the method that dealt with checksum and signature validation into a
separate method that should be called before one loads a package to
ensure it is valid.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dave Reisner 7eb2f0cd15 pacman/upgrade: print 'loading packages...' only once
Do this outside the loop to prevent the message from being displayed
(and pluralized!) for each individual package.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dan McGee 8e3b39a9e0 pacman: use dynamic string allocation where it makes sense
None of these are hot-code paths, and at least the target reading has
little need for an arbitrary length limitation (however crazy it might
be to have longer arguments).

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dan McGee 0f92fc5963 utils/cleanupdelta: remove unneeded syncdbpath
This variable was totally unused.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dan McGee 79cbce60ac Remove all usages of alpm_list_getdata() from the library
No need for the indirection; just access ->data instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:10 -05:00
Dan McGee 70e2c34f0f _alpm_runscriptlet(): remove clean_tmpdir variable
This is always true at the end since we return early if we couldn't
create the tmpdir, so it is totally unnecessary.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:10 -05:00
Dan McGee 3796164848 Access db->pkgcache directly in db_free_pkgcache()
We shouldn't be going through the accessor that does a bunch of
unnecessary legwork, including potentially loading the pkgcache right
before we free it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:10 -05:00
Dan McGee 95119d46d4 Flip getcwd()/chdir() for open()/fchdir() in the frontend
Just like we did in libalpm in commit 288a81d847.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:10 -05:00
Dan McGee 288a81d847 Use more efficient way of restoring working directory
Rather than using a string-based path, we can restore the working
directory via a file descriptor and use of fchdir().

From the getcwd manpage:
    Opening the current directory (".") and calling fchdir(2) to
    return is usually a faster and more reliable alternative when
    sufficiently many file descriptors are available.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-19 14:11:08 -05:00
Dan McGee bfe36c2ddf Reduce path allocation on the stack in local database
We did a lot of both malloc-ing and stack printing to form some paths in
this code. Attempt to unify it all into the one get_pkgpath() method by
adding an optional third "filename" parameter, and form the necessary
path string all in one go.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-19 13:43:13 -05:00
Dan McGee e1899cbc64 Be smarter about running ldconfig during removal transactions
1. Don't run it if something failed in package removal- this mirrors
what we already do in sync transactions.
2. Don't run it if we are invoking it for the replaces removal bit of a
sync transaction- it doesn't make sense to run ldconfig halfway through
a sync install; we should only run it once at the end.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-19 13:18:42 -05:00
Dan McGee a94ad29740 Search for non-prefixed paths in skip_remove list
We add them to this list with the root path not appended; we should be
searching for them this way as well.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-19 13:17:16 -05:00
Dan McGee 41d8deff88 be_local: cope with a desc file without trailing newline
We checked the (fgets == NULL and !feof) case, but never actually bailed
out of the loop if we were at the end of the file, causing infinite
looping.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 17:32:15 -05:00
Dan McGee 86d9fcbfff Remove const specifier from changelog_read() void parameter
This shouldn't really be declared with const, and causes a compile error
when -Wcast-qual is used. Remove the const specifier from the function
specification and all implementations.

Also fix one other trivial -Wcast-qual warning in _alpm_db_cmp().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 17:11:39 -05:00
Dan McGee 69a3558b75 Remove dead changelog_feof() code
We never ended up using or really needing this; kill it for now knowing
it is in git history if ever needed again.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 17:03:56 -05:00
Dan McGee 49dff4c80b Add a random pactest
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 17:00:21 -05:00
Dave Reisner 83ee9708b1 src/util: provide strndup definitions where needed
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:58:21 -05:00
Dave Reisner 07e89c1e5d dload: avoid using memrchr
This function doesn't exist on OSX. Since there aren't any other
candidates in alpm for which this function would make sense to use,
simply replace the function call with a loop that does the equivalent.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-18 16:57:59 -05:00
Dan McGee 52c65fdfea Ensure entire struct is zeroed in _alpm_parsedate()
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-18 16:57:26 -05:00
Dave Reisner c12fa4ab19 pactree: include missing ctype.h header
needed for isspace() -- avoids warnings on OSX.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:57:09 -05:00
Dave Reisner b1a09b93ef configure: Fix quoting in SEDINPLACE on Darwin
single quotes expanded to nothing, leaving us with a command that
assumed the sed expression was the backup suffix. Use a pair of escaped
double quotes, which survives automake and ends up properly in makepkg.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:57:07 -05:00
Dave Reisner 223a92ca9d dload: remove user:pass@ definition from hostname
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-18 15:35:58 -05:00
Dave Reisner 7ad78c2c88 paccache: remove unnecessary if check
This is superfluous as the ensuing for loop will exit immediately on the
same condition avoided by the if.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-18 15:34:54 -05:00
Dan McGee a7d7798032 Fix build without gpgme
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 15:34:28 -05:00
Dave Reisner f883efe2cb pacman: add short opt '-p' for --print to -{S,R}h
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:24:55 -05:00
Dave Reisner e01dbcc068 include ldconfig.stub in EXTRA_DIST
Since c51b9ca, ldconfig.stub is required by pactest so we need to
include it as part of the dist tarball.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:18:44 -05:00
Dave Reisner 68856755c4 buildsys: remove existing symlinks before installing
This fixes build errors when performing a manual install straight to a
filesystem where the files already exist.

Reported-by: Sergej Pupykin <ml@sergej.pp.ru>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:18:07 -05:00
Dan McGee a2356d5ae3 Don't duplicate header strings
There is no need to print them into buffers; we can use the values
returned by gettext() directly without issue.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:18:07 -05:00
Dave Reisner 4a02350ded makepkg: fix recreation of hardlinks to .gz manpages
4ed12ae tightened up the logic to use only find, but ignored the fact
that since the manpage hard link names were no longer captured. They
were created as separate compressed manpages, rather than as hardlinks.

This also introduces a minor efficiency of deleting all hardlinks at
once and using proper iteration over an array rather than a string.

Note to anyone else touching this code: e2fsprogs and libpcap are useful
for testing this. If that changes in the future, you can use the below
bash to locate others:

  IFS=$'\n' read -rd '' -a a < <(find /usr/share/man -type f \! -links 1)
  pacman -Qqo "${a[@]}" | sort -u

I broke it!

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-14 17:25:29 -04:00
Dave Reisner d1e04c1b67 makepkg: add missing newline on passing gpg sourcecheck
When a sourceball passes this check without any warnings, a newline is
omitted. Similar to the if clause of this else block, print a single new
line at the end of the clause instead of accounting for each output.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-14 14:19:18 -04:00
Dave Reisner 0f69e2ec0b makepkg: check for var existance before file existance
This prevents makepkg from aborting with 'file not found' when
changelog= or install= are declared in a PKGBUILD, but empty.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-12 08:27:13 -04:00
Dave Reisner 3905ada993 account for partial delta files in download size
Similar to an earlier commit which accounts for .part files for full
packages, calculate the download_size for deltas keeping mind the
possibility of a partial transfer.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 19:10:48 -05:00
Dave Reisner d8eacae7bc make compute_download_size consider .part files
Check for the existance of a partial download of a package file before
jumping to delta calculations. Currently, if there were 10MiB remaining
in a 100MiB the values passed to the front end do not reflect this.

Refactored from an old patch originally by Dan.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 19:09:04 -05:00
Dave Reisner befddfc3e6 dload: provide optional netrc support
if ~/.netrc exists and has credentials for the hostname requested in a
download, they will be provided in an http auth request. This can still
be overridden by explcitly declaring user:pass in the URL.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 19:07:25 -05:00
Dave Reisner c736a12e86 makepkg: unset errexit when sourcing /etc/profile
This is a fix for a bash3 specific bug, where a file sourced by
/etc/profile would exit non-zero and make its way back up to makepkg,
forcing it to exit after package installation. Along with unsetting the
ERR handler, temporarily unset errexit to avoid this.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-11 13:47:07 +10:00
Dave Reisner 7f1235ccbc paccache: escape . in trimming of diskspace string
Before:
==> finished dry run: 2 candidates (diskspace saved: 7. MiB)

After:
==> finished dry run: 2 candidates (diskspace saved: 7.8 MiB)

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-11 13:46:07 +10:00
Dan McGee 4737a87b84 download callback: show decimal places in rate if we have room
Display now looks like this, whereas before we would have just showed
'2M/s' for the extra repository download. The cutoff is placed at 100.0
to ensure we only use 4 character slots of width (e.g. '99.9', '100').

:: Synchronizing package databases...
 testing                   39.9 KiB   470K/s 00:00 [######################] 100%
 core                      51.4 KiB   469K/s 00:00 [######################] 100%
 extra                    768.8 KiB   2.1M/s 00:00 [######################] 100%
 community-testing       1941.0   B  54.4M/s 00:00 [######################] 100%
 multilib                  26.6 KiB   458K/s 00:00 [######################] 100%
 community                449.8 KiB  1649K/s 00:00 [######################] 100%

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 13:45:59 +10:00
Dan McGee f7653e582b Move download callback static vars into function
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 13:45:54 +10:00
Dave Reisner db70c9da15 diskspace: fix memory leak on root mount not found
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-08 14:18:19 -05:00
Dan McGee a03313f3f6 Print 'loading packages' message on -U operations
This will be the first thing printed when doing an upgrade. Currently
there is no output at all until we start resolving dependencies, which
can be a while in if specifying very large targets on the command line,
in which case it is nice to let the user know we are doing something.

Addresses FS#25822 in the most KISS way possible.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-08 14:14:51 -05:00
Dave Reisner 905ae640cf makepkg: use more awk'ish syntax in sanity checks
This simplifies the flow a bit, making the pipeline a little easier to
grok.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-07 21:05:05 -05:00
Dave Reisner 4ed12aec30 makepkg: avoid for loop in deleting manpage hardlinks
find can do this all on its own and remain portable.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-07 21:05:04 -05:00
Dave Reisner 17c3de3e4f makepkg: act on function return value, not output
Correcting a typo, as this function will never output anything.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-07 21:05:04 -05:00
Dave Reisner 3d9f961d13 makepkg: refactor check_pgpsigs output
- display associated warnings on same line as pass/fail msg, to be more
  consistent with checksum verification output
- properly error on a revoked key (matching pacman's behavior)

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-07 21:05:04 -05:00
Dan McGee 8ffa2b24a5 Use more correct integer types in diskspace checks
This adjusts type usage to match POSIX provided types from
<sys/types.h> rather than assuming everything will fit in a long or
unsigned long. Use fsblkcnt_t (unsigned) and blkcnt_t (signed) as
appropriate. These are affected the same way off_t is on 32 bit
platforms, where the types are extende to 64 bits if large file support
is enabled.

Because most numbers here are block counts, this isn't
near as pressing as using a 32-bit variable for file sizes where
anything over 2GiB can burn you; we likely can support files at least
512 but mainly 4096 times larger.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-07 21:05:04 -05:00
Dan McGee b961ebe16f query check: use provided filelist count instead of keeping track
We don't need to keep track of how many files are in a package now that
said value is provided to us. It also makes more sense to use size_t
here for types rather than the (hopefully never too short) int.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-07 20:51:35 -05:00
Dan McGee 6317db8429 Remove unnecessary cast
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-07 20:51:35 -05:00
Dan McGee 3e08614fda Ensure PackageRequired works as expected
Changes in commit dc3336c277 caused this to stop working as expected for
sync packages, due to the way the logic is structured. Ensure we always
enter the signature code if the bitflag is flipped on to check
signatures for packages. Rename 'use_sig' to 'has_sig' for clarity.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-07 20:51:35 -05:00
Dave Reisner 0e79802c0a makepkg: use globs in place of regex
We seem to enjoy using bash regex capabilities, but never referencing
the result with BASH_REMATCH. Replace almost all regexes with equivalent
globs which are faster and functionally equivalent in these cases.

This enables the extglob shopt.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-06 11:46:01 -05:00
Dan McGee 8d0ff3d7dc dload: use intmax_t when printing off_t
This works for both 32-bit and 64-bit platforms.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-06 11:44:29 -05:00