Skip to content

Commit

Permalink
Bump to version 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhayward committed Jun 28, 2016
1 parent 4fc99a8 commit 120561f
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 124 deletions.
Binary file modified Extras/Transcode Log Analyzer.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion Extras/uninstallTranscode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin export PATH

function define_Constants () {
# define version number
local versStamp="Version 1.0.9, 06-25-2017"
local versStamp="Version 1.1.0, 06-25-2017"
readonly scriptVers="${versStamp:8:${#versStamp}-20}"

loggerTag="transcode.uninstall"
Expand Down Expand Up @@ -146,6 +146,7 @@ function uninstall_preferenceFiles () {
removeThis[9]="${libDir}/Preferences/com.videotranscode.gem.update.plist"
removeThis[10]="${libDir}/Preferences/com.videotranscode.transcode.update.plist"
removeThis[11]="${libDir}/Preferences/com.videotranscode.transcode.full.update.plist"
removeThis[12]="${libDir}/Preferences/com.videotranscode.gem.update.inprogress.plist"

# remove preferences
for i in "${removeThis[@]}"; do
Expand Down
Binary file modified Setup Assistant/Transcode Setup Assistant.zip
Binary file not shown.
Binary file modified Updater/AutoUpdater.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Updater/SHA1_AU.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>SHA1checksum</key>
<string>3584c65273b5f7bf7269610abee38c38253e4f09</string>
<string>be71bdba34b30f3652fa545b521ae50be52f40db</string>
</dict>
</plist>
Binary file modified Updater/Transcode Updater.zip
Binary file not shown.
94 changes: 55 additions & 39 deletions Updater/updateTranscode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin export PATH
#----------------------------------------------------------FUNCTIONS----------------------------------------------------------------

function define_Constants () {
local versStamp="Version 1.2.0, 06-24-2016"
local versStamp="Version 1.2.4, 06-28-2016"

loggerTag="transcode.update"

readonly prefDir="${libDir}/Preferences"
readonly workDir=$(aliasPath "${libDir}/Application Support/Transcode/Transcode alias")

readonly updaterPath=$(mktemp -d "/tmp/transcodeUpdater_XXXXXXXXXXXX")
readonly icnsPath="${libDir}/Application Support/Transcode/Transcode_custom.icns"

readonly comLabel="com.videotranscode.transcode"
readonly sh_echoMsg="${appScriptsPath}/_echoMsg.sh"
readonly sh_ifError="${appScriptsPath}/_ifError.sh"
readonly sh_updatePost="${appScriptsPath}/Transcode Updater.app/Contents/Resources/updateTranscodePost.sh"
readonly plistBuddy="/usr/libexec/PlistBuddy"
readonly versCurrent=$(${plistBuddy} -c 'print :CFBundleShortVersionString' "${appScriptsPath}/Transcode Updater.app/Contents/Resources/transcodeVersion.plist")

fullUpdate="false"
needsUpdate="false"
SHA1Clean="false"

# From brewAutoUpdate:
# readonly libDir="${HOME}/Library"
# readonly appScriptsPath="${libDir}/Application Scripts/com.videotranscode.transcode"
Expand All @@ -51,42 +54,27 @@ function runAndDisown () {
"$@" &
}

function clean_Up () {
# delete the auto-update files
rm -rf "${updaterPath}"
# run the post-update script and disown from this shell so this script can be updated if needed
runAndDisown "${appScriptsPath}/Transcode Updater.app/Contents/Resources/updateTranscodePost.sh"
}

function check4Update_Transcode () {
local needsUpdatePlist="${comLabel}.update.plist"
local downloadedZipFile="Transcode Updater.zip"
local capturedOutput=""
local needsUpdatePath="${prefDir}/${needsUpdatePlist}"

. "${sh_echoMsg}" "Checking for Transcode updates..." ""
# has the update been checked for previously
if [ ! -e "${needsUpdatePath}" ]; then
# get a copy of Transcode Updater.app
curl -L -o "${updaterPath}/${downloadedZipFile}" github.com/bmhayward/Transcode/raw/master/Updater/Transcode%20Updater.zip > /dev/null
curl -L -o "${updaterPath}/${downloadedZipFile}" github.com/bmhayward/Transcode/raw/master/Updater/Transcode%20Updater.zip > /dev/null
# extract the Version.plist from the archive
unzip -j "${updaterPath}/${downloadedZipFile}" "Transcode Updater.app/Contents/Resources/transcodeVersion.plist" -d "${updaterPath}" > /dev/null
unzip -j "${updaterPath}/${downloadedZipFile}" "Transcode Updater.app/Contents/Resources/transcodeVersion.plist" -d "${updaterPath}" > /dev/null
# remove any remnants of the unzip
rm -rf "${updaterPath}/__MACOSX"
rm -rf "${updaterPath}/__MACOSX"
# check the version numbers for an update
capturedOutput=$(diff --brief "${appScriptsPath}/Transcode Updater.app/Contents/Resources/transcodeVersion.plist" "${updaterPath}/transcodeVersion.plist")

if [[ "${capturedOutput}" = *"differ"* ]]; then
# create the Transcode update sempahore
touch "${needsUpdatePath}"
fi
capturedOutput=$(diff --brief "${appScriptsPath}/Transcode Updater.app/Contents/Resources/transcodeVersion.plist" "${updaterPath}/transcodeVersion.plist")

if [[ "${capturedOutput}" = *"differ"* ]]; then
# needs update
needsUpdate="true"
fi
}

function update_Transcode () {
local needsUpdatePlist="${comLabel}.update.plist"
local needsUpdatePath="${prefDir}/${needsUpdatePlist}"
local needsFullUpdatePlist="${comLabel}.full.update.plist"
local waitingPlist="{prefDir}/com.videotranscode.batch.waiting.plist"
local onHoldPlist="{prefDir}/com.videotranscode.batch.onhold.plist"
local workingPlist="{prefDir}/com.videotranscode.batch.working.plist"
Expand All @@ -100,7 +88,7 @@ function update_Transcode () {
local SHA1=""
local capturedOutput=""
# can update happen
if [[ -e "${needsUpdatePath}" ]] && [[ ! -e "${waitingPlist}" || ! -e "${onHoldPlist}" || ! -e "${workingPlist}" ]]; then
if [[ "${needsUpdate}" == "true" ]] && [[ ! -e "${waitingPlist}" || ! -e "${onHoldPlist}" || ! -e "${workingPlist}" ]]; then
# pull down a copy of AutoUpdater
curl -L -o "${updaterPath}/${downloadedZipFile}" github.com/bmhayward/Transcode/raw/master/Updater/${downloadedZipFile} >/dev/null
# pull down a copy of SHA1 checksum
Expand All @@ -111,7 +99,8 @@ function update_Transcode () {
capturedOutput=$(shasum "${updaterPath}/${downloadedZipFile}")
SHA1="${capturedOutput%% *}"
# do the SHA1 checksums match?
if [ "${auSHA1}" == "${SHA1}" ]; then
if [ "${auSHA1}" == "${SHA1}" ]; then
SHA1Clean="true"
# extract the auto-update to the AutoUpdater directory in the temp folder
unzip "${updaterPath}/${downloadedZipFile}" -d "${updaterPath}/${downloadedZipFile%.*}" >/dev/null
# unzip any applications in the AutoUpdater directory
Expand All @@ -127,8 +116,8 @@ function update_Transcode () {
versUpdate=$(${plistBuddy} -c 'print :CFBundleShortVersionString' "${updaterPath}/transcodeVersion.plist")
# check to see if a full update needs to be done
if [ "${versCurrent}" != "${versPrevious}" ]; then
# create the Transcode full update semaphore
touch "${prefDir}/${needsFullUpdatePlist}"
# needs full update
fullUpdate="true"
fi

. "${sh_echoMsg}" "Updating Transcode from ${versCurrent} to ${versUpdate}." ""
Expand Down Expand Up @@ -160,7 +149,6 @@ function update_Transcode () {

case "${fileType}" in
sh|app|command )

if [ "${fileName}" != "updateTranscode.sh" ]; then
# move to the update location
ditto "${i}" "${transcode2Replace}"
Expand All @@ -176,37 +164,65 @@ function update_Transcode () {
;;

workflow )

cp -R -p "${i}" "${transcode2Replace}"

. "${sh_echoMsg}" "==> Updated ${fileName}" ""
;;
esac
done

. "${sh_echoMsg}" "Update complete." ""
else
if [ -e "${prefDir}/${needsFullUpdatePlist}" ]; then
# remove the full update semaphore file
rm -f "${prefDir}/${needsFullUpdatePlist}"
fi
# remove the full update flag
fullUpdate="false"

. "${sh_echoMsg}" "SHA1 checksums do not match, update skipped." ""
fi
# delete the sempahore file
rm -f "${needsUpdatePath}"
elif [[ -e "${waitingPlist}" || -e "${onHoldPlist}" || -e "${workingPlist}" ]]; then
. "${sh_echoMsg}" "Update deferred." ""
else
. "${sh_echoMsg}" "Already up-to-date." ""
fi
}

function clean_Up () {
# delete the auto-update files from /tmp
rm -rf "${updaterPath}"

find "${appScriptsPath}/" -name "*.sh" -exec chmod +x {} \;
find "${workDir}/" -name "*.command" -exec chmod +x {} \;
find "${workDir}/Extras/" -name "*.command" -exec chmod +x {} \;

local gemUpdatePlist="com.videotranscode.gem.update.plist"
local plistName="com.videotranscode.gemautoupdate"
local plistFile="${libDir}/LaunchAgents/${plistName}.plist" # get the watch folder launch agent

if [ ! -e "${plistFile}" ]; then # write out the watch folder LaunchAgent plist to ~/Library/LaunchAgent
local watchPath="${libDir}/Preferences/${gemUpdatePlist}" # get the path to the watch plist

${plistBuddy} -c 'Add :Label string "'"${plistName}"'"' "${plistFile}"; cat "${plistFile}" > /dev/null 2>&1
${plistBuddy} -c 'Add :ProgramArguments array' "${plistFile}"
${plistBuddy} -c 'Add :ProgramArguments:0 string "'"${appScriptsPath}/Transcode Updater.app/Contents/Resources/updateTranscodeGemsCheck.sh"'"' "${plistFile}"
${plistBuddy} -c 'Add :RunAtLoad bool true' "${plistFile}"
${plistBuddy} -c 'Add :WatchPaths array' "${plistFile}"
${plistBuddy} -c 'Add :WatchPaths:0 string "'"${watchPath}"'"' "${plistFile}"

chmod 644 "${plistFile}"

launchctl load "${plistFile}" # load the launchAgent

. "${sh_echoMsg}" "Created and started launchAgent ${watchPath}..." ""
fi
# run updateTranscodeGemsCheck independently
touch "${prefDir}/${gemUpdatePlist}"
}

function __main__ () {
define_Constants

check4Update_Transcode
update_Transcode
. "${sh_updatePost}" # executing this way to run an updated version if available
}


Expand Down
2 changes: 1 addition & 1 deletion Updater/updateTranscodeGems.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#----------------------------------------------------------FUNCTIONS----------------------------------------------------------------

function define_Constants () {
local versStamp="Version 1.0.6, 06-25-2016"
local versStamp="Version 1.0.7, 06-27-2016"

loggerTag="gem.update"

Expand Down
14 changes: 10 additions & 4 deletions Updater/updateTranscodeGemsCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#----------------------------------------------------------FUNCTIONS----------------------------------------------------------------

function define_Constants () {
local versStamp="Version 1.0.1, 06-25-2016"
local versStamp="Version 1.0.3, 06-28-2016"

loggerTag="gem.update"

Expand All @@ -31,19 +31,24 @@ function define_Constants () {

readonly sh_echoMsg="${appScriptsPath}/_echoMsg.sh"
readonly sh_ifError="${appScriptsPath}/_ifError.sh"
readonly needsUpdatePlist="com.videotranscode.gem.update.plist"
readonly needsUpdatePath="${prefDir}/${needsUpdatePlist}"
}

function __main__ () {
define_Constants

declare -a gemUpdates

update_Gems
}

function clean_Up () {
# remove update script
rm -f "/tmp/updateTranscode.sh"
}

function update_Gems () {
local needsUpdatePlist="com.videotranscode.gem.update.plist"
local needsUpdatePath="${prefDir}/${needsUpdatePlist}"
local updateInProgressPlist="com.videotranscode.gem.update.inprogress.plist"
local updateInProgessPath="${prefDir}/${updateInProgressPlist}"
local updateVT="false"
Expand Down Expand Up @@ -127,6 +132,7 @@ function update_Gems () {
#----------------------------------------------------------MAIN----------------------------------------------------------------
# Execute
trap clean_Up INT TERM EXIT # always run clean_Up regardless of how the script terminates
trap '. "${sh_ifError}" ${LINENO} $?' ERR # trap errors
__main__
Expand Down
Loading

0 comments on commit 120561f

Please sign in to comment.