neilcsmith-net commented on code in PR #107:
URL: 
https://github.com/apache/netbeans-nbpackage/pull/107#discussion_r2180039163


##########
src/main/java/org/apache/netbeans/nbpackage/deb/DebTask.java:
##########
@@ -199,7 +199,11 @@ private void setupLauncher(Path binDir, String 
packageLocation, String execName)
                 Map.of("PACKAGE", packageLocation, "EXEC", execName));
         Path bin = binDir.resolve(execName);
         Files.writeString(bin, script, StandardOpenOption.CREATE_NEW);
-        Files.setPosixFilePermissions(bin, 
PosixFilePermissions.fromString("rwxr-xr-x"));
+        try {
+            Files.setPosixFilePermissions(bin, 
PosixFilePermissions.fromString("rwxr-xr-x"));
+        } catch (UnsupportedOperationException ex) {
+            context().warningHandler().accept("UnsupportedOperationException : 
PosixFilePermissions");
+        }

Review Comment:
   Thanks!  Neither of those are really needed here, and we can't pass the 
exception - the warning handler is a `Consumer<String>`.  This specifically 
only catches the `UnsupportedOperationException` which is 
[documented](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/nio/file/Files.html#setPosixFilePermissions(java.nio.file.Path,java.util.Set))
 to be thrown only if the file system doesn't support posix permissions.  Other 
exceptions will still bubble up and exit with stacktrace.  By this point the 
image already contains a bunch of other files that should have posix 
permissions - the (third-party) `ArchiveUtils` quietly ignores permissions it 
can't set on archive extraction.  This at least ensures _a_ warning is shown.
   
   There are two scenarios for image-only creation.  The first is to step in 
and alter the image, which I used to require in a personal project until 
`package.merge` and `package.remove`.  The second is for cross-platform testing 
and development.  The image in the latter case is unlikely to be usable to 
create a valid package from.  We should perhaps look to warn about that more 
broadly.  Need to also check whether `dpkg` or `rpmbuild` already fail on eg. 
FAT filesystems.
   
   TL;DR :smile:  neither option really that useful at this particular point.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to