SMF icon indicating copy to clipboard operation
SMF copied to clipboard

Package manager won't parse some packages generated on OSX

Open jdarwood007 opened this issue 2 years ago • 5 comments

Description

When I use a package that was generated on OS X, I get these errors during upload:

( ! ) Fatal error: Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /Sources/Errors.php on line 231
( ! ) TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /Sources/Errors.php on line 231

This doesn't seem to be the root of the error, but what I'm getting back

If I manually upload the file, nothing shows up.

The file was generated using OSX's built in tar uitlity

➜  StopForumSpam git:(master) tar -zcf ~/Downloads/StopForumSpam-test.tgz *

Steps to reproduce

  1. Attempt to upload the attached file to package manger. Errors

Environment (complete as necessary)

  • Version/Git revision: latest
  • Database Type: N/A
  • Database Version: N/A
  • PHP Version: 8.0

Additional information/references

StopForumSpam-test.tar.gz

OS X tar utility is adding some additional metadata (which is not a file) to the compressed file, which SMF Package Manager is trying to read out.

You should see data like this in the archive.

119 LIBARCHIVE.xattr.com.apple.quarantine=MDA4MTs2MWRhMDUxNTtDaHJvbWU7MEY5NERCOTgtQ0M0Ni00ODIwLTk5MEEtM0M0QTRBODY4RkVC 95 SCHILY.xattr.com.apple.quarantine=0081;61da0515;Chrome;0F94DB98-CC46-4820-990A-3C4A4A868FEB

This only happens I think if a file exists in the directory that is quarantined by OS X. https://apple.stackexchange.com/questions/104712/what-causes-os-x-to-mark-a-folder-as-quarantined

jdarwood007 avatar Jan 09 '22 19:01 jdarwood007

The problem here is that the ._ files are special files that contain file attributes for other files...

When tarred up, of course they're tarred, but the tar package is also adding an attribute row, of type = 'x', into the tar index. When we step thru the index, we are not checking the type.

To solve, read_tgz_data needs to bypass entries of type 'x' or 'g'. At least...

Check out the values in the typeflag here: https://www.gnu.org/software/tar/manual/html_node/Standard.html

We are basically passing all of those back as if they were real files. We should probably only do 0, \0 and 5 - files and directories.

The problem is that they give them 'filenames' that look like the real filenames, so downstream processes (like pacman) end up trying to read this binary data...

So, let's say you have ONE SINGLE file you would like in your tar: package-info.xml

But you save it in OSX, so you end up with two files: ._package-info.xml package-info.xml

Now, you tar that up. The resulting tar has THREE entries in the archive index: someheader/package-info.xml (type = 'x') ._package-info.xml (type = 0) package-info.xml (type = 0)

To pacman, the first entry here looks like the real file: someheader/package-info.xml

So it tries to read it, but it's binary.

sbulen avatar Jan 09 '22 21:01 sbulen

I don't know if .zips have similar issues....

sbulen avatar Jan 09 '22 21:01 sbulen

StopForumSpam-test.zip

Zip files seem to be fine when created in OSX

➜  StopForumSpam git:(master) zip -1 ~/Downloads/StopForumSpam-test.zip *

jdarwood007 avatar Jan 09 '22 21:01 jdarwood007

I don't know if .zips have similar issues....

They do not

On Sun, Jan 9, 2022 at 2:47 PM Jeremy D @.***> wrote:

StopForumSpam-test.zip https://github.com/SimpleMachines/SMF2.1/files/7836027/StopForumSpam-test.zip

Zip files seem to be fine when created in OSX

➜ StopForumSpam git:(master) zip -1 ~/Downloads/StopForumSpam-test.zip *

— Reply to this email directly, view it on GitHub https://github.com/SimpleMachines/SMF2.1/issues/7227#issuecomment-1008430196, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADJNN2SFPNLGQRXQOYNY4LUVH675ANCNFSM5LSF4UUA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

live627 avatar Jan 09 '22 22:01 live627

This is an issue that we can deal with in the future. If #7229 is fully tested in time for 2.1.1, great, but there's no great rush on this one. I have been making SMF-compatible tar.gz archives on my Mac for years, using the following command line switches:

tar -cz --no-xattrs --no-acls --no-mac-metadata --no-fflags --exclude='.git*' --exclude='.DS_Store' --exclude='._*' -f filenames...

... and anyone else making .tar.gz files on a Mac has either been using the same or using a GUI solution.

Sesquipedalian avatar Jan 24 '22 01:01 Sesquipedalian