File: makebundle.py

package info (click to toggle)
gajim 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,320 kB
  • sloc: python: 79,114; sh: 387; xml: 67; makefile: 6
file content (53 lines) | stat: -rwxr-xr-x 1,455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3

import os
import sys
from argparse import ArgumentParser
from subprocess import CalledProcessError
from subprocess import check_output
from subprocess import run

if __name__ == "__main__":
    if not os.path.isdir("mac"):
        sys.exit(
            'Unable to find "mac" directory. make sure you run '
            "this script from the project root"
        )

    parser = ArgumentParser(
        description="Create a macOS .app bundle. "
        "Requires PyInstaller and hdiutil (macOS)."
    )
    parser.add_argument("--version", help="version number of the .app bundle")
    args = parser.parse_args()

    if args.version:
        version = args.version
    else:
        try:
            version = check_output(["git", "describe", "--tags"])
            version = version.decode().strip()
        except CalledProcessError:
            version = "unknown"
    dmg_name = f"gajim-{version}.dmg"

    # the .spec has to be in the project root
    run(["cp", "mac/gajim.spec", "gajim.spec"], check=True)
    run(["pyinstaller", "gajim.spec"], check=True)
    # we only want Gajim.app in the dmg
    run(["rm", "-rf", "dist/launch"], check=True)
    run(
        [
            "hdiutil",
            "create",
            "-volname",
            "Gajim",
            "-srcfolder",
            "dist",
            "-ov",
            "-format",
            "UDZO",
            dmg_name,
        ],
        check=True,
    )