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* packageInfoFileName = NULL;
|
||||
const char* installPath = NULL;
|
||||
bool isBuildPackage = false;
|
||||
bool quiet = false;
|
||||
bool verbose = false;
|
||||
|
||||
@ -46,11 +48,16 @@ command_create(int argc, const char* const* argv)
|
||||
};
|
||||
|
||||
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)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'b':
|
||||
isBuildPackage = true;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
changeToDirectory = optarg;
|
||||
break;
|
||||
@ -63,6 +70,10 @@ command_create(int argc, const char* const* argv)
|
||||
packageInfoFileName = optarg;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
installPath = optarg;
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
quiet = true;
|
||||
break;
|
||||
@ -83,6 +94,13 @@ command_create(int argc, const char* const* argv)
|
||||
|
||||
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
|
||||
PackageWriterListener listener(verbose, quiet);
|
||||
BPackageWriter packageWriter(&listener);
|
||||
@ -97,6 +115,7 @@ command_create(int argc, const char* const* argv)
|
||||
if (packageInfoFD < 0) {
|
||||
fprintf(stderr, "Error: Failed to open package info file \"%s\": "
|
||||
"%s\n", packageInfoFileName, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,12 +125,30 @@ command_create(int argc, const char* const* argv)
|
||||
listener.PrintError(
|
||||
"Error: Failed to change the current working directory to "
|
||||
"\"%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
|
||||
if (add_current_directory_entries(packageWriter, listener, true) != B_OK)
|
||||
if (!isBuildPackage) {
|
||||
if (add_current_directory_entries(packageWriter, listener, true)
|
||||
!= B_OK) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// add the .PackageInfo
|
||||
result = packageWriter.AddEntry(B_HPKG_PACKAGE_INFO_FILE_NAME,
|
||||
|
@ -41,10 +41,19 @@ static const char* kUsage =
|
||||
" create [ <options> ] <package>\n"
|
||||
" Creates package file <package> from contents of current directory.\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"
|
||||
" -i <info> - Use the package info file <info>. It will be added as\n"
|
||||
" \".PackageInfo\", overriding a \".PackageInfo\" file,\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"
|
||||
" -v - Be verbose (show more info about created package).\n"
|
||||
"\n"
|
||||
|
Loading…
Reference in New Issue
Block a user