4 // Copyright (c) 2000-2005 Per Liden
5 // Copyright (c) 2006-2010 by CRUX team (http://crux.nu)
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, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 void pkgrm::run(int argc
, char** argv
)
29 // Check command line options
34 for (int i
= 1; i
< argc
; i
++) {
35 string
option(argv
[i
]);
36 if (option
== "-r" || option
== "--root") {
37 assert_argument(argv
, argc
, i
);
40 } else if (option
[0] == '-' || !o_package
.empty()) {
41 throw runtime_error("invalid option " + option
);
47 if (o_package
.empty())
48 throw runtime_error("option missing");
54 throw runtime_error("only root can remove packages");
60 db_lock
lock(o_root
, true);
63 if (!db_find_pkg(o_package
))
64 throw runtime_error("package " + o_package
+ " not installed");
72 void pkgrm::print_help() const
74 cout
<< "usage: " << utilname
<< " [options] <package>" << endl
76 << " -r, --root <path> specify alternative installation root" << endl
77 << " -v, --version print version and exit" << endl
78 << " -h, --help print help and exit" << endl
;