Skip to content

Commit

Permalink
Recreate tar
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinqian-db committed Oct 24, 2024
1 parent 41f7c6c commit 7e578a3
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion container/incremental_load.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ function guess_runfiles() {
popd > /dev/null 2>&1
}

function untar_and_retar_without_xattrs() {
# Parameters: original tarball and new tarball
local original_tarball="$1"
local new_tarball="$2"

# Create a temporary directory for untarring
local tmp_dir
tmp_dir=$(mktemp -d)

# Step 1: Untar the original tarball into the temporary directory
tar -xPf "${original_tarball}" -C "${tmp_dir}"

# Step 2: Remove extended attributes from all files in the extracted directory
find "${tmp_dir}" -exec xattr -c {} \;

# Step 3: Re-tar the files without xattrs
tar --no-xattrs -cPf "${new_tarball}" -C "${tmp_dir}" .

# Clean up the temporary directory
rm -rf "${tmp_dir}"

echo "!!! OLD SHA256: $(sha256sum "${original_tarball}" | cut -d' ' -f1), NEW SHA256: $(sha256sum "${new_tarball}" | cut -d' ' -f1)"
}


RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

DOCKER="${DOCKER:-docker}"
Expand Down Expand Up @@ -186,7 +211,8 @@ function import_config() {
# Only create the link if it doesn't exist.
# Only add files to MISSING once.
if [ ! -f "${diff_id}.tar" ]; then
cp "${layer}" "${diff_id}.tar"
untar_and_retar_without_xattrs "${layer}" "${diff_id}.tar"
# cp "${layer}" "${diff_id}.tar"
# ln -s "${layer}" "${diff_id}.tar"
# TEST TEST TEST
# chmod +w "${diff_id}.tar"
Expand Down

0 comments on commit 7e578a3

Please sign in to comment.