tools/update-packaging/test/make_full_update.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/update-packaging/test/make_full_update.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     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 +# In here to use the local common.sh to allow the full mars to have unfiltered files
    1.14 +
    1.15 +. $(dirname "$0")/common.sh
    1.16 +
    1.17 +# -----------------------------------------------------------------------------
    1.18 +
    1.19 +print_usage() {
    1.20 +  notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
    1.21 +}
    1.22 +
    1.23 +if [ $# = 0 ]; then
    1.24 +  print_usage
    1.25 +  exit 1
    1.26 +fi
    1.27 +
    1.28 +if [ $1 = -h ]; then
    1.29 +  print_usage
    1.30 +  notice ""
    1.31 +  notice "The contents of DIRECTORY will be stored in ARCHIVE."
    1.32 +  notice ""
    1.33 +  notice "Options:"
    1.34 +  notice "  -h  show this help text"
    1.35 +  notice ""
    1.36 +  exit 1
    1.37 +fi
    1.38 +
    1.39 +# -----------------------------------------------------------------------------
    1.40 +
    1.41 +archive="$1"
    1.42 +targetdir="$2"
    1.43 +# Prevent the workdir from being inside the targetdir so it isn't included in
    1.44 +# the update mar.
    1.45 +if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
    1.46 +  # Remove the /
    1.47 +  targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
    1.48 +fi
    1.49 +workdir="$targetdir.work"
    1.50 +updatemanifestv2="$workdir/updatev2.manifest"
    1.51 +updatemanifestv3="$workdir/updatev3.manifest"
    1.52 +targetfiles="updatev2.manifest updatev3.manifest"
    1.53 +
    1.54 +mkdir -p "$workdir"
    1.55 +
    1.56 +# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
    1.57 +# Info.plist so it launches the right architecture, bug 600098
    1.58 +
    1.59 +# Generate a list of all files in the target directory.
    1.60 +pushd "$targetdir"
    1.61 +if test $? -ne 0 ; then
    1.62 +  exit 1
    1.63 +fi
    1.64 +
    1.65 +if [ ! -f "precomplete" ]; then
    1.66 +  notice "precomplete file is missing!"
    1.67 +  exit 1
    1.68 +fi
    1.69 +
    1.70 +list_files files
    1.71 +
    1.72 +popd
    1.73 +
    1.74 +# Add the type of update to the beginning of the update manifests.
    1.75 +> $updatemanifestv2
    1.76 +> $updatemanifestv3
    1.77 +notice ""
    1.78 +notice "Adding type instruction to update manifests"
    1.79 +notice "       type complete"
    1.80 +echo "type \"complete\"" >> $updatemanifestv2
    1.81 +echo "type \"complete\"" >> $updatemanifestv3
    1.82 +
    1.83 +notice ""
    1.84 +notice "Adding file add instructions to update manifests"
    1.85 +num_files=${#files[*]}
    1.86 +
    1.87 +for ((i=0; $i<$num_files; i=$i+1)); do
    1.88 +  f="${files[$i]}"
    1.89 +
    1.90 +  if check_for_add_if_not_update "$f"; then
    1.91 +    make_add_if_not_instruction "$f" "$updatemanifestv3"
    1.92 +    if check_for_add_to_manifestv2 "$f"; then
    1.93 +      make_add_instruction "$f" "$updatemanifestv2" "" 1
    1.94 +    fi
    1.95 +  else
    1.96 +    make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
    1.97 +  fi
    1.98 +
    1.99 +  dir=$(dirname "$f")
   1.100 +  mkdir -p "$workdir/$dir"
   1.101 +  $BZIP2 -cz9 "$targetdir/$f" > "$workdir/$f"
   1.102 +  copy_perm "$targetdir/$f" "$workdir/$f"
   1.103 +
   1.104 +  targetfiles="$targetfiles \"$f\""
   1.105 +done
   1.106 +
   1.107 +# Append remove instructions for any dead files.
   1.108 +notice ""
   1.109 +notice "Adding file and directory remove instructions from file 'removed-files'"
   1.110 +append_remove_instructions "$targetdir" "$updatemanifestv2" "$updatemanifestv3"
   1.111 +
   1.112 +$BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2"
   1.113 +$BZIP2 -z9 "$updatemanifestv3" && mv -f "$updatemanifestv3.bz2" "$updatemanifestv3"
   1.114 +
   1.115 +eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
   1.116 +mv -f "$workdir/output.mar" "$archive"
   1.117 +
   1.118 +# cleanup
   1.119 +rm -fr "$workdir"
   1.120 +
   1.121 +notice ""
   1.122 +notice "Finished"
   1.123 +notice ""

mercurial