From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yann E. MORIN Date: Fri, 7 Dec 2018 20:44:17 +0100 Subject: [Buildroot] [PATCH 2/2] core/sdk: don't mangle symlinks with '.' or '..' at start In-Reply-To: References: <6ce3997e4824d41b50e13b8554e9f7e59e63a8af.1544206190.git.yann.morin.1998@free.fr> Message-ID: <20181207194417.GJ2561@scaer> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Joel, All, On 2018-12-07 12:39 -0700, Joel Carlson spake thusly: > On Fri, Dec 7, 2018 at 11:10 AM Yann E. MORIN wrote: > > From: Joel Carlson > > The current transform changes any '.' at the start of a filename to > > $(BR2_SDK_PREFIX). This also applies to the target of a symlink, when > > it is relative. > > > > We thus might end up with something like: > > $(BR2_SDK_PREFIX)/bin/aarch64-linux-gnu-ar -> > > $(BR2_SDK_PREFIX)./opt/ext-toolchain/bin/aarch64-linux-gnu-ar > > > > when it should be: > > $(BR2_SDK_PREFIX)/bin/aarch64-linux-gnu-ar -> > > ../opt/ext-toolchain/bin/aarch64-linux-gnu-ar > > > > We fix that by making sure we always remove a known prefix, i.e. we > > remove the path to host dir. The obvious solution would be to cd into > > $(HOST_DIR)/.. , then tar ./host/ and finally use a --transfrom pattern > > as 's,^\./$(notdir $(HOST_DIR)),$(BR2_SDK_PREFIX)'. > > > > Since $(HOST_DIR) can point to a user-supplied location, we don't know > > very well how the pattern may patch. > > > > Instead, we cd into / and tar the full path to $(HOST_DIR). > > > > Since tar removes any leading '/', it would spurr a warning message, > > which is annoying. So we explicitly remove the leading '/' from > > $(HOST_DIR) when we tar it. > > > > Finally, we transform all filenames to replace a leading $(HOST_DIR) > > (without a leading /) to the prefix to use. > > > > Signed-off-by: Joel Carlson > > [yann.morin.1998 at free.fr: > > - use a single transform pattern > > - use full HOST_DIR path as pattern to replace > > - update commit log accordingly > > ] > > Signed-off-by: "Yann E. MORIN" > > > > So not sure what protocol is on tags when this is essentially v2 of my > own patch, but... > Reviewed-by: Joel Carlson > Tested-by: Joel Carlson Since my proposal is more than trivial tweaks of your proposal, your tags are welcome. Thanks for reporting the issue, for your initial patch which got me kickstarted, and thanks for your review and tests! :-) Regards, Yann E. MORIN. > Applied this and the first patch to my branch and made sure my SDKs > seemed to have the correct links. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'