public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules
@ 2020-02-12  6:24 Gary Lin
  2020-02-12  6:24 ` [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions Gary Lin
  2020-02-12  6:31 ` [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Sun, Zailiang
  0 siblings, 2 replies; 5+ messages in thread
From: Gary Lin @ 2020-02-12  6:24 UTC (permalink / raw)
  To: devel; +Cc: Zailiang Sun, Yi Qian

The cab file previously contained the unsigned payload without the FMP
header, so the firmware would reject the capsule generated by fwupd
based on the cab file. This commit copies the signed capsule into the
cab file so that fwupd can generate a valid capsule.

Cc: Zailiang Sun <zailiang.sun@intel.com>
cc: Yi Qian <yi.qian@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 .../Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
index a37648ac96..1a6c597c4a 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
+++ b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
@@ -181,7 +181,7 @@ def GenCapsuleDevice (BaseName, PayloadFileName, Guid, Version, Lsv, CapsulesPat
         LogAlways (ProcessOutput[0].decode())
         Error ('GenerateCapsule returned an error')
 
-    Copy (PayloadFileName, (CapsulesPath, 'firmware.bin'))
+    Copy (FmpCapsuleFile, (CapsulesPath, 'firmware.bin'))
     MetaInfoXml = MetaInfoXmlTemplate
     MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_GUID', Guid)
     MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_BASE_NAME', BaseName)
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions
  2020-02-12  6:24 [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Gary Lin
@ 2020-02-12  6:24 ` Gary Lin
  2020-02-12  6:33   ` Sun, Zailiang
  2020-02-12  6:31 ` [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Sun, Zailiang
  1 sibling, 1 reply; 5+ messages in thread
From: Gary Lin @ 2020-02-12  6:24 UTC (permalink / raw)
  To: devel; +Cc: Zailiang Sun, Yi Qian

Clean up the script.

Cc: Zailiang Sun <zailiang.sun@intel.com>
cc: Yi Qian <yi.qian@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py | 97 ----------------------------
 1 file changed, 97 deletions(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py b/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
index 220515c809..be1d23560e 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
@@ -59,108 +59,12 @@ def NormalizePath(target):
     else:
         return os.path.normpath (target)
 
-def RemoveFile(target):
-    target = NormalizePath(target)
-    if not target or target == os.pathsep:
-        Error ('RemoveFile() invalid target')
-    if os.path.exists(target):
-        os.remove (target)
-        Log ('remove %s' % (RelativePath (target)))
-
-def RemoveDirectory(target):
-    target = NormalizePath(target)
-    if not target or target == os.pathsep:
-        Error ('RemoveDirectory() invalid target')
-    if os.path.exists(target):
-        Log ('rmdir %s' % (RelativePath (target)))
-        shutil.rmtree(target)
-
 def CreateDirectory(target):
     target = NormalizePath(target)
     if not os.path.exists(target):
         Log ('mkdir %s' % (RelativePath (target)))
         os.makedirs (target)
 
-def Copy(src, dst):
-    src = NormalizePath(src)
-    dst = NormalizePath(dst)
-    for File in glob.glob(src):
-        Log ('copy %s -> %s' % (RelativePath (File), RelativePath (dst)))
-        shutil.copy (File, dst)
-
-def GenCapsuleDevice (BaseName, PayloadFileName, Guid, Version, Lsv, CapsulesPath, CapsulesSubDir):
-    global gBaseToolsPath
-    LogAlways ('Generate Capsule: {0} {1:08x} {2:08x} {3}'.format (Guid, Version, Lsv, PayloadFileName))
-
-    VersionString = '.'.join([str(ord(x)) for x in struct.pack('>I', Version).decode()])
-
-    FmpCapsuleFile = NormalizePath ((CapsulesPath, CapsulesSubDir, BaseName + '.' + VersionString + '.cap'))
-    Command = GenerateCapsuleCommand.format (
-                FMP_CAPSULE_GUID    = Guid,
-                FMP_CAPSULE_VERSION = Version,
-                FMP_CAPSULE_LSV     = Lsv,
-                BASE_TOOLS_PATH     = gBaseToolsPath,
-                FMP_CAPSULE_FILE    = FmpCapsuleFile,
-                FMP_CAPSULE_PAYLOAD = PayloadFileName
-                )
-    Command = ' '.join(Command.splitlines()).strip()
-    if gArgs.Verbose:
-        Command = Command + ' -v'
-
-    Log (Command)
-
-    Process = subprocess.Popen(Command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    ProcessOutput = Process.communicate()
-
-    if Process.returncode == 0:
-        Log (ProcessOutput[0].decode())
-    else:
-        LogAlways (Command)
-        LogAlways (ProcessOutput[0].decode())
-        Error ('GenerateCapsule returned an error')
-
-    Copy (PayloadFileName, (CapsulesPath, 'firmware.bin'))
-    MetaInfoXml = MetaInfoXmlTemplate
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_GUID', Guid)
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_BASE_NAME', BaseName)
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_VERSION_DECIMAL', str(Version))
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_STRING', VersionString)
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_DATE', str(datetime.date.today()))
-    f = open (NormalizePath ((CapsulesPath, 'firmware.metainfo.xml')), 'w')
-    f.write(MetaInfoXml)
-    f.close()
-
-    f = open (NormalizePath ((CapsulesPath, 'Lvfs.ddf')), 'w')
-    f.write(LvfsDdfTemplate)
-    f.close()
-
-    if sys.platform == "win32":
-        Command = 'makecab /f ' + NormalizePath ((CapsulesPath, 'Lvfs.ddf'))
-    else:
-        Command = 'gcab --create firmware.cab firmware.bin firmware.metainfo.xml'
-    Log (Command)
-
-    Process = subprocess.Popen(Command, cwd=CapsulesPath, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    ProcessOutput = Process.communicate()
-
-    if Process.returncode == 0:
-        Log (ProcessOutput[0].decode())
-    else:
-        LogAlways (Command)
-        LogAlways (ProcessOutput[0].decode())
-        Error ('GenerateCapsule returned an error')
-
-    FmpCabinetFile = NormalizePath ((CapsulesPath, CapsulesSubDir, BaseName + '.' + VersionString + '.cab'))
-
-    Copy ((CapsulesPath, 'firmware.cab'), FmpCabinetFile)
-
-    RemoveFile ((CapsulesPath, 'firmware.cab'))
-    RemoveFile ((CapsulesPath, 'setup.inf'))
-    RemoveFile ((CapsulesPath, 'setup.rpt'))
-    RemoveFile ((CapsulesPath, 'Lvfs.ddf'))
-    RemoveFile ((CapsulesPath, 'firmware.metainfo.xml'))
-    RemoveFile ((CapsulesPath, 'firmware.bin'))
-
 BiosIdTemplate = '''
 BOARD_ID       = MNW2MAX
 BOARD_REV      = $BOARD_REV
@@ -170,7 +74,6 @@ BUILD_TYPE     = $BUILD_TYPE
 VERSION_MINOR  = 01
 '''
 
-
 if __name__ == '__main__':
     #
     # Create command line argument parser object
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules
  2020-02-12  6:24 [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Gary Lin
  2020-02-12  6:24 ` [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions Gary Lin
@ 2020-02-12  6:31 ` Sun, Zailiang
  2020-02-12  6:41   ` [edk2-devel] " Gary Lin
  1 sibling, 1 reply; 5+ messages in thread
From: Sun, Zailiang @ 2020-02-12  6:31 UTC (permalink / raw)
  To: Gary Lin, devel@edk2.groups.io; +Cc: Qian, Yi

Hi Lin,

Next time you might need have Mike Kinney in the cc list:)

Reviewed-by: Zailiang Sun <Zailiang.sun@intel.com>

-----Original Message-----
From: Gary Lin <glin@suse.com> 
Sent: Wednesday, February 12, 2020 2:24 PM
To: devel@edk2.groups.io
Cc: Sun, Zailiang <zailiang.sun@intel.com>; Qian, Yi <yi.qian@intel.com>
Subject: [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules

The cab file previously contained the unsigned payload without the FMP
header, so the firmware would reject the capsule generated by fwupd
based on the cab file. This commit copies the signed capsule into the
cab file so that fwupd can generate a valid capsule.

Cc: Zailiang Sun <zailiang.sun@intel.com>
cc: Yi Qian <yi.qian@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 .../Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
index a37648ac96..1a6c597c4a 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
+++ b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
@@ -181,7 +181,7 @@ def GenCapsuleDevice (BaseName, PayloadFileName, Guid, Version, Lsv, CapsulesPat
         LogAlways (ProcessOutput[0].decode())
         Error ('GenerateCapsule returned an error')
 
-    Copy (PayloadFileName, (CapsulesPath, 'firmware.bin'))
+    Copy (FmpCapsuleFile, (CapsulesPath, 'firmware.bin'))
     MetaInfoXml = MetaInfoXmlTemplate
     MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_GUID', Guid)
     MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_BASE_NAME', BaseName)
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions
  2020-02-12  6:24 ` [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions Gary Lin
@ 2020-02-12  6:33   ` Sun, Zailiang
  0 siblings, 0 replies; 5+ messages in thread
From: Sun, Zailiang @ 2020-02-12  6:33 UTC (permalink / raw)
  To: Gary Lin, devel@edk2.groups.io; +Cc: Qian, Yi

Reviewed-by: Zailiang Sun <Zailiang.sun@intel.com>

-----Original Message-----
From: Gary Lin <glin@suse.com> 
Sent: Wednesday, February 12, 2020 2:24 PM
To: devel@edk2.groups.io
Cc: Sun, Zailiang <zailiang.sun@intel.com>; Qian, Yi <yi.qian@intel.com>
Subject: [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions

Clean up the script.

Cc: Zailiang Sun <zailiang.sun@intel.com>
cc: Yi Qian <yi.qian@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py | 97 ----------------------------
 1 file changed, 97 deletions(-)

diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py b/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
index 220515c809..be1d23560e 100644
--- a/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
+++ b/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py
@@ -59,108 +59,12 @@ def NormalizePath(target):
     else:
         return os.path.normpath (target)
 
-def RemoveFile(target):
-    target = NormalizePath(target)
-    if not target or target == os.pathsep:
-        Error ('RemoveFile() invalid target')
-    if os.path.exists(target):
-        os.remove (target)
-        Log ('remove %s' % (RelativePath (target)))
-
-def RemoveDirectory(target):
-    target = NormalizePath(target)
-    if not target or target == os.pathsep:
-        Error ('RemoveDirectory() invalid target')
-    if os.path.exists(target):
-        Log ('rmdir %s' % (RelativePath (target)))
-        shutil.rmtree(target)
-
 def CreateDirectory(target):
     target = NormalizePath(target)
     if not os.path.exists(target):
         Log ('mkdir %s' % (RelativePath (target)))
         os.makedirs (target)
 
-def Copy(src, dst):
-    src = NormalizePath(src)
-    dst = NormalizePath(dst)
-    for File in glob.glob(src):
-        Log ('copy %s -> %s' % (RelativePath (File), RelativePath (dst)))
-        shutil.copy (File, dst)
-
-def GenCapsuleDevice (BaseName, PayloadFileName, Guid, Version, Lsv, CapsulesPath, CapsulesSubDir):
-    global gBaseToolsPath
-    LogAlways ('Generate Capsule: {0} {1:08x} {2:08x} {3}'.format (Guid, Version, Lsv, PayloadFileName))
-
-    VersionString = '.'.join([str(ord(x)) for x in struct.pack('>I', Version).decode()])
-
-    FmpCapsuleFile = NormalizePath ((CapsulesPath, CapsulesSubDir, BaseName + '.' + VersionString + '.cap'))
-    Command = GenerateCapsuleCommand.format (
-                FMP_CAPSULE_GUID    = Guid,
-                FMP_CAPSULE_VERSION = Version,
-                FMP_CAPSULE_LSV     = Lsv,
-                BASE_TOOLS_PATH     = gBaseToolsPath,
-                FMP_CAPSULE_FILE    = FmpCapsuleFile,
-                FMP_CAPSULE_PAYLOAD = PayloadFileName
-                )
-    Command = ' '.join(Command.splitlines()).strip()
-    if gArgs.Verbose:
-        Command = Command + ' -v'
-
-    Log (Command)
-
-    Process = subprocess.Popen(Command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    ProcessOutput = Process.communicate()
-
-    if Process.returncode == 0:
-        Log (ProcessOutput[0].decode())
-    else:
-        LogAlways (Command)
-        LogAlways (ProcessOutput[0].decode())
-        Error ('GenerateCapsule returned an error')
-
-    Copy (PayloadFileName, (CapsulesPath, 'firmware.bin'))
-    MetaInfoXml = MetaInfoXmlTemplate
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_GUID', Guid)
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_BASE_NAME', BaseName)
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_VERSION_DECIMAL', str(Version))
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_STRING', VersionString)
-    MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_DATE', str(datetime.date.today()))
-    f = open (NormalizePath ((CapsulesPath, 'firmware.metainfo.xml')), 'w')
-    f.write(MetaInfoXml)
-    f.close()
-
-    f = open (NormalizePath ((CapsulesPath, 'Lvfs.ddf')), 'w')
-    f.write(LvfsDdfTemplate)
-    f.close()
-
-    if sys.platform == "win32":
-        Command = 'makecab /f ' + NormalizePath ((CapsulesPath, 'Lvfs.ddf'))
-    else:
-        Command = 'gcab --create firmware.cab firmware.bin firmware.metainfo.xml'
-    Log (Command)
-
-    Process = subprocess.Popen(Command, cwd=CapsulesPath, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    ProcessOutput = Process.communicate()
-
-    if Process.returncode == 0:
-        Log (ProcessOutput[0].decode())
-    else:
-        LogAlways (Command)
-        LogAlways (ProcessOutput[0].decode())
-        Error ('GenerateCapsule returned an error')
-
-    FmpCabinetFile = NormalizePath ((CapsulesPath, CapsulesSubDir, BaseName + '.' + VersionString + '.cab'))
-
-    Copy ((CapsulesPath, 'firmware.cab'), FmpCabinetFile)
-
-    RemoveFile ((CapsulesPath, 'firmware.cab'))
-    RemoveFile ((CapsulesPath, 'setup.inf'))
-    RemoveFile ((CapsulesPath, 'setup.rpt'))
-    RemoveFile ((CapsulesPath, 'Lvfs.ddf'))
-    RemoveFile ((CapsulesPath, 'firmware.metainfo.xml'))
-    RemoveFile ((CapsulesPath, 'firmware.bin'))
-
 BiosIdTemplate = '''
 BOARD_ID       = MNW2MAX
 BOARD_REV      = $BOARD_REV
@@ -170,7 +74,6 @@ BUILD_TYPE     = $BUILD_TYPE
 VERSION_MINOR  = 01
 '''
 
-
 if __name__ == '__main__':
     #
     # Create command line argument parser object
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules
  2020-02-12  6:31 ` [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Sun, Zailiang
@ 2020-02-12  6:41   ` Gary Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Gary Lin @ 2020-02-12  6:41 UTC (permalink / raw)
  To: devel, zailiang.sun; +Cc: Qian, Yi

On Wed, Feb 12, 2020 at 06:31:46AM +0000, Sun, Zailiang wrote:
> Hi Lin,
> 
> Next time you might need have Mike Kinney in the cc list:)
> 
Ok, will do that if I have patches for Vlv2TbltDevicePkg.

Thanks,

Gary Lin

> Reviewed-by: Zailiang Sun <Zailiang.sun@intel.com>
> 
> -----Original Message-----
> From: Gary Lin <glin@suse.com> 
> Sent: Wednesday, February 12, 2020 2:24 PM
> To: devel@edk2.groups.io
> Cc: Sun, Zailiang <zailiang.sun@intel.com>; Qian, Yi <yi.qian@intel.com>
> Subject: [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules
> 
> The cab file previously contained the unsigned payload without the FMP
> header, so the firmware would reject the capsule generated by fwupd
> based on the cab file. This commit copies the signed capsule into the
> cab file so that fwupd can generate a valid capsule.
> 
> Cc: Zailiang Sun <zailiang.sun@intel.com>
> cc: Yi Qian <yi.qian@intel.com>
> Signed-off-by: Gary Lin <glin@suse.com>
> ---
>  .../Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py  | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
> index a37648ac96..1a6c597c4a 100644
> --- a/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
> +++ b/Platform/Intel/Vlv2TbltDevicePkg/Feature/Capsule/GenerateCapsule/GenCapsuleAll.py
> @@ -181,7 +181,7 @@ def GenCapsuleDevice (BaseName, PayloadFileName, Guid, Version, Lsv, CapsulesPat
>          LogAlways (ProcessOutput[0].decode())
>          Error ('GenerateCapsule returned an error')
>  
> -    Copy (PayloadFileName, (CapsulesPath, 'firmware.bin'))
> +    Copy (FmpCapsuleFile, (CapsulesPath, 'firmware.bin'))
>      MetaInfoXml = MetaInfoXmlTemplate
>      MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_GUID', Guid)
>      MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_BASE_NAME', BaseName)
> -- 
> 2.16.4
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-12  6:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-12  6:24 [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Gary Lin
2020-02-12  6:24 ` [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions Gary Lin
2020-02-12  6:33   ` Sun, Zailiang
2020-02-12  6:31 ` [PATCH 1/2] Vlv2TbltDevicePkg/GenerateCapsule: Create cab files with signed capsules Sun, Zailiang
2020-02-12  6:41   ` [edk2-devel] " Gary Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox