Skip to content

Commit

Permalink
Update mar building tools to latest upstream versions
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Jan 15, 2015
1 parent e39e7a8 commit 097c5fa
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 264 deletions.
125 changes: 78 additions & 47 deletions update-packaging/common.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,100 @@ copy_perm() {

make_add_instruction() {
f="$1"
filev2="$2"
# The third param will be an empty string when a file add instruction is only
# needed in the version 2 manifest. This only happens when the file has an
# add-if-not instruction in the version 3 manifest. This is due to the
# precomplete file prior to the version 3 manifest having a remove instruction
# for this file so the file is removed before applying a complete update.
filev3="$3"

# Used to log to the console
if [ $2 ]; then
if [ $4 ]; then
forced=" (forced)"
else
forced=
fi

is_extension=$(echo "$f" | grep -c 'extensions/.*/')
is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
if [ $is_extension = "1" ]; then
# Use the subdirectory of the extensions folder as the file to test
# before performing this add instruction.
testdir=$(echo "$f" | sed 's/\(extensions\/[^\/]*\)\/.*/\1/')
notice " add-if: $f$forced"
echo "add-if \"$testdir\" \"$f\""
testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
notice " add-if \"$testdir\" \"$f\""
echo "add-if \"$testdir\" \"$f\"" >> $filev2
if [ ! $filev3 = "" ]; then
echo "add-if \"$testdir\" \"$f\"" >> $filev3
fi
else
notice " add: $f$forced"
echo "add \"$f\""
notice " add \"$f\"$forced"
echo "add \"$f\"" >> $filev2
if [ ! $filev3 = "" ]; then
echo "add \"$f\"" >> $filev3
fi
fi
}

check_for_add_if_not_update() {
add_if_not_file_chk="$1"

if [ `basename $add_if_not_file_chk` = "channel-prefs.js" -o \
`basename $add_if_not_file_chk` = "update-settings.ini" ]; then
## "true" *giggle*
return 0;
fi
## 'false'... because this is bash. Oh yay!
return 1;
}

check_for_add_to_manifestv2() {
add_if_not_file_chk="$1"

if [ `basename $add_if_not_file_chk` = "update-settings.ini" ]; then
## "true" *giggle*
return 0;
fi
## 'false'... because this is bash. Oh yay!
return 1;
}

make_add_if_not_instruction() {
f="$1"
filev3="$2"

notice " add-if-not \"$f\" \"$f\""
echo "add-if-not \"$f\" \"$f\"" >> $filev3
}

make_patch_instruction() {
f="$1"
is_extension=$(echo "$f" | grep -c 'extensions/.*/')
is_search_plugin=$(echo "$f" | grep -c 'searchplugins/.*')
filev2="$2"
filev3="$3"

is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
if [ $is_extension = "1" ]; then
# Use the subdirectory of the extensions folder as the file to test
# before performing this add instruction.
testdir=$(echo "$f" | sed 's/\(extensions\/[^\/]*\)\/.*/\1/')
notice " patch-if: $f"
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\""
elif [ $is_search_plugin = "1" ]; then
notice " patch-if: $f"
echo "patch-if \"$f\" \"$f.patch\" \"$f\""
testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
notice " patch-if \"$testdir\" \"$f.patch\" \"$f\""
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev2
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> $filev3
else
notice " patch: $f"
echo "patch \"$f.patch\" \"$f\""
notice " patch \"$f.patch\" \"$f\""
echo "patch \"$f.patch\" \"$f\"" >> $filev2
echo "patch \"$f.patch\" \"$f\"" >> $filev3
fi
}

append_remove_instructions() {
dir="$1"
filev1="$2"
filev2="$3"
filev2="$2"
filev3="$3"

if [ -f "$dir/removed-files" ]; then
prefix=
listfile="$dir/removed-files"
elif [ -f "$dir/Contents/MacOS/removed-files" ]; then
prefix=Contents/MacOS/
listfile="$dir/Contents/MacOS/removed-files"
elif [ -f "$dir/Contents/Resources/removed-files" ]; then
listfile="$dir/Contents/Resources/removed-files"
fi
if [ -n "$listfile" ]; then
# Map spaces to pipes so that we correctly handle filenames with spaces.
Expand All @@ -103,31 +147,20 @@ append_remove_instructions() {
if [ -n "$f" ]; then
# Exclude comments
if [ ! $(echo "$f" | grep -c '^#') = 1 ]; then
# Normalize the path to the root of the Mac OS X bundle if necessary
fixedprefix="$prefix"
if [ $prefix ]; then
if [ $(echo "$f" | grep -c '^\.\./') = 1 ]; then
if [ $(echo "$f" | grep -c '^\.\./\.\./') = 1 ]; then
f=$(echo $f | sed -e 's:^\.\.\/\.\.\/::')
fixedprefix=""
else
f=$(echo $f | sed -e 's:^\.\.\/::')
fixedprefix=$(echo "$prefix" | sed -e 's:[^\/]*\/$::')
fi
fi
fi
if [ $(echo "$f" | grep -c '\/$') = 1 ]; then
notice " rmdir: $fixedprefix$f"
echo "rmdir \"$fixedprefix$f\"" >> $filev2
notice " rmdir \"$f\""
echo "rmdir \"$f\"" >> $filev2
echo "rmdir \"$f\"" >> $filev3
elif [ $(echo "$f" | grep -c '\/\*$') = 1 ]; then
# Remove the *
f=$(echo "$f" | sed -e 's:\*$::')
notice " rmrfdir: $fixedprefix$f"
echo "rmrfdir \"$fixedprefix$f\"" >> $filev2
notice " rmrfdir \"$f\""
echo "rmrfdir \"$f\"" >> $filev2
echo "rmrfdir \"$f\"" >> $filev3
else
notice " remove: $fixedprefix$f"
echo "remove \"$fixedprefix$f\"" >> $filev1
echo "remove \"$fixedprefix$f\"" >> $filev2
notice " remove \"$f\""
echo "remove \"$f\"" >> $filev2
echo "remove \"$f\"" >> $filev3
fi
fi
fi
Expand All @@ -136,16 +169,14 @@ append_remove_instructions() {
}

# List all files in the current directory, stripping leading "./"
# Skip the channel-prefs.js file as it should not be included in any
# generated MAR files (see bug 306077). Pass a variable name and it will be
# filled as an array.
# Pass a variable name and it will be filled as an array.
list_files() {
count=0

find . -type f \
! -name "channel-prefs.js" \
! -name "update.manifest" \
! -name "updatev2.manifest" \
! -name "updatev3.manifest" \
! -name "temp-dirlist" \
! -name "temp-filelist" \
| sed 's/\.\/\(.*\)/\1/' \
Expand Down
56 changes: 26 additions & 30 deletions update-packaging/make_full_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,53 @@ if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
fi
workdir="$targetdir.work"
updatemanifestv1="$workdir/update.manifest"
updatemanifestv2="$workdir/updatev2.manifest"
targetfiles="update.manifest updatev2.manifest"
updatemanifestv3="$workdir/updatev3.manifest"
targetfiles="updatev2.manifest updatev3.manifest"

mkdir -p "$workdir"

# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
# Info.plist so it launches the right architecture, bug 600098

# Generate a list of all files in the target directory.
pushd "$targetdir"
if test $? -ne 0 ; then
exit 1
fi

if [ ! -f "precomplete" ]; then
notice "precomplete file is missing!"
exit 1
if [ ! -f "Contents/Resources/precomplete" ]; then
notice "precomplete file is missing!"
exit 1
fi
fi

list_files files

popd

# Add the type of update to the beginning of the update manifests.
> $updatemanifestv2
> $updatemanifestv3
notice ""
notice "Adding file add instructions to file 'update.manifest'"
> $updatemanifestv1
notice "Adding type instruction to update manifests"
notice " type complete"
echo "type \"complete\"" >> $updatemanifestv2
echo "type \"complete\"" >> $updatemanifestv3

notice ""
notice "Adding file add instructions to update manifests"
num_files=${#files[*]}

for ((i=0; $i<$num_files; i=$i+1)); do
f="${files[$i]}"

# removed-files is excluded by make_incremental_updates.py so it is excluded
# here for consistency.
if [ `basename $f` = "removed-files" ]; then
continue 1
fi

make_add_instruction "$f" >> $updatemanifestv1
if check_for_add_if_not_update "$f"; then
make_add_if_not_instruction "$f" "$updatemanifestv3"
if check_for_add_to_manifestv2 "$f"; then
make_add_instruction "$f" "$updatemanifestv2" "" 1
fi
else
make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
fi

dir=$(dirname "$f")
mkdir -p "$workdir/$dir"
Expand All @@ -92,25 +99,13 @@ for ((i=0; $i<$num_files; i=$i+1)); do
targetfiles="$targetfiles \"$f\""
done

# Add the type of update to the beginning of and cat the contents of the version
# 1 update manifest to the version 2 update manifest.
> $updatemanifestv2
notice ""
notice "Adding type instruction to file 'updatev2.manifest'"
notice " type: complete"
echo "type \"complete\"" >> $updatemanifestv2

notice ""
notice "Concatenating file 'update.manifest' to file 'updatev2.manifest'"
cat $updatemanifestv1 >> $updatemanifestv2

# Append remove instructions for any dead files.
notice ""
notice "Adding file and directory remove instructions from file 'removed-files'"
append_remove_instructions "$targetdir" "$updatemanifestv1" "$updatemanifestv2"
append_remove_instructions "$targetdir" "$updatemanifestv2" "$updatemanifestv3"

$BZIP2 -z9 "$updatemanifestv1" && mv -f "$updatemanifestv1.bz2" "$updatemanifestv1"
$BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2"
$BZIP2 -z9 "$updatemanifestv3" && mv -f "$updatemanifestv3.bz2" "$updatemanifestv3"

eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"
mv -f "$workdir/output.mar" "$archive"
Expand All @@ -120,3 +115,4 @@ rm -fr "$workdir"

notice ""
notice "Finished"
notice ""
Loading

0 comments on commit 097c5fa

Please sign in to comment.