From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7059736144635756544 X-Received: by 2002:a63:f15:: with SMTP id e21mr2177879pgl.571.1643978723506; Fri, 04 Feb 2022 04:45:23 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:902:d483:: with SMTP id c3ls1619799plg.4.gmail; Fri, 04 Feb 2022 04:45:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJNSK+BHdLiY0/uGU8tT5iZd61E0j3ItA8q1fG787xHIDLTG3w/W3ArLhw38E9fT5ljVGj X-Received: by 2002:a17:90a:cc15:: with SMTP id b21mr2959647pju.153.1643978722769; Fri, 04 Feb 2022 04:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643978722; cv=none; d=google.com; s=arc-20160816; b=MPfsMFH6ogj1vSqTIfO8y4CDh2joEn++AiIThBU6G1ulq3TMIkCCenrj81crYXHyWV 24uawmMd6kJ01BEp6oy3QAvACknyWnIs/NS8+loLJt3moNKMM955NhJuBojD0YY/exsV 3O7YiGgrJ+VnGcDmLbapkGLf3bMaywvKoG42jyFBHMJWZJ8nU/cOXhhIG+AF0nyQbQAu 2CVEnHD+WTAMl5evdd0k8Xeu5P9cXc1menh8x4eyJ/cpa+1bD4v12BtCMSihPa/B4f/a X+DWQh9Kt+NA+4lFY5B52/HO2YVhqSrWEzdVjIGt0OyW4EM/CD+SCtcEaLH0K3/eGf5e mEXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:ironport-sdr :ironport-sdr; bh=e+3xJ7VYPplA4Uz57cWMycyl6CxfWaCWGG4NDKwlD2k=; b=oMvYPiHNotz0oM4iSytgusVf77sn9zlmIZDSKkRzB1/+iHqs12yvBMweTi69tS21O5 0CFL+RGTlM12nEjbhlhVDqiVUM4zdauTW741olUg0J0S005BoidPUu18HQk56XphEQtT VD2qomoLos0CtloMIG1XDLeJvxvVy7c2xPq8bGASP7P6X1woepED2Gp+v5afJ2fgGc8e VrTqKa503IJDO8w7uF48h8fpdoac2J/vUJcA5O51YfzKAec+iXqBOe0+cZqyEdCgE7f4 OGUmq3BDlqC0BR5Bo5jgTN/3jO4onKSypBWsWjql/D2ZTAOWINB8QFZmgBLuZK5FKFNE xqaQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 68.232.141.98 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com. [68.232.141.98]) by gmr-mx.google.com with ESMTPS id a10si81215pgw.5.2022.02.04.04.45.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Feb 2022 04:45:22 -0800 (PST) Received-SPF: pass (google.com: domain of cedric_hombourger@mentor.com designates 68.232.141.98 as permitted sender) client-ip=68.232.141.98; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 68.232.141.98 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com IronPort-SDR: dFsLd/aVGGjHnvwMC0D7Yrg8P5fMDV6h6UCsvSJi9xfzASMzZA2Qbk2j5gQb50h6//h83k0p5T gtJ6beb1w6P5wjEsBR1WMg3leVM96UNhZ5Ppt7n8nE+5/90FBkAEvI6CAPNidDqK05Bi8b02LG mrDjL0rMHDo7CH1qMURWvIlqAVABi2rzswCcI6Y4HhCaYq6hq2NRBiBlJdsV5W8+q3wCtMigDX TiwMHKsSwfH2Oe9YoSEW6suM53xH4khSmfa/RcZAuR6XkTxVQSOu/seo9R2znkwCTj0BATmlvt v/T7RhzF7A7ZBhJ2N5Ydo8Vi X-IronPort-AV: E=Sophos;i="5.88,342,1635235200"; d="scan'208";a="71607912" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 04 Feb 2022 04:45:21 -0800 IronPort-SDR: 72WXL8tYFB7mn+AVPGn2H26eEDngVuakZnBZkDT2x1qUbiao0E2/q2hSElLH3gdMZqcBApB7nh hOrOUraNXYSwTsqMMAVcVhPok1TgAyf3ygLBS7ffKirT0ALl6hM9VkLs3y79UnKcHhGRh4vKeq FQzsizStNWLvRKrF5bys3u1oLjLqcyhi9swM9uahIdug/e1pVGuhBSbR8LRaX6wvfWDv8Qcsvu F7vdh7LqhbR6WTMJIuViBa2ibPXRrkNZLzJ9HjDdLo4T3VphzmHafwx7zzfuW0Yk0i3VO8Xnk6 MaI= Message-ID: <6de834583c405b429ad6eb921e363d0e2a3cf7da.camel@mentor.com> Subject: Re: [PATCH v3] dpkg-base: resolve DL_DIR in do_adjust_git From: Cedric Hombourger To: Jan Kiszka , CC: Cedric Hombourger Date: Fri, 4 Feb 2022 13:45:06 +0100 In-Reply-To: <6e0eeb9c-3b5c-228b-f6dd-0fb7334b4c10@siemens.com> References: <0a7f590d-63f5-5505-a9c9-718f9d8c81fb@siemens.com> <20220204105418.30167-1-Cedric_Hombourger@mentor.com> <6e0eeb9c-3b5c-228b-f6dd-0fb7334b4c10@siemens.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Return-Path: Cedric_Hombourger@mentor.com X-TUID: LRMEnRVyD2ZP On Fri, 2022-02-04 at 12:04 +0100, Jan Kiszka wrote: > On 04.02.22 11:54, Cedric Hombourger wrote: > > From: Cedric Hombourger > > > > git_link is resolved using os.path.realpath() but git_dl is not. > > If DL_DIR points to a symbolic link, the comparison will always > > fail and do_adjust_git() will attempt to re-create the symbolic > > link. Resolve DL_DIR for a comparison between resolved paths. > > In the event where paths do differ, the symbolic link needs to > > be deleted first. > > > > Signed-off-by: Cedric Hombourger > > --- > >  meta/classes/dpkg-base.bbclass | 10 +++++++--- > >  1 file changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg- > > base.bbclass > > index 2add0b2..258e040 100644 > > --- a/meta/classes/dpkg-base.bbclass > > +++ b/meta/classes/dpkg-base.bbclass > > @@ -20,9 +20,13 @@ python do_adjust_git() { > >      rootdir = d.getVar('WORKDIR', True) > >   > >      git_link = os.path.join(d.getVar('GIT_DL_LINK_DIR'), '.git- > > downloads') > > -    git_dl = os.path.join(d.getVar("DL_DIR"), "git") > > +    dl_dir = os.path.realpath(d.getVar("DL_DIR")) > > +    git_dl = os.path.join(dl_dir, "git") > >   > > -    if not os.path.exists(git_link) or os.path.realpath(git_link) > > != git_dl: > > +    if os.path.exists(git_link) and os.path.realpath(git_link) != > > git_dl: > > +        os.unlink(git_link) > > + > > +    if not os.path.exists(git_link): > >          os.symlink(git_dl, git_link) > >   > >      for src_uri in (d.getVar("SRC_URI", True) or "").split(): > > @@ -34,7 +38,7 @@ python do_adjust_git() { > >   > >              if os.path.islink(ud.localpath): > >                  realpath = os.path.realpath(ud.localpath) > > -                filter_out = os.path.join(d.getVar("DL_DIR"), > > "git") + "/" > > +                filter_out = git_dl + "/" > >                  if realpath.startswith(filter_out): > >                      # make the link relative > >                      link = realpath.replace(filter_out, '', 1) > > Looks good and was surely an untested case so far. It's actually two > fixes in one (os.symlink != ln -sf...) > > Does this explain your "race condition" from before? Yes it certainly did. I had misinterpreted the symptoms / root-cause (thanks again for pointing me to the lock around do_adjust_git) > > Jan >