hrev46197 adds 6 changesets to branch 'master' old head: 54c746641ae240867f0730d9d1f810666f079706 new head: a27d687e2abdf10b16e5780df644a73f762afcaf overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=a27d687+%5E54c7466 ---------------------------------------------------------------------------- 0262f55: boot loader heap: Remove left over debug variables bd3bb3c: boot loader vfs.h: small cleanup 066d508: boot loader: Support loading haiku-*.hpkg ... i.e. properly canonically named Haiku system packages. 40c9cb7: rule AddFilesToContainer: Support naming files later * Add "flags" parameter and only supported flag "computeName". When specified the "destName" argument is the name of a shell command or function that will be called to determine the destination file name when the container is built. * AddFilesToHaikuImage: Pass flags to AddFilesToContainer. 16c8373: package: Add "info" command It allows to print individual information from the package meta data. a27d687: Name the generated HPKG files properly * rule AddPackageFilesToHaikuImage: Add "flags" parameter. The only supported flag is "nameFromMetaInfo". It causes the packages to be copied under their canonical file name onto the image. * Use the new flag for all generated packages save haiku_loader.hpkg. [ Ingo Weinhold <ingo_weinhold@xxxxxx> ] ---------------------------------------------------------------------------- 13 files changed, 273 insertions(+), 26 deletions(-) build/jam/ImageRules | 58 ++++++++++--- build/jam/OptionalPackages | 10 ++- build/jam/images/HaikuImage | 2 + build/jam/images/HaikuImageBootstrap | 2 + build/scripts/build_haiku_image | 6 ++ headers/private/kernel/boot/vfs.h | 15 ++-- src/bin/package/Jamfile | 2 +- src/bin/package/command_info.cpp | 136 +++++++++++++++++++++++++++++++ src/bin/package/package.cpp | 16 ++++ src/bin/package/package.h | 3 +- src/system/boot/loader/heap.cpp | 3 - src/system/boot/loader/vfs.cpp | 45 +++++++++- src/tools/package/Jamfile | 1 + ############################################################################ Commit: 0262f55a51dbd24f96b4577023c34cfa3cb48847 URL: http://cgit.haiku-os.org/haiku/commit/?id=0262f55 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Wed Oct 9 01:09:04 2013 UTC boot loader heap: Remove left over debug variables ---------------------------------------------------------------------------- diff --git a/src/system/boot/loader/heap.cpp b/src/system/boot/loader/heap.cpp index 9d945fc..4bb2fde 100644 --- a/src/system/boot/loader/heap.cpp +++ b/src/system/boot/loader/heap.cpp @@ -168,9 +168,6 @@ static void* sHeapBase; static size_t /*sHeapSize,*/ sMaxHeapSize, sAvailable, sMaxHeapUsage; static FreeChunkTree sFreeChunkTree; -static uint64 sTotalMallocCycles = 0; -static uint64 sTotalFreeCycles = 0; - static inline size_t align(size_t size) ############################################################################ Commit: bd3bb3cf5835524f1299074be43d0d0bd5ec63bb URL: http://cgit.haiku-os.org/haiku/commit/?id=bd3bb3c Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Wed Oct 9 01:28:07 2013 UTC boot loader vfs.h: small cleanup ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/boot/vfs.h b/headers/private/kernel/boot/vfs.h index f00e282..6cc97f9 100644 --- a/headers/private/kernel/boot/vfs.h +++ b/headers/private/kernel/boot/vfs.h @@ -109,17 +109,17 @@ public: BootVolume(); ~BootVolume(); - status_t SetTo(Directory* rootDirectory); - void Unset(); + status_t SetTo(Directory* rootDirectory); + void Unset(); - bool IsValid() const + bool IsValid() const { return fRootDirectory != NULL; } - Directory* RootDirectory() const + Directory* RootDirectory() const { return fRootDirectory; } - Directory* SystemDirectory() const + Directory* SystemDirectory() const { return fSystemDirectory; } - bool IsPackaged() const + bool IsPackaged() const { return fPackaged; } private: ############################################################################ Commit: 066d508682dd3028eb9b971974b913990811d3a1 URL: http://cgit.haiku-os.org/haiku/commit/?id=066d508 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Wed Oct 9 01:30:32 2013 UTC boot loader: Support loading haiku-*.hpkg ... i.e. properly canonically named Haiku system packages. ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/boot/vfs.h b/headers/private/kernel/boot/vfs.h index 6cc97f9..cf64119 100644 --- a/headers/private/kernel/boot/vfs.h +++ b/headers/private/kernel/boot/vfs.h @@ -123,6 +123,9 @@ public: { return fPackaged; } private: + int _OpenSystemPackage(); + +private: Directory* fRootDirectory; // root directory of the volume Directory* fSystemDirectory; diff --git a/src/system/boot/loader/vfs.cpp b/src/system/boot/loader/vfs.cpp index ae95a85..21d02c8 100644 --- a/src/system/boot/loader/vfs.cpp +++ b/src/system/boot/loader/vfs.cpp @@ -14,6 +14,8 @@ #include <StorageDefs.h> +#include <AutoDeleter.h> + #include <boot/platform.h> #include <boot/partitions.h> #include <boot/stdio.h> @@ -435,8 +437,7 @@ BootVolume::SetTo(Directory* rootDirectory) fSystemDirectory = static_cast<Directory*>(systemNode); // try opening the system package - int packageFD = open_from(fSystemDirectory, "packages/haiku.hpkg", - O_RDONLY); + int packageFD = _OpenSystemPackage(); fPackaged = packageFD >= 0; if (!fPackaged) return B_OK; @@ -474,6 +475,46 @@ BootVolume::Unset() } +int +BootVolume::_OpenSystemPackage() +{ + // open the packages directory + Node* packagesNode = fSystemDirectory->Lookup("packages", false); + if (packagesNode == NULL) + return -1; + MethodDeleter<Node, status_t> packagesNodeReleaser(packagesNode, + &Node::Release); + + if (!S_ISDIR(packagesNode->Type())) + return -1; + Directory* packageDirectory = (Directory*)packagesNode; + + // search for the system package + int fd = -1; + void* cookie; + if (packageDirectory->Open(&cookie, O_RDONLY) == B_OK) { + char name[B_FILE_NAME_LENGTH]; + while (packageDirectory->GetNextEntry(cookie, name, sizeof(name)) + == B_OK) { + // The name must end with ".hpkg". + size_t nameLength = strlen(name); + if (nameLength < 6 || strcmp(name + nameLength - 5, ".hpkg") != 0) + continue; + + // The name must either be "haiku.hpkg" or start with "haiku-". + if (strcmp(name, "haiku.hpkg") == 0 + || strncmp(name, "haiku-", 6) == 0) { + fd = open_from(packageDirectory, name, O_RDONLY); + break; + } + } + packageDirectory->Close(cookie); + } + + return fd; +} + + // #pragma mark - ############################################################################ Commit: 40c9cb7b47a7c26b270aae3eebe7a018e31b214f URL: http://cgit.haiku-os.org/haiku/commit/?id=40c9cb7 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Wed Oct 9 01:38:49 2013 UTC rule AddFilesToContainer: Support naming files later * Add "flags" parameter and only supported flag "computeName". When specified the "destName" argument is the name of a shell command or function that will be called to determine the destination file name when the container is built. * AddFilesToHaikuImage: Pass flags to AddFilesToContainer. ---------------------------------------------------------------------------- diff --git a/build/jam/ImageRules b/build/jam/ImageRules index f057e05..0aabdc0 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -189,10 +189,15 @@ rule PropagateContainerUpdateTargetFlags toTarget : fromTarget rule AddFilesToContainer container : directoryTokens : targets : destName + : flags { # AddFilesToContainer <container> : <directoryTokens> : <targets> - # [ : dest name ] + # : [ <destName> ] : [ <flags> ] # + # Supported flags: + # computeName - <destName> is the name of a shell command/function that + # computes the destination name. + local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ; local systemDirTokens = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ; @@ -236,15 +241,22 @@ rule AddFilesToContainer container : directoryTokens : targets : destName local target ; for target in $(targets) { local name ; + local nameFunction ; if $(destName) { - name = $(destName) ; + if computeName in $(flags) { + nameFunction = $(destName) ; + name = $(destName)/$(target:BS) ; + } else { + name = $(destName) ; + } } else { - name = $(target:G=:D=) ; + name = $(target:BS) ; } local destTarget = $(name:G=$(containerGrist)__$(directory:G=)) ; TARGET on $(destTarget) = $(target) ; INSTALL_DIR on $(destTarget) = $(directory) ; + NAME_FUNCTION on $(destTarget) = $(nameFunction) ; $(installTargetsVar) on $(target) += $(destTarget) ; TARGETS_TO_INSTALL on $(directory) += $(destTarget) ; @@ -673,14 +685,22 @@ rule CreateContainerCopyFilesScript container : script local destTarget ; for destTarget in $(destTargets) { local target = [ on $(destTarget) return $(TARGET) ] ; - local name = $(destTarget:BS) ; + local name = $(destTarget:G=) ; if $(name) != $(target:BS) { # use a unique dummy target for this file, on which we # can define the TARGET_DIR variable local dummyTarget = $(script)-dummy-$(dir:G=)-$(target) ; NotFile $(dummyTarget) ; TARGET_DIR on $(dummyTarget) = $(dir:G=) ; - INSTALL_TARGET_NAME on $(dummyTarget) = $(name) ; + + local nameFunction + = [ on $(destTarget) return $(NAME_FUNCTION) ] ; + if $(nameFunction) { + INSTALL_TARGET_NAME on $(dummyTarget) = "\\${name}" ; + } else { + INSTALL_TARGET_NAME on $(dummyTarget) = $(name) ; + } + NAME_FUNCTION on $(dummyTarget) = $(nameFunction) ; Depends $(dummyTarget) : $(initScript) $(target) $(serializationDependency) ; @@ -748,6 +768,11 @@ actions piecemeal AppendToContainerCopyFilesScript bind OUTPUT_SCRIPT actions AppendToContainerCopyFilesScriptSingleFile { + if [ -n "$(NAME_FUNCTION:E)" ]; then + echo "name=\`$(NAME_FUNCTION:E) \"$(2[2])\" 2> /dev/null \` || exit 1" \ + >> $(2[1]) + fi + echo \$cp "\"\${sPrefix}$(2[2])\"" \ "\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" >> $(2[1]) } @@ -885,12 +910,13 @@ rule AddDirectoryToHaikuImage directoryTokens : attributeFiles : $(directoryTokens) : $(attributeFiles) ] ; } -rule AddFilesToHaikuImage directory : targets : destName +rule AddFilesToHaikuImage directory : targets : destName : flags { - # AddFilesToHaikuImage <directory> : <targets> [ : dest name ] + # AddFilesToHaikuImage <directory> : <targets> : [ <destName> ] + # : [ <flags> ] AddFilesToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directory) - : $(targets) : $(destName) ; + : $(targets) : $(destName) : $(flags) ; } rule FFilesInHaikuImageDirectory directoryTokens ############################################################################ Commit: 16c83730262f1e4f0fc69d80744bb36dcfbbe3af URL: http://cgit.haiku-os.org/haiku/commit/?id=16c8373 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Wed Oct 9 01:43:08 2013 UTC package: Add "info" command It allows to print individual information from the package meta data. ---------------------------------------------------------------------------- diff --git a/src/bin/package/Jamfile b/src/bin/package/Jamfile index 7f34919..80f0c95 100644 --- a/src/bin/package/Jamfile +++ b/src/bin/package/Jamfile @@ -7,11 +7,11 @@ BinCommand package : command_create.cpp command_dump.cpp command_extract.cpp + command_info.cpp command_list.cpp package.cpp PackageWriterListener.cpp PackageWritingUtils.cpp - : package be $(TARGET_LIBSUPC++) diff --git a/src/bin/package/command_info.cpp b/src/bin/package/command_info.cpp new file mode 100644 index 0000000..301e358 --- /dev/null +++ b/src/bin/package/command_info.cpp @@ -0,0 +1,136 @@ +/* + * Copyright 2013, Ingo Weinhold, ingo_weinhold@xxxxxx. + * Distributed under the terms of the MIT License. + */ + + +#include <getopt.h> +#include <stdio.h> +#include <string.h> + +#include <Entry.h> +#include <package/PackageInfo.h> + +#include "package.h" + + +using namespace BPackageKit; + + +int +command_info(int argc, const char* const* argv) +{ + const char* format = "name: %name% version: %version%\n"; + + while (true) { + static struct option sLongOptions[] = { + { "format", required_argument, 0, 'f' }, + { "help", no_argument, 0, 'h' }, + { 0, 0, 0, 0 } + }; + + opterr = 0; // don't print errors + int c = getopt_long(argc, (char**)argv, "f:h", sLongOptions, NULL); + if (c == -1) + break; + + switch (c) { + case 'f': + format = optarg; + break; + + default: + print_usage_and_exit(true); + break; + } + } + + // One argument should remain -- the package file name. + if (optind + 1 != argc) + print_usage_and_exit(true); + + const char* fileName = argv[optind++]; + + // Read the package info from the package file. If it doesn't look like a + // package file, assume it is a package info file. + BPackageInfo info; + if (BString(fileName).EndsWith(".hpkg")) { + status_t error = info.ReadFromPackageFile(fileName); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to read package file \"%s\": %s\n", + fileName, strerror(error)); + return 1; + } + } else { + status_t error = info.ReadFromConfigFile(BEntry(fileName)); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to read package info file \"%s\": " + "%s\n", fileName, strerror(error)); + return 1; + } + } + + // parse format string and produce output + BString output; + while (*format != '\0') { + char c = *format++; + switch (c) { + case '%': + { + const char* start = format; + while (*format != '\0' && *format != '%') + format++; + if (*format != '%') { + fprintf(stderr, "Error: Unexpected at end of the format " + "string. Expected \"%%\".\n"); + return 1; + } + + if (format == start) { + output << '%'; + } else { + BString variable(start, format - start); + if (variable == "fileName") { + output << info.CanonicalFileName(); + } else if (variable == "name") { + output << info.Name(); + } else if (variable == "version") { + output << info.Version().ToString(); + } else { + fprintf(stderr, "Error: Unsupported placeholder \"%s\" " + "in format string.\n", variable.String()); + return 1; + } + } + + format++; + break; + } + + case '\\': + c = *format++; + if (c == '\0') { + fprintf(stderr, "Error: \"\\\" at the end of the format " + "string.\n"); + return 1; + } + switch (c) { + case 'n': + c = '\n'; + break; + case 't': + c = '\t'; + break; + } + // fall through + + default: + output << c; + break; + } + } + + fputs(output.String(), stdout); + + return 0; +} diff --git a/src/bin/package/package.cpp b/src/bin/package/package.cpp index 180169c..4954d99 100644 --- a/src/bin/package/package.cpp +++ b/src/bin/package/package.cpp @@ -76,6 +76,19 @@ static const char* kUsage = " of the archive.\n" " -i <info> - Extract the .PackageInfo file to <info> instead.\n" "\n" + " info [ <options> ] <package>\n" + " Prints individual meta information of package file <package>.\n" + "\n" + " -f <format>, --format <format>\n" + " - Print the given format string, performing the following\n" + " replacements:\n" + " %fileName% - the package's canonical file name\n" + " %name% - the package name\n" + " %version% - the package version\n" + " %% - %\n" + " \n - new line\n" + " \t - tab\n" + "\n" " list [ <options> ] <package>\n" " Lists the contents of package file <package>.\n" "\n" @@ -118,6 +131,9 @@ main(int argc, const char* const* argv) if (strcmp(command, "list") == 0) return command_list(argc - 1, argv + 1); + if (strcmp(command, "info") == 0) + return command_info(argc - 1, argv + 1); + if (strcmp(command, "help") == 0) print_usage_and_exit(false); else diff --git a/src/bin/package/package.h b/src/bin/package/package.h index 05ebf17..966386b 100644 --- a/src/bin/package/package.h +++ b/src/bin/package/package.h @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. + * Copyright 2009-2013, Ingo Weinhold, ingo_weinhold@xxxxxx. * Distributed under the terms of the MIT License. */ #ifndef PACKAGE_H @@ -12,6 +12,7 @@ int command_add(int argc, const char* const* argv); int command_create(int argc, const char* const* argv); int command_dump(int argc, const char* const* argv); int command_extract(int argc, const char* const* argv); +int command_info(int argc, const char* const* argv); int command_list(int argc, const char* const* argv); diff --git a/src/tools/package/Jamfile b/src/tools/package/Jamfile index 771e6a2..b9dfd36 100644 --- a/src/tools/package/Jamfile +++ b/src/tools/package/Jamfile @@ -11,6 +11,7 @@ BuildPlatformMain <build>package : command_create.cpp command_dump.cpp command_extract.cpp + command_info.cpp command_list.cpp package.cpp PackageWriterListener.cpp ############################################################################ Revision: hrev46197 Commit: a27d687e2abdf10b16e5780df644a73f762afcaf URL: http://cgit.haiku-os.org/haiku/commit/?id=a27d687 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Wed Oct 9 01:47:28 2013 UTC Name the generated HPKG files properly * rule AddPackageFilesToHaikuImage: Add "flags" parameter. The only supported flag is "nameFromMetaInfo". It causes the packages to be copied under their canonical file name onto the image. * Use the new flag for all generated packages save haiku_loader.hpkg. ---------------------------------------------------------------------------- diff --git a/build/jam/ImageRules b/build/jam/ImageRules index 0aabdc0..172a766 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -1009,14 +1009,26 @@ rule AddBootModuleSymlinksToHaikuImage targets : $(targets) ; } -rule AddPackageFilesToHaikuImage location : packages +rule AddPackageFilesToHaikuImage location : packages : flags { + # AddPackageFilesToHaikuImage <location> : <packages> : <flags> + # + # Supported flags: + # nameFromMetaInfo - determine the target file name from the package meta + # info + packages = [ FFilterByBuildFeatures $(packages) ] ; HAIKU_PACKAGES_IN_IMAGE on $(HAIKU_IMAGE_CONTAINER_NAME) = [ on $(HAIKU_IMAGE_CONTAINER_NAME) return $(HAIKU_PACKAGES_IN_IMAGE) ] $(packages) ; HAIKU_PACKAGE_INSTALLATION_LOCATION on $(packages) = $(location) ; - AddFilesToHaikuImage $(location) packages : $(packages) ; + + if nameFromMetaInfo in $(flags) { + AddFilesToHaikuImage $(location) packages : $(packages) + : packageFileName : computeName ; + } else { + AddFilesToHaikuImage $(location) packages : $(packages) ; + } } rule AddOptionalHaikuImagePackages packages diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index e071611..a9c018b 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -146,6 +146,8 @@ if [ IsOptionalHaikuImagePackageAdded DevelopmentMin ] haiku_devel.hpkg haiku_$(TARGET_PACKAGING_ARCHS[2-])_devel.hpkg makefile_engine.hpkg + : + nameFromMetaInfo ; } @@ -271,7 +273,8 @@ if [ IsOptionalHaikuImagePackageAdded WebPositive ] { for architectureObject in [ MultiArchSubDirSetup ] { on $(architectureObject) { if [ FIsBuildFeatureEnabled webpositive ] { - AddPackageFilesToHaikuImage system : webpositive.hpkg ; + AddPackageFilesToHaikuImage system : webpositive.hpkg + : nameFromMetaInfo ; InstallOptionalHaikuImagePackage $(baseURL)/WebPositiveBookmarks-2012-02-18.zip : home config settings WebPositive ; @@ -284,8 +287,9 @@ if [ IsOptionalHaikuImagePackageAdded WebPositive ] { # Welcome if [ IsOptionalHaikuImagePackageAdded Welcome ] { - AddPackageFilesToHaikuImage system : haiku_userguide.hpkg ; - AddPackageFilesToHaikuImage system : haiku_welcome.hpkg ; + AddPackageFilesToHaikuImage system : haiku_userguide.hpkg + : nameFromMetaInfo ; + AddPackageFilesToHaikuImage system : haiku_welcome.hpkg : nameFromMetaInfo ; AddSymlinkToHaikuImage home Desktop : /boot/system/bin/welcome : Welcome ; diff --git a/build/jam/images/HaikuImage b/build/jam/images/HaikuImage index 930247e..6a352b7 100644 --- a/build/jam/images/HaikuImage +++ b/build/jam/images/HaikuImage @@ -218,6 +218,8 @@ include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuPackages ] ; AddPackageFilesToHaikuImage system : haiku.hpkg haiku_$(TARGET_PACKAGING_ARCHS[2-]).hpkg + : + nameFromMetaInfo ; AddPackageFilesToHaikuImage system : haiku_loader.hpkg ; diff --git a/build/jam/images/HaikuImageBootstrap b/build/jam/images/HaikuImageBootstrap index fb50897..9be515c 100644 --- a/build/jam/images/HaikuImageBootstrap +++ b/build/jam/images/HaikuImageBootstrap @@ -175,6 +175,8 @@ include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuPackages ] ; AddPackageFilesToHaikuImage system : haiku.hpkg haiku_$(TARGET_PACKAGING_ARCHS[2-]).hpkg + : + nameFromMetaInfo ; AddPackageFilesToHaikuImage system : haiku_loader.hpkg ; diff --git a/build/scripts/build_haiku_image b/build/scripts/build_haiku_image index 6712519..e647281 100755 --- a/build/scripts/build_haiku_image +++ b/build/scripts/build_haiku_image @@ -219,6 +219,12 @@ downloadFile() } +packageFileName() +{ + $package info -f "%fileName%" "$1" +} + + mkdir -p $tmpDir copyrightsFile=$tmpDir/copyrights $rmAttrs -f $copyrightsFile