Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=c03722001f2d1010868ac948e835a5cb5c4442ea
commit c03722001f2d1010868ac948e835a5cb5c4442ea Author: Michel Hermier <[email protected]> Date: Thu Aug 14 17:19:52 2014 +0200 pacman-g2: Make -Y --vercmp an official command. diff --git a/doc/pacman-g2.txt b/doc/pacman-g2.txt index ef95f49..880674b 100644 --- a/doc/pacman-g2.txt +++ b/doc/pacman-g2.txt @@ -55,6 +55,9 @@ pacman-g2 packages are in a bzipped tar format. CGroup is "name=systemd:/system/sshd.service", you can run "systemctl restart sshd.service". +-Y, --vercmp:: + Perform a version comparison of the 2 version strings arguments. + -V, --version:: Display version and exit. diff --git a/src/pacman-g2/CMakeLists.txt b/src/pacman-g2/CMakeLists.txt index 77e33c7..1a3d33e 100644 --- a/src/pacman-g2/CMakeLists.txt +++ b/src/pacman-g2/CMakeLists.txt @@ -11,6 +11,7 @@ set(PACMAN_SOURCES sync.c trans.c util.c + vercmp.c ) include_directories (${PACMAN-G2_SOURCE_DIR}) diff --git a/src/pacman-g2/conf.h b/src/pacman-g2/conf.h index 2a682c8..44e5f5a 100644 --- a/src/pacman-g2/conf.h +++ b/src/pacman-g2/conf.h @@ -36,7 +36,6 @@ typedef struct __config_t { unsigned short noconfirm; unsigned short noprogressbar; unsigned short op_d_all; - unsigned short op_d_vertest; unsigned short op_d_resolve; unsigned short op_q_isfile; unsigned short op_q_info; diff --git a/src/pacman-g2/deptest.c b/src/pacman-g2/deptest.c index 33535aa..64678a7 100644 --- a/src/pacman-g2/deptest.c +++ b/src/pacman-g2/deptest.c @@ -50,20 +50,11 @@ int deptestpkg(list_t *targets) return(0); } - if(config->op_d_vertest) { - if(targets->data && targets->next && targets->next->data) { - int ret = pacman_pkg_vercmp(targets->data, targets->next->data); - printf("%d\n", ret); - return(ret); - } + if(config->op_d_all) { + pacman_output_generate(targets, pmc_syncs); return(0); } - if(config->op_d_all) { - pacman_output_generate(targets, pmc_syncs); - return(0); - } - /* we create a transaction to hold a dummy package to be able to use * deps checkings from pacman_trans_prepare() */ if(pacman_trans_init(PM_TRANS_TYPE_ADD, 0, NULL, NULL, NULL) == -1) { diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c index e8d8fff..10aedf6 100644 --- a/src/pacman-g2/pacman-g2.c +++ b/src/pacman-g2/pacman-g2.c @@ -44,7 +44,9 @@ #include "query.h" #include "sync.h" #include "deptest.h" +#include "pacman-g2.h" #include "ps.h" +#include "trans.h" #define PACCONF "/etc/pacman-g2.conf" @@ -57,7 +59,8 @@ enum { PM_OP_QUERY, PM_OP_SYNC, PM_OP_DEPTEST, - PM_OP_PS + PM_OP_PS, + PM_OP_VERCMP, }; /* Long operations */ @@ -102,6 +105,7 @@ static void usage(int op, char *myname) printf(_(" %s {-Q --query} [options] [package]\n"), myname); printf(_(" %s {-S --sync} [options] [package]\n"), myname); printf(_(" %s {-P --ps} [options]\n"), myname); + printf(_(" %s {-Y --vercmp} [options] <version1> <version2>\n"), myname); printf(_("\nuse '%s --help' with other options for more syntax\n"), myname); } else { if(op == PM_OP_ADD) { @@ -160,6 +164,10 @@ static void usage(int op, char *myname) printf(_(" -y, --refresh download fresh package databases from the server\n")); printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n")); printf(_(" --nointegrity don't check the integrity of the packages using sha1\n")); + } else if(op == PM_OP_VERCMP) { + printf(_(" %s {-Y --vercmp} [options] <version1> <version2>\n"), myname); + printf(_("options:\n")); + return; } printf(_(" --config <path> set an alternate configuration file\n")); printf(_(" --noconfirm do not ask for anything confirmation\n")); @@ -189,7 +197,7 @@ static void version(void) static void cleanup(int exitcode) { - if(exitcode != 0 && config->op_d_vertest == 0) { + if(exitcode != 0) { fprintf(stderr, "\n"); } @@ -256,8 +264,8 @@ static int parseargs(int argc, char *argv[]) {"deptest", no_argument, 0, 'T'}, /* used by makepkg */ {"upgrade", no_argument, 0, 'U'}, {"version", no_argument, 0, 'V'}, - {"vertest", no_argument, 0, 'Y'}, /* does the same as the 'vercmp' binary */ - {"all", no_argument, 0, 'a'}, + {"vercmp", no_argument, 0, 'Y'}, /* does the same as the 'vercmp' binary */ + {"all", no_argument, 0, 'a'}, {"dbpath", required_argument, 0, 'b'}, {"cascade", no_argument, 0, 'c'}, {"changelog", no_argument, 0, 'c'}, @@ -299,7 +307,7 @@ static int parseargs(int argc, char *argv[]) }; char root[PATH_MAX]; - while((opt = getopt_long(argc, argv, "ARUFQSPTDYr:b:vkhsacVfmnoldepituwyg", opts, &option_index))) { + while((opt = getopt_long(argc, argv, "ARUFQSPTDYr:b:vkhsacVfmnoldepituwyg", opts, &option_index))) { if(opt < 0) { break; } @@ -341,11 +349,8 @@ static int parseargs(int argc, char *argv[]) case 'T': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST); break; case 'U': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE); break; case 'V': config->version = 1; break; - case 'Y': - config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST); - config->op_d_vertest = 1; - break; - case 'a': config->op_d_all = 1; break; + case 'Y': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_VERCMP); break; + case 'a': config->op_d_all = 1; break; case 'b': if(config->dbpath) { free(config->dbpath); @@ -501,7 +506,7 @@ int main(int argc, char *argv[]) /* check if we have sufficient permission for the requested operation */ if(myuid > 0) { - if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST && config->op != PM_OP_PS) { + if(config->op != PM_OP_MAIN && config->op != PM_OP_QUERY && config->op != PM_OP_DEPTEST && config->op != PM_OP_PS && config->op != PM_OP_VERCMP) { if((config->op == PM_OP_SYNC && !config->op_s_sync && (config->op_s_search || config->group || config->op_q_list || config->op_q_info || (config->flags & PM_TRANS_FLAG_PRINTURIS))) @@ -617,6 +622,7 @@ int main(int argc, char *argv[]) case PM_OP_SYNC: ret = syncpkg(pm_targets); break; case PM_OP_PS: ret = pspkg(0); break; case PM_OP_DEPTEST: ret = deptestpkg(pm_targets); break; + case PM_OP_VERCMP: ret = vercmp(pm_targets); break; default: ERR(NL, _("no operation specified (use -h for help)\n")); ret = 1; diff --git a/src/pacman-g2/pacman-g2.h b/src/pacman-g2/pacman-g2.h new file mode 100644 index 0000000..017dd09 --- /dev/null +++ b/src/pacman-g2/pacman-g2.h @@ -0,0 +1,30 @@ +/* + * pacman-g2.h + * + * Copyright (c) 2014 by Michel Hermier <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ +#ifndef _PM_PACMAN_G2_H +#define _PM_PACMAN_G2_H + +#include "list.h" + +int vercmp(list_t *targets); + +#endif /* _PM_PACMAN_G2_H */ + +/* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman-g2/vercmp.c b/src/pacman-g2/vercmp.c new file mode 100644 index 0000000..079c816 --- /dev/null +++ b/src/pacman-g2/vercmp.c @@ -0,0 +1,54 @@ +/* + * deptest.c + * + * Copyright (c) 2002-2006 by Judd Vinet <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <libintl.h> +#include <pacman.h> +/* pacman-g2 */ +#include "util.h" +#include "list.h" +#include "conf.h" +#include "log.h" +#include "sync.h" +#include "deptest.h" + +extern config_t *config; +extern list_t *pmc_syncs; + +int pacman_output_generate(pmlist_t *targets, pmlist_t *dblist); + +int vercmp(list_t *targets) +{ + // FIXME: should count targets + + if(targets != NULL && targets->data && targets->next && targets->next->data) { + int ret = pacman_pkg_vercmp(targets->data, targets->next->data); + printf("%d\n", ret); + return(ret); + } + return(0); +} + +/* vim: set ts=2 sw=2 noet: */ _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
