xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #1340: osx-make-appstore-pkg-v2.sh

File osx-make-appstore-pkg-v2.sh, 6.2 KB (added by Antoine Martin, 6 years ago)

updated patch

Line 
1Index: Inherit.entitlements
2===================================================================
3Cannot display: file marked as a binary type.
4svn:mime-type = application/xml
5Index: Inherit.entitlements
6===================================================================
7--- Inherit.entitlements        (revision 0)
8+++ Inherit.entitlements        (working copy)
9
10Property changes on: Inherit.entitlements
11___________________________________________________________________
12Added: svn:mime-type
13## -0,0 +1 ##
14+application/xml
15\ No newline at end of property
16Index: Shell-wrapper.c
17===================================================================
18--- Shell-wrapper.c     (revision 0)
19+++ Shell-wrapper.c     (working copy)
20@@ -0,0 +1,65 @@
21+#include <stdio.h>
22+#include <stdlib.h>
23+#include <string.h>
24+#include <errno.h>
25+#include <unistd.h>
26+#include <libproc.h>
27+
28+/**
29+ * Compile and place the resulting binary somewhere in the bundle under /Contents/
30+ * this program will try to execute the file with the same name in /Contents/Resources/scripts/
31+ * using the shell /bin/sh
32+ */
33+#define MAX_ARGV 100
34+
35+int main (int argc, char* argv[])
36+{
37+       int ret;
38+       pid_t pid;
39+       char pathbuf[PROC_PIDPATHINFO_MAXSIZE+10];
40+       char filename[PROC_PIDPATHINFO_MAXSIZE+10];
41+       char *p;
42+
43+       pid = getpid();
44+       ret = proc_pidpath(pid, pathbuf, PROC_PIDPATHINFO_MAXSIZE);
45+       if (ret <= 0) {
46+               fprintf(stderr, "PID %d: proc_pidpath ();\n", pid);
47+               fprintf(stderr, "       %s\n", strerror(errno));
48+               return 1;
49+       }
50+#ifdef DEBUG
51+       printf("proc %d: %s\n", pid, pathbuf);
52+#endif
53+       //stop on last directory separator to copy the filename:
54+       p = pathbuf;
55+       while (strchr(p, '/')) {
56+               p= strchr(p, '/')+1;
57+       }
58+       strcpy(filename, p);
59+       //stop on last "/Contents" directory:
60+       p = pathbuf;
61+       while (strstr(p, "/Contents/")) {
62+               p = strstr(p, "/Contents/")+1;
63+       }
64+       if (!p) {
65+               fprintf(stderr, "invalid command path '%s': '/Contents/' directory not found in path\n", pathbuf);
66+               return 1;
67+       }
68+       strcpy(p, "/Contents/Resources/scripts/");
69+       strcpy(pathbuf+strlen(pathbuf), filename);
70+       char *new_argv[MAX_ARGV];
71+       new_argv[0] = "/bin/sh";
72+       new_argv[1] = pathbuf;
73+       int i = 1;
74+       while (argv[i]!=NULL && i<(MAX_ARGV-1)) {
75+               new_argv[i+1] = argv[i];
76+               i += 1;
77+       }
78+       new_argv[i+1] = NULL;
79+#ifdef DEBUG
80+       printf("execv(/bin/sh, %s, ..)\n", pathbuf);
81+#endif
82+       int v = execv("/bin/sh", new_argv);
83+       fprintf(stderr, "execv(\"/bin/sh\", %s, ..) returned %i\n", pathbuf, v);
84+       return v;
85+}
86Index: make-appstore-PKG.sh
87===================================================================
88--- make-appstore-PKG.sh        (revision 0)
89+++ make-appstore-PKG.sh        (working copy)
90@@ -0,0 +1,72 @@
91+#!/bin/bash
92+
93+echo
94+echo "*******************************************************************************"
95+if [ ! -d "./image/Xpra.app" ]; then
96+       echo "./image/Xpra.app is missing - cannot continue"
97+       exit 1
98+fi
99+rm -fr ./appstore/ 2>&1 > /dev/null
100+mkdir appstore
101+cp -R ./image/Xpra.app ./appstore/
102+echo "WARNING: removing sound sub-app support"
103+rm -fr ./appstore/Xpra.app/Contents/Xpra_NoDock.app
104+
105+#get the version and build info from the python build records:
106+export PYTHONPATH="appstore/Xpra.app/Contents/Resources/lib/python/"
107+VERSION=`python -c "from xpra import __version__;import sys;sys.stdout.write(__version__)"`
108+REVISION=`python -c "from xpra import src_info;import sys;sys.stdout.write(str(src_info.REVISION))"`
109+REV_MOD=`python -c "from xpra import src_info;import sys;sys.stdout.write(['','M'][src_info.LOCAL_MODIFICATIONS>0])"`
110+BUILD_CPU=`python -c "from xpra import build_info;import sys;sys.stdout.write(str(build_info.BUILD_CPU))"`
111+BUILD_INFO=""
112+if [ "$BUILD_CPU" != "i386" ]; then
113+       BUILD_INFO="-x86_64"
114+fi
115+
116+PKG_FILENAME="./image/Xpra$BUILD_INFO-$VERSION-r$REVISION$REV_MOD-appstore.pkg"
117+rm -f $PKG_FILENAME >& /dev/null
118+echo "Making $PKG_FILENAME"
119+
120+rm appstore/Xpra.app/Contents/MacOS/*
121+
122+#move all the scripts to Resources/scripts:
123+mkdir appstore/Xpra.app/Contents/Resources/scripts
124+rm -f appstore/Xpra.app/Contents/MacOS/*
125+for x in Bug_Report GTK_info Network_info Python Xpra Launcher Config_info Keyboard_Tool OpenGL_check PythonExecWrapper Encoding_info Keymap_info Path_info Version_info Shadow Feature_info Manual PowerMonitor Webcam_Test GStreamer_info NativeGUI_info Print Websockify; do
126+       mv "appstore/Xpra.app/Contents/Helpers/$x" "appstore/Xpra.app/Contents/Resources/scripts/"
127+       if [ "$x" != "PythonExecWrapper" ]; then
128+               cat appstore/Xpra.app/Contents/Info.plist | sed "s+Launcher+$x+g" | sed "s+org.xpra.Xpra+org.xpra.$x+g" | sed "s+Xpra+$x+g" > ./appstore/temp.plist
129+               gcc -arch i386 -o "appstore/Xpra.app/Contents/MacOS/$x" "./Shell-wrapper.c" -sectcreate __TEXT __info_plist ./appstore/temp.plist
130+               rm appstore/temp.plist
131+       fi
132+done
133+ls -la appstore/Xpra.app/Contents/MacOS
134+echo
135+ls -la appstore/Xpra.app/Contents/Helpers
136+#remove gstreamer bits:
137+#rm appstore/Xpra.app/Contents/Helpers/gst*
138+
139+
140+CODESIGN_ARGS="--force --verbose --sign \"3rd Party Mac Developer Application\" --entitlements ./Xpra.entitlements"
141+eval codesign $CODESIGN_ARGS appstore/Xpra.app/Contents/MacOS/Launcher
142+eval codesign $CODESIGN_ARGS appstore/Xpra.app/Contents/Helpers/*
143+EXES=`find appstore/Xpra.app/Contents/MacOS -type f | grep -v "Launcher" | xargs`
144+eval codesign $CODESIGN_ARGS $EXES
145+
146+CODESIGN_ARGS="--force --verbose --sign \"3rd Party Mac Developer Application\" --entitlements ./Inherit.entitlements"
147+LIBS=`find appstore/Xpra.app/Contents/Resources -name "*so" -or -name "*dylib" | xargs`
148+eval codesign $CODESIGN_ARGS $LIBS
149+eval "find appstore/Xpra.app/Contents/Resources/bin/ -type f -exec codesign $CODESIGN_ARGS {} \;"
150+
151+CODESIGN_ARGS="--force --verbose --sign \"3rd Party Mac Developer Application\" --entitlements ./Xpra.entitlements"
152+eval codesign $CODESIGN_ARGS appstore/Xpra.app/Contents/MacOS/Launcher
153+eval codesign $CODESIGN_ARGS appstore/Xpra.app
154+productbuild --component ./appstore/Xpra.app /Applications $PKG_FILENAME --sign "3rd Party Mac Developer Installer: $CODESIGN_KEYNAME"
155+
156+#show resulting file and copy it to the desktop
157+du -sm $PKG_FILENAME
158+cp $PKG_FILENAME ~/Desktop/
159+
160+echo "Done PKG"
161+echo "*******************************************************************************"
162+echo
163
164Property changes on: make-appstore-PKG.sh
165___________________________________________________________________
166Added: svn:executable
167## -0,0 +1 ##
168+*
169\ No newline at end of property