summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Do not compare signed and unsigned typesAllan McRae2010-06-30
| | | | | | | | | 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>
* Clarify testing within conditional statementsAllan McRae2010-06-21
| | | | | | | | | 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>
* Remove unnecessary gettext callDan McGee2010-06-05
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Allow to include a path containing wildcardsMarc-A. Dahlhaus2010-05-18
| | | | | | | Dan: line wrapping and man page touchup. Signed-off-by: Marc-A. Dahlhaus <mad@wol.de> Signed-off-by: Dan McGee <dan@archlinux.org>
* Allow Include directive in any sectionsXavier Chantry2010-05-17
| | | | | | | | | 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>
* Allow -Qo to perform a functional 'which'Allan McRae2010-05-11
| | | | | | | | | | | | When pacman queries the ownership of an object that is not a path, it will check in the users PATH for a match. Implements FS#8798. Dan: did some small refactoring and error message changes when PATH is searched and nothing is found. Original-patch-by: Shankar <jatheendra@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Improve documentation of -k/--dbonlyDan McGee2010-05-05
| | | | | | | 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>
* Remove unused 'z' option from getopt_long's optstringNagy Gabor2010-05-05
| | | | | | | 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>
* Introduce -D, --databaseNagy Gabor2010-05-05
| | | | | | | | | | | | | 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>
* Build vercmp without needing link to libalpmDan McGee2010-05-04
| | | | | | | | Include the object file directly from the libalpm version comparison code as it is the only thing we need. This drops the dependency of vercmp on libalpm and all of the stuff we know it drags in. Signed-off-by: Dan McGee <dan@archlinux.org>
* check for valid optarg before using strdupSerge Ziryukin2010-04-26
| | | | | | Signed-off-by: Serge Ziryukin <ftrvxmtrx@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Show --print and --print-format options with -Rh, -Sh and -Uh onlyNagy Gabor2010-03-25
| | | | | | | 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>
* Show 'Required By' in -Sii outputDan McGee2010-03-23
| | | | | | | | | | Just as we do in -Qi, we can compute required by information for sync database packages. The behavior seems sane; for a given package, the -Sii required by will show all packages in *any* sync database that require it. Implements FS#16244. Signed-off-by: Dan McGee <dan@archlinux.org>
* Strip extension off all package compression typesDan McGee2010-03-18
| | | | | | | | | Since we were searching for '.pkg.tar.gz' before, we now have started to show extensions during the download when we have a '.pkg.tar.xz' package. Just look for '.pkg.tar.' (or '.db.tar.') instead and suppress anything found from that point on. Signed-off-by: Dan McGee <dan@archlinux.org>
* Bump copyright dates to 2010Dan McGee2010-03-14
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* fix a few warnings reported by clangXavier Chantry2010-03-14
| | | | | | | | | - 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>
* Mark two functions staticDan McGee2010-03-14
| | | | | | | These were just introduced in the `--print` patch, and don't need to be exposed outside of util.c. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add new --print operation for all operationsXavier Chantry2010-03-14
| | | | | | | | | | | | | 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>
* print installed packagesXavier Chantry2010-03-14
| | | | | Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* callback: use variable length for progressbar textXavier Chantry2010-03-14
| | | | | | | | | | | | | | | | This fixes FS#17523 We always used a fixed value of 50 for textlen, which is often not enough for download progress bar. At least we can use a bigger width on large terminal (e.g. 60% of width) and keep 50 as minimum. before: nautilus-2.28.4-1-x... 5.7M 789.2K/s 00:00:07 [####################################] 100% after: nautilus-2.28.4-1-x86_64 5.7M 770.7K/s 00:00:08 [##############################] 100% Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* callback.c : less magic progress barsXavier Chantry2010-03-14
| | | | | | | | | | | | | | 1 - Explain magic numbers 2 - There was a weird off by 1 mess in the progress bar. The code supposedly shared the width between 50 chars for text (textlen) and the rest for the progress bar (proglen = getcols() - textlen). But the code actually used textlen + 1 for the text and proglen - 1 for the progress bar (with haslen=1, the progress bar was actually empty), which was a bit confusing so I changed it. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* delta : add external cleanup scriptXavier Chantry2010-03-14
| | | | | Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Do not print installed size when only downloadingAllan McRae2010-01-19
| | | | | | | | When using --downloadonly the "Total Installed Size" message is not needed and perhaps misleading. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Print "there is nothing to do" with NOOP transactionsNagy Gabor2010-01-19
| | | | | | | | | | | The "local database is up to date" message has been replaced with "there is nothing to do" message. This used with "empty" -S, -R, -U operations too. (Examples: pacman -S ignored_pkg, pacman -Ru needed_pkg.) See FS#17859. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* add some more sanity check for optargXavier Chantry2009-12-13
| | | | | | | | | | | 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>
* refactor _parseoptionsXavier Chantry2009-12-13
| | | | | | | | 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>
* Remove trailing whitespace on all lines in list_displayDan McGee2009-12-13
| | | | | | | | | | | | | | | | This ensures we never have trailing whitespace. Take the following text, with line numbers added for clarity: 1. Title : item1 item2 item3 item4 2. item5 item6 item7 item8 3. item9 itemA itemB itemC Laszlo Papp helpfully pointed out we would have two trailing spaces on line three after the last item. However, we also had these trailing spaces on lines one and two, which the initial patch didn't take care of. This can be seen on something like `pacman -Qi glibc`. Signed-off-by: Dan McGee <dan@archlinux.org>
* download: major refactor to address lingering issuesDan McGee2009-11-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Refactor do/while cycle and multiple while cyclesLaszlo Papp2009-11-15
| | | | | | | | * 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>
* Merge branch 'maint'Dan McGee2009-11-10
|\
| * Fix opendir error condition checksDan McGee2009-10-27
| | | | | | | | | | | | | | | | | | | | Thanks to Laszlo Papp <djszapi@archlinux.us> for the following catch: opendir(path)) == (DIR *)-1; is maybe the result of misunderstanding the manpage. If an opendir() call isn't successful it returns NULL rather than '(DIR *)-1'. Noticed-by: Laszlo Papp <djszapi@archlinux.us> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Size handling was changed in fgets() functionsLaszlo Papp2009-10-19
| | | | | | | | | | | | | | | | 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>
* | Replace hardcoded option numbers with enumerationLaszlo Papp2009-10-12
| | | | | | | | | | | | | | | | 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>
* | Remove makepath function from frontendLaszlo Papp2009-10-11
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | cygwin fix : use unsigned char for ctype functionXavier Chantry2009-10-11
| | | | | | | | | | | | | | | | | | | | | | | | See http://www.nabble.com/-PATCH-RFA--Distinguish-between-EOF-and-character-with-value-0xff-td23161772.html#a23188494 cygwin 1.7 actually displays a warning when using signed char with the ctype function, so that compilation fails when using -Wall -Werror. So we just cast all arguments to unsigned char. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Minor scope/typing cleanupsDan McGee2009-10-11
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2009-10-11
|\|
| * callback.c : fallback to normal download with bogus sizeXavier Chantry2009-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using totaldownload, we might get into some weird situations where xfered>total because of bogus CSIZE database entries. This code adds a sanity check and fallbacks to normal download progress if needed. Here is an example using totaldownload on a database with wrong CSIZE, for a total download of ~26 MB. Before : gnome-desktop-2.28.... 1144,3K 678,3K/s 00:00:02 [#################] 4% gnome-panel-2.28.0-... 4,2M 887,7K/s 00:00:05 [#################] 16% gnome-applets-2.28.... 13,6M 1083,0K/s 00:00:13 [#################] 52% gnome-backgrounds-2... 22,9M 964,0K/s 00:00:24 [#################] 87% gnome-settings-daem... 23,6M 938,5K/s 00:00:26 [#################] 90% gnome-control-cente... 26,1M 946,1K/s 00:00:28 [#################] 100% gnome-icon-theme-2.... 27,7M 1465,0K/s 1193046:28:15 [#######----------] gnome-icon-theme-2.... 28,0M 1502,2K/s 1193046:28:15 [########---------] gnome-icon-theme-2.... 28,4M 1582,2K/s 1193046:28:15 [##########-------] gnome-icon-theme-2.... 28,7M 1603,4K/s 1193046:28:15 [############-----] gnome-icon-theme-2.... 29,0M 1604,5K/s 1193046:28:15 [##############---] gnome-icon-theme-2.... 29,3M 1621,0K/s 1193046:28:14 [################-] gnome-icon-theme-2.... 29,6M 1434,8K/s 1193046:28:14 [#################] gnome-icon-theme-2.... 29,6M 974,2K/s 00:00:31 [#################] 113% After : gnome-desktop-2.28.... 1144,3K 1038,7K/s 00:00:01 [#################] 4% gnome-panel-2.28.0-... 4,2M 988,4K/s 00:00:04 [#################] 16% gnome-applets-2.28.... 13,6M 1190,4K/s 00:00:12 [#################] 52% gnome-backgrounds-2... 22,9M 1242,9K/s 00:00:19 [#################] 87% gnome-settings-daem... 23,6M 1193,9K/s 00:00:20 [#################] 90% gnome-control-cente... 2,5M 1347,4K/s 00:00:02 [#################] 100% gnome-icon-theme-2.... 3,5M 1205,4K/s 00:00:03 [#################] 100% Note that gnome-control-center resetted to normal progress mode (2,5M is the package size, not the total size) Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | testdb : fix many memleaksXavier Chantry2009-09-22
| | | | | | | | | | | | | | | | | | | | Yes, it was that bad :P We still have memleaks left because we cannot free the error data returned by libalpm, but pacman has the same issue. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Allow cache cleaning to process all cache directoriesDan McGee2009-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we only looked at the first cache directory returned by the library. This allows us to look at all cache directories for cleaning. In addition, change the way we do a full (-Scc) cache cleaning operation. Instead of removing the parent directory, remove each package one-by-one as in the -Sc case. This would be ideal for someone mounting a cache directory over NFS, as it ensures we don't wipe out the mountpoint from underneath the directory. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Propagate return status up in DB cleaning codeDan McGee2009-09-21
| | | | | | | | | | | | | | We didn't look at the return status of sync_cleandb() in sync_cleandb_all(). Make it do so and return it up the call chain. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add missing closedir calls in cache cleanupDan McGee2009-09-21
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Fully implement database lazy loadingDan McGee2009-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'maint'Dan McGee2009-09-20
|\| | | | | | | | | | | | | | | Message updates made this one a bit messy, but nothing too bad. Conflicts: lib/libalpm/add.c lib/libalpm/remove.c
| * Strndup usage and small typo fixLaszlo Papp2009-09-20
| | | | | | | | | | | | | | | | | | | | | | ./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>
| * Kill -F option for good in option parsingDan McGee2009-09-18
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
| * String improvementsXavier Chantry2009-09-16
| | | | | | | | | | | | | | Add more untranslated strings, improve consistency, etc. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
| * Revert "Fix a memleak involving lazy DB loading"Dan McGee2009-09-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Fix a memleak involving lazy DB loadingXavier Chantry2009-09-08
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Ask user confirmation for -R operation, tooNagy Gabor2009-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After commit 0da96abc, pacman always asks user confirmation for -U, so it is more coherent to doing that for -R, too. Btw, most users use -Rs always, so they won't notice any change. In the old code the -Ru operation was forgotten: Though it is a not "dangerous" operation, but the target list can be changed by that, too. Non-interactive scripts should always use --noconfirm (unexpected questions can be asked by all transactions). [That's why we should always default to the safest answers.] I've also added a pkglist != NULL sanity check (because -Ru can empty target list in trans_prepare part). Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>