Long symbolic links (> 100 chars) get their target file names truncated when a pkg containing them is added `apk add`
While working on the mono APK I ran into this issue where when the apk is being installed, the symbolic link target file names were getting truncated at 100 chars.
> sudo apk add ~/packages/testing/x86_64/mono-4.2.2.30-r1.apk
> find /usr/lib/mono/4.5/ -xtype l | xargs ls -l
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/Mono.CompilerServices.SymbolWriter.dll -> ../gac/Mono.CompilerServices.SymbolWriter/4.0.0.0__0738eb9f132ed756/Mono.CompilerServices.SymbolWrit
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.ComponentModel.Composition.dll -> ../gac/System.ComponentModel.Composition/4.0.0.0__b77a5c561934e089/System.ComponentModel.Composition
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.ComponentModel.DataAnnotations.dll -> ../gac/System.ComponentModel.DataAnnotations/4.0.0.0__31bf3856ad364e35/System.ComponentModel.DataAnn
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.DirectoryServices.Protocols.dll -> ../gac/System.DirectoryServices.Protocols/4.0.0.0__b03f5f7f11d50a3a/System.DirectoryServices.Protoco
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.IO.Compression.FileSystem.dll -> ../gac/System.IO.Compression.FileSystem/4.0.0.0__b77a5c561934e089/System.IO.Compression.FileSystem.d
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Reactive.Observable.Aliases.dll -> ../gac/System.Reactive.Observable.Aliases/0.0.0.0__31bf3856ad364e35/System.Reactive.Observable.Alias
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Reactive.PlatformServices.dll -> ../gac/System.Reactive.PlatformServices/2.2.0.0__31bf3856ad364e35/System.Reactive.PlatformServices.d
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Reactive.Runtime.Remoting.dll -> ../gac/System.Reactive.Runtime.Remoting/2.2.0.0__31bf3856ad364e35/System.Reactive.Runtime.Remoting.d
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Reactive.Windows.Threading.dll -> ../gac/System.Reactive.Windows.Threading/2.2.0.0__31bf3856ad364e35/System.Reactive.Windows.Threading
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Runtime.DurableInstancing.dll -> ../gac/System.Runtime.DurableInstancing/4.0.0.0__31bf3856ad364e35/System.Runtime.DurableInstancing.d
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Runtime.Serialization.Formatters.Soap.dll -> ../gac/System.Runtime.Serialization.Formatters.Soap/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.Seriali
lrwxrwxrwx 1 root root 100 Feb 6 14:53 /usr/lib/mono/4.5/System.Windows.Forms.DataVisualization.dll -> ../gac/System.Windows.Forms.DataVisualization/4.0.0.0__31bf3856ad364e35/System.Windows.Forms.DataVis
As you can see the target file name is being truncated at 100 characters.
I expanded the apk with GNU tar into a local dir & there were no broken symlinks:
> tar --version
tar (GNU tar) 1.28
> cd foo; tar xfz ~/packages/testing/x86_64/mono-4.2.2.30-r1.apk
> find usr/lib/mono/4.5/ -xtype l
>
In archive.c, the tar header has a linkname char field which is only 100 characters long - I think this is the root cause.
(from redmine: issue id 5076, created on 2016-02-06, closed on 2016-07-28)
- Changesets:
- Revision 9c736d01 by Timo Teräs on 2016-02-09T14:55:06Z:
archive: fix long symlink target names
don't overwrite the link_target if it was found from pax header.
ref #5076