1

Preface: We have a complex build process and discovered it's working on one system and failing on another (unfortunally/Murphy it worked on the Jenkins build server, so the problem remained undiscovered for long). The error source turned out to be the order in which hard-linked files were put into a tar file by some external component:

a and b were hard-linked and tarred, while later, on extracting the tar file, only a was extracted. Of course, when a was the first to be archived, it worked, but if b was the first in the tar, the typical Cannot hard link error shows up.

Of course, we could tar cf with --hard-dereference, but this means changing a script in an external tool (which is to be avoided), so my question is different:

Question: Our basic goal is to have a reproducable result, independent of the system. Currently, the tarring order is reproducable on one system, but can be randomly different on another system. Can we force a file order for tar without giving options to tar or splitting the tar call into several calls?

The systems are all linux right now, but could as well be FreeBSD or MacOS some time.

  • Please describe your problem. What you claim is in conflict with typical tar behavior. So you either have a broken tar implementation or a strange constraint that you missed to describe. – schily Oct 15 at 16:46
  • I‘ll try better: I check out the same git repo on two linux machines, start the same buildroot build, in which some package generates a hard link to a file and creates a tar of the dir structure with both files. Now it turns out, on one machine file a is first in the tar, on the other machine it‘s file b. This produces a problem in the further build process. – Philippos Oct 15 at 19:35
  • OK, that behavior with different order can be explained with different filesystems in use. It still does not explain why there is a problem with links unless your tar implementation is broken. – schily Oct 16 at 10:54
  • Only parts of the tar are needed at one later step, so only this branch containing a is extracted. This works as long as a was the first file to be tarred, but if b was in the archive first, a contains just a reference and the error message is the expected behaviour. – Philippos Oct 17 at 18:30
  • In that case. you would need to either use a tar that allows to have the data twice with a hard link or to give tar a list of files in the order needed by you. – schily Oct 18 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.