24 : server_tool_(server_tool) { }
29 const std::string &manifest_path,
const std::string &repo_url,
30 const std::string &spooler_definition,
const std::string &
temp_dir,
31 const std::string &certificate,
const std::string &priv_key,
32 const std::string &repo_name,
const std::string &pwd,
33 const std::string &
meta_info,
const std::string &reflog_chksum_path,
34 const std::string &proxy,
const bool garbage_collectable,
35 const bool bootstrap_shortcuts,
const bool return_early,
36 const std::vector<shash::Any> reflog_catalogs) {
38 if (reflog_chksum_path !=
"") {
54 const bool follow_redirects =
false;
68 if (!manifest.IsValid()) {
75 if (reflog_chksum_path.empty()) {
76 reflog_hash = manifest->reflog_hash();
81 manifest->GetHashAlgorithm());
82 spooler = upload::Spooler::Construct(sd);
83 if (!spooler.IsValid()) {
89 if (!reflog_hash.
IsNull()) {
97 if (spooler->Peek(
".cvmfsreflog")) {
99 "no reflog hash specified but reflog is present");
107 upload::Spooler::CallbackPtr callback = spooler->RegisterListener(
111 spooler->ProcessCertificate(certificate);
113 spooler->UnregisterListener(callback);
115 if (certificate_hash.
IsNull()) {
121 shash::Any metainfo_hash = manifest->meta_info();
122 if (!meta_info.empty()) {
123 upload::Spooler::CallbackPtr callback = spooler->RegisterListener(
125 spooler->ProcessMetainfo(meta_info);
127 spooler->UnregisterListener(callback);
129 if (metainfo_hash.
IsNull()) {
139 if (!reflog->
AddCatalog(manifest->catalog_hash())) {
149 if (!manifest->history().IsNull()) {
150 if (!reflog->
AddHistory(manifest->history())) {
156 if (!metainfo_hash.
IsNull()) {
165 std::vector<shash::Any>::const_iterator i = reflog_catalogs.begin();
166 std::vector<shash::Any>::const_iterator iend = reflog_catalogs.end();
167 for (; i != iend; ++i) {
170 "Failed to add additional catalog %s to Reflog",
171 (*i).ToString().c_str());
182 spooler->UploadReflog(reflog_db_file);
183 spooler->WaitForUpload();
184 reflog_hash.
algorithm = manifest->GetHashAlgorithm();
186 unlink(reflog_db_file.c_str());
187 if (spooler->GetNumberOfErrors()) {
189 spooler->GetNumberOfErrors());
192 if (!reflog_chksum_path.empty())
203 manifest->set_certificate(certificate_hash);
204 manifest->set_repository_name(repo_name);
205 manifest->set_publish_timestamp(time(NULL));
206 manifest->set_garbage_collectability(garbage_collectable);
207 manifest->set_has_alt_catalog_path(bootstrap_shortcuts);
208 if (!metainfo_hash.
IsNull()) {
209 manifest->set_meta_info(metainfo_hash);
211 if (!reflog_hash.
IsNull()) {
212 manifest->set_reflog_hash(reflog_hash);
215 std::string signed_manifest = manifest->ExportString();
216 shash::Any published_hash(manifest->GetHashAlgorithm());
218 reinterpret_cast<const unsigned char *>(signed_manifest.data()),
219 signed_manifest.length(), &published_hash);
220 signed_manifest +=
"--\n" + published_hash.ToString() +
"\n";
223 if (manifest->has_alt_catalog_path()) {
224 const bool success = spooler->PlaceBootstrappingShortcut(
225 manifest->certificate())
226 && spooler->PlaceBootstrappingShortcut(
227 manifest->catalog_hash())
228 && (manifest->history().IsNull()
229 || spooler->PlaceBootstrappingShortcut(
230 manifest->history()))
231 && (metainfo_hash.
IsNull()
232 || spooler->PlaceBootstrappingShortcut(
237 "failed to place VOMS bootstrapping "
247 reinterpret_cast<const unsigned char *>(published_hash.ToString().data()),
248 published_hash.GetHexSize(), &sig, &sig_size);
249 if (!manifest_was_signed) {
254 signed_manifest += std::string(reinterpret_cast<char *>(sig), sig_size);
263 spooler->UploadManifest(manifest_path);
264 spooler->WaitForUpload();
265 unlink(manifest_path.c_str());
266 if (spooler->GetNumberOfErrors()) {
268 spooler->GetNumberOfErrors());
282 "Failed to upload certificate "
int return_code
the return value of the spooler operation
std::string database_file() const
const manifest::Manifest * manifest() const
SharedPtr< string > temp_dir
bool AddHistory(const shash::Any &history)
HttpObjectFetcher ObjectFetcher
static bool ReadChecksum(const std::string &path, shash::Any *checksum)
bool SafeWriteToFile(const std::string &content, const std::string &path, int mode)
upload::Spooler * spooler
void Set(const T &object)
bool AddCatalog(const shash::Any &catalog)
bool AddMetainfo(const shash::Any &metainfo)
bool Sign(const unsigned char *buffer, const unsigned buffer_size, unsigned char **signature, unsigned *signature_size)
static void HashDatabase(const std::string &database_path, shash::Any *hash_reflog)
manifest::Reflog * reflog
void DropDatabaseFileOwnership()
bool DirectoryExists(const std::string &path)
bool AddCertificate(const shash::Any &certificate)
void HashMem(const unsigned char *buffer, const unsigned buffer_size, Any *any_digest)
std::string meta_info() const
static bool WriteChecksum(const std::string &path, const shash::Any &value)
static Manifest * LoadFile(const std::string &path)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)