X-Git-Url: http://gitweb/?a=blobdiff_plain;f=src%2Fpkgadd.cc;h=a5721fee0a8ffdb7218b69aa0e83c3888924f8f2;hb=d559ecf5a667b22c9e34fc3d908974d0233a4b2d;hp=4bc16520aea2b166627f549318af5ef66939909b;hpb=a0a634132e76613b552d33b7f62d1706836d8b5d;p=pkgutils-cross.git diff --git a/src/pkgadd.cc b/src/pkgadd.cc index 4bc1652..a5721fe 100644 --- a/src/pkgadd.cc +++ b/src/pkgadd.cc @@ -2,7 +2,7 @@ // pkgutils // // Copyright (c) 2000-2005 Per Liden -// Copyright (c) 2006-2007 by CRUX team (http://crux.nu) +// Copyright (c) 2006-2010 by CRUX team (http://crux.nu) // // 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 @@ -33,6 +33,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; @@ -43,6 +44,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") { @@ -71,7 +76,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) @@ -112,18 +117,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) {