Add options -b and -I to package command
* With -b building a build package can be requested. It will be empty save for the .PackageInfo. No license check is performed. * -I allows to specify an install path.
This commit is contained in:
parent
6ae0ecd49a
commit
1fc3ceeda2
@ -34,6 +34,8 @@ command_create(int argc, const char* const* argv)
|
|||||||
{
|
{
|
||||||
const char* changeToDirectory = NULL;
|
const char* changeToDirectory = NULL;
|
||||||
const char* packageInfoFileName = NULL;
|
const char* packageInfoFileName = NULL;
|
||||||
|
const char* installPath = NULL;
|
||||||
|
bool isBuildPackage = false;
|
||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
@ -46,11 +48,16 @@ command_create(int argc, const char* const* argv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
opterr = 0; // don't print errors
|
opterr = 0; // don't print errors
|
||||||
int c = getopt_long(argc, (char**)argv, "+C:hi:qv", sLongOptions, NULL);
|
int c = getopt_long(argc, (char**)argv, "+bC:hi:I:qv", sLongOptions,
|
||||||
|
NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'b':
|
||||||
|
isBuildPackage = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
changeToDirectory = optarg;
|
changeToDirectory = optarg;
|
||||||
break;
|
break;
|
||||||
@ -63,6 +70,10 @@ command_create(int argc, const char* const* argv)
|
|||||||
packageInfoFileName = optarg;
|
packageInfoFileName = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'I':
|
||||||
|
installPath = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'q':
|
case 'q':
|
||||||
quiet = true;
|
quiet = true;
|
||||||
break;
|
break;
|
||||||
@ -83,6 +94,13 @@ command_create(int argc, const char* const* argv)
|
|||||||
|
|
||||||
const char* packageFileName = argv[optind++];
|
const char* packageFileName = argv[optind++];
|
||||||
|
|
||||||
|
// -I is only allowed when -b is given
|
||||||
|
if (installPath != NULL && !isBuildPackage) {
|
||||||
|
fprintf(stderr, "Error: \"-I\" is only allowed when \"-b\" is "
|
||||||
|
"given.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// create package
|
// create package
|
||||||
PackageWriterListener listener(verbose, quiet);
|
PackageWriterListener listener(verbose, quiet);
|
||||||
BPackageWriter packageWriter(&listener);
|
BPackageWriter packageWriter(&listener);
|
||||||
@ -97,6 +115,7 @@ command_create(int argc, const char* const* argv)
|
|||||||
if (packageInfoFD < 0) {
|
if (packageInfoFD < 0) {
|
||||||
fprintf(stderr, "Error: Failed to open package info file \"%s\": "
|
fprintf(stderr, "Error: Failed to open package info file \"%s\": "
|
||||||
"%s\n", packageInfoFileName, strerror(errno));
|
"%s\n", packageInfoFileName, strerror(errno));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +125,30 @@ command_create(int argc, const char* const* argv)
|
|||||||
listener.PrintError(
|
listener.PrintError(
|
||||||
"Error: Failed to change the current working directory to "
|
"Error: Failed to change the current working directory to "
|
||||||
"\"%s\": %s\n", changeToDirectory, strerror(errno));
|
"\"%s\": %s\n", changeToDirectory, strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBuildPackage)
|
||||||
|
packageWriter.SetCheckLicenses(false);
|
||||||
|
|
||||||
|
// set install path, if specified
|
||||||
|
if (installPath != NULL) {
|
||||||
|
result = packageWriter.SetInstallPath(installPath);
|
||||||
|
if (result != B_OK) {
|
||||||
|
fprintf(stderr, "Error: Failed to set the package install path: "
|
||||||
|
"%s\n", strerror(result));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all files of the current directory, save for the .PackageInfo
|
// add all files of the current directory, save for the .PackageInfo
|
||||||
if (add_current_directory_entries(packageWriter, listener, true) != B_OK)
|
if (!isBuildPackage) {
|
||||||
return 1;
|
if (add_current_directory_entries(packageWriter, listener, true)
|
||||||
|
!= B_OK) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add the .PackageInfo
|
// add the .PackageInfo
|
||||||
result = packageWriter.AddEntry(B_HPKG_PACKAGE_INFO_FILE_NAME,
|
result = packageWriter.AddEntry(B_HPKG_PACKAGE_INFO_FILE_NAME,
|
||||||
|
@ -41,10 +41,19 @@ static const char* kUsage =
|
|||||||
" create [ <options> ] <package>\n"
|
" create [ <options> ] <package>\n"
|
||||||
" Creates package file <package> from contents of current directory.\n"
|
" Creates package file <package> from contents of current directory.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" -b - Create an empty build package. Only the .PackageInfo "
|
||||||
|
"will\n"
|
||||||
|
" be added.\n"
|
||||||
" -C <dir> - Change to directory <dir> before adding entries.\n"
|
" -C <dir> - Change to directory <dir> before adding entries.\n"
|
||||||
" -i <info> - Use the package info file <info>. It will be added as\n"
|
" -i <info> - Use the package info file <info>. It will be added as\n"
|
||||||
" \".PackageInfo\", overriding a \".PackageInfo\" file,\n"
|
" \".PackageInfo\", overriding a \".PackageInfo\" file,\n"
|
||||||
" existing.\n"
|
" existing.\n"
|
||||||
|
" -I <path> - Set the package's installation path to <path>. This is\n"
|
||||||
|
" an option only for use in package building. It will "
|
||||||
|
"cause\n"
|
||||||
|
" the package .self link to point to <path>, which is "
|
||||||
|
"useful\n"
|
||||||
|
" to redirect a \"make install\". Only allowed with -b.\n"
|
||||||
" -q - Be quiet (don't show any output except for errors).\n"
|
" -q - Be quiet (don't show any output except for errors).\n"
|
||||||
" -v - Be verbose (show more info about created package).\n"
|
" -v - Be verbose (show more info about created package).\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user