From 8ce3073beed9b1848187fdfa0f2e4701ccceb324 Mon Sep 17 00:00:00 2001 From: Haofan Zheng Date: Wed, 10 May 2023 18:55:04 -0700 Subject: [PATCH] Fixed file path in patch files --- libs/GenPatchFiles.py | 19 ++++++++++++++++++- libs/asn1-decode/Asn1Decode.patch | 4 ++-- libs/ens-contracts/BytesUtils.patch | 4 ++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libs/GenPatchFiles.py b/libs/GenPatchFiles.py index b6f9c73..190e219 100644 --- a/libs/GenPatchFiles.py +++ b/libs/GenPatchFiles.py @@ -12,6 +12,7 @@ import json import os import requests +import subprocess LIBS_DIR_PATH = os.path.dirname(os.path.abspath(__file__)) @@ -30,6 +31,7 @@ def _GenPatchForSingleFile(destFile: str, srcFile: str, verTag: str): destBaseFile, ext = os.path.splitext(destFile) tmpFile = destBaseFile + '.' + verTag + ext patchFile = destBaseFile + '.patch' + destDir = os.path.dirname(destFile) # print(tmpFile, '^', destFile, '->', patchFile) if os.path.exists(patchFile): @@ -55,7 +57,22 @@ def _GenPatchForSingleFile(destFile: str, srcFile: str, verTag: str): hashlib.sha256(resp.content).digest() ): # generate patch file if content is different - os.system('diff -u {} {} > {}'.format(tmpFile, destFile, patchFile)) + proc = subprocess.Popen( + [ + 'diff', + '-u', + os.path.basename(tmpFile), + os.path.basename(destFile) + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=destDir, + ) + stdout, stderr = proc.communicate() + # if proc.returncode != 0: + # raise RuntimeError('Failed to generate patch file: {}'.format(stderr)) + with open(patchFile, 'wb') as f: + f.write(stdout) # remove tmp file os.remove(tmpFile) diff --git a/libs/asn1-decode/Asn1Decode.patch b/libs/asn1-decode/Asn1Decode.patch index 11585e6..81af341 100644 --- a/libs/asn1-decode/Asn1Decode.patch +++ b/libs/asn1-decode/Asn1Decode.patch @@ -1,5 +1,5 @@ ---- /home/ubuntu/codelab/decent-ra-onchain/libs/asn1-decode/Asn1Decode.5c2d1469fc678513753786acb441e597969192ec.sol 2023-05-10 18:15:17.534744080 -0700 -+++ /home/ubuntu/codelab/decent-ra-onchain/libs/asn1-decode/Asn1Decode.sol 2023-05-10 18:14:14.998486467 -0700 +--- Asn1Decode.5c2d1469fc678513753786acb441e597969192ec.sol 2023-05-10 18:54:03.224133752 -0700 ++++ Asn1Decode.sol 2023-05-10 18:14:14.998486467 -0700 @@ -1,6 +1,7 @@ -pragma solidity ^0.5.2; +// SPDX-License-Identifier: MIT diff --git a/libs/ens-contracts/BytesUtils.patch b/libs/ens-contracts/BytesUtils.patch index 4925c43..86245c3 100644 --- a/libs/ens-contracts/BytesUtils.patch +++ b/libs/ens-contracts/BytesUtils.patch @@ -1,5 +1,5 @@ ---- /home/ubuntu/codelab/decent-ra-onchain/libs/ens-contracts/BytesUtils.883a0a2d64d07df54f3ebbb0e81cf2e9d012c14d.sol 2023-05-10 17:58:27.981281430 -0700 -+++ /home/ubuntu/codelab/decent-ra-onchain/libs/ens-contracts/BytesUtils.sol 2023-05-08 02:38:06.477673524 -0700 +--- BytesUtils.883a0a2d64d07df54f3ebbb0e81cf2e9d012c14d.sol 2023-05-10 18:54:02.896132917 -0700 ++++ BytesUtils.sol 2023-05-08 02:38:06.477673524 -0700 @@ -1,4 +1,5 @@ -pragma solidity ^0.8.4; +// SPDX-License-Identifier: MIT