X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FUPT.py;h=930a8c1d4cd251bbbcdea57cd621d56e2a0308e5;hb=1b2e077260030290c512f3ac71a044ed1150899f;hp=59c4a88f8efea8141c03cad349f755e95624d415;hpb=452582852dc3654ce51e0c6072aaf752d1b0e3ed;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/UPT/UPT.py
index 59c4a88f8e..930a8c1d4c 100644
--- a/BaseTools/Source/Python/UPT/UPT.py
+++ b/BaseTools/Source/Python/UPT/UPT.py
@@ -1,12 +1,12 @@
## @file
#
-# This file is the main entry for UPT
+# This file is the main entry for UPT
#
-# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -19,8 +19,9 @@ UPT
## import modules
#
-from Core import FileHook
+import locale
import sys
+from Core import FileHook
import os.path
from sys import platform
import platform as pf
@@ -46,6 +47,7 @@ import InstallPkg
import RmPkg
import InventoryWs
import ReplacePkg
+import TestInstall
from Library.Misc import GetWorkspace
from Library import GlobalData
from Core.IpiDb import IpiDatabase
@@ -69,6 +71,9 @@ def CheckConflictOption(Opt):
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_I_R_EXCLUSIVE)
elif Opt.PackFileToCreate and Opt.PackFileToRemove:
Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_C_R_EXCLUSIVE)
+ elif Opt.TestDistFiles and (Opt.PackFileToCreate or Opt.PackFileToInstall \
+ or Opt.PackFileToRemove or Opt.PackFileToReplace):
+ Logger.Error("UPT", OPTION_CONFLICT, ExtraData=ST.ERR_C_R_EXCLUSIVE)
if Opt.CustomPath and Opt.UseGuidedPkgPath:
Logger.Warn("UPT", ST.WARN_CUSTOMPATH_OVERRIDE_USEGUIDEDPATH)
@@ -81,7 +86,7 @@ def SetLogLevel(Opt):
Logger.SetLevel(Logger.VERBOSE)
elif Opt.opt_quiet:
Logger.SetLevel(Logger.QUIET + 1)
- elif Opt.debug_level != None:
+ elif Opt.debug_level is not None:
if Opt.debug_level < 0 or Opt.debug_level > 9:
Logger.Warn("UPT", ST.ERR_DEBUG_LEVEL)
Logger.SetLevel(Logger.INFO)
@@ -111,7 +116,7 @@ def Main():
Parser.add_option("-q", "--quiet", action="store_true", dest="opt_quiet", help=ST.HLP_RETURN_AND_DISPLAY)
- Parser.add_option("-i", "--install", action="store", type="string", dest="Install_Distribution_Package_File",
+ Parser.add_option("-i", "--install", action="append", type="string", dest="Install_Distribution_Package_File",
help=ST.HLP_SPECIFY_PACKAGE_NAME_INSTALL)
Parser.add_option("-c", "--create", action="store", type="string", dest="Create_Distribution_Package_File",
@@ -146,6 +151,9 @@ def Main():
Parser.add_option("--use-guided-paths", action="store_true", dest="Use_Guided_Paths", help=ST.HLP_USE_GUIDED_PATHS)
+ Parser.add_option("-j", "--test-install", action="append", type="string",
+ dest="Test_Install_Distribution_Package_Files", help=ST.HLP_TEST_INSTALL)
+
Opt = Parser.parse_args()[0]
Var2Var = [
@@ -159,6 +167,7 @@ def Main():
("PackFileToReplace", Opt.Replace_Distribution_Package_File),
("PackFileToBeReplaced", Opt.Original_Distribution_Package_File),
("UseGuidedPkgPath", Opt.Use_Guided_Paths),
+ ("TestDistFiles", Opt.Test_Install_Distribution_Package_Files)
]
for Var in Var2Var:
@@ -166,20 +175,21 @@ def Main():
try:
GlobalData.gWORKSPACE, GlobalData.gPACKAGE_PATH = GetWorkspace()
- except FatalError, XExcept:
+ except FatalError as XExcept:
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
return XExcept.args[0]
- # Start *********************************************
# Support WORKSPACE is a long path
- # Only work well on windows
- # Linux Solution TBD
+ # Only works for windows system
if pf.system() == 'Windows':
- os.system('@echo off\nsubst b: /D')
- os.system('subst b: "%s"' % GlobalData.gWORKSPACE)
- GlobalData.gWORKSPACE = 'B:\\'
- # End ***********************************************
+ Vol = 'B:'
+ for Index in range(90, 65, -1):
+ Vol = chr(Index) + ':'
+ if not os.path.isdir(Vol):
+ os.system('subst %s "%s"' % (Vol, GlobalData.gWORKSPACE))
+ break
+ GlobalData.gWORKSPACE = '%s\\' % Vol
WorkspaceDir = GlobalData.gWORKSPACE
@@ -214,12 +224,14 @@ def Main():
RunModule = MkPkg.Main
elif Opt.PackFileToInstall:
- if not Opt.PackFileToInstall.endswith('.dist'):
- Logger.Error("InstallPkg", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Opt.PackFileToInstall)
+ AbsPath = []
+ for Item in Opt.PackFileToInstall:
+ if not Item.endswith('.dist'):
+ Logger.Error("InstallPkg", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Item)
- AbsPath = GetFullPathDist(Opt.PackFileToInstall, WorkspaceDir)
- if not AbsPath:
- Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_INSTALL_DIST_NOT_FOUND % Opt.PackFileToInstall)
+ AbsPath.append(GetFullPathDist(Item, WorkspaceDir))
+ if not AbsPath:
+ Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_INSTALL_DIST_NOT_FOUND % Item)
Opt.PackFileToInstall = AbsPath
setattr(Opt, 'PackageFile', Opt.PackFileToInstall)
@@ -265,12 +277,20 @@ def Main():
Opt.PackFileToReplace = AbsPath
RunModule = ReplacePkg.Main
+ elif Opt.Test_Install_Distribution_Package_Files:
+ for Dist in Opt.Test_Install_Distribution_Package_Files:
+ if not Dist.endswith('.dist'):
+ Logger.Error("TestInstall", FILE_TYPE_MISMATCH, ExtraData=ST.ERR_DIST_EXT_ERROR % Dist)
+
+ setattr(Opt, 'DistFiles', Opt.Test_Install_Distribution_Package_Files)
+ RunModule = TestInstall.Main
+
else:
Parser.print_usage()
return OPTION_MISSING
ReturnCode = RunModule(Opt)
- except FatalError, XExcept:
+ except FatalError as XExcept:
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \
@@ -285,11 +305,12 @@ def Main():
else:
GlobalData.gDB.Commit()
Mgr.commit()
- except StandardError:
+ except Exception:
Logger.Quiet(ST.MSG_RECOVER_FAIL)
GlobalData.gDB.CloseDb()
+
if pf.system() == 'Windows':
- os.system('subst b: /D')
+ os.system('subst %s /D' % GlobalData.gWORKSPACE.replace('\\', ''))
return ReturnCode