tools/update-packaging/test/make_full_update.sh

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/bin/bash
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6 #
     7 # This tool generates full update packages for the update system.
     8 # Author: Darin Fisher
     9 #
    10 # In here to use the local common.sh to allow the full mars to have unfiltered files
    12 . $(dirname "$0")/common.sh
    14 # -----------------------------------------------------------------------------
    16 print_usage() {
    17   notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY"
    18 }
    20 if [ $# = 0 ]; then
    21   print_usage
    22   exit 1
    23 fi
    25 if [ $1 = -h ]; then
    26   print_usage
    27   notice ""
    28   notice "The contents of DIRECTORY will be stored in ARCHIVE."
    29   notice ""
    30   notice "Options:"
    31   notice "  -h  show this help text"
    32   notice ""
    33   exit 1
    34 fi
    36 # -----------------------------------------------------------------------------
    38 archive="$1"
    39 targetdir="$2"
    40 # Prevent the workdir from being inside the targetdir so it isn't included in
    41 # the update mar.
    42 if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
    43   # Remove the /
    44   targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
    45 fi
    46 workdir="$targetdir.work"
    47 updatemanifestv2="$workdir/updatev2.manifest"
    48 updatemanifestv3="$workdir/updatev3.manifest"
    49 targetfiles="updatev2.manifest updatev3.manifest"
    51 mkdir -p "$workdir"
    53 # On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
    54 # Info.plist so it launches the right architecture, bug 600098
    56 # Generate a list of all files in the target directory.
    57 pushd "$targetdir"
    58 if test $? -ne 0 ; then
    59   exit 1
    60 fi
    62 if [ ! -f "precomplete" ]; then
    63   notice "precomplete file is missing!"
    64   exit 1
    65 fi
    67 list_files files
    69 popd
    71 # Add the type of update to the beginning of the update manifests.
    72 > $updatemanifestv2
    73 > $updatemanifestv3
    74 notice ""
    75 notice "Adding type instruction to update manifests"
    76 notice "       type complete"
    77 echo "type \"complete\"" >> $updatemanifestv2
    78 echo "type \"complete\"" >> $updatemanifestv3
    80 notice ""
    81 notice "Adding file add instructions to update manifests"
    82 num_files=${#files[*]}
    84 for ((i=0; $i<$num_files; i=$i+1)); do
    85   f="${files[$i]}"
    87   if check_for_add_if_not_update "$f"; then
    88     make_add_if_not_instruction "$f" "$updatemanifestv3"
    89     if check_for_add_to_manifestv2 "$f"; then
    90       make_add_instruction "$f" "$updatemanifestv2" "" 1
    91     fi
    92   else
    93     make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
    94   fi
    96   dir=$(dirname "$f")
    97   mkdir -p "$workdir/$dir"
    98   $BZIP2 -cz9 "$targetdir/$f" > "$workdir/$f"
    99   copy_perm "$targetdir/$f" "$workdir/$f"
   101   targetfiles="$targetfiles \"$f\""
   102 done
   104 # Append remove instructions for any dead files.
   105 notice ""
   106 notice "Adding file and directory remove instructions from file 'removed-files'"
   107 append_remove_instructions "$targetdir" "$updatemanifestv2" "$updatemanifestv3"
   109 $BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2"
   110 $BZIP2 -z9 "$updatemanifestv3" && mv -f "$updatemanifestv3.bz2" "$updatemanifestv3"
   112 eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
   113 mv -f "$workdir/output.mar" "$archive"
   115 # cleanup
   116 rm -fr "$workdir"
   118 notice ""
   119 notice "Finished"
   120 notice ""

mercurial