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.
26 #include <sys/types.h>
40 // Patch to help compile this utility on unpatched kernel source
41 #ifndef EXT2_IMMUTABLE_FILE_FL
42 #define EXT2_IMMUTABLE_FILE_FL 0x00000010
43 #define EXT2_IMMUTABLE_LINK_FL 0x00008000
47 FILE *vutil_execdistcmd (const char *, Vserver const &, const char *);
48 extern const char K_DUMPFILES[];
49 extern const char K_UNIFILES[];
50 extern const char K_PKGVERSION[];
55 string version; // version + release
56 Package(string &_name, string &_version)
57 : name (_name), version(_version)
60 Package(const char *_name, const char *_version)
61 : name (_name), version(_version)
64 Package(const string &line)
68 Package & operator = (const string &_line)
71 string::iterator pos = find (line.begin(),line.end(),'=');
72 if (pos != line.end()){
73 name = string(line.begin(),pos);
74 version = string(pos + 1,line.end());
78 Package (const Package &pkg)
81 version = pkg.version;
83 bool operator == (const Package &v) const
85 return name == v.name && version == v.version;
87 bool operator < (const Package &v) const
92 }else if (name == v.name && version < v.version){
97 // Load the file member of the package, but exclude configuration file
98 void loadfiles(Vserver const &ref, set<string> &files)
100 if (debug > 2) cout << "Loading files for package " << name << endl;
101 string namever = name + '-' + version;
102 FILE *fin = vutil_execdistcmd (K_UNIFILES,ref,namever.c_str());
105 while (fgets(tmp,sizeof(tmp)-1,fin)!=NULL){
106 int last = strlen(tmp)-1;
107 if (last >= 0 && tmp[last] == '\n') tmp[last] = '\0';
111 if (debug > 2) cout << "Done\n";
114 bool locate(const string &path)
116 return find (files.begin(),files.end(),path) != files.end();
121 // Check if two package have the same name (but potentially different version)
125 same_name(const Package &_pkg) : pkg(_pkg) {}
126 bool operator()(const Package &p)
128 return pkg.name == p.name;