123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #!/bin/bash
- set -e
- version=60.3.0
- archive=./icecat-${version}-gnu1.tar.bz2
- folder=./icecat-${version}
- function usage {
- echo "Usage: icebuild [command1 [command2 [...]]]"
- echo
- echo "Downloads, patches and builds GNU IceCat for macOS. Available"
- echo "commands:"
- echo
- echo " build Compile the sources"
- echo " help Display this message and exit"
- echo " prepare Download the sources and prepare them for"
- echo " compilation"
- echo " update_dmg Copy the final DMG into the dmgs folder"
- echo
- echo "Multiple commands can be specified at once. If no commands"
- echo "are given, the script defaults to 'prepare build'."
- exit 0
- }
- function announce {
- echo -e "\033[93m|> $1\033[0m"
- }
- function die {
- echo -e "\e[31mError: $1\e[0m"
- exit 1
- }
- function fetch_archive {
- announce "Fetching source archive for ${version}"
- if [[ ! -f "${archive}" ]]; then
- wget "https://ftpmirror.gnu.org/gnuzilla/${version}/${archive}"
- else
- echo "Found previously downloaded archive ${archive}"
- fi
- }
- function extract_archive {
- announce "Extracting source archive"
- if [[ ! -d "${folder}" ]]; then
- tar xjfv "${archive}"
- else
- echo "Found previously extracted archive contents ${folder}"
- fi
- }
- function apply_patches {
- announce "Patching files"
- pushd "${folder}"
- while read -r file; do
- if ! patch -Rsf --dry-run -p0 -i "${file}" > /dev/null; then
- patch -p0 -i "${file}"
- else
- echo "$(basename "${file}") was already applied"
- fi
- done < <(find ../ -maxdepth 1 -name "*.patch")
- popd
- }
- function prepare_folders {
- announce "Preparing build folders"
- pushd "${folder}"
- mkdir -vp objdir
- mkdir -vp browser/branding/unofficial/moz.build
- popd
- }
- function build {
- announce "Building"
- pushd "${folder}/objdir"
- export CXX='/usr/bin/clang++ -stdlib=libc++'
- ../configure \
- --with-l10n-base=../l10n \
- --enable-official-branding \
- --with-macos-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
- make
- make package
- popd
- }
- function update_dmg {
- local dmg=${folder}/objdir/dist/icecat-${version}.en-US.mac.dmg
- if [[ ! -f "${dmg}" ]]; then
- die "Could not find ${dmg}"
- fi
- local txt=${dmg%%.dmg}.txt
- if [[ ! -f "${txt}" ]]; then
- die "Could not find ${txt}"
- fi
- local name=$(basename "${dmg}")
- local ts=$(cat "${txt}")
- cp -v "${dmg}" "dmgs/${name%%.dmg}.${ts}.dmg"
- }
- # Handle help command
- for arg in $@; do
- if [[ ${arg} == help ]]; then
- usage
- fi
- done
- # Default commands (if needed) and validate them
- commands=${@-prepare build}
- for command in ${commands}; do
- case "${command}" in
- prepare)
- ;;
- build)
- ;;
- update_dmg)
- ;;
- *)
- die "Invalid command ${command}"
- ;;
- esac
- done
- # Handle commands
- for command in ${commands}; do
- case "${command}" in
- prepare)
- fetch_archive
- extract_archive
- apply_patches
- prepare_folders
- ;;
- build)
- build
- ;;
- update_dmg)
- update_dmg
- ;;
- esac
- done
|