d9503526784d4d3ad52d16dd2b56b54978d73e62
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,
32 #include <sys/types.h>
35 #define PKG_EXT ".pkg.tar.gz"
36 #define PKG_DIR "var/lib/pkg"
37 #define PKG_DB "var/lib/pkg/db"
38 #define PKG_REJECTED "var/lib/pkg/rejected"
39 #define VERSION_DELIM '#'
40 #define LDCONFIG "/sbin/ldconfig"
41 #define LDCONFIG_CONF "/etc/ld.so.conf"
52 typedef map
<string
, pkginfo_t
> packages_t
;
54 explicit pkgutil(const string
& name
);
56 virtual void run(int argc
, char** argv
) = 0;
57 virtual void print_help() const = 0;
58 void print_version() const;
62 void db_open(const string
& path
);
64 void db_add_pkg(const string
& name
, const pkginfo_t
& info
);
65 bool db_find_pkg(const string
& name
);
66 void db_rm_pkg(const string
& name
);
67 void db_rm_pkg(const string
& name
, const set
<string
>& keep_list
);
68 void db_rm_files(set
<string
> files
, const set
<string
>& keep_list
);
69 set
<string
> db_find_conflicts(const string
& name
, const pkginfo_t
& info
);
72 pair
<string
, pkginfo_t
> pkg_open(const string
& filename
) const;
73 void pkg_install(const string
& filename
, const set
<string
>& keep_list
, const set
<string
>& non_install_files
) const;
74 void pkg_footprint(string
& filename
) const;
75 void ldconfig() const;
84 db_lock(const string
& root
, bool exclusive
);
90 class runtime_error_with_errno
: public runtime_error
{
92 explicit runtime_error_with_errno(const string
& msg
) throw()
93 : runtime_error(msg
+ string(": ") + strerror(errno
)) {}
94 explicit runtime_error_with_errno(const string
& msg
, int e
) throw()
95 : runtime_error(msg
+ string(": ") + strerror(e
)) {}
99 void assert_argument(char** argv
, int argc
, int index
);
100 string
itos(unsigned int value
);
101 string
mtos(mode_t mode
);
102 string
trim_filename(const string
& filename
);
103 bool file_exists(const string
& filename
);
104 bool file_empty(const string
& filename
);
105 bool file_equal(const string
& file1
, const string
& file2
);
106 bool permissions_equal(const string
& file1
, const string
& file2
);
107 void file_remove(const string
& basedir
, const string
& filename
);
109 #endif /* PKGUTIL_H */