4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 #include <alpm_list.h>
40 /* if keep_used != 0, then the db files which match an used syncdb
42 static int sync_cleandb(const char *dbpath
, int keep_used
) {
47 dir
= opendir(dbpath
);
49 pm_fprintf(stderr
, PM_LOG_ERROR
, _("could not access database directory\n"));
53 syncdbs
= alpm_option_get_syncdbs();
56 /* step through the directory one file at a time */
57 while((ent
= readdir(dir
)) != NULL
) {
61 const char *dname
= ent
->d_name
;
64 if(strcmp(dname
, ".") == 0 || strcmp(dname
, "..") == 0) {
67 /* skip the local and sync directories */
68 if(strcmp(dname
, "sync") == 0 || strcmp(dname
, "local") == 0) {
71 /* skip the db.lck file */
72 if(strcmp(dname
, "db.lck") == 0) {
76 /* build the full path */
77 snprintf(path
, PATH_MAX
, "%s%s", dbpath
, dname
);
79 /* remove all non-skipped directories and non-database files */
82 if(S_ISDIR(buf
.st_mode
) || strcmp(path
+ len
- 3, ".db") != 0) {
84 pm_fprintf(stderr
, PM_LOG_ERROR
,
85 _("could not remove %s\n"), path
);
95 char *dbname
= strndup(dname
, len
- 3);
96 for(i
= syncdbs
; i
&& !found
; i
= alpm_list_next(i
)) {
97 pmdb_t
*db
= alpm_list_getdata(i
);
98 found
= !strcmp(dbname
, alpm_db_get_name(db
));
102 /* We have a database that doesn't match any syncdb.
103 * Ask the user if he wants to remove it. */
105 if(!yesno(_("Do you want to remove %s?"), path
)) {
110 pm_fprintf(stderr
, PM_LOG_ERROR
,
111 _("could not remove %s\n"), path
);
121 static int sync_cleandb_all(void) {
123 char newdbpath
[PATH_MAX
];
126 dbpath
= alpm_option_get_dbpath();
127 printf(_("Database directory: %s\n"), dbpath
);
128 if(!yesno(_("Do you want to remove unused repositories?"))) {
131 /* The sync dbs were previously put in dbpath/ but are now in dbpath/sync/.
132 * We will clean everything in dbpath/ except local/, sync/ and db.lck, and
133 * only the unused sync dbs in dbpath/sync/ */
134 ret
+= sync_cleandb(dbpath
, 0);
136 sprintf(newdbpath
, "%s%s", dbpath
, "sync/");
137 ret
+= sync_cleandb(newdbpath
, 1);
139 printf(_("Database directory cleaned up\n"));
143 static int sync_cleancache(int level
)
146 alpm_list_t
*sync_dbs
= alpm_option_get_syncdbs();
147 pmdb_t
*db_local
= alpm_option_get_localdb();
150 for(i
= alpm_option_get_cachedirs(); i
; i
= alpm_list_next(i
)) {
151 printf(_("Cache directory: %s\n"), (char*)alpm_list_getdata(i
));
154 if(!config
->cleanmethod
) {
155 /* default to KeepInstalled if user did not specify */
156 config
->cleanmethod
= PM_CLEAN_KEEPINST
;
160 printf(_("Packages to keep:\n"));
161 if(config
->cleanmethod
& PM_CLEAN_KEEPINST
) {
162 printf(_(" All locally installed packages\n"));
164 if(config
->cleanmethod
& PM_CLEAN_KEEPCUR
) {
165 printf(_(" All current sync database packages\n"));
167 if(!yesno(_("Do you want to remove all other packages from cache?"))) {
170 printf(_("removing old packages from cache...\n"));
172 if(!noyes(_("Do you want to remove ALL files from cache?"))) {
175 printf(_("removing all files from cache...\n"));
178 for(i
= alpm_option_get_cachedirs(); i
; i
= alpm_list_next(i
)) {
179 const char *cachedir
= alpm_list_getdata(i
);
180 DIR *dir
= opendir(cachedir
);
184 pm_fprintf(stderr
, PM_LOG_ERROR
,
185 _("could not access cache directory %s\n"), cachedir
);
191 /* step through the directory one file at a time */
192 while((ent
= readdir(dir
)) != NULL
) {
195 pmpkg_t
*localpkg
= NULL
, *pkg
= NULL
;
196 const char *local_name
, *local_version
;
199 if(strcmp(ent
->d_name
, ".") == 0 || strcmp(ent
->d_name
, "..") == 0) {
202 /* build the full filepath */
203 snprintf(path
, PATH_MAX
, "%s%s", cachedir
, ent
->d_name
);
205 /* short circuit for removing all packages from cache */
211 /* attempt to load the package, prompt removal on failures as we may have
212 * files here that aren't valid packages. we also don't need a full
213 * load of the package, just the metadata. */
214 if(alpm_pkg_load(path
, 0, &localpkg
) != 0 || localpkg
== NULL
) {
215 if(yesno(_("File %s does not seem to be a valid package, remove it?"), path
)) {
217 alpm_pkg_free(localpkg
);
223 local_name
= alpm_pkg_get_name(localpkg
);
224 local_version
= alpm_pkg_get_version(localpkg
);
226 if(config
->cleanmethod
& PM_CLEAN_KEEPINST
) {
227 /* check if this package is in the local DB */
228 pkg
= alpm_db_get_pkg(db_local
, local_name
);
229 if(pkg
!= NULL
&& alpm_pkg_vercmp(local_version
,
230 alpm_pkg_get_version(pkg
)) == 0) {
231 /* package was found in local DB and version matches, keep it */
232 pm_printf(PM_LOG_DEBUG
, "pkg %s-%s found in local db\n",
233 local_name
, local_version
);
237 if(config
->cleanmethod
& PM_CLEAN_KEEPCUR
) {
238 /* check if this package is in a sync DB */
239 for(j
= sync_dbs
; j
&& delete; j
= alpm_list_next(j
)) {
240 pmdb_t
*db
= alpm_list_getdata(j
);
241 pkg
= alpm_db_get_pkg(db
, local_name
);
242 if(pkg
!= NULL
&& alpm_pkg_vercmp(local_version
,
243 alpm_pkg_get_version(pkg
)) == 0) {
244 /* package was found in a sync DB and version matches, keep it */
245 pm_printf(PM_LOG_DEBUG
, "pkg %s-%s found in sync db\n",
246 local_name
, local_version
);
251 /* free the local file package */
252 alpm_pkg_free(localpkg
);
264 static int sync_synctree(int level
, alpm_list_t
*syncs
)
267 int success
= 0, ret
;
269 if(trans_init(0) == -1) {
273 for(i
= syncs
; i
; i
= alpm_list_next(i
)) {
274 pmdb_t
*db
= alpm_list_getdata(i
);
276 ret
= alpm_db_update((level
< 2 ? 0 : 1), db
);
278 pm_fprintf(stderr
, PM_LOG_ERROR
, _("failed to update %s (%s)\n"),
279 alpm_db_get_name(db
), alpm_strerrorlast());
280 } else if(ret
== 1) {
281 printf(_(" %s is up to date\n"), alpm_db_get_name(db
));
288 if(trans_release() == -1) {
291 /* We should always succeed if at least one DB was upgraded - we may possibly
292 * fail later with unresolved deps, but that should be rare, and would be
296 pm_fprintf(stderr
, PM_LOG_ERROR
, _("failed to synchronize any databases\n"));
301 static void print_installed(pmdb_t
*db_local
, pmpkg_t
*pkg
)
303 const char *pkgname
= alpm_pkg_get_name(pkg
);
304 const char *pkgver
= alpm_pkg_get_version(pkg
);
305 pmpkg_t
*lpkg
= alpm_db_get_pkg(db_local
, pkgname
);
307 const char *lpkgver
= alpm_pkg_get_version(lpkg
);
308 if(strcmp(lpkgver
,pkgver
) == 0) {
309 printf(" [%s]", _("installed"));
311 printf(" [%s: %s]", _("installed"), lpkgver
);
316 /* search the sync dbs for a matching package */
317 static int sync_search(alpm_list_t
*syncs
, alpm_list_t
*targets
)
319 alpm_list_t
*i
, *j
, *ret
;
322 pmdb_t
*db_local
= alpm_option_get_localdb();
324 for(i
= syncs
; i
; i
= alpm_list_next(i
)) {
325 pmdb_t
*db
= alpm_list_getdata(i
);
326 /* if we have a targets list, search for packages matching it */
328 ret
= alpm_db_search(db
, targets
);
331 ret
= alpm_db_get_pkgcache_list(db
);
339 for(j
= ret
; j
; j
= alpm_list_next(j
)) {
341 pmpkg_t
*pkg
= alpm_list_getdata(j
);
343 if (!config
->quiet
) {
344 printf("%s/%s %s", alpm_db_get_name(db
), alpm_pkg_get_name(pkg
),
345 alpm_pkg_get_version(pkg
));
347 printf("%s", alpm_pkg_get_name(pkg
));
350 /* print the package size with the output if ShowSize option set */
351 if(!config
->quiet
&& config
->showsize
) {
352 /* Convert byte size to MB */
353 double mbsize
= (double)alpm_pkg_get_size(pkg
) / (1024.0 * 1024.0);
355 printf(" [%.2f MB]", mbsize
);
358 if (!config
->quiet
) {
359 if((grp
= alpm_pkg_get_groups(pkg
)) != NULL
) {
362 for(k
= grp
; k
; k
= alpm_list_next(k
)) {
363 const char *group
= alpm_list_getdata(k
);
365 if(alpm_list_next(k
)) {
366 /* only print a spacer if there are more groups */
373 print_installed(db_local
, pkg
);
375 /* we need a newline and initial indent first */
377 indentprint(alpm_pkg_get_desc(pkg
), 4);
381 /* we only want to free if the list was a search list */
390 static int sync_group(int level
, alpm_list_t
*syncs
, alpm_list_t
*targets
)
392 alpm_list_t
*i
, *j
, *k
;
395 for(i
= targets
; i
; i
= alpm_list_next(i
)) {
396 const char *grpname
= alpm_list_getdata(i
);
397 for(j
= syncs
; j
; j
= alpm_list_next(j
)) {
398 pmdb_t
*db
= alpm_list_getdata(j
);
399 pmgrp_t
*grp
= alpm_db_readgrp(db
, grpname
);
402 /* get names of packages in group */
403 for(k
= alpm_grp_get_pkgs(grp
); k
; k
= alpm_list_next(k
)) {
405 printf("%s %s\n", grpname
,
406 alpm_pkg_get_name(alpm_list_getdata(k
)));
408 printf("%s\n", alpm_pkg_get_name(alpm_list_getdata(k
)));
415 for(i
= syncs
; i
; i
= alpm_list_next(i
)) {
416 pmdb_t
*db
= alpm_list_getdata(i
);
418 for(j
= alpm_db_get_grpcache(db
); j
; j
= alpm_list_next(j
)) {
419 pmgrp_t
*grp
= alpm_list_getdata(j
);
420 const char *grpname
= alpm_grp_get_name(grp
);
423 for(k
= alpm_grp_get_pkgs(grp
); k
; k
= alpm_list_next(k
)) {
424 printf("%s %s\n", grpname
,
425 alpm_pkg_get_name(alpm_list_getdata(k
)));
428 /* print grp names only, no package names */
429 printf("%s\n", grpname
);
438 static int sync_info(alpm_list_t
*syncs
, alpm_list_t
*targets
)
440 alpm_list_t
*i
, *j
, *k
;
444 for(i
= targets
; i
; i
= alpm_list_next(i
)) {
448 char target
[512]; /* TODO is this enough space? */
449 char *repo
= NULL
, *pkgstr
= NULL
;
451 strncpy(target
, i
->data
, 512);
452 pkgstr
= strchr(target
, '/');
458 for(j
= syncs
; j
; j
= alpm_list_next(j
)) {
459 db
= alpm_list_getdata(j
);
460 if(strcmp(repo
, alpm_db_get_name(db
)) == 0) {
467 pm_fprintf(stderr
, PM_LOG_ERROR
,
468 _("repository '%s' does not exist\n"), repo
);
472 for(k
= alpm_db_get_pkgcache_list(db
); k
; k
= alpm_list_next(k
)) {
473 pmpkg_t
*pkg
= alpm_list_getdata(k
);
475 if(strcmp(alpm_pkg_get_name(pkg
), pkgstr
) == 0) {
476 dump_pkg_sync(pkg
, alpm_db_get_name(db
), config
->op_s_info
);
483 pm_fprintf(stderr
, PM_LOG_ERROR
,
484 _("package '%s' was not found in repository '%s'\n"), pkgstr
, repo
);
490 for(j
= syncs
; j
; j
= alpm_list_next(j
)) {
491 pmdb_t
*db
= alpm_list_getdata(j
);
493 for(k
= alpm_db_get_pkgcache_list(db
); k
; k
= alpm_list_next(k
)) {
494 pmpkg_t
*pkg
= alpm_list_getdata(k
);
496 if(strcmp(alpm_pkg_get_name(pkg
), pkgstr
) == 0) {
497 dump_pkg_sync(pkg
, alpm_db_get_name(db
), config
->op_s_info
);
504 pm_fprintf(stderr
, PM_LOG_ERROR
,
505 _("package '%s' was not found\n"), pkgstr
);
511 for(i
= syncs
; i
; i
= alpm_list_next(i
)) {
512 pmdb_t
*db
= alpm_list_getdata(i
);
514 for(j
= alpm_db_get_pkgcache_list(db
); j
; j
= alpm_list_next(j
)) {
515 dump_pkg_sync(alpm_list_getdata(j
), alpm_db_get_name(db
), config
->op_s_info
);
523 static int sync_list(alpm_list_t
*syncs
, alpm_list_t
*targets
)
525 alpm_list_t
*i
, *j
, *ls
= NULL
;
526 pmdb_t
*db_local
= alpm_option_get_localdb();
529 for(i
= targets
; i
; i
= alpm_list_next(i
)) {
530 const char *repo
= alpm_list_getdata(i
);
533 for(j
= syncs
; j
; j
= alpm_list_next(j
)) {
534 pmdb_t
*d
= alpm_list_getdata(j
);
536 if(strcmp(repo
, alpm_db_get_name(d
)) == 0) {
543 pm_fprintf(stderr
, PM_LOG_ERROR
,
544 _("repository \"%s\" was not found.\n"),repo
);
549 ls
= alpm_list_add(ls
, db
);
555 for(i
= ls
; i
; i
= alpm_list_next(i
)) {
556 pmdb_t
*db
= alpm_list_getdata(i
);
558 for(j
= alpm_db_get_pkgcache_list(db
); j
; j
= alpm_list_next(j
)) {
559 pmpkg_t
*pkg
= alpm_list_getdata(j
);
561 if (!config
->quiet
) {
562 printf("%s %s %s", alpm_db_get_name(db
), alpm_pkg_get_name(pkg
),
563 alpm_pkg_get_version(pkg
));
564 print_installed(db_local
, pkg
);
567 printf("%s\n", alpm_pkg_get_name(pkg
));
579 static alpm_list_t
*syncfirst(void) {
580 alpm_list_t
*i
, *res
= NULL
;
582 for(i
= config
->syncfirst
; i
; i
= alpm_list_next(i
)) {
583 char *pkgname
= alpm_list_getdata(i
);
584 pmpkg_t
*pkg
= alpm_db_get_pkg(alpm_option_get_localdb(), pkgname
);
589 if(alpm_sync_newversion(pkg
, alpm_option_get_syncdbs())) {
590 res
= alpm_list_add(res
, strdup(pkgname
));
597 static pmdb_t
*get_db(const char *dbname
)
600 for(i
= alpm_option_get_syncdbs(); i
; i
= i
->next
) {
601 pmdb_t
*db
= i
->data
;
602 if(strcmp(alpm_db_get_name(db
), dbname
) == 0) {
609 static int process_pkg(pmpkg_t
*pkg
)
611 int ret
= alpm_add_pkg(pkg
);
614 if(pm_errno
== PM_ERR_TRANS_DUP_TARGET
615 || pm_errno
== PM_ERR_PKG_IGNORED
) {
616 /* just skip duplicate or ignored targets */
617 pm_printf(PM_LOG_WARNING
, _("skipping target: %s\n"), alpm_pkg_get_name(pkg
));
620 pm_fprintf(stderr
, PM_LOG_ERROR
, "'%s': %s\n", alpm_pkg_get_name(pkg
),
621 alpm_strerrorlast());
628 static int process_group(alpm_list_t
*dbs
, char *group
)
632 alpm_list_t
*pkgs
= alpm_find_grp_pkgs(dbs
, group
);
633 int count
= alpm_list_count(pkgs
);
636 pm_fprintf(stderr
, PM_LOG_ERROR
, _("target not found: %s\n"), group
);
640 printf(_(":: There are %d members in group %s:\n"), count
,
642 select_display(pkgs
);
643 char *array
= malloc(count
);
644 multiselect_question(array
, count
);
646 for(i
= pkgs
; i
; i
= alpm_list_next(i
)) {
649 pmpkg_t
*pkg
= alpm_list_getdata(i
);
651 if(process_pkg(pkg
) == 1) {
657 alpm_list_free(pkgs
);
662 static int process_targname(alpm_list_t
*dblist
, char *targname
)
664 pmpkg_t
*pkg
= alpm_find_dbs_satisfier(dblist
, targname
);
667 return(process_pkg(pkg
));
669 /* fallback on group */
670 return(process_group(dblist
, targname
));
673 static int process_target(char *target
)
675 /* process targets */
676 char *targstring
= strdup(target
);
677 char *targname
= strchr(targstring
, '/');
680 alpm_list_t
*dblist
= NULL
;
690 pm_fprintf(stderr
, PM_LOG_ERROR
, _("database not found: %s\n"),
695 dblist
= alpm_list_add(dblist
, db
);
696 ret
= process_targname(dblist
, targname
);
697 alpm_list_free(dblist
);
699 targname
= targstring
;
700 dblist
= alpm_option_get_syncdbs();
701 ret
= process_targname(dblist
, targname
);
708 static int sync_trans(alpm_list_t
*targets
)
711 alpm_list_t
*data
= NULL
;
712 alpm_list_t
*packages
= NULL
;
715 /* Step 1: create a new transaction... */
716 if(trans_init(config
->flags
) == -1) {
720 /* process targets */
721 for(i
= targets
; i
; i
= alpm_list_next(i
)) {
722 char *targ
= alpm_list_getdata(i
);
723 if(process_target(targ
) == 1) {
729 if(config
->op_s_upgrade
) {
730 printf(_(":: Starting full system upgrade...\n"));
731 alpm_logaction("starting full system upgrade\n");
732 if(alpm_sync_sysupgrade(config
->op_s_upgrade
>= 2) == -1) {
733 pm_fprintf(stderr
, PM_LOG_ERROR
, "%s\n", alpm_strerrorlast());
739 /* Step 2: "compute" the transaction based on targets and flags */
740 if(alpm_trans_prepare(&data
) == -1) {
741 pm_fprintf(stderr
, PM_LOG_ERROR
, _("failed to prepare transaction (%s)\n"),
742 alpm_strerrorlast());
745 case PM_ERR_PKG_INVALID_ARCH
:
746 for(i
= data
; i
; i
= alpm_list_next(i
)) {
747 char *pkg
= alpm_list_getdata(i
);
748 printf(_(":: package %s does not have a valid architecture\n"), pkg
);
751 case PM_ERR_UNSATISFIED_DEPS
:
752 for(i
= data
; i
; i
= alpm_list_next(i
)) {
753 pmdepmissing_t
*miss
= alpm_list_getdata(i
);
754 pmdepend_t
*dep
= alpm_miss_get_dep(miss
);
755 char *depstring
= alpm_dep_compute_string(dep
);
756 printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss
),
761 case PM_ERR_CONFLICTING_DEPS
:
762 for(i
= data
; i
; i
= alpm_list_next(i
)) {
763 pmconflict_t
*conflict
= alpm_list_getdata(i
);
764 const char *package1
= alpm_conflict_get_package1(conflict
);
765 const char *package2
= alpm_conflict_get_package2(conflict
);
766 const char *reason
= alpm_conflict_get_reason(conflict
);
767 /* only print reason if it contains new information */
768 if(strcmp(package1
, reason
) == 0 || strcmp(package2
, reason
) == 0) {
769 printf(_(":: %s and %s are in conflict\n"), package1
, package2
);
771 printf(_(":: %s and %s are in conflict (%s)\n"), package1
, package2
, reason
);
782 packages
= alpm_trans_get_add();
783 if(packages
== NULL
) {
784 /* nothing to do: just exit without complaining */
785 printf(_(" there is nothing to do\n"));
789 /* Step 3: actually perform the operation */
791 print_packages(packages
);
795 display_targets(alpm_trans_get_remove(), 0);
796 display_targets(alpm_trans_get_add(), 1);
800 if(config
->op_s_downloadonly
) {
801 confirm
= yesno(_("Proceed with download?"));
803 confirm
= yesno(_("Proceed with installation?"));
809 if(alpm_trans_commit(&data
) == -1) {
810 pm_fprintf(stderr
, PM_LOG_ERROR
, _("failed to commit transaction (%s)\n"),
811 alpm_strerrorlast());
814 case PM_ERR_FILE_CONFLICTS
:
815 for(i
= data
; i
; i
= alpm_list_next(i
)) {
816 pmfileconflict_t
*conflict
= alpm_list_getdata(i
);
817 switch(alpm_fileconflict_get_type(conflict
)) {
818 case PM_FILECONFLICT_TARGET
:
819 printf(_("%s exists in both '%s' and '%s'\n"),
820 alpm_fileconflict_get_file(conflict
),
821 alpm_fileconflict_get_target(conflict
),
822 alpm_fileconflict_get_ctarget(conflict
));
824 case PM_FILECONFLICT_FILESYSTEM
:
825 printf(_("%s: %s exists in filesystem\n"),
826 alpm_fileconflict_get_target(conflict
),
827 alpm_fileconflict_get_file(conflict
));
832 case PM_ERR_PKG_INVALID
:
833 case PM_ERR_DLT_INVALID
:
834 for(i
= data
; i
; i
= alpm_list_next(i
)) {
835 char *filename
= alpm_list_getdata(i
);
836 printf(_("%s is invalid or corrupted\n"), filename
);
843 printf(_("Errors occurred, no packages were upgraded.\n"));
848 /* Step 4: release transaction resources */
853 if(trans_release() == -1) {
860 int pacman_sync(alpm_list_t
*targets
)
862 alpm_list_t
*sync_dbs
= NULL
;
864 /* clean the cache */
865 if(config
->op_s_clean
) {
868 if(trans_init(0) == -1) {
872 ret
+= sync_cleancache(config
->op_s_clean
);
874 ret
+= sync_cleandb_all();
876 if(trans_release() == -1) {
883 /* ensure we have at least one valid sync db set up */
884 sync_dbs
= alpm_option_get_syncdbs();
885 if(sync_dbs
== NULL
|| alpm_list_count(sync_dbs
) == 0) {
886 pm_printf(PM_LOG_ERROR
, _("no usable package repositories configured.\n"));
890 if(config
->op_s_sync
) {
891 /* grab a fresh package list */
892 printf(_(":: Synchronizing package databases...\n"));
893 alpm_logaction("synchronizing package lists\n");
894 if(!sync_synctree(config
->op_s_sync
, sync_dbs
)) {
899 /* search for a package */
900 if(config
->op_s_search
) {
901 return(sync_search(sync_dbs
, targets
));
904 /* look for groups */
906 return(sync_group(config
->group
, sync_dbs
, targets
));
909 /* get package info */
910 if(config
->op_s_info
) {
911 return(sync_info(sync_dbs
, targets
));
914 /* get a listing of files in sync DBs */
915 if(config
->op_q_list
) {
916 return(sync_list(sync_dbs
, targets
));
919 if(targets
== NULL
) {
920 if(config
->op_s_upgrade
) {
922 } else if(config
->op_s_sync
) {
925 /* don't proceed here unless we have an operation that doesn't require a
927 pm_printf(PM_LOG_ERROR
, _("no targets specified (use -h for help)\n"));
932 alpm_list_t
*targs
= alpm_list_strdup(targets
);
933 if(!(config
->flags
& PM_TRANS_FLAG_DOWNLOADONLY
) && !config
->print
) {
934 /* check for newer versions of packages to be upgraded first */
935 alpm_list_t
*packages
= syncfirst();
937 /* Do not ask user if all the -S targets are SyncFirst packages, see FS#15810 */
938 alpm_list_t
*tmp
= NULL
;
939 if(config
->op_s_upgrade
|| (tmp
= alpm_list_diff(targets
, packages
, (alpm_list_fn_cmp
)strcmp
))) {
941 printf(_(":: The following packages should be upgraded first :\n"));
942 list_display(" ", packages
);
943 if(yesno(_(":: Do you want to cancel the current operation\n"
944 ":: and upgrade these packages now?"))) {
948 config
->op_s_upgrade
= 0;
954 pm_printf(PM_LOG_DEBUG
, "skipping SyncFirst dialog\n");
960 int ret
= sync_trans(targs
);
966 /* vim: set ts=2 sw=2 noet: */