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


##########
src/main/java/org/apache/netbeans/nbpackage/StringUtils.java:
##########
@@ -30,11 +30,31 @@
 public class StringUtils {
 
     private static final Pattern TOKEN_PATTERN = 
Pattern.compile("\\$\\{(.+?)\\}");
+    private static final Pattern SCRIPT_VAR_PATTERN = 
Pattern.compile("\\$\\{\\{(.+?)\\}\\}");
 
     private StringUtils() {
         // static utilities
     }
 
+  /**
+    * Unescapes the bash variables in the script template
+    *
+    * @param template script template
+    * @return script with unescaped variables
+    */
+    public static String unescapeScriptVars(String script)

Review Comment:
   I think this should be removed.  It should be unnecessary.  The API should 
give you the option to leave unmatched tokens in place already.



##########
src/main/resources/org/apache/netbeans/nbpackage/shell/shell.script.template:
##########
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+
+APP_DIR=${APP_DIR}
+
+if ! [ $(id -u) = 0 ]; then
+   DEFAULT_INSTALL_PREFIX=$HOME/.local
+   DESKTOP_FILE_INSTALL_DIR=$HOME/.local/share/applications
+else
+   DEFAULT_INSTALL_PREFIX=/usr/local
+   DESKTOP_FILE_INSTALL_DIR=/usr/local/share/applications
+fi
+
+read -p "Enter ${APP_NAME} Install Prefix 
[${{DEFAULT_INSTALL_PREFIX}}]/${{APP_DIR}}: " INSTALL_PREFIX

Review Comment:
   Move to `${DEFAULT_INSTALL_PREFIX}` pattern.
   
   Also, mixing up `${{APP_DIR}}` and `${APP_DIR}`.



##########
src/main/resources/org/apache/netbeans/nbpackage/shell/shell.desktop.template:
##########
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=${package.name}
+Exec=${{LAUNCHER}}

Review Comment:
   Just use `${LAUNCHER}`.  Or as it's replaced from script, a different token 
delimiter.



##########
src/main/java/org/apache/netbeans/nbpackage/shell/TarScriptPackager.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.netbeans.nbpackage.shell;
+
+import org.apache.netbeans.nbpackage.ExecutionContext;
+import org.apache.netbeans.nbpackage.Option;
+import org.apache.netbeans.nbpackage.Packager;
+import org.apache.netbeans.nbpackage.Template;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.stream.Stream;
+
+/**
+ * Packager for Linux embedded tar in script installer.
+ */
+public class TarScriptPackager implements Packager {
+
+    static final ResourceBundle MESSAGES
+            = 
ResourceBundle.getBundle(TarScriptPackager.class.getPackageName() + 
".Messages");
+
+    /**
+     * Path to png icon (48x48) as required by AppDir / XDG specification.
+     * Defaults to Apache NetBeans icon.
+     */
+    static final Option<Path> ICON_PATH
+            = Option.ofPath("package.shell.icon",

Review Comment:
   Might be better to have all the options prefixed with `tar` instead of 
`shell` for consistency?  eg. `package.tar.icon` here.



##########
src/main/java/org/apache/netbeans/nbpackage/NBPackage.java:
##########
@@ -132,7 +133,8 @@ public final class NBPackage {
             new RpmPackager(),
             new InnoSetupPackager(),
             new PkgPackager(),
-            new ZipPackager()
+            new ZipPackager(),
+            new TarScriptPackager()

Review Comment:
   Keep zip last - move tar below rpm to keep Linux options together.



##########
src/main/resources/org/apache/netbeans/nbpackage/shell/Messages.properties:
##########
@@ -0,0 +1,37 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Option file help comments
+option.icon.help=Path to 48x48 png icon as required by xdg specification. 
Defaults to Apache NetBeans logo.
+option.svg.help=Path to SVG icon. Will only be used if package.shell.icon also 
set. Defaults to Apache NetBeans logo.
+option.wmclass.help=StartupWMClass to set in .desktop file. Should match the 
WMClass of the main application window.
+option.category.help=Application category (or categories) to use in the 
.desktop file.
+option.desktopfilename.help=Optional name for .desktop file (without suffix). 
Defaults to sanitized package name.
+option.desktop_template.help=Optional path to custom .desktop file template.
+option.launcher_template.help=Optional path to custom launcher script template.
+option.template.help=Optional path to an alternative shell script (*.sh) file 
template.
+
+# Option defaults
+option.wmclass.default=${package.name}
+option.category.default=Development;Java;IDE;
+
+# Messages
+message.missingdebtools=The sed, tar, which commands must be installed.

Review Comment:
   `message.missingtartools`?
   
   Although it's not used by the packager anyway?



-- 
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