Skip to content

Commit 92310cd

Browse files
committed
make pythonbase.app usefull
1 parent 23abf53 commit 92310cd

File tree

9 files changed

+49
-314
lines changed

9 files changed

+49
-314
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
- run: ./bootstrap.sh
1111
- run: ./build.sh
1212
- run: ./bundle.sh
13-
- run: ./release.sh _build/gPodder.app $(git describe --tags)
14-
- run: rm -Rf _build/gPodder.app/
13+
- run: ./release.sh _build/pythonbase.app $(git describe --tags)
14+
- run: rm -Rf _build/pythonbase.app/ _build/run-*
1515
- store_artifacts:
1616
path: /Users/distiller/project/_build
1717
dummy:

README.asciidoc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
*Don't Panic*
44

5-
This is a collection of files required to build gPodder.app :
6-
gPodder as a native GTK+ Quartz application for Mac OS X 10.9+
5+
This is a collection of files required to build pythonbase.app:
6+
native dependencies to run gPodder as a native GTK+ Quartz application for Mac OS X 10.9+,
7+
with a working python interpreter and pip utility.
78

8-
The scripts are executed on circle.ci, with xcode 9.3.
9+
The scripts are executed on circle.ci, with xcode 9.4.1.
910

1011
NOTE: In case you want just want to run gPodder from source you can ignore all
1112
this and use the released bundle as a development environment. Download the
@@ -54,8 +55,8 @@ https://wiki.gnome.org/Projects/GTK+/OSX/Building#line-38[here]).
5455
Releasing on OS X
5556

5657
. see *<<Creating a Bundle>>*
57-
. test latest gPodder-base-xxx.zip on macOS
58-
. `git tag -a -m "bla bla" base-x.y.z`
58+
. test latest pythonbase-xxx.zip on macOS
59+
. `git tag -a -m "bla bla" YY.MM.DD`
5960
. `git push`
6061
. rerun the latest circleci master job (will pick the new tag)
6162
. `GITHUB_TOKEN=xxxx ./github_release.py --download --circle-build LATEST_CI_BUILD --previous-tag THE_PREVIOUS_RELEASE_TAG base-x.y.z`
@@ -65,19 +66,20 @@ Releasing on OS X
6566
. now you can update the tag in `.circleci/config.yml` of the gPodder project.
6667

6768

68-
Releasing on Linux by patching deps:
69+
Releasing on macOS by using the working pip:
6970

7071
[start=4]
71-
. `./release_on_linux.sh ~/Downloads/gPodder-3.8.4_0.deps.zip /tmp/gpodder`
72+
git clone https://github.com/gpodder/gpodder.git
73+
cd gpodder
74+
./tools/mac-osx/release_on_mac.sh ~/Downloads/pythonbase-21.4.27.zips
7275

7376
== Issues
7477

75-
See https://github.com/elelay/gpodder-osx-bundle
78+
See https://github.com/gpodder/gpodder-osx-bundle
7679

7780
== Using gPodder:
7881

79-
See https://github.com/elelay/gpoder-osx-bundle/wiki/Using for instructions...
80-
And the official help guide http://gpodder.github.io/docs/
82+
See the official help guide http://gpodder.github.io/docs/
8183

8284
== Content Description
8385

bundle.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@ echo compiling native launcher...
88
echo 'clang -mmacosx-version-min=10.9 -framework Foundation -L$PREFIX/lib `python3-config --cflags --ldflags --embed` -o $PREFIX/bin/python-launcher misc/bundle/launcher.m'| jhbuild shell
99

1010
echo creating app...
11-
jhbuild run gtk-mac-bundler misc/bundle/gpodder.bundle
11+
jhbuild run gtk-mac-bundler misc/bundle/pythonbase.bundle
1212

1313
echo post-processing...
14-
APP="$QL_OSXBUNDLE_BUNDLE_DEST/gPodder.app"
14+
APP="$QL_OSXBUNDLE_BUNDLE_DEST/pythonbase.app"
1515
APP_PREFIX="$APP"/Contents/Resources
1616
JHBUILD_PREFIX="$HOME/gtk/inst"
1717
mydir=`pwd`
1818

19-
# change case of gPodder.app
20-
mv "$QL_OSXBUNDLE_BUNDLE_DEST/gpodder.app" "$QL_OSXBUNDLE_BUNDLE_DEST/app.app"
21-
mv "$QL_OSXBUNDLE_BUNDLE_DEST/app.app" "$APP"
22-
2319

20+
CMDS="run-pip run-python"
21+
for cmd in ${CMDS}; do
22+
cp -a "$APP"/Contents/MacOS/{pythonbase,$cmd}
23+
if [ -e "$QL_OSXBUNDLE_BUNDLE_DEST/$cmd" ]; then
24+
unlink "$QL_OSXBUNDLE_BUNDLE_DEST/$cmd"
25+
fi
26+
ln -s $(basename "$APP")/Contents/MacOS/$cmd "$QL_OSXBUNDLE_BUNDLE_DEST/"
27+
done
2428

2529
# kill some useless files
2630
rm -Rf "$APP_PREFIX"/lib/python3.8/test
@@ -33,10 +37,10 @@ find "$APP_PREFIX"/lib/python3.8 -name '*.pyo' -delete
3337
echo checking for dynamic linking consistency : nothing should reference gtk/inst
3438
find "$APP_PREFIX" -name '*.so' -and -print -and -exec sh -c 'otool -L $1 | grep /gtk/inst' '{}' '{}' ';'
3539

36-
# make openssl option dir
40+
# make openssl option dir to prevent looking into /etc
3741
mkdir -p "$APP_PREFIX/etc/openssl"
3842

3943

4044
# list the provenance of every file in the bundle
41-
$mydir/misc/provenance.pl "$JHBUILD_PREFIX" "$APP" > "$QL_OSXBUNDLE_BUNDLE_DEST"/gPodder.contents
45+
$mydir/misc/provenance.pl "$JHBUILD_PREFIX" "$APP" > "$QL_OSXBUNDLE_BUNDLE_DEST"/pythonbase.contents
4246

misc/bundle/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<key>CFBundleDevelopmentRegion</key>
66
<string>English</string>
77
<key>CFBundleExecutable</key>
8-
<string>gpodder</string>
8+
<string>pythonbase</string>
99
<key>CFBundleGetInfoString</key>
1010
<string>gPodder @VERSION@ @COPYRIGHT@</string>
1111
<key>CFBundleIdentifier</key>

misc/bundle/launcher.py

Lines changed: 3 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,14 @@
11
import os
2-
import os.path
32
import platform
43
import re
54
import runpy
6-
import subprocess
75
import sys
8-
import time
9-
import traceback
10-
from os.path import dirname, expanduser, join
11-
from subprocess import PIPE, CalledProcessError, Popen
6+
from os.path import basename, dirname, join
127

138

14-
class MakeCertPem:
15-
""" create openssl cert bundle from system certificates """
16-
17-
def __init__(self, openssl):
18-
self.openssl = openssl
19-
20-
def is_valid_cert(self, cert):
21-
""" check if cert is valid according to openssl"""
22-
cmd = [self.openssl, "x509", "-inform", "pem", "-checkend", "0", "-noout"]
23-
# print("D: is_valid_cert %r" % cmd)
24-
proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
25-
stdout, stderr = proc.communicate(cert)
26-
# print("out: %s; err:%s; ret:%i" % (stdout, stderr, proc.returncode))
27-
return proc.returncode == 0
28-
29-
def get_certs(self):
30-
""" extract System's certificates then filter them by validity
31-
and return a list of text of valid certs
32-
"""
33-
cmd = ["security", "find-certificate", "-a", "-p",
34-
"/System/Library/Keychains/SystemRootCertificates.keychain"]
35-
cert_re = re.compile(b"^-----BEGIN CERTIFICATE-----$" +
36-
b".+?" +
37-
b"^-----END CERTIFICATE-----$", re.M | re.S)
38-
try:
39-
certs_str = subprocess.check_output(cmd)
40-
all_certs = cert_re.findall(certs_str)
41-
print("I: extracted %i certificates" % len(all_certs))
42-
valid_certs = [cert for cert in all_certs
43-
if self.is_valid_cert(cert)]
44-
print("I: of which %i are valid certificates" % len(valid_certs))
45-
return valid_certs
46-
except OSError:
47-
print("E: extracting certificates using %r" % cmd)
48-
traceback.print_exc()
49-
except CalledProcessError as err:
50-
print(("E: extracting certificates using %r, exit=%i" %
51-
(cmd, err.returncode)))
52-
53-
@staticmethod
54-
def write_certs(certs, dest):
55-
""" write concatenated certs to dest """
56-
with open(dest, "wb") as output:
57-
output.write(b"\n".join(certs))
58-
59-
def regen(self, dest):
60-
""" main program """
61-
print("I: make_cert_pem %s %s" % (self.openssl, dest))
62-
certs = self.get_certs()
63-
if certs is None:
64-
print("E: no certificate extracted")
65-
return -1
66-
else:
67-
self.write_certs(certs, dest)
68-
print("I: updated %s with %i certificates" % (dest, len(certs)))
69-
return 0
70-
719
# print("launcher.py sys.argv=", sys.argv)
7210
bundlepath = sys.argv.pop(0)
73-
app = os.path.basename(sys.argv[0])
11+
app = basename(sys.argv[0])
7412

7513
bundle_contents = join(bundlepath, 'Contents')
7614
bundle_res = join(bundle_contents, 'Resources')
@@ -107,70 +45,18 @@ def regen(self, dest):
10745
sys.path.append(bundle_res)
10846
print('System Path:\n','\n'.join(sys.path))
10947

110-
# see https://gpodder.github.io/docs/user-manual.html#gpodder-home-folder-and-download-location
111-
# To override gPodder home and/or download directory:
112-
# 1. uncomment (remove the pound sign and space) at the begining of the relevant line
113-
# 2. replace ~/gPodderData or ~/gPodderDownloads with the path you want for your gPodder home
114-
# (you can move the original folder in the Finder first,
115-
# then drag and drop to the launcher.py in TextEdit to ensure the correct path is set)
116-
# uncomment the following line to override gPodder home
117-
# os.environ['GPODDER_HOME'] = expanduser('~/gPodderData')
118-
# uncomment the following line to override gPodder download directory
119-
# os.environ['GPODDER_DOWNLOAD_DIR'] = expanduser('~/gPodderDownloads')
120-
12148
for k, v in os.environ.items():
12249
print("%s=%s" % (k,v))
12350

124-
def gpodder_home():
125-
# don't inadvertently create the new gPodder home,
126-
# it would be prefered to the old one
127-
default_path = join(os.environ['HOME'], 'Library', 'Application Support', 'gPodder')
128-
cands = [
129-
os.environ.get('GPODDER_HOME'),
130-
default_path,
131-
join(os.environ['HOME'], 'gPodder'),
132-
]
133-
for cand in cands:
134-
if cand and os.path.exists(cand):
135-
return cand
136-
return default_path
137-
138-
139-
gphome = gpodder_home()
140-
os.makedirs(join(gphome, 'openssl'), exist_ok=True)
141-
# generate cert.extracted.pem
142-
cert_gen = join(gphome, 'openssl', 'cert.extracted.pem')
143-
cert_pem = join(gphome, 'openssl', 'cert.pem')
144-
regen = False
145-
if not os.path.isfile(cert_gen):
146-
regen = True
147-
else:
148-
last_modified = os.stat(cert_gen).st_mtime
149-
regen = last_modified < time.time() - 3600 * 7
150-
151-
if regen:
152-
print('(Re)generating', cert_pem)
153-
openssl = join(bundle_bin, 'openssl')
154-
MakeCertPem(openssl).regen(cert_gen)
155-
else:
156-
print('No regenerating', cert_gen, 'it\'s fresh enough')
157-
158-
# and link to it by default. Users may want to point cert.pem to MacPorts
159-
# /opt/local/etc/openssl/cert.pem, for instance.
160-
if not os.path.exists(cert_pem):
161-
os.symlink(os.path.basename(cert_gen), cert_pem)
162-
#Set path to CA files
163-
os.environ['SSL_CERT_FILE'] = cert_pem
51+
python_exe = join(bundle_contents, 'MacOS', 'python3')
16452

16553
if app == 'run-python':
166-
python_exe = join(bundle_contents, 'MacOS', 'python3')
16754
# executable is repeated as argv[0].
16855
# Old sys.argv[0] points to Contents/MacOS so must be removed
16956
args = [python_exe] + sys.argv[1:]
17057
# print("running", args)
17158
os.execv(python_exe, args)
17259
elif app == 'run-pip':
173-
python_exe = join(bundle_contents, 'MacOS', 'python3')
17460
pip = join(bundle_contents, 'Resources', 'bin', 'pip3')
17561
# executable is repeated as argv[0].
17662
# Old sys.argv[0] points to Contents/MacOS so must be removed

misc/bundle/launcher.sh

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)