Procházet zdrojové kódy

Reduce dependencies on external binaries.

This includes changes which greatly simplify the build system by
getting rid of the conditional support on Bash, when
Bash is needed for a succesful build anyway. Other changes
include using the "jar" binary (part of JDK) to manipulate jar's,
instead of the external unzip binary (not part of msysgit on
Windows). Issue 4052.

Change-Id: Ib409a977462398156b92b49f824e773694e4f210
Reviewed-on: http://gerrit.dmdirc.com/1164
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.4rc1
Chris Northwood před 14 roky
rodič
revize
5d77a20c7b
6 změnil soubory, kde provedl 303 přidání a 324 odebrání
  1. 26
    0
      build-functions.sh
  2. 62
    73
      build-installer.xml
  3. 23
    25
      build-plugins.xml
  4. 24
    64
      build.xml
  5. 109
    107
      createPluginJar.sh
  6. 59
    55
      updateBundledPlugins.sh

+ 26
- 0
build-functions.sh Zobrazit soubor

@@ -0,0 +1,26 @@
1
+#!/bin/bash
2
+# Provides functions that are used in multiple scripts in the build process
3
+
4
+function safe_mktemp {
5
+	if [ -x "`which mktemp`" ] ; then
6
+		TMPDIR=`mktemp -d`
7
+	else
8
+		if [ -d "$TMP" ] ; then
9
+			# We're running under Windows then use the global TMP location
10
+			TMPDIR="$TMP/$1-`date +%s`-$$-$RANDOM"
11
+		else
12
+			TMPDIR="`pwd`/build/temp/$1-$$-$RANDOM"
13
+		fi
14
+		# this is fragile
15
+		if [ -d "$TMPDIR" ] ; then
16
+			echo "no suitable temp folder found"
17
+			exit 2
18
+		fi
19
+		mkdir -p "$TMPDIR"  
20
+		if [ ! -d "$TMPDIR" ] ; then
21
+			echo "no suitable temp folder found"
22
+			exit 2
23
+		fi
24
+	fi
25
+	echo $TMPDIR
26
+}

+ 62
- 73
build-installer.xml Zobrazit soubor

@@ -1,73 +1,62 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project name="DMDirc-installer" default="default" basedir=".">
3
-    <description>Tasks to build the DMDirc installer.</description>
4
-
5
-    <target name="-installer-build" if="has.bash">
6
-        <exec executable="/bin/bash" dir="installer" resultproperty="installer.result">
7
-            <arg value="release.sh"/>
8
-            <arg value="this"/>
9
-        </exec>
10
-
11
-        <condition property="installer.success">
12
-            <equals arg1="${installer.result}" arg2="0" />
13
-        </condition>
14
-
15
-        <echo message="Installer build finished."/>
16
-        <echo message="Completed build files can be found in:"/>
17
-        <echo message="    ${installer.output.dir}"/>
18
-        <echo message=""/>
19
-    </target>
20
-
21
-
22
-    <target name="-installer-build-stable" if="has.bash">
23
-        <exec executable="/bin/bash" dir="installer" resultproperty="installer.result">
24
-            <arg value="release.sh"/>
25
-            <arg value="-t"/>
26
-            <arg value="-c"/>
27
-            <arg value="STABLE"/>
28
-            <arg value="--upload"/>
29
-        </exec>
30
-
31
-        <condition property="installer.success">
32
-            <equals arg1="${installer.result}" arg2="0" />
33
-        </condition>
34
-
35
-        <echo message="Installer build finished."/>
36
-        <echo message="Completed build files can be found in:"/>
37
-        <echo message="    ${installer.output.dir}"/>
38
-        <echo message=""/>
39
-    </target>
40
-
41
-    <target name="-installer-build-unstable" if="has.bash">
42
-        <exec executable="/bin/bash" dir="installer" resultproperty="installer.result">
43
-            <arg value="release.sh"/>
44
-            <arg value="-t"/>
45
-            <arg value="-c"/>
46
-            <arg value="UNSTABLE"/>
47
-        </exec>
48
-
49
-        <condition property="installer.success">
50
-            <equals arg1="${installer.result}" arg2="0" />
51
-        </condition>
52
-
53
-        <echo message="Installer build finished."/>
54
-        <echo message="Completed build files can be found in:"/>
55
-        <echo message="    ${installer.output.dir}"/>
56
-        <echo message=""/>
57
-    </target>
58
-    
59
-    <target name="-installer-nobuild" unless="has.bash">
60
-        <echo message="This task only works on linux"/>
61
-    </target>
62
-
63
-    <target name="installer" depends="-installer-nobuild, -installer-build"
64
-            description="Build the installer." />
65
-
66
-    <target name="installer-stable" depends="-installer-nobuild, -installer-build-stable"
67
-            description="Build the installer for a stable release." />
68
-
69
-    <target name="installer-unstable" depends="-installer-nobuild, -installer-build-unstable"
70
-            description="Build the installer for an unstable release." />
71
-
72
-
73
-</project>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project name="DMDirc-installer" default="default" basedir=".">
3
+    <description>Tasks to build the DMDirc installer.</description>
4
+
5
+    <target name="installer"
6
+            description="Build the installer.">
7
+        <exec executable="bash" dir="installer" resultproperty="installer.result">
8
+            <arg value="release.sh"/>
9
+            <arg value="this"/>
10
+        </exec>
11
+
12
+        <condition property="installer.success">
13
+            <equals arg1="${installer.result}" arg2="0" />
14
+        </condition>
15
+
16
+        <echo message="Installer build finished."/>
17
+        <echo message="Completed build files can be found in:"/>
18
+        <echo message="    ${installer.output.dir}"/>
19
+        <echo message=""/>
20
+    </target>
21
+
22
+    <target name="installer-stable"
23
+            description="Build the installer for a stable release.">
24
+        <exec executable="bash" dir="installer" resultproperty="installer.result">
25
+            <arg value="release.sh"/>
26
+            <arg value="-t"/>
27
+            <arg value="-c"/>
28
+            <arg value="STABLE"/>
29
+            <arg value="--upload"/>
30
+        </exec>
31
+
32
+        <condition property="installer.success">
33
+            <equals arg1="${installer.result}" arg2="0" />
34
+        </condition>
35
+
36
+        <echo message="Installer build finished."/>
37
+        <echo message="Completed build files can be found in:"/>
38
+        <echo message="    ${installer.output.dir}"/>
39
+        <echo message=""/>
40
+    </target>
41
+
42
+    <target name="installer-unstable"
43
+            description="Build the installer for an unstable release.">
44
+        <exec executable="bash" dir="installer" resultproperty="installer.result">
45
+            <arg value="release.sh"/>
46
+            <arg value="-t"/>
47
+            <arg value="-c"/>
48
+            <arg value="UNSTABLE"/>
49
+        </exec>
50
+
51
+        <condition property="installer.success">
52
+            <equals arg1="${installer.result}" arg2="0" />
53
+        </condition>
54
+
55
+        <echo message="Installer build finished."/>
56
+        <echo message="Completed build files can be found in:"/>
57
+        <echo message="    ${installer.output.dir}"/>
58
+        <echo message=""/>
59
+    </target>
60
+
61
+
62
+</project>

+ 23
- 25
build-plugins.xml Zobrazit soubor

@@ -1,25 +1,23 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project name="DMDirc-plugins" default="default" basedir=".">
3
-
4
-    <!-- Netbeans property files -->
5
-    <property file="nbproject/project.properties"/>
6
-    <property file="nbproject/private/private.properties"/>
7
-    <property file="${user.properties.file}"/>
8
-    
9
-    <target name="build-plugins" depends="-build-plugins_bash" description="Build all plugins"/>
10
-    
11
-    <target name="-build-plugins_bash" if="has.bash">
12
-        <exec executable="/bin/bash">
13
-            <arg value="createAllPluginJar.sh"/>
14
-            <arg value="${src.dir}/com/dmdirc/addons/"/>
15
-        </exec>
16
-    </target>
17
-
18
-    <target name="-update-bundled-plugins" if="has.bash">
19
-       <exec executable="/bin/bash">
20
-            <arg value="updateBundledPlugins.sh"/>
21
-            <arg value="${dist.jar}"/>
22
-       </exec>
23
-    </target>
24
-    
25
-</project>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project name="DMDirc-plugins" default="default" basedir=".">
3
+
4
+    <!-- Netbeans property files -->
5
+    <property file="nbproject/project.properties"/>
6
+    <property file="nbproject/private/private.properties"/>
7
+    <property file="${user.properties.file}"/>
8
+    
9
+    <target name="build-plugins" description="Build all plugins">
10
+        <exec executable="bash">
11
+            <arg value="createAllPluginJar.sh"/>
12
+            <arg value="${src.dir}/com/dmdirc/addons/"/>
13
+        </exec>
14
+    </target>
15
+
16
+    <target name="-update-bundled-plugins">
17
+       <exec executable="bash">
18
+            <arg value="updateBundledPlugins.sh"/>
19
+            <arg value="${dist.jar}"/>
20
+       </exec>
21
+    </target>
22
+    
23
+</project>

+ 24
- 64
build.xml Zobrazit soubor

@@ -1,64 +1,24 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project name="DMDirc" default="default" basedir=".">
3
-    <description>Builds, tests, and runs the project DMDirc.</description>
4
-
5
-    <available file="/bin/bash" property="has.bash"/>
6
-
7
-    <import file="nbproject/build-impl.xml"/>
8
-    <import file="build-installer.xml"/>
9
-    <import file="build-jar.xml"/>
10
-    <import file="build-plugins.xml"/>
11
-    <import file="build-reports.xml"/>
12
-    <import file="build-tests.xml"/>
13
-    <import file="build-versioning.xml"/>
14
-
15
-    <target name="-submodules" depends="-submodules-bash, -submodules-default"/>
16
-
17
-    <target name="-check-use">
18
-        <!-- Use script iff:
19
-               - bash is available
20
-               - submodule.update is set to true
21
-        -->
22
-        <condition property="use.bash.submodule">
23
-            <and>
24
-                <equals arg1="${submodule.update}" arg2="true" />
25
-                <equals arg1="${has.bash}" arg2="true" />
26
-            </and>
27
-        </condition>
28
-        
29
-        <!-- Use git's built in commands iff:
30
-             - submodule.update is set to true
31
-             - bash is not available
32
-        -->
33
-        <condition property="use.default.submodule">
34
-            <and>
35
-                <equals arg1="${submodule.update}" arg2="true" />
36
-                <equals arg1="${has.bash}" arg2="false" />
37
-            </and>
38
-        </condition>
39
-    </target>
40
-
41
-
42
-    <target name="-submodules-bash" depends="-check-use" if="use.bash.submodule">
43
-        <exec executable="/bin/bash">
44
-            <arg value="updateSubModules.sh"/>
45
-        </exec>
46
-    </target>
47
-
48
-    <target name="-submodules-default" depends="-check-use" if="use.default.submodule">
49
-        <exec executable="git">
50
-            <arg value="submodule"/>
51
-            <arg value="init"/>
52
-        </exec>
53
-        <exec executable="git">
54
-            <arg value="submodule"/>
55
-            <arg value="update"/>
56
-        </exec>
57
-    </target>
58
-
59
-    <target name="-pre-init" depends="-submodules"/>
60
-    <target name="-post-compile" depends="-write-version, build-plugins, -addpluginlibs"/>
61
-    <target name="-post-test-run" depends="-do-test-reports"/>
62
-    <target name="-post-jar" depends="-addjarlibs,-update-bundled-plugins"/>
63
-
64
-</project>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project name="DMDirc" default="default" basedir=".">
3
+    <description>Builds, tests, and runs the project DMDirc.</description>
4
+
5
+    <import file="nbproject/build-impl.xml"/>
6
+    <import file="build-installer.xml"/>
7
+    <import file="build-jar.xml"/>
8
+    <import file="build-plugins.xml"/>
9
+    <import file="build-reports.xml"/>
10
+    <import file="build-tests.xml"/>
11
+    <import file="build-versioning.xml"/>
12
+
13
+    <target name="-submodules" if="submodule.update">
14
+        <exec executable="bash">
15
+            <arg value="updateSubModules.sh"/>
16
+        </exec>
17
+    </target>
18
+
19
+    <target name="-pre-init" depends="-submodules"/>
20
+    <target name="-post-compile" depends="-write-version, build-plugins, -addpluginlibs"/>
21
+    <target name="-post-test-run" depends="-do-test-reports"/>
22
+    <target name="-post-jar" depends="-addjarlibs,-update-bundled-plugins"/>
23
+
24
+</project>

+ 109
- 107
createPluginJar.sh Zobrazit soubor

@@ -1,107 +1,109 @@
1
-#!/bin/bash
2
-# This script will create a plugin jar file for a given plugin.
3
-
4
-VALID_EXTS="class,png,exe,dll,html,css,js,gif,py"
5
-
6
-if [ "${1}" = "" -o "${2}" = "" ]; then
7
-	echo "Usage Example: ${0} com.dmdirc.addons.windowstatus WindowStatusPlugin"
8
-	echo "The above would create WindowStatusPlugin.jar in the plugins/ folder of the current dir"
9
-	exit;
10
-fi
11
-
12
-destdir=${PWD}
13
-srcdir=${PWD}/modules/plugins/
14
-pluginname=${1}
15
-foldername=${pluginname//.//}
16
-
17
-if [ "${REBUILDPLUGINS}" != "true" ]; then
18
-	newer=`find ${srcdir}/src/${foldername} -type f -newer ${destdir}/plugins/${2}.jar 2>&1 | wc -l`
19
-	
20
-	if [ $newer -eq 0 ]; then
21
-		echo "${2}.jar appears to be up-to-date";
22
-		exit 0;
23
-	fi
24
-fi;
25
-
26
-echo "Creating ${2}.jar for ${pluginname} (${foldername})"
27
-
28
-if [ ! -e modules/plugins/src/${foldername}/plugin.config ]; then
29
-	echo "no plugin.config found";
30
-	exit 0;
31
-fi
32
-
33
-#echo "looking for classes"
34
-TMPDIR=`mktemp -d`
35
-#echo "Using temp dir: ${TMPDIR}"
36
-cd $TMPDIR
37
-
38
-mkdir META-INF
39
-if [ -e "${srcdir}/src/${foldername}/plugin.config" ]; then
40
-	cp "${srcdir}/src/${foldername}/plugin.config" META-INF/
41
-fi;
42
-
43
-if [ -d "${srcdir}/src/${foldername}/licences/" ]; then
44
-	cp -r "${srcdir}/src/${foldername}/licences/" META-INF/licences/
45
-fi;
46
-
47
-if [ -d "${srcdir}/src/${foldername}/identities/" ]; then
48
-        cp -r "${srcdir}/src/${foldername}/identities/" META-INF/identities/
49
-fi;
50
-
51
-
52
-# Do the same for plugin.config
53
-# This is rudimentary, it a version: section already exists (eg to specify
54
-# friendlyversion) then it won't add the number= key.
55
-if [ -e META-INF/plugin.config ]; then
56
-	VERSIONLINE=`grep -n "version:$" META-INF/plugin.config | cut -f 1 -d ':'`
57
-
58
-	if [ -z "$VERSIONLINE" ]; then
59
-		sed 's/keysections:/keysections:\n  version/g' META-INF/plugin.config > META-INF/plugin.config.temp
60
-		rm -Rf META-INF/plugin.config
61
-		mv META-INF/plugin.config.temp META-INF/plugin.config		
62
-	fi;
63
-
64
-	GIT=`which git`
65
-	REV=$(${GIT} --git-dir "${srcdir}/.git" describe --tags `${GIT} --git-dir "${srcdir}/.git" rev-list --max-count=1 HEAD -- "src/${foldername}"`);
66
-
67
-	echo "" >> META-INF/plugin.config
68
-	echo "" >> META-INF/plugin.config
69
-	echo "version:" >> META-INF/plugin.config;
70
-	echo "  number=$REV" >> META-INF/plugin.config;
71
-fi;
72
-
73
-foo=`echo $foldername | sed -e 's/\/[^\/]*$//g'`
74
-mkdir -p "$foo"
75
-cd "${foo}"
76
-ln -s "${destdir}/build/classes/${foldername}" .
77
-cd "$TMPDIR"
78
-mkdir -p "${destdir}/plugins/"
79
-
80
-rm -Rf "${destdir}/plugins/${2}.jar"
81
-jar -cvf "${srcdir}/src/${foldername}/${2}.jar" META-INF >/dev/null
82
-bit=""
83
-while [ 1 -eq 1 ]; do
84
-	bit=${bit}/*
85
-	ls ${foo}${bit}/* >/dev/null 2>&1
86
-	if [ ${?} -ne 0 ]; then
87
-		break;
88
-	else
89
-		DIR="${PWD}"
90
-		for prepackage in `ls "${srcdir}/src/${foldername}${bit}/prePackage.sh" 2>/dev/null`; do
91
-			cd `dirname "${prepackage}"`
92
-			/bin/sh "${prepackage}"
93
-			cd ${DIR}
94
-		done;
95
-
96
-		FILES="ls -1 "${foo}${bit}/"*.{${VALID_EXTS}}"
97
-                FILES=`eval ${FILES} 2>/dev/null`
98
-
99
-		jar -uvf "${srcdir}/src/${foldername}/${2}.jar" ${FILES} >/dev/null
100
-	fi
101
-done
102
-
103
-mv "${srcdir}/src/${foldername}/${2}.jar" "${destdir}/plugins/"
104
-
105
-cd "${srcdir}"
106
-rm -Rf ${TMPDIR}
107
-#echo "done";
1
+#!/bin/bash
2
+# This script will create a plugin jar file for a given plugin.
3
+
4
+. build-functions.sh
5
+
6
+VALID_EXTS="class,png,exe,dll,html,css,js,gif,py"
7
+
8
+if [ "${1}" = "" -o "${2}" = "" ]; then
9
+	echo "Usage Example: ${0} com.dmdirc.addons.windowstatus WindowStatusPlugin"
10
+	echo "The above would create WindowStatusPlugin.jar in the plugins/ folder of the current dir"
11
+	exit;
12
+fi
13
+
14
+destdir=${PWD}
15
+srcdir=${PWD}/modules/plugins/
16
+pluginname=${1}
17
+foldername=${pluginname//.//}
18
+
19
+if [ "${REBUILDPLUGINS}" != "true" ]; then
20
+	newer=`find ${srcdir}/src/${foldername} -type f -newer ${destdir}/plugins/${2}.jar 2>&1 | wc -l`
21
+	
22
+	if [ $newer -eq 0 ]; then
23
+		echo "${2}.jar appears to be up-to-date";
24
+		exit 0;
25
+	fi
26
+fi;
27
+
28
+echo "Creating ${2}.jar for ${pluginname} (${foldername})"
29
+
30
+if [ ! -e modules/plugins/src/${foldername}/plugin.config ]; then
31
+	echo "no plugin.config found";
32
+	exit 0;
33
+fi
34
+
35
+#echo "looking for classes"
36
+TMPDIR=`safe_mktemp $foldername`
37
+#echo "Using temp dir: ${TMPDIR}"
38
+cd $TMPDIR
39
+
40
+mkdir META-INF
41
+if [ -e "${srcdir}/src/${foldername}/plugin.config" ]; then
42
+	cp "${srcdir}/src/${foldername}/plugin.config" META-INF/
43
+fi;
44
+
45
+if [ -d "${srcdir}/src/${foldername}/licences/" ]; then
46
+	cp -r "${srcdir}/src/${foldername}/licences/" META-INF/licences/
47
+fi;
48
+
49
+if [ -d "${srcdir}/src/${foldername}/identities/" ]; then
50
+        cp -r "${srcdir}/src/${foldername}/identities/" META-INF/identities/
51
+fi;
52
+
53
+
54
+# Do the same for plugin.config
55
+# This is rudimentary, it a version: section already exists (eg to specify
56
+# friendlyversion) then it won't add the number= key.
57
+if [ -e META-INF/plugin.config ]; then
58
+	VERSIONLINE=`grep -n "version:$" META-INF/plugin.config | cut -f 1 -d ':'`
59
+
60
+	if [ -z "$VERSIONLINE" ]; then
61
+		sed 's/keysections:/keysections:\n  version/g' META-INF/plugin.config > META-INF/plugin.config.temp
62
+		rm -Rf META-INF/plugin.config
63
+		mv META-INF/plugin.config.temp META-INF/plugin.config		
64
+	fi;
65
+
66
+	GIT=`which git`
67
+	REV=$(${GIT} --git-dir "${srcdir}/.git" describe --tags `${GIT} --git-dir "${srcdir}/.git" rev-list --max-count=1 HEAD -- "src/${foldername}"`);
68
+
69
+	echo "" >> META-INF/plugin.config
70
+	echo "" >> META-INF/plugin.config
71
+	echo "version:" >> META-INF/plugin.config;
72
+	echo "  number=$REV" >> META-INF/plugin.config;
73
+fi;
74
+
75
+foo=`echo $foldername | sed -e 's/\/[^\/]*$//g'`
76
+mkdir -p "$foo"
77
+cd "${foo}"
78
+ln -s "${destdir}/build/classes/${foldername}" .
79
+cd "$TMPDIR"
80
+mkdir -p "${destdir}/plugins/"
81
+
82
+rm -Rf "${destdir}/plugins/${2}.jar"
83
+jar -cvf "${srcdir}/src/${foldername}/${2}.jar" META-INF >/dev/null
84
+bit=""
85
+while [ 1 -eq 1 ]; do
86
+	bit=${bit}/*
87
+	ls ${foo}${bit}/* >/dev/null 2>&1
88
+	if [ ${?} -ne 0 ]; then
89
+		break;
90
+	else
91
+		DIR="${PWD}"
92
+		for prepackage in `ls "${srcdir}/src/${foldername}${bit}/prePackage.sh" 2>/dev/null`; do
93
+			cd `dirname "${prepackage}"`
94
+			/bin/sh "${prepackage}"
95
+			cd ${DIR}
96
+		done;
97
+
98
+		FILES="ls -1 "${foo}${bit}/"*.{${VALID_EXTS}}"
99
+                FILES=`eval ${FILES} 2>/dev/null`
100
+
101
+		jar -uvf "${srcdir}/src/${foldername}/${2}.jar" ${FILES} >/dev/null
102
+	fi
103
+done
104
+
105
+mv "${srcdir}/src/${foldername}/${2}.jar" "${destdir}/plugins/"
106
+
107
+cd "${srcdir}"
108
+rm -Rf ${TMPDIR}
109
+#echo "done";

+ 59
- 55
updateBundledPlugins.sh Zobrazit soubor

@@ -1,55 +1,59 @@
1
-#!/bin/bash
2
-# updateBundledPlugins.sh <jar>
3
-# 
4
-# Reads the version of each bundled plugin in the specified jar, and writes
5
-# the names and versions to the jar's version.config file.
6
-
7
-jar=$1
8
-dir=`mktemp -d`
9
-config="$dir/com/dmdirc/version.config"
10
-
11
-# Read the jar's version.config out
12
-unzip -qq $jar com/dmdirc/version.config -d $dir;
13
-
14
-# Check for previous data
15
-startOffset=`grep -n "Begin updateBundledPlugins.sh" $config | head -n 1 | cut -f 1 -d ':'`
16
-endOffset=`grep -n "End updateBundledPlugins.sh" $config | tail -n 1 | cut -f 1 -d ':'`
17
-
18
-if [ -n "$startOffset" -a -n "$endOffset" ]; then
19
- # Previous data found, let's get rid of it
20
-
21
- head -n $(($startOffset-2)) $config >> $config.tmp;
22
- tail -n +$(($endOffset+1)) $config >> $config.tmp;
23
-
24
- mv $config.tmp $config;
25
-fi;
26
-
27
-# Add our new sections
28
-echo "" >> $config;
29
-echo "# --- Begin updateBundledPlugins.sh (`date`) --- " >> $config
30
-echo "keysections:" >> $config;
31
-echo "    bundledplugins_versions" >> $config;
32
-echo "" >> $config;
33
-echo "bundledplugins_versions:" >> $config;
34
-
35
-# For each plugin in the jar...
36
-for plugin in `unzip -qql $jar plugins/* | cut -f 2 -d '/'`; do
37
- pluginName=${plugin%.jar}
38
-
39
- # Extract it to our temporary dir (can't extract zip files from stdin)
40
- unzip -qqj $jar plugins/$plugin -d $dir;
41
-
42
- # Read the plugin.config file and parse out the version number
43
- version=`unzip -c $dir/$plugin META-INF/plugin.config | grep -C 1 version: | grep number= | cut -f 2 -d '='`;
44
-
45
- # And add the version to our version.config
46
- echo "    $pluginName=$version" >> $config;
47
-done;
48
-
49
-echo "# --- End updateBundledPlugins.sh --- " >> $config;
50
-
51
-# Update the version in the jar
52
-jar uf $jar -C $dir com/dmdirc/version.config;
53
-
54
-# Remove the temporary directory
55
-rm -rf $dir;
1
+#!/bin/bash
2
+# updateBundledPlugins.sh <jar>
3
+# 
4
+# Reads the version of each bundled plugin in the specified jar, and writes
5
+# the names and versions to the jar's version.config file.
6
+
7
+. build-functions.sh
8
+
9
+jar=$1
10
+dir=`safe_mktemp $jar`
11
+config="$dir/com/dmdirc/version.config"
12
+jar="`pwd`/$jar"
13
+
14
+cd $dir
15
+# Read the jar's version.config out
16
+jar -xf $jar
17
+
18
+# Check for previous data
19
+startOffset=`grep -n "Begin updateBundledPlugins.sh" $config | head -n 1 | cut -f 1 -d ':'`
20
+endOffset=`grep -n "End updateBundledPlugins.sh" $config | tail -n 1 | cut -f 1 -d ':'`
21
+
22
+if [ -n "$startOffset" -a -n "$endOffset" ]; then
23
+ # Previous data found, let's get rid of it
24
+
25
+ head -n $(($startOffset-2)) $config >> $config.tmp;
26
+ tail -n +$(($endOffset+1)) $config >> $config.tmp;
27
+
28
+ mv $config.tmp $config;
29
+fi;
30
+
31
+# Add our new sections
32
+echo "" >> $config;
33
+echo "# --- Begin updateBundledPlugins.sh (`date`) --- " >> $config
34
+echo "keysections:" >> $config;
35
+echo "    bundledplugins_versions" >> $config;
36
+echo "" >> $config;
37
+echo "bundledplugins_versions:" >> $config;
38
+
39
+# For each plugin in the jar...
40
+for plugin in `ls plugins/* | cut -f 2 -d '/'`; do
41
+ pluginName=${plugin%.jar}
42
+
43
+ # Extract it to our temporary dir (can't extract zip files from stdin)
44
+ jar -xf plugins/$plugin;
45
+ # Read the plugin.config file and parse out the version number
46
+ version=`cat META-INF/plugin.config | grep -1 version: | grep number= | cut -f 2 -d '='`;
47
+
48
+ # And add the version to our version.config
49
+ echo "    $pluginName=$version" >> $config;
50
+done;
51
+
52
+echo "# --- End updateBundledPlugins.sh --- " >> $config;
53
+
54
+# Update the version in the jar
55
+jar uf $jar -C $dir com/dmdirc/version.config;
56
+
57
+# Remove the temporary directory
58
+cd ..
59
+rm -rf $dir;

Načítá se…
Zrušit
Uložit