Bug 15541 - support/downloads/git generates deceptive archive of Linux repo
Summary: support/downloads/git generates deceptive archive of Linux repo
Status: RESOLVED MOVED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2020.02
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-12 19:54 UTC by Larry Gadallah
Modified: 2024-06-15 15:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Gadallah 2023-04-12 19:54:29 UTC
Given:
- Select a local commit ID/tag for the Linux kernel that does not exist in the local Linux kernel repo by setting BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION in the defconfig file
- Run a build

Expected behavior:
- Build should fail when expected commit ID/tag of the Linux kernel repo cannot be checked out

Observed behavior:
- Build does not fail when expected commit ID/tag of the Linux kernel repo cannot be checked out
- Build creates archive of Linux kernel repo in linux/linux-<commit ID>-br1.tar.gz
- Adding some instrumentation to the support/downloads/git script shows that the actual commit ID in the linux/linux-<commit ID>-br1.tar.gz file is the HEAD of the local Linux repo, not the (non-existent) commit ID requested
- Build proceeds and succeeds with the linux/linux-<commit ID>-br1.tar.gz file, with only a warning like this showing in the build log:

2023-03-15T11:45:24.9572834Z [7m>>> linux 0af534041cba4c33e540f6b31b73ce78f8326757 Downloading[27m
2023-03-15T11:45:25.0699794Z Reinitialized existing Git repository in /mnt/home/dl/linux/git/.git/
2023-03-15T11:45:25.1164499Z Fetching all references
2023-03-15T11:45:26.0788251Z Warning: Permanently added 'github.com,192.30.255.112' (ECDSA) to the list of known hosts.
2023-03-15T11:45:26.0788565Z 
2023-03-15T11:46:06.2456837Z warning: refname '0af534041cba4c33e540f6b31b73ce78f8326757' is ambiguous.
2023-03-15T11:46:06.2457533Z Git normally never creates a ref that ends with 40 hex characters
2023-03-15T11:46:06.2458253Z because it will be ignored when you just specify 40-hex. These refs
2023-03-15T11:46:06.2458834Z may be created by mistake. For example,
2023-03-15T11:46:06.2459109Z 
2023-03-15T11:46:06.2459403Z   git switch -c $br $(git rev-parse ...)
2023-03-15T11:46:06.2459683Z 
2023-03-15T11:46:06.2460022Z where "$br" is somehow empty and a 40-hex ref is created. Please
2023-03-15T11:46:06.2461804Z examine these refs and maybe delete them. Turn this message off by
2023-03-15T11:46:06.2462318Z running "git config advice.objectNameWarning false"
2023-03-15T11:47:54.3146989Z [7m>>> linux 0af534041cba4c33e540f6b31b73ce78f8326757 Extracting[27m

2023-03-15T11:47:54.3157663Z gzip -d -c /mnt/home/dl/linux/linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz | tar --strip-components=1 -C /mnt/work/output/r515_octane/build/linux-0af534041cba4c33e540f6b31b73ce78f8326757   -xf -
Comment 1 Larry Gadallah 2023-04-12 20:00:09 UTC
Adding a 'set -x' at the top and a 'git log -1' at the bottom of support/download/git yields the following, showing the issue explicitly:

>>> linux 0af534041cba4c33e540f6b31b73ce78f8326757 Downloading
+ . /mnt/work/buildroot/support/download/helpers
+ myname=/mnt/work/buildroot/support/download/git
+ OPTS=("${@}")
+ declare -a OPTS
+ verbose=
+ recurse=0
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ cset=0af534041cba4c33e540f6b31b73ce78f8326757
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ dl_dir=/mnt/home/dl/linux
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ basename=linux-0af534041cba4c33e540f6b31b73ce78f8326757
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ uri=git@github.com:impinj-octane/linux-kernel.git
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ case "${OPT}" in
+ output=/mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/output
+ getopts :hc:d:o:n:N:H:ru:qf:e OPT
+ shift 15
+ git_cache=/mnt/home/dl/linux/git
+ mkdir -p /mnt/home/dl/linux/git
+ pushd /mnt/home/dl/linux/git
+ trap _on_error ERR
+ cat
+ _git init .
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git init .
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git init .
Initialized empty Git repository in /mnt/home/dl/linux/git/.git/
+ _git remote
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git remote
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git remote
+ grep -q -E '^origin$'
+ _git remote add origin ''\''git@github.com:impinj-octane/linux-kernel.git'\'''
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git remote add origin ''\''git@github.com:impinj-octane/linux-kernel.git'\'''
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git remote add origin git@github.com:impinj-octane/linux-kernel.git
+ _git remote set-url origin ''\''git@github.com:impinj-octane/linux-kernel.git'\'''
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git remote set-url origin ''\''git@github.com:impinj-octane/linux-kernel.git'\'''
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git remote set-url origin git@github.com:impinj-octane/linux-kernel.git
+ printf 'Fetching all references\n'
Fetching all references
+ _git fetch origin
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git fetch origin
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git fetch origin
Warning: Permanently added 'github.com,192.30.255.113' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 8074633, done.
remote: Counting objects: 100% (65368/65368), done.
remote: Compressing objects: 100% (26591/26591), done.
remote: Total 8074633 (delta 44871), reused 50448 (delta 38657), pack-reused 8009265
Receiving objects: 100% (8074633/8074633), 1.52 GiB | 8.98 MiB/s, done.
Resolving deltas: 100% (6789454/6789454), done.
From github.com:impinj-octane/linux-kernel
 * [new branch]                PI-23091-new-kernel     -> origin/PI-23091-new-kernel
. . .
 * [new tag]                   v4.16.8                 -> v4.16.8
+ _git fetch origin -t
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git fetch origin -t
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git fetch origin -t
Warning: Permanently added the ECDSA host key for IP address '192.30.255.112' to the list of known hosts.
+ _git fetch origin ''\''0af534041cba4c33e540f6b31b73ce78f8326757:0af534041cba4c33e540f6b31b73ce78f8326757'\'''
+ _git rev-parse --quiet --verify ''\''0af534041cba4c33e540f6b31b73ce78f8326757^{commit}'\'''
+ cmd='printf "Deregistering submodule \"%s\"\n" "${path}" && cd .. && rm -rf "${path##*/}"'
+ _git submodule --quiet foreach ''\''printf "Deregistering submodule \"%s\"\n" "${path}" && cd .. && rm -rf "${path##*/}"'\'''
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git submodule --quiet foreach ''\''printf "Deregistering submodule \"%s\"\n" "${path}" && cd .. && rm -rf "${path##*/}"'\'''
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git submodule --quiet foreach 'printf "Deregistering submodule \"%s\"\n" "${path}" && cd .. && rm -rf "${path##*/}"'
+ _git checkout -f -q ''\''0af534041cba4c33e540f6b31b73ce78f8326757'\'''
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git checkout -f -q ''\''0af534041cba4c33e540f6b31b73ce78f8326757'\'''
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git checkout -f -q 0af534041cba4c33e540f6b31b73ce78f8326757
warning: refname '0af534041cba4c33e540f6b31b73ce78f8326757' is ambiguous.
Git normally never creates a ref that ends with 40 hex characters
because it will be ignored when you just specify 40-hex. These refs
may be created by mistake. For example,

  git switch -c $br $(git rev-parse ...)

where "$br" is somehow empty and a 40-hex ref is created. Please
examine these refs and maybe delete them. Turn this message off by
running "git config advice.objectNameWarning false"
+ _git clean -ffdx
+ eval GIT_DIR=/mnt/home/dl/linux/git/.git git clean -ffdx
++ GIT_DIR=/mnt/home/dl/linux/git/.git
++ git clean -ffdx
++ _git log -1 --pretty=format:%ci
++ eval GIT_DIR=/mnt/home/dl/linux/git/.git git log -1 --pretty=format:%ci
+++ GIT_DIR=/mnt/home/dl/linux/git/.git
+++ git log -1 --pretty=format:%ci
+ date='2022-12-16 15:50:20 +0000'
+ '[' 0 -eq 1 ']'
+ popd
+ git log -1
commit 80165e2cb123947637819792b6401e4b5bd96286 (HEAD)
Author: Lee Gillham <lgillham@impinj.com>
Date:   Fri Mar 3 16:12:08 2023 -0800

    rshell: Correctly report ProductionFused status

    - The ICTL library uses the script /usr/sbin/sb_status.sh and compares
      the output with "production", the buffer was too small. Increased size
      of the buffer to 11 (from 9) characters, so production + NULL would
      fit.

    PI-33597
+ mk_tar_gz /mnt/home/dl/linux/git linux-0af534041cba4c33e540f6b31b73ce78f8326757 '2022-12-16 15:50:20 +0000' /mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/output '.git/*'
+ local in_dir=/mnt/home/dl/linux/git
+ local base_dir=linux-0af534041cba4c33e540f6b31b73ce78f8326757
+ local 'date=2022-12-16 15:50:20 +0000'
+ local out=/mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/output
+ shift 4
+ local glob tmp pax_options
+ local -a find_opts
+ for glob in "$@"
+ find_opts+=(-or -path "./${glob#./}")
++ date -d '2022-12-16 15:50:20 +0000' -u +%Y-%m-%dT%H:%M:%S+00:00
+ date=2022-12-16T15:50:20+00:00
+ pax_options=delete=atime,delete=ctime,delete=mtime
+ pax_options+=',exthdr.name=%d/PaxHeaders/%f,exthdr.mtime={2022-12-16T15:50:20+00:00}'
+++ pwd
++ mktemp --tmpdir=/mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9
+ tmp=/mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/tmp.9pbn9R4HDp
+ pushd /mnt/home/dl/linux/git
+ find . -not -type d -and -not '(' -false -or -path './.git/*' ')'
+ LC_ALL=C
+ sort
+ tar cf - '--transform=s#^\./#linux-0af534041cba4c33e540f6b31b73ce78f8326757/#S' --numeric-owner --owner=0 --group=0 --mtime=2022-12-16T15:50:20+00:00 --format=posix '--pax-option=delete=atime,delete=ctime,delete=mtime,exthdr.name=%d/PaxHeaders/%f,exthdr.mtime={2022-12-16T15:50:20+00:00}' -T /mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/tmp.9pbn9R4HDp.sorted
+ gzip -6 -n
+ rm -f /mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/tmp.9pbn9R4HDp.list /mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/tmp.9pbn9R4HDp.sorted /mnt/work/output/r515_octane/build/.linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz.47D9n9/tmp.9pbn9R4HDp.tar
+ popd
>>> linux 0af534041cba4c33e540f6b31b73ce78f8326757 Extracting
gzip -d -c /mnt/home/dl/linux/linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz | tar --strip-components=1 -C /mnt/work/output/r515_octane/build/linux-0af534041cba4c33e540f6b31b73ce78f8326757   -xf -


Note that the file created, /mnt/home/dl/linux/linux-0af534041cba4c33e540f6b31b73ce78f8326757-br1.tar.gz has a name that implies that it is associated with commit ID 0af534041cba4c33e540f6b31b73ce78f8326757 but the commit of the repo that was archived is actually 80165e2cb123947637819792b6401e4b5bd96286 as shown by the 'git log -1' output.
Comment 2 Yann E. MORIN 2024-06-15 15:08:12 UTC
Thank you for your report.

The issue tracker for the Buildroot project has been moved to
the Gitlab.com issue tracker:
    https://gitlab.com/buildroot.org/buildroot/-/issues

We are taking this opportunity to close old issues in this old
tracker. If you believe your issue is still relevant, please
open one in the new issue tracker.

Thank you!