From nobody Mon Nov 25 03:44:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+78282+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78282+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1627472732; cv=none; d=zohomail.com; s=zohoarc; b=Qb9dQ+Ygw+VvzdOva2YO/YI0GdC/Eglyau9NpFXudvYdmmLpA7SPVlzyQ00MMqBIgJE886qoNcUGR1WQxyi2XYLp20Ly+BD4YtnHqqvM6zjiwquhffda+HuL5PsXnbQkrxVK0GcLuRVy3ZcU0wj4+NggansTrPRHreTWdr6DlZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627472732; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=TvUSx/ZvQBaa0lywxv+gTBKvfowweEA7KOdeMKzfGPo=; b=fkvb6KPYm75kJhT62CnW2OLap8qOGWWOLa1A1KYDv4HJ5hD/Lrb76UP664gA0Y5EfVo75larKvLXj1HBykmPe/8hTt21QX2AUrk07o1f+ZE/z1GfLviuC8JdxnaeQvudD1Vw6PX7P6Lu/3OzxOry4X0zHUq3ve5xISU4sXxL4L0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78282+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16274727320461023.7345339975408; Wed, 28 Jul 2021 04:45:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6tpWYY1788612xnrHzr1BODI; Wed, 28 Jul 2021 04:45:31 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.3662.1627472731044636611 for ; Wed, 28 Jul 2021 04:45:31 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10058"; a="212372626" X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="212372626" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 04:45:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,276,1620716400"; d="scan'208";a="580708616" X-Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.137]) by fmsmga001.fm.intel.com with ESMTP; 28 Jul 2021 04:45:29 -0700 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Yuwei Chen Subject: [edk2-devel] [Patch] BaseTools: use shutil.copyfile instead shutil.copy2 Date: Wed, 28 Jul 2021 19:45:23 +0800 Message-Id: <20210728114523.687-1-bob.c.feng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,bob.c.feng@intel.com X-Gm-Message-State: 6PucucrbTa5rIOlpMjPwBBMIx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1627472731; bh=YW5OcaCNcBI0maXOybup5XEcpzfYRkcmaqOry1eMTyE=; h=Cc:Date:From:Reply-To:Subject:To; b=NNeEYOa5P/3YECAMbHf2vB+Aiia1s9adfpjWUpDPtHijcHDX0A9YP6FYB7SuEc5l6yV ts0NejdUOlmXlgh9tCcm9/BxqF0crhasHXEKWpZ0tesNQG4B79XtzAJxdTbk9/+1FhqK8 m8ngrvXfb9L1Gf7a8cZP1C92EGQvFTasETs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1627472733607100001 Content-Type: text/plain; charset="utf-8" In Split tool, the copy file actions only need to copy file content but not need to copy file metadata. copy2() copies the file metadata that causes split unit test failed under edk2-basetools CI environment. So this patch changes the call of copy2() to copyfile(). Signed-off-by: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Reviewed-by: Philippe Mathieu-Daude Reviewed-by: Yuwei Chen --- BaseTools/Source/Python/Split/Split.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Split/Split.py b/BaseTools/Source/Pyth= on/Split/Split.py index e223a72a94..e70d5c22c4 100644 --- a/BaseTools/Source/Python/Split/Split.py +++ b/BaseTools/Source/Python/Split/Split.py @@ -146,18 +146,18 @@ def splitFile(inputfile, position, outputdir=3DNone, = outputfile1=3DNone, outputfile2 logger.error("Can't make dir: %s" % outputfolder) raise(e) =20 if position <=3D 0: if outputfile2 !=3D os.path.abspath(inputfile): - shutil.copy2(os.path.abspath(inputfile), outputfile2) + shutil.copyfile(os.path.abspath(inputfile), outputfile2) with open(outputfile1, "wb") as fout: fout.write(b'') else: inputfilesize =3D getFileSize(inputfile) if position >=3D inputfilesize: if outputfile1 !=3D os.path.abspath(inputfile): - shutil.copy2(os.path.abspath(inputfile), outputfile1) + shutil.copyfile(os.path.abspath(inputfile), outputfile1) with open(outputfile2, "wb") as fout: fout.write(b'') else: try: tempdir =3D tempfile.mkdtemp() @@ -169,12 +169,12 @@ def splitFile(inputfile, position, outputdir=3DNone, = outputfile1=3DNone, outputfile2 fout1.write(content1) =20 content2 =3D fin.read(inputfilesize - position) with open(tempfile2, "wb") as fout2: fout2.write(content2) - shutil.copy2(tempfile1, outputfile1) - shutil.copy2(tempfile2, outputfile2) + shutil.copyfile(tempfile1, outputfile1) + shutil.copyfile(tempfile2, outputfile2) except Exception as e: logger.error("Split file failed") raise(e) finally: if os.path.exists(tempdir): --=20 2.29.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#78282): https://edk2.groups.io/g/devel/message/78282 Mute This Topic: https://groups.io/mt/84503147/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-