Re: [patch] PkgCreate.pm make it more clear why a shared library is invalid
On Thu, 12 Nov 2015 16:15:35 +0100 Marc Espie wrote: > On Wed, Nov 11, 2015 at 05:13:45PM +0100, Adam Wolk wrote: > > Hi tech@, > > > > I have been working recently on packaging a shared library for the > > first time and hit a stumbling block yesterday. > > > > $ make package > > `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to > > date. ===> Building package for libwebsockets-1.5 > > Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz > > reading plist| > > Error: Invalid shared library @lib lib/libwebsockets.so.5 > > I'm pretty sure the naming scheme is out of place in the error > message. But yeah, the message is not perfect. Maybe then just adding a name would help here? It is a bit difficult to handle since the code checks both that the file matches the naming scheme & that it's located in at least one sub-folder. Leaving it up to you. I know what to do next time I spot that. Thought it would be easier for someone else to understand the error when hit. Regards, Adam Index: OpenBSD/PkgCreate.pm === RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm,v retrieving revision 1.118 diff -u -p -r1.118 PkgCreate.pm --- OpenBSD/PkgCreate.pm6 Nov 2015 08:53:12 - 1.118 +++ OpenBSD/PkgCreate.pm11 Nov 2015 16:07:33 - @@ -674,7 +674,7 @@ sub check_version $state->error("Incorrectly versioned shared library: #1", $unsubst); } } else { - $state->error("Invalid shared library #1", $unsubst); + $state->error("Invalid shared library name #1", $unsubst); } $state->{has_libraries} = 1; }
Re: [patch] PkgCreate.pm make it more clear why a shared library is invalid
On Wed, Nov 11, 2015 at 05:13:45PM +0100, Adam Wolk wrote: > Hi tech@, > > I have been working recently on packaging a shared library for the > first time and hit a stumbling block yesterday. > > $ make package > `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to date. > ===> Building package for libwebsockets-1.5 > Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz > reading plist| > Error: Invalid shared library @lib lib/libwebsockets.so.5 I'm pretty sure the naming scheme is out of place in the error message. But yeah, the message is not perfect.
[patch] PkgCreate.pm make it more clear why a shared library is invalid
Hi tech@, I have been working recently on packaging a shared library for the first time and hit a stumbling block yesterday. $ make package `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to date. ===> Building package for libwebsockets-1.5 Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz reading plist| Error: Invalid shared library @lib lib/libwebsockets.so.5 This error message made me think that I either generated the .so incorrectly or that it's format is not a valid shared library. I went to bed and tackled the issue again today. Quick look at PkgCreate revealed that the error is generated by PkgCreate in check_version: https://github.com/lattera/openbsd/blob/master/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm#L618 The error is a result of $self->parse returning undef as it's result. Parse resolves to: https://github.com/lattera/openbsd/blob/master/usr.sbin/pkg_add/OpenBSD/PackingElement.pm#L659 and the result is just based on a regexp match & extract: $filename =~ m/^(.*?)\/?lib([^\/]+)\.so\.(\d+)\.(\d+)$/o Now in my case after seeing the above it is obvious that the packaging fails due to the lib not following lib$NAME.so.$major.$minor naming scheme. I would like to suggest a small change to the reported error to make the cause of the problem more apparent. Current : Error: Invalid shared library @lib lib/libwebsockets.so.5 Proposed: Error: Shared library name doesn't match lib/lib$name.so.$major.$minor naming scheme @lib lib/libwebsockets.so.5 I did confirm that not existing files are handeled later on: $ make package `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to date. ===> Building package for libwebsockets-1.5 Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz checksumming|** | 91% Error: /usr/ports/pobj/libwebsockets-1.5/fake-amd64/usr/local/lib/libwebsockets.so.5.0 does not exist Fatal error: can't continue of course the error message is just a suggestion, maybe someone can come up with a better/less verbose one. Here's the output after the patch: # make package `/usr/ports/pobj/libwebsockets-1.5/fake-amd64/.fake_done' is up to date. ===> Building package for libwebsockets-1.5 Create /usr/ports/packages/amd64/all/libwebsockets-1.5.tgz reading plist| Error: Shared library name doesn't match lib/lib$name.so.$major.$minor naming scheme @lib lib/libwebsockets.so.5 checking dependencies... checksumming Fatal error: can't continue at /usr/libdata/perl5/OpenBSD/PkgCreate.pm line 1543. *** Error 1 in . (/usr/ports/infrastructure/mk/bsd.port.mk:1959 '/usr/ports/packages/amd64/all/libwebsockets-1.5.tgz') *** Error 1 in . (/usr/ports/infrastructure/mk/bsd.port.mk:2511 '_internal-package') *** Error 1 in /usr/ports/mystuff/devel/libwebsockets (/usr/ports/infrastructure/mk/bsd.port.mk:2491 'package') Small offtopic question before the patch: I noticed that the regexp in PackingElement.pm uses the /o flag. Actually a lot of regexp in pkg_add subtree use them. The perlre(1) docs have this to say about this flag: Substitution-specific modifiers described in "s/PATTERN/REPLACEMENT/msixpodualgcer" in perlop are: o - pretend to optimize your code, but actually introduce bugs Quick search on perlmonks yields: http://www.perlmonks.org/?node_id=256053 Guess it's mostly harmless just wanted to know if there are plans to kill them off? Error message patch: Index: OpenBSD/PkgCreate.pm === RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm,v retrieving revision 1.118 diff -u -p -r1.118 PkgCreate.pm --- OpenBSD/PkgCreate.pm6 Nov 2015 08:53:12 - 1.118 +++ OpenBSD/PkgCreate.pm11 Nov 2015 16:07:33 - @@ -674,7 +674,7 @@ sub check_version $state->error("Incorrectly versioned shared library: #1", $unsubst); } } else { - $state->error("Invalid shared library #1", $unsubst); + $state->error("Shared library name doesn't match lib/lib\$name.so.\$major.\$minor naming scheme #1", $unsubst); } $state->{has_libraries} = 1; }