2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #ifndef SETUP_PACKAGE_SOURCE_H
17 #define SETUP_PACKAGE_SOURCE_H
19 /* this is the parent class for all package source (not source code - installation
20 * source as in http/ftp/disk file) operations.
26 #include "csu_util/MD5Sum.h"
32 site (const std::string
& newkey
);
35 bool operator == (site
const &rhs
)
37 return casecompare(key
, rhs
.key
) == 0;
44 packagesource ():size (0), canonical (), shortname (), cached (), validated (false)
46 memset (sha512sum
, 0, sizeof sha512sum
);
49 /* how big is the source file */
51 /* The canonical name - the complete path to the source file
52 * i.e. foo/bar/package-1.tar.bz2
54 const char *Canonical () const
56 if (!canonical
.empty())
57 return canonical
.c_str();
61 /* What is the cached filename, to prevent directory scanning during
62 install? Except in mirror mode, we never set this without
63 checking the size. The more expensive hash checking is reserved
64 for verifying the integrity of downloaded files and sources of
65 packages about to be installed. Set the 'validated' flag to
66 avoid checking the hash twice. */
67 char const *Cached () const
69 /* Pointer-coerce-to-boolean is used by many callers. */
72 return cached
.c_str();
74 /* sets the canonical path */
75 void set_canonical (char const *);
76 void set_cached (const std::string
& );
77 unsigned char sha512sum
[SHA512_DIGEST_LENGTH
];
80 /* The next two functions throw exceptions on failure. */
81 void check_size_and_cache (const std::string fullname
);
83 typedef std::vector
<site
> sitestype
;
87 std::string canonical
;
88 /* For progress reporting. */
89 std::string shortname
;
92 void check_sha512 (const std::string fullname
) const;
93 void check_md5 (const std::string fullname
) const;
96 #endif /* SETUP_PACKAGE_SOURCE_H */