create-distributable-package.sh 4.51 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
24
USEZIP=no
25 26
USECOMPRESSEDARCHIVE=yes
USEDMG=no
27 28 29 30 31 32

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

33 34
Package VLCKit

35
  By default, VLCKit will be packaged as a tar.xz archive.
36
  You can use the options below to package a different flavor of VLCKit
37
  or/and to store the binaries in a zip or a dmg file instead.
38 39 40 41 42

OPTIONS:
   -h            Show some help
   -v            Be verbose
   -m            Package MobileVLCKit
43
   -t            Package TVVLCKit
44
   -z            Use zip file format
45
   -d            Use dmg file format
46 47 48 49
EOF

}

50
while getopts "hvmtz" OPTION
51 52 53 54 55 56 57 58 59 60 61 62
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         m)
             MOBILE=yes
             ;;
63 64 65 66
         t)
             MOBILE=yes
             TV=yes
             ;;
67 68 69
         z)
             USEZIP=yes
             ;;
70 71 72 73
         z)
             USEDMG=yes
             USECOMPRESSEDARCHIVE=no
             ;;
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
     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"

93
if [ "$USECOMPRESSEDARCHIVE" != "yes" ]; then
94 95 96
    DMGFOLDERNAME="VLCKit-binary"
fi

97
if [ "$MOBILE" = "yes" ]; then
98
    if [ "$USECOMPRESSEDARCHIVE" = "yes" ]; then
99 100 101 102 103 104 105
        DMGFOLDERNAME="MobileVLCKit-binary"
    else
        DMGFOLDERNAME="MobileVLCKit - binary package"
    fi
    DMGITEMNAME="MobileVLCKit-REPLACEWITHVERSION"
fi
if [ "$TV" = "yes" ]; then
106
    if [ "$USECOMPRESSEDARCHIVE" = "yes" ]; then
107 108 109 110 111
        DMGFOLDERNAME="TVVLCKit-binary"
    else
        DMGFOLDERNAME="TVVLCKit - binary package"
    fi
    DMGITEMNAME="TVVLCKit-REPLACEWITHVERSION"
112 113 114 115 116 117
fi

info "checking for distributable binary package"

spushd ${root}
if [ "$MOBILE" = "no" ]; then
118
    if [ ! -e "build/Release/VLCKit.framework" ]; then
119
        info "VLCKit not found for distribution, creating... this will take long"
120
        ./compileAndBuildVLCKit.sh -x
121 122
    fi
else
123 124 125
    if [ "$TV" = "yes" ]; then
        if [ ! -e "build/TVVLCKit.framework" ]; then
            info "TVVLCKit not found for distribution, creating... this will take long"
126
            ./compileAndBuildVLCKit.sh -f -t
127 128 129 130
        fi
    else
        if [ ! -e "build/MobileVLCKit.framework" ]; then
            info "MobileVLCKit not found for distribution, creating... this will take long"
131
            ./compileAndBuildVLCKit.sh -f
132 133
        fi
    fi
134 135
fi

136 137 138
info "Deleting previous data"
rm -rf "${DMGFOLDERNAME}"

139 140 141 142
info "Collecting items"
mkdir -p "${DMGFOLDERNAME}"
mkdir -p "${DMGFOLDERNAME}/Sample Code"
if [ "$MOBILE" = "no" ]; then
143
    cp -R build/Release/VLCKit.framework "${DMGFOLDERNAME}"
144
    cp -R Examples/macOS/* "${DMGFOLDERNAME}/Sample Code"
145
    cp -R doc "${DMGFOLDERNAME}"
146
    cp COPYING "${DMGFOLDERNAME}"
147
else
148 149 150 151
    if [ "$TV" = "yes" ]; then
        cp -R build/TVVLCKit.framework "${DMGFOLDERNAME}"
    else
        cp -R build/MobileVLCKit.framework "${DMGFOLDERNAME}"
152
        cp -R Examples/iOS/* "${DMGFOLDERNAME}/Sample Code"
153
    fi
154
    cp -R doc "${DMGFOLDERNAME}"
155
    cp COPYING "${DMGFOLDERNAME}"
156 157 158 159 160 161 162
fi
cp NEWS "${DMGFOLDERNAME}"
spushd "${DMGFOLDERNAME}"
mv NEWS NEWS.txt
mv COPYING COPYING.txt
spopd

163 164 165
if [ "$USEDMG" = "yes" ]; then
    info "Creating disk-image"
    rm -f ${DMGITEMNAME}-rw.dmg
166 167
    hdiutil create -srcfolder "${DMGFOLDERNAME}" "${DMGITEMNAME}-rw.dmg" -scrub -format UDRW
    mkdir -p ./mount
168

169 170 171 172 173 174 175 176
    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
        if [ "$TV" = "no" ]; then
            osascript Packaging/mobile_dmg_setup.scpt "${DMGFOLDERNAME}"
        fi
177
    fi
178
    hdiutil detach ./mount/"${DMGFOLDERNAME}"
179

180 181 182 183 184
    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}"
185
else
186 187 188 189 190 191 192
    if [ "$USEZIP" = "yes" ]; then
        info "Creating zip-archive"
        zip -y -r ${DMGITEMNAME}.zip "${DMGFOLDERNAME}"
    else
        info "Creating xz-archive"
        tar -cJf ${DMGITEMNAME}.tar.xz "${DMGFOLDERNAME}"
    fi
193
fi
194 195 196

spopd

197
info "Distributable package created"