Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale dependent behaviour #132

Open
fanfan70 opened this issue Mar 29, 2024 · 2 comments
Open

Locale dependent behaviour #132

fanfan70 opened this issue Mar 29, 2024 · 2 comments

Comments

@fanfan70
Copy link

For another issue (#125), I've written a test script.
Thank for the answer by the way!
I've fixed it and now I see a problem linked to configured language: I use a french environment, in which I get this error (run without argument, see script below) while committing:

+ ratarmount --commit-overlay --write-overlay /tmp/overlay /tmp/example.tar /tmp/mnt
To commit the overlay folder to the archive, these commands have to be executed:

    tar --delete --null --verbatim-files-from --files-from='/tmp/tmplvgbnz0o/deletions.lst' \
        --file '/tmp/example.tar' 2>&1 |
       sed '/^tar: Exiting with failure/d; /^tar.*Not found in archive/d'
    tar --append -C '/tmp/overlay' --null --verbatim-files-from --files-from='/tmp/tmplvgbnz0o/append.lst' --file '/tmp/example.tar'

Committing is an experimental feature!
Please confirm by entering "commit". Any other input will cancel.
> tar: file2 : non trouvé dans l'archive
tar: /file2 : non trouvé dans l'archive
tar: ./file2 : non trouvé dans l'archive
tar: Arrêt avec code d'échec à cause des erreurs précédentes
[Error] There were problems when trying to delete files.

"non trouvé dans l'archive" means "not found in the archive"
"Arrêt avec code d'échec à cause des erreurs précédentes" means "stop with error code because of previous errors"

When I run the same script (no argument too) after a "export LANGUAGE=en_US", I don't get the error.

Script :

#!/bin/bash

set -xv
set -o errexit
set -o nounset

OVERLAY_DIR=/tmp/overlay
MOUNT_POINT=/tmp/mnt

function exit_handler()
{
  if (( $? == 0 )); then
    echo
    echo OK
  else
    echo
    echo ERROR >&2
  fi

  umount_dir
  rm -rf $OVERLAY_DIR $MOUNT_POINT
}
trap exit_handler EXIT

function umount_dir()
{
  if [[ -n $(mount|grep "FuseMount on $MOUNT_POINT type") ]]; then
    echo umounting $MOUNT_POINT
    fusermount -u $MOUNT_POINT
  fi
}

function create_dummy_tar()
{
  local tar_dir=/tmp/example_tar
  tar=/tmp/example.tar
  rm -rf $tar* $tar_dir
  mkdir -p $tar_dir/dir1
  ls -al / > $tar_dir/file1
  tar cf $tar $tar_dir
  rm -r $tar_dir
}

if (( $# == 0 )); then
  create_dummy_tar
elif (( $# == 1 )); then
  tar=$1
else
  echo "syntax: $(basename $0) <tar file>" >&2
  exit 1
fi

if [[ ! -f $tar ]]; then
  echo "$tar: no such file" >&2
  exit 1
fi

umount_dir

rm -rf $OVERLAY_DIR $MOUNT_POINT
mkdir -p $OVERLAY_DIR $MOUNT_POINT

# mount tar
ratarmount --write-overlay $OVERLAY_DIR $tar $MOUNT_POINT

# add file to mounted archive
ls -al / > $MOUNT_POINT/file2

# add folder to mounted archive
mkdir -p $MOUNT_POINT/dir2

# umount tar
sleep 1
umount_dir

# commit changes
echo "committing changes..."
ratarmount --commit-overlay --write-overlay $OVERLAY_DIR $tar $MOUNT_POINT <<EOT
commit
EOT

echo
tar tf $tar
echo

Thank you!

@mxmlnkn
Copy link
Owner

mxmlnkn commented Mar 29, 2024

Hi there, glad I was able to help previously.

I have some follow-up questions:

  • What is your LANGUAGE set to? I tried LANGUAGE=fr_FR and the script still prints "OK" among many other lines of debug output. The settings for all LC variables might also be helpful: printenv | grep LC.
  • Could you try running tar --delete --null --verbatim-files-from --files-from='/tmp/tmplvgbnz0o/deletions.lst' --file '/tmp/example.tar' manually and see what happens. Also, you could try listing /tmp/tmplvgbnz0o/deletions.lst if it wasn't deleted and check whether it looks ok.
  • What is the output of tar --version?

@mxmlnkn
Copy link
Owner

mxmlnkn commented Mar 29, 2024

The follow-up questions are unnecessary. The bug is obvious. English is hardcoded in the line with sed '/^tar: Exiting with failure/d; /^tar.*Not found in archive/d'. You can fully ignore those warnings. What happens is: to avoid multiple versions of the same file existing in the TAR, the delete line, simply tries to remove all paths for files that later will be appended to the archive. The resulting warnings by GNU tar are filtered, which only works in English.

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

No branches or pull requests

2 participants