From patchwork Thu Feb 2 03:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 51660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp16584wrn; Wed, 1 Feb 2023 19:41:08 -0800 (PST) X-Google-Smtp-Source: AK7set+oINke2KjISpacnpT/UTDCyvgUhf0ByYExrQtxo2az8kW7H+dgatTSstHHAeOvjqZwC+h/ X-Received: by 2002:a17:906:f52:b0:84c:a065:d723 with SMTP id h18-20020a1709060f5200b0084ca065d723mr4679994ejj.44.1675309267895; Wed, 01 Feb 2023 19:41:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675309267; cv=none; d=google.com; s=arc-20160816; b=WQFOSxa93bsX30mdBLzJB4Cw46AcsdDGbGi6XUmqu51q437OvAHIPrvT4H+QQF/E+q fICx02syXl/gc+T3RCIdMTIkQo9SzUUE+jYrvf9nNVUYEcGRStX7XB+1n5ZuUsJrGH65 VON9M4oHIukhsaT3kJKnRMTohoUbsVgSZ2XvEXxUgvANH5434Fo9M+RRnPaRtGF/S64Q +y8VwJQb5pE5m3Vvg6+3DYb3GE1k6o6/HGaWrqLzZwMUAa9USTDL87Qne2l4sjiZn6dY 4Mj7+g759xE4D5EULabG0tOP7qA6DvtmEUBCbBEpeVGOte3Zd5uFgBXw8NACmgOJSs5y ohTQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eEC+o831dTJJ1VNjFwAsX3DeP23R2H29B+t3yfRkXd8=; b=iLIo+LkL30N4k6I6x/xdDHSkTaCtiK4MeqLf1HBdKprdjPKJ4xhhCm57Y97i7VBSyi ogOEYMO7f5A54JbDMAtGPGeUIgt1Xa+X/A7cXYJe4cZXEK7ZwOTqLsZpFeYFj49NbuFl 38DzyfsQQegSAdCpSViYXPrOSnCzBpvaDkAYc7XLS2YfeTntRpes5bm+z/kEQl5cG7Yt WzfAQfVjgWTp3/V881x8NsmTw+/mmT2lvx9FdqTZlz7D7BpUYRxfGsX9A4vjxbpxNXoE mQi/fVwvOeD/I9LgejVrCny37/nmrIoWTSEAhd2eJRzDtVP+cIss0k/nrAWT2Fq3Wl8L 7+jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pleWgAvn; 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 c20-20020a1709063f1400b0084d1a2c5a0asi7681634ejj.937.2023.02.01.19.40.20; Wed, 01 Feb 2023 19:41:07 -0800 (PST) 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=pleWgAvn; 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 S232123AbjBBDit (ORCPT + 99 others); Wed, 1 Feb 2023 22:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232036AbjBBDif (ORCPT ); Wed, 1 Feb 2023 22:38:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D74207C33B; Wed, 1 Feb 2023 19:38:27 -0800 (PST) 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 54A06619F6; Thu, 2 Feb 2023 03:38:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 379A1C433A0; Thu, 2 Feb 2023 03:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675309106; bh=KXuZfaeH7hMLScNzjw9KIjQhR6lHbbBdzM21WJPtsjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pleWgAvnIG67cOTdneIcBLnkr1Vww6FuxtCTfC61XwvN98DsxND2uVkSC7IKZDxB9 F2HBLiChX462E/zL16gsrX2WwQ/53kar1hijeuYX4kk8x6f5zLW4Q6kggiDVg33WPB HKLcE7Cv7ThUkiUKM/DsQ4SQfBkaMhVU98ILr0ZmqQZN4Yl2IBNFr2+HZCtXh8fa72 3KFLhllmRdU/KuZcqIORBXFwerkR+tCWMrSlztRRRq8qEjAtcpzLNfEphmMBrlTX6x 8UpInv0uLSNIhyyeMwYV9uruGwWETUnGs6qEKBak/nJNavYL2M3xbgYrGVKkASa6U2 4e/iVKffoNZwQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Ben Hutchings , Masahiro Yamada Subject: [PATCH v4 1/6] kbuild: add a tool to generate a list of files ignored by git Date: Thu, 2 Feb 2023 12:37:11 +0900 Message-Id: <20230202033716.341858-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202033716.341858-1-masahiroy@kernel.org> References: <20230202033716.341858-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756689090859453064?= X-GMAIL-MSGID: =?utf-8?q?1756689090859453064?= In short, the motivation of this commit is to build a source package without cleaning the source tree. The deb-pkg and (src)rpm-pkg targets first run 'make clean' before creating a source tarball. Otherwise build artifacts such as *.o, *.a, etc. would be included in the tarball. Yet, the tarball ends up containing several garbage files since 'make clean' does not clean everything. Cleaning the tree every time is annoying since it makes the incremental build impossible. It is desirable to create a source tarball without cleaning the tree. In fact, there are some ways to archive this. The easiest way is 'git archive'. Actually, 'make perf-tar*-src-pkg' does this way, but I do not like it because it works only when the source tree is managed by git, and all files you want in the tarball must be committed in advance. I want to make it work without relying on git. We can do this. Files that are not tracked by git are generated files. We can list them out by parsing the .gitignore files. Of course, .gitignore does not cover all the cases, but it works well enough. tar(1) claims to support it: --exclude-vcs-ignores Exclude files that match patterns read from VCS-specific ignore files. Supported files are: .cvsignore, .gitignore, .bzrignore, and .hgignore. The best scenario would be to use 'tar --exclude-vcs-ignores', but this option does not work. --exclude-vcs-ignore does not understand any of the negation (!), preceding slash, following slash, etc.. So, this option is just useless. Hence, I wrote this gitignore parser. The previous version [1], written in Python, was so slow. This version is implemented in C, so it works much faster. This tool traverses the source tree, parsing the .gitignore files. It prints the file paths that are not tracked by git. The output can be used for tar's --exclude-from= option. [How to test this tool] $ git clean -dfx $ make -s -j$(nproc) defconfig all # or allmodconifg or whatever $ git archive -o ../linux1.tar --prefix=./ HEAD $ tar tf ../linux1.tar | LANG=C sort > ../file-list1 # files emitted by 'git archive' $ make scripts_exclude HOSTCC scripts/gen-exclude $ scripts/gen-exclude --prefix=./ -o ../exclude-list $ tar cf ../linux2.tar --exclude-from=../exclude-list . $ tar tf ../linux2.tar | LANG=C sort > ../file-list2 # files emitted by 'tar' $ diff ../file-list1 ../file-list2 | grep -E '^(<|>)' < ./Documentation/devicetree/bindings/.yamllint < ./drivers/clk/.kunitconfig < ./drivers/gpu/drm/tests/.kunitconfig < ./drivers/gpu/drm/vc4/tests/.kunitconfig < ./drivers/hid/.kunitconfig < ./fs/ext4/.kunitconfig < ./fs/fat/.kunitconfig < ./kernel/kcsan/.kunitconfig < ./lib/kunit/.kunitconfig < ./mm/kfence/.kunitconfig < ./net/sunrpc/.kunitconfig < ./tools/testing/selftests/arm64/tags/ < ./tools/testing/selftests/arm64/tags/.gitignore < ./tools/testing/selftests/arm64/tags/Makefile < ./tools/testing/selftests/arm64/tags/run_tags_test.sh < ./tools/testing/selftests/arm64/tags/tags_test.c < ./tools/testing/selftests/kvm/.gitignore < ./tools/testing/selftests/kvm/Makefile < ./tools/testing/selftests/kvm/config < ./tools/testing/selftests/kvm/settings The source tarball contains most of files that are tracked by git. You see some diffs, but it is just because some .gitignore files are wrong. $ git ls-files -i -c --exclude-per-directory=.gitignore Documentation/devicetree/bindings/.yamllint drivers/clk/.kunitconfig drivers/gpu/drm/tests/.kunitconfig drivers/hid/.kunitconfig fs/ext4/.kunitconfig fs/fat/.kunitconfig kernel/kcsan/.kunitconfig lib/kunit/.kunitconfig mm/kfence/.kunitconfig tools/testing/selftests/arm64/tags/.gitignore tools/testing/selftests/arm64/tags/Makefile tools/testing/selftests/arm64/tags/run_tags_test.sh tools/testing/selftests/arm64/tags/tags_test.c tools/testing/selftests/kvm/.gitignore tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/config tools/testing/selftests/kvm/settings [1]: https://lore.kernel.org/all/20230128173843.765212-1-masahiroy@kernel.org/ Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier --- (no changes since v3) Changes in v3: - Various code refactoring: remove struct gitignore, remove next: label etc. - Support --extra-pattern option Changes in v2: - Reimplement in C Makefile | 4 + scripts/.gitignore | 1 + scripts/Makefile | 2 +- scripts/gen-exclude.c | 623 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 629 insertions(+), 1 deletion(-) create mode 100644 scripts/gen-exclude.c diff --git a/Makefile b/Makefile index 2faf872b6808..35b294cc6f32 100644 --- a/Makefile +++ b/Makefile @@ -1652,6 +1652,10 @@ distclean: mrproper %pkg: include/config/kernel.release FORCE $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ +PHONY += scripts_exclude +scripts_exclude: scripts_basic + $(Q)$(MAKE) $(build)=scripts scripts/gen-exclude + # Brief documentation of the typical targets used # --------------------------------------------------------------------------- diff --git a/scripts/.gitignore b/scripts/.gitignore index 6e9ce6720a05..7f433bc1461c 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only /asn1_compiler +/gen-exclude /generate_rust_target /insert-sys-cert /kallsyms diff --git a/scripts/Makefile b/scripts/Makefile index 32b6ba722728..5dcd7f57607f 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -38,7 +38,7 @@ HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED endif # The following programs are only built on demand -hostprogs += unifdef +hostprogs += gen-exclude unifdef # The module linker script is preprocessed on demand targets += module.lds diff --git a/scripts/gen-exclude.c b/scripts/gen-exclude.c new file mode 100644 index 000000000000..5c4ecd902290 --- /dev/null +++ b/scripts/gen-exclude.c @@ -0,0 +1,623 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Traverse the source tree, parsing all .gitignore files, and print file paths +// that are not tracked by git. +// The output is suitable to the --exclude-from option of tar. +// This is useful until the --exclude-vcs-ignores option gets working correctly. +// +// Copyright (C) 2023 Masahiro Yamada + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +// struct pattern - represent an ignore pattern (a line in .gitignroe) +// @negate: negate the pattern (prefixing '!') +// @dir_only: only matches directories (trailing '/') +// @path_match: true if the glob pattern is a path instead of a file name +// @double_asterisk: true if the glob pattern contains double asterisks ('**') +// @glob: glob pattern +struct pattern { + bool negate; + bool dir_only; + bool path_match; + bool double_asterisk; + char glob[]; +}; + +struct pattern **patterns; +static int nr_patterns, alloced_patterns; + +// Remember the number of patterns at each directory level +static int *nr_patterns_at; +// Track the current/max directory level; +static int depth, max_depth; +static bool debug_on; +static FILE *out_fp; +static char *prefix = ""; +static char *progname; + +static void __attribute__((noreturn)) perror_exit(const char *s) +{ + perror(s); + + exit(EXIT_FAILURE); +} + +static void __attribute__((noreturn)) error_exit(const char *fmt, ...) +{ + va_list args; + + fprintf(stderr, "%s: error: ", progname); + + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + + exit(EXIT_FAILURE); +} + +static void debug(const char *fmt, ...) +{ + va_list args; + int i; + + if (!debug_on) + return; + + fprintf(stderr, "[DEBUG]"); + + for (i = 0; i < depth * 2; i++) + fputc(' ', stderr); + + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); +} + +static void *xrealloc(void *ptr, size_t size) +{ + ptr = realloc(ptr, size); + if (!ptr) + perror_exit(progname); + + return ptr; +} + +static void *xmalloc(size_t size) +{ + return xrealloc(NULL, size); +} + +static char *xstrdup(const char *s) +{ + char *new = strdup(s); + + if (!new) + perror_exit(progname); + + return new; +} + +static bool simple_match(const char *string, const char *pattern) +{ + return fnmatch(pattern, string, FNM_PATHNAME) == 0; +} + +// Handle double asterisks ("**") matching. +// FIXME: +// This function does not work if double asterisks apppear multiple times, +// like "foo/**/bar/**/baz". +static bool double_asterisk_match(const char *path, const char *pattern) +{ + bool result = false; + int slash_diff = 0; + char *modified_pattern, *q; + const char *p; + size_t len; + + for (p = path; *p; p++) + if (*p == '/') + slash_diff++; + + for (p = pattern; *p; p++) + if (*p == '/') + slash_diff--; + + len = strlen(pattern) + 1; + + if (slash_diff > 0) + len += slash_diff * 2; + modified_pattern = xmalloc(len); + + q = modified_pattern; + for (p = pattern; *p; p++) { + if (!strncmp(p, "**/", 3)) { + // "**/" means zero of more sequences of '*/". + // "foo**/bar" matches "foobar", "foo*/bar", + // "foo*/*/bar", etc. + while (slash_diff-- > 0) { + *q++ = '*'; + *q++ = '/'; + } + + if (slash_diff == 0) { + *q++ = '*'; + *q++ = '/'; + } + + if (slash_diff < 0) + slash_diff++; + + p += 2; + } else if (!strcmp(p, "/**")) { + // A trailing "/**" matches everything inside. + while (slash_diff-- >= 0) { + *q++ = '/'; + *q++ = '*'; + } + + p += 2; + } else { + // Copy other patterns as-is. + // Other consecutive asterisks are considered regular + // asterisks. fnmatch() already handles them like that. + *q++ = *p; + } + } + + *q = '\0'; + + result = simple_match(path, modified_pattern); + + free(modified_pattern); + + return result; +} + +// Return true if the given path is ignored by git. +static bool is_ignored(const char *path, const char *name, bool is_dir) +{ + int i; + + // Search the patterns in the reverse order because the last matching + // pattern wins. + for (i = nr_patterns - 1; i >= 0; i--) { + struct pattern *p = patterns[i]; + + if (!is_dir && p->dir_only) + continue; + + if (!p->path_match) { + // If the pattern has no slash at the beginning or + // middle, it matches against the basename. Most cases + // fall into this and work well with double asterisks. + if (!simple_match(name, p->glob)) + continue; + } else if (!p->double_asterisk) { + // Unless the pattern has double asterisks, it is still + // simple but matches against the path instead. + if (!simple_match(path, p->glob)) + continue; + } else { + // Double asterisks with a slash. Complex, but rare. + if (!double_asterisk_match(path, p->glob)) + continue; + } + + debug("%s: matches %s%s%s\n", path, p->negate ? "!" : "", + p->glob, p->dir_only ? "/" : ""); + + return !p->negate; + } + + debug("%s: no match\n", path); + + return false; +} + +// Return the length of the initial segment of the string that does not contain +// the unquoted sequence of the given character. Similar to strcspn() in libc. +static size_t strcspn_trailer(const char *str, char c) +{ + bool quoted = false; + size_t len = strlen(str); + size_t spn = len; + const char *s; + + for (s = str; *s; s++) { + if (!quoted && *s == c) { + if (s - str < spn) + spn = s - str; + } else { + spn = len; + + if (!quoted && *s == '\\') + quoted = true; + else + quoted = false; + } + } + + return spn; +} + +// Add an gitignore pattern. +static void add_pattern(char *s, const char *dirpath) +{ + bool negate = false; + bool dir_only = false; + bool path_match = false; + bool double_asterisk = false; + char *e = s + strlen(s); + struct pattern *p; + size_t len; + + // Skip comments + if (*s == '#') + return; + + // Trailing spaces are ignored unless they are quoted with backslash. + e = s + strcspn_trailer(s, ' '); + *e = '\0'; + + // The prefix '!' negates the pattern + if (*s == '!') { + s++; + negate = true; + } + + // If there is slash(es) that is not escaped at the end of the pattern, + // it matches only directories. + len = strcspn_trailer(s, '/'); + if (s + len < e) { + dir_only = true; + e = s + len; + *e = '\0'; + } + + // Skip if the line gets empty + if (*s == '\0') + return; + + // Double asterisk is tricky. Mark it to handle it specially later. + if (strstr(s, "**/") || strstr(s, "/**")) + double_asterisk = true; + + // If there is a slash at the beginning or middle, the pattern + // is relative to the directory level of the .gitignore. + if (strchr(s, '/')) { + if (*s == '/') + s++; + path_match = true; + } + + len = e - s; + + // We need more room to store dirpath and '/' + if (path_match) + len += strlen(dirpath) + 1; + + p = xmalloc(sizeof(*p) + len + 1); + p->negate = negate; + p->dir_only = dir_only; + p->path_match = path_match; + p->double_asterisk = double_asterisk; + p->glob[0] = '\0'; + + if (path_match) { + strcat(p->glob, dirpath); + strcat(p->glob, "/"); + } + + strcat(p->glob, s); + + debug("Add pattern: %s%s%s\n", negate ? "!" : "", p->glob, + dir_only ? "/" : ""); + + if (nr_patterns >= alloced_patterns) { + alloced_patterns += 128; + patterns = xrealloc(patterns, + sizeof(*patterns) * alloced_patterns); + } + + patterns[nr_patterns++] = p; +} + +static void *load_gitignore(const char *dirpath) +{ + struct stat st; + char path[PATH_MAX], *buf; + int fd, ret; + + ret = snprintf(path, sizeof(path), "%s/.gitignore", dirpath); + if (ret >= sizeof(path)) + error_exit("%s: too long path was truncated\n", path); + + // If .gitignore does not exist in this directory, open() fails. + // It is ok, just skip it. + fd = open(path, O_RDONLY); + if (fd < 0) + return NULL; + + if (fstat(fd, &st) < 0) + perror_exit(path); + + buf = xmalloc(st.st_size + 1); + if (read(fd, buf, st.st_size) != st.st_size) + perror_exit(path); + + buf[st.st_size] = '\0'; + if (close(fd)) + perror_exit(path); + + return buf; +} + +// Parse '.gitignore' in the given directory. +static void parse_gitignore(const char *dirpath) +{ + char *buf, *s, *next; + + buf = load_gitignore(dirpath); + if (!buf) + return; + + debug("Parse %s/.gitignore\n", dirpath); + + for (s = buf; *s; s = next) { + next = s; + + while (*next != '\0' && *next != '\n') + next++; + + if (*next != '\0') { + *next = '\0'; + next++; + } + + add_pattern(s, dirpath); + } + + free(buf); +} + +// Save the current number of patterns and increment the depth +static void increment_depth(void) +{ + if (depth >= max_depth) { + max_depth += 1; + nr_patterns_at = xrealloc(nr_patterns_at, + sizeof(*nr_patterns_at) * max_depth); + } + + nr_patterns_at[depth] = nr_patterns; + depth++; +} + +// Decrement the depth, and free up the patterns of this directory level. +static void decrement_depth(void) +{ + depth--; + if (depth < 0) + error_exit("BUG\n"); + + while (nr_patterns > nr_patterns_at[depth]) + free(patterns[--nr_patterns]); +} + +// If we find an ignored path, print it. +static void print_path(const char *path) +{ + // The path always start with "./". If not, it is a bug. + if (strlen(path) < 2) + error_exit("BUG\n"); + + // Replace the root directory with the prefix you like. + // This is useful for the tar command. + fprintf(out_fp, "%s%s\n", prefix, path + 2); +} + +// Traverse the entire directory tree, parsing .gitignore files. +// Print file paths that are not tracked by git. +// +// Return true if all files under the directory are ignored, false otherwise. +static bool traverse_directory(const char *dirpath) +{ + bool all_ignored = true; + DIR *dirp; + + debug("Enter[%d]: %s\n", depth, dirpath); + increment_depth(); + + // We do not know whether .gitignore exists in this directory or not. + // Anyway, try to open it. + parse_gitignore(dirpath); + + dirp = opendir(dirpath); + if (!dirp) + perror_exit(dirpath); + + while (1) { + char path[PATH_MAX]; + struct dirent *d; + int ret; + + errno = 0; + d = readdir(dirp); + if (!d) { + // readdir() returns NULL on the end of the directory + // steam, and also on an error. To distinguish them, + // errno should be checked. + if (errno) + perror_exit(dirpath); + break; + } + + if (!strcmp(d->d_name, "..") || !strcmp(d->d_name, ".")) + continue; + + ret = snprintf(path, sizeof(path), "%s/%s", dirpath, d->d_name); + if (ret >= sizeof(path)) + error_exit("%s: too long path was truncated\n", path); + + if (is_ignored(path, d->d_name, d->d_type & DT_DIR)) { + debug("Ignore: %s\n", path); + print_path(path); + } else { + if ((d->d_type & DT_DIR) && !(d->d_type & DT_LNK)) { + if (!traverse_directory(path)) + all_ignored = false; + } else { + all_ignored = false; + } + } + } + + if (closedir(dirp)) + perror_exit(dirpath); + + // If all the files under this directory are ignored, let's ignore this + // directory as well in order to avoid empty directories in the tarball. + if (all_ignored) { + debug("Ignore: %s (due to all files inside ignored)\n", dirpath); + print_path(dirpath); + } + + decrement_depth(); + debug("Leave[%d]: %s\n", depth, dirpath); + + return all_ignored; +} + +// Register hard-coded ignore patterns. +static void add_fixed_patterns(void) +{ + const char * const fixed_patterns[] = { + ".git/", + }; + int i; + + for (i = 0; i < ARRAY_SIZE(fixed_patterns); i++) { + char *s = xstrdup(fixed_patterns[i]); + + add_pattern(s, "."); + free(s); + } +} + +static void usage(void) +{ + fprintf(stderr, + "usage: %s [options]\n" + "\n" + "Print files that are not ignored by git\n" + "\n" + "options:\n" + " -d, --debug print debug messages to stderr\n" + " -e, --extra-pattern PATTERN Add extra ignore patterns. This behaves like it is prepended to the top .gitignore\n" + " -h, --help show this help message and exit\n" + " -o, --output FILE output to a file (default: '-', i.e. stdout)\n" + " -p, --prefix PREFIX prefix added to each path (default: empty string)\n" + " -r, --rootdir DIR root of the source tree (default: current working directory):\n", + progname); +} + +int main(int argc, char *argv[]) +{ + const char *output = "-"; + const char *rootdir = "."; + + progname = strrchr(argv[0], '/'); + if (progname) + progname++; + else + progname = argv[0]; + + while (1) { + static struct option long_options[] = { + {"debug", no_argument, NULL, 'd'}, + {"extra-pattern", required_argument, NULL, 'e'}, + {"help", no_argument, NULL, 'h'}, + {"output", required_argument, NULL, 'o'}, + {"prefix", required_argument, NULL, 'p'}, + {"rootdir", required_argument, NULL, 'r'}, + {}, + }; + + int c = getopt_long(argc, argv, "de:ho:p:r:", long_options, NULL); + + if (c == -1) + break; + + switch (c) { + case 'd': + debug_on = true; + break; + case 'e': + add_pattern(optarg, "."); + break; + case 'h': + usage(); + exit(0); + case 'o': + output = optarg; + break; + case 'p': + prefix = optarg; + break; + case 'r': + rootdir = optarg; + break; + case '?': + usage(); + /* fallthrough */ + default: + exit(EXIT_FAILURE); + } + } + + if (chdir(rootdir)) + perror_exit(rootdir); + + if (strcmp(output, "-")) { + out_fp = fopen(output, "w"); + if (!out_fp) + perror_exit(output); + } else { + out_fp = stdout; + } + + add_fixed_patterns(); + + traverse_directory("."); + + if (depth != 0) + error_exit("BUG\n"); + + while (nr_patterns > 0) + free(patterns[--nr_patterns]); + free(patterns); + free(nr_patterns_at); + + fflush(out_fp); + if (ferror(out_fp)) + error_exit("not all data was written to the output\n"); + + if (fclose(out_fp)) + perror_exit(output); + + return 0; +} From patchwork Thu Feb 2 03:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 51657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp16504wrn; Wed, 1 Feb 2023 19:40:52 -0800 (PST) X-Google-Smtp-Source: AK7set97NXazTA1Ko4vLzKSf+Q2lrr5TLTXRBmwM0vHsXL36pEUWzSVzm3r8u2JiszABw7vY0pha X-Received: by 2002:a05:6402:1c0c:b0:49e:a174:329c with SMTP id ck12-20020a0564021c0c00b0049ea174329cmr3380251edb.36.1675309252812; Wed, 01 Feb 2023 19:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675309252; cv=none; d=google.com; s=arc-20160816; b=bP9kdTfhfOxTIrux3wC27DzK4rnepmiYZCvBIaW4td8GKJeR+mqwIjvG8tO6gFtGsy OV3OQbP/PUJjNioQEi7PL2WFq2ZRPgt03zeSojvnp/hR3tmu2WnGaozI7Ea1JEFSIJXu gzmd5bJFs6sYSoK+kIhdooyaTgVpWtnBM4+z6NcojSta5oVAUmMh5+P5Wy4WEB0fLFe5 /uXjHvVBzEJPpgGGXX1fNTeLexSIW/GNacLZu0AOwZvr4eknLg0cickFf3uiqxMICkSG pMPdPWZfL5DVthUA/RvUzhNz7/kU2/jIP6+syX3vz82FjNaO3OOnR/jAcl6gSEI7mWG6 HZ0A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3iudJKVE0ELL2WVQ9GcYN+CZKwhN1XXmjUT+efzkH4g=; b=Sxjuco95SyAbpCGJWqEFlJhJjy/kaB/hE3bH4KGqCLomM1pfVvkyxLManNCkXfcM33 qhacbewXlaxAqqrQc6YqlaB3fQcrkulFWEnJkvzleWku2dTUxD4iTOJkTlSh/9JV+BYe H5VVw1yctAL8sy36l9N46oL6HefuQ/POkn1drEd4tx6wvJWI2OxkWAqt9LB68cW9hTZ6 eJJ5YetM7d3RrBWu4Q8n/K+bGOJbw5vmOuhJ5jf7hthP8+4dhq6/MuwBLaooaavrJn6s pR779ldnK51ukBmOyZqdvZl8rbE0VdVmkerqgCqd0Bi0l9ohQRpX/UYWgFIDm+SOM7w2 1r+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bj1VfFc1; 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 e24-20020a50fb98000000b0047deaeaeb4fsi12128433edq.97.2023.02.01.19.40.28; Wed, 01 Feb 2023 19:40:52 -0800 (PST) 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=bj1VfFc1; 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 S232195AbjBBDjO (ORCPT + 99 others); Wed, 1 Feb 2023 22:39:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbjBBDii (ORCPT ); Wed, 1 Feb 2023 22:38:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C1F7B419; Wed, 1 Feb 2023 19:38:30 -0800 (PST) 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 A97BA619E5; Thu, 2 Feb 2023 03:38:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36ABBC433A1; Thu, 2 Feb 2023 03:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675309109; bh=q+FdDvjhNstlnFeTmy4laRxc/ZnBwhI+dZWJtjSZSRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bj1VfFc1j+hElkksF/9w6LutWhVo2oBLFKRb/8IKQApLk0OYGZBUwtt2I0OwwVF6p gV44yfhYiKp1+wcZWMhpr5FcrCmxlDPJj08C81saF6+S9v3WL0tb4VDgn5joWxOdSq 3+N8fXPpYLQ7UmL0vrZyaSF5VJs6TfaJAQVJ6ol5GxbAE0X+gVQHyDymNlILpl6s/H 8xJzGRjLeh4CsGw0ToHu6yXMx+ZNnpGj3p7XNDs4MmhOd2LVkhRQ2iJmU/M8EEIUEW /R+5nIvCDmEPrbbD72pfwBRlG9+Winl0Coo7FkX4Sa0wHCn0PO2qBX877Vi+/ssHpo 5Paxf8AGQ2vBQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Ben Hutchings , Masahiro Yamada , Tom Rix , llvm@lists.linux.dev Subject: [PATCH v4 2/6] kbuild: deb-pkg: create source package without cleaning Date: Thu, 2 Feb 2023 12:37:12 +0900 Message-Id: <20230202033716.341858-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202033716.341858-1-masahiroy@kernel.org> References: <20230202033716.341858-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756689074999586589?= X-GMAIL-MSGID: =?utf-8?q?1756689074999586589?= If you run 'make deb-pkg', all objects are lost due to 'make clean', which makes the incremental builds impossible. Instead of cleaning, pass the exclude list to tar's --exclude-from option. Previously, *.diff.gz contained some check-in files such as .clang-format, .cocciconfig. With this commit, *.diff.gz will only contain the .config and debian/. The other source files will go into the tarball. Signed-off-by: Masahiro Yamada --- Changes in v4: - Fix a typo in comment Changes in v3: - Add --extra-pattern='*.rej' - Exclude symlinks at the toplevel - Add --sort=name tar option scripts/Makefile.package | 38 +++++++++++++++++++++++++++++++++----- scripts/package/mkdebian | 25 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index dfbf40454a99..14567043a8af 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -50,6 +50,32 @@ fi ; \ tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) +# Source Tarball +# --------------------------------------------------------------------------- + +PHONY += gen-exclude +gen-exclude: + $(Q)$(MAKE) -f $(srctree)/Makefile scripts_exclude + +# - Commit 1f5d3a6b6532e25a5cdf1f311956b2b03d343a48 removed '*.rej' from +# .gitignore, but it is definitely a generated file. +# - The kernel tree has no symlink at the toplevel. If it does, it is a +# generated one. +quiet_cmd_exclude_list = GEN $@ + cmd_exclude_list = \ + scripts/gen-exclude --extra-pattern='*.rej' --prefix=./ --rootdir=$(srctree) > $@; \ + find . -maxdepth 1 -type l >> $@; \ + echo "./$@" >> $@ + +.exclude-list: gen-exclude + $(call cmd,exclude_list) + +quiet_cmd_tar = TAR $@ + cmd_tar = tar -I $(KGZIP) -c -f $@ -C $(srctree) --exclude-from=$< --exclude=./$@ --sort=name --transform 's:^\.:linux:S' . + +%.tar.gz: .exclude-list + $(call cmd,tar) + # rpm-pkg # --------------------------------------------------------------------------- PHONY += rpm-pkg @@ -81,12 +107,11 @@ binrpm-pkg: PHONY += deb-pkg deb-pkg: - $(MAKE) clean $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian - $(call cmd,src_tar,$(KDEB_SOURCENAME)) - origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ - mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz - +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) --source-option=-sP -i.git -us -uc + $(Q)origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ + $(MAKE) -f $(srctree)/scripts/Makefile.package ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz + +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \ + --build=source,binary --source-option=-sP -nc -us -uc PHONY += bindeb-pkg bindeb-pkg: @@ -174,4 +199,7 @@ help: @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball' @echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball' +PHONY += FORCE +FORCE: + .PHONY: $(PHONY) diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index c3bbef7a6754..2f612617cbcf 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -84,6 +84,8 @@ set_debarch() { fi } +rm -rf debian + # Some variables and settings used throughout the script version=$KERNELRELEASE if [ -n "$KDEB_PKGVERSION" ]; then @@ -135,6 +137,29 @@ fi mkdir -p debian/source/ echo "1.0" > debian/source/format +# Ugly: ignore anything except .config or debian/ +# (is there a cleaner way to do this?) +cat<<'EOF' > debian/source/local-options +diff-ignore + +extend-diff-ignore = ^[^.d] + +extend-diff-ignore = ^\.[^c] +extend-diff-ignore = ^\.c($|[^o]) +extend-diff-ignore = ^\.co($|[^n]) +extend-diff-ignore = ^\.con($|[^f]) +extend-diff-ignore = ^\.conf($|[^i]) +extend-diff-ignore = ^\.confi($|[^g]) +extend-diff-ignore = ^\.config. + +extend-diff-ignore = ^d($|[^e]) +extend-diff-ignore = ^de($|[^b]) +extend-diff-ignore = ^deb($|[^i]) +extend-diff-ignore = ^debi($|[^a]) +extend-diff-ignore = ^debia($|[^n]) +extend-diff-ignore = ^debian[^/] +EOF + echo $debarch > debian/arch extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)" extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)" From patchwork Thu Feb 2 03:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 51659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp16560wrn; Wed, 1 Feb 2023 19:41:04 -0800 (PST) X-Google-Smtp-Source: AK7set/HQLwJhCxO2VBKFMWC74IVu7zyK3jCcCMs2r18nleq0fEdzMjPRmKcK5CGj7q6L30abRqf X-Received: by 2002:a17:906:8a43:b0:861:4671:a834 with SMTP id gx3-20020a1709068a4300b008614671a834mr4038463ejc.71.1675309264404; Wed, 01 Feb 2023 19:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675309264; cv=none; d=google.com; s=arc-20160816; b=VEgKiuaTAP4uGxTtk6YL+9vC+MYwJgWzSDF4M13yt7Ws1QzCi91bzYtnucs+axuxI2 0x+mniifarTZuvQUusnz7T0ZYbl4KqxQOIMO/aY3kGE0sP+rGjzP7v9ZQobYkgMK6r0r Ll/QX2atbdA8+DHWOQne9lQXtcBnvqgPuayKeR7FW2wHbJ9KRXvUAe9EhdGPBS8NpErk lS/qXFY0eP4kkDYwSQ39sMG1xHZbe1nwuNPBX4VzGiy7fEkt4EY7xRsSUbzj9Buylqf+ qgCbCAlaMesyNxXJX8WWFdN+EkIoK7oEIGwrlXATWJ+GOxy7MK8U3pqoh9Khz65dKYyp AeJg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=af+Lmnamyq+Vj0QJs2upLmb2NKkykGxYDkgtqG/HDbc=; b=aIF9Dn1zRS6jmcTaP1eOP+QXa0tZqj0iV/zTCWXInR+Gg6bEuXbBrrkyjvkmAKuUVX GvhoIVASGE2oIeAdhx36nFHGu4GmkfbfTrAi2ENEjDCtwpQKEfF8QHklYIHoXkXccAv+ gPif6gpGcNhrBgBEG96kBh+sINviuYHQ1Uuuimfu8amd7HeqrrPbqltAF4ZWBz0OYgfP zgYxK11uRKoj6WPwrQJALMlbmfwUHdbn3lWHa9Dxdzpil1Sy//Dp8vv8IIA0rGkcY0FN PR3PH+DUf+PlyrTldr5u8C7yXh3yHU6/9RXbJrmnSUbdzvDPbjUcz0RBP1MeoYQ20fL+ YJ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YoJXVmAe; 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 c23-20020a17090620d700b008844ab9c163si17832995ejc.440.2023.02.01.19.40.41; Wed, 01 Feb 2023 19:41:04 -0800 (PST) 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=YoJXVmAe; 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 S232153AbjBBDj3 (ORCPT + 99 others); Wed, 1 Feb 2023 22:39:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232145AbjBBDi4 (ORCPT ); Wed, 1 Feb 2023 22:38:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89CC37CC8E; Wed, 1 Feb 2023 19:38:33 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 33226B823F3; Thu, 2 Feb 2023 03:38:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DC52C433D2; Thu, 2 Feb 2023 03:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675309110; bh=x0KTKr8AWX5SJ12jjijewRor4FwBC86L1vP2JGQb2o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YoJXVmAeUENsU+fdPArOWx1wGbKJxv8AOK4KsFllmQF6NK4cmlVHyXF4/I/7PCIrb WqolRgbtNIEHgUFEndVLULWcGhKqg0wMwWglvnJu9nirUN7qHXR+cEO9c48Klm0SNb +1w1lPHn6j22lUSowZ6WsFbQOoDCxXQcX5HcaYVLWzT3/aypkgdDah+TdanUiLs6D9 atVdLiY44t7/AEuOItP12lt3QPhekv0Or1INO5q61wYlK/cjHtmBSjXr0fxURkiieF QKz5CFNiMF1IMNN2SeAyXGKdt470nTp2XAgO6ss7FV0yzgaULklCwk8WFq8LRgYsYZ 7oAuDQhL0j7OQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Ben Hutchings , Masahiro Yamada Subject: [PATCH v4 3/6] kbuild: rpm-pkg: build binary packages from source rpm Date: Thu, 2 Feb 2023 12:37:13 +0900 Message-Id: <20230202033716.341858-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202033716.341858-1-masahiroy@kernel.org> References: <20230202033716.341858-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756689087333322497?= X-GMAIL-MSGID: =?utf-8?q?1756689087333322497?= The build rules of rpm-pkg and srcrpm-pkg are almost the same. Remove the code duplication. Change rpm-pkg to build binary packages from the source package generated by srcrpm-pkg. This changes the output directory of the srpm generated by 'make rpm-pkg' because srcrpm-pkg overrides _srcrpmdir. Signed-off-by: Masahiro Yamada --- (no changes since v3) Changes in v3: - Explain that the source package location will be changed. scripts/Makefile.package | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 14567043a8af..ebf3db81b994 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -79,11 +79,9 @@ quiet_cmd_tar = TAR $@ # rpm-pkg # --------------------------------------------------------------------------- PHONY += rpm-pkg -rpm-pkg: - $(MAKE) clean - $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec - $(call cmd,src_tar,$(KERNELPATH),kernel.spec) - +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \ +rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec) +rpm-pkg: srcrpm-pkg + +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \ --define='_smp_mflags %{nil}' # srcrpm-pkg From patchwork Thu Feb 2 03:37:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 51663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp17135wrn; Wed, 1 Feb 2023 19:42:57 -0800 (PST) X-Google-Smtp-Source: AK7set/J6LfbcGUDKKfyXc4LJ8vlKO/b/9X0d/W489tW3c+np5d89uhF/SyVg/AireFwAiNpS5Ti X-Received: by 2002:a05:6402:5295:b0:4a2:3637:5be2 with SMTP id en21-20020a056402529500b004a236375be2mr4395377edb.39.1675309377209; Wed, 01 Feb 2023 19:42:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675309377; cv=none; d=google.com; s=arc-20160816; b=z747O4Zhyl2dJUoXJBDsOmVHBoVLCnKHm49eFHVld7oRdlommYzs+1V1++DMGYezb5 uMBh7p6hDUj/l5paB3dRQJeXBIPD+r6fay4CMyYcoab3oHlNPSF4i2mnRG2u7qRj9Bcr Ea1UAbt0SvHNCL0mnPqJ129BeFMPS0KfOI493Mrppjgoohesub0NjsVS+njZcavdU/SL 8tzAUZ0TjqzbsJ7Lxk/xqZg+NLxVxBVToMlxyYAV0zS9KM18j67Y9ynF0cJ6Ovg5UugM 9uKHcEgqu4OnVBozO4TS16Y7nF6t2Q1FQnt3O8QjOeHX08UR7gfol4Oq0q1btLLvvyxM U8Bg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z1egM9lXLaVI6SWp1XVjkt1LmgC+pwHseAm9oWTNOqQ=; b=FHvO0gdmHddSaRGjxD9cxHMu1elCNhWEwsLGPIZuzAD6jUzKAPW3qFQplnAM0jkDZf t/Bi1/6+9YYI/z5fJR+zVuGdBOUDauS8r+CSseihzp/+d6oIT3Hd+FjSh1bpJQ7Q4kDw 2G/4kBUubTmut1sGLu/noVGLAEKJIxTlr3MkjKDMLWBDEdnpmaZImc85z8t/trBmajeE cR6r8EO72yyqNV6PnujPbjA11JgYmi6zRpgncsKrb2MhMGRq7sSN28kcbzILc7SF07cV fgfI1brr+4xVkRUn5thBouBytRpxD7Rcs4eMOxbAkjFnPQjZ2yn9jVH6/0lBXN2ZMlEF 3KgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YbddWuwl; 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 j3-20020a170906104300b0088de3d552e0si4715498ejj.859.2023.02.01.19.42.33; Wed, 01 Feb 2023 19:42:57 -0800 (PST) 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=YbddWuwl; 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 S232282AbjBBDji (ORCPT + 99 others); Wed, 1 Feb 2023 22:39:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbjBBDjL (ORCPT ); Wed, 1 Feb 2023 22:39:11 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF247BBDF; Wed, 1 Feb 2023 19:38:35 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 068ECB823F4; Thu, 2 Feb 2023 03:38:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E279C4339B; Thu, 2 Feb 2023 03:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675309112; bh=AUM4G/NznoutwHp2zakKErj/+py6ZVYqFif0aaYonoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YbddWuwlrwf6dZveTVYnfBrks8e4vES4xJI2PEttABMEZbBxaP57tHYqmfJ1zpB0D 2VpawxhMYAi8Otd8a8YCDTT51tIkFDdZP+Cq8gmRxsAs61ulKY8xwMmxwKt4v8uye8 JvrEWrFNsP3my4OXTZj/fjRYboQ4ZARU24q2M8Rw1f7gD1jiybOUNoSfnJIxoKFxui Nlc31P9ec2qjGq9AjWubzYewaI/4NBlr0njpKELIkfnxZV0EsFfRv/xaYOL8Q/z1IT J1nXP6H9zd5Lm9xY7k6G+EomVqjFgcZ1T+XulbQno8UOWmIwBv3PD8+CB5cVRJkB4h dT1rQBPSUQE8A== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Ben Hutchings , Masahiro Yamada Subject: [PATCH v4 4/6] kbuild: srcrpm-pkg: create source package without cleaning Date: Thu, 2 Feb 2023 12:37:14 +0900 Message-Id: <20230202033716.341858-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202033716.341858-1-masahiroy@kernel.org> References: <20230202033716.341858-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756689205795856153?= X-GMAIL-MSGID: =?utf-8?q?1756689205795856153?= If you run 'make (src)rpm-pkg', all objects are lost due to 'make clean', which makes the incremental builds impossible. Instead of cleaning, pass the exclude list to tar's --exclude-from option. Previously, the .config was contained in the source tarball. With this commit, the source rpm consists of separate linux.tar.gz and .config. Remove stale comments. Now, 'make (src)rpm-pkg' works with O= option. Signed-off-by: Masahiro Yamada --- Changes in v4: - Do not delete the old tar command because it is still used by snap-pkg although snap-pkg is broken, and it does not work at all. scripts/Makefile.package | 29 +++-------------------------- scripts/package/mkspec | 8 ++++---- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index ebf3db81b994..6732632a0259 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -3,27 +3,6 @@ include $(srctree)/scripts/Kbuild.include -# RPM target -# --------------------------------------------------------------------------- -# The rpm target generates two rpm files: -# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm -# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1..rpm -# The src.rpm files includes all source for the kernel being built -# The .rpm includes kernel configuration, modules etc. -# -# Process to create the rpm files -# a) clean the kernel -# b) Generate .spec file -# c) Build a tar ball, using symlink to make kernel version -# first entry in the path -# d) and pack the result to a tar.gz file -# e) generate the rpm files, based on kernel.spec -# - Use /. to avoid tar packing just the symlink - -# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT, -# but the binrpm-pkg target can; for some reason O= gets ignored. - -# Remove hyphens since they have special meaning in RPM filenames KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) KDEB_SOURCENAME ?= linux-upstream KBUILD_PKG_ROOTCMD ?="fakeroot -u" @@ -87,12 +66,10 @@ rpm-pkg: srcrpm-pkg # srcrpm-pkg # --------------------------------------------------------------------------- PHONY += srcrpm-pkg -srcrpm-pkg: - $(MAKE) clean +srcrpm-pkg: linux.tar.gz $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec - $(call cmd,src_tar,$(KERNELPATH),kernel.spec) - +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ts $(KERNELPATH).tar.gz \ - --define='_smp_mflags %{nil}' --define='_srcrpmdir $(srctree)' + +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \ + --define='_smp_mflags %{nil}' --define='_sourcedir .' --define='_srcrpmdir .' # binrpm-pkg # --------------------------------------------------------------------------- diff --git a/scripts/package/mkspec b/scripts/package/mkspec index 108c0cb95436..83a64d9d7372 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -47,7 +47,8 @@ sed -e '/^DEL/d' -e 's/^\t*//' < X-Patchwork-Id: 51664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp17689wrn; Wed, 1 Feb 2023 19:44:42 -0800 (PST) X-Google-Smtp-Source: AK7set8lEI2leoTTqRlnrdLeWdn8id2y9p5OJV1sJswT3LuX4XQK2tngXfN5eAV4SYD28WOiJOxh X-Received: by 2002:a17:906:bcf6:b0:84d:4493:c83f with SMTP id op22-20020a170906bcf600b0084d4493c83fmr4954123ejb.6.1675309482143; Wed, 01 Feb 2023 19:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675309482; cv=none; d=google.com; s=arc-20160816; b=pM5ny2yVhudc4BTr9DXfjP8okjxr6hANq7HdDD1eZmSBP3dhD8mGwJZy3gMwQtG//P EAeNDT0e+hUfllGFHgTTdvBLfb3c9W1x1nfIqw3vfD0K2OPeLymZ452rmiRn07gKFRka GdfnyGZ6aoaJ+l0V3e8SM4DEq6oREppQ7H0rqQEVWlbbL145OqqmvlR3XzkrQ4cFwTQq AxMXIpnR6zWAdurQeG39oqNNDVzmft89RDIN2N2yZlyn2LlwH6swN/R2wQeQfPMdYJu/ eP6nwRQkz4sC6B29dcOUCSL2amhTbsBFjVoEB1+WW3SfHYOVANsitdXF3FlP8r1/4bMN +XqQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1NRcB3mNqqbpJ2TiINLFoboCBAGpezm1LcHP4p9TrY4=; b=PrDTtzGTQjrH/V5l4h/MfBKlpXOXOxjG03eVPU6pt7QxsPsYXxSUOvqi6TV7zKj0k9 mt6xIagLY4wwmw9anec9GDgS71ewox+bygBXr36t2lXIN7d3ElVlAShjXMTe4mXkdDhr /CWFjKkHUc9m3j0W380cu0axfbXJzXwyqY5HiUVG1XmU0PccXwTBZCsyPZGC4SyMPtcG oq0N58WOwc6KZMNz1j9GnR7l30VcXKgsFCB2iwtH3DuyVHR7Cm2gqiEK1oO6RzOQR70d inuOcrmjRjdOz+RONepgksllgfE5JIKLEDLYtabu+ocxDRs5rRmdCu4QcQO+0tevmFVw oYdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=arcnWMp7; 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 17-20020a170906019100b00886f6e734a1si16797136ejb.16.2023.02.01.19.44.16; Wed, 01 Feb 2023 19:44:42 -0800 (PST) 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=arcnWMp7; 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 S232041AbjBBDk0 (ORCPT + 99 others); Wed, 1 Feb 2023 22:40:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbjBBDjM (ORCPT ); Wed, 1 Feb 2023 22:39:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B99107BE52; Wed, 1 Feb 2023 19:38:35 -0800 (PST) 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 3D47E619AB; Thu, 2 Feb 2023 03:38:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28117C433A1; Thu, 2 Feb 2023 03:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675309114; bh=JOstGkfwG8D5eh52wwoTtq8OkUqGBqYqmVGY1qdUjgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=arcnWMp7qxSPT3213lprYFMZ8g3ZRO/RMXCW+6sLDXTLfbJVWMsOTy3HrYfyK08La aqVYDAjD6qqMVrQFqdA81wQhu7+CB3Vj0f9OPn0JdShDjWQ+zL+Dbe5MsYlZ6NZhh5 6ZvDuPuk5i6XJyVXp2SzxsFvF3aUQ/0jkJ6dkoeX5ZVoN2TnEmWj5hjjpHKRebEJ00 Bapqokhe5WfJsiLuCknY1RAFjBaPlIdJYhoL7xjq/thdnKoqjQnZeBhKWkVMrzxX5A tOKjM00RdTXbQpmosGnsm6UvmcdpUzLTYOVGh4NopOMSMiKlBpzUnxa1PivuKBKTJp Lo2PrwLYOeblg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Ben Hutchings , Masahiro Yamada Subject: [PATCH v4 5/6] kbuild: deb-pkg: hide KDEB_SOURCENAME from Makefile Date: Thu, 2 Feb 2023 12:37:15 +0900 Message-Id: <20230202033716.341858-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202033716.341858-1-masahiroy@kernel.org> References: <20230202033716.341858-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756689315677744913?= X-GMAIL-MSGID: =?utf-8?q?1756689315677744913?= scripts/Makefile.package does not need to know the value of KDEB_SOURCENAME because the source name can be taken from debian/changelog by using dpkg-parsechangelog. Move the default of KDEB_SOURCENAME (i.e. linux-upstream) to scripts/package/mkdebian. Signed-off-by: Masahiro Yamada --- (no changes since v3) Changes in v3: - Move cmd_debianize Changes in v2: - New patch scripts/Makefile.package | 23 +++++++++++++++-------- scripts/package/mkdebian | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 6732632a0259..5135a5419a72 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -4,9 +4,7 @@ include $(srctree)/scripts/Kbuild.include KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) -KDEB_SOURCENAME ?= linux-upstream KBUILD_PKG_ROOTCMD ?="fakeroot -u" -export KDEB_SOURCENAME # Include only those top-level files that are needed by make, plus the GPL copy TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \ include init io_uring ipc kernel lib mm net rust \ @@ -80,17 +78,26 @@ binrpm-pkg: +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec +quiet_cmd_debianize = GEN $@ + cmd_debianize = $(srctree)/scripts/package/mkdebian + +PHONY += debian +debian: + $(call cmd,debianize) + +PHONY += debian-tarball +debian-tarball: source = $(shell dpkg-parsechangelog -S Source) +debian-tarball: orig-version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//') +debian-tarball: debian + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package ../$(source)_$(orig-version).orig.tar.gz + PHONY += deb-pkg -deb-pkg: - $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian - $(Q)origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ - $(MAKE) -f $(srctree)/scripts/Makefile.package ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz +deb-pkg: debian-tarball +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \ --build=source,binary --source-option=-sP -nc -us -uc PHONY += bindeb-pkg -bindeb-pkg: - $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian +bindeb-pkg: debian +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc PHONY += intdeb-pkg diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index 2f612617cbcf..0c1ed6215a02 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -95,7 +95,7 @@ else revision=$($srctree/init/build-version) packageversion=$version-$revision fi -sourcename=$KDEB_SOURCENAME +sourcename=${KDEB_SOURCENAME:-linux-upstream} if [ "$ARCH" = "um" ] ; then packagename=user-mode-linux From patchwork Thu Feb 2 03:37:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 51668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp26536wrn; Wed, 1 Feb 2023 20:11:07 -0800 (PST) X-Google-Smtp-Source: AK7set/EWzTuo073jYIKsNFFSqwSflRnqchM5IJkH4AwAKU81ItsSpIl1aEiZEqx8AQ8gZ0oqDvk X-Received: by 2002:a17:902:db0c:b0:192:751c:6e8d with SMTP id m12-20020a170902db0c00b00192751c6e8dmr5312430plx.58.1675311067441; Wed, 01 Feb 2023 20:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675311067; cv=none; d=google.com; s=arc-20160816; b=JcSudJQlsg/VpFHiEUpX85EQ/penUCyizom4C0J6eSqY5fAGtKDrZd1cUjprSA7z8/ 7YfGu0STpZKlUM712naZW+hLdf94gSWPamfR2YTLbI93rIrsorvCr4Te3AUGqOHMFJqf fDtNUsKlMaHfIyHfF0GxgWeTw7eb9u8OdpCJLDEcK9VL5fq3a5NU73Yn12DjYMeSiBav +7A9HRxBj5KP2H9DTWOfy0x1cJUWHMMVMGI9y8wJwJDebSWf3dYlXDA8dCs2qzSXb6Rv LvZmUvSfyGXblNuxMXpv9YHf4Xwyx4dUqlVWwytOPrOnFm2LCfOrlaOkbXo4UsS5BpWQ vnNw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UzM9vGYT3KDydrH7yF6tZsPbgwRMDZ7wM+1r6yWkQDY=; b=q8b2YSupfwy3QaXdVmVsQ8cVbdOt+4hINGUYw3tUJ+lOXTgtiZcJ4kKFR/7SeDtAH7 5dY12TY/r3/b9IQ0NqoEp0lvYRqxcIzp/NOOQlhDxcBHwgAhrMCHK5ut4zDoDxf32efd Dy+37MuGDDdtLdBZO24t17IkXkyyC/oPu9EnVzgBTHd2PXUMCEeABYHqMIB6eR9y59aq XEddBk2hLCpwWGjNCFxKScq1Bw0lBU5+qv/l2O0WiZvyhYHvljoh9AKuZJWS9JNMkVSM rgy8NSPglSoA9ahdft6llRVCTaXfMaxNOAnmxDjb3aAkgEnZEGpzOaHLO8C0NGKlt7Hw sGSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CZ4TYa3h; 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 l10-20020a170903120a00b0017a0e7aaf6bsi24652933plh.128.2023.02.01.20.10.54; Wed, 01 Feb 2023 20:11:07 -0800 (PST) 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=CZ4TYa3h; 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 S232135AbjBBDki (ORCPT + 99 others); Wed, 1 Feb 2023 22:40:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232190AbjBBDjO (ORCPT ); Wed, 1 Feb 2023 22:39:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC27D7D6DD; Wed, 1 Feb 2023 19:38:37 -0800 (PST) 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 2C176619E8; Thu, 2 Feb 2023 03:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B21EC433A0; Thu, 2 Feb 2023 03:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675309116; bh=q+6WIWIgdV8iv/IIa/6uMtSiTo1opal/OruDUNHzygM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CZ4TYa3hUVo//cGVT9wCIRN2RIiYwn5/BzvtUZde6EmRCfxXZXGUE4WRlhid8/OmH kUXkmEIEgknC0wbPaqndPoLt1lbtMxLxapwMzxdmA10uL39DqHn5kPbkExo5NT1w1s ha8PernNgJKGazEzqLWghxhVjbv68JXxl8rwZ9kEUQ+i4l4guiWmin9pN5C5B51Oqp M9cgwx6s+pmCqvyp9gWnx4YzpKd5T4bclV1MbOqgryUaNfKHkSKg9mmKPh4l16p9zj pqFEewShOzO+L+0eUOUrjKrS4lfj2gBr3aN/06t+9i+h0WKNDigiY9/MHWP/21TLAZ HbUluvTgY8vfw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Ben Hutchings , Masahiro Yamada Subject: [PATCH v4 6/6] kbuild: deb-pkg: switch over to format 3.0 (quilt) Date: Thu, 2 Feb 2023 12:37:16 +0900 Message-Id: <20230202033716.341858-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202033716.341858-1-masahiroy@kernel.org> References: <20230202033716.341858-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756690977633617201?= X-GMAIL-MSGID: =?utf-8?q?1756690977633617201?= Switch from "1.0" to "3.0 (quilt)" because it works more cleanly. All files except .config and debian/ go into the .orig tarball. You can add a single patch, debian/patches/config, and delete the ugly extend-diff-ignore patterns. The debian tarball will be compressed into *.debian.tar.xz by default. If you like to use a different compression mode, you can pass the command line option, DPKG_FLAGS=-Zgzip, for example. The .orig tarball only supports gzip for now. The combination of gzip and xz is somewhat clumsy, but it is not a practical problem. Signed-off-by: Masahiro Yamada --- Changes in v4: - New patch scripts/Makefile.package | 2 +- scripts/package/mkdebian | 42 +++++++++++++++++----------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 5135a5419a72..454268a37af1 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -94,7 +94,7 @@ debian-tarball: debian PHONY += deb-pkg deb-pkg: debian-tarball +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \ - --build=source,binary --source-option=-sP -nc -us -uc + --build=source,binary -nc -us -uc PHONY += bindeb-pkg bindeb-pkg: debian diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index 0c1ed6215a02..1ab4c6ee76d9 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -135,30 +135,24 @@ else fi mkdir -p debian/source/ -echo "1.0" > debian/source/format - -# Ugly: ignore anything except .config or debian/ -# (is there a cleaner way to do this?) -cat<<'EOF' > debian/source/local-options -diff-ignore - -extend-diff-ignore = ^[^.d] - -extend-diff-ignore = ^\.[^c] -extend-diff-ignore = ^\.c($|[^o]) -extend-diff-ignore = ^\.co($|[^n]) -extend-diff-ignore = ^\.con($|[^f]) -extend-diff-ignore = ^\.conf($|[^i]) -extend-diff-ignore = ^\.confi($|[^g]) -extend-diff-ignore = ^\.config. - -extend-diff-ignore = ^d($|[^e]) -extend-diff-ignore = ^de($|[^b]) -extend-diff-ignore = ^deb($|[^i]) -extend-diff-ignore = ^debi($|[^a]) -extend-diff-ignore = ^debia($|[^n]) -extend-diff-ignore = ^debian[^/] -EOF +echo "3.0 (quilt)" > debian/source/format + +{ + echo "diff-ignore" + echo "extend-diff-ignore = .*" +} > debian/source/local-options + +# Add .config as a patch +mkdir -p debian/patches +{ + echo "Subject: Add .config" + echo "Author: ${maintainer}" + echo + echo "--- /dev/null" + echo "+++ linux/.config" + diff -u /dev/null .config | tail -n +3 +} > debian/patches/config +echo config > debian/patches/series echo $debarch > debian/arch extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)"