1 // $Id: vutil.h,v 1.1 2003/09/29 22:01:57 ensc Exp $
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_FL
40 #define EXT2_IMMUTABLE_FL 0x00000010
43 #ifndef EXT2_IUNLINK_FL
44 /* Set both bits for backward compatibility */
45 #define EXT2_IUNLINK_FL 0x08008000
48 #ifndef EXT2_BARRIER_FL
49 #define EXT2_BARRIER_FL 0x04000000
53 FILE *vutil_execdistcmd (const char *, const string &, const char *);
54 extern const char K_DUMPFILES[];
55 extern const char K_UNIFILES[];
56 extern const char K_PKGVERSION[];
61 string version; // version + release
62 PACKAGE(string &_name, string &_version)
63 : name (_name), version(_version)
66 PACKAGE(const char *_name, const char *_version)
67 : name (_name), version(_version)
70 PACKAGE(const string &line)
74 PACKAGE & operator = (const string &_line)
77 string::iterator pos = find (line.begin(),line.end(),'=');
78 if (pos != line.end()){
79 name = string(line.begin(),pos);
80 version = string(pos + 1,line.end());
84 PACKAGE (const PACKAGE &pkg)
87 version = pkg.version;
89 bool operator == (const PACKAGE &v) const
91 return name == v.name && version == v.version;
93 bool operator < (const PACKAGE &v) const
98 }else if (name == v.name && version < v.version){
103 // Load the file member of the package, but exclude configuration file
104 void loadfiles(const string &ref, set<string> &files)
106 if (debug > 2) cout << "Loading files for package " << name << endl;
107 string namever = name + '-' + version;
108 FILE *fin = vutil_execdistcmd (K_UNIFILES,ref,namever.c_str());
111 while (fgets(tmp,sizeof(tmp)-1,fin)!=NULL){
112 int last = strlen(tmp)-1;
113 if (last >= 0 && tmp[last] == '\n') tmp[last] = '\0';
117 if (debug > 2) cout << "Done\n";
120 bool locate(const string &path)
122 return find (files.begin(),files.end(),path) != files.end();
127 // Check if two package have the same name (but potentially different version)
131 same_name(const PACKAGE &_pkg) : pkg(_pkg) {}
132 bool operator()(const PACKAGE &p)
134 return pkg.name == p.name;