Skip to content

Conversation

boegel
Copy link
Contributor

@boegel boegel commented Jun 22, 2023

No description provided.

tar_first_file=$(tar tf "${tar_file}" | head -n 1)
tar_top_level_dir=$(echo "${tar_first_file}" | cut -d/ -f1)
tar_contents_type_dir=$(echo "${tar_first_file}" | head -n 2 | tail -n 1 | cut -d/ -f2)
tar_contents_type_dir=$(tar tf "${tar_file}" | head -n 2 | tail -n 1 | cut -d/ -f2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo ${tar_first_file} | head -n 2 doesn't make much sense, since ${tar_first_file} is guaranteed to only be a single line

For compat layer tarball, this happens to work:

$ tar tf eessi-2023.06-compat-linux-aarch64-1686750806.tar.gz | head -n 1
2023.06/compat/linux/aarch64/
$ tar tf eessi-2023.06-compat-linux-aarch64-1686750806.tar.gz | head -n 1 | head -n 2 | tail -n 1 | cut -d/ -f2
compat

Likewise for software tarballs:

$ tar tf eessi-2023.06-software-linux-aarch64-neoverse_n1-1687302831.tar.tar | head -n 1
2023.06/software/linux/aarch64/neoverse_n1/.lmod/lmodrc.lua
$ tar tf eessi-2023.06-software-linux-aarch64-neoverse_n1-1687302831.tar.tar | head -n 1 | head -n 2 | tail -n 1 | cut -d/ -f2
software

Doesn't work for init tarball created with create_directory_tarballs though:

$ tar tf eessi-2023.06-init-1687437311.tar.gz | head -n 1
2023.06/
[$ tar tf eessi-2023.06-init-1687437311.tar.gz | head -n 1 | head -n 2 | tail -n 1 | cut -d/ -f2

With the fix, it does work fine:

$ tar tf eessi-2023.06-init-1687437311.tar.gz | head -n 2 | tail -n 1 | cut -d/ -f2
init
$ tar tf eessi-2023.06-software-linux-aarch64-neoverse_n1-1687302831.tar.tar | head -n 2 | tail -n 1 | cut -d/ -f2
software
$ tar tf eessi-2023.06-compat-linux-aarch64-1686750806.tar.gz | head -n 2 | tail -n 1 | cut -d/ -f2
compat

Although avoiding the double use of tar tf makes sense, it doesn't matter too much, since it's a quick operation, even for large tarballs.

@boegel boegel requested a review from bedroge June 22, 2023 14:37
Copy link
Collaborator

@bedroge bedroge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@bedroge bedroge merged commit 3101cd6 into EESSI:main Jun 22, 2023
@boegel boegel deleted the fix_ingest_tarball_init branch June 22, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants