1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/update-packaging/make_full_update.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,151 @@ 1.4 +#!/bin/bash 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 +# 1.10 +# This tool generates full update packages for the update system. 1.11 +# Author: Darin Fisher 1.12 +# 1.13 + 1.14 +. $(dirname "$0")/common.sh 1.15 + 1.16 +# TODO: it would be better to pass this as a command line option. 1.17 +directories_to_remove='TorBrowser/Data/Browser/profile.default/extensions/https-everywhere@eff.org' 1.18 + 1.19 +# ----------------------------------------------------------------------------- 1.20 + 1.21 +print_usage() { 1.22 + notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY" 1.23 +} 1.24 + 1.25 +if [ $# = 0 ]; then 1.26 + print_usage 1.27 + exit 1 1.28 +fi 1.29 + 1.30 +if [ $1 = -h ]; then 1.31 + print_usage 1.32 + notice "" 1.33 + notice "The contents of DIRECTORY will be stored in ARCHIVE." 1.34 + notice "" 1.35 + notice "Options:" 1.36 + notice " -h show this help text" 1.37 + notice " -q be less verbose" 1.38 + notice "" 1.39 + exit 1 1.40 +fi 1.41 + 1.42 +if [ $1 = -q ]; then 1.43 + QUIET=1 1.44 + shift 1.45 +fi 1.46 + 1.47 +# ----------------------------------------------------------------------------- 1.48 + 1.49 +archive="$1" 1.50 +targetdir="$2" 1.51 +# Prevent the workdir from being inside the targetdir so it isn't included in 1.52 +# the update mar. 1.53 +if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then 1.54 + # Remove the / 1.55 + targetdir=$(echo "$targetdir" | sed -e 's:\/$::') 1.56 +fi 1.57 +workdir="$targetdir.work" 1.58 +updatemanifestv2="$workdir/updatev2.manifest" 1.59 +updatemanifestv3="$workdir/updatev3.manifest" 1.60 +targetfiles="updatev2.manifest updatev3.manifest" 1.61 + 1.62 +mkdir -p "$workdir" 1.63 + 1.64 +# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the 1.65 +# Info.plist so it launches the right architecture, bug 600098 1.66 + 1.67 +# Generate a list of all files in the target directory. 1.68 +pushd "$targetdir" 1.69 +if test $? -ne 0 ; then 1.70 + exit 1 1.71 +fi 1.72 + 1.73 +if [ ! -f "precomplete" ]; then 1.74 + notice "precomplete file is missing!" 1.75 + exit 1 1.76 +fi 1.77 + 1.78 +list_files files 1.79 +list_symlinks symlinks symlink_targets 1.80 + 1.81 +popd 1.82 + 1.83 +# Add the type of update to the beginning of the update manifests. 1.84 +> "$updatemanifestv2" 1.85 +> "$updatemanifestv3" 1.86 +notice "" 1.87 +notice "Adding type instruction to update manifests" 1.88 +notice " type complete" 1.89 +echo "type \"complete\"" >> "$updatemanifestv2" 1.90 +echo "type \"complete\"" >> "$updatemanifestv3" 1.91 + 1.92 +# If removal of any old, existing directories is desired, emit the appropriate 1.93 +# rmrfdir commands. 1.94 +notice "" 1.95 +notice "Adding directory removal instructions to update manifests" 1.96 +for dir_to_remove in $directories_to_remove; do 1.97 + # rmrfdir requires a trailing slash; if slash is missing, add one. 1.98 + if ! [[ "$dir_to_remove" =~ /$ ]]; then 1.99 + dir_to_remove="${dir_to_remove}/" 1.100 + fi 1.101 + echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv2" 1.102 + echo "rmrfdir \"$dir_to_remove\"" >> "$updatemanifestv3" 1.103 +done 1.104 + 1.105 +notice "" 1.106 +notice "Adding file add instructions to update manifests" 1.107 +num_files=${#files[*]} 1.108 + 1.109 +for ((i=0; $i<$num_files; i=$i+1)); do 1.110 + f="${files[$i]}" 1.111 + 1.112 + if check_for_add_if_not_update "$f"; then 1.113 + make_add_if_not_instruction "$f" "$updatemanifestv3" 1.114 + if check_for_add_to_manifestv2 "$f"; then 1.115 + make_add_instruction "$f" "$updatemanifestv2" "" 1 1.116 + fi 1.117 + else 1.118 + make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3" 1.119 + fi 1.120 + 1.121 + dir=$(dirname "$f") 1.122 + mkdir -p "$workdir/$dir" 1.123 + $BZIP2 -cz9 "$targetdir/$f" > "$workdir/$f" 1.124 + copy_perm "$targetdir/$f" "$workdir/$f" 1.125 + 1.126 + targetfiles="$targetfiles \"$f\"" 1.127 +done 1.128 + 1.129 +notice "" 1.130 +notice "Adding symlink add instructions to update manifests" 1.131 +num_symlinks=${#symlinks[*]} 1.132 +for ((i=0; $i<$num_symlinks; i=$i+1)); do 1.133 + link="${symlinks[$i]}" 1.134 + target="${symlink_targets[$i]}" 1.135 + make_addsymlink_instruction "$link" "$target" "$updatemanifestv2" "$updatemanifestv3" 1.136 +done 1.137 + 1.138 +# Append remove instructions for any dead files. 1.139 +notice "" 1.140 +notice "Adding file and directory remove instructions from file 'removed-files'" 1.141 +append_remove_instructions "$targetdir" "$updatemanifestv2" "$updatemanifestv3" 1.142 + 1.143 +$BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2" 1.144 +$BZIP2 -z9 "$updatemanifestv3" && mv -f "$updatemanifestv3.bz2" "$updatemanifestv3" 1.145 + 1.146 +eval "$MAR -C \"$workdir\" -c output.mar $targetfiles" 1.147 +mv -f "$workdir/output.mar" "$archive" 1.148 + 1.149 +# cleanup 1.150 +rm -fr "$workdir" 1.151 + 1.152 +notice "" 1.153 +notice "Finished" 1.154 +notice ""