File: Make_MC_dmg.sh

package info (click to toggle)
mediaconch 25.04-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,828 kB
  • sloc: ansic: 126,293; cpp: 39,636; javascript: 34,300; xml: 2,950; sh: 2,121; makefile: 200; python: 183
file content (170 lines) | stat: -rw-r--r-- 5,462 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/sh

if test -d ~/Qt/5.3/clang_64/bin; then
    PATH=$PATH:~/Qt/5.3/clang_64/bin
fi

if [ $# != 2 ]; then
    echo
    echo "Usage: Make_MC_dmg.sh kind version"
    echo
    exit 1
fi

KIND="$1"
VERSION="$2"

if [ "$KIND" = "CLI" ] || [ "$KIND" = "cli" ]; then
    KIND="CLI"
elif [ "$KIND" = "Server" ] || [ "$KIND" = "server" ]; then
    KIND="Server"
elif [ "$KIND" = "GUI" ] || [ "$KIND" = "gui" ]; then
    KIND="GUI"
else
    echo
    echo "KIND must be either [CLI | cli] or [Server | server ] or [GUI | gui]"
    echo
    exit 1
fi

APPNAME="MediaConch"
APPNAME_lower=`echo ${APPNAME} |awk '{print tolower($0)}'`
KIND_lower=`echo ${KIND} |awk '{print tolower($0)}'`
SIGNATURE="MediaArea.net"
FILES="tmp-${APPNAME}_${KIND}"
TEMPDMG="tmp-${APPNAME}_${KIND}.dmg"
FINALDMG="${APPNAME}_${KIND}_${VERSION}_Mac.dmg"
WD=`pwd`

# Clean up
rm -fr "${FILES}-Root"
rm -fr "${FILES}"
rm -f "${APPNAME}.pkg"
rm -f "${TEMPDMG}"
rm -f "${FINALDMG}"

echo
echo ========== Create the package ==========
echo

mkdir -p "${FILES}/.background"
cp ../../License.html "${FILES}"
cp Logo_White.icns "${FILES}/.background"
if [ "$KIND" = "CLI" ] || [ "$KIND" = "GUI" ]; then
    cp "../../Release/ReadMe_${KIND}_Mac.txt" "${FILES}/ReadMe.txt"
    cp "../../History_${KIND}.txt" "${FILES}/History.txt"
fi

if [ "$KIND" = "CLI" ]; then

    cd ../GNU/CLI
    if test -e ".libs/${APPNAME_lower}"; then
        mv -f ".libs/${APPNAME_lower}" .
    fi
    if ! test -x "${APPNAME_lower}"; then
        echo
        echo "${APPNAME_lower} can’t be found, or this file isn’t a executable."
        echo
        exit 1
    fi
    strip -u -r "${APPNAME_lower}"
    cd ../../Mac

    mkdir -p "${FILES}-Root/usr/local/bin"
    cp "../GNU/CLI/${APPNAME_lower}" "${FILES}-Root/usr/local/bin"
    codesign --deep --options=runtime --force --verbose --sign "Developer ID Application: ${SIGNATURE}" "${FILES}-Root/usr/local/bin/${APPNAME_lower}"

    pkgbuild --root "${FILES}-Root" --identifier "net.mediaarea.${APPNAME_lower}.mac-${KIND_lower}" --sign "Developer ID Installer: ${SIGNATURE}" --version "${VERSION}" "${FILES}/${APPNAME_lower}.pkg"
    codesign --deep --options=runtime --force --verbose --sign "Developer ID Application: ${SIGNATURE}" "${FILES}/${APPNAME_lower}.pkg"

fi

if [ "$KIND" = "Server" ]; then

    APPNAME_lower="mediaconchd"

    cd ../GNU/Server
    if test -e ".libs/${APPNAME_lower}"; then
        mv -f ".libs/${APPNAME_lower}" .
    fi
    if ! test -x "${APPNAME_lower}"; then
        echo
        echo "${APPNAME_lower} can’t be found, or this file isn’t an executable."
        echo
        exit 1
    fi
    strip -u -r "${APPNAME_lower}"
    cd ../../Mac

    mkdir -p "${FILES}-Root/usr/local/bin"
    cp "../GNU/Server/${APPNAME_lower}" "${FILES}-Root/usr/local/bin"
    codesign --deep --options=runtime --force --verbose --sign "Developer ID Application: ${SIGNATURE}" "${FILES}-Root/usr/local/bin/${APPNAME_lower}"

    pkgbuild --root "${FILES}-Root" --identifier "net.mediaarea.${APPNAME_lower}.mac-${KIND_lower}" --sign "Developer ID Installer: ${SIGNATURE}" --version "${VERSION}" "${FILES}/${APPNAME_lower}.pkg"
    codesign --deep --options=runtime --force --verbose --sign "Developer ID Application: ${SIGNATURE}" "${FILES}/${APPNAME_lower}.pkg"

fi

if [ "$KIND" = "GUI" ]; then

    strip -u -r "../Qt/${APPNAME}.app/Contents/MacOS/${APPNAME}"
    cp -r "../Qt/${APPNAME}.app" "${FILES}/"
    sed -i '' -e "s/VERSION/${VERSION}/g" "${FILES}/${APPNAME}.app/Contents/Info.plist"
    macdeployqt "${FILES}/${APPNAME}.app"

    echo
    echo
    echo Signing the application...
    echo

    codesign --options=runtime --force --verbose --entitlements QtWebEngineProcess-ns.entitlements --sign "Developer ID Application: ${SIGNATURE}" "${FILES}/${APPNAME}.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess"
    codesign --deep --options=runtime --force --verbose --preserve-metadata=identifier,entitlements --sign "Developer ID Application: ${SIGNATURE}" "${FILES}/${APPNAME}.app"

    echo
    echo
    echo Verifying the signature...
    echo
    codesign --verify --deep --verbose=1 "${FILES}/${APPNAME}.app/Contents/MacOS/${APPNAME}"

    echo
    echo
fi

echo
echo ========== Create the disk image ==========
echo

# Check if an old image isn't already attached
DEVICE=$(hdiutil info |grep -B 1 "/Volumes/${APPNAME}" |egrep '^/dev/' | sed 1q | awk '{print $1}')
test -e "$DEVICE" && hdiutil detach -force "${DEVICE}"

hdiutil create "${TEMPDMG}" -ov -fs HFS+ -format UDRW -volname "${APPNAME}" -srcfolder "${FILES}"
DEVICE=$(hdiutil attach -readwrite -noverify "${TEMPDMG}" | egrep '^/dev/' | sed 1q | awk '{print $1}')
sleep 2

cd "/Volumes/${APPNAME}"
if [ "$KIND" = "GUI" ]; then
    ln -s /Applications
fi
test -e .DS_Store && rm -fr .DS_Store
cd - >/dev/null

if [ "$KIND" = "CLI" ] || [ "$KIND" = "GUI" ]; then
    . Osascript_${KIND}.sh
    osascript_Function
fi

hdiutil detach "${DEVICE}"
sleep 2

echo
echo ========== Convert to compressed image ==========
echo
hdiutil convert "${TEMPDMG}" -format UDBZ -o "${FINALDMG}"

# Useless since the dmg will transit on no HFS+ partition (at least
# on the linux server)
codesign --deep --options=runtime --force --verbose --sign "Developer ID Application: ${SIGNATURE}" "${FINALDMG}"

unset -v APPNAME APPNAME_lower KIND KIND_lower VERSION SIGNATURE
unset -v FILES TEMPDMG FINALDMG WD FRAMEWORK DEVICE TMP