From patchwork Mon Sep 7 08:20:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijai Kumar K X-Patchwork-Id: 38 Return-Path: Delivered-To: ilbers.mnt@gmail.com Received: by 2002:a4a:eb04:0:0:0:0:0 with SMTP id f4csp3467793ooj; Mon, 7 Sep 2020 09:20:40 -0700 (PDT) X-Received: by 2002:a17:907:213b:: with SMTP id qo27mr21075529ejb.441.1599495640387; Mon, 07 Sep 2020 09:20:40 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1599495640; cv=pass; d=google.com; s=arc-20160816; b=tQ6CrwpwMyWa5JeftAT5mIMVzdHilDGZDhqjmeWrPuUBdGnPfJdTkcdF8grM+UKh46 DQyGhFO6VeBWbtrIHid35faaE6xKHse8i5mNpeeTibjrwEyVtQMHpVAZzR+qICpetDXZ sy/xLra1hiQF6PhfVyB+rknSW8uuQYLqlzjCXBcbT7OiG8hOpoWnN5zchVDDOvslYJIB 87ZA4+nAJ2IQrD7Ol0MfA3BjVvgkJRAkUA/ZiOw2BKfSJvCp0V+E1C10o80cSjf57oSV C7DGTKJhsbJEGJtntM54fVmvNg12bvTeeQUuJtrK7sVqnfrYSUfpKt/DJ1g2FlUpkRZD pnkg== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:ironport-sdr:ironport-sdr:sender :dkim-signature; bh=0g1RsucR9EI0CpKrWCPiFBM56S7JKlyOCvIG2NcfVhw=; b=IPWJVi9IHsgGH9+2snsGRjATylAULZtSae0D7bAPyMPAAwFCofX5+TKknQv6JL9PCN Ls+HTAnJq1aOXwfD7MYSmuYyMK4Sra5+JgjhfqyjAXR7FtEJS/tNijIVrwfYlK83VRpU LKXR6QKUTzDL9mHd9csGcx2aWc6S+s8e6VQAk5FQ4cIFd1FRGPUOpJIhiquTjfhgZD8m xTEyOKQcY7j0dHXLk3/mEJtA3r8VktBgHhFQLPTQ38i3iKfiSN4eG3UX+cFgq7Lhn+5I GwkHcyhtKgCe4reWURfEtcHTUuaRZECY/gIdnH0PsEgp18IcYDHVfPU0ls1kNK10emkw g+KA== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=UFzUwIcZ; arc=pass (i=2 spf=pass spfdomain=mentor.com); spf=pass (google.com: domain of isar-users+bncbcwp7lf37ukrbv533h5akgqeiq2fwya@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCWP7LF37UKRBV533H5AKGQEIQ2FWYA@googlegroups.com Received: from mail-sor-f55.google.com (mail-sor-f55.google.com. [209.85.220.55]) by mx.google.com with SMTPS id u11sor8791125ejy.31.2020.09.07.09.20.40 (Google Transport Security); Mon, 07 Sep 2020 09:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of isar-users+bncbcwp7lf37ukrbv533h5akgqeiq2fwya@googlegroups.com designates 209.85.220.55 as permitted sender) client-ip=209.85.220.55; Authentication-Results: mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=UFzUwIcZ; arc=pass (i=2 spf=pass spfdomain=mentor.com); spf=pass (google.com: domain of isar-users+bncbcwp7lf37ukrbv533h5akgqeiq2fwya@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCWP7LF37UKRBV533H5AKGQEIQ2FWYA@googlegroups.com ARC-Seal: i=2; a=rsa-sha256; t=1599495640; cv=pass; d=google.com; s=arc-20160816; b=C5V88bamWmLdQhxNkKFzILjrL+1qaSL6Mr4D+Xe2kX+0B4UlOW3Y90ErV9jY8cUYAR v0FSg36N0M4kT7oNWflsB0AZ2Y5ziOzkR9MDcQeypWWbS7g9T0gBFaFTA+gHUHHe4ZIV fASxx47i4Aga+4GZtQPgLQ76qCbrI88wORMsRZM4j8gdCCkdW6HFw3TQ7WGEIpq2KxwT voh912J8K9Ys0Cam56Um62yWuyjnSpOlesJ98Z/wUfvtZi9g5QMq50Uw4s5cWJRQ1GJa lmPysyR4dfRYsquDYi+ZwqWm8gXmP2+/0JLc+acc5ISuIPvcDl+MI5sJ2YjzZ+6Q/ywb pfug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:to:from:ironport-sdr:ironport-sdr:sender :dkim-signature; bh=0g1RsucR9EI0CpKrWCPiFBM56S7JKlyOCvIG2NcfVhw=; b=wSTNMgoiphTRiRr5f8LGnaJPuxt33BRIaEk4cE9TuECXNeMMzv47wPltXP1Zp23W1s lXD+Z8IKVfsXYWF85pbhEqWUXIEHoYx9li4A03Vp4RlVChDDKlQhSMZLePtoN+fmFNvb JZw4HCPJQI12xjDfcCr17WFHLfRPbBa42/6/+LGxpPnOxZS2BRZ0nKVzFt4l6y7jJk0F nQ/qBbIgREVSdT6VpTrjfC6Bh5dFyrVfGYnE5sMJIG+JLnSK6eChRLzo16qPSbhT+GOC g7Qq8H+UUusFkv1kY/+fiue9s4MHnWtNZdJSn4xpmKl6eg2Cpx8/b90XXdy+9x+bwXO9 DJGw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.137.252 as permitted sender) smtp.mailfrom=Vijaikumar_Kanagarajan@mentor.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:ironport-sdr:ironport-sdr:from:to:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=0g1RsucR9EI0CpKrWCPiFBM56S7JKlyOCvIG2NcfVhw=; b=UFzUwIcZZUC1C6x11i1qJzy0tzWA6BUF6hIxEEZR6QClETgb6XQ1JIwbeBV2Ur39uS NHtlkSoGBZ0aEktPzYXkGdaKhOzmPn7birIAh8TJr319kIWb0yGV7fHJlPo5A6Zh3vZq gPNxuroacf9Fw7ZyYQmUeMs6y2hgpHigXFh8QGAsgRiQduy+vzk//cr+EP+kX1MvB3Eu vGW8kpIXsU7cJjNmAGdDK/h7tIjfdRB00VoJzHVZ7HFEDrJdaKVV0iJK7Z1R+eYEh3m/ Ui1cRJOS5PHky5RKJ+YylaJJy7hD0R0cz68X250o8Pvdo+PQAPixMTObFY2nYdS3zO1P SBBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:ironport-sdr:ironport-sdr:from:to:subject :date:message-id:in-reply-to:references:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=0g1RsucR9EI0CpKrWCPiFBM56S7JKlyOCvIG2NcfVhw=; b=sRIGthw/85UQdcAq57q58eHxaA9QWYI9fYcqwdt2jdxKkbcJlmpK38q+F+d9MSTjKF 3xWS7XjTg9SlsSh9Fzr0DWPryReqWk/IDvknhHTdOXaOud8WtEp85TCDOxmmfTB8tLd5 P/t5+vbzgqrzfX6qlKaIQl1+SZS/sPdsorvhcV5NvyAwt+qJxZ+JwizxiM5XpHf7FT1u 74Q0DbKoPl9JHaLMiSsKS8ikOS5pqGRveIQ0kcPwb7EctYg85TkvHrBGsEGslxC4Lb0t T2y2dW4IC+xYnlQSsHqyDHBk+XOTWXnuzGK+QMRFA0Ef560LL/akJNWiBzG2vprWMJmy s5pg== Sender: isar-users@googlegroups.com X-Gm-Message-State: AOAM533bO3zzEvmSE1OCiV0QGYoEm/eu6/upCpnEeIehlDzmzn8EYFcW kPePkMGqKDTiLagBesX5sx4= X-Google-Smtp-Source: ABdhPJy1ZV6r5r8QVOBfgP8nVZ65RELpX6Zu5J+aJIh7URhJ3J6kb3KCKFgBilfZZRNhVJEOcfRsZQ== X-Received: by 2002:a17:906:2b97:: with SMTP id m23mr22218106ejg.61.1599495640111; Mon, 07 Sep 2020 09:20:40 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:bc05:: with SMTP id j5ls233246edh.0.gmail; Mon, 07 Sep 2020 09:20:39 -0700 (PDT) X-Received: by 2002:aa7:c70a:: with SMTP id i10mr22865029edq.218.1599495639027; Mon, 07 Sep 2020 09:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599495639; cv=none; d=google.com; s=arc-20160816; b=ufr07Q2p9YWVHQWg5NsH2yBwxX/9Lo+pVaNidmuJFUt/4gzWNS7H14h1it+Rm0+8ND 5etrWm3dgKyC5k8dI6CNDTjS4dFP3AE6AH24hxgS25V4Wv51YF78u+XJU1kWrYq2x0aG 4wLgtOlQLLdjU/qteytWEoQv1OdLsSfPWxKpE1VIWou73Y/XJYeadqO4aIhJEJ1DWcIJ fkSrY5KXHwXr/ADhQdeQknbOPUFxThtvV365liI+NesgJxayIk3dsVQKRSbRqfKXXctV mneacR1qwilXsVgGztj/18AvvvTKlpkGRzNYZ5FAQ/Dp/O91ad7DFRXXTPkRo+hHjQvb IrUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:to:from :ironport-sdr:ironport-sdr; bh=44YMmy8he/Krw5pKz6mdxmyPNemXWdNAzenOwLm4qaM=; b=DHtH720mMp7SV0++xcnRIFPC6CMD0VTkY8lKZVCmbWDNLOur9wQOPgqUI9uA4PEGjY LQ0aOycpyBC1zy2mhMOpn8M+LG8rVKbGh868zFLPNxaQeWG/4OMXCA6VW6ksntIx93T+ Y6dOM59iWmMDk16wbjbu0rfsan2QJvEXuwtEfnCUxqIblnM38G0ju2+0EhNlMZqyTIXy tKGbSrNupolGj8B3CyFt4Dl26kQ+ac16hANcSumRgan32JPz9opnB9671i8Yp8ED9J1A 6FS//CPBCuPEViR4jmsMLn2wft2/8PyVyCZAjbcY1kuE8hia0Gl1hsQeHcyVVbtLFNK/ aqaA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.137.252 as permitted sender) smtp.mailfrom=Vijaikumar_Kanagarajan@mentor.com Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com. [68.232.137.252]) by gmr-mx.google.com with ESMTPS id w16si466474edq.4.2020.09.07.09.20.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 09:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.137.252 as permitted sender) client-ip=68.232.137.252; IronPort-SDR: HQxldEcWFrMXBBP4smlSOznEF5Gxtxbl/JRwcQpOHLxl4Or/Lbf9QzpeXw7arxfbqANF9Wcm4v E/KqmouLuaFLblII6Q5TSWsZ5zQzrmxdoZF65D+qA8x+EfT/7m+MGuGdn4mW+d+aDzjyYu1ix7 Y/QWXwSzm3WJjGzlm8Nw9L6deLxnA60qJhRPJtcgYZUzaGYXCpUG/6Ui51K0PvNcRC1xjeN16r tQBthMMjzoF12rvzkr2Zx4Qu2FznPy7wdBYqD8mMWOy9WNxUsIQZtjqT7BG21yHD0xXHpQCJ7d WHM= X-IronPort-AV: E=Sophos;i="5.76,402,1592899200"; d="scan'208";a="52770193" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 Sep 2020 08:20:37 -0800 IronPort-SDR: vGOILfRnRHHo7bbGI38jOE+5ywsjuUMwlDy6hM+PV+DwLhDpYm6rIQ6RL6aziyCj5FsRKW05M2 tAxmejZwJL7sKEIK8f0dCglJQiSQZI6V7YXUqAszksjMXY6BAYV0FXuW9WvrD9Le5ub4CKdJIo LlJbFZNJuUPIDWE1BDvAqbsmcfgLhhvgaNDOryqOTOZLX+ipHtJMJbNKUK/MkUNQFNHXXJWgav Zv7tdBxGx7fAVG3UIpWXfW6Lp+eEER0Q4oPmOpw86RX7R9zqOUJ8KNoekWmAP29P7ZvtAQp421 Qzg= From: Vijai Kumar K To: , Subject: [PATCH v3 4/9] oe.path: Add copyhardlink() helper function Date: Mon, 7 Sep 2020 21:50:13 +0530 Message-ID: <20200907162018.16636-1-Vijaikumar_Kanagarajan@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200907161756.16372-4-Vijaikumar_Kanagarajan@mentor.com> References: <20200907161756.16372-4-Vijaikumar_Kanagarajan@mentor.com> MIME-Version: 1.0 X-ClientProxiedBy: SVR-ORW-MBX-09.mgc.mentorg.com (147.34.90.209) To svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) X-Original-Sender: vijaikumar_kanagarajan@mentor.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.137.252 as permitted sender) smtp.mailfrom=Vijaikumar_Kanagarajan@mentor.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1677192740443480944?= X-GMAIL-MSGID: =?utf-8?q?1677192740443480944?= From: Paul Barker This function creates hard links if possible, falling back to copying the file if the destination is on a different volume to the source. The docstring for copyhardlinktree() is also updated to make the difference between the two functions a little clearer. Signed-off-by: Paul Barker Signed-off-by: Ross Burton Signed-off-by: Richard Purdie [Vijai: Imported from OE-core 5437efa16f9bec914e417c6c939a39c247084f52] Signed-off-by: Vijai Kumar K --- meta/lib/oe/path.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index 90c87f5..c6bb604 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py @@ -94,7 +94,7 @@ def copytree(src, dst): subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) def copyhardlinktree(src, dst): - """ Make the hard link when possible, otherwise copy. """ + """Make a tree of hard links when possible, otherwise copy.""" bb.utils.mkdirhier(dst) if os.path.isdir(src) and not len(os.listdir(src)): return @@ -118,6 +118,17 @@ def copyhardlinktree(src, dst): else: copytree(src, dst) +def copyhardlink(src, dst): + """Make a hard link when possible, otherwise copy.""" + + # We need to stat the destination directory as the destination file probably + # doesn't exist yet. + dstdir = os.path.dirname(dst) + if os.stat(src).st_dev == os.stat(dstdir).st_dev: + os.link(src, dst) + else: + shutil.copy(src, dst) + def remove(path, recurse=True): """ Equivalent to rm -f or rm -rf