Why do I get files like ._foo in my tarball on OS X?
Solution 1:
OS X's tar uses the AppleDouble format to store extended attributes and ACLs.
$ touch file1 file2 file3
$ xattr -w key value file1
$ chmod +a 'admin allow delete' file2
$ ls -le@ *
-rw-r--r--@ 1 lauri staff 0 May 25 07:09 file1
key 5
-rw-r--r--+ 1 lauri staff 0 May 25 07:09 file2
0: group:admin allow delete
-rw-r--r-- 1 lauri staff 0 May 25 07:09 file3
$ tar -cf 1.tar *
$ tar -tf 1.tar
./._file1
file1
./._file2
file2
file3
OS X's tar also knows how to convert the ._ members back to native formats, but the ._ files are usually kept when archives are extracted on other platforms. You can tell tar to not include the metadata by setting COPYFILE_DISABLE to some value:
$ COPYFILE_DISABLE=1 tar -cf 2.tar file*
$ tar -tf 2.tar
file1
file2
file3
- The copyfile functions are described in
man copyfile
-
ls -l@
shows the keys and sizes of extended attributes,ls -le
prints ACLs -
xattr -l
lists the keys and values of extended attributes -
xattr -c
clears all extended attributes (-d can't be used alone) -
chmod -N
deletes ACLs - Zip files created on OS X use a __MACOSX folder to store similar metadata
Information stored as extended attributes:
- Resource forks (resource forks have been extended attributes since 10.4)
- Custom icons set in Finder and the images of Icon\r files
- Metadata in PSD files
- Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts
- Information about aliases (aliases stop working if extended attributes are removed)
- Quarantine status or source URLs of files downloaded from the internet
- Spotlight comments
- Encoding of files saved with TextEdit
- Caret position of files opened with TextMate
- Skim notes
Solution 2:
As of bsdtar 3.0.3 - libarchive 3.0.3
(and perhaps earlier) there's a new option to the bsdtar
command called --disable-copyfile
to suppress the creation of ._
files.
# on Mac OS X
# /usr/bin/tar -> bsdtar
ls -l /usr/bin/tar
# from man bsdtar
--disable-copyfile
Mac OS X specific. Disable the use of copyfile(3).