Commit Graph

188 Commits

Author SHA1 Message Date
Dan McGee efd8ae483f Merge branch 'maint'
Conflicts:
	lib/libalpm/alpm.h
	lib/libalpm/trans.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-15 18:41:49 -05:00
Rémy Oudompheng aac9e7c280 Move documentation of public transaction functions to alpm.h 2011-04-09 22:36:43 +02:00
Rémy Oudompheng ff6f6027f0 Fix broken documentation for alpm_trans_prepare()
The current state of the code does not allow to see immediately
that it returns a list of pmdepmissing_t structures.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-09 15:24:11 -05:00
Rémy Oudompheng a479e0300b libalpm: set pm_errno correctly in alpm_trans_get_flags()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-09 15:24:05 -05:00
Dan McGee 0303b26b1e Style change: return(x) --> return x
This was discussed and more or less agreed upon on the mailing list. A
huge checkin, but if we just do it and let people adjust the pain will
end soon enough. Rebasing should be relatively straighforward for anyone
that sees conflicts; just be sure you use the new return style if
possible.

The following semantic patch was used to do the change, along with some
hand-massaging in order to preserve parenthesis where appropriate:

The semantic match that finds this problem is as follows, although some
hand-massaging was done in order to keep parenthesis where appropriate:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression a;
@@
- return(a);
+ return a;

// </smpl>

A macros_file was also provided with the following content:

Additional steps taken, mainly for ASSERT() macros:
$ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c
$ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 19:49:45 -05:00
Dan McGee f45369800a Check local DB version before continuing transaction
Ensure we have a local DB version that is up to par with what we expect
before we go down any road that might modify it. This should prevent
stupid mistakes with the 3.5.X upgrade and people not running
pacman-db-upgrade after the transaction as they will need to.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:46:00 -06:00
Dan McGee 5ea4706f57 Move locking functions to where they are needed
We only call these from the transaction init and teardown, so move them
to that file, mark them static, and push more of the logic of handle
manipulation into these functions.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:43:36 -06:00
Dan McGee 1eccae3d93 Fix trans no-argument function definitions
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:41:32 -06:00
Jonathan Conder acd9269478 Fix double close of the lock file
According to FOPEN(3), using fclose on an fdopen'd file stream also
closes the underlying file descriptor. This happened in _alpm_lckmk
(util.c), which meant that when alpm_trans_release closed it again, the
log file (which reused the original file descriptor) was closed instead.

Signed-off-by: Jonathan Conder <jonno.conder@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-27 13:32:41 -06:00
Dan McGee 6735807c0f Remove trans->skip_add
This is old code that has since gone stale; we no longer ever add
anything to this list so no need to keep it around and check the
contents during extraction.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-22 16:48:51 -06:00
Allan McRae d288240426 Update copyright years for 2011
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 18:47:37 -06:00
Allan McRae 81dd9d3ebc Detect undefined PATH_MAX
POSIX does not require PATH_MAX be defined when there is not actual
limit to its value.  This affects HURD based systems.  Work around
this by defining PATH_MAX to 4096 (as on Linux) when this is not
defined.

Also, clean up inclusions of limits.h and remove autoconf check for
this header as we do not use macro shields for its inclusion anyway.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-29 19:24:13 -06:00
Dan McGee a35610beba Merge branch 'maint'
Conflicts:
	lib/libalpm/be_local.c
	lib/libalpm/trans.c
2010-12-12 19:53:20 -06:00
Dan McGee eedf4f4e63 Fix possible null pointer deref in check_arch
If we have a corrupted database, a package can come through without an arch,
causing the code to blow up when making strcmp() calls. It might even be
possible with perfectly valid database entries lacking an 'arch =' line.
This behavior was seen as at least one of the problems in FS#21668.

Ensure pkgarch is not null before doing anything further.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-10 19:45:14 -06:00
Dan McGee 522ef5e981 Move the cache stuff where it should be
Cache bullshit only has relevance to be_files, so move it there.

Signed-off-by: Dan McGee <dan@archlinux.org>
[Allan: BIG rebase]
Signed-off-by: Allan McRae <allan@archlinux.org>
2010-10-13 23:53:18 +10:00
Jonathan Conder 693ebbd16b use execv to avoid using sh just to run ldconfig
Signed-off-by: Jonathan Conder <j@skurvy.no-ip.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-08-27 11:19:15 -05:00
Dan McGee d896527d21 fgets invocation cleanup
From the fgets manpage:

	fgets() reads in at most one less than size characters from stream and
	stores them into the buffer pointed to by s. Reading stops after an EOF
	or a newline. If a newline is read, it is stored into the buffer. A
	'\0' is stored after the last character in the buffer.

This means there is no need at all to do 'size - 1' math. Remove all of that
and just use sizeof() for simplicity on the buffer we plan on reading into.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-08-23 21:48:28 -05:00
Allan McRae 60de8ec932 Check return value of fgets calls
Prevents compiler warnings with -D_FORTIFY_SOURCE=2

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-07-07 07:24:57 -05:00
Allan McRae 59c47aaf52 Clarify testing within conditional statements
Follow the HACKING guidelines and always use != 0 or == 0 rather
than negation within conditional statements to improve clarity.
Most of these are !strcmp usages which is the example of what not
to do in the HACKING document.

Signed-off-by: Allan McRae <allan@archlinux.org>
2010-06-21 01:04:58 +10:00
Dan McGee a36ff9404b Bump copyright dates to 2010
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-14 19:46:59 -05:00
Laszlo Papp be266b4364 Refactor do/while cycle and multiple while cycles
* It makes the code clearer to read/understand
* Cppcheck tool doesn't show this anymore: [./util.c:215]: (error) Resource leak: fd

[Dan: don't change the coding style]
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-11-15 19:40:56 -06:00
Laszlo Papp 4281a1a7f2 Size handling was changed in fgets() functions
Pacman's fgets function in the API used hardcoded numbers to identify the size.
This is not good practice, so replace them with sizeof handling.

Signed-off-by: Laszlo Papp <djszapi@archlinux.us>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-19 07:37:53 -05:00
Xavier Chantry 14ab02e289 Rework the alpm_unpack functions
Add support to extract a list of entries

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11 15:18:47 -05:00
Dan McGee 145103aacc typing: a few more fixes for special int types
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11 14:41:59 -05:00
Xavier Chantry b4317a740a Change the interface for target loading
-int alpm_trans_sysupgrade(int enable_downgrade);
-int alpm_trans_sync(char *target);
-int alpm_trans_add(char *target);
-int alpm_trans_remove(char *target);
+int alpm_sync_sysupgrade(int enable_downgrade);
+int alpm_sync_target(char *target);
+int alpm_sync_dbtarget(char *db, char *target);
+int alpm_add_target(char *target);
+int alpm_remove_target(char *target);

* functions renaming
* add new sync_dbtarget which allows to specify the db
* repo/ syntax handling is moved to frontend
( should implement FS#15141)
* group handling is moved to backend
( see http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html )
2009-09-12 13:06:43 +02:00
Xavier Chantry 8ff3b87066 Remove transaction type
This basically started with this change :

 /* Transaction */
 struct __pmtrans_t {
-       pmtranstype_t type;
        pmtransflag_t flags;
        pmtransstate_t state;
-       alpm_list_t *packages;      /* list of (pmpkg_t *) */
+       alpm_list_t *add;      /* list of (pmpkg_t *) */
+       alpm_list_t *remove;      /* list of (pmpkg_t *) */

And then I have to modify all the code accordingly.
2009-09-08 22:17:41 -05:00
Nagy Gabor 0da96abc90 Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets

See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.

We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.

_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()

sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).

I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-08 22:04:14 -05:00
Xavier Chantry 5b27e78ba0 Check package arch before installing
This implements FS#15622

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-06 15:51:25 -05:00
Nagy Gabor 1d19f0896c Introduce -Suu
If the user switches from unstable repo to a stable one, it is quite hard to
sync its system with the new repo (the user will see many "Local is newer
than stable" messages, nothing more). That's why I introduced -Suu, which
treats a sync package like an upgrade, iff the package version doesn't match
with the local one's.

I added a new pactest (sync104.py) to test this, and I updated the
documentation of -Su.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
[Dan: slight doc reword]
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-22 20:16:52 -05:00
Xavier Chantry 2e043aae36 Run ldconfig inside chroot.
This fixes FS#15294.

The code to run a command inside a chroot was refactored from the
_alpm_runscriptlet function to _alpm_run_chroot.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-07-16 06:12:04 -05:00
Dan McGee c72b4543b6 Update copyright headers and messages
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-01 02:08:33 -05:00
Nagy Gabor 19b8b63885 Introduce _alpm_pkg_free_trans()
The main purpose of this function to make our code more readable.
It frees transaction specific fields of pmpkg_t. (It is used when a package
is removed from the target list.)

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-07 15:11:16 -05:00
Nagy Gabor c520d38451 Introduce PM_TRANS_FLAG_NOLOCK
This flag indicates that the front-end will not call alpm_trans_commit(),
so the database needn't be locked. This is the first step toward fixing
FS#8905.

If this flag is set, alpm_trans_commit() does nothing and returns with
an error (that has new code: PM_ERR_TRANS_NOT_LOCKED).

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-01 22:00:57 -05:00
Nagy Gabor aefb4e0fa5 Remove pmsyncpkg_t
pmsyncpkg_t data sructure was removed:
1. pmpkg_t.reason is used instead of pmsyncpkg_t.newreason. (The target
packages come from sync repos, so we can use this field without any
problems. Upgrade transaction also uses this field to store this info.)
2. pmsyncpkg_t.removes was moved to pmpkg_t.removes.
This step requires careful programming, because we don't duplicate packages
when we add them to trans->packages. So we modify sync pkgcache when we
add this transaction-only info to our package. Hence it is important to
free this list when we remove any package from the target list
(remove_unresolvable, remove_conflicts, trans_free), otherwise this could
confuse the new sync transactions (with non-pacman GUI).

Overall, our code became ~100 line shorter, and we can call our helper
functions directly on trans->packages in sync.c, we don't need to maintain
parallel package lists.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 14:05:13 -05:00
Xavier Chantry de97282fbd Revert "popen does NOT require /bin/sh in a subchroot"
This reverts commit 9558639d80.

This change was wrong, popen does require /bin/sh in a subchroot.

1) pacman -S lilo -r root

Notice no error

2) rm root/bin/sh ; pacman -S lilo -r root

Notice an error :
error: scriptlet failed to execute correctly

Actually, we already get an explicit error here, when popen is run, so there
is no need to check for bin/sh explicitely.

Besides this check was problematic in some cases. For example, bash itself
has a scriptlet, but only post_install and post_upgrade, no pre_install and
pre_upgrade. However, since bash has a scriptlet, runscriptlet will also be
called before bash is installed. It won't do anything since the scriptlet
has no pre_install function. But if we keep the check, we will still get
"error : no /bin/sh".

Conflicts:

	lib/libalpm/trans.c

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-03-15 11:41:37 -05:00
Xavier Chantry 36863b968f runscriptlet : Flush open fds before fork() to avoid cloning buffers
This is a bug I noticed 2 years ago :
http://www.nabble.com/Re%3A-logging-output-crazy-to11437357.html#a11479679

I thought I fixed it with 57d77eab32

But the bug was still here. Reading man fork, this part caught my attention:

*  The child inherits copies of the parent's set  of  open  file
descriptors.  Each  file descriptor  in  the  child refers to the same open
file description (see open(2)) as the corresponding file descriptor in the
parent.  This means that the two descriptors  share open  file  status
flags, current file offset, and signal-driven I/O attributes (see the
description of F_SETOWN and F_SETSIG in fcntl(2)).

Since the open file descriptors are inherited, it is probably a good idea to
flush them before forking.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-03-15 11:40:49 -05:00
Nagy Gabor 314b4462d2 -Qu rework
From now on -Qu is an "outdated package" filter on local database.
(This is a behaviour change.)

This patch fixes some memleaks and makes the code cleaner, for details see
my comment on FS#7884.

FS#11868 is implemented.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-10-31 19:46:13 -05:00
Dan McGee cd51abf0c8 Merge branch 'maint' 2008-10-28 22:20:09 -05:00
Dan McGee d1fec15d81 Correctly close the pipe used for scriptlet execution
We never had a call to pclose() in here before, leaving our file descriptor
in some sort of limbo state. In addition, clean up some of the other logic
such as directly calling exit(1) on a popen() failure rather than going to
our cleanup block, and handling and respecting the exit status of the
subprocess correctly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-10-18 23:59:28 -05:00
Dan McGee fa02a71abd Merge branch 'maint' 2008-10-12 21:36:45 -05:00
Dan McGee f9be2334f7 libalpm: handle syscall interruption correctly
It is possible to throw EINTR from a system call such as open(), close(), or
waitpid() if custom signal handlers are set up and they are not initialized
with the SA_RESTART flag. This was noticed by Andreas Radke when ^C (SIGINT)
was given during the call to waitpid(), causing it to throw the EINTR error
and we could not accommodate it.

Simply wrap these calls in a simple loop that allows us to retry the call if
interrupted.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-10-12 21:28:05 -05:00
Dan McGee da933c223e Remove unnecessary initialization in new functions
We don't need to zero things out, we are already using calloc for this
purpose.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-09-03 09:36:31 -05:00
Nagy Gabor 03021713e5 _alpm_db_add_pkgincache rework
Commit 8240da6cb3 broke some alpm hierarchy
and introduced a new memleak (trans->packages was never freed in case of add
transaction, even if the transaction wasn't committed), so it is reverted
now.

We follow a different approach to reduce memory usage:
_alpm_db_add_pkgincache doesn't duplicate the whole package before adding
it to the cache, only the package name and version (INFRQ_BASE).
This method needs very small extra memory (compared to the reverted method),
and after transaction commit we use less memory than before (since the
big 'files' fields are not copied to cache), this is useful in GUIs.

Note: The old add_pkgincache was a bit broken, since pkg->origin wasn't
filled in correctly.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Acked-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-15 19:16:42 -05:00
Dan McGee 29bf6814f7 Use access() instead of stat() when possible
We were using the stat() system call in quite a few places when we didn't
actually need anything the stat struct returned- we were simply checking for
file existence. access() will be more efficient in those cases.

Before (strace pacman -Ss pacman):
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 33.16    0.005987           0     19016           stat64

After:
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 34.85    0.003863           0     12633         1 access
  7.95    0.000881           0      6391         7 stat64

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-06-15 22:52:27 -05:00
Dan McGee 4c872594da Remove unnecessary header file, move one macro to util.c
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-06 20:20:20 -05:00
Chantry Xavier e7a2232934 Kill PM_TRANS_TYPE_ADD.
This was totally useless.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-17 21:01:22 -05:00
Nagy Gabor d060e31be3 Remove trans->targets
Its implementation was quite broken:
* add_loadtarget() might have silently filtered out some targets when
  replacing an older version.
* This was used in sync.c to determine whether a target is implicit or not,
  which is incorrect behavior. Before this patch we silently removed user
  confirmed replacements; now we always warn on a replacement.
* remove001.py behavior was quite odd in adding same target 5 times to the
  target list, we can change this behavior to be a failure.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
[Xav: changed remove001 pactest accordingly]
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
[Dan: rewrote commit message]
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-10 18:57:36 -05:00
Chantry Xavier 8240da6cb3 libalpm/cache.c : don't duplicate packages in pkgcache.
Edit _alpm_db_add_pkgincache to not duplicate packages, because this is not
needed, is slower, and uses more memory. This made the max memory usage
during base reinstall go from 10.4MB to 9.7MB.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-23 20:13:01 -06:00
Jaroslaw Swierczynski 801a268056 FS#9183 : force correct permissions on tmp/.
[Xav: removed unneeded makepath_internal function, and fixed the permission
value : 1777 -> 01777]
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-13 18:42:26 -06:00
Allan McRae 14d6832ef2 Allow NULL parameter in alpm_trans_commit
Fixes FS#7380: alpm crashes on passing NULL to alpm_trans_commit in
a sync operation.  Adds check that data parameter is not NULL in
several functions.

Signed-off-by: Allan McRae <mcrae_allan@hotmail.com>
[Dan: fix whitespace]
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-28 19:46:21 -06:00
Aaron Griffin 9558639d80 popen does NOT require /bin/sh in a subchroot
I appears that when chrooted, the /bin/sh used by popen is that of the parent
process. This is true until the process forks once chrooted, which we do not
want to do.

As such, this actually makes things nicer. We don't need a /bin/sh in a chroot
to run install scriptlets, and don't need to check for it in the root directory

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-10 23:03:16 -06:00
Aaron Griffin 565d2eeed5 Correct scriptlet usage pattern
The new pattern is as follows:
    . /path/to/scriptlet
    post_upgrade X Y

This requires less frameworking in the install scripts (the three lines that
shift and eval a function are nasty)

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-10 23:02:07 -06:00
Dan McGee 9781d0d637 Update GNU GPL boilerplate and copyright dates
Update the GPL boilerplate to direct people to the GNU website for a copy of
the license, as well as bump all of Judd's copyrights to 2007.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-10 22:55:39 -06:00
Chantry Xavier 8bee526d28 Fix a memleak in _alpm_sync_free.
An alpm_list_free call was missing.
Also make use of alpm_list_free_inner in both _alpm_sync_free and
_alpm_trans_free.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25 14:00:38 -06:00
Chantry Xavier 83fa6aa289 Remove duplicated get_upgrades function, use sysupgrade instead.
The alpm_get_upgrades was exactly the same as find_replacements +
_alpm_sync_sysupgrade, except that it automatically made the eventual
replacements, without asking the user : Replace %s with %s/%s? [Y/n]

The replace question, asked in find_replacements. can now be skipped by
using a NULL trans argument, so that we get the same behavior as with
alpm_get_upgrades.

So alpm_db_get_upgrades() can now be replaced by
alpm_sync_sysupgrade(db_local, syncdbs).

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-21 00:05:05 -06:00
Dan McGee 23b4e0270b Fix sh and scriptlet interaction
dash doesn't pass positional parameters to sourced scripts, causing install
scripts to fail. Instead of sourcing the script, make it executable and
call it directly which allows positional parameters to be passed correctly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-18 16:49:02 -06:00
Dan McGee 5f0c241987 POSIX shell does not specify meaning of source operation
Just use '.' operator instead. Oops.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-18 12:37:29 -06:00
Chantry Xavier c8be7540a5 Remove provide.c and provide.h .
This file only contained one private function : _alpm_db_whatprovides .
And the public alpm_db_whatprovides was in db.c , so I moved everything there.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
[Dan: updated POTFILES.in as well]
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17 09:50:05 -06:00
Dan McGee 3d10786394 Fix memleak in _alpm_trans_free with package lists
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17 09:39:00 -06:00
Dan McGee 2322909703 War on whitespace
Run the kernel's cleanfile script on all of our source files.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-16 20:18:45 -06:00
Dan McGee 7219326dd4 Remove REQUIREDBY usage from libalpm
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>
2007-11-14 18:49:50 -06:00
Chantry Xavier 0686fec839 Remove the newline automatically added by alpm_logaction.
This way, _alpm_logaction behaves like _alpm_log, and gives more control.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-11-04 18:04:43 -06:00
Dan McGee 006387828c Readd scriptlet logging that got lost in an earlier commit
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>
2007-11-04 11:27:41 -06:00
Dan McGee cc754bc6e3 libalpm: introduce MALLOC and CALLOC macros
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>
2007-10-29 01:00:52 -05:00
Chantry Xavier 3d7e06f204 libalpm/trans.c : fix a recently introduced breakage in scriptlets handling.
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>
2007-10-14 18:47:19 -05:00
Chantry Xavier 4e6a03c4f6 libalpm/trans.c : remove the DBPath <-> RootDir dependence in runscriptlet.
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>
2007-10-14 18:46:43 -05:00
Dan McGee b1613c2651 Clean up the scriptlet fork code a bit, honor the child return value
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-08 20:46:55 -05:00
Aaron Griffin 4853a4aad9 Fail loudly is scriptlets cannot be run via /bin/sh
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>
2007-10-04 21:36:25 -05:00
Chantry Xavier b0aa510592 trans.c : reworking of transaction interruptions
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>
2007-09-16 20:17:44 -05:00
Chantry Xavier b15a5194d1 libalpm/trans.c : remove the lock even on interrupted transactions.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-09-06 19:45:16 -05:00
Dan McGee 5c9eec5570 libalpm: add newlines to all strings passed to log callback
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>
2007-08-23 22:26:55 -04:00
Dan McGee c22e381a8b Post trial install changes, round one
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>
2007-08-21 21:28:05 -04:00
Nagy Gabor b1808930ce libalpm/add.c,trans.c : cleanup of requiredby handling.
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.html
http://www.archlinux.org/pipermail/pacman-dev/2007-July/008920.html

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-08-20 15:23:53 -04:00
Dan McGee fc65a9bcb1 Fix some errors spit out by -Wextra
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-16 16:19:06 -04:00
Dan McGee f0ea21cffc Ensure requiredby entries are removed during an upgrade
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>
2007-07-14 09:34:39 -04:00
Andrew Fyfe c0a7d9d82d Some doxygen comments.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
2007-07-12 16:00:58 -04:00
Dan McGee d402583c43 Remove some more conditional include stuff
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-12 16:00:35 -04:00
Dan McGee ea1fef69ad Remove gettext calls from all PM_LOG_DEBUG messages
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>
2007-07-10 14:24:58 -04:00
Chantry Xavier 57d77eab32 libalpm/trans.c : exit the forked process correctly in case of errors.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-07-09 17:47:05 -04:00
Dan McGee 1480ac29e4 Clean up the alpm handle
Add some comments in handle.h, and remove the pmaccess_t part that we
don't even use.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-09 15:23:26 -04:00
Dan McGee 4906e15d0d Remove gettext from any alpm_logaction calls
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>
2007-07-09 13:44:48 -04:00
Dan McGee ad691001e2 Remove scriptlet START and DONE commands that we don't use
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>
2007-06-27 22:12:59 -04:00
Dan McGee 64d36db5f4 Move functions out of alpm.c to where they belong
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>
2007-06-04 22:52:04 -04:00
Dan McGee ed13ac2cc8 Remove freespace checking code
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>
2007-06-02 13:17:26 -04:00
Dan McGee 2bcecbd62c Remove unnecessary casts on malloc and elsewhere
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>
2007-05-14 03:16:55 -04:00
Dan McGee 8bbb5dd078 libalpm util.c and util.h cleanup
* 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>
2007-04-29 12:47:02 -04:00
Dan McGee a57b2f233f Remove FREELISTPTR macro
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-28 03:54:25 -04:00
Dan McGee a3491224df Remove FREEPKG macro and correctly type _alpm_pkg_free
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-28 02:59:58 -04:00
Dan McGee 3cf8a333d0 Remove FREEGRP macro and correctly type _alpm_grp_free
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27 20:38:54 -04:00
Dan McGee ec7d6955b8 Remove FREESYNC macro and correctly type _alpm_sync_free
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27 14:53:01 -04:00
Dan McGee db9e10f142 Remove FREETRANS macro and correctly type _alpm_trans_free
Remove an unnecessary macro, and get rid of the void pointer.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27 14:29:23 -04:00
Dan McGee 75efcbbff6 Clean up gettext on the libalpm side
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>
2007-04-26 19:39:53 -04:00
Aaron Griffin 76f816b9f7 Backport changes from 3.0.1
* Align makepkg -g checksums (Tom Killian <tom@archlinux.org>)
* Use additional case-sensitive string compare to defeat locale issues (tr_TR)
* Added Russian mirror
* Fix a -R failure when trying to remove the same target twice
* Bump configure.ac version to 3.0.1

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-04-04 00:30:14 -05:00
Dan McGee 0203fabe54 * Fix an issue where the same dependency was recorded multiple times in the
'required by' field.
2007-03-12 04:47:58 +00:00
Aaron Griffin 166ffc4f9e * Bug fix for makepkg dependency testing. This requires that we
expose alpm_splitdep and alpm_depcmp as public symbols
* Removed a duplicate strtrim for question responses
2007-03-07 07:45:30 +00:00
Dan McGee 5baba84397 * Added missing header include guards in md5.h and sha1.h.
* 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.
2007-03-06 01:21:41 +00:00
Dan McGee 869e81e1cf This commit looks much more monumental than it is. Almost all just #include
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.
2007-03-05 22:13:33 +00:00
Dan McGee e24c22e308 * A little more hacking with wchar_t output, but nothing really changed in
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.
2007-03-03 09:43:16 +00:00
Aaron Griffin 7f5dada885 Big commit this time:
* 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
2007-03-03 08:13:59 +00:00
Aaron Griffin 4aca4980a7 *** empty log message *** 2007-03-01 05:42:53 +00:00