Anything dealing with libintl and localization should be correctly guarded
inside an ENABLE_NLS block on both the pacman and libalpm sides.
Signed-off-by: Dan McGee <dan@archlinux.org>
This displays the download size, taking into account delta files and
cached files.
This closes FS#4182.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Delta files will be used if the size is smaller than a percent
(MAX_DELTA_RATIO) of the package size.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
We print the total to two decimal places, so there is no real need for
rounding of the values. Remove the rounding and switch all output to two
decimal places.
Signed-off-by: Dan McGee <dan@archlinux.org>
Root is needed for most install / remove operation, because it's needed
for chrooting, for running scriptlets.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Change the default visibility of libalpm functions to internal instead of
hidden- this allows for slightly better optimization because it tells GCC
that the function can never be called outside of the current module (see
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html).
Also added some attributes to the pacman print functions so that they check
the format strings being passed to them.
Signed-off-by: Dan McGee <dan@archlinux.org>
When the -Sy operation failed, the lock wasn't removed because
alpm_trans_release wasn't called. This is fixed now.
Also, after my last change in commit 52e7e6d747 ,
Sp didn't do anything anymore.
That's because needs_transaction returned false for -Sp, so the sync transaction
wasn't run. However, the current implementation of -Sp requires a sync transaction.
Also, since a transaction creates the lock file at the beginning, and releases it
at the end, this mean that -Sp requires root access anyway..
I think I understand now why Aaron found that the current -Sp implementation is hackish :)
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
I just moved the root path check out of needs_transaction, and put it directly
in pacman.c . I think this part is alright.
For the other problems, I thought about doing the transaction first, in a new
sync trans function, which will init and release a transaction. And then doing
the commands like -Ss / -Sl / -Sg / -Si.
The problem is that for commands like -Sys / -Syl / etc, only the refresh part
of the transaction should be done. So I had to introduce an ugly sync_only
hack.
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Included options are -g, -i, -s, and -l
All of these will sync the DB if -y is specified and permissions are
appropriate.
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Packages and DBs now support using the UNIX epoch (seconds since Jan 1, 1970)
for use in builddate and installdate. This will only affect newly built
packages. Old existing packages with the text format are still supported, but
this is deprecated.
In the case of removal of text time support, this code will fail gracefully,
returning the start of the epoch for broken packages.
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
In most cases, we want to fully scan a package when we load it, which serves
as a integrity verification check. However, there are times when it is only
desired to read the metadata and nothing else, so allow the caller of pkg_load
to choose the behavior they need.
This pays big dividends in speeding up pacman cache cleaning functionality.
Old (729 packages):
real 1m43.717s
user 1m20.785s
sys 0m2.993s
New (729 packages):
real 0m25.607s
user 0m19.389s
sys 0m0.543s
Signed-off-by: Dan McGee <dan@archlinux.org>
pacman/callback.c already did the work I set out to do with this commit, so
update the comments accordingly in the frontend and backend.
Signed-off-by: Dan McGee <dan@archlinux.org>
Partial cache cleaning was eliminated in a previous commit because it relied
on package naming conventions. Re-add it the correct way- we actually open
up each package in the cache and get a name and version out of it. If the
name and version match that of an installed package, keep it. If the package
is not installed or the version does not match the locally-installed version,
get rid of it.
This can easily be modified if some other heuristic of keeping and removing
packages is desired, or if we should clean out the cache dir of any files
that are not packages, etc.
The biggest current problem with this new approach- speed. Here is one run
on my local machine, going from 1643 to 729 packages in the cache (753 in
the local DB):
real 4m25.829s
user 3m22.527s
sys 0m6.713s
This is likely best addressed by the package loading scheme, which may be
loading the entirety of each package archive, which is a waste when we only
need the .PKGINFO file read.
Signed-off-by: Dan McGee <dan@archlinux.org>
Previously, package names must match a specified scheme or they will cause
pacman add operations to fail. This is not a very intelligent or necessary
way to act, so remove the dependency on the name of the package to be
installed and read all relevant information from the metadata instead.
This does have one causality to be addressed later- pacman cache cleaning
functionality, which has never been phenomenal, just lost most capability.
Signed-off-by: Dan McGee <dan@archlinux.org>
I suppose -Qii could be used for other things than displaying
the list of backup files, but currently, it's the only one,
so that's how I documented it..
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Add some alpm functions for getting optdepends, have makepkg include them
in the PKGINFO file, and have a pacman -Qi operation display the raw string
as stored by libalpm.
Signed-off-by: Dan McGee <dan@archlinux.org>
My two previous hacks related to this part
(8038190c7c and
b15a5194d1) were caused by the lack of
understanding of a feature introduced a while ago:
Better control over CTRL-C interruptions -- do not leave the DB in an
inconsistent state (54008798ef).
Now I have been looking at this commit, and the added feature is indeed
interesting. The main problem I had with it is that it does a rather
unusual use of alpm_trans_release, which caused a few problems that I tried
to fix in a weird way. I think these problems were caused by the fact that
there weren't any difference between "interrupt transaction" and "release a
transaction which failed" actions from the alpm_trans_release POV. So I
decided to add a new function instead, alpm_trans_interrupt, which is
called on Ctrl+C, and which only sets trans->state to STATE_INTERRUPTED so
that remove_commit and add_commit can exit cleanly at a safe moment. This
allowed me to revert my two previous hacks as well.
Also ensure we handle SIGINT correctly in all cases- if a transaction is
not ongoing, then we can free the transaction and exit quickly.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This reverts commit dfc85cb5f5
and b6f3fe6957.
This DB check is already in testdb (among others).
Also testdb now uses the db path set at make time by default,
so specifying the db path is optional.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
I'm currently working on python bindings for alpm written in pyrex. While
working i found that declaring alpm_strerror as
char * alpm_strerror (void)
instead of
char * alpm_strerror (int err)
and then using pm_errno in the implementation instead of err, could make it
more bindings-friendly.
Dan: cleaned up and added void to declaration. Instead of replacing existing
function, add a new function called 'alpm_strerrorlast(void)'.
Signed-off-by: Stefano Esposito <stefano.esposito87@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Introduce two new methods into the API - alpm_db_register_sync and
alpm_db_register_local, which replace the functionality of
alpm_db_register. db_register_local always returns the local DB, and
db_register_sync will always try to register a sync DB. This conceptually
separates the local DB from sync DBs in the code. Also updated the pacman
frontend to use the new functions. In addition, this changes the location
of all sync DBs in the filesystem from $DBPATH/$REPO to $DBPATH/sync/$REPO,
This removes the silly limitation that a sync DB couldn't be named 'local',
along with structurally separating sync DBs and the local DB in the
filesystem.
Signed-off-by: Travis Willard <travis@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This allows us to remove the hack in the frontend where we added a newline
to everything coming out of the pm_printf functions, and instead let the
developer put newlines where they want them. This should be the last hangover
of that auto-newline stuff.
Signed-off-by: Dan McGee <dan@archlinux.org>
Use the default cachedir (specified at compile time) if one wasn't specified
on the command line or in the config file.
Signed-off-by: Dan McGee <dan@archlinux.org>
A bunch of changes related to my first "real" install of pacman-git into
/usr/local and trying to use it.
* Shift some uses of free -> FREE in libalpm.
* Move stat and sanity checks of config paths into libalpm from the
config and argument parsing in pacman.c.
* Fix issue where dbpath still was not defined early enough due to its
requirement for being used in alpm_db_register. This should be rewritten
so it doesn't have this dependency, but this will work for now.
Signed-off-by: Dan McGee <dan@archlinux.org>
There's no need for a second hashing algorithm. MD5 serves the purpose
of verifying that a package file hasn't been corrupted during download.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Signed-off-by: Dan McGee <dan@archlinux.org>
The t shortcut for --test was removed,
the orphan option (previously -Qe) was renamed to -Qt,
-Qe lists all packages installed explictly,
and -Qd lists all packages installed as dependencies.
Besides, t can be combined with either e or d.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
The --foreign and --orphans functions now behave as a filter
for the other options. This cleans the code a bit, and will
make easier the adding of new filter options, like
explicit (show only explictly installed packages) or depends
(show only packages installed as dependencies).
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Remove some unnecessary headers in the two utilities as well as fix
a possible non-null termination issue in vercmp.
Signed-off-by: Dan McGee <dan@archlinux.org>
Remove the commented desc_localized stuff, we can find it later in version
control. Also remove some unnecessary includes of the stat header and
use -fstack-protector-all which is a bit more broad.
Signed-off-by: Dan McGee <dan@archlinux.org>
Instead of barfing when the root path and db path haven't been defined,
have pacman set them to some sane defaults when they aren't specified on
either the command line or the config file.
Also do some cleaning of error output and Doxygen comments.
Signed-off-by: Dan McGee <dan@archlinux.org>
.gitignore works recursively, so we don't need Makefile and Makefile.in
in all of the subdirectory .gitignore files.
Signed-off-by: Dan McGee <dan@archlinux.org>
This replaces the former -D operation that was undocumented and rather
hacky. It can be used with add, upgrade, or sync transactions and will affect
all packages installed. Should close FS #7193.
Also tell makepkg to use this new flag.
Signed-off-by: Dan McGee <dan@archlinux.org>
makepkg: We still need the source files in $srcdir because PKGBUILDS need
access to noextract() files and other file not handled by by
extract_source(). (eg config files)
query.c: Fix some output formating.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Remove unused buildtype field from pmpkg_t struct and anything associated
with it, as it is unused at the moment. If we need to readd it, it is an
easy revert of this commit.
Signed-off-by: Dan McGee <dan@archlinux.org>
There is no real reason to burden our translators with these messages, as
anyone helping to debug these will probably want them in English.
Signed-off-by: Dan McGee <dan@archlinux.org>
Changed the exit code for missing deps from 1 to 127 because 1 is used
for other errors. makepkg breaks if pacman exits with 1 for any reason
other than a missing dep.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
We shouldn't translate log messages to pacman.log so it is consistant and
can be parsed by other tools. Remove all gettext _() around these strings.
Signed-off-by: Dan McGee <dan@archlinux.org>
Move the translations from src/pacman/po to just po/ so we can include the
scripts gettext translations in the same message catalog as that of the
pacman frontend. The libalpm message catalog, for now, will remain a separate
existence.
Signed-off-by: Dan McGee <dan@archlinux.org>
Previously, the following error was displayed even after a valid
and successful query operation on all packages,
like -Q , -Ql, -Qi, -Qil :
no targets specified (use -h for help)
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
The -Ql operation is supposed to print all files but directories.
stat was used for detecting directories. However, when stat failed,
(because the file doesn't exist or is not readable), the files
were still displayed just like the others.
Now, these files are printed on stderr, with the corresponding error message.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
I previously introduced some patches to make just about every path in
pacman/libalpm configurable; doing this with the lockfile seemed a bit too
far and we really should just place the lockfile where it belongs- with the
DB that needs locking.
More details in this thread:
http://archlinux.org/pipermail/pacman-dev/2007-June/008499.html
Signed-off-by: Dan McGee <dan@archlinux.org>
The scriptlet calling had some unneeded complexity for the time being
which we aren't using here. Let's get rid of it until we find a good way
to implement it correctly.
Signed-off-by: Dan McGee <dan@archlinux.org>
Refactor the goto cleanup; statements out of add.c and remove.c, and move
what the cleanup: label did into a function.
Signed-off-by: Dan McGee <dan@archlinux.org>
Re-add some checks for a valid target list. In addition, move variable
declarations to the most local scope possible, which should help in finding
errors that were previously uncaught.
Signed-off-by: Dan McGee <dan@archlinux.org>
Move a lot of the operations that pacman query performs into their own
functions for ease of following the flow and for possible later merges with
their sync counterparts. We need to think less in terms of operations and
more in term of overall concepts.
Also (re)introduced checks for the target list on a -Q operation, ensuring
that we only call certain query operations when it is sane to do so.
Signed-off-by: Dan McGee <dan@archlinux.org>
This should hopefully allow multiple cache dirs to be specified in
pacman.conf and/or on the command line, and allow pacman to test
each one for the package file. The first one found to be writeable is
used as the download cache.
Signed-off-by: Dan McGee <dan@archlinux.org>
After adding a alpm_db_check() operation in the back end, we can call it
in the front end and present a user-friendly interface to it.
Inspired-by: VMiklos <vmiklos@frugalware.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
* Readd default logmask of ERROR and WARNING
* Remove DOWNLOAD log level as it no longer applies
* Add 'no targets' logic back in where it applies
* Switch some prints in parseconfig to ERROR
Signed-off-by: Dan McGee <dan@archlinux.org>
Remove the logmask functionality from the backend as it has been moved to
the frontend, and change the logging callback function to use pm_printf.
In addition, make much better use of va_list- use the args list instead
of a arbitrarily chosen string to print to in the logging functions.
Signed-off-by: Dan McGee <dan@archlinux.org>
Reorder some of the initilization stuff in pacman.c, as well as remove
some code that should be reimplemented elsewhere- checking the target
list to see if it is NULL.
Change the temp printf statements in parseconfig to pm_printf as well.
Signed-off-by: Dan McGee <dan@archlinux.org>
Add pm_printf, pm_fprintf, and pm_vfprintf to the pacman frontend for use by
debug printing and other output messages from pacman. These will be
incorporated into the log callback functions in the next iteration of
changes.
Signed-off-by: Dan McGee <dan@archlinux.org>
Add some 'const' keywords all over the code to make it a bit more strict on
what you can and can't do with data. This is especially important when we
return pointers to the pacman frontend- ideally this would always be
untouchable data.
Signed-off-by: Dan McGee <dan@archlinux.org>
The db variable was left unset when calling alpm_db_register, leading
to a failure to ever register a sync db. Also added a check to ensure
DBPath was set when trying to register a database.
Signed-off-by: Dan McGee <dan@archlinux.org>
Switch over to the new frontend parseconfig.
* Fix a few issues in parseconfig
* Remove unused callback upon database registration
* Remove conf file related errors from error.c/alpm.h
Signed-off-by: Dan McGee <dan@archlinux.org>
Move chomp, usecolor, and showsize out of the backend and into the
pacman frontend as they are pacman-specific options and not related
to the behavior of libalpm.
Signed-off-by: Dan McGee <dan@archlinux.org>
alpm.h is the only "publically viewable" file, so there is no reason to have
functions in alpm.c that belong in package.c, db.c, etc. Move the functions
where they belong and leave only the library init functions in alpm.c.
Signed-off-by: Dan McGee <dan@archlinux.org>
* Add vim modeline to Makefile.am and configure.ac
* Fix white space in Makefile.am and configure.ac
* Add contrib/wget-xdelta.sh to EXTRA_DIST in Makefile.am
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Signed-off-by: Dan McGee <dan@archlinux.org>
Remove any use of the former path variables defined by the Makefiles or
config.h. These are now runtime configurable only with pacman.conf (or by
using flags on the command line).
Signed-off-by: Dan McGee <dan@archlinux.org>
Clean up pacman_query so functionality is actually in functions, similar to how
sync.c is organized. After doing this, it is easy to see similarity in the code
between sync.c and query.c, so we should be able to consolidate some of this.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Also cleaned up some duplicate printf lines related to the ShowSize option.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This change allows us to use all autoconf specified paths, most notably
$(localstatedir). It is quite a change and touches a lot of files, as
all references to the DB and cache were done with the ROOTDIR as a prefix.
* add --lock command-line option to pacman to specify the location of the
lockfile (this can now be specified at configure time by setting the
$localstatedir path).
* Rip quite a few settings out of configure.ac as they are now picked by
setting the paths during configure or make.
* Fix bug with /tmp fallback for sync downloads not working correctly
(related to root location, now the system tmp dir is used).
* Simplified the parameters to some libalpm functions, and added get/set
for the new lockfile option.
* Renamed several of the DEFS to names without the PM_ prefix.
Signed-off-by: Dan McGee <dan@archlinux.org>
Regression from 2.9.8 where a failed -Qi lookup did not return an error
on exit. The exit status is now incremented for each error encountered.
Signed-off-by: Dan McGee <dan@archlinux.org>
Using the autoscan tool, ensure we are doing the checks we should be doing
in configure.ac. There is still more work to do, but this is a start at
cleaning up the file a bit to make it much easier to change in the future.
Signed-off-by: Dan McGee <dan@archlinux.org>
-Qee now lists "orphans" the way pacman used to - that
is, -Qe lists packages required by nothing that were
installed as a dependency, but -Qee lists all packages
not required by something else.
Also, I snuck in a compile fix for my real_path cleanup earlier, heh
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Removed some unneeded path munging so that our relative
paths resolve properly. This closes FS#7068
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
We had many unnecessary casts, most of them dealing with malloc and
other memory allocations. The variable type should take care of it;
no need to do it explicitly. In addition, I caught a const error while
removing the casts.
Signed-off-by: Dan McGee <dan@archlinux.org>
This patch adds a -z|--showsize option to the -Q and -S commands. The
option displays the size of individual packages. This is something that
I have wanted for a while, and there is a feature request for it.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>