From patchwork Wed Sep 2 10:56:18 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: 23 Return-Path: Delivered-To: ilbers.mnt@gmail.com Received: by 2002:a4a:eb04:0:0:0:0:0 with SMTP id f4csp654329ooj; Wed, 2 Sep 2020 11:57:12 -0700 (PDT) X-Received: by 2002:a62:6847:: with SMTP id d68mr4455867pfc.110.1599073031947; Wed, 02 Sep 2020 11:57:11 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1599073031; cv=pass; d=google.com; s=arc-20160816; b=wDqPY8mnU39PaJ0BXQukGj3caSUhX93uVTf7FX1jXoEcpY+94C/rlW3M1dOBj6Ex2y jHzbLZrw0CUNlmYULS8hbXrjfbC+KyJqCJTuI4zXZY7YiePf6WS/TPdovBQzCpc2kgnC POjPXVYowKF25sbzIA2ffB9Dh6eP807aNEShymjgAfETOT3TSP0M5hCCDsBVW8OXmpKR cWqHOBxsGwDAM8+/vOOtVIZkeqQ1BwRScgCRjjXiQbJ9uc8g47mOTVQz60IhIsm7gKY9 Z7HHVCf+dP9UpXt5uQjRSMM4xnvfo5U/YIFCmsDYkm0p8CWnjpn0KHDzDq1dYnVkPAaS fFdQ== 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=O/yP7MsZ+YJcKCCU6FtXmiNneV507XPtOL1mpHc1D7Y=; b=jzqS3Qk7/uMl/UY36eZslGLtjIqNTH+fVf1WPvhCgfnNBfksdcj0/wkF3UxKK8rsqk SSZeU19aww6Bf6kz/PN8wF5DP7ME1dNA7XYkRoZ3xCGYl8pHOAad/YGAPTYu91Rs3xA4 FF2hR57G6EMncjfj2fN/AGo0ShKDg231TNzclNGzll+XP2j8k1UVbUvyq/zN/gb8NZF8 mgWMu+1Bs+cBKsla0PTHloZDsCtp1BhCwnKlEsLGhBfr2oXdUPCrVkrNaMOLM/7hGHow qE5ahsjdA6ZUj4/MNXp9fwKlsB6GbjjtaYOYodM7zbe2lxfX9rSIJ0FBZG9iqk4KCvDi S5fA== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b=jE3XfxqL; arc=pass (i=2 spf=pass spfdomain=mentor.com); spf=pass (google.com: domain of isar-users+bncbcwp7lf37ukrbb6wx75akgqegkeurwi@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCWP7LF37UKRBB6WX75AKGQEGKEURWI@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 bb10sor124744plb.2.2020.09.02.11.57.11 (Google Transport Security); Wed, 02 Sep 2020 11:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of isar-users+bncbcwp7lf37ukrbb6wx75akgqegkeurwi@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=jE3XfxqL; arc=pass (i=2 spf=pass spfdomain=mentor.com); spf=pass (google.com: domain of isar-users+bncbcwp7lf37ukrbb6wx75akgqegkeurwi@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCWP7LF37UKRBB6WX75AKGQEGKEURWI@googlegroups.com ARC-Seal: i=2; a=rsa-sha256; t=1599073031; cv=pass; d=google.com; s=arc-20160816; b=fj8vVbzHEJvNh4TshlHoY5/okfxh60geB6+H7iHu2P9zaJX+j1MVHyhtYVSx96N0AC 9HkpoHINCuy+LkmKd/mdHuU5P+64rZdSLvypp8UpH0KIRkPRowfPes6BKOu851l/9pOy G/zkLkGBZZpdo1DJBlNS1j5RlTQ2UU9i9idF5hK7RAM6rTVyHkGmKHwyBsp2726lQl+/ z2AbXLF3nDRff47tiu+LC0IzmyAuY7YadIS4tm3nnulhRnflUBCRB6AfrnLZ1kscZn95 9/FLUvY7fMj4Iy0+IFIi+d6j6ujlbAc7z8diVvWFZEaxL8MwHQLSWZtXyrz7vvHU34ju b1aA== 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=O/yP7MsZ+YJcKCCU6FtXmiNneV507XPtOL1mpHc1D7Y=; b=yblhcIQhs3l8/RM8Si/jUm4conRhbIUFExRJv0U/acC9EBD6WmY9sycTMm+J23Qcgl xnIfJTxL3Re7IbsrJi7wGM7KU0h46bzcUM0uviHhlXf3cjo3a9TSnjuEHqMz6n9ZCv8Y zRDVuqL1p2zQmmRbn2WQRBzy/mTNJU9DDiRNoNirc+S/plsImCnmgjBtiWoBVF7nr8Ht pR85D39Rs8G8cMV7Ar0fRMwNyktaiDRZWkwqgPw5QgMx3UmO28qN5P3u5KlVQCsjphla UFYIpwVq9uJ5LRW8Yn/St7ddvOm5/t4JFbxJ8o4w30F6nIop2dEe7EG01wEj5ugLXdpy DkOg== 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: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=O/yP7MsZ+YJcKCCU6FtXmiNneV507XPtOL1mpHc1D7Y=; b=jE3XfxqLHQi0i+r0j7dKhP96LuBA353wgyaeSzpKhM+CfnjYnVy9fB86fTCGI4JOsU hGJu7NdONX4pMpgJb19olo/Ne3DkpueVhTxDYgQ+tqsgO1K1MSI8RUyCLUi3rwMa01/b YesoZpzwBU2zZvKIK/ltxtbaZGXQOpOD6ofblsIRbgVQB7PtTnbfVXdxxxLxjI2EAtfL RW9sY92e8LeZriweTeEHxpmOYWEcnI1zE+oqsQjducS8PPT2PHgoMgLJTJzn/X+9U81M JXQqF2wFcdOmp2yizoJ+eCFEvEq4VrylgKSPkMt1euekFM0KPcrmqpw8UGI3Jd/Ap8xS 3z+w== 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=O/yP7MsZ+YJcKCCU6FtXmiNneV507XPtOL1mpHc1D7Y=; b=Gfu0bbts81Jnrqawd1mHCQqoh1BrrV2GHL0iSolQYJmTqk1ABtyXZVUL/9y2TuJjg3 FEI3aP7IAW9DbBrlgJtBbQ2mb8iRCtJqIxbY53uvHyiVehPE5hPle2qbdfA5b6YBobwQ 2TXG+zraerrnf1EGRqFjQZHioc9lj+aSB1v3yPOW7btkTQCqjouOtYHW1CFNwfjASRAj 8V7az97R3ULzhEZ/KAPFYIzCYU9mn1NDmnh90MPZ/nTAbrRBuR4l0DeOfwbSV4oHXucO s8M32wseqK+gALGCS5X+aU8sF9Nh2Mlna8/0s6+e/genNW9mydN2ilpBz2DdRegn2Fhj jKgA== Sender: isar-users@googlegroups.com X-Gm-Message-State: AOAM530aUiIwM6BpQEerCP9GjAaOvqoyyf/Vlv6a6VjoYZxB0YCg8I2P HbnSwEz78ddgCBnloDF1u50= X-Google-Smtp-Source: ABdhPJwNc4oKWj+V9D115kg1HQYj25fCvfxIeSda17JHMqb3shASFk61PMxO2lkHkYpHJNScGJ6dpA== X-Received: by 2002:a17:902:eb0b:: with SMTP id l11mr3153374plb.57.1599073031540; Wed, 02 Sep 2020 11:57:11 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:902:720b:: with SMTP id ba11ls1640934plb.0.gmail; Wed, 02 Sep 2020 11:57:11 -0700 (PDT) X-Received: by 2002:a17:902:fe0b:: with SMTP id g11mr3248360plj.172.1599073030986; Wed, 02 Sep 2020 11:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599073030; cv=none; d=google.com; s=arc-20160816; b=uC3onr2uTsoYiP2rutns9ZN++a1w+DegbnTO4auhumx8BdRNIH2iMtoaXbp1CLV78k daB5dsC94hatSqFiAkZj9Spw9NbiqJsfmhHzyej4B2o0H4eEbjWzkM3z6kNs/07srO0K fAV3IrcbfH3WKortCjM3bnibVhSo6T8XrvzKhObECwpbhTr3ICEiFB+jnMhrsc1A6UwA SiCZYLBByOZqcy9aNfkA+Ii055SQmeYEKT+bzIgOeg3CR0+5/UFRk7xyQxTC6t4Zyg56 +fFryt7qQF63Mw5yVWtdRscnNjUgvUZSMdxvXzen45WZHgQJLpTaWNJvob0SuIPejyyd jBQA== 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=AzVqOT0ZXUpGlS2QPjqwR5zAmIvI9ymHR/UCQ7ya3NzfAli19JyjlRKy4zzmZ+afWD 1DQK+Jw9ABWC70WcHOcUkiF2Lh/bGYv+lMAPQCgFmBbyM7zUXWSEwaYAViGNWJ7ateNl GJDS98xVcOWTErTN0TPebu/uf4++VagN5wfhE9LG0Tj7Th/LauMOBGBbRTWplqW9F5GK 1yjhrI43uuPgZnBFaqhrwLCR0wsbFu5uWz+Vha0vLlCvRXcAL5i5tBXhzEYNQZr+3NIT H5IIRzN+zhVpN4Y2idYtK4QejCzE3WWqP3NckiIUewBKoYwXQLDmG/SLsJHVeR4+pWN7 lkBA== 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 a199si43434pfd.1.2020.09.02.11.57.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2020 11:57:10 -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: 30nirJfAuxUROOc7D5WZ+KAHXYbqKDQpS7zQT0+izkOvVMsepGKVa/tu4V3jkovqqBtV6tZ3z0 8BZAaYq1UAd5y1NaN1x6oIsSO1IhdhMTGZhARsyaYJ7c0aoA1GbmI4PE4gRozbmP3epmBnAXT5 OQHx7cX4FlrobzHkn53Kg68gUoHvU5Dy2jMJdGCIOYsByU3BYRmj2US0VLfxcJPO8DzKEVfm8y SUdTVZoRpsWJPR2OmfnMGBqhQeUyACCbjcb1HckbQPuYHEbDbYHR6aTvPXugh6gOgLcVa9qO5q UEo= X-IronPort-AV: E=Sophos;i="5.76,383,1592899200"; d="scan'208";a="54698484" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 02 Sep 2020 10:57:10 -0800 IronPort-SDR: kAGh/oaaq47mm/pT3H2BrE2REQuUo0ICS973KaVgOkHntGRtsDJpdPZgMNAukBVl+NYrUYNbOB 7ojpKpKCm6S/znr4RJ1x1/sxz4QgiEE0ZW2TP5IOUal2PlfARxRyM1mPDb++0m9vl4Fkx/6d14 Uldk6D8HRwBA3DTPxDedHXIIfHFC6/A8VfCnemquYY+M6f0MlrJ1UDAXO2CVqgfBIL7fn81QPb pQ8cUb18z323SUqaHFXwFuH9Ijy0/+BM77840T8MCh8oRIMTihI3uIteHFN3OOSmGwU0KMd549 GC4= From: Vijai Kumar K To: , Subject: [PATCH v2 04/10] oe.path: Add copyhardlink() helper function Date: Thu, 3 Sep 2020 00:26:18 +0530 Message-ID: <20200902185624.15044-5-Vijaikumar_Kanagarajan@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200902185624.15044-1-Vijaikumar_Kanagarajan@mentor.com> References: <20200902185624.15044-1-Vijaikumar_Kanagarajan@mentor.com> MIME-Version: 1.0 X-ClientProxiedBy: SVR-ORW-MBX-07.mgc.mentorg.com (147.34.90.207) 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?1676749603383569757?= X-GMAIL-MSGID: =?utf-8?q?1676749603383569757?= 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