create-dmg.sh 3.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
set -e

info()
{
    local green="\033[1;32m"
    local normal="\033[0m"
    echo "[${green}Package${normal}] $1"
}

spushd()
{
    pushd "$1" > /dev/null
}

spopd()
{
    popd > /dev/null
}

MOBILE=no
22
TV=no
23
VERBOSE=no
Felix Paul Kühne's avatar
Felix Paul Kühne committed
24
USEZIP=no
25
26
27
28
29
30
31
32
33
34
35
36

usage()
{
cat << EOF
usage: $0 [options]

Build vlc in the current directory

OPTIONS:
   -h            Show some help
   -v            Be verbose
   -m            Package MobileVLCKit
37
   -t            Package TVVLCKit
38
   -z            Use zip file format
39
40
41
42
EOF

}

43
while getopts "hvmtz" OPTION
44
45
46
47
48
49
50
51
52
53
54
55
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         m)
             MOBILE=yes
             ;;
56
57
58
59
         t)
             MOBILE=yes
             TV=yes
             ;;
60
61
62
         z)
             USEZIP=yes
             ;;
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
     esac
done
shift $(($OPTIND - 1))

out="/dev/null"
if [ "$VERBOSE" = "yes" ]; then
   out="/dev/stdout"
fi

if [ "x$1" != "x" ]; then
    usage
    exit 1
fi

root=`dirname $0`/../

DMGFOLDERNAME="VLCKit - binary package"
DMGITEMNAME="VLCKit-REPLACEWITHVERSION"

Felix Paul Kühne's avatar
Felix Paul Kühne committed
82
83
84
85
86
87
88
89
90
if [ "$MOBILE" = "yes" ]; then
    if [ "$USEZIP" = "yes" ]; then
        DMGFOLDERNAME="MobileVLCKit-binary"
    else
        DMGFOLDERNAME="MobileVLCKit - binary package"
    fi
    DMGITEMNAME="MobileVLCKit-REPLACEWITHVERSION"
fi
if [ "$TV" = "yes" ]; then
91
92
93
94
95
96
    if [ "$USEZIP" = "yes" ]; then
        DMGFOLDERNAME="TVVLCKit-binary"
    else
        DMGFOLDERNAME="TVVLCKit - binary package"
    fi
    DMGITEMNAME="TVVLCKit-REPLACEWITHVERSION"
97
98
99
100
101
102
fi

info "checking for distributable binary package"

spushd ${root}
if [ "$MOBILE" = "no" ]; then
103
104
105
106
107
108
109
    if [ ! -e "VLCKit" ]; then
        info "VLCKit not found for distribution, creating..."
        if [ "$VERBOSE" = "yes" ]; then
            make VLCKit V=1
        else
            make VLCKit
        fi
110
111
    fi
else
112
113
114
115
116
117
118
119
120
121
122
    if [ "$TV" = "yes" ]; then
        if [ ! -e "build/TVVLCKit.framework" ]; then
            info "TVVLCKit not found for distribution, creating... this will take long"
            ./buildMobileVLCKit.sh -f -t
        fi
    else
        if [ ! -e "build/MobileVLCKit.framework" ]; then
            info "MobileVLCKit not found for distribution, creating... this will take long"
            ./buildMobileVLCKit.sh -f
        fi
    fi
123
124
fi

125
126
127
info "Deleting previous data"
rm -rf "${DMGFOLDERNAME}"

128
129
130
131
info "Collecting items"
mkdir -p "${DMGFOLDERNAME}"
mkdir -p "${DMGFOLDERNAME}/Sample Code"
if [ "$MOBILE" = "no" ]; then
132
133
    cp -R VLCKit/* "${DMGFOLDERNAME}"
    cp -R Examples_OSX/* "${DMGFOLDERNAME}/Sample Code"
134
    cp -R doc "${DMGFOLDERNAME}"
135
else
136
137
138
139
140
141
    if [ "$TV" = "yes" ]; then
        cp -R build/TVVLCKit.framework "${DMGFOLDERNAME}"
    else
        cp -R build/MobileVLCKit.framework "${DMGFOLDERNAME}"
        cp -R Examples_iOS/* "${DMGFOLDERNAME}/Sample Code"
    fi
142
    cp -R doc "${DMGFOLDERNAME}"
143
    cp COPYING "${DMGFOLDERNAME}"
144
145
146
147
148
149
150
151
fi
cp NEWS "${DMGFOLDERNAME}"
spushd "${DMGFOLDERNAME}"
mv NEWS NEWS.txt
mv COPYING COPYING.txt
spopd
rm -f ${DMGITEMNAME}-rw.dmg

152
if [ "$USEZIP" = "no" ]; then
153
154
155
156
157
158
159
160
161
info "Creating disk-image"
hdiutil create -srcfolder "${DMGFOLDERNAME}" "${DMGITEMNAME}-rw.dmg" -scrub -format UDRW
mkdir -p ./mount

info "Moving file icons around"
hdiutil attach -readwrite -noverify -noautoopen -mountRoot ./mount ${DMGITEMNAME}-rw.dmg
if [ "$MOBILE" = "no" ]; then
osascript Packaging/dmg_setup.scpt "${DMGFOLDERNAME}"
else
162
163
164
    if [ "$TV" = "no" ]; then
        osascript Packaging/mobile_dmg_setup.scpt "${DMGFOLDERNAME}"
    fi
165
166
167
168
169
170
171
172
fi
hdiutil detach ./mount/"${DMGFOLDERNAME}"

info "Compressing disk-image"
rm -f ${DMGITEMNAME}.dmg
hdiutil convert "${DMGITEMNAME}-rw.dmg" -format UDBZ -o "${DMGITEMNAME}.dmg"
rm -f ${DMGITEMNAME}-rw.dmg
rm -rf "${DMGFOLDERNAME}"
173
174
175
176
else
info "Creating zip-archive"
zip -r ${DMGITEMNAME}.zip "${DMGFOLDERNAME}"
fi
177
178
179

spopd

180
info "Distributable package created"