Message ID | 20230325141909.2512452-1-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp460228vqo; Sat, 25 Mar 2023 08:07:22 -0700 (PDT) X-Google-Smtp-Source: AK7set8fZHC41vF4Xrfunx/kkNVhIQ/sB1vRUuelR96eWSKeYC0ysf9KpxjkfkHHXROHP6g+UIJI X-Received: by 2002:a17:906:448b:b0:939:bc91:cc6f with SMTP id y11-20020a170906448b00b00939bc91cc6fmr13177576ejo.21.1679756842071; Sat, 25 Mar 2023 08:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679756842; cv=none; d=google.com; s=arc-20160816; b=EMfP/G4LofiOXLMM2WRqAneq7hJFDJzCBxhFaeyaWBtVbKmHMjjX3ZYtPbRG2K9eCw 2l4+Qib657r4EFX3joCgadFBhXxa60la4lGlJv22wjd7XCbxfiJgxJJXoK1h8GTDIGar 12+zNxX6LUIvWSIEw39qQq+iQmclFVAZHJk71DpopWK1haW6mM46IAq2WiLZvBG1sNsu j7NKQfxJKLsv8RDO+sTNLfq2BQ8TkTNLdRJbIbCdQpis0+myo+/LLTaHUOflWZRr9Ult QctKVSZ9UVTgruzOJp7Ef9a0TM8dplRcr2A+3tlhtr0XsdSOtfRbfZwhDky03SL8YIA3 3j6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pkdCFbi7hy5GQD+W7aNSjPq0C4dC3kUcMrFY9ATHEE0=; b=uL7UJjHzatn9RpLWb0sAlsO8jiL/kFb+dJU+c6sADaw6PtnPxuZuNMhRDaJ5M8DOJ+ wkNdMvOOfXAuoWNa9oFfYcUL4HS5ZhuBI5ehmBgJjgrIdn6Yov4Dsce9+f81+vSGsDpl W1kSAyyi92BKRgpbUadYwVAHiNX5p0Vu39BSaOQXdDq0N2O9aKux6kBCVYrl6iRV+sjz zcPBYfyAosbDLbbD8aBffHk6GlUBmg9OPVVPgYfBpvE0zs9DON4HB0JV9jD8rWWp6FfP xaOM8z0lmurpHRSArB6lmDNU2MUn0DVnWkTVmWLoER91suw7uGa9nM4ZROzb9JTe+SGg kDRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d6k+DhKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a05640208cf00b004c30cb1f8cdsi3382323edz.224.2023.03.25.08.06.58; Sat, 25 Mar 2023 08:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d6k+DhKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbjCYOTU (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Sat, 25 Mar 2023 10:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbjCYOTT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 25 Mar 2023 10:19:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BA061114B; Sat, 25 Mar 2023 07:19:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 883AB60C6C; Sat, 25 Mar 2023 14:19:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A3D6C433D2; Sat, 25 Mar 2023 14:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679753956; bh=5QjzAdbwAc0VpltsXBqbvPGXjoKOMT/y6u/uaixI0GM=; h=From:To:Cc:Subject:Date:From; b=d6k+DhKOvruw0egjMdatWqCIm8t9wwp/hbNrSwBDGJ4zak4fS1/vrm+THCRoq0yXa JzShFpPIn2NLWRrsvNzSGAqgHiB3QrmoELVFGAVb28ImE/BECymAU8+6h8OK0pQDx/ KIVuEqy0Pfq7rYbahhnvQSMuhywzmqgOh5eVIxT52rUaderVuj0oN25UdofXVNzSOz JBh8OAzQ1LLxRzN9FXMFmrQ8LEDCypDaJaqTOY0rq5mlHKNZVOUapCE+9COHqT4of5 Qn27DKbzgn2WM7Hf08A4ixZkxZ3UnTvra4m+cLSkjGOgKvGfRXnLsx0y0THh6Fyi+g bEdDA5fIEHytg== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu> Subject: [PATCH] kbuild: fix package build error due to broken symlinks Date: Sat, 25 Mar 2023 23:19:09 +0900 Message-Id: <20230325141909.2512452-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761352710599117276?= X-GMAIL-MSGID: =?utf-8?q?1761352710599117276?= |
Series |
kbuild: fix package build error due to broken symlinks
|
|
Commit Message
Masahiro Yamada
March 25, 2023, 2:19 p.m. UTC
'make deb-pkg' and 'make rpm-pkg' fail if a broken symlink exists in
a dirty source tree. Handle symlinks properly, and also, keep the
executable permission.
Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/package/gen-diff-patch | 36 +++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
Comments
On Sat 25 Mar 2023 23:19:09 GMT, Masahiro Yamada wrote: > 'make deb-pkg' and 'make rpm-pkg' fail if a broken symlink exists in > a dirty source tree. Handle symlinks properly, and also, keep the > executable permission. > > Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation") > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > --- > > scripts/package/gen-diff-patch | 36 +++++++++++++++++++++++++--------- > 1 file changed, 27 insertions(+), 9 deletions(-) > > diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch > index f842ab50a780..23551de92e1b 100755 > --- a/scripts/package/gen-diff-patch > +++ b/scripts/package/gen-diff-patch > @@ -23,16 +23,34 @@ fi > git -C ${srctree} status --porcelain --untracked-files=all | > while read stat path > do > - if [ "${stat}" = '??' ]; then > - > - if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && > - ! head -n1 .tmp_diff | grep -q "Binary files"; then > - { > - echo "--- /dev/null" > - echo "+++ linux/$path" > - cat .tmp_diff | tail -n +3 > - } >> ${untracked_patch} > + if [ "${stat}" != '??' ]; then > + continue > + fi > + > + if [ -L "${path}" ]; then > + { > + echo "diff --git a/${path} b/${path}" > + echo "new file mode 120000" > + echo "--- /dev/null" > + echo "+++ b/$path" > + echo "@@ -0,0 +1 @@" > + printf "+"; readlink ${path} Better quote "${path}"? > + echo '\ No newline at end of file' > + } >> ${untracked_patch} Here quoting should not be necessary as mkdebian and mkspec give only save filenames, but for consistency I'd quote ${untracked_patch} as well. > + elif ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && > + ! head -n1 .tmp_diff | grep -q "Binary files"; then > + if [ -x ${path} ]; then Same here. > + mode=100755 > + else > + mode=100644 > fi > + { > + echo "diff --git a/${path} b/${path}" > + echo "new file mode ${mode}" > + echo "--- /dev/null" > + echo "+++ b/$path" > + cat .tmp_diff | tail -n +3 > + } >> ${untracked_patch} And possibly here? > fi > done > > -- > 2.34.1 Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
On Thu, Mar 30, 2023 at 5:02 AM Nicolas Schier <nicolas@fjasle.eu> wrote: > > On Sat 25 Mar 2023 23:19:09 GMT, Masahiro Yamada wrote: > > 'make deb-pkg' and 'make rpm-pkg' fail if a broken symlink exists in > > a dirty source tree. Handle symlinks properly, and also, keep the > > executable permission. > > > > Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation") > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > --- > > > > scripts/package/gen-diff-patch | 36 +++++++++++++++++++++++++--------- > > 1 file changed, 27 insertions(+), 9 deletions(-) > > > > diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch > > index f842ab50a780..23551de92e1b 100755 > > --- a/scripts/package/gen-diff-patch > > +++ b/scripts/package/gen-diff-patch > > @@ -23,16 +23,34 @@ fi > > git -C ${srctree} status --porcelain --untracked-files=all | > > while read stat path > > do > > - if [ "${stat}" = '??' ]; then > > - > > - if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && > > - ! head -n1 .tmp_diff | grep -q "Binary files"; then > > - { > > - echo "--- /dev/null" > > - echo "+++ linux/$path" > > - cat .tmp_diff | tail -n +3 > > - } >> ${untracked_patch} > > + if [ "${stat}" != '??' ]; then > > + continue > > + fi > > + > > + if [ -L "${path}" ]; then > > + { > > + echo "diff --git a/${path} b/${path}" > > + echo "new file mode 120000" > > + echo "--- /dev/null" > > + echo "+++ b/$path" > > + echo "@@ -0,0 +1 @@" > > + printf "+"; readlink ${path} > > Better quote "${path}"? Thanks for the suggestion. Quoting variables are correct in most cases. But, that is not enough to generate a valid patch when a file path contains spaces. 'git format-patch' produces a patch that is accepted by GNU patch and also by dpkg-source. I learned a trick from GIT source code. If you are interested, what GIT does [1]. [1] https://github.com/git/git/commit/1a9eb3b9d50367bee8fe85022684d812816fe531 I will send v2 later, where I made some more efforts to fix several corner cases even if that is not perfect.
On Sat, Apr 01, 2023 at 11:55:44PM +0900 Masahiro Yamada wrote: > On Thu, Mar 30, 2023 at 5:02 AM Nicolas Schier <nicolas@fjasle.eu> wrote: > > > > On Sat 25 Mar 2023 23:19:09 GMT, Masahiro Yamada wrote: > > > 'make deb-pkg' and 'make rpm-pkg' fail if a broken symlink exists in > > > a dirty source tree. Handle symlinks properly, and also, keep the > > > executable permission. > > > > > > Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation") > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > > --- > > > > > > scripts/package/gen-diff-patch | 36 +++++++++++++++++++++++++--------- > > > 1 file changed, 27 insertions(+), 9 deletions(-) > > > > > > diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch > > > index f842ab50a780..23551de92e1b 100755 > > > --- a/scripts/package/gen-diff-patch > > > +++ b/scripts/package/gen-diff-patch > > > @@ -23,16 +23,34 @@ fi > > > git -C ${srctree} status --porcelain --untracked-files=all | > > > while read stat path > > > do > > > - if [ "${stat}" = '??' ]; then > > > - > > > - if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && > > > - ! head -n1 .tmp_diff | grep -q "Binary files"; then > > > - { > > > - echo "--- /dev/null" > > > - echo "+++ linux/$path" > > > - cat .tmp_diff | tail -n +3 > > > - } >> ${untracked_patch} > > > + if [ "${stat}" != '??' ]; then > > > + continue > > > + fi > > > + > > > + if [ -L "${path}" ]; then > > > + { > > > + echo "diff --git a/${path} b/${path}" > > > + echo "new file mode 120000" > > > + echo "--- /dev/null" > > > + echo "+++ b/$path" > > > + echo "@@ -0,0 +1 @@" > > > + printf "+"; readlink ${path} > > > > Better quote "${path}"? > > > Thanks for the suggestion. > > Quoting variables are correct in most cases. > But, that is not enough to generate a valid > patch when a file path contains spaces. > > > > 'git format-patch' produces a patch that > is accepted by GNU patch and also by dpkg-source. > > I learned a trick from GIT source code. > > > If you are interested, what GIT does [1]. > > > [1] https://github.com/git/git/commit/1a9eb3b9d50367bee8fe85022684d812816fe531 thanks for the pointer, that is really interesting! Kind regards, Nicolas > I will send v2 later, where I made some more efforts > to fix several corner cases even if that is not perfect. > > > > > > > > > -- > Best Regards > Masahiro Yamada
On Sun, Apr 2, 2023 at 2:53 AM Nicolas Schier <nicolas@fjasle.eu> wrote: > > On Sat, Apr 01, 2023 at 11:55:44PM +0900 Masahiro Yamada wrote: > > On Thu, Mar 30, 2023 at 5:02 AM Nicolas Schier <nicolas@fjasle.eu> wrote: > > > > > > On Sat 25 Mar 2023 23:19:09 GMT, Masahiro Yamada wrote: > > > > 'make deb-pkg' and 'make rpm-pkg' fail if a broken symlink exists in > > > > a dirty source tree. Handle symlinks properly, and also, keep the > > > > executable permission. > > > > > > > > Fixes: 05e96e96a315 ("kbuild: use git-archive for source package creation") > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > > > --- > > > > > > > > scripts/package/gen-diff-patch | 36 +++++++++++++++++++++++++--------- > > > > 1 file changed, 27 insertions(+), 9 deletions(-) > > > > > > > > diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch > > > > index f842ab50a780..23551de92e1b 100755 > > > > --- a/scripts/package/gen-diff-patch > > > > +++ b/scripts/package/gen-diff-patch > > > > @@ -23,16 +23,34 @@ fi > > > > git -C ${srctree} status --porcelain --untracked-files=all | > > > > while read stat path > > > > do > > > > - if [ "${stat}" = '??' ]; then > > > > - > > > > - if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && > > > > - ! head -n1 .tmp_diff | grep -q "Binary files"; then > > > > - { > > > > - echo "--- /dev/null" > > > > - echo "+++ linux/$path" > > > > - cat .tmp_diff | tail -n +3 > > > > - } >> ${untracked_patch} > > > > + if [ "${stat}" != '??' ]; then > > > > + continue > > > > + fi > > > > + > > > > + if [ -L "${path}" ]; then > > > > + { > > > > + echo "diff --git a/${path} b/${path}" > > > > + echo "new file mode 120000" > > > > + echo "--- /dev/null" > > > > + echo "+++ b/$path" > > > > + echo "@@ -0,0 +1 @@" > > > > + printf "+"; readlink ${path} > > > > > > Better quote "${path}"? > > > > > > Thanks for the suggestion. > > > > Quoting variables are correct in most cases. > > But, that is not enough to generate a valid > > patch when a file path contains spaces. > > > > > > > > 'git format-patch' produces a patch that > > is accepted by GNU patch and also by dpkg-source. > > > > I learned a trick from GIT source code. > > > > > > If you are interested, what GIT does [1]. > > > > > > [1] https://github.com/git/git/commit/1a9eb3b9d50367bee8fe85022684d812816fe531 > > thanks for the pointer, that is really interesting! > > Kind regards, > Nicolas > > > > I will send v2 later, where I made some more efforts > > to fix several corner cases even if that is not perfect. I wrote a patch (attached to this email) but I am still thinking if this is worth the complicated scripting... Another approach would be to stop caring untracked files.
diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch index f842ab50a780..23551de92e1b 100755 --- a/scripts/package/gen-diff-patch +++ b/scripts/package/gen-diff-patch @@ -23,16 +23,34 @@ fi git -C ${srctree} status --porcelain --untracked-files=all | while read stat path do - if [ "${stat}" = '??' ]; then - - if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && - ! head -n1 .tmp_diff | grep -q "Binary files"; then - { - echo "--- /dev/null" - echo "+++ linux/$path" - cat .tmp_diff | tail -n +3 - } >> ${untracked_patch} + if [ "${stat}" != '??' ]; then + continue + fi + + if [ -L "${path}" ]; then + { + echo "diff --git a/${path} b/${path}" + echo "new file mode 120000" + echo "--- /dev/null" + echo "+++ b/$path" + echo "@@ -0,0 +1 @@" + printf "+"; readlink ${path} + echo '\ No newline at end of file' + } >> ${untracked_patch} + elif ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && + ! head -n1 .tmp_diff | grep -q "Binary files"; then + if [ -x ${path} ]; then + mode=100755 + else + mode=100644 fi + { + echo "diff --git a/${path} b/${path}" + echo "new file mode ${mode}" + echo "--- /dev/null" + echo "+++ b/$path" + cat .tmp_diff | tail -n +3 + } >> ${untracked_patch} fi done