]> git.sesse.net Git - vlc/blob - extras/package/macosx/codesign.sh
macosx: added Podcast UI skeleton
[vlc] / extras / package / macosx / codesign.sh
1 #!/bin/sh
2 # Copyright @ 2012 Felix Paul Kühne <fkuehne at videolan dot org>
3 #
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU Lesser General Public License as published by
6 # the Free Software Foundation; either version 2.1 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17
18 info()
19 {
20     local green="\033[1;32m"
21     local normal="\033[0m"
22     echo "[${green}codesign${normal}] $1"
23 }
24
25 usage()
26 {
27 cat << EOF
28 usage: $0 [options]
29
30 Sign VLC.app in the current directory
31
32 OPTIONS:
33    -h            Show this help
34    -i            Identity to use
35    -t            Entitlements file to use
36    -g            Enable additional magic
37 EOF
38
39 }
40
41 while getopts "hi:t:g" OPTION
42 do
43      case $OPTION in
44          h)
45              usage
46              exit 1
47          ;;
48          i)
49              IDENTITY=$OPTARG
50          ;;
51          t)
52              OPTIONS="--entitlements $OPTARG"
53          ;;
54          g)
55              GK="yes"
56          ;;
57      esac
58 done
59 shift $(($OPTIND - 1))
60
61 if [ "x$1" != "x" ]; then
62     usage
63     exit 1
64 fi
65
66 if test -z "$GK"
67 then
68     info "Signing the executable"
69     codesign --force --sign "$IDENTITY" $OPTIONS VLC.app/Contents/MacOS/VLC
70
71     info "Signing the modules"
72     find VLC.app/Contents/MacOS/plugins/* -type f -exec codesign --force -s "$IDENTITY" $OPTIONS '{}' \;
73
74     info "Signing the libraries"
75     find VLC.app/Contents/MacOS/lib/* -type f -exec codesign --force -s "$IDENTITY" $OPTIONS '{}' \;
76
77     info "Signing the lua stuff"
78     find VLC.app/Contents/MacOS/share/lua/* -name *luac -type f -exec codesign --force -s "$IDENTITY" $OPTIONS '{}' \;
79 else
80     REQUIREMENT="=designated => anchor apple generic  and identifier \"org.videolan.vlc\" and ((cert leaf[field.1.2.840.113635.100.6.1.9] exists) or ( certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists  and certificate leaf[subject.OU] = \"75GAHG3SZQ\" ))"
81
82     info "Signing the executable"
83     codesign --force --sign "$IDENTITY" $OPTIONS --requirements "$REQUIREMENT" VLC.app/Contents/MacOS/VLC
84
85     info "Signing the modules"
86     find VLC.app/Contents/MacOS/plugins/* -type f -exec codesign --force -s "$IDENTITY" $OPTIONS --requirements "$REQUIREMENT" '{}' \;
87
88     info "Signing the libraries"
89     find VLC.app/Contents/MacOS/lib/* -type f -exec codesign --force -s "$IDENTITY" $OPTIONS --requirements "$REQUIREMENT" '{}' \;
90
91     info "Signing the lua stuff"
92     find VLC.app/Contents/MacOS/share/lua/* -name *luac -type f -exec codesign --force -s "$IDENTITY" $OPTIONS --requirements "$REQUIREMENT" '{}' \;
93 fi
94
95 info "all items signed, validating..."
96
97 info "Validating binary"
98 codesign --verify VLC.app/Contents/MacOS/VLC
99
100 info "Validating modules"
101 find VLC.app/Contents/MacOS/plugins/* -type f -exec codesign --verify '{}' \;
102
103 info "Validating libraries"
104 find VLC.app/Contents/MacOS/lib/* -type f -exec codesign --verify '{}' \;
105
106 info "Validating lua stuff"
107 find VLC.app/Contents/MacOS/share/lua/* -name *luac -type f -exec codesign --verify '{}' \;
108
109 info "Validation complete"