tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

get_and_diffoscope (2357B)


      1 #!/bin/bash
      2 
      3 set -e
      4 set -x
      5 set -o pipefail
      6 
      7 cd /builds/worker
      8 
      9 mkdir a b
     10 
     11 # /builds/worker/bin contains wrapper binaries to divert what diffoscope
     12 # needs to use, so it needs to appear first.
     13 export PATH=/builds/worker/bin:$PATH
     14 
     15 # Until https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879010 is
     16 # implemented, it's better to first manually extract the data.
     17 # Plus dmg files are not supported yet.
     18 
     19 RESOURCE_DIR=firefox
     20 case "$ORIG_URL" in
     21 *.zip|*.apk)
     22 	curl -L "$ORIG_URL" > a.zip
     23 	curl -L "$NEW_URL" > b.zip
     24 	unzip -d a a.zip
     25 	unzip -d b b.zip
     26 	;;
     27 *.tar.zst)
     28 	curl -L "$ORIG_URL" | tar -C a --zstd -xf -
     29 	curl -L "$NEW_URL" | tar -C b --zstd -xf -
     30 	;;
     31 *.tar.bz2)
     32 	curl -L "$ORIG_URL" | tar -C a -jxf -
     33 	curl -L "$NEW_URL" | tar -C b -jxf -
     34 	;;
     35 *.tar.xz)
     36 	# Account for comparing with old bz2 format
     37 	curl -L "$ORIG_URL" | tar -C a -Jxf -
     38 	curl -L "$NEW_URL" | tar -C b -Jxf -
     39 	;;
     40 *.tar.gz)
     41 	curl -L "$ORIG_URL" | tar -C a -zxf -
     42 	curl -L "$NEW_URL" | tar -C b -zxf -
     43 	;;
     44 *.dmg)
     45 	for tool in lipo otool; do
     46 		ln -s $MOZ_FETCHES_DIR/cctools/bin/x86_64-apple-darwin*-$tool bin/$tool
     47 	done
     48 	curl -L "$ORIG_URL" > a.dmg
     49 	curl -L "$NEW_URL" > b.dmg
     50 	for i in a b; do
     51 		$MOZ_FETCHES_DIR/dmg/dmg extract $i.dmg $i.hfs
     52 		$MOZ_FETCHES_DIR/dmg/hfsplus $i.hfs extractall / $i
     53 	done
     54 	RESOURCE_DIR=$(cd b; echo */Contents/Resources)
     55 	;;
     56 *)
     57 	ARTIFACT=$(basename "${ORIG_URL}")
     58 	curl -L "$ORIG_URL" > "a/${ARTIFACT}"
     59 	curl -L "$NEW_URL" > "b/${ARTIFACT}"
     60 esac
     61 
     62 case "$ORIG_URL" in
     63 */target.apk)
     64 	OMNIJAR=assets/omni.ja
     65 	;;
     66 *)
     67 	OMNIJAR=omni.ja
     68 	;;
     69 esac
     70 
     71 # Builds are 99% of the time differing in some small ways, so it's not
     72 # really useful to report a failure (at least not until we actually
     73 # care about the builds being 100% identical).
     74 POST=true
     75 
     76 fail() {
     77 	exit 1
     78 }
     79 
     80 for option; do
     81 	case "$option" in
     82 	--unpack)
     83 		CURDIR=$PWD
     84 		for dir in a b; do
     85 			# Need to run mach python from inside the gecko source.
     86 			# See bug #1533642.
     87 			(cd $GECKO_PATH && ./mach python toolkit/mozapps/installer/unpack.py --omnijar $OMNIJAR "$CURDIR/$dir/$RESOURCE_DIR")
     88 		done
     89 		;;
     90 	--fail)
     91 		POST="fail"
     92 		;;
     93 	*)
     94 		echo "Unsupported option: $option" >&2
     95 		exit 1
     96 	esac
     97 done
     98 
     99 if [ -n "$PRE_DIFF" ]; then
    100 	eval $PRE_DIFF
    101 fi
    102 
    103 if eval diffoscope \
    104 	--html diff.html \
    105 	--text diff.txt \
    106 	--progress \
    107 	$DIFFOSCOPE_ARGS \
    108 	a b
    109 then
    110 	# Ok
    111 	:
    112 else
    113 	$(dirname $0)/report_error diff
    114 	$POST
    115 fi