CARDS 2.3.99
Package manager for the NuTyX GNU/Linux distribution
libcards.h
1 /*
2  GNU GENERAL PUBLIC LICENSE
3  Version 2, June 1991
4 
5  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
6  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
7 
8  Everyone is permitted to copy and distribute verbatim copies
9  of this license document, but changing it is not allowed.
10 
11  Preamble
12 
13  The licenses for most software are designed to take away your
14 freedom to share and change it. By contrast, the GNU General Public
15 License is intended to guarantee your freedom to share and change free
16 software--to make sure the software is free for all its users. This
17 General Public License applies to most of the Free Software
18 Foundation's software and to any other program whose authors commit to
19 using it. (Some other Free Software Foundation software is covered by
20 the GNU Library General Public License instead.) You can apply it to
21 your programs, too.
22 
23  When we speak of free software, we are referring to freedom, not
24 price. Our General Public Licenses are designed to make sure that you
25 have the freedom to distribute copies of free software (and charge for
26 this service if you wish), that you receive source code or can get it
27 if you want it, that you can change the software or use pieces of it
28 in new free programs; and that you know you can do these things.
29 
30  To protect your rights, we need to make restrictions that forbid
31 anyone to deny you these rights or to ask you to surrender the rights.
32 These restrictions translate to certain responsibilities for you if you
33 distribute copies of the software, or if you modify it.
34 
35  For example, if you distribute copies of such a program, whether
36 gratis or for a fee, you must give the recipients all the rights that
37 you have. You must make sure that they, too, receive or can get the
38 source code. And you must show them these terms so they know their
39 rights.
40 
41  We protect your rights with two steps: (1) copyright the software, and
42 (2) offer you this license which gives you legal permission to copy,
43 distribute and/or modify the software.
44 
45  Also, for each author's protection and ours, we want to make certain
46 that everyone understands that there is no warranty for this free
47 software. If the software is modified by someone else and passed on, we
48 want its recipients to know that what they have is not the original, so
49 that any problems introduced by others will not reflect on the original
50 authors' reputations.
51 
52  Finally, any free program is threatened constantly by software
53 patents. We wish to avoid the danger that redistributors of a free
54 program will individually obtain patent licenses, in effect making the
55 program proprietary. To prevent this, we have made it clear that any
56 patent must be licensed for everyone's free use or not licensed at all.
57 
58  The precise terms and conditions for copying, distribution and
59 modification follow.
60 
61  GNU GENERAL PUBLIC LICENSE
62  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
63 
64  0. This License applies to any program or other work which contains
65 a notice placed by the copyright holder saying it may be distributed
66 under the terms of this General Public License. The "Program", below,
67 refers to any such program or work, and a "work based on the Program"
68 means either the Program or any derivative work under copyright law:
69 that is to say, a work containing the Program or a portion of it,
70 either verbatim or with modifications and/or translated into another
71 language. (Hereinafter, translation is included without limitation in
72 the term "modification".) Each licensee is addressed as "you".
73 
74 Activities other than copying, distribution and modification are not
75 covered by this License; they are outside its scope. The act of
76 running the Program is not restricted, and the output from the Program
77 is covered only if its contents constitute a work based on the
78 Program (independent of having been made by running the Program).
79 Whether that is true depends on what the Program does.
80 
81  1. You may copy and distribute verbatim copies of the Program's
82 source code as you receive it, in any medium, provided that you
83 conspicuously and appropriately publish on each copy an appropriate
84 copyright notice and disclaimer of warranty; keep intact all the
85 notices that refer to this License and to the absence of any warranty;
86 and give any other recipients of the Program a copy of this License
87 along with the Program.
88 
89 You may charge a fee for the physical act of transferring a copy, and
90 you may at your option offer warranty protection in exchange for a fee.
91 
92  2. You may modify your copy or copies of the Program or any portion
93 of it, thus forming a work based on the Program, and copy and
94 distribute such modifications or work under the terms of Section 1
95 above, provided that you also meet all of these conditions:
96 
97  a) You must cause the modified files to carry prominent notices
98  stating that you changed the files and the date of any change.
99 
100  b) You must cause any work that you distribute or publish, that in
101  whole or in part contains or is derived from the Program or any
102  part thereof, to be licensed as a whole at no charge to all third
103  parties under the terms of this License.
104 
105  c) If the modified program normally reads commands interactively
106  when run, you must cause it, when started running for such
107  interactive use in the most ordinary way, to print or display an
108  announcement including an appropriate copyright notice and a
109  notice that there is no warranty (or else, saying that you provide
110  a warranty) and that users may redistribute the program under
111  these conditions, and telling the user how to view a copy of this
112  License. (Exception: if the Program itself is interactive but
113  does not normally print such an announcement, your work based on
114  the Program is not required to print an announcement.)
115 
116 These requirements apply to the modified work as a whole. If
117 identifiable sections of that work are not derived from the Program,
118 and can be reasonably considered independent and separate works in
119 themselves, then this License, and its terms, do not apply to those
120 sections when you distribute them as separate works. But when you
121 distribute the same sections as part of a whole which is a work based
122 on the Program, the distribution of the whole must be on the terms of
123 this License, whose permissions for other licensees extend to the
124 entire whole, and thus to each and every part regardless of who wrote it.
125 
126 Thus, it is not the intent of this section to claim rights or contest
127 your rights to work written entirely by you; rather, the intent is to
128 exercise the right to control the distribution of derivative or
129 collective works based on the Program.
130 
131 In addition, mere aggregation of another work not based on the Program
132 with the Program (or with a work based on the Program) on a volume of
133 a storage or distribution medium does not bring the other work under
134 the scope of this License.
135 
136  3. You may copy and distribute the Program (or a work based on it,
137 under Section 2) in object code or executable form under the terms of
138 Sections 1 and 2 above provided that you also do one of the following:
139 
140  a) Accompany it with the complete corresponding machine-readable
141  source code, which must be distributed under the terms of Sections
142  1 and 2 above on a medium customarily used for software interchange; or,
143 
144  b) Accompany it with a written offer, valid for at least three
145  years, to give any third party, for a charge no more than your
146  cost of physically performing source distribution, a complete
147  machine-readable copy of the corresponding source code, to be
148  distributed under the terms of Sections 1 and 2 above on a medium
149  customarily used for software interchange; or,
150 
151  c) Accompany it with the information you received as to the offer
152  to distribute corresponding source code. (This alternative is
153  allowed only for noncommercial distribution and only if you
154  received the program in object code or executable form with such
155  an offer, in accord with Subsection b above.)
156 
157 The source code for a work means the preferred form of the work for
158 making modifications to it. For an executable work, complete source
159 code means all the source code for all modules it contains, plus any
160 associated interface definition files, plus the scripts used to
161 control compilation and installation of the executable. However, as a
162 special exception, the source code distributed need not include
163 anything that is normally distributed (in either source or binary
164 form) with the major components (compiler, kernel, and so on) of the
165 operating system on which the executable runs, unless that component
166 itself accompanies the executable.
167 
168 If distribution of executable or object code is made by offering
169 access to copy from a designated place, then offering equivalent
170 access to copy the source code from the same place counts as
171 distribution of the source code, even though third parties are not
172 compelled to copy the source along with the object code.
173 
174  4. You may not copy, modify, sublicense, or distribute the Program
175 except as expressly provided under this License. Any attempt
176 otherwise to copy, modify, sublicense or distribute the Program is
177 void, and will automatically terminate your rights under this License.
178 However, parties who have received copies, or rights, from you under
179 this License will not have their licenses terminated so long as such
180 parties remain in full compliance.
181 
182  5. You are not required to accept this License, since you have not
183 signed it. However, nothing else grants you permission to modify or
184 distribute the Program or its derivative works. These actions are
185 prohibited by law if you do not accept this License. Therefore, by
186 modifying or distributing the Program (or any work based on the
187 Program), you indicate your acceptance of this License to do so, and
188 all its terms and conditions for copying, distributing or modifying
189 the Program or works based on it.
190 
191  6. Each time you redistribute the Program (or any work based on the
192 Program), the recipient automatically receives a license from the
193 original licensor to copy, distribute or modify the Program subject to
194 these terms and conditions. You may not impose any further
195 restrictions on the recipients' exercise of the rights granted herein.
196 You are not responsible for enforcing compliance by third parties to
197 this License.
198 
199  7. If, as a consequence of a court judgment or allegation of patent
200 infringement or for any other reason (not limited to patent issues),
201 conditions are imposed on you (whether by court order, agreement or
202 otherwise) that contradict the conditions of this License, they do not
203 excuse you from the conditions of this License. If you cannot
204 distribute so as to satisfy simultaneously your obligations under this
205 License and any other pertinent obligations, then as a consequence you
206 may not distribute the Program at all. For example, if a patent
207 license would not permit royalty-free redistribution of the Program by
208 all those who receive copies directly or indirectly through you, then
209 the only way you could satisfy both it and this License would be to
210 refrain entirely from distribution of the Program.
211 
212 If any portion of this section is held invalid or unenforceable under
213 any particular circumstance, the balance of the section is intended to
214 apply and the section as a whole is intended to apply in other
215 circumstances.
216 
217 It is not the purpose of this section to induce you to infringe any
218 patents or other property right claims or to contest validity of any
219 such claims; this section has the sole purpose of protecting the
220 integrity of the free software distribution system, which is
221 implemented by public license practices. Many people have made
222 generous contributions to the wide range of software distributed
223 through that system in reliance on consistent application of that
224 system; it is up to the author/donor to decide if he or she is willing
225 to distribute software through any other system and a licensee cannot
226 impose that choice.
227 
228 This section is intended to make thoroughly clear what is believed to
229 be a consequence of the rest of this License.
230 
231  8. If the distribution and/or use of the Program is restricted in
232 certain countries either by patents or by copyrighted interfaces, the
233 original copyright holder who places the Program under this License
234 may add an explicit geographical distribution limitation excluding
235 those countries, so that distribution is permitted only in or among
236 countries not thus excluded. In such case, this License incorporates
237 the limitation as if written in the body of this License.
238 
239  9. The Free Software Foundation may publish revised and/or new versions
240 of the General Public License from time to time. Such new versions will
241 be similar in spirit to the present version, but may differ in detail to
242 address new problems or concerns.
243 
244 Each version is given a distinguishing version number. If the Program
245 specifies a version number of this License which applies to it and "any
246 later version", you have the option of following the terms and conditions
247 either of that version or of any later version published by the Free
248 Software Foundation. If the Program does not specify a version number of
249 this License, you may choose any version ever published by the Free Software
250 Foundation.
251 
252  10. If you wish to incorporate parts of the Program into other free
253 programs whose distribution conditions are different, write to the author
254 to ask for permission. For software which is copyrighted by the Free
255 Software Foundation, write to the Free Software Foundation; we sometimes
256 make exceptions for this. Our decision will be guided by the two goals
257 of preserving the free status of all derivatives of our free software and
258 of promoting the sharing and reuse of software generally.
259 
260  NO WARRANTY
261 
262  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
263 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
264 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
265 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
266 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
267 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
268 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
269 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
270 REPAIR OR CORRECTION.
271 
272  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
273 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
274 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
275 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
276 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
277 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
278 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
279 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
280 POSSIBILITY OF SUCH DAMAGES.
281 
282  END OF TERMS AND CONDITIONS
283 
284  Appendix: How to Apply These Terms to Your New Programs
285 
286  If you develop a new program, and you want it to be of the greatest
287 possible use to the public, the best way to achieve this is to make it
288 free software which everyone can redistribute and change under these terms.
289 
290  To do so, attach the following notices to the program. It is safest
291 to attach them to the start of each source file to most effectively
292 convey the exclusion of warranty; and each file should have at least
293 the "copyright" line and a pointer to where the full notice is found.
294 
295  <one line to give the program's name and a brief idea of what it does.>
296  Copyright (C) 19yy <name of author>
297 
298  This program is free software; you can redistribute it and/or modify
299  it under the terms of the GNU General Public License as published by
300  the Free Software Foundation; either version 2 of the License, or
301  (at your option) any later version.
302 
303  This program is distributed in the hope that it will be useful,
304  but WITHOUT ANY WARRANTY; without even the implied warranty of
305  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
306  GNU General Public License for more details.
307 
308  You should have received a copy of the GNU General Public License
309  along with this program; if not, write to the Free Software
310  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
311 
312 Also add information on how to contact you by electronic and paper mail.
313 
314 If the program is interactive, make it output a short notice like this
315 when it starts in an interactive mode:
316 
317  Gnomovision version 69, Copyright (C) 19yy name of author
318  Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
319  This is free software, and you are welcome to redistribute it
320  under certain conditions; type `show c' for details.
321 
322 The hypothetical commands `show w' and `show c' should show the appropriate
323 parts of the General Public License. Of course, the commands you use may
324 be called something other than `show w' and `show c'; they could even be
325 mouse-clicks or menu items--whatever suits your program.
326 
327 You should also get your employer (if you work as a programmer) or your
328 school, if any, to sign a "copyright disclaimer" for the program, if
329 necessary. Here is a sample; alter the names:
330 
331  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
332  `Gnomovision' (which makes passes at compilers) written by James Hacker.
333 
334  <signature of Ty Coon>, 1 April 1989
335  Ty Coon, President of Vice
336 
337 This General Public License does not permit incorporating your program into
338 proprietary programs. If your program is a subroutine library, you may
339 consider it more useful to permit linking proprietary applications with the
340 library. If this is what you want to do, use the GNU Library General
341 Public License instead of this License.
342 */
343 
344 
345 #ifndef LIB_CARDS_INCLUDED
346 #define LIB_CARDS_INCLUDED
347 
348 
349 #include <string>
350 #include <iterator>
351 #include <iostream>
352 
353 #include <syslog.h>
354 #include <stdio.h>
355 #include <sys/utsname.h>
356 #include <locale.h>
357 #include <libintl.h>
358 
359 #define _ gettext
360 
364 std::string getMachineType ();
365 
366 
367 
368 
369 #include <cstring>
370 
371 #define RED "\033[1;31m"
372 #define GREEN "\033[1;32m"
373 #define YELLOW "\033[1;33m"
374 #define BLUE "\033[1;34m"
375 #define MAGENTA "\033[1;35m"
376 #define CYAN "\033[1;36m"
377 #define WHITE "\033[1;37m"
378 #define NORMAL "\033[1;0m"
379 
380 #define ACTION _("\033[1;33maction:\033[1;0m")
381 #define USAGE _("\033[1;33musage: \033[1;0m")
382 #define OPTIONS _("\033[1;33moptions\033[1;0m")
383 #define REQUIRED _("\033[1;33mrequired\033[1;0m")
384 #define DESCRIPTION _("\033[1;33mdescription: \033[1;0m")
385 #define COMMAND _("\033[1;34mcommand\033[1;0m")
386 
387 
388 enum error
389 {
390 CANNOT_DOWNLOAD_FILE,
391 CANNOT_CREATE_FILE,
392 CANNOT_OPEN_FILE,
393 CANNOT_FIND_FILE,
394 CANNOT_READ_FILE,
395 CANNOT_COPY_FILE,
396 CANNOT_PARSE_FILE,
397 CANNOT_READ_DIRECTORY,
398 CANNOT_WRITE_FILE,
399 CANNOT_SYNCHRONIZE,
400 CANNOT_RENAME_FILE,
401 CANNOT_DETERMINE_NAME_BUILDNR,
402 WRONG_ARCHITECTURE,
403 EMPTY_PACKAGE,
404 CANNOT_FORK,
405 WAIT_PID_FAILED,
406 DATABASE_LOCKED,
407 CANNOT_LOCK_DIRECTORY,
408 CANNOT_REMOVE_FILE,
409 CANNOT_CREATE_DIRECTORY,
410 CANNOT_RENAME_DIRECTORY,
411 OPTION_ONE_ARGUMENT,
412 INVALID_OPTION,
413 OPTION_MISSING,
414 TOO_MANY_OPTIONS,
415 ONLY_ROOT_CAN_INSTALL_UPGRADE_REMOVE,
416 PACKAGE_NOT_FOUND,
417 PACKAGE_ALLREADY_INSTALL,
418 PACKAGE_NOT_INSTALL,
419 PACKAGE_NOT_PREVIOUSLY_INSTALL,
420 LISTED_FILES_ALLREADY_INSTALLED,
421 PKGADD_CONFIG_LINE_TOO_LONG,
422 PKGADD_CONFIG_WRONG_NUMBER_ARGUMENTS,
423 PKGADD_CONFIG_UNKNOWN_ACTION,
424 PKGADD_CONFIG_UNKNOWN_EVENT,
425 CANNOT_COMPILE_REGULAR_EXPRESSION,
426 CANNOT_GENERATE_LEVEL,
427 NOT_INSTALL_PACKAGE_NEITHER_PACKAGE_FILE
428 };
429 
430 class RunTimeErrorWithErrno : public std::runtime_error
431 {
432  public:
433  explicit RunTimeErrorWithErrno(const std::string& msg) throw();
434  explicit RunTimeErrorWithErrno(const std::string& msg, int e) throw();
435 };
436 
437 
438 #include <string.h>
439 
440 #define uint8 unsigned char
441 #define uint32 unsigned long int
442 
444 {
445  uint32 total[2];
446  uint32 state[4];
447  uint8 buffer[64];
448 };
449 
450 void md5_starts( struct md5_context *ctx );
451 void md5_update( struct md5_context *ctx, uint8 *input, uint32 length );
452 void md5_finish( struct md5_context *ctx, uint8 digest[16] );
453 
454 
455 
456 
457 #include <fstream>
458 #include <map>
459 #include <set>
460 #include <vector>
461 
462 #include <sys/stat.h>
463 
464 #define GIGA 1e9
465 #define MEGA 1e6
466 #define KILO 1e3
467 #define PACKAGE_LOCALE_DIR "/usr/share/locale"
468 #define GETTEXT_PACKAGE "cards"
469 
470 void *Malloc(size_t s);
471 
472 struct keyValue
473 {
474  std::string parameter;
475  std::string value;
476 };
477 
481 typedef struct
482 {
483  char **items;
484  unsigned int count;
485 } itemList;
486 
490 itemList *initItemList(void);
491 
495 void addItemToItemList(itemList *list, const char *item);
496 
501 void freeItemList(itemList *list);
502 
506 keyValue splitKeyValue
507 (std::string s, char delimiter);
508 
509 std::set<std::string> getKeysList
510 (std::string file, std::string delimiter);
511 
512 std::string getValueOfKey
513 (std::string file, std::string delimiter,std::string parameter);
514 
515 std::string getValue(const std::string& s, char delimiter);
516 std::string getValueBefore( const std::string& s, char del );
517 std::string itos(unsigned int value);
518 std::string ultos(unsigned long int value);
519 
520 std::string mtos(mode_t mode);
521 std::string trimFileName(const std::string& filename);
522 std::string sizeHumanRead(int value);
523 
524 /*param s the string to be searched, param delimiter the delimiter char
525 return the value after the first occurance of a delimiter */
526 std::string getFirstValueOfKeyAfterDelim(const std::string& s, char delimiter);
527 
528 /*param s the string to be searched param delimiter the delimiter char
529 return the value before the first occurance of a delimiter */
530 std::string getFirstValueOfKeyBeforeDelim(const std::string& s, char delimiter);
531 
532 /* strip whitespace in the beginning and end of string, return a stripped string */
533 std::string stripWhiteSpace(const std::string& s);
534 
535 /* populate a vector of string with delimited character */
536 std::vector<std::string> parseDelimitedList
537 (const std::string& s, const char delimiter);
538 
539 /* populate a set of string with delimited character */
540 std::set<std::string> parseDelimitedSetList
541 (const std::string& s, const char delimiter);
542 
543 /* make sure s1 starts with s2 */
544 bool startsWith(const std::string& s, const std::string& with);
545 
550 bool startsWithNoCase(const std::string& s1, const std::string& s2);
551 
552 std::string convertToLowerCase(const std::string& s);
553 std::string convertToUpperCase(const std::string& s);
554 
555 std::string replaceAll
556 ( std::string& in, const std::string& oldString, const std::string& newString );
557 
567 template <class T>
568 void split( const std::string& s, char del,
569  T& target,
570  int startPos, bool useEmpty )
571 {
572  std::string line = s;
573  std::string ss;
574  std::string::size_type pos;
575  int offset = startPos;
576  while ( ( pos = line.find( del, offset ) ) != std::string::npos ) {
577  offset = 0;
578  if ( line[pos-1] == '\\' ) {
579  line.erase(pos-1,1);
580  ss = ss + line.substr(0,pos);
581  line.erase(0,pos);
582  continue;
583  }
584  std::string val = line.substr( 0, pos );
585  if ( ( useEmpty || !stripWhiteSpace( val ).empty() ) ||
586  ( ss.length() > 0 ) ) {
587  target.push_back( ss + val );
588  }
589  line.erase( 0, pos+1 );
590  }
591 
592  if ( ( line.length() > 0 ) || ( ss.length() > 0 ) ) {
593  target.push_back( ss + line );
594  }
595 }
596 
597 
598 
599 
600 #include <utime.h>
601 #include <dirent.h>
602 #include <sys/param.h>
603 #include <sys/file.h>
604 #include <unistd.h>
605 #include <libgen.h>
606 #include <err.h>
607 
608 #define S_CARDS_MODE 0755
609 
610 #define WS_NONE 0
611 #define WS_RECURSIVE (1 << 0)
612 #define WS_DEFAULT WS_RECURSIVE
613 #define WS_FOLLOWLINK (1 << 1) /* follow symlinks */
614 #define WS_DOTFILES (1 << 2) /* per unix convention, .file is hidden */
615 #define WS_MATCHDIRS (1 << 3) /* if pattern is used on dir names too */
616 
617 enum {
618  WALK_OK = 0,
619  WALK_BADPATTERN,
620  WALK_NAMETOOLONG,
621  WALK_BADIO
622 };
623 
624 struct InfoFile
625 {
626  std::string url;
627  std::string filename;
628  std::string dirname;
629  std::string md5sum;
630  long int filetime;
631  utimbuf acmodtime;
632  FILE *stream;
633 };
634 
635 struct DirUrl {
636  std::string Dir;
637  std::string Url;
638 };
639 
640 struct Config {
641  Config() {}
642  std::string hostname;
643  std::string database;
644  std::string username;
645  std::string password;
646  std::string socket;
647  std::string collection;
648  std::string name;
649  std::string version;
650  std::string arch;
651  std::string logdir;
652  std::vector<std::string> locale;
653  std::vector<DirUrl> dirUrl;
654  std::vector<std::string> baseDir;
655  std::vector<std::string> archs;
656 };
657 
658 int getConfig(const char *fileName, Config& config);
659 void * getDatas ( void * var, FILE * file, long offset, size_t size, size_t nmemb);
660 std::string trimFileName(const std::string& filename);
661 time_t getEpochModifyTimeFile(const std::string& filename);
662 std::string getDateFromEpoch(const time_t& epoch);
663 std::string getModifyTimeFile(const std::string& filename);
664 bool checkFileExist(const std::string& filename);
665 bool checkFileEmpty(const std::string& filename);
666 bool checkRegularFile(const std::string& filename);
667 bool checkFileSignature(const std::string& filename, const std::string& signature);
668 bool checkFilesEqual(const std::string& file1, const std::string& file2);
669 bool checkPermissionsEqual(const std::string& file1, const std::string& file2);
670 bool createRecursiveDirs(const std::string& pathname);
671 void cleanupMetaFiles(const std::string& basedir);
672 void removeFile(const std::string& basedir, const std::string& filename);
673 int copyFile(const char * destFile, const char * origFile);
674 int findFile(std::set<std::string>& filesList, const std::string& basedir);
675 int findDir(itemList *filenameList, const char *path);
676 int findRecursiveFile(std::set<std::string>& filenameList, const char *filename, int spec);
677 int readFileStripSpace(itemList *fileContent, const char *fileName);
678 int readFile(itemList *fileContent, const char *fileName);
679 int parseFile(std::set<std::string>& fileContent, const char* fileName);
680 int parseFile(std::vector<std::string>& fileContent, const char* fileName);
681 bool findMD5sum(const std::string& fileName, unsigned char* result);
682 bool checkMD5sum(const char * fileName, const char * MD5Sum);
683 /* read a file
684  return it into a template container */
685 template <class T>
686 int parseFile( T& target, const char* fileName)
687 {
688  FILE *fp = fopen (fileName, "r");
689  if (!fp)
690  return -1;
691  const int length = BUFSIZ;
692  char input[length];
693  std::string line;
694  while (fgets(input, length, fp)) {
695  input[strlen(input)-1] = '\0';
696  line = input;
697  target.push_back(line);
698  }
699  fclose(fp);
700  return 0;
701 }
702 
703 
704 
705 
706 
707 #include <archive.h>
708 #include <archive_entry.h>
709 
710 
711 #if ARCHIVE_VERSION_NUMBER >= 3000000
712 #define INIT_ARCHIVE(ar) \
713  archive_read_support_filter_gzip((ar)); \
714  archive_read_support_filter_bzip2((ar)); \
715  archive_read_support_filter_xz((ar)); \
716  archive_read_support_format_tar((ar))
717 #define FREE_ARCHIVE(ar) \
718  archive_read_free((ar))
719 #else
720 #define INIT_ARCHIVE(ar) \
721  archive_read_support_compression_gzip((ar)); \
722  archive_read_support_compression_bzip2((ar)); \
723  archive_read_support_compression_xz((ar)); \
724  archive_read_support_format_tar((ar))
725 #define FREE_ARCHIVE(ar) \
726  archive_read_finish((ar))
727 #endif
728 
729 #define DEFAULT_BYTES_PER_BLOCK (20 * 512)
730 #define METAFILE ".META"
731 #define INFOFILE ".INFO"
732 #define MTREEFILE ".MTREE"
733 
734 enum archive_error
735 {
736 CANNOT_OPEN_ARCHIVE,
737 CANNOT_READ_ARCHIVE,
738 CANNOT_FIND_META_FILE,
739 CANNOT_FIND_MTREE_FILE,
740 CANNOT_FIND_NAME,
741 CANNOT_FIND_ARCH,
742 EMPTY_ARCHIVE
743 };
744 
745 
746 class ArchiveUtils
747 {
748  public:
749 
750 
751  ArchiveUtils(const std::string& fileName);
752  virtual ~ArchiveUtils();
753 
754  virtual void treatErrors(const std::string& s) const;
755 
756  void printDeps(); // Print Out the dependencies
757  void printMeta(); // Print Out the .META file
758  void printInfo(); // the .INFO file
759  void list(); // list the files to stdio
760 
761 
762  unsigned int long size(); // Numbers of files in the archive
763  std::set<std::string> setofFiles(); // return a order set of string
764  std::set<std::string> listofDependencies(); // return an order set of dependencies
765  std::set<std::string> listofAlias(); // return the alias list
766  std::set<std::pair<std::string,time_t> > listofDependenciesBuildDate(); // return an order set of dependencies,BuildDate
767  std::string arch(); // return the arch of the package
768  std::string version(); // return the version of the package
769  int release(); // return the release of the package
770  std::string description();// return the description of the package
771  std::string url(); // return the url of the package
772  std::string contributors(); // return the Contributor(s) of the package
773  std::string maintainer(); // return the Maintainer(s) of the package
774  std::string collection(); // return the collection of the package
775  std::string packager(); // return the Packager(s) of the package
776  std::string builddate(); // return the date like Mon Mar 24 10:16:00 2014
777  std::string name(); // return the name of the package
778  std::string namebuildn(); // return the name + epochvalue
779  std::string epochBuildDate(); // return the epochvalue in string format
780  time_t buildn(); // return the epoch value
781 
782  private:
783 
784  std::string getPackageName();
785  std::string getPackageArch();
786  std::vector<std::string> extractFileContent(const char * fileName);
787  void getRunTimeDependencies();
788  void getRunTimeDependenciesEpoch();
789  void getAliasList();
790 
791  unsigned int long m_size;
792 
793  std::vector<std::string> m_contentMtree;
794  std::vector<std::string> m_contentMeta;
795  std::vector<std::string> m_contentInfo;
796 
797  std::set<std::string> m_rtDependenciesList;
798  std::set<std::pair<std::string,time_t> > m_rtDependenciesEpochList;
799  std::string m_fileName;
800  std::string m_packageName;
801  std::string m_packageArch;
802  std::set<std::string> m_filesList;
803  std::set<std::string> m_aliasList;
804 
805  archive_error m_actualError;
806 };
807 
808 int openArchive(const char *fileName);
809 
810 
811 
812 
813 
815  std::string md5SUM;
816  std::string name;
817  std::string arch;
818 };
819 
826 /*
827  **************************************************
828  * 73193bfc1cb30fe02a880ed088ed7590#1414192958#aalib#1.4rc5##n.a#n.a#n.a#n.a#.cards.tar.xz
829  * 650ed499ce78791d45b91aaf7f91b445#1428615787#firefox#37.0.1#1#Standalone web browser from mozilla.org#http://www.mozilla.com/firefox/#n.a#pierre at nutyx dot org,tnut at nutyx dot org#.cards.tar.xz
830  *************************************************
831  */
833  std::string md5SUM;
834  std::string s_buildDate;
835  std::string basePackageName;
836  std::string extention;
837  std::string version;
838  int release;
839  std::string description;
840  std::string URL;
841  std::string contributors;
842  std::string maintainer;
843  std::string packager;
844  std::string fileDate;
845  std::string alias;
846  std::string group;
847  time_t buildDate;
848  std::vector<PortFilesList> portFilesList;
849 };
850 
852  std::string Dir;
853  std::string Url;
854  std::vector<BasePackageInfo> basePackageList;
855 };
859 struct RepoInfo {
860  std::string branch;
861  std::string arch;
862  std::string collection;
863  std::vector<BasePackageInfo> basePackageList;
864 };
865 class Pkgrepo {
866 public:
867 
868  Pkgrepo(const std::string& fileName);
869  virtual ~Pkgrepo() {}
870  static int parseConfig(const char *fileName,
871  Config& config);
872 
883  std::set<std::string> getListOutOfDate();
884 
889  std::string getPortDir (const std::string& portName);
890 
891 
897  std::string getBasePortName (const std::string& portName);
902  std::string getBasePackageName(const std::string& packageName);
908  std::string getBasePackageVersion(const std::string& packageName);
909 
913  std::string getPortVersion (const std::string& portName);
914 
919  int getBasePackageRelease (const std::string& packageName);
920 
924  int getPortRelease(const std::string& portName);
928  bool checkPortExist(const std::string& portName);
929 
933  std::set<std::string> getListOfPackagesFromCollection(const std::string& collectionName);
934 
938  time_t getBinaryBuildTime (const std::string& portName);
939 
944  std::set<std::string> getBinaryPackageList();
949  std::vector<RepoInfo> getRepoInfo();
955  unsigned int getPortsList();
956 
957  bool getBinaryPackageInfo(const std::string& packageName);
958  bool getPortInfo(const std::string& portName);
959 
960 protected:
965  int parseConfig(const char *fileName);
966 
979  void parsePkgRepoCollectionFile();
980 
991  void parseCollectionDirectory();
992 
1004  void parseCurrentPackagePkgRepoFile();
1005 
1011  void parsePackagePkgfileFile();
1012 
1013 
1014  bool m_parsePkgRepoCollectionFile;
1015  bool m_parseCollectionDirectory;
1016  bool m_parsePackagePkgfileFile;
1017 
1018  std::vector<PortsDirectory>::iterator m_PortsDirectory_i;
1019  std::vector<BasePackageInfo>::iterator m_BasePackageInfo_i;
1020  std::vector<PortFilesList>::iterator m_PortFilesList_i;
1021 
1022  std::vector<PortFilesList> m_portFilesList;
1023 
1024  std::string m_packageFileName;
1025  std::string m_packageFileNameSignature;
1026  std::string m_configFileName;
1027  Config m_config;
1028 
1029  std::vector<PortsDirectory> m_portsDirectoryList;
1030 };
1031 #define REPODWL_H
1032 
1033 
1034 class Repodwl: public Pkgrepo {
1035 public:
1036  Repodwl(const char *fileName);
1047  void downloadPortsPkgRepo(const std::string& packageName);
1048 
1059  void downloadPackageFileName(const std::string& packageFileName);
1060  bool checkBinaryExist(const std::string& packageName);
1061  std::string getPackageFileName(const std::string& packageName);
1062  std::string getPackageFileNameSignature(const std::string& packageName);
1063 };
1064 
1071 #include <curl/curl.h>
1072 
1073 
1082 class FileDownload
1083 {
1084  public:
1085 
1094  FileDownload(std::string url, std::string dirName, std::string fileName, bool progress);
1095 
1105  FileDownload(std::string url, std::string dirName, std::string fileName, std::string MD5Sum , bool progress);
1106 
1114  FileDownload(std::vector<InfoFile> destinationFiles,bool progress);
1115 
1120  {
1121  curl_slist_free_all(m_slist);
1122  curl_global_cleanup();
1123  curl_easy_cleanup(m_curl);
1124  }
1125 
1126  private:
1127 
1131  bool checkMD5sum();
1132 
1136  void downloadFile();
1137 
1138  static int updateProgressHandle(void *p, double dltotal, double dlnow, double ultotal, double ulnow);
1139  static size_t writeToStreamHandle(void *buffer, size_t size, size_t nmemb, void *stream);
1140  int updateProgress(void *p, double dltotal, double dlnow, double ultotal, double ulnow);
1141  size_t writeToStream(void *buffer, size_t size, size_t nmemb, void *stream);
1142  void initFileToDownload(std::string _url, std::string _file);
1143 
1147  bool checkUpToDate();
1148  struct dwlProgress
1149  {
1150  double lastruntime;
1151  CURL *curl;
1152  };
1153  struct curl_slist *m_slist;
1154  void updateProgress();
1155 
1156  CURL* m_curl;
1157  CURLcode m_curlCode;
1158  dwlProgress m_downloadProgress;
1159  InfoFile m_destinationFile;
1160  std::string m_url;
1161  std::string m_downloadFileName;
1162  bool m_checkMD5;
1163  bool m_progress;
1164  std::string m_MD5Sum;
1165 };
1166 
1167 
1168 
1169 
1170 #include <list>
1171 #include <cassert>
1172 #include <cstddef>
1173 #include <cstdlib>
1174 #include <cstdio>
1175 
1176 #include <unistd.h>
1177 #include <fcntl.h>
1178 #include <sys/types.h>
1179 #include <sys/wait.h>
1180 
1181 
1190 class process
1191 {
1192 public:
1193  process();
1194  process( const std::string& app, const std::string& args, int fileDescriptorLog=0 );
1195 
1196  void execute(const std::string& app, const std::string& arguments, int fileDescriptorLog=0 );
1197 
1202  int execute();
1203 
1208  int executeShell();
1209 
1213  std::string name();
1214 
1218  std::string args();
1219 
1220 private:
1221 
1222  int exec(const int argc, char** argv);
1223  int execLog(const int argc, char** argv);
1224 
1225  int execShell(const char* shell);
1226  int execShellLog(const char* shell);
1227 
1228  std::string m_application;
1229  std::string m_arguments;
1230  int m_fileDescriptorLog;
1231 };
1232 
1233 
1234 
1235 
1236 #include <stdio.h>
1237 #include <stdlib.h>
1238 #include <string.h>
1239 #include <unistd.h>
1240 #include <sys/stat.h>
1241 
1242 
1243 int getRuntimeLibrariesList (std::set<std::string>& runtimeLibrariesList, const std::string& filename);
1244 
1245 
1252 #include <stdexcept>
1253 #include <csignal>
1254 #include <algorithm>
1255 
1256 #include <regex.h>
1257 #include <ext/stdio_filebuf.h>
1258 #include <pwd.h>
1259 #include <grp.h>
1260 
1261 
1262 
1263 #define LDCONFIG "sbin/ldconfig"
1264 #define LDCONFIG_CONF "etc/ld.so.conf"
1265 #define LDCONFIG_CONF_ARGS "-r "
1266 #define SHELL "bin/sh"
1267 
1268 #define INSTALL_INFO "usr/bin/install-info"
1269 #define INSTALL_INFO_ARGS "--info-dir=usr/share/info "
1270 #define UPDATE_ICON "usr/bin/gtk-update-icon-cache"
1271 #define UPDATE_ICON_ARGS "-f -t "
1272 
1273 #define COMPILE_SCHEMAS "usr/bin/glib-compile-schemas"
1274 #define COMPILE_SCHEMAS_ARGS ""
1275 
1276 #define UPDATE_DESKTOP_DB "usr/bin/update-desktop-database"
1277 #define UPDATE_DESKTOP_DB_ARGS "-q "
1278 
1279 #define UPDATE_MIME_DB "usr/bin/update-mime-database"
1280 #define UPDATE_MIME_DB_ARGS "-n "
1281 
1282 #define GDK_PIXBUF_QUERY_LOADER "usr/bin/gdk-pixbuf-query-loaders"
1283 #define GDK_PIXBUF_QUERY_LOADER_ARGS "--update-cache"
1284 
1285 #define GIO_QUERYMODULES "usr/bin/gio-querymodules"
1286 #define GIO_QUERYMODULES_ARGS "usr/lib/gio/modules"
1287 
1288 #define QUERY_IMMODULES_3 "usr/bin/gtk-query-immodules-3.0"
1289 #define QUERY_IMMODULES_3_ARGS "--update-cache"
1290 
1291 #define QUERY_IMMODULES_2 "usr/bin/gtk-query-immodules-2.0"
1292 #define QUERY_IMMODULES_2_ARGS "--update-cache"
1293 
1294 enum action
1295 {
1296 PKG_DOWNLOAD_START,
1297 PKG_DOWNLOAD_RUN,
1298 PKG_DOWNLOAD_END,
1299 DB_OPEN_START,
1300 DB_OPEN_RUN,
1301 DB_OPEN_END,
1302 PKG_PREINSTALL_START,
1303 PKG_PREINSTALL_END,
1304 PKG_INSTALL_START,
1305 PKG_INSTALL_END,
1306 PKG_INSTALL_RUN,
1307 PKG_POSTINSTALL_START,
1308 PKG_POSTINSTALL_END,
1309 PKG_MOVE_META_START,
1310 PKG_MOVE_META_END,
1311 DB_ADD_PKG_START,
1312 DB_ADD_PKG_END,
1313 LDCONFIG_START,
1314 LDCONFIG_END,
1315 RM_PKG_FILES_START,
1316 RM_PKG_FILES_RUN,
1317 RM_PKG_FILES_END
1318 };
1319 
1320 struct pkginfo_t {
1321  std::string base;
1322  std::string group;
1323  std::string collection;
1324  std::string description;
1325  std::string signature;
1326  time_t build; // date of build
1327  std::string version;
1328  int release;
1329  std::string url;
1330  std::string contributors;
1331  std::string packager;
1332  std::string maintainer;
1333  time_t install; // date of last installation
1334  std::string arch;
1335  int size;
1336  std::set< std::pair<std::string,time_t> > dependencies;
1337  std::set<std::string> alias;
1338  std::set<std::string> files;
1339 };
1340 typedef std::map<std::string, pkginfo_t> packages_t;
1341 typedef std::map<std::string, std::string> alias_t;
1342 
1343 enum rule_event_t {
1344  LDCONF,
1345  UPGRADE,
1346  INSTALL,
1347  INFO,
1348  ICONS,
1349  SCHEMAS,
1350  DESKTOP_DB,
1351  MIME_DB,
1352  QUERY_PIXBUF,
1353  GIO_QUERY,
1354  QUERY_IMOD3,
1355  QUERY_IMOD2
1356 };
1357 
1358 struct rule_t {
1359  rule_event_t event;
1360  std::string pattern;
1361  bool action;
1362 };
1363 
1364 class Pkgdbh {
1365 public:
1366 
1367  explicit Pkgdbh(const std::string& name);
1368  virtual ~Pkgdbh();
1369 
1370  /* Following methods can be redefined in derivated class */
1371  virtual void parseArguments(int argc, char** argv);
1372  virtual void run(int argc, char** argv) {};
1373  virtual void run() {};
1374 
1375  virtual void printHelp() const {};
1376 
1377  virtual void progressInfo() const;
1378  virtual void treatErrors(const std::string& s) const;
1379 
1380 
1381  void print_version() const;
1382  int getNumberOfPackages();
1383  std::set<std::string> getListOfPackageName();
1384  bool checkPackageNameExist(const std::string& name) const;
1385 
1386 protected:
1387  // Database
1388 
1389  std::set<std::string> getFilesOfPackage(const std::string& packageName);
1390  int getListOfPackageNames(const std::string& path);
1391  std::pair<std::string, pkginfo_t> getInfosPackage(const std::string& packageName);
1392  void buildSimpleDatabase();
1393  void buildCompleteDatabase(const bool& silent);
1394  void buildDatabase(const bool& progress,
1395  const bool& simple,
1396  const bool& all,
1397  const bool& files,
1398  const std::string& packageName);
1399 
1400 
1401  void addPackageFilesRefsToDB(const std::string& name,
1402  const pkginfo_t& info);
1403 
1404  bool checkPackageNameUptodate(const std::pair<std::string,
1405  pkginfo_t>& archiveName);
1406  bool checkPackageNameBuildDateSame(const std::pair<std::string,
1407  time_t>& dependencieNameBuild);
1408 
1409  /*
1410  * Remove the physical files after followings some rules
1411  */
1412  void removePackageFiles(const std::string& name);
1413  void removePackageFiles(const std::string& name,
1414  const std::set<std::string>& keep_list);
1415 
1416  /*
1417  * Remove meta data about the removed package
1418  */
1419  void removePackageFilesRefsFromDB(const std::string& name);
1420  void removePackageFilesRefsFromDB(std::set<std::string> files,
1421  const std::set<std::string>& keep_list);
1422  std::set<std::string> getConflictsFilesList(const std::string& name,
1423  const pkginfo_t& info);
1424 
1425  // Tar.gz
1426  std::pair<std::string, pkginfo_t> openArchivePackage(const std::string& filename);
1427  std::set< std::pair<std::string, time_t> > getPackageDependencies(const std::string& filename);
1428  void extractAndRunPREfromPackage(const std::string& filename);
1429  void installArchivePackage(const std::string& filename,
1430  const std::set<std::string>& keep_list,
1431  const std::set<std::string>& non_install_files);
1432 
1433  /*
1434  * The folder holding the meta datas is going to be create here
1435  */
1436  void moveMetaFilesPackage(const std::string& name, pkginfo_t& info);
1437 
1438 
1439  void readRulesFile();
1440  void getInstallRulesList(const std::vector<rule_t>& rules,
1441  rule_event_t event, std::vector<rule_t>& found) const;
1442  bool checkRuleAppliesToFile(const rule_t& rule,
1443  const std::string& file);
1444 
1445  void getFootprintPackage(std::string& filename);
1446 
1447  std::string m_packageArchiveName;
1448  std::string m_packageName;
1449  std::string m_packageArchiveVersion;
1450  std::string m_packageArchiveRelease;
1451  std::string m_packageArchiveCollection;
1452  std::string m_packageVersion;
1453  std::string m_packageRelease;
1454  std::string m_packageCollection;
1455  std::string m_utilName;
1456  std::string m_root;
1457  std::string m_build;
1458  std::vector<rule_t> m_actionRules;
1459  std::set< std::pair<std::string, int> > m_postInstallList;
1460  alias_t m_listOfAlias;
1461 
1462  packages_t m_listOfInstPackages;
1463  packages_t m_listOfDepotPackages;
1464 
1465  action m_actualAction;
1466  error m_actualError;
1467 
1468 private:
1469 
1470  void runLastPostInstall();
1471 
1472  std::set<std::string> m_runtimeLibrariesList;
1473  std::set<std::string> m_filesList;
1474  std::set<std::string> m_packageNamesList;
1475  unsigned int m_filesNumber;
1476  unsigned int m_installedFilesNumber;
1477 
1478 
1479  bool m_DB_Empty;
1480  bool m_miniDB_Empty;
1481 };
1482 
1483 class Db_lock {
1484 public:
1485  Db_lock(const std::string& m_root, bool exclusive);
1486  ~Db_lock();
1487 
1488 private:
1489  DIR* m_dir;
1490  struct sigaction m_sa;
1491 };
1492 
1493 void assertArgument(char** argv, int argc, int index);
1494 void rotatingCursor();
1495 
1509 class Pkgadd : public Pkgdbh {
1510 public:
1514  Pkgadd();
1520  Pkgadd(const std::string& commandName);
1521  void parseArguments(int argc, char** argv);
1522  void preRun();
1523  void postRun();
1524  virtual void run();
1525  virtual void run(int argc, char** argv);
1526  virtual void printHelp() const;
1527 
1528 protected:
1529  bool m_runPrePost;
1530  bool m_upgrade;
1531  bool m_force;
1532 private:
1533  std::set<std::string> getKeepFileList(const std::set<std::string>& files,
1534  const std::vector<rule_t>& rules);
1535  std::set<std::string> applyInstallRules(const std::string& name,
1536  pkginfo_t& info,
1537  const std::vector<rule_t>& rules);
1538  void applyPostInstallRules(const std::string& name,
1539  pkginfo_t& info,
1540  const std::vector<rule_t>& rules);
1541  void getInstallRulesList(const std::vector<rule_t>& rules,
1542  rule_event_t event,
1543  std::vector<rule_t>& found) const;
1544  void getPostInstallRulesList(const std::vector<rule_t>& rules,
1545  std::vector<rule_t>& found) const;
1546 };
1547 
1554 class Pkgrm : public Pkgdbh {
1555 public:
1556  Pkgrm(const std::string& commandName) : Pkgdbh(commandName) {}
1557  Pkgrm();
1558  void run();
1559  void run(int argc, char** argv);
1560  void printHelp() const;
1561 };
1562 
1563 
1570 #include <sstream>
1571 #include <iomanip>
1572 
1573 
1574 class Pkginfo : public Pkgdbh {
1575 public:
1576  Pkginfo(const std::string& commandName);
1577  Pkginfo();
1578  virtual void run(int argc, char** argv);
1579  virtual void parseArguments(int argc, char** argv);
1580  virtual void run();
1581  virtual void finish();
1582  virtual void printHelp() const;
1583 
1584 protected:
1585  std::string m_arg;
1586  int m_runtimedependencies_mode;
1587  int m_footprint_mode;
1588  int m_archiveinfo;
1589  int m_installed_mode;
1590  int m_list_mode;
1591  int m_owner_mode;
1592  int m_details_mode;
1593  int m_libraries_mode;
1594  int m_runtime_mode;
1595  int m_epoc;
1596 
1597 };
1598 
1599 
1600 
1601 
1602 
1603 class Pkginst : public Pkgadd, public Repodwl {
1604 public:
1605  Pkginst(const std::string& commandName, const char *configFileName);
1606  void generateDependencies(const std::pair<std::string,time_t>& packageName);
1607  void generateDependencies();
1608 
1609 protected:
1610  std::vector<std::string> m_dependenciesList;
1611 };
1612 
1613 
1614 #include <cstring>
1615 #include <cstdlib>
1616 #include <iostream>
1617 
1618 
1619 #include <curl/curl.h>
1620 #include <sys/types.h>
1621 #include <sys/stat.h>
1622 #include <unistd.h>
1623 #include <libgen.h>
1624 #include <dirent.h>
1625 
1626 class Pkgsync
1627 {
1628 public:
1633  Pkgsync();
1634  Pkgsync(const std::string& url,
1635  const std::string& directory,
1636  const std::string& repoFile);
1637 
1638  virtual void treatErrors(const std::string& s) const;
1639 
1640  virtual void run();
1641  virtual void purge();
1642  static const std::string DEFAULT_REPOFILE;
1643 
1644  void setRootPath(const std::string& path);
1645  void setConfigFile(const std::string& file);
1646 
1647 private:
1648 
1649  unsigned int getLocalPackages(const std::string& path);
1650  unsigned int getRemotePackages(const std::string& pkgrepoFile);
1651 
1652  void deleteFolder(const std::string& folderName);
1653 
1654  std::set<std::string> m_localPackagesList;
1655  std::set<std::string> m_remotePackagesList;
1656  const std::string m_baseDirectory;
1657  const std::string m_remoteUrl;
1658  std::string m_repoFile;
1659  std::string m_root;
1660  std::string m_configFile;
1661  error m_actualError;
1662 
1663 
1664 };
1665 
1666 #endif
1667 // vim:set ts=2 :
Definition: libcards.h:1320
Definition: libcards.h:481
Definition: libcards.h:865
Definition: libcards.h:814
Definition: libcards.h:1358
Definition: libcards.h:1574
Definition: error_treat.h:88
Definition: archive_utils.h:67
Definition: libcards.h:859
Definition: file_utils.h:64
Definition: libcards.h:851
Definition: libcards.h:832
Definition: libcards.h:472
Definition: libcards.h:1554
Definition: libcards.h:1626
Pkgadd class.
Definition: libcards.h:1509
Definition: libcards.h:443
Definition: file_utils.h:69
File Download class.
Definition: file_download.h:43
Definition: libcards.h:1483
Definition: libcards.h:1190
Definition: file_utils.h:53
Definition: libcards.h:1034
Definition: libcards.h:1364
~FileDownload()
Definition: libcards.h:1119
Definition: libcards.h:1603