This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 24357
Collapse All | Expand All

(-)a/apisupport.harness/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.apisupport.harness
2
OpenIDE-Module: org.netbeans.modules.apisupport.harness
3
OpenIDE-Module-Specification-Version: 1.15
3
OpenIDE-Module-Specification-Version: 1.16
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/apisupport/harness/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/apisupport/harness/Bundle.properties
5
5
(-)a/apisupport.harness/nbproject/project.properties (+2 lines)
Lines 110-112 Link Here
110
110
111
test.unit.cp.extra=${cluster}/jnlp/jnlp-launcher.jar
111
test.unit.cp.extra=${cluster}/jnlp/jnlp-launcher.jar
112
javadoc.arch=${basedir}/arch.xml
112
javadoc.arch=${basedir}/arch.xml
113
114
nbm.executable.files=launchers/app.sh
(-)a/apisupport.harness/release/README (+4 lines)
Lines 725-730 Link Here
725
nbm.distribution - optional URL to location where your NBM can be downloaded
725
nbm.distribution - optional URL to location where your NBM can be downloaded
726
from.
726
from.
727
727
728
nbm.executable.files [since 6.8] - space separated patterns of files relative to 
729
cluster directory for which executable permissions should be set on Unix system 
730
when building the module and on NBM installation/update in runtime.
731
728
nbm.homepage - optional URL to HTML homepage for background about the module.
732
nbm.homepage - optional URL to HTML homepage for background about the module.
729
733
730
nbm.is.global - set to "true" if NBM cannot be installed in user directory.
734
nbm.is.global - set to "true" if NBM cannot be installed in user directory.
(-)a/apisupport.harness/taskdefs.properties (+1 lines)
Lines 45-50 Link Here
45
makemasterjnlp=org.netbeans.nbbuild.MakeMasterJNLP
45
makemasterjnlp=org.netbeans.nbbuild.MakeMasterJNLP
46
parseprojectxml=org.netbeans.nbbuild.ParseProjectXml
46
parseprojectxml=org.netbeans.nbbuild.ParseProjectXml
47
genlist=org.netbeans.nbbuild.MakeListOfNBM
47
genlist=org.netbeans.nbbuild.MakeListOfNBM
48
genexecutables=org.netbeans.nbbuild.MakeExecutableFilesList
48
arch=org.netbeans.nbbuild.Arch
49
arch=org.netbeans.nbbuild.Arch
49
fixdependencies=org.netbeans.nbbuild.FixDependencies
50
fixdependencies=org.netbeans.nbbuild.FixDependencies
50
sortsuitemodules=org.netbeans.nbbuild.SortSuiteModules
51
sortsuitemodules=org.netbeans.nbbuild.SortSuiteModules
(-)a/autoupdate.services/libsrc/org/netbeans/updater/ModuleUpdater.java (-4 / +91 lines)
Lines 42-47 Link Here
42
package org.netbeans.updater;
42
package org.netbeans.updater;
43
43
44
import java.io.*;
44
import java.io.*;
45
import java.lang.reflect.Method;
45
import java.util.*;
46
import java.util.*;
46
import java.util.jar.*;
47
import java.util.jar.*;
47
48
Lines 97-102 Link Here
97
    
98
    
98
    public static final String UPDATER_JAR = "updater.jar"; // NOI18N
99
    public static final String UPDATER_JAR = "updater.jar"; // NOI18N
99
    public static final String AUTOUPDATE_UPDATER_JAR_PATH = "netbeans/modules/ext/" + UPDATER_JAR; // NOI18N
100
    public static final String AUTOUPDATE_UPDATER_JAR_PATH = "netbeans/modules/ext/" + UPDATER_JAR; // NOI18N
101
102
    public static final String EXECUTABLE_FILES_ENTRY = "Info/executable.list";
100
    
103
    
101
    /** files that are supposed to be installed (when running inside the ide) */
104
    /** files that are supposed to be installed (when running inside the ide) */
102
    private Collection<File> forInstall;
105
    private Collection<File> forInstall;
Lines 354-359 Link Here
354
                try {
357
                try {
355
                    jarFile = new JarFile (nbm);
358
                    jarFile = new JarFile (nbm);
356
                    Enumeration entries = jarFile.entries();
359
                    Enumeration entries = jarFile.entries();
360
                    List <String> executableFiles = readExecutableFilesList(jarFile);
361
                    List <File> filesToChmod = new ArrayList <File> ();
357
                    while( entries.hasMoreElements() ) {
362
                    while( entries.hasMoreElements() ) {
358
                        JarEntry entry = (JarEntry) entries.nextElement();
363
                        JarEntry entry = (JarEntry) entries.nextElement();
359
                        checkStop();
364
                        checkStop();
Lines 383-401 Link Here
383
                                    destFile.getParentFile ().mkdirs ();
388
                                    destFile.getParentFile ().mkdirs ();
384
                                }
389
                                }
385
                                bytesRead = copyStreams( jarFile.getInputStream( entry ), new FileOutputStream( destFile ), bytesRead );
390
                                bytesRead = copyStreams( jarFile.getInputStream( entry ), new FileOutputStream( destFile ), bytesRead );
391
                                if(executableFiles.contains(pathTo)) {
392
                                    filesToChmod.add(destFile);
393
                                }
386
                                UpdaterFrame.setProgressValue( bytesRead );
394
                                UpdaterFrame.setProgressValue( bytesRead );
387
                            }
395
                            }
388
                        } else if ( entry.getName().startsWith( UPDATE_MAIN_DIR )&&
396
                        } else if ( entry.getName().startsWith( UPDATE_MAIN_DIR )&&
389
                                  !entry.isDirectory() ) {
397
                                  !entry.isDirectory() ) {
390
                            // run main                  
398
                            // run main
391
                            File destFile = new File (getMainDirectory (cluster),
399
                            String pathTo = entry.getName().substring(UPDATE_MAIN_DIR.length() + 1);
392
                                entry.getName().substring(UPDATE_MAIN_DIR.length() + 1) );
400
                            File destFile = new File (getMainDirectory (cluster), pathTo);
401
                            if(executableFiles.contains(pathTo)) {
402
                                filesToChmod.add(destFile);
403
                            }
393
                            destFile.getParentFile ().mkdirs ();
404
                            destFile.getParentFile ().mkdirs ();
394
                            hasMainClass = true;
405
                            hasMainClass = true;
395
                            bytesRead = copyStreams( jarFile.getInputStream( entry ), new FileOutputStream( destFile ), bytesRead );
406
                            bytesRead = copyStreams( jarFile.getInputStream( entry ), new FileOutputStream( destFile ), bytesRead );
396
                            UpdaterFrame.setProgressValue( bytesRead );
407
                            UpdaterFrame.setProgressValue( bytesRead );
397
                        }
408
                        }
398
                    }
409
                    }
410
                    chmod(filesToChmod);
399
                    if ( hasMainClass ) {                    
411
                    if ( hasMainClass ) {                    
400
                        MainConfig mconfig = new MainConfig (getMainDirString (cluster) + UpdateTracking.FILE_SEPARATOR + JVM_PARAMS_FILE, cluster);
412
                        MainConfig mconfig = new MainConfig (getMainDirString (cluster) + UpdateTracking.FILE_SEPARATOR + JVM_PARAMS_FILE, cluster);
401
                        if (mconfig.isValid()) {
413
                        if (mconfig.isValid()) {
Lines 455-461 Link Here
455
            t.deleteUnusedFiles ();            
467
            t.deleteUnusedFiles ();            
456
        }
468
        }
457
    }
469
    }
458
    
470
471
    private List<String> readExecutableFilesList(JarFile jarFile) {
472
        List<String> list = new ArrayList<String>();
473
        JarEntry executableFilesEntry = jarFile.getJarEntry(EXECUTABLE_FILES_ENTRY);
474
        if (executableFilesEntry != null) {
475
            BufferedInputStream bis = null;
476
            try {
477
                bis = new BufferedInputStream(jarFile.getInputStream(executableFilesEntry));
478
                byte[] buffer = new byte[8192];
479
                int c = 0;
480
                StringBuilder sb = new StringBuilder();
481
                while ((c = bis.read(buffer)) != -1) {
482
                    sb.append(new String(buffer, 0, c));
483
                }
484
                String[] lines = sb.toString().trim().split("(?:\r\n|\n|\r)");
485
                for (String s : lines) {
486
                    if (s.trim().length() > 0) {
487
                        list.add(s);
488
                    }
489
                }
490
            } catch (Exception e) {
491
                e.printStackTrace();
492
            } finally {
493
                if (bis != null) {
494
                    try {
495
                        bis.close();
496
                    } catch (IOException e) {
497
                    }
498
                }
499
            }
500
        }
501
        return list;
502
    }
503
504
    private void chmod(List <File> executableFiles) {
505
        if(isWindows() || executableFiles.isEmpty()) {
506
            return;
507
        }
508
        if (System.getProperty("java.version").startsWith("1.5")) {
509
            // Find chmod
510
            File chmod = new File("/bin/chmod"); // NOI18N
511
            if (!chmod.isFile()) {
512
                chmod = new File("/usr/bin/chmod"); // NOI18N
513
            }
514
            if (chmod.isFile()) {
515
                Process process = null;
516
                try {
517
                    List <String> command = new ArrayList<String>();
518
                    command.add(chmod.getAbsolutePath());
519
                    command.add("a+x");
520
                    for(File executableFile : executableFiles) {
521
                        command.add(executableFile.getAbsolutePath());
522
                    }
523
                    process = new ProcessBuilder(command).start();
524
                    process.waitFor();
525
                } catch (Exception e) {
526
                    e.printStackTrace();
527
                } finally {
528
                    if (process != null) {
529
                        process.destroy();
530
                    }
531
                }
532
            }
533
        } else {
534
            // Determine if java.io.File.setExecutable method is supported
535
            try {
536
                Method setExecutableMethod = File.class.getMethod("setExecutable", Boolean.TYPE, Boolean.TYPE);
537
                for(File executableFile : executableFiles) {
538
                    setExecutableMethod.invoke(executableFile, true, false);
539
                }
540
            } catch (Exception e) {
541
                e.printStackTrace();
542
            }
543
        }
544
    }
545
459
    public static boolean trickyDeleteOnWindows(File destFile) {
546
    public static boolean trickyDeleteOnWindows(File destFile) {
460
        assert isWindows() : "Call it only on Windows but system is " + System.getProperty("os.name");
547
        assert isWindows() : "Call it only on Windows but system is " + System.getProperty("os.name");
461
        File f = new File(destFile.getParentFile(), destFile.getName());
548
        File f = new File(destFile.getParentFile(), destFile.getName());
(-)a/autoupdate.services/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.autoupdate.services
2
OpenIDE-Module: org.netbeans.modules.autoupdate.services
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.9
4
OpenIDE-Module-Specification-Version: 1.10
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
(-)a/autoupdate.services/test/unit/src/org/netbeans/modules/autoupdate/services/ExecutablePermissionsTest.java (+174 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.autoupdate.services;
42
43
import java.io.File;
44
import java.io.IOException;
45
import java.io.InputStream;
46
import java.lang.reflect.Method;
47
import java.util.HashMap;
48
import java.util.Map;
49
import org.netbeans.api.autoupdate.UpdateUnit;
50
import org.netbeans.spi.autoupdate.UpdateItem;
51
import org.netbeans.spi.autoupdate.UpdateProvider;
52
53
/**
54
 *
55
 * @author Dmitry Lipin
56
 */
57
public class ExecutablePermissionsTest extends NbmAdvancedTestCase {
58
59
    private UpdateProvider p = null;
60
    private String testModuleVersion = "1.0";
61
    private String testModuleName = "org.yourorghere.executable.permissions";
62
63
    public ExecutablePermissionsTest(String name) {
64
        super(name);
65
    }
66
67
    @Override
68
    protected void setUp() throws IOException, Exception {
69
        super.setUp();
70
    }
71
72
    @Override
73
    public boolean canRun() {
74
        return super.canRun() && !System.getProperty("os.name").startsWith("Windows");
75
    }
76
77
    private String generateExecutablePermissionsModuleElement() {
78
        String res = "\n<module codenamebase=\"" + testModuleName + "\" " +
79
                "homepage=\"http://www.netbeans.org/\" distribution=\"nbresloc:/org/netbeans/api/autoupdate/data/org-yourorghere-executable-permissions.nbm\" " +
80
                "license=\"standard-nbm-license.txt\" downloadsize=\"5122\" " +
81
                "needsrestart=\"false\" moduleauthor=\"\" " +
82
                "eager=\"false\" " +
83
                "releasedate=\"2006/02/23\">\n";
84
        res += "<manifest OpenIDE-Module=\"" + testModuleName + "\" " +
85
                "OpenIDE-Module-Name=\"" + testModuleName + "\" " +
86
                "AutoUpdate-Show-In-Client=\"true\" " +
87
                "OpenIDE-Module-Specification-Version=\"" + testModuleVersion + "\"/>\n";
88
        res += "</module>";
89
        return res;
90
    }
91
92
    public void testExecutablePermissionsModule() throws IOException {
93
        String os = !org.openide.util.Utilities.isUnix() ? "Windows" : "Unix";
94
        String catalog = generateCatalog(generateExecutablePermissionsModuleElement());
95
96
        p = createUpdateProvider(catalog);
97
        p.refresh(true);
98
99
        Map<String, UpdateUnit> unitImpls = new HashMap<String, UpdateUnit>();
100
        Map<String, UpdateItem> updates = p.getUpdateItems();
101
        assertNotNull("Some modules are installed.", updates);
102
        assertFalse("Some modules are installed.", updates.isEmpty());
103
        assertTrue(testModuleName + " found in parsed items.", updates.keySet().contains(testModuleName + "_" + testModuleVersion));
104
105
        Map<String, UpdateUnit> newImpls = UpdateUnitFactory.getDefault().appendUpdateItems(unitImpls, p);
106
        assertNotNull("Some units found.", newImpls);
107
        assertFalse("Some units found.", newImpls.isEmpty());
108
109
        UpdateUnit u1 = newImpls.get(testModuleName);
110
        installUpdateUnit(u1);
111
        File f = new File(userDir, "bin/start.sh");
112
        assertTrue("File " + f + " should exist after module installation", f.exists());
113
        if (System.getProperty("java.version").startsWith("1.5")) {
114
            File ls = new File("/bin/ls");
115
            if (!ls.isFile()) {
116
                ls = new File("/usr/bin/ls");
117
            }
118
            if (ls.isFile()) {
119
                String output = readCommandOutput(ls.getAbsolutePath(), "-la", f.getAbsolutePath()).trim();
120
                int index = output.indexOf(" ");
121
                assertFalse("Can`t read permissions from output:\n" + output, index == -1);
122
                String permissions = output.substring(0, index);
123
                assertTrue("File " + f + " does not have executable permissions after installation, actual perms : " + permissions,
124
                        permissions.matches(".*x.*x.*x.*"));
125
            }
126
        } else {
127
            Method canExecuteMethod = null;
128
            try {
129
                canExecuteMethod = File.class.getMethod("canExecute", new Class[]{});
130
            } catch (Exception e) {
131
                assertTrue("java.io.File.canExecute method is not accessible", false);
132
            }
133
            boolean canExecute = false;
134
            try {
135
                canExecute = (Boolean) canExecuteMethod.invoke(f);
136
            } catch (Exception e) {
137
                assertTrue("File " + f + " is not executable after module installation", canExecute);
138
                e.printStackTrace();
139
            }
140
        }
141
    }
142
143
    private String readCommandOutput(String... command) {
144
        ProcessBuilder builder = new ProcessBuilder(command);
145
        boolean doRun = true;
146
        StringBuilder sb = new StringBuilder();
147
        byte[] bytes = new byte[8192];
148
        int c = 0;
149
150
        try {
151
            Process process = builder.start();
152
            while (doRun) {
153
                try {
154
                    Thread.sleep(20);
155
                } catch (InterruptedException e) {
156
                }
157
                try {
158
                    process.exitValue();
159
                    doRun = false;
160
                } catch (IllegalThreadStateException e) {
161
                    ; // do nothing - the process is still running
162
                }
163
                InputStream is = process.getInputStream();
164
                while ((c = is.read(bytes)) != -1) {
165
                    sb.append(new String(bytes, 0, c));
166
                }
167
            }
168
            return sb.toString();
169
        } catch (IOException e) {
170
            e.printStackTrace();
171
            return new String();
172
        }
173
    }
174
}
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/MakeExecutableFilesList.java (+150 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
package org.netbeans.nbbuild;
40
41
import java.io.File;
42
import java.util.ArrayList;
43
import java.util.List;
44
import org.apache.tools.ant.BuildException;
45
import org.apache.tools.ant.DirectoryScanner;
46
import org.apache.tools.ant.Project;
47
import org.apache.tools.ant.Task;
48
import org.apache.tools.ant.types.FileSet;
49
50
/**
51
 * Create the list of files which require executable permissions to be set.
52
 * @author Dmitry Lipin
53
 */
54
public class MakeExecutableFilesList extends Task {
55
56
    File targetDir = null;
57
    ModuleFileSet mfs = null;
58
    String executableIncludes = null;
59
    //String propertyName = null;
60
    String refid;
61
    private static final String ALL_FILES_PATTERN = "**";
62
63
64
    //String sep = null;
65
66
    public MakeExecutableFilesList() {
67
    }
68
69
    @Override
70
    public void execute() throws BuildException {
71
        if (targetDir == null) {
72
            throw new BuildException("You have to specify target directoty");
73
        }
74
        //if (propertyName == null) {
75
        //    throw new BuildException("You have to specify property name for storing executable files list");
76
        //}
77
        if (refid == null) {
78
           throw new BuildException("You have to specify reference id for storing executable files list");
79
        }
80
81
        DirectoryScanner moduleFilesDs = mfs.getDirectoryScanner(this.getProject());
82
        moduleFilesDs.scan();
83
        FileSet efs = new FileSet();
84
        efs.setDir(targetDir);
85
        efs.setProject(getProject());
86
        if(executableIncludes==null || executableIncludes.length() == 0) {
87
            efs.setExcludes(ALL_FILES_PATTERN);
88
        } else {
89
            efs.setIncludes(executableIncludes);
90
        }
91
        DirectoryScanner executableDs = efs.getDirectoryScanner(this.getProject());
92
        executableDs.scan();
93
        String[] moduleIncludes = moduleFilesDs.getIncludedFiles();
94
95
        List<String> moduleExecutables = new ArrayList<String>();
96
        for (String executable : executableDs.getIncludedFiles()) {
97
            for (String include : moduleIncludes) {
98
                if (executable.equals(include)) {
99
                    moduleExecutables.add(executable);
100
                    break;
101
                }
102
            }
103
        }
104
105
        if (!moduleExecutables.isEmpty()) {
106
            log("Executable files in module: " + moduleExecutables, Project.MSG_VERBOSE);
107
        } else {
108
            log("No executable files in module: " + moduleExecutables, Project.MSG_VERBOSE);
109
        }
110
        FileSet fs = new FileSet();
111
        fs.setDir(targetDir);
112
        fs.setProject(getProject());
113
        StringBuilder sb = new StringBuilder("");
114
        for (int i = 0; i < moduleExecutables.size(); i++) {
115
            if (i != 0) {
116
                sb.append(" ");
117
            }
118
            sb.append(moduleExecutables.get(i).replace("\\", "/"));
119
        }
120
        if(sb.length()>0) {
121
            fs.setIncludes(sb.toString());
122
        } else {
123
            fs.setExcludes(ALL_FILES_PATTERN);
124
        }
125
        DirectoryScanner ds = fs.getDirectoryScanner();
126
        ds.scan();
127
        log("Executable files length: " + ds.getIncludedFilesCount());
128
        getProject().addReference(refid, fs);
129
    }
130
131
    public void setRefid(String refid) {
132
        this.refid = refid;
133
    }
134
135
    public void setTargetDir(File s) {
136
        this.targetDir = s;
137
    }
138
139
    public void setIncludes(String executableIncludes) {
140
        this.executableIncludes = executableIncludes;
141
    }
142
    public ModuleFileSet createModuleFileSet() {
143
        return (mfs = new ModuleFileSet());
144
    }
145
146
    
147
    
148
    public static class ModuleFileSet extends FileSet {
149
    }
150
}
(-)a/nbbuild/antsrc/org/netbeans/nbbuild/MakeNBM.java (-2 / +41 lines)
Lines 73-82 Link Here
73
import javax.xml.parsers.ParserConfigurationException;
73
import javax.xml.parsers.ParserConfigurationException;
74
import org.apache.tools.ant.AntClassLoader;
74
import org.apache.tools.ant.AntClassLoader;
75
import org.apache.tools.ant.BuildException;
75
import org.apache.tools.ant.BuildException;
76
import org.apache.tools.ant.DirectoryScanner;
76
import org.apache.tools.ant.Project;
77
import org.apache.tools.ant.Project;
77
import org.apache.tools.ant.Task;
78
import org.apache.tools.ant.Task;
78
import org.apache.tools.ant.taskdefs.Jar;
79
import org.apache.tools.ant.taskdefs.Jar;
79
import org.apache.tools.ant.taskdefs.SignJar;
80
import org.apache.tools.ant.taskdefs.SignJar;
81
import org.apache.tools.ant.types.FileSet;
80
import org.apache.tools.ant.types.Path;
82
import org.apache.tools.ant.types.Path;
81
import org.apache.tools.ant.types.ZipFileSet;
83
import org.apache.tools.ant.types.ZipFileSet;
82
import org.w3c.dom.DOMImplementation;
84
import org.w3c.dom.DOMImplementation;
Lines 320-326 Link Here
320
    private ArrayList<Attributes> moduleAttributes = null;
322
    private ArrayList<Attributes> moduleAttributes = null;
321
    private Attributes englishAttr = null;
323
    private Attributes englishAttr = null;
322
    private Path updaterJar;
324
    private Path updaterJar;
323
    
325
    private FileSet executablesSet;
326
324
    /** Try to find and create localized info.xml files */
327
    /** Try to find and create localized info.xml files */
325
    public void setLocales(String s) {
328
    public void setLocales(String s) {
326
        locales = new ArrayList<String>();
329
        locales = new ArrayList<String>();
Lines 342-347 Link Here
342
    public void setFile(File file) {
345
    public void setFile(File file) {
343
        this.file = file;
346
        this.file = file;
344
    }
347
    }
348
349
    /** List of executable files in NBM concatinated by ${line.separator}. */
350
    public FileSet createExecutables() {
351
        return (executablesSet = new FileSet());
352
    }
345
    
353
    
346
    /** Module manifest needed for versioning.
354
    /** Module manifest needed for versioning.
347
     * @deprecated Use {@link #setModule} instead.
355
     * @deprecated Use {@link #setModule} instead.
Lines 653-664 Link Here
653
        for (ZipFileSet zfs : infoXMLFileSets) {
661
        for (ZipFileSet zfs : infoXMLFileSets) {
654
            jar.addFileset(zfs);
662
            jar.addFileset(zfs);
655
        }
663
        }
664
        DirectoryScanner ds = executablesSet.getDirectoryScanner();
665
        ds.scan();
666
        String  [] executables = ds.getIncludedFiles();
667
668
        if(executables!=null && executables.length > 0) {
669
            ZipFileSet executablesList = new ZipFileSet();
670
            File executablesFile;
671
            StringBuilder sb = new StringBuilder("");
672
                String ls = System.getProperty("line.separator");
673
                for(int i=0;i < executables.length;i++) {
674
                    if(i!=0) {
675
                        sb.append(ls);
676
                    }
677
                    sb.append(executables[i].replace("\\","/"));
678
                }
679
            try {
680
                executablesFile = File.createTempFile("executables",".list");
681
                OutputStream infoStream = new FileOutputStream (executablesFile);
682
                try {
683
                    infoStream.write(sb.toString().getBytes());
684
                } finally {
685
                    infoStream.close ();
686
                }
687
            } catch (IOException e) {
688
                throw new BuildException("exception when creating Info/executables.list", e, getLocation());
689
            }
690
            executablesFile.deleteOnExit();
691
            executablesList.setFile(executablesFile);
692
            executablesList.setFullpath("Info/executables.list");
693
            jar.addZipfileset(executablesList);
694
        }
656
695
657
        if (main != null) { // Add the main dir
696
        if (main != null) { // Add the main dir
658
            main.setPrefix("main"); // use main prefix
697
            main.setPrefix("main"); // use main prefix
659
            jar.addZipfileset(main);
698
            jar.addZipfileset(main);
660
        }
699
        }
661
            
700
662
        jar.setCompress(true);
701
        jar.setCompress(true);
663
	jar.setLocation(getLocation());
702
	jar.setLocation(getLocation());
664
	jar.init ();
703
	jar.init ();
(-)a/nbbuild/default.xml (+3 lines)
Lines 60-65 Link Here
60
    <taskdef name="genlist"
60
    <taskdef name="genlist"
61
         classname="org.netbeans.nbbuild.MakeListOfNBM"
61
         classname="org.netbeans.nbbuild.MakeListOfNBM"
62
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
62
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
63
    <taskdef name="genexecutables"
64
         classname="org.netbeans.nbbuild.MakeExecutableFilesList"
65
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
63
    <taskdef name="setcluster"
66
    <taskdef name="setcluster"
64
         classname="org.netbeans.nbbuild.SetCluster"
67
         classname="org.netbeans.nbbuild.SetCluster"
65
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
68
         classpath="${nb_all}/nbbuild/nbantext.jar"/>
(-)a/nbbuild/templates/common.xml (-1 / +20 lines)
Lines 252-257 Link Here
252
                <patternset includes="${release.files}"/>
252
                <patternset includes="${release.files}"/>
253
            </fileset>
253
            </fileset>
254
        </copy>
254
        </copy>
255
        <antcall target="chmod-executables"/>
256
    </target>
257
258
    
259
    <target name="chmod-executables" depends="-init-executables">
260
        <chmod perm="a+x" dir="${cluster}">
261
            <fileset refid="module.executable.files"/>
262
        </chmod>
255
    </target>
263
    </target>
256
264
257
    <target name="verify-class-linkage" depends="jar,release">
265
    <target name="verify-class-linkage" depends="jar,release">
Lines 332-338 Link Here
332
    <target name="-nbm-prompt-for-storepass" if="keystore" unless="storepass">
340
    <target name="-nbm-prompt-for-storepass" if="keystore" unless="storepass">
333
        <input addproperty="storepass" message="Enter password for ${keystore}:"/>
341
        <input addproperty="storepass" message="Enter password for ${keystore}:"/>
334
    </target>
342
    </target>
335
    <target name="nbm" depends="init,netbeans,-nbm-prompt-for-storepass" description="Build NBM archive.">
343
344
    <target name="-init-executables">
345
        <property name="nbm.executable.files" value=""/><!--fallback-->
346
        <genexecutables targetDir="${cluster}" refid="module.executable.files" includes="${nbm.executable.files}">
347
            <modulefileset dir="${cluster}">
348
                <patternset refid="module.files"/>
349
            </modulefileset>
350
        </genexecutables>
351
    </target>
352
353
    <target name="nbm" depends="init,netbeans,-nbm-prompt-for-storepass,-init-executables" description="Build NBM archive.">
336
        <mkdir dir="build"/>
354
        <mkdir dir="build"/>
337
        <property name="nbm.target.cluster" value=""/> <!-- fallback -->
355
        <property name="nbm.target.cluster" value=""/> <!-- fallback -->
338
        <property name="license.file.override" value="${license.file}"/>
356
        <property name="license.file.override" value="${license.file}"/>
Lines 354-359 Link Here
354
                    <filename name="modules/ext/updater.jar"/>
372
                    <filename name="modules/ext/updater.jar"/>
355
                </pathfileset>
373
                </pathfileset>
356
            </updaterjar>
374
            </updaterjar>
375
            <executables refid="module.executable.files"/>
357
        </makenbm>
376
        </makenbm>
358
    </target>
377
    </target>
359
378

Return to bug 24357