3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 // based on vutil.h by Jacques Gelinas
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, or (at your option)
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, USA.
24 #include <sys/types.h>
38 // Patch to help compile this utility on unpatched kernel source
39 #ifndef EXT2_IMMUTABLE_FILE_FL
40 #define EXT2_IMMUTABLE_FILE_FL 0x00000010
41 #define EXT2_IMMUTABLE_LINK_FL 0x00008000
45 FILE *vutil_execdistcmd (const char *, const string &, const char *);
46 extern const char K_DUMPFILES[];
47 extern const char K_UNIFILES[];
48 extern const char K_PKGVERSION[];
53 string version; // version + release
54 Package(string &_name, string &_version)
55 : name (_name), version(_version)
58 Package(const char *_name, const char *_version)
59 : name (_name), version(_version)
62 Package(const string &line)
66 Package & operator = (const string &_line)
69 string::iterator pos = find (line.begin(),line.end(),'=');
70 if (pos != line.end()){
71 name = string(line.begin(),pos);
72 version = string(pos + 1,line.end());
76 Package (const Package &pkg)
79 version = pkg.version;
81 bool operator == (const Package &v) const
83 return name == v.name && version == v.version;
85 bool operator < (const Package &v) const
90 }else if (name == v.name && version < v.version){
95 // Load the file member of the package, but exclude configuration file
96 void loadfiles(const string &ref, set<string> &files)
98 if (debug > 2) cout << "Loading files for package " << name << endl;
99 string namever = name + '-' + version;
100 FILE *fin = vutil_execdistcmd (K_UNIFILES,ref,namever.c_str());
103 while (fgets(tmp,sizeof(tmp)-1,fin)!=NULL){
104 int last = strlen(tmp)-1;
105 if (last >= 0 && tmp[last] == '\n') tmp[last] = '\0';
109 if (debug > 2) cout << "Done\n";
112 bool locate(const string &path)
114 return find (files.begin(),files.end(),path) != files.end();
119 // Check if two package have the same name (but potentially different version)
123 same_name(const Package &_pkg) : pkg(_pkg) {}
124 bool operator()(const Package &p)
126 return pkg.name == p.name;