4 // Copyright (c) 2000-2005 Per Liden
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 void pkgrm::run(int argc
, char** argv
)
28 // Check command line options
33 for (int i
= 1; i
< argc
; i
++) {
34 string
option(argv
[i
]);
35 if (option
== "-r" || option
== "--root") {
36 assert_argument(argv
, argc
, i
);
39 } else if (option
[0] == '-' || !o_package
.empty()) {
40 throw runtime_error("invalid option " + option
);
46 if (o_package
.empty())
47 throw runtime_error("option missing");
53 throw runtime_error("only root can remove packages");
59 db_lock
lock(o_root
, true);
62 if (!db_find_pkg(o_package
))
63 throw runtime_error("package " + o_package
+ " not installed");
71 void pkgrm::print_help() const
73 cout
<< "usage: " << utilname
<< " [options] <package>" << endl
75 << " -r, --root <path> specify alternative installation root" << endl
76 << " -v, --version print version and exit" << endl
77 << " -h, --help print help and exit" << endl
;