summaryrefslogtreecommitdiff
path: root/src/pacman/pacman.c
AgeCommit message (Collapse)Author
2011-01-31Allow both cleanmethod values to be specified at the same timeDan McGee
No reason to disallow this- it allows keeping even more packages around in the cache. Test cases included for this case and to ensure the default behavior is preserved. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-29Remove need to explicitly register the local DBDan McGee
Perform the cheap struct and string setup of the local DB at handle initialization time to match the teardown we do when releasing the handle. If the local DB is not needed, all real initialization is done lazily after DB paths and other things have been configured anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-12Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/be_files.c
2011-01-11Make debug config messages consistent in capitalizationDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07Fix some more simple conversion "errors"Dan McGee
None of these warn at the normal "-Wall -Werror" level, but casts do occur that we are fine with. Make them explicit to silence some warnings when using "-Wconversion". Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07Update copyright years for 2011Allan McRae
Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-30Declare all local functions staticAllan McRae
All functions that are limited to the local translation unit are declared static. This exposed that the _pkg_get_deltas declaration in be_local.c was being satified by the function in packages.c which when declared static caused linker failures. Fixes all warnings with -Wmissing-{declarations,prototypes}. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12Add configuration option to control disk space checkingAllan McRae
Disk space checking is likely to be an unnecessary bottleneck to people with reasonable partition sizes so add a configuration option to allow it to be disabled/enabled as wanted. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12Remove AC_TYPE_SIGNAL usageDan McGee
This macro is deemed unnecessary by even the autoconf guys, so we really don't need to use it. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12alpm/remove.c : respect --dbonly during remove-upgradeXavier Chantry
When a -Sk or -Uk operation induced a removal of an existing local package, --dbonly was not in effect and the files were all removed. Fixing this behavior was already marked as TODO in database012 pactest ------------ TODO: I honestly think the above should NOT delete the original les, it hould upgrade the DB entry without touching anything on the file stem. E.g. this test should be the same as: pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz ------------ Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> [Dan: small coding style touchup] Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12pacman: sort --help outputXavier Chantry
Example with pacman -Uh : $ pacman -Uh options: -b, --dbpath <path> set an alternate database location -d, --nodeps skip dependency checks -f, --force force install, overwrite conflicting files -k, --dbonly only modify database entries, not package files -r, --root <path> set an alternate installation root -v, --verbose be verbose --arch <arch> set an alternate architecture --asdeps install packages as non-explicitly installed --asexplicit install packages as explicitly installed --cachedir <dir> set an alternate package cache location --config <path> set an alternate configuration file --debug display debug messages --ignore <pkg> ignore a package upgrade (can be used more than once) --ignoregroup <grp> ignore a group upgrade (can be used more than once) --logfile <path> set an alternate log file --noconfirm do not ask for any confirmation --noprogressbar do not show a progress bar when downloading files --noscriptlet do not execute the install scriptlet if one exists --print only print the targets instead of performing the operation --print-format <string> specify how the targets should be printed Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> [Dan: small coding style touchups] Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12CLI args: update --help and manpageXavier Chantry
The three parts (help, manpage and code) are now organized in the same way and much easier to compare : - specific options - install/upgrade options for -S and -U - transaction options for -S -R and -U - global options After this re-organization, it was easy to update and sync the three components together. Duplication is also avoided. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12Ensure stdin args are correctly terminatedDan McGee
And don't require pm_targets to be empty to read from stdin either. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-11-04Support reading package args from stdinDave Reisner
Only occurs if no arguments were provided directly. Arguments can be separated by any amount of valid whitespace. This allows for piping into pacman from other programs or from itself, e.g.: pacman -Qdtq | pacman -Rs This is better than using xargs, as xargs will not reconnect stdin to the terminal. The above operation performed using xargs would require the --noconfirm flag to be passed to pacman. Signed-off-by: Dave Reisner <d@falconindy.com>
2010-10-11CLI args: stricter/better parsingJakob Gruber
In the following, the letters SRUDQ refer to the corresponding pacman operations. Most of the work in this commit is about removing as many options as possible from the global section and moving them to where they actually belong. Additionally, --ignore{,group} are added to U and --dbonly is added to S. --dbonly added to S --asdeps moved to S/U/D --asexplicit moved to S/U/D --print-format moved to S/U/R --noprogressbar moved to S/U/R --noscriptlet moved to S/U/R --ignorepkg added to U --ignoregrp added to U -d moved to S/U/R (--nodeps) and Q (--deps) -p moved to S/U/R (--print) and Q (--file) -f moved to S/U Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-11CLI args: reorganize parsingJakob Gruber
Split parsing of CLI arguments into separate functions: parsearg_op (operations) parsearg_global (global options) parsearg_{database,query,remove,sync,deptest,upgrade} Organization strictly follows the manpage (even where the manpage is incorrect) - these cases will be fixed in the following commits. Switch cases are copy/pasted and statements unrelated to chosen operation are deleted. Parsing logic adjusted as follows: 1) Parse operation 2) If we can bail out early (duplicate op, help/version requested) do so 3) Parse arguments again: foreach arg: if arg is operation: continue tryparse_args_specific_to_op if unsuccessful tryparse_args_global if unsuccessful print error message and exit Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-07-01Check return value of chdir and getcwdAllan McRae
Prevents compiler warnings when building with -D_FORTIFY_SOURCE=2 Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-06-30Do not compare signed and unsigned typesAllan McRae
The casting of nread is safe as it is tested to be >0 when it is initally assigned. It is also being implicitly cast in the fwrite call in the line above. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-18Allow to include a path containing wildcardsMarc-A. Dahlhaus
Dan: line wrapping and man page touchup. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-17Allow Include directive in any sectionsXavier Chantry
Fix a regression of 51f9e5e40a7 that only allowed Include in repo sections. Thanks to Marc - A. Dahlhaus for reporting the issue. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-05Improve documentation of -k/--dbonlyDan McGee
We had the long option wrong in some places and its behavior wasn't documented at all with regards to -U/--upgrade. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-05Remove unused 'z' option from getopt_long's optstringNagy Gabor
In addition, I permuted shortopts to make it more readable. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-05Introduce -D, --databaseNagy Gabor
The request of FS#12950 is implemented. On the backend side, I introduced a new function, alpm_db_set_pkgreason(), to modify the install reason of a package in the local database. On the front-end side, I introduced a new main operation, -D/--database, which has two options, --asdeps and --asexplicit. I documented this in pacman manual. I've created two pactests to test -D: database001.py and database002.py. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-04-26check for valid optarg before using strdupSerge Ziryukin
Signed-off-by: Serge Ziryukin <ftrvxmtrx@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-25Show --print and --print-format options with -Rh, -Sh and -Uh onlyNagy Gabor
http://mailman.archlinux.org/pipermail/pacman-dev/2010-March/010519.html Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-14Bump copyright dates to 2010Dan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-14fix a few warnings reported by clangXavier Chantry
- remove unused variables - some more sanity checks - safer printf Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-14Add new --print operation for all operationsXavier Chantry
And a new --print-format option to configure the output. This implements FS#14208 Example usage : pacman -Sp --print-format "%r/%n-%v : %l [%s]" kdelibs extra/kdelibs-4.3.2-4 : ftp://mir2.archlinuxfr.org/archlinux/extra/os/i686/kdelibs-4.3.2-4-i686.pkg.tar.gz [0,00] Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-12-13add some more sanity check for optargXavier Chantry
getopt should already ensure that optarg is not NULL when an argument is required, but just be extra safe and double check it before using optarg. To be honest, I only did that to make clang shut up and eliminate the last warnings it reported. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-12-13refactor _parseoptionsXavier Chantry
This function was quite huge (~230 lines) and difficult to parse, now it is slightly better. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-11-15download: major refactor to address lingering issuesDan McGee
Sorry for this being such a huge patch, but I believe it is necessary for quite a few reasons which I will attempt to explain herein. I've been mulling this over for a while, but wasn't super happy with making the download interface more complex. Instead, if we carefully order things in the internal download code, we can actually make the interface simpler. 1. FS#15657 - This involves `name.db.tar.gz.part` files being left around the filesystem, and then causing all sorts of issues when someone attempts to rerun the operation they canceled. We need to ensure that if we resume a download, we are resuming it on exactly the same file; if we cannot be almost postive of that then we need to start over. 2. http://www.mail-archive.com/pacman-dev@archlinux.org/msg03536.html - Here we have a lighttpd bug to ruin the day. If we send both a Range: header and If-Modified-Since: header across the wire in a GET request, lighttpd doesn't do what we want in several cases. If the file hadn't been modified, it returns a '304 Not Modified' instead of a '206 Partial Content'. We need to do a stat (e.g. HEAD in HTTP terms) operation here, and the proceed accordingly based off the values we get back from it. 3. The mtime stuff was rather ugly, and relied on the called function to write back to a passed in reference, which isn't the greatest. Instead, use the power of the filesystem to contain this info. Every file downloaded internally is now carefully timestamped with the remote file time. This should allow the resume logic to work. In order to guarantee this, we need to implement a signal handler that catches interrupts, notifies the running code, and causes it to set the mtimes on the file. It then rethrows the signal so the pacman signal handler (or any frontend) works as expected. 4. We did a lot of funky stuff in trying to track the DB last modified time. It is a lot easier to just keep the downloaded DB file around and track the time on that rather than in a funky dot file. It also kills a lot of code. 5. For GPG verification of the databases down the road, we are going to need the DB file around for at least a short bit of time anyway, so this gets us closer to that. Signed-off-by: Dan McGee <dan@archlinux.org> [Xav: fixed printf with off_t] Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-11-15Refactor do/while cycle and multiple while cyclesLaszlo Papp
* 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-10-12Replace hardcoded option numbers with enumerationLaszlo Papp
Pacman's long option parsing used hardcoded numbers to identify them. This is not good practice, so replace them with enumeration constants. Signed-off-by: Laszlo Papp <djszapi@archlinux.us> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11Minor scope/typing cleanupsDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-20Fully implement database lazy loadingDan McGee
Commit 34e1413d75 attempted to implement lazy loading of package databases. Although it took care of my main complaint (creating the database directory if it didn't exist), it didn't allow sync repos to be registered before alpm_option_set_dbpath() had been called. With this patch, we no longer compute the individual repository DB paths until necessary, allowing full lazy loading to work as intended, and allowing us to drop the extra setlibpath() calls from the frontend. This allows the changes introduced in a2cd48960 (but later reverted) to be added back in again. Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-20Merge branch 'maint'Dan McGee
Message updates made this one a bit messy, but nothing too bad. Conflicts: lib/libalpm/add.c lib/libalpm/remove.c
2009-09-20Strndup usage and small typo fixLaszlo Papp
./src/pacman/package.c: - small typo fix ./src/pacman/pacman.c: - strdup is changed to strndup, because it's safer like in case of config option Signed-off-by: Laszlo Papp <djszapi2@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-18Kill -F option for good in option parsingDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-16String improvementsXavier Chantry
Add more untranslated strings, improve consistency, etc. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-14Revert "Fix a memleak involving lazy DB loading"Dan McGee
This doesn't quite work, as can be seen by the pactest results: Total = 179 Pass = 108 ( 60.34%) Expected Fail = 5 ( 2.79%) Unexpected Pass = 0 ( 0.00%) Fail = 66 ( 36.87%) If you peek inside '_alpm_db_new' when it gets called for the sync databases, the base dbpath is still at the default value, causing things like pactest to fail miserably. We need some further work to do fully lazy loading, and that belongs on master, not maint. This reverts commit a2cd48960e33043f75c81e0ecbc2d33b20b695fe. Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-08Re-add the non-user friendly --ask optionXavier Chantry
This re-implements the --ask option which was removed in commit 1ff8e7f364a9f640ada7526384646d510ac29967. This option does not have to be exposed to the user (help,doc,etc), but is very very useful for pactest if we want to have more coverage there. This was rewritten in a smarter way, without code duplication. And with a different behavior : this option is now only used to inverse default behavior to questions. We still use bit operations based on the following struct : /* Transaction Conversations (ie, questions) */ typedef enum _pmtransconv_t { PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01, PM_TRANS_CONV_REPLACE_PKG = 0x02, PM_TRANS_CONV_CONFLICT_PKG = 0x04, PM_TRANS_CONV_CORRUPTED_PKG = 0x08, PM_TRANS_CONV_LOCAL_NEWER = 0x10, PM_TRANS_CONV_REMOVE_PKGS = 0x20, } pmtransconv_t; for each conv matched, the default answer is inversed. --ask 0 : all default answers are preserved --ask 4 : only conflict question is inversed --ask 63 : all questions are inversed (63 == 1+2+4+8+16+32) Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-08Fix a memleak involving lazy DB loadingXavier Chantry
Lazy opening of databases is supported since 34e1413d75. We don't need that setlibpath call each time we register a database. Besides this caused a memleak in case setlibpath failed, because setlibpath exit directly and we did not do the cleanup part (section string was not freed, and a file descriptor remained open). Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-07use strreplace in the xfercommand codeXavier Chantry
this operation was re-implemented using static strings, instead of using the existing strreplace function Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-06fix small memleak in an error caseXavier Chantry
Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-06Log commandline in pacman/alpm logXavier Chantry
This implements FS#11452. Original-work-by: silvio <silvio@port1024.net> Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-06Allow $arch to be used in ServerXavier Chantry
similarly to the $repo variable, Server can now contain $arch, which will be automatically replaced by the appropriate architecture. This allows us to have one universal mirrorlist file, for both i686 and x86_64, woohoo! Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-06Add Architecture and --arch optionXavier Chantry
Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-08-18dload.c : various fixesXavier Chantry
- fix one memleak if get_filename failed - cleanup according to Joerg's feedback: "url_for_string: If fetchParseURL returned successful, you should always have a scheme set. The logic for anonftp should only be needed for very broken server -- do you know of any such? download_internal: Specifying 'p' is now a nop -- it is tried by default first with fall-back to active FTP." Signed-off-by: Xavier Chantry <shiningxc@gmail.com> [Dan: remove from pacman.conf and pacman.conf.5] Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-26Ensure version screen fits in 80 colsDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-22Add a fetch callback to allow front-end download supportSebastian Nowicki
This allows a frontend to define its own download algorithm so that the libfetch dependency can be omitted without using an external process. The callback will be used when if it is defined, otherwise the old behavior applies. Signed-off-by: Sebastian Nowicki <sebnow@gmail.com> [Dan: minor cleanups] Signed-off-by: Dan McGee <dan@archlinux.org>