| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | set -e | 
					
						
							|  |  |  | set +x | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  |   echo "usage: $(basename $0) [output-absolute-path]" | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   echo | 
					
						
							|  |  |  |   echo "Generate distributable .zip archive from ./checkout folder that was previously built." | 
					
						
							|  |  |  |   echo | 
					
						
							|  |  |  |   exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | ZIP_PATH=$1 | 
					
						
							|  |  |  | if [[ $ZIP_PATH != /* ]]; then | 
					
						
							|  |  |  |   echo "ERROR: path $ZIP_PATH is not absolute" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if [[ $ZIP_PATH != *.zip ]]; then | 
					
						
							|  |  |  |   echo "ERROR: path $ZIP_PATH must have .zip extension" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if [[ -f $ZIP_PATH ]]; then | 
					
						
							|  |  |  |   echo "ERROR: path $ZIP_PATH exists; can't do anything." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if ! [[ -d $(dirname $ZIP_PATH) ]]; then | 
					
						
							|  |  |  |   echo "ERROR: folder for path $($ZIP_PATH) does not exist." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-19 16:08:27 -08:00
										 |  |  | trap "cd $(pwd -P)" EXIT | 
					
						
							| 
									
										
										
										
											2019-11-20 10:08:55 -08:00
										 |  |  | cd "$(dirname $0)" | 
					
						
							| 
									
										
										
										
											2019-11-19 16:08:27 -08:00
										 |  |  | cd checkout | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | OBJ_FOLDER=$(ls -1 | grep obj-) | 
					
						
							|  |  |  | if [[ $OBJ_FOLDER == "" ]]; then | 
					
						
							|  |  |  |   echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?" | 
					
						
							|  |  |  |   exit 1; | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-12-11 16:56:42 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ./mach package | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then | 
					
						
							|  |  |  |   echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?" | 
					
						
							| 
									
										
										
										
											2019-11-18 18:18:28 -08:00
										 |  |  |   exit 1; | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:07 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Copy the libstdc++ version we linked against. | 
					
						
							|  |  |  | # TODO(aslushnikov): this won't be needed with official builds. | 
					
						
							|  |  |  | if [[ "$(uname)" == "Linux" ]]; then | 
					
						
							|  |  |  |   cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $OBJ_FOLDER/dist/firefox/libstdc++.so.6 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # tar resulting directory and cleanup TMP. | 
					
						
							|  |  |  | cd $OBJ_FOLDER/dist | 
					
						
							|  |  |  | zip -r $ZIP_PATH firefox |