Changeset 18809 in vbox
- Timestamp:
- Apr 7, 2009 11:57:07 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r18782 r18809 242 242 { 243 243 RTPrintf("VBoxManage export <machines> --output|-o <ovf>\n" 244 " [--legacy09]\n" 245 " [--vsys <number of virtual system>]\n" 246 " [--product <product name>]\n" 247 " [--producturl <product url>]\n" 248 " [--vendor <vendor name>]\n" 249 " [--vendorurl <vendor url>]\n" 250 " [--version <version info>]\n" 251 " [--eula <license text>]\n" 252 " [--eulafile <filename>]\n" 244 253 "\n"); 245 254 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r18775 r18809 44 44 #include <iprt/ctype.h> 45 45 #include <iprt/path.h> 46 #include <iprt/file.h> 46 47 47 48 #include <VBox/log.h> … … 93 94 { "--vmname", 'V', RTGETOPT_REQ_STRING }, 94 95 { "-vmname", 'V', RTGETOPT_REQ_STRING }, // deprecated 96 { "--description", 'd', RTGETOPT_REQ_STRING }, 95 97 { "--eula", 'L', RTGETOPT_REQ_STRING }, 96 98 { "-eula", 'L', RTGETOPT_REQ_STRING }, // deprecated … … 151 153 return errorSyntax(USAGE_IMPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 152 154 mapArgsMapsPerVsys[ulCurVsys]["vmname"] = ValueUnion.psz; 155 break; 156 157 case 'd': // --description 158 if (ulCurVsys == (uint32_t)-1) 159 return errorSyntax(USAGE_IMPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 160 mapArgsMapsPerVsys[ulCurVsys]["description"] = ValueUnion.psz; 161 break; 162 163 case 'L': // --eula 164 if (ulCurVsys == (uint32_t)-1) 165 return errorSyntax(USAGE_IMPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 166 mapArgsMapsPerVsys[ulCurVsys]["eula"] = ValueUnion.psz; 153 167 break; 154 168 … … 327 341 switch (t) 328 342 { 343 case VirtualSystemDescriptionType_OS: 344 if (findArgValue(strOverride, pmapArgs, "ostype")) 345 { 346 bstrFinalValue = strOverride; 347 RTPrintf("%2u: OS type specified with --ostype: \"%ls\"\n", 348 a, bstrFinalValue.raw()); 349 } 350 else 351 RTPrintf("%2u: Suggested OS type: \"%ls\"" 352 "\n (change with \"--vsys %u --ostype <type>\"; use \"list ostypes\" to list all possible values)\n", 353 a, bstrFinalValue.raw(), i); 354 break; 355 329 356 case VirtualSystemDescriptionType_Name: 330 357 if (findArgValue(strOverride, pmapArgs, "vmname")) … … 340 367 break; 341 368 342 case VirtualSystemDescriptionType_OS: 343 if (findArgValue(strOverride, pmapArgs, "ostype")) 369 case VirtualSystemDescriptionType_Product: 370 RTPrintf("%2u: Product (ignored): %ls\n", 371 a, aVboxValues[a]); 372 break; 373 374 case VirtualSystemDescriptionType_ProductUrl: 375 RTPrintf("%2u: ProductUrl (ignored): %ls\n", 376 a, aVboxValues[a]); 377 break; 378 379 case VirtualSystemDescriptionType_Vendor: 380 RTPrintf("%2u: Vendor (ignored): %ls\n", 381 a, aVboxValues[a]); 382 break; 383 384 case VirtualSystemDescriptionType_VendorUrl: 385 RTPrintf("%2u: VendorUrl (ignored): %ls\n", 386 a, aVboxValues[a]); 387 break; 388 389 case VirtualSystemDescriptionType_Version: 390 RTPrintf("%2u: Version (ignored): %ls\n", 391 a, aVboxValues[a]); 392 break; 393 394 case VirtualSystemDescriptionType_Description: 395 if (findArgValue(strOverride, pmapArgs, "description")) 344 396 { 345 397 bstrFinalValue = strOverride; 346 RTPrintf("%2u: OS type specified with --ostype: \"%ls\"\n",398 RTPrintf("%2u: Description specified with --description: \"%ls\"\n", 347 399 a, bstrFinalValue.raw()); 348 400 } 349 401 else 350 RTPrintf("%2u: Suggested OS type:\"%ls\""351 "\n (change with \"--vsys %u -- ostype <type>\"; use \"list ostypes\" to list all)\n",402 RTPrintf("%2u: Description \"%ls\"" 403 "\n (change with \"--vsys %u --description <desc>\")\n", 352 404 a, bstrFinalValue.raw(), i); 353 break;354 355 case VirtualSystemDescriptionType_Description:356 RTPrintf("%2u: Description: \"%ls\"\n",357 a, bstrFinalValue.raw());358 405 break; 359 406 … … 381 428 else 382 429 RTPrintf("%2u: End-user license agreement" 383 "\n (display with \"--vsys %u - eula show\";"384 "\n accept with \"--vsys %u - eula accept\")\n",430 "\n (display with \"--vsys %u --eula show\";" 431 "\n accept with \"--vsys %u --eula accept\")\n", 385 432 a, i, i); 386 433 break; … … 620 667 = { 621 668 { "--output", 'o', RTGETOPT_REQ_STRING }, 669 { "--legacy09", 'l', RTGETOPT_REQ_NOTHING }, 670 { "--vsys", 's', RTGETOPT_REQ_UINT32 }, 671 { "--product", 'p', RTGETOPT_REQ_STRING }, 672 { "--producturl", 'P', RTGETOPT_REQ_STRING }, 673 { "--vendor", 'd', RTGETOPT_REQ_STRING }, 674 { "--vendorurl", 'D', RTGETOPT_REQ_STRING }, 675 { "--version", 'v', RTGETOPT_REQ_STRING }, 676 { "--eula", 'e', RTGETOPT_REQ_STRING }, 677 { "--eulafile", 'E', RTGETOPT_REQ_STRING }, 622 678 }; 623 679 … … 627 683 628 684 Utf8Str strOutputFile; 685 Utf8Str strOvfFormat("ovf-1.0"); // the default export version 629 686 std::list< ComPtr<IMachine> > llMachines; 630 687 688 uint32_t ulCurVsys = (uint32_t)-1; 689 // for each --vsys X command, maintain a map of command line items 690 ArgsMapsMap mapArgsMapsPerVsys; 631 691 do 632 692 { … … 638 698 RTGetOptInit(&GetState, a->argc, a->argv, g_aExportOptions, 639 699 RT_ELEMENTS(g_aExportOptions), 0, 0 /* fFlags */); 700 701 Utf8Str strProductUrl; 640 702 while ((c = RTGetOpt(&GetState, &ValueUnion))) 641 703 { … … 647 709 else 648 710 strOutputFile = ValueUnion.psz; 711 break; 712 713 case 'l': // --legacy09 714 strOvfFormat = "ovf-0.9"; 715 break; 716 717 case 's': // --vsys 718 ulCurVsys = ValueUnion.u32; 719 break; 720 721 case 'p': // --product 722 if (ulCurVsys == (uint32_t)-1) 723 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 724 mapArgsMapsPerVsys[ulCurVsys]["product"] = ValueUnion.psz; 725 break; 726 727 case 'P': // --producturl 728 if (ulCurVsys == (uint32_t)-1) 729 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 730 mapArgsMapsPerVsys[ulCurVsys]["producturl"] = ValueUnion.psz; 731 break; 732 733 case 'd': // --vendor 734 if (ulCurVsys == (uint32_t)-1) 735 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 736 mapArgsMapsPerVsys[ulCurVsys]["vendor"] = ValueUnion.psz; 737 break; 738 739 case 'D': // --vendorurl 740 if (ulCurVsys == (uint32_t)-1) 741 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 742 mapArgsMapsPerVsys[ulCurVsys]["vendorurl"] = ValueUnion.psz; 743 break; 744 745 case 'v': // --version 746 if (ulCurVsys == (uint32_t)-1) 747 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 748 mapArgsMapsPerVsys[ulCurVsys]["version"] = ValueUnion.psz; 749 break; 750 751 case 'e': // --eula 752 if (ulCurVsys == (uint32_t)-1) 753 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 754 mapArgsMapsPerVsys[ulCurVsys]["eula"] = ValueUnion.psz; 755 break; 756 757 case 'E': // --eulafile 758 if (ulCurVsys == (uint32_t)-1) 759 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Option \"%s\" requires preceding --vsys argument.", GetState.pDef->pszLong); 760 mapArgsMapsPerVsys[ulCurVsys]["eulafile"] = ValueUnion.psz; 649 761 break; 650 762 … … 695 807 return errorSyntax(USAGE_EXPORTAPPLIANCE, "Missing --output argument with export command."); 696 808 809 // match command line arguments with the machines count 810 // this is only to sort out invalid indices at this time 811 ArgsMapsMap::const_iterator it; 812 for (it = mapArgsMapsPerVsys.begin(); 813 it != mapArgsMapsPerVsys.end(); 814 ++it) 815 { 816 uint32_t ulVsys = it->first; 817 if (ulVsys >= llMachines.size()) 818 return errorSyntax(USAGE_EXPORTAPPLIANCE, 819 "Invalid index %RI32 with -vsys option; you specified only %zu virtual system(s).", 820 ulVsys, llMachines.size()); 821 } 822 697 823 ComPtr<IAppliance> pAppliance; 698 824 CHECK_ERROR_BREAK(a->virtualBox, CreateAppliance(pAppliance.asOutParam())); 699 825 700 826 std::list< ComPtr<IMachine> >::iterator itM; 827 uint32_t i=0; 701 828 for (itM = llMachines.begin(); 702 829 itM != llMachines.end(); 703 ++itM )830 ++itM, ++i) 704 831 { 705 832 ComPtr<IMachine> pMachine = *itM; 706 833 ComPtr<IVirtualSystemDescription> pVSD; 707 834 CHECK_ERROR_BREAK(pMachine, Export(pAppliance, pVSD.asOutParam())); 835 // Add additional info to the virtal system description if the user wants so 836 ArgsMap *pmapArgs = NULL; 837 ArgsMapsMap::iterator itm = mapArgsMapsPerVsys.find(i); 838 if (itm != mapArgsMapsPerVsys.end()) 839 pmapArgs = &itm->second; 840 if (pmapArgs) 841 { 842 ArgsMap::iterator itD; 843 for (itD = pmapArgs->begin(); 844 itD != pmapArgs->end(); 845 ++itD) 846 { 847 if (itD->first == "product") 848 pVSD->AddDescription (VirtualSystemDescriptionType_Product, Bstr(itD->second), Bstr(itD->second)); 849 else if (itD->first == "producturl") 850 pVSD->AddDescription (VirtualSystemDescriptionType_ProductUrl, Bstr(itD->second), Bstr(itD->second)); 851 else if (itD->first == "vendor") 852 pVSD->AddDescription (VirtualSystemDescriptionType_Vendor, Bstr(itD->second), Bstr(itD->second)); 853 else if (itD->first == "vendorurl") 854 pVSD->AddDescription (VirtualSystemDescriptionType_VendorUrl, Bstr(itD->second), Bstr(itD->second)); 855 else if (itD->first == "version") 856 pVSD->AddDescription (VirtualSystemDescriptionType_Version, Bstr(itD->second), Bstr(itD->second)); 857 else if (itD->first == "eula") 858 pVSD->AddDescription (VirtualSystemDescriptionType_License, Bstr(itD->second), Bstr(itD->second)); 859 else if (itD->first == "eulafile") 860 { 861 Utf8Str strContent; 862 void *pvFile; 863 size_t cbFile; 864 int rc = RTFileReadAll(itD->second.c_str(), &pvFile, &cbFile); 865 if (RT_SUCCESS(rc)) 866 { 867 Bstr strContent((char*)pvFile); 868 pVSD->AddDescription (VirtualSystemDescriptionType_License, strContent, strContent); 869 RTFileReadAllFree(pvFile, cbFile); 870 } 871 else 872 { 873 RTPrintf("ERROR: Cannot read license file \"%s\" which should be included in the virtual system %u.\n", 874 itD->second.c_str(), 875 i); 876 return 1; 877 } 878 } 879 } 880 } 708 881 } 709 882 … … 713 886 ComPtr<IProgress> progress; 714 887 char *pszAbsFilePath = RTPathAbsDup(strOutputFile.c_str()); 715 CHECK_ERROR_BREAK(pAppliance, Write(Bstr( "ovf-0.9"), Bstr(pszAbsFilePath), progress.asOutParam()));888 CHECK_ERROR_BREAK(pAppliance, Write(Bstr(strOvfFormat), Bstr(pszAbsFilePath), progress.asOutParam())); 716 889 RTStrFree(pszAbsFilePath); 717 890
Note:
See TracChangeset
for help on using the changeset viewer.