X-Git-Url: http://gitweb/?a=blobdiff_plain;f=pkgadd.cc;h=2310ea05ede54e09e61bcb8637d9b44527939fc9;hb=58e4c4e5d6198eff7f552cc48b1704c14f42a2e9;hp=8856851e6d979f9117cae92cc26237a8f43efeca;hpb=3e5b7ed9bbe9a9659486a9d4c51f3466d1e877ec;p=pkgutils-cross.git diff --git a/pkgadd.cc b/pkgadd.cc index 8856851..2310ea0 100644 --- a/pkgadd.cc +++ b/pkgadd.cc @@ -2,7 +2,10 @@ // pkgutils // // Copyright (c) 2000-2005 Per Liden -// +// Copyright (c) 2006-2013 by CRUX team (http://crux.nu) +// +// Patches for alternative pkgadd.conf file by Jose V Beneyto +// // 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 @@ -32,6 +35,7 @@ void pkgadd::run(int argc, char** argv) // Check command line options // string o_root; + string o_config; string o_package; bool o_upgrade = false; bool o_force = false; @@ -42,6 +46,10 @@ void pkgadd::run(int argc, char** argv) assert_argument(argv, argc, i); o_root = argv[i + 1]; i++; + } else if (option == "-c" || option == "--config") { + assert_argument(argv, argc, i); + o_config = argv[i + 1]; + i++; } else if (option == "-u" || option == "--upgrade") { o_upgrade = true; } else if (option == "-f" || option == "--force") { @@ -70,7 +78,7 @@ void pkgadd::run(int argc, char** argv) db_open(o_root); pair package = pkg_open(o_package); - vector config_rules = read_config(); + vector config_rules = read_config(o_config); bool installed = db_find_pkg(package.first); if (installed && !o_upgrade) @@ -111,18 +119,21 @@ void pkgadd::print_help() const { cout << "usage: " << utilname << " [options] " << endl << "options:" << endl - << " -u, --upgrade upgrade package with the same name" << endl - << " -f, --force force install, overwrite conflicting files" << endl - << " -r, --root specify alternative installation root" << endl - << " -v, --version print version and exit" << endl - << " -h, --help print help and exit" << endl; + << " -u, --upgrade upgrade package with the same name" << endl + << " -f, --force force install, overwrite conflicting files" << endl + << " -r, --root specify alternative installation root" << endl + << " -c, --config use alternate configuration file" << endl + << " -v, --version print version and exit" << endl + << " -h, --help print help and exit" << endl; } -vector pkgadd::read_config() const +vector pkgadd::read_config(string file) const { vector rules; unsigned int linecount = 0; - const string filename = root + PKGADD_CONF; + string filename = root + PKGADD_CONF; + + if (!file.empty()) filename = file; ifstream in(filename.c_str()); if (in) {