Bug 1392914 Remove updatev2.manifest r=mhowell

I've left the mention of updatev2.manifest in list_files and list_dirs for now, similar to how v1 has been left.

Differential Revision: https://phabricator.services.mozilla.com/D80011
This commit is contained in:
Simon Fraser 2020-06-18 07:42:21 +00:00
parent 22b263e21b
commit e75d5918a7
6 changed files with 19 additions and 85 deletions

View File

@ -67,13 +67,7 @@ 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"
filev3="$2"
# Used to log to the console
if [ $4 ]; then
@ -88,16 +82,10 @@ make_add_instruction() {
# before performing this add instruction.
testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
verbose_notice " add-if \"$testdir\" \"$f\""
echo "add-if \"$testdir\" \"$f\"" >> "$filev2"
if [ ! $filev3 = "" ]; then
echo "add-if \"$testdir\" \"$f\"" >> "$filev3"
fi
echo "add-if \"$testdir\" \"$f\"" >> "$filev3"
else
verbose_notice " add \"$f\"$forced"
echo "add \"$f\"" >> "$filev2"
if [ ! "$filev3" = "" ]; then
echo "add \"$f\"" >> "$filev3"
fi
echo "add \"$f\"" >> "$filev3"
fi
}
@ -113,17 +101,6 @@ check_for_add_if_not_update() {
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"
@ -134,8 +111,7 @@ make_add_if_not_instruction() {
make_patch_instruction() {
f="$1"
filev2="$2"
filev3="$3"
filev3="$2"
is_extension=$(echo "$f" | grep -c 'distribution/extensions/.*/')
if [ $is_extension = "1" ]; then
@ -143,19 +119,16 @@ make_patch_instruction() {
# before performing this add instruction.
testdir=$(echo "$f" | sed 's/\(.*distribution\/extensions\/[^\/]*\)\/.*/\1/')
verbose_notice " patch-if \"$testdir\" \"$f.patch\" \"$f\""
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev2"
echo "patch-if \"$testdir\" \"$f.patch\" \"$f\"" >> "$filev3"
else
verbose_notice " patch \"$f.patch\" \"$f\""
echo "patch \"$f.patch\" \"$f\"" >> "$filev2"
echo "patch \"$f.patch\" \"$f\"" >> "$filev3"
fi
}
append_remove_instructions() {
dir="$1"
filev2="$2"
filev3="$3"
filev3="$2"
if [ -f "$dir/removed-files" ]; then
listfile="$dir/removed-files"
@ -177,17 +150,14 @@ append_remove_instructions() {
if [ ! $(echo "$f" | grep -c '^#') = 1 ]; then
if [ $(echo "$f" | grep -c '\/$') = 1 ]; then
verbose_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:\*$::')
verbose_notice " rmrfdir \"$f\""
echo "rmrfdir \"$f\"" >> "$filev2"
echo "rmrfdir \"$f\"" >> "$filev3"
else
verbose_notice " remove \"$f\""
echo "remove \"$f\"" >> "$filev2"
echo "remove \"$f\"" >> "$filev3"
fi
fi

View File

@ -35,6 +35,7 @@ fi
if [ $1 = -q ]; then
QUIET=1
export QUIET
shift
fi
@ -51,9 +52,8 @@ if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
fi
workdir="$targetdir.work"
updatemanifestv2="$workdir/updatev2.manifest"
updatemanifestv3="$workdir/updatev3.manifest"
targetfiles="updatev2.manifest updatev3.manifest"
targetfiles="updatev3.manifest"
mkdir -p "$workdir"
@ -75,12 +75,10 @@ list_files files
popd
# Add the type of update to the beginning of the update manifests.
> "$updatemanifestv2"
> "$updatemanifestv3"
notice ""
notice "Adding type instruction to update manifests"
notice " type complete"
echo "type \"complete\"" >> "$updatemanifestv2"
echo "type \"complete\"" >> "$updatemanifestv3"
notice ""
@ -92,11 +90,8 @@ for ((i=0; $i<$num_files; i=$i+1)); do
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"
make_add_instruction "$f" "$updatemanifestv3"
fi
dir=$(dirname "$f")
@ -110,9 +105,8 @@ done
# Append remove instructions for any dead files.
notice ""
notice "Adding file and directory remove instructions from file 'removed-files'"
append_remove_instructions "$targetdir" "$updatemanifestv2" "$updatemanifestv3"
append_remove_instructions "$targetdir" "$updatemanifestv3"
$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force "$updatemanifestv2" && mv -f "$updatemanifestv2.xz" "$updatemanifestv2"
$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
mar_command="$mar_command -C \"$workdir\" -c output.mar"

View File

@ -111,9 +111,8 @@ if [ $(echo "$newdir" | grep -c '\/$') = 1 ]; then
newdir=$(echo "$newdir" | sed -e 's:\/$::')
fi
workdir="$(mktemp -d)"
updatemanifestv2="$workdir/updatev2.manifest"
updatemanifestv3="$workdir/updatev3.manifest"
archivefiles="updatev2.manifest updatev3.manifest"
archivefiles="updatev3.manifest"
mkdir -p "$workdir"
@ -148,10 +147,8 @@ popd
# Add the type of update to the beginning of the update manifests.
notice ""
notice "Adding type instruction to update manifests"
> $updatemanifestv2
> $updatemanifestv3
notice " type partial"
echo "type \"partial\"" >> $updatemanifestv2
echo "type \"partial\"" >> $updatemanifestv3
notice ""
@ -182,7 +179,7 @@ for ((i=0; $i<$num_oldfiles; i=$i+1)); do
mkdir -p `dirname "$workdir/$f"`
$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force --stdout "$newdir/$f" > "$workdir/$f"
copy_perm "$newdir/$f" "$workdir/$f"
make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3" 1
make_add_instruction "$f" "$updatemanifestv3" 1
archivefiles="$archivefiles \"$f\""
continue 1
fi
@ -227,12 +224,12 @@ for ((i=0; $i<$num_oldfiles; i=$i+1)); do
fullsize=$(get_file_size "$workdir/$f")
if [ $patchsize -lt $fullsize ]; then
make_patch_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
make_patch_instruction "$f" "$updatemanifestv3"
mv -f "$patchfile" "$workdir/$f.patch"
rm -f "$workdir/$f"
archivefiles="$archivefiles \"$f.patch\""
else
make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
make_add_instruction "$f" "$updatemanifestv3"
rm -f "$patchfile"
archivefiles="$archivefiles \"$f\""
fi
@ -269,7 +266,7 @@ for ((i=0; $i<$num_newfiles; i=$i+1)); do
if check_for_add_if_not_update "$f"; then
make_add_if_not_instruction "$f" "$updatemanifestv3"
else
make_add_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"
make_add_instruction "$f" "$updatemanifestv3"
fi
@ -281,14 +278,13 @@ notice "Adding file remove instructions to update manifests"
for ((i=0; $i<$num_removes; i=$i+1)); do
f="${remove_array[$i]}"
verbose_notice " remove \"$f\""
echo "remove \"$f\"" >> $updatemanifestv2
echo "remove \"$f\"" >> $updatemanifestv3
done
# Add remove instructions for any dead files.
notice ""
notice "Adding file and directory remove instructions from file 'removed-files'"
append_remove_instructions "$newdir" "$updatemanifestv2" "$updatemanifestv3"
append_remove_instructions "$newdir" "$updatemanifestv3"
notice ""
notice "Adding directory remove instructions for directories that no longer exist"
@ -299,12 +295,10 @@ for ((i=0; $i<$num_olddirs; i=$i+1)); do
# If this dir doesn't exist in the new directory remove it.
if [ ! -d "$newdir/$f" ]; then
verbose_notice " rmdir $f/"
echo "rmdir \"$f/\"" >> $updatemanifestv2
echo "rmdir \"$f/\"" >> $updatemanifestv3
fi
done
$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force "$updatemanifestv2" && mv -f "$updatemanifestv2.xz" "$updatemanifestv2"
$XZ $XZ_OPT --compress $BCJ_OPTIONS --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
mar_command="$mar_command -C \"$workdir\" -c output.mar"

View File

@ -1,14 +0,0 @@
#!/bin/bash
# helper tool for testing. Cats the manifest out of a mar file
mar="$1"
workdir="/tmp/catmanifest"
rm -rf "$workdir"
mkdir -p "$workdir"
cp "$1" "$workdir"
cd "$workdir"
mar -x "$1"
mv updatev2.manifest updatev2.manifest.xz
xz -d updatev2.manifest.xz
cat updatev2.manifest

View File

@ -30,8 +30,7 @@ cp "$2" "$todir"
cd "$fromdir"
mar -x "$1"
rm "$1"
mv updatev2.manifest updatev2.manifest.xz
xz -d updatev2.manifest.xz
rm -f updatev2.manifest # Older files may contain this
mv updatev3.manifest updatev3.manifest.xz
xz -d updatev3.manifest.xz
ls $lsargs > files.txt
@ -39,8 +38,6 @@ ls $lsargs > files.txt
cd "$todir"
mar -x "$2"
rm "$2"
mv updatev2.manifest updatev2.manifest.xz
xz -d updatev2.manifest.xz
mv updatev3.manifest updatev3.manifest.xz
xz -d updatev3.manifest.xz
ls $lsargs > files.txt

View File

@ -44,9 +44,8 @@ if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then
targetdir=$(echo "$targetdir" | sed -e 's:\/$::')
fi
workdir="$targetdir.work"
updatemanifestv2="$workdir/updatev2.manifest"
updatemanifestv3="$workdir/updatev3.manifest"
targetfiles="updatev2.manifest updatev3.manifest"
targetfiles="updatev3.manifest"
mkdir -p "$workdir"
@ -68,12 +67,10 @@ list_files files
popd
# Add the type of update to the beginning of the update manifests.
> $updatemanifestv2
> $updatemanifestv3
notice ""
notice "Adding type instruction to update manifests"
notice " type complete"
echo "type \"complete\"" >> $updatemanifestv2
echo "type \"complete\"" >> $updatemanifestv3
notice ""
@ -85,11 +82,8 @@ for ((i=0; $i<$num_files; i=$i+1)); do
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"
make_add_instruction "$f" "$updatemanifestv3"
fi
dir=$(dirname "$f")
@ -103,9 +97,8 @@ done
# Append remove instructions for any dead files.
notice ""
notice "Adding file and directory remove instructions from file 'removed-files'"
append_remove_instructions "$targetdir" "$updatemanifestv2" "$updatemanifestv3"
append_remove_instructions "$targetdir" "$updatemanifestv3"
$XZ $XZ_OPT --compress --x86 --lzma2 --format=xz --check=crc64 --force "$updatemanifestv2" && mv -f "$updatemanifestv2.xz" "$updatemanifestv2"
$XZ $XZ_OPT --compress --x86 --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3"
eval "$MAR -C \"$workdir\" -c output.mar $targetfiles"