Ticket #12917: repository_rework_squash.diff
File repository_rework_squash.diff, 19.3 KB (added by , 8 years ago) |
---|
-
build/jam/ImageRules
diff --git a/build/jam/ImageRules b/build/jam/ImageRules index c018470..3141d70 100644
a b rule AddPackagesAndRepositoryVariablesToContainerScript script : container 901 901 local repositoryFiles ; 902 902 for repository in $(HAIKU_REPOSITORIES) { 903 903 repositoryFiles 904 += [ on $(repository) return $(HAIKU_REPOSITORY_C ACHE_FILE) ] ;904 += [ on $(repository) return $(HAIKU_REPOSITORY_CONFIG_FILE) ] ; 905 905 } 906 906 907 907 AddTargetVariableToScript $(script) : $(repositoryFiles) : repositories ; -
build/jam/RepositoryRules
diff --git a/build/jam/RepositoryRules b/build/jam/RepositoryRules index fb91089..9290f2f 100644
a b actions BuildRemoteHaikuPortsRepository1 761 761 } 762 762 763 763 764 rule HaikuRepository repository : repoInfoTemplate : packages 764 rule HaikuRepository repository : repoInfoTemplate : packages : url 765 765 { 766 # HaikuRepository <repository> : <repoInfoTemplate> : <packages> 767 # [ : < url> [ : <versionFile> ]] ;766 # HaikuRepository <repository> : <repoInfoTemplate> : <packages> : <url> 767 # [ : <versionFile> ] ; 768 768 # Builds the Haiku repository from the given packages and repository info 769 769 # template. <repository> must already be located. 770 770 # … … rule HaikuRepository repository : repoInfoTemplate : packages 773 773 # meta data files. 774 774 # <repoInfoTemplate> - The repository info template file to be used. 775 775 # <packages> - The packages to be added to the repository. 776 # <url> - The remote location of the initial update repository 776 777 777 778 local architecture = $(HAIKU_PACKAGING_ARCH) ; 778 779 local secondaryArchitecture ; … … rule HaikuRepository repository : repoInfoTemplate : packages 791 792 # build the respository config 792 793 local repositoryConfig = $(repository:G=repository-config)-config ; 793 794 MakeLocate $(repositoryConfig) : $(repositoriesDir) ; 794 RepositoryConfig $(repositoryConfig) : $(repositoryInfo) ;795 RepositoryConfig $(repositoryConfig) : $(repositoryInfo) : $(url) ; 795 796 HAIKU_REPOSITORY_CONFIG_FILE on $(repository) = $(repositoryConfig) ; 796 797 797 798 # setup the repository cache file -
build/jam/repositories/Haiku
diff --git a/build/jam/repositories/Haiku b/build/jam/repositories/Haiku index 14f5ebe..1e2f0b1 100644
a b if $(webPositiveIsAvailable) { 52 52 packages += webpositive ; 53 53 } 54 54 55 HaikuRepository $(haikuRepository) : $(repoInfo) : $(packages:S=.hpkg) ; 55 local version = current ; 56 #local version = $(HAIKU_VERSION) ; 57 local remoteURL = http://packages.haiku-os.org/haiku/master/$(HAIKU_PACKAGING_ARCH)/$(version) ; 58 59 HaikuRepository $(haikuRepository) : $(repoInfo) : $(packages:S=.hpkg) : $(remoteURL) ; -
build/scripts/build_haiku_image
diff --git a/build/scripts/build_haiku_image b/build/scripts/build_haiku_image index 28ab709..7554e0a 100755
a b set -o errexit 7 7 # tmpDir 8 8 # addBuildCompatibilityLibDir 9 9 # systemPackages - lists of the hpkg packages copied/updated 10 # repositories - all repository files10 # repositories - all repository configuration files 11 11 # downloadDir 12 12 # The following are only for image types: 13 13 # installDir -
headers/os/package/RepositoryInfo.h
diff --git a/headers/os/package/RepositoryInfo.h b/headers/os/package/RepositoryInfo.h index 32aa05d..513539c 100644
a b public: 33 33 status_t InitCheck() const; 34 34 35 35 const BString& Name() const; 36 const BString& OriginalBaseURL() const;37 36 const BString& Vendor() const; 38 37 const BString& Summary() const; 39 38 uint8 Priority() const; … … public: 42 41 const BStringList& LicenseTexts() const; 43 42 44 43 void SetName(const BString& name); 45 void SetOriginalBaseURL(const BString& url);46 44 void SetVendor(const BString& vendor); 47 45 void SetSummary(const BString& summary); 48 46 void SetPriority(uint8 priority); … … public: 57 55 58 56 static const uint8 kDefaultPriority; 59 57 58 // XXX: Kill me after everyone upgrades 59 static const char* const kURLField; 60 60 61 static const char* const kNameField; 61 static const char* const kURLField;62 62 static const char* const kVendorField; 63 63 static const char* const kSummaryField; 64 64 static const char* const kPriorityField; … … private: 74 74 status_t fInitStatus; 75 75 76 76 BString fName; 77 BString fOriginalBaseURL;78 77 BString fVendor; 79 78 BString fSummary; 80 79 uint8 fPriority; -
src/bin/package_repo/command_list.cpp
diff --git a/src/bin/package_repo/command_list.cpp b/src/bin/package_repo/command_list.cpp index c2dcd12..54d223d 100644
a b struct RepositoryContentListHandler : BRepositoryContentHandler { 69 69 printf("repository-info:\n"); 70 70 printf("\tname: %s\n", repositoryInfo.Name().String()); 71 71 printf("\tsummary: %s\n", repositoryInfo.Summary().String()); 72 printf("\turl: %s\n", repositoryInfo.OriginalBaseURL().String());73 72 printf("\tvendor: %s\n", repositoryInfo.Vendor().String()); 74 73 printf("\tpriority: %u\n", repositoryInfo.Priority()); 75 74 printf("\tarchitecture: %s\n", -
src/bin/pkgman/command_list_repos.cpp
diff --git a/src/bin/pkgman/command_list_repos.cpp b/src/bin/pkgman/command_list_repos.cpp index 677983a..c7a26cc 100644
a b ListReposCommand::Execute(int argc, const char* const* argv) 118 118 repoCache.Info().Architecture()]); 119 119 printf("\t\tpkg-count: %" B_PRIu32 "\n", 120 120 repoCache.CountPackages()); 121 printf("\t\torig-url: %s\n",122 repoCache.Info().OriginalBaseURL().String());123 121 printf("\t\torig-prio: %u\n", repoCache.Info().Priority()); 124 122 } else 125 123 printf("\t\t<no repository cache found>\n"); -
src/data/repository_infos/haiku
diff --git a/src/data/repository_infos/haiku b/src/data/repository_infos/haiku index a6501ab..1c1a558 100644
a b name Haiku 2 2 vendor "Haiku Project" 3 3 summary "The Haiku repository (for Haiku %HAIKU_VERSION_NO_REVISION%)" 4 4 priority 1 5 url http://packages.haiku-os.org/haiku/master/%HAIKU_PACKAGING_ARCH%/%HAIKU_VERSION_NO_REVISION%6 5 architecture %HAIKU_PACKAGING_ARCH% -
src/data/repository_infos/haikuports
diff --git a/src/data/repository_infos/haikuports b/src/data/repository_infos/haikuports index 3c62733..bb62321 100644
a b name HaikuPorts 2 2 vendor "Haiku Project" 3 3 summary "The HaikuPorts repository (for Haiku %HAIKU_VERSION_NO_REVISION%)" 4 4 priority 1 5 url http://packages.haiku-os.org/haikuports/master/repo/%HAIKU_PACKAGING_ARCH%/dummy6 5 architecture %HAIKU_PACKAGING_ARCH% -
src/kits/package/RepositoryInfo.cpp
diff --git a/src/kits/package/RepositoryInfo.cpp b/src/kits/package/RepositoryInfo.cpp index aaff367..4682854 100644
a b 1 1 /* 2 * Copyright 2011 , Haiku, Inc. All Rights Reserved.2 * Copyright 2011-2016, Haiku, Inc. All Rights Reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 5 * Authors: 6 6 * Oliver Tappe <zooey@hirschkaefer.de> 7 * Alexander von Gluck IV <kallisti5@unixzen.com> 7 8 */ 8 9 9 10 … … namespace BPackageKit { 27 28 const uint8 BRepositoryInfo::kDefaultPriority = 50; 28 29 29 30 const char* const BRepositoryInfo::kNameField = "name"; 30 const char* const BRepositoryInfo::kURLField = "url";31 31 const char* const BRepositoryInfo::kVendorField = "vendor"; 32 32 const char* const BRepositoryInfo::kSummaryField = "summary"; 33 33 const char* const BRepositoryInfo::kPriorityField = "priority"; … … const char* const BRepositoryInfo::kArchitectureField = "architecture"; 35 35 const char* const BRepositoryInfo::kLicenseNameField = "licenseName"; 36 36 const char* const BRepositoryInfo::kLicenseTextField = "licenseText"; 37 37 38 // XXX: Kill me after everyone upgrades. 39 const char* const BRepositoryInfo::kURLField = "url"; 40 38 41 39 42 BRepositoryInfo::BRepositoryInfo() 40 43 : … … BRepositoryInfo::Archive(BMessage* data, bool deep) const 82 85 if (result != B_OK) 83 86 return result; 84 87 85 if ((result = data->AddString(kNameField, fName)) != B_OK) 88 // XXX: Kill me after everyone upgrades 89 if ((result = data->AddString(kURLField, "STUB")) != B_OK) 86 90 return result; 87 if ((result = data->AddString(kURLField, fOriginalBaseURL)) != B_OK) 91 92 if ((result = data->AddString(kNameField, fName)) != B_OK) 88 93 return result; 89 94 if ((result = data->AddString(kVendorField, fVendor)) != B_OK) 90 95 return result; 91 result = data->AddString(kSummaryField, fSummary); 92 if (result != B_OK) 96 if ((result = data->AddString(kSummaryField, fSummary)) != B_OK) 93 97 return result; 94 98 if ((result = data->AddUInt8(kPriorityField, fPriority)) != B_OK) 95 99 return result; … … BRepositoryInfo::Name() const 139 143 140 144 141 145 const BString& 142 BRepositoryInfo::OriginalBaseURL() const143 {144 return fOriginalBaseURL;145 }146 147 148 const BString&149 146 BRepositoryInfo::Vendor() const 150 147 { 151 148 return fVendor; … … BRepositoryInfo::SetName(const BString& name) 195 192 196 193 197 194 void 198 BRepositoryInfo::SetOriginalBaseURL(const BString& url)199 {200 fOriginalBaseURL = url;201 }202 203 204 void205 195 BRepositoryInfo::SetVendor(const BString& vendor) 206 196 { 207 197 fVendor = vendor; … … BRepositoryInfo::_SetTo(const BMessage* data) 257 247 status_t result; 258 248 if ((result = data->FindString(kNameField, &fName)) != B_OK) 259 249 return result; 260 if ((result = data->FindString(kURLField, &fOriginalBaseURL)) != B_OK)261 return result;262 250 if ((result = data->FindString(kVendorField, &fVendor)) != B_OK) 263 251 return result; 264 252 result = data->FindString(kSummaryField, &fSummary); … … BRepositoryInfo::_SetTo(const BEntry& entry) 318 306 &unload_driver_settings); 319 307 320 308 const char* name = get_driver_parameter(settingsHandle, "name", NULL, NULL); 321 const char* url = get_driver_parameter(settingsHandle, "url", NULL, NULL);322 309 const char* vendor 323 310 = get_driver_parameter(settingsHandle, "vendor", NULL, NULL); 324 311 const char* summary … … BRepositoryInfo::_SetTo(const BEntry& entry) 328 315 const char* architectureString 329 316 = get_driver_parameter(settingsHandle, "architecture", NULL, NULL); 330 317 331 if (name == NULL || *name == '\0' || url == NULL || *url == '\0'318 if (name == NULL || *name == '\0' 332 319 || vendor == NULL || *vendor == '\0' 333 320 || summary == NULL || *summary == '\0' 334 321 || priorityString == NULL || *priorityString == '\0' … … BRepositoryInfo::_SetTo(const BEntry& entry) 343 330 } 344 331 345 332 fName = name; 346 fOriginalBaseURL = url;347 333 fVendor = vendor; 348 334 fSummary = summary; 349 335 fPriority = atoi(priorityString); -
src/tools/create_repository_config/create_repository_config.cpp
diff --git a/src/tools/create_repository_config/create_repository_config.cpp b/src/tools/create_repository_config/create_repository_config.cpp index 9837945..549146f 100644
a b 1 1 /* 2 * Copyright 2013 , Haiku, Inc. All Rights Reserved.2 * Copyright 2013-2016, Haiku, Inc. All Rights Reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 5 * Authors: 6 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 * Alexander von Gluck IV <kallisti5@unixzen.com> 7 8 */ 8 9 9 10 … … void 37 38 print_usage_and_exit(bool error) 38 39 { 39 40 fprintf(error ? stderr : stdout, 40 "Usage: %s [ <URL> ]<repository info> <repository config>\n"41 "Usage: %s <URL> <repository info> <repository config>\n" 41 42 "Creates a repository config file from a given repository info and\n" 42 "the base URL (the directory in which the \"repo\", \"repo.info\',\n" 43 "and \"repo.sha256 files can be found). If the URL is not specified,\n" 44 "the one from the repository info is used.", 43 "the base URL (the directory in which the 'repo', 'repo.info',\n" 44 "and 'repo.sha256' files can be found).\n", 45 45 sProgramName); 46 46 exit(error ? 1 : 0); 47 47 } … … print_usage_and_exit(bool error) 50 50 int 51 51 main(int argc, const char* const* argv) 52 52 { 53 if (argc < 3 || argc >4) {53 if (argc != 4) { 54 54 if (argc == 2 55 55 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) { 56 56 print_usage_and_exit(false); … … main(int argc, const char* const* argv) 59 59 } 60 60 61 61 int argi = 1; 62 const char* url = arg c == 4 ? argv[argi++] : NULL;62 const char* url = argv[argi++]; 63 63 const char* infoPath = argv[argi++]; 64 64 const char* configPath = argv[argi++]; 65 65 … … main(int argc, const char* const* argv) 68 68 DIE_ON_ERROR(repoInfo.SetTo(infoPath), 69 69 "failed to read repository info file \"%s\"", infoPath); 70 70 71 if (url == NULL)72 url = repoInfo.OriginalBaseURL();73 74 71 // init and write the config 75 72 BPackageKit::BRepositoryConfig repoConfig; 76 73 repoConfig.SetName(repoInfo.Name()); -
new file src/tools/get_package_dependencies/HTTPClient.cpp
diff --git a/src/tools/get_package_dependencies/HTTPClient.cpp b/src/tools/get_package_dependencies/HTTPClient.cpp new file mode 100644 index 0000000..2297d4d
- + 1 /* 2 * Copyright 2016, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Alexander von Gluck IV <kallisti5@unixzen.com> 7 */ 8 9 10 #include "HTTPClient.h" 11 12 #include <File.h> 13 14 15 HTTPClient::HTTPClient() 16 : 17 fCurl(NULL) 18 { 19 fCurl = curl_easy_init(); 20 curl_easy_setopt(fCurl, CURLOPT_FOLLOWLOCATION, 1L); 21 curl_easy_setopt(fCurl, CURLOPT_NOSIGNAL, 1); 22 curl_easy_setopt(fCurl, CURLOPT_ACCEPT_ENCODING, "deflate"); 23 curl_easy_setopt(fCurl, CURLOPT_WRITEFUNCTION, &_WriteCallback); 24 } 25 26 27 HTTPClient::~HTTPClient() 28 { 29 curl_easy_cleanup(fCurl); 30 } 31 32 33 size_t 34 HTTPClient::_WriteCallback(void *buffer, size_t size, size_t nmemb, 35 void *userp) 36 { 37 BFile* target = reinterpret_cast<BFile*>(userp); 38 ssize_t dataWritten = target->Write(buffer, size * nmemb); 39 return size_t(dataWritten); 40 } 41 42 43 status_t 44 HTTPClient::Get(BString* url, BEntry* destination) 45 { 46 BFile target(destination, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY); 47 48 curl_easy_setopt(fCurl, CURLOPT_URL, url->String()); 49 curl_easy_setopt(fCurl, CURLOPT_WRITEDATA, &target); 50 51 CURLcode res = curl_easy_perform(fCurl); 52 53 // Check result 54 if (res != CURLE_OK) { 55 fprintf(stderr, "curl_easy_perform() failed: %s\n", 56 curl_easy_strerror(res)); 57 return B_ERROR; 58 } 59 60 return B_OK; 61 } -
new file src/tools/get_package_dependencies/HTTPClient.h
diff --git a/src/tools/get_package_dependencies/HTTPClient.h b/src/tools/get_package_dependencies/HTTPClient.h new file mode 100644 index 0000000..d178153
- + 1 /* 2 * Copyright 2016, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Alexander von Gluck IV <kallisti5@unixzen.com> 7 */ 8 #ifndef HTTP_CLIENT_H 9 #define HTTP_CLIENT_H 10 11 12 #include <String.h> 13 #include <Entry.h> 14 #include <curl/curl.h> 15 16 17 class HTTPClient { 18 public: 19 HTTPClient(); 20 ~HTTPClient(); 21 22 status_t Get(BString* url, BEntry* destination); 23 24 private: 25 static size_t _WriteCallback(void *buffer, size_t size, size_t nmemb, 26 void *userp); 27 28 CURL* fCurl; 29 }; 30 31 32 #endif /* HTTP_CLIENT_H */ -
src/tools/get_package_dependencies/Jamfile
diff --git a/src/tools/get_package_dependencies/Jamfile b/src/tools/get_package_dependencies/Jamfile index 0bba9b0..452afab 100644
a b USES_BE_API on <build>get_package_dependencies = true ; 8 8 9 9 BuildPlatformMain <build>get_package_dependencies : 10 10 get_package_dependencies.cpp 11 HTTPClient.cpp 11 12 : 12 13 libpackage-add-on-libsolv_build.so 13 14 libsolvext_build.so libsolv_build.so 14 libpackage_build.so $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++)15 libpackage_build.so $(HOST_LIBBE) curl $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) 15 16 ; -
src/tools/get_package_dependencies/get_package_dependencies.cpp
diff --git a/src/tools/get_package_dependencies/get_package_dependencies.cpp b/src/tools/get_package_dependencies/get_package_dependencies.cpp index 63d5439..09ec554 100644
a b 1 1 /* 2 * Copyright 2013 , Haiku, Inc. All Rights Reserved.2 * Copyright 2013-2016, Haiku, Inc. All Rights Reserved. 3 3 * Distributed under the terms of the MIT License. 4 4 * 5 5 * Authors: 6 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 * Alexander von Gluck IV <kallisti5@unixzen.com> 7 8 */ 8 9 9 10 … … 13 14 14 15 #include <map> 15 16 17 #include <FindDirectory.h> 18 #include <package/RepositoryConfig.h> 16 19 #include <package/RepositoryCache.h> 17 20 #include <package/manager/Exceptions.h> 18 21 #include <package/manager/RepositoryBuilder.h> … … 23 26 #include <package/solver/SolverProblemSolution.h> 24 27 #include <package/solver/SolverRepository.h> 25 28 #include <package/solver/SolverResult.h> 29 #include <Path.h> 30 31 #include "HTTPClient.h" 26 32 27 33 28 34 using namespace BPackageKit; … … void 44 50 print_usage_and_exit(bool error) 45 51 { 46 52 fprintf(error ? stderr : stdout, 47 "Usage: %s <repository > ... -- <package> ...\n"53 "Usage: %s <repository-config> ... -- <package> ...\n" 48 54 "Resolves the dependencies of the given packages using the given\n" 49 55 "repositories and prints the URLs of the packages that are also\n" 50 56 "needed to satisfy all requirements. Fails, if there are conflicts\n" … … print_usage_and_exit(bool error) 54 60 } 55 61 56 62 63 static status_t 64 get_repocache(BRepositoryConfig config, BPath* outFile) 65 { 66 BString finalURL; 67 finalURL.SetTo(config.BaseURL()); 68 finalURL += "/repo"; 69 70 if (find_directory(B_SYSTEM_TEMP_DIRECTORY, outFile) != B_OK) 71 outFile->SetTo("/tmp"); 72 73 BString tempFile = config.Name(); 74 tempFile += ".repocache"; 75 76 outFile->Append(tempFile); 77 78 //printf("Downloading: %s\n", finalURL.String()); 79 //printf("Final output will be %s\n", outFile->Path()); 80 81 BEntry entry(outFile->Path()); 82 HTTPClient* http = new HTTPClient; 83 status_t result = http->Get(&finalURL, &entry); 84 delete http; 85 86 return result; 87 } 88 89 57 90 int 58 91 main(int argc, const char* const* argv) 59 92 { … … main(int argc, const char* const* argv) 93 126 DIE(B_OK, "%s", e.Details().String()); 94 127 } 95 128 96 // add external repositories 97 std::map<BSolverRepository*, BRepositoryInfo> repositoryInfos; 129 // add specified remote repositories 130 std::map<BSolverRepository*, BString> repositoryURLs; 131 98 132 for (int i = 0; i < repositoryCount; i++) { 99 133 BSolverRepository* repository = new BSolverRepository; 134 BRepositoryConfig config; 135 error = config.SetTo(repositories[i]); 136 if (error != B_OK) 137 DIE(error, "failed to read repository config '%s'", repositories[i]); 138 139 // TODO: It would make sense if BRepositoryBuilder could accept a 140 // BRepositoryConfig directly and "get" the remote BRepositoryCache 141 // to properly solve dependencies. For now we curl here. 142 143 BPath output; 144 get_repocache(config, &output); 145 100 146 BRepositoryCache cache; 101 error = cache.SetTo( repositories[i]);147 error = cache.SetTo(output.Path()); 102 148 if (error != B_OK) 103 DIE(error, "failed to read repository file '%s'", repositories[i]); 149 DIE(error, "failed to read repository cache '%s'", repositories[i]); 150 104 151 BRepositoryBuilder(*repository, cache) 105 152 .AddToSolver(solver, false); 106 repository Infos[repository] = cache.Info();153 repositoryURLs[repository] = config.BaseURL(); 107 154 } 108 155 109 156 // solve … … main(int argc, const char* const* argv) 152 199 switch (element->Type()) { 153 200 case BSolverResultElement::B_TYPE_INSTALL: 154 201 if (package->Repository() != &installedRepository) { 155 const BRepositoryInfo& info 156 = repositoryInfos[package->Repository()]; 157 BString url = info.OriginalBaseURL(); 202 BString url = repositoryURLs[package->Repository()]; 158 203 url << "/packages/" << package->Info().CanonicalFileName(); 159 204 printf("%s\n", url.String()); 160 205 }