Instead of using the often-busted REQUIREDBY entries in the pacman database,
compute them each time they are required. This should help many things:
1. Simplify the codebase
2. Prevent future database corruption
3. Ensure when we do use requiredby, it is always correct
4. Shrink the pmpkg_t memory overhead
Signed-off-by: Dan McGee <dan@archlinux.org>
I broke scriptlet logging with ad691001e2.
Readd more or less what was there before, although it still needs a lot of
work including hopefully rewriting it to a new event subsystem and having
it log to a seperate file.
Signed-off-by: Dan McGee <dan@archlinux.org>
These macros take the place of the common 4 or 5 line blocks of code we had
in most places that called malloc or calloc. This should reduce some code
duplication and make memory allocation more standard in libalpm.
Highlights:
* Note that the MALLOC macro actually uses calloc, this is just for safety
so that memory is initialized to 0. This can be easily changed in one
place.
* One malloc call was completely eliminated- it made more sense to do it
on the stack.
* The use of RET_ERR in public functions (mainly the alpm_*_new functions)
was standardized, this makes sense so pm_errno is set.
Signed-off-by: Dan McGee <dan@archlinux.org>
Commit 4853a4aad9 used the tmpdir variable
for checking the existence of /bin/sh, without resetting it.
This caused /bin/sh to be deleted during the cleanup part, as soon as a scriptlet
other than pre_upgrade or pre_install was executed.
For example, on the first post_upgrade during a -Su.
I introduced two variables : clean_tmpdir and restore_cwd, for deciding what should
be done in the cleanup part.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
This code assumed that DBPath was under RootDir, while this is not necessarily the case :
pacman doesn't enforce anymore than DBPath is under RootDir.
So now, all scriptlets will be put somewhere in RootDir/tmp/, so that when it chroots in RootDir,
the scriptlets are still available inside the chroot.
This also removes the need of normalizing both dbpath and rootdir, in order to do computation on the paths.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
If /bin/sh is missing in the root directory, scriptlets cannot be executed, as
we're explicitly calling it.
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
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 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>
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>
This patch cleans up and fix the _alpm_trans_update_depends function
and ensure that all requiredby fields are filled in case of multiple satisfiers
(previously, the handling of mutliple satisfiers in that function was inconsistent).
This makes a special case handling of requiredby in commit_single_pkg() obsolete,
and so allows cleaning that code as well.
Also fixed upgrade056 pactest because :
1) the requiredby fields were wrong, and this wouldn't happen with the fixed _alpm_trans_update_depends().
2) this is a very unusual case anyway (and handling all corner cases combined to a broken database
seems nearly impossible to achieve).
References :
http://www.archlinux.org/pipermail/pacman-dev/2007-July/008919.htmlhttp://www.archlinux.org/pipermail/pacman-dev/2007-July/008920.html
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
This fixes the failure of the requiredby004 pactest in a not so pretty way,
but it gets the job done. I purposely used the extremely long name of
PM_TRANS_TYPE_REMOVEUPGRADE to be both clear and in the hope that someone
else will figure out a better solution.
Original idea from Nagy Gabor, patch updated and cleaned for current code.
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>
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>
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>
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>
This code depends on /etc/mtab existance, which is not very reliable in all
cases, especially in a chroot or non-Linux environment. Dump it for now
until we can find a better way.
Signed-off-by: Dan McGee <dan@archlinux.org>
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>
* Remove some unnecessary conditional compiling in util.h- move the
functions tha required it to trans.c (along with a bunch of new header
includes).
* Clean up util.h a bit- remove some header includes, remove universal
libarchive include and only put it in the files that need it.
Signed-off-by: Dan McGee <dan@archlinux.org>
Remove inclusion of libintl.h from all files, because we can do it once
in util.c where the _() macro is defined.
Signed-off-by: Dan McGee <dan@archlinux.org>
* Some header cleanup on the pacman side of things - we had alpm.h instead
alpm_list.h in a few headers.
* removed an extra slash in path-building snprintf in server.c.
reordering and adding ones that were forgotten (noticed when trying to
compile after reordering).
* Updated the HACKING file to include information on #include usage.
* print -> vprint in "making dir" function in pactest.
it. Eventually we'll make progress.
* Rewrote the _alpm_splitdep function to behave more like all our other
function calls. Use heap instead of stack allocation for the depend struct,
so now it needs to be freed by the caller.
* Moved entirely to alpm_pkg_get_* accessors, to read data on demand
* Mostly removed the INFRQ_ parameters from outside the be_files backend (making
the backend more extensible in the long run)
* packages created from _alpm_db_scan now have the db and origin set (making
accessors actually work for these packages)
* removed _alpm_db_ensure_pkgcache
* totally revamped the _alpm_checkconflicts function, making it cleaner and
easier to read (and thus fix in the long run) - maintainable code ftw
NOTE: feel free to rename the functions... I couldn't think of anything better
* removed an extra loop in sync.c:find_replacements - no sense in looping over
an entire DB while strcmp'ing the name, when we have get_pkgfromcache
Other:
* package struct "license" -> "licenses"
* Created _alpm_sync_find (duplicate code in some places, find_pkginsync
* Minor const correctness changes along the way
* fixed a couple extra '/' pathing issues (non-issues really)
* removed a duplicate pkg_cmp function
* Unified some functions names "package" -> "pkg" for consistency
* Removed the goofy 'faketarget' stuff used for dep testing
* Renamed alpm_pkg_isin -> alpm_pkg_find
* Renamed alpm_db_readpkg -> alpm_db_get_pkg
from one package to another seemlessly (knock on wood). This is implemented
through the use of two skip lists in the trans struct- skip_add and
skip_remove, which replace the former trans->skiplist.
* Removed an unnecessary function parameter, added a necessary one.
* If a package has no backup files, print '(none)' under the heading so it is
more obvious.
* Updated my TODO list.
* alpm_list_is_in --> alpm_list_find
* alpm_list_is_strin --> alpm_list_find_str
* Flip parameters of both functions to be inline with rest of alpm_list.
First commit, woohoo.
optimizations in order to make the code much more readable and
type-checkable. Every enum in the library now has it's own type that
should be used instead of the generic 'unsigned char'. In addition,
several #define statements dealing with constants were converted to
enums.
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* renamed pmlist_t -> alpm_list_t
* made alpm_list_t a public type (alpm_list.h header)
* removed additional storage for registered DBs in pacman source
* some code cleanup
* removed duplicate (pm)list_display functions from pacman source
* misc code cleanup
* Modified some dependancy checking
* Changed "performing local database upgrade" message to be more clear
* Change 'usize' to 'isize' in database files
* Scriptlet output is now sent to pacman's log file
* Limited some debugging output to be more clear
* Furthered the "lazy caching" to force the pkgcache to read nothing
(INFRQ_NONE) by default. Anything requiring package data should now check
the infolevel of each package and attempt to update it. This could be
ironed out a bit more later (by using the front-end get_info function
* Switched to libfetch. Drastic changes to the download code and the callback
progress bar functions. Also fixed the return value of
_alpm_downloadfiles_forreal. Downloading now supports http, ftp, https, and
files urls, along with 'mtime's and numerous other fancy features from
libfetch.
* Removed the PMList typedef, in favor of the same naming scheme other
structs use 'pmlist_t'
* Added a time stamp on debug output, to make it more informational
* Moved alpm_db_register to _alpm_db_register, making the public function
not take a callback parameter