From patchwork Mon Aug 24 01:27:44 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: 11 Return-Path: Delivered-To: ilbers.mnt@gmail.com Received: by 2002:a05:7000:4605:0:0:0:0 with SMTP id b5csp2149934mae; Mon, 24 Aug 2020 02:28:33 -0700 (PDT) X-Received: by 2002:a37:5d01:: with SMTP id r1mr3844237qkb.18.1598261313732; Mon, 24 Aug 2020 02:28:33 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1598261313; cv=pass; d=google.com; s=arc-20160816; b=iczW+mRAGKxITK9RK3VZ5pBgEDiRj8kmkQQ14wNRGjKWO8FvxxQq7xB3W74Rz3dyTh RRwEbki5C7XxaoAkZVgplKDi8CNHi+KltHbEChMxgL4J0gZwIeQ9ZLd9hOlooILwJEEP g5J1M0veV9R1kh83jJZviwh+f7WCv3muv4I4e2/5KOpVQ+sdNvdjsU8wsuWPy0SoT6I6 PXRDMp5IuaVdjUSdTgiOclra2y7hdE2p8BiPWJ2LiB8JrUw56XCysRXTQp9DCL5tiEn+ AMQ9YQgJZjPXBDg81v3CNJ6TGtNVMScaliTgdPJ0PRIB/5c25EN+0iNYc9dJvC7NaIB8 IW9w== 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:cc:to:from:ironport-sdr:ironport-sdr:sender :dkim-signature; bh=tLorBTZjkXpGXitI/NoMkSJseiT6dBcpkeRfL9/w8Cg=; b=N00xuAeTv75O28UXIl5/7y7W83bY6IIMT2sL/A81NGHGVpVmDiDcq2WpMzNSmKWvy8 2oEaB3szn0rzia/ct2NHer2Bcznkcr2DDHtyfwqlTO9c/KIRvNIoXuSiMp3nIsKRfwUE oX8BKlOk2gWofv6yDah/Vj+sSqDzW2J1VTozUw9hyu+YoxSF/6Mx/6C5XLWYCYmUcHWV 20ldaz+iK8Ow2k6BSUpnwXsZNLCet8178fpz1tcd6dgVJk46zICMTqaMs0SY3fjuh76h 91ZIxivcX9/2JAWefwyoStFFA++KDsIOYhYsKDyPpFB5k6s+LaRgMfFbbTqyUm1HAl6E DA9Q== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=JhNSjUvT; arc=pass (i=2 spf=pass spfdomain=mentor.com); spf=pass (google.com: domain of isar-users+bncbcw7ho6fuybrbqmqr35akgqe2hxfc2a@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCW7HO6FUYBRBQMQR35AKGQE2HXFC2A@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 f3sor3290150qkm.195.2020.08.24.02.28.33 (Google Transport Security); Mon, 24 Aug 2020 02:28:33 -0700 (PDT) Received-SPF: pass (google.com: domain of isar-users+bncbcw7ho6fuybrbqmqr35akgqe2hxfc2a@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=JhNSjUvT; arc=pass (i=2 spf=pass spfdomain=mentor.com); spf=pass (google.com: domain of isar-users+bncbcw7ho6fuybrbqmqr35akgqe2hxfc2a@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCW7HO6FUYBRBQMQR35AKGQE2HXFC2A@googlegroups.com ARC-Seal: i=2; a=rsa-sha256; t=1598261313; cv=pass; d=google.com; s=arc-20160816; b=xpKZVn96nZPrZ8vTFtFXKYu+/AOIuxuW7GTGOSUdnr87DTjFSsue9LxbaQu64t3KYu Uq7diRDvfy2SHI2AdlPLnOHgEoiJ9itkuyiqGNtHiYBVuJxVhFfibrMsaH7FqzC0qD4w nAR3uq0lEIiYUtSFERQ9mg6cYmxoaOR8AtBvtGYf4q2d/FWfv4tkwCOPYpIX9M7dUeLi LWNcTVy4RJXhu2Ui19bAXqJmj5nem08TkpYbVvut7Yh2i8kD+ROTDl4GVTDmPhFSih/T 1VNwdCbOmUZZDmYfE/bBqUx1Uaol8+N0p9wNWix/ZlpkopFTp772CqOG0ZwqGI1tFcip K7AA== 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:cc:to:from:ironport-sdr:ironport-sdr:sender :dkim-signature; bh=tLorBTZjkXpGXitI/NoMkSJseiT6dBcpkeRfL9/w8Cg=; b=FNPwzIHJ+r64yVtqViD94DTca6zPeOLmYCw9r5iuwLpoEE8d7hdWPmt03hvwLjMCCU nEioHjRQpQvD246wCtrFh9EGxZF5J9vF90GiPvu7Wfqq/F8TjhU1ixYn3r2riQKYlZWJ hHD5uZdGjAORlNO18kCnzvbUVWTd/QomvltHmDofBT1k1jsebwR0yNgxwdAGZMvOZx5M 4g2V22NmGQzRGxdK/d4zcMB91g0cERaeMmN3uHojKqDVuGrxD3B4F5FeOGv2rUpcXDut dzYGz4+P3CkhzjsS7HzDCgvI6T839X+9W3lTLtWCFAGsWpCrjdor7CEnxHU2JKD3Coib XzWQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.129.153 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:cc: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=tLorBTZjkXpGXitI/NoMkSJseiT6dBcpkeRfL9/w8Cg=; b=JhNSjUvTY3r7eaQ4lwqzZN2qKKbzEt6Vdc/dMkDUtPz/XBBs/09b8GouCxrb+5aWZj Wbbvkjo3eOSezcMFsZWVd3UuUEbJEHb54LbSD80yqaCN9PSK0uJ2TswW/ldCmP63Qosy 0kbkZD8tEQhXURHNKy69tNSamB7F8CNRdL2+Qyq4nUmW+YnbEyrY7b5d9MvKc5DB7Xhs RQTUUxVKmuEJ5OdCvo/AGyl8wl//oiiEVJMy3YKC3+ow15cbe9inPytfj6uhmqIZcCKd +XvdYLTq77b909HVlePavVzAWsYpo14VZ+/OaH22ZesmUYOENkiTKZ1J/6ZBz+Px95B5 SjOw== 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:cc :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=tLorBTZjkXpGXitI/NoMkSJseiT6dBcpkeRfL9/w8Cg=; b=nqkSZmBGysU25UxEq/L5Tq22ROiT6+LQ0DUGItqPldXRQ/3hxzSTnePmXHrd8syI96 YbAmCHoFF81D2izmBohRpz+IL08/EK7AKOjgKxgT9EVlxJau3x/kLpCCXSkPlWkSl0/8 OD5UVimje1ubuGKQx1whPYCPfVp5Lgnz6KsjfGxZRcR7mSGZ60Ns0CBNFG0Bi3TYVBCo 4W5R/A9VZ2IleKRMF0yOFDpuVrkSpyfkgclXldm6T2OOFBREXQMG9LtDfttjzp3zU0RT dUttimdxnO1XRTNZNY9mWsBhvRKK3pZPll71cZu8c34HcVUiIK+d/OXSm9aWO8tyxykU vRbA== Sender: isar-users@googlegroups.com X-Gm-Message-State: AOAM53161WcTww4N6JY/jLQ0mhjZaBSnirCMFVg20DyHU24gbx50zCpg OkDwpik9d3LVXxrqiYLVUlE= X-Google-Smtp-Source: ABdhPJzBMZYzsxu3OBSzom7qQYgeDgDsC2Ejc8uHdxJOb2DT1F0QI8NA8ejPsnJvOuDc6nstuFNCuw== X-Received: by 2002:a05:620a:2408:: with SMTP id d8mr1251190qkn.481.1598261313405; Mon, 24 Aug 2020 02:28:33 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ac8:4986:: with SMTP id f6ls1908047qtq.11.gmail; Mon, 24 Aug 2020 02:28:33 -0700 (PDT) X-Received: by 2002:ac8:24d9:: with SMTP id t25mr3968414qtt.15.1598261313120; Mon, 24 Aug 2020 02:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598261313; cv=none; d=google.com; s=arc-20160816; b=rkflpSG2G1rccv91OotwG/vCj4IE12XghMuzCz+DmWaCtFb7m0bdLEu4KuN7fyc4or gtYdn6MOJ662E/RwWVkzJnRJ6gfgYxIlhI42Vlnzosmj0gu4nI5ewOpxe6BYB4rKhzw6 LJPU/Gau9owywk6b0bi4/x6E6z5fyyMWDPpefwjZrench0BZoPXfxtpVO2ARVPgmA364 fTjRm52X6Fi4F3R92mKMgCf4ATHvn0j5DTc1xUvtNB5amj97yl1qkRwxAD2aE4kXHnYe ybUeG3wrsA3U8PpTwBQOU0B2LUxeRnFHNwqct1x/gSQyJ1cbnNUM07LuMwPrLNWZ4meE KMVA== 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:cc:to :from:ironport-sdr:ironport-sdr; bh=44YMmy8he/Krw5pKz6mdxmyPNemXWdNAzenOwLm4qaM=; b=Zy2i08aVnJw954Ag3HCRBydEYd6ksvpIYSbDKhE3H00oVRAPL9P1k9KiATy1ji09qu YwUfLxkcTfvKmBvL4LdLKa5MpXjFEbPovB4wTfc3swnc/fUS7ayUrMJOV+gTbZn/gfja D/jQQWadpcEeZJ1eC3oGBMxc2+k/wj8IaDCMxl0o4hnHGYfGms34tvkmK+SkQhHbJKqP G5RnhAcgw7iBhjkav3xBEqdFEk3KeUGjMYtZS1SHJq020qHrVo9dTFUIliZCelEf0tE3 IUdATigQ4oxUiZeVB2o8gT5F+XG1GUvDIF8neC7mvYit4T4Ospa6sc+4WnQ3h2pI7F8E kdeg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.129.153 as permitted sender) smtp.mailfrom=Vijaikumar_Kanagarajan@mentor.com Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com. [68.232.129.153]) by gmr-mx.google.com with ESMTPS id e16si360474qto.5.2020.08.24.02.28.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Aug 2020 02:28:33 -0700 (PDT) Received-SPF: pass (google.com: domain of vijaikumar_kanagarajan@mentor.com designates 68.232.129.153 as permitted sender) client-ip=68.232.129.153; IronPort-SDR: +NHAXWxH+o3eqMpnwy1sRDZ5BXNLAG6Mw7YQbxJfOFrZxsjhbRRi9Pg5Bybr70S4jWbapxZqq9 9FXwZK8JBSQExWVQzRSgwJ+Rt+1FBXhI3765YqbbxZp2N2wjdBgGwzuq2whOgSCd7fmWzyQz8Z CGwDbhD3VBHqcm3Fa+yL0Ei7R1MhL+j6isEJIfrqC8l5mpbkmt8lopmzZ+KNGHnUzpxf6yloSr va0GA7z/aH/n54DCHzFT9ZxG/NKG3OT4jUkp4VnMdnvwGIOHnqPXdEdYoRC4bF7t1v3rLpvW7l WY0= X-IronPort-AV: E=Sophos;i="5.76,348,1592899200"; d="scan'208";a="54369374" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 24 Aug 2020 01:28:32 -0800 IronPort-SDR: GbS6UMvdXQkN7G3WNAoYGX0U3ir9fp8KRMOTJ6Nfjg/vXfE5PHQTgITheNbRa/sD9BAsfKvygO 1yFKZSQuJYyvZHcgYpVOmfT5v+4waE5ynZl3Biq/6nVGLZCu51WPwbYfcBEBNRFjtr9BtI4gWs ikTmUk5Ft8DTQ3MSX55VrX6NlQ20HbXr0kkoOFB4Q0Mt2DF5M8cqcg3g0lAHRiyeaNRcK7W3YR fun+FbSjv+xRlefRRkaGqqpfB0DCcicnwwIvquT2EVref99RMNQKY0SPuA9MzGjOWBSQluWDtY c6s= From: Vijai Kumar K To: CC: Paul Barker , Ross Burton , Richard Purdie , Vijai Kumar K Subject: [RFC PATCH 04/10] oe.path: Add copyhardlink() helper function Date: Mon, 24 Aug 2020 14:57:44 +0530 Message-ID: <20200824092750.19642-5-Vijaikumar_Kanagarajan@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200824092750.19642-1-Vijaikumar_Kanagarajan@mentor.com> References: <20200824092750.19642-1-Vijaikumar_Kanagarajan@mentor.com> MIME-Version: 1.0 X-ClientProxiedBy: SVR-ORW-MBX-05.mgc.mentorg.com (147.34.90.205) 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.129.153 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?1675898455292151614?= X-GMAIL-MSGID: =?utf-8?q?1675898455292151614?= 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