diff options
author | Moonchild <moonchild@palemoon.org> | 2022-02-12 17:47:03 +0000 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2022-02-12 14:23:18 -0600 |
commit | f66babd8b8368ada3e5aa29cdef1c77291ee4ddd (patch) | |
tree | e3842e2a6bf19090185f9c475b3846e1bb79ac97 /system/packager | |
download | GRE-f66babd8b8368ada3e5aa29cdef1c77291ee4ddd.tar.gz |
Create the Goanna Runtime Environment
Diffstat (limited to 'system/packager')
-rw-r--r-- | system/packager/base.mk | 270 | ||||
-rw-r--r-- | system/packager/installer.mk | 83 | ||||
-rw-r--r-- | system/packager/locale-install.rdf.in | 34 | ||||
-rw-r--r-- | system/packager/make-update.sh | 325 | ||||
-rw-r--r-- | system/packager/packager.mk | 157 | ||||
-rw-r--r-- | system/packager/skin-install.rdf.in | 21 |
6 files changed, 890 insertions, 0 deletions
diff --git a/system/packager/base.mk b/system/packager/base.mk new file mode 100644 index 000000000..fb1114575 --- /dev/null +++ b/system/packager/base.mk @@ -0,0 +1,270 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# == | Setup | ======================================================================================================== + +ifndef GREPKGR_BASE_MK_INCLUDED +GREPKGR_BASE_MK_INCLUDED := 1 +else +$(error GRE Packager base.mk may only be included once) +endif # GREPKGR_BASE_MK_INCLUDED + +# --------------------------------------------------------------------------------------------------------------------- + +# These vars are here so that if paths change the number of places that need to be changed is minimal. +MOZINST_PATH := $(MOZILLA_DIR)/system/installer +GREPKGR_PATH := $(MOZILLA_DIR)/system/packager + +# --------------------------------------------------------------------------------------------------------------------- + +# This entire section contains common values normally spread all over hell and back but mostly originate from +# the multiple application installer makefiles. Which was redundantly redundant so we collect them here. + +DEFINES += \ + -DDLL_PREFIX=$(DLL_PREFIX) \ + -DDLL_SUFFIX=$(DLL_SUFFIX) \ + -DBIN_SUFFIX=$(BIN_SUFFIX) \ + -DMOZ_APP_NAME=$(MOZ_APP_NAME) \ + -DMOZ_APP_DISPLAYNAME=$(MOZ_APP_NAME) \ + -DMOZ_APP_ID=$(MOZ_APP_ID) \ + -DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \ + -DMOZ_APP_MAXVERSION=$(MOZ_APP_MAXVERSION) \ + -DMOZILLA_VERSION=$(MOZILLA_VERSION) \ + -DBINPATH=bin \ + -DPREF_DIR=$(PREF_DIR) \ + -DMOZ_ICU_VERSION=$(MOZ_ICU_VERSION) \ + -DMOZ_ICU_DBG_SUFFIX=$(MOZ_ICU_DBG_SUFFIX) \ + -DICU_DATA_FILE=$(ICU_DATA_FILE) \ + -DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME) \ + $(NULL) + +export USE_ELF_HACK ELF_HACK_FLAGS + +ifdef NO_PKG_DEFAULT_FILES +NO_PKG_FILES += \ + certutil$(BIN_SUFFIX) \ + modutil$(BIN_SUFFIX) \ + pk12util$(BIN_SUFFIX) \ + shlibsign$(BIN_SUFFIX) \ + xpcshell$(BIN_SUFFIX) \ + $(NULL) +endif + +NON_OMNIJAR_FILES += \ + defaults/profile/chrome/userChrome-example.css \ + defaults/profile/chrome/userContent-example.css \ + defaults/profile/mimeTypes.rdf \ + $(NULL) + +MOZ_PKG_FATAL_WARNINGS = 1 + +ifeq ($(MOZ_CHROME_FILE_FORMAT),jar) +DEFINES += -DJAREXT=.jar +else +ifeq ($(MOZ_PACKAGER_FORMAT),omni) +DEFINES += -DMOZ_OMNIJAR=1 +endif +DEFINES += -DJAREXT= +endif + +ifdef MOZ_DEBUG +DEFINES += -DMOZ_DEBUG=1 +endif + +ifdef ENABLE_TESTS +DEFINES += -DENABLE_TESTS=1 +endif + +ifdef MOZ_ANGLE_RENDERER +DEFINES += -DMOZ_ANGLE_RENDERER=$(MOZ_ANGLE_RENDERER) +ifdef MOZ_D3DCOMPILER_VISTA_DLL +DEFINES += -DMOZ_D3DCOMPILER_VISTA_DLL=$(MOZ_D3DCOMPILER_VISTA_DLL) +endif +ifdef MOZ_D3DCOMPILER_XP_DLL +DEFINES += -DMOZ_D3DCOMPILER_XP_DLL=$(MOZ_D3DCOMPILER_XP_DLL) +endif +endif + +ifdef NIGHTLY_BUILD +DEFINES += -DNIGHTLY_BUILD=1 +endif + +ifdef MOZ_ENABLE_GNOME_COMPONENT +DEFINES += -DMOZ_ENABLE_GNOME_COMPONENT=1 +endif + +ifneq (,$(filter gtk%,$(MOZ_WIDGET_TOOLKIT))) +DEFINES += -DMOZ_GTK=1 +ifeq ($(MOZ_WIDGET_TOOLKIT),gtk3) +DEFINES += -DMOZ_GTK3=1 +endif +endif + +ifdef MOZ_FOLD_LIBS +DEFINES += -DMOZ_FOLD_LIBS=1 +endif + +ifdef _MSC_VER +DEFINES += -D_MSC_VER=$(_MSC_VER) +endif + +ifdef MOZ_SYSTEM_NSPR +DEFINES += -DMOZ_SYSTEM_NSPR=1 +endif + +ifdef MOZ_SYSTEM_NSS +DEFINES += -DMOZ_SYSTEM_NSS=1 +endif + +ifdef NSS_DISABLE_DBM +DEFINES += -DNSS_DISABLE_DBM=1 +endif + +ifdef NECKO_WIFI +DEFINES += -DNECKO_WIFI=1 +endif + +ifdef GKMEDIAS_SHARED_LIBRARY +DEFINES += -DGKMEDIAS_SHARED_LIBRARY +endif + +# Set MSVC dlls version to package, if any. +# With VS2015+ it does not make sense to define the ucrt libs without +# the base c++ libs and vice versa. +ifdef MOZ_NO_DEBUG_RTL +ifdef WIN32_REDIST_DIR +ifdef WIN_UCRT_REDIST_DIR +DEFINES += \ + -DMOZ_PACKAGE_MSVC_DLLS=1 \ + -DMSVC_C_RUNTIME_DLL=$(MSVC_C_RUNTIME_DLL) \ + -DMSVC_CXX_RUNTIME_DLL=$(MSVC_CXX_RUNTIME_DLL) \ + -DMOZ_PACKAGE_WIN_UCRT_DLLS=1 \ + $(NULL) +endif +endif +endif + +ifeq ($(OS_ARCH),WINNT) +DEFINES += -DMOZ_SHARED_MOZGLUE=1 +endif + +ifdef MOZ_SYSTEM_ICU +DEFINES += -DMOZ_SYSTEM_ICU +endif + +ifdef MOZ_ICU_DATA_ARCHIVE +DEFINES += -DMOZ_ICU_DATA_ARCHIVE +endif + +ifdef MOZ_UPDATER +DEFINES += -DMOZ_UPDATER=1 +endif + +ifneq (,$(wildcard $(DIST)/bin/application.ini)) +BUILDID = $(shell $(PYTHON) $(MOZILLA_DIR)/config/printconfigsetting.py $(DIST)/bin/application.ini App BuildID) +else +BUILDID = $(shell $(PYTHON) $(MOZILLA_DIR)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID) +endif + +# --------------------------------------------------------------------------------------------------------------------- + +# Package Application Name +ifndef PKG_APP_NAME +PKG_APP_NAME := $(MOZ_APP_NAME) +endif + +# Package Application Version +ifndef PKG_APP_VERSION +PKG_APP_VERSION := $(MOZ_APP_VERSION) +endif + +# --------------------------------------------------------------------------------------------------------------------- + +# TARGET_OS/TARGET_CPU may be un-intuitive, so we hardcode some special formats +ifndef PKG_BUILD_TARGET +PKG_BUILD_TARGET := $(TARGET_OS)-$(TARGET_CPU) +ifeq ($(OS_ARCH),WINNT) +ifeq ($(TARGET_CPU),x86_64) +PKG_BUILD_TARGET := win64 +else +PKG_BUILD_TARGET := win32 +endif +endif +ifeq ($(TARGET_OS),linux-gnu) +PKG_BUILD_TARGET := linux-$(TARGET_CPU) +endif +ifeq ($(OS_ARCH),SunOS) +PKG_BUILD_TARGET := sunos-$(TARGET_CPU) +endif +endif # PKG_BUILD_TARGET + +# --------------------------------------------------------------------------------------------------------------------- + +# Support the older var in this case but only if the newer one isn't set. +# We use this when we want to offer different flavors like gtk2 vs gtk3 or different flavors of sunos. +ifndef PKG_BUILD_FLAVOR +ifdef MOZ_PKG_SPECIAL +PKG_BUILD_TARGET := $(PKG_BUILD_TARGET)-$(MOZ_PKG_SPECIAL) +endif # MOZ_PKG_SPECIAL +else +PKG_BUILD_TARGET := $(PKG_BUILD_TARGET)-$(PKG_BUILD_FLAVOR) +endif # PKG_BUILD_FLAVOR + +# --------------------------------------------------------------------------------------------------------------------- + +ifndef PGK_BASENAME +PKG_BASENAME := $(PKG_APP_NAME)-$(PKG_APP_VERSION).$(PKG_BUILD_TARGET) +endif + +# XXXTobin: It would be nice if we could have a generic stage directory but various tools won't allow it. +PKG_STAGE_DIR = $(PKG_APP_NAME) + +# --------------------------------------------------------------------------------------------------------------------- + +ifeq ($(OS_ARCH),WINNT) +# Archiver command and filename +PKG_ARCHIVER_CMD = 7z a -t7z -m0=lzma2 -mx=9 -aoa -bb3 +PKG_ARCHIVE_FILENAME = $(PKG_BASENAME).7z + +# Windows Symbol stage directory and archive filename +PKG_SYMBOLS_STAGE_DIR = $(PKG_STAGE_DIR)-symbols +PKG_SYMBOLS_FILENAME = $(PKG_BASENAME)-symbols.7z + +# NSIS-related vars and defines. +ifdef MAKENSISU +DEFINES += -DHAVE_MAKENSISU=1 +CONFIG_DIR = instgen +ifndef SFX_MODULE +SFX_MODULE = $(MOZILLA_SRCDIR)/other-licenses/7zstub/gre/7zSD.sfx +endif # SFX_MODULE +endif # MAKENSISU + +# Installer filename +PKG_INSTALLER_FILENAME = $(PKG_BASENAME).installer.exe + +# Generic OS name when specifics aren't as important +PKG_GENERIC_OS = windows +else +# Archiver command and filename for not-windows target operating systems +PKG_ARCHIVER_CMD = $(TAR) cfJv +PKG_ARCHIVE_FILENAME = $(PKG_BASENAME).tar.xz + +# Generic OS name when specifics aren't as important +PKG_GENERIC_OS = unix +endif + +# We only use the complete mar patch file +PKG_UPDATE_FILENAME = $(PKG_BASENAME).mar + +# This is the mozbuildinfo json file that contains a number of mozinfra build values +# We also use this in our infra because it exists.. +PKG_JSON_FILENAME = $(PKG_BASENAME).json + +# Vars that are used in faking xpi-stage to create useful packages that are normally ONLY omnijar'd +PKG_XPI_L10N_STAGE_DIR = xpi-stage/grepkgr-locale +PKG_XPI_L10N_FILENAME := $(PKG_APP_NAME)-$(PKG_APP_VERSION).en-US.langpack.zip +PKG_XPI_SKIN_STAGE_DIR = xpi-stage/grepkgr-skin +PKG_XPI_SKIN_FILENAME := $(PKG_APP_NAME)-$(PKG_APP_VERSION).$(PKG_GENERIC_OS).theme.zip + +# ===================================================================================================================== diff --git a/system/packager/installer.mk b/system/packager/installer.mk new file mode 100644 index 000000000..a9c0447ec --- /dev/null +++ b/system/packager/installer.mk @@ -0,0 +1,83 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# == | Setup | ======================================================================================================== + +TOOLKIT_NSIS_FILES = \ + common.nsh \ + locale.nlf \ + locale-fonts.nsh \ + locale-rtl.nlf \ + locales.nsi \ + overrides.nsh \ + setup.ico \ + $(NULL) + +CUSTOM_NSIS_PLUGINS = \ + AccessControl.dll \ + AppAssocReg.dll \ + ApplicationID.dll \ + CertCheck.dll \ + CityHash.dll \ + InetBgDL.dll \ + InvokeShellVerb.dll \ + liteFirewallW.dll \ + ServicesHelper.dll \ + ShellLink.dll \ + UAC.dll \ + $(NULL) + +CUSTOM_UI = nsisui.exe + +# ===================================================================================================================== + +# == | Makefile Targets | ============================================================================================= + +$(CONFIG_DIR)/7zSD.sfx: + $(CYGWIN_WRAPPER) upx --best -o $(CONFIG_DIR)/7zSD.sfx $(SFX_MODULE) + +# --------------------------------------------------------------------------------------------------------------------- + +$(CONFIG_DIR)/setup.exe:: + $(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(MOZINST_PATH)/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/Plugins/,$(CUSTOM_NSIS_PLUGINS)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/,$(CUSTOM_UI)) $(CONFIG_DIR) + $(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ + $(srcdir)/$(INSTALLER_DEFINES) -o $(CONFIG_DIR)/defines.nsi) + cd $(CONFIG_DIR) && $(MAKENSISU) installer.nsi + +# --------------------------------------------------------------------------------------------------------------------- + +installer:: stage-package + @rm -rf $(DIST)/installer-stage $(DIST)/xpt + @echo 'Staging installer files...' + @$(NSINSTALL) -D $(DIST)/installer-stage/core + @$(TOOLCHAIN_PREFIX)cp -av $(DIST)/$(PKG_STAGE_DIR)/. $(DIST)/installer-stage/core + $(RM) -r $(CONFIG_DIR) && mkdir $(CONFIG_DIR) + $(MAKE) $(CONFIG_DIR)/setup.exe + $(INSTALL) $(CONFIG_DIR)/setup.exe $(DIST)/installer-stage + @echo 'Compressing installer files...' + cd $(DIST)/installer-stage && $(CYGWIN_WRAPPER) $(PKG_ARCHIVER_CMD) $(abspath $(CONFIG_DIR))/app.7z + $(MAKE) $(CONFIG_DIR)/7zSD.sfx + cat $(CONFIG_DIR)/7zSD.sfx $(CONFIG_DIR)/app.tag $(CONFIG_DIR)/app.7z > "$(DIST)/$(PKG_INSTALLER_FILENAME)" + +# --------------------------------------------------------------------------------------------------------------------- + +uninstaller:: + $(RM) -r $(CONFIG_DIR) && mkdir $(CONFIG_DIR) + $(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(DIST)/branding/,$(BRANDING_FILES)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(MOZINST_PATH)/windows/nsis/,$(TOOLKIT_NSIS_FILES)) $(CONFIG_DIR) + $(INSTALL) $(addprefix $(MOZILLA_DIR)/other-licenses/nsis/Plugins/,$(CUSTOM_NSIS_PLUGINS)) $(CONFIG_DIR) + $(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ + $(srcdir)/src/defines.nsi.in -o $(CONFIG_DIR)/defines.nsi) + $(PYTHON) $(MOZINST_PATH)/windows/nsis/preprocess-locale.py --preprocess-locale \ + $(MOZILLA_SRCDIR) $(abspath $(srcdir))/locale $(AB_CD) $(CONFIG_DIR) + $(NSINSTALL) -D $(DIST)/bin/uninstall + cd $(CONFIG_DIR) && $(MAKENSISU) uninstaller.nsi + cp $(CONFIG_DIR)/helper.exe $(DIST)/bin/uninstall + +# ===================================================================================================================== diff --git a/system/packager/locale-install.rdf.in b/system/packager/locale-install.rdf.in new file mode 100644 index 000000000..23cc16d3c --- /dev/null +++ b/system/packager/locale-install.rdf.in @@ -0,0 +1,34 @@ +<?xml version="1.0"?> + +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + <Description about="urn:mozilla:install-manifest" + em:type="8" +#ifdef MC_PALEMOON + em:id="langpack-en-US@palemoon.org" +#elif BINOC_NAVIGATOR + em:id="langpack-en-US@borealis.binaryoutcast.com" +#elif BINOC_MAIL + em:id="langpack-en-US@interlink.binaryoutcast.com" +#else +#expand em:id="langpack-en-US@__MOZ_APP_NAME" +#endif + em:version="@MOZ_APP_VERSION@" + em:name="English (US) Language Pack" +#if defined(BINOC_NAVIGATOR) || defined(BINOC_MAIL) + em:creator="Binary Outcast" +#elif MC_PALEMOON + em:creator="Moonchild Productions" +#else + em:creator="Open Source Contributors" +#endif + em:strictCompatibility="true" + em:license="MPL-2.0"> + + <em:targetApplication> + <Description em:id="@MOZ_APP_ID@" + em:minVersion="@MOZ_APP_VERSION@" + em:maxVersion="@MOZ_APP_MAXVERSION@"/> + </em:targetApplication> + </Description> +</RDF> diff --git a/system/packager/make-update.sh b/system/packager/make-update.sh new file mode 100644 index 000000000..bfa867a5f --- /dev/null +++ b/system/packager/make-update.sh @@ -0,0 +1,325 @@ +#!/bin/bash +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# +# This tool generates full update packages for the update system. +# Author: Darin Fisher +# + +# ----------------------------------------------------------------------------- +# By default just assume that these tools exist in our path +MAR=${MAR:-mar} +MBSDIFF=${MBSDIFF:-mbsdiff} +if [[ -z "${MAR_OLD_FORMAT}" ]]; then + XZ=${XZ:-xz} +else + MAR_OLD_FORMAT=1 + BZIP2=${BZIP2:-bzip2} +fi + +# ----------------------------------------------------------------------------- +# Helper routines + +notice() { + echo "$*" 1>&2 +} + +get_file_size() { + info=($(ls -ln "$1")) + echo ${info[4]} +} + +copy_perm() { + reference="$1" + target="$2" + + if [ -x "$reference" ]; then + chmod 0755 "$target" + else + chmod 0644 "$target" + fi +} + +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 [ $4 ]; then + forced=" (forced)" + else + forced= + fi + + 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/\(.*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\"" >> "$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` = "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" + 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/\(.*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.patch\" \"$f\"" + echo "patch \"$f.patch\" \"$f\"" >> "$filev2" + echo "patch \"$f.patch\" \"$f\"" >> "$filev3" + fi +} + +append_remove_instructions() { + dir="$1" + filev2="$2" + filev3="$3" + + if [ -f "$dir/removed-files" ]; then + listfile="$dir/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. + files=($(cat "$listfile" | tr " " "|" | sort -r)) + num_files=${#files[*]} + for ((i=0; $i<$num_files; i=$i+1)); do + # Map pipes back to whitespace and remove carriage returns + f=$(echo ${files[$i]} | tr "|" " " | tr -d '\r') + # Trim whitespace + f=$(echo $f) + # Exclude blank lines. + if [ -n "$f" ]; then + # Exclude comments + if [ ! $(echo "$f" | grep -c '^#') = 1 ]; then + if [ $(echo "$f" | grep -c '\/$') = 1 ]; then + 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 \"$f\"" + echo "rmrfdir \"$f\"" >> "$filev2" + echo "rmrfdir \"$f\"" >> "$filev3" + else + notice " remove \"$f\"" + echo "remove \"$f\"" >> "$filev2" + echo "remove \"$f\"" >> "$filev3" + fi + fi + fi + done + fi +} + +# List all files in the current directory, stripping leading "./" +# Pass a variable name and it will be filled as an array. +list_files() { + count=0 + + find . -type f \ + ! -name "update.manifest" \ + ! -name "updatev2.manifest" \ + ! -name "updatev3.manifest" \ + ! -name "temp-dirlist" \ + ! -name "temp-filelist" \ + | sed 's/\.\/\(.*\)/\1/' \ + | sort -r > "temp-filelist" + while read file; do + eval "${1}[$count]=\"$file\"" + (( count++ )) + done < "temp-filelist" + rm "temp-filelist" +} + +# List all directories in the current directory, stripping leading "./" +list_dirs() { + count=0 + + find . -type d \ + ! -name "." \ + ! -name ".." \ + | sed 's/\.\/\(.*\)/\1/' \ + | sort -r > "temp-dirlist" + while read dir; do + eval "${1}[$count]=\"$dir\"" + (( count++ )) + done < "temp-dirlist" + rm "temp-dirlist" +} + +# ----------------------------------------------------------------------------- + +print_usage() { + notice "Usage: $(basename $0) [OPTIONS] ARCHIVE DIRECTORY" +} + +if [ $# = 0 ]; then + print_usage + exit 1 +fi + +if [ $1 = -h ]; then + print_usage + notice "" + notice "The contents of DIRECTORY will be stored in ARCHIVE." + notice "" + notice "Options:" + notice " -h show this help text" + notice "" + exit 1 +fi + +# ----------------------------------------------------------------------------- + +archive="$1" +targetdir="$2" +# Prevent the workdir from being inside the targetdir so it isn't included in +# the update mar. +if [ $(echo "$targetdir" | grep -c '\/$') = 1 ]; then + # Remove the / + targetdir=$(echo "$targetdir" | sed -e 's:\/$::') +fi +workdir="$targetdir.work" +updatemanifestv2="$workdir/updatev2.manifest" +updatemanifestv3="$workdir/updatev3.manifest" +targetfiles="updatev2.manifest updatev3.manifest" + +mkdir -p "$workdir" + +# Generate a list of all files in the target directory. +pushd "$targetdir" +if test $? -ne 0 ; then + exit 1 +fi + +if [ ! -f "precomplete" ]; then + 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 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]}" + + 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" + if [[ -n $MAR_OLD_FORMAT ]]; then + $BZIP2 -cz9 "$targetdir/$f" > "$workdir/$f" + else + $XZ --compress --x86 --lzma2 --format=xz --check=crc64 --force --stdout "$targetdir/$f" > "$workdir/$f" + fi + copy_perm "$targetdir/$f" "$workdir/$f" + + targetfiles="$targetfiles \"$f\"" +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" + +if [[ -n $MAR_OLD_FORMAT ]]; then + $BZIP2 -z9 "$updatemanifestv2" && mv -f "$updatemanifestv2.bz2" "$updatemanifestv2" + $BZIP2 -z9 "$updatemanifestv3" && mv -f "$updatemanifestv3.bz2" "$updatemanifestv3" +else + $XZ --compress --x86 --lzma2 --format=xz --check=crc64 --force "$updatemanifestv2" && mv -f "$updatemanifestv2.xz" "$updatemanifestv2" + $XZ --compress --x86 --lzma2 --format=xz --check=crc64 --force "$updatemanifestv3" && mv -f "$updatemanifestv3.xz" "$updatemanifestv3" +fi + +eval "$MAR -C \"$workdir\" -c output.mar $targetfiles" +mv -f "$workdir/output.mar" "$archive" + +# cleanup +rm -fr "$workdir" + +notice "" +notice "Finished" +notice "" diff --git a/system/packager/packager.mk b/system/packager/packager.mk new file mode 100644 index 000000000..bf968e3dc --- /dev/null +++ b/system/packager/packager.mk @@ -0,0 +1,157 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# == | Makefile Targets | ============================================================================================= + +libs:: stage-package + +install:: + $(error "make install" is no longer supported on any target operating system. Use "make package" instead) + +ifeq ($(OS_ARCH),WINNT) +ifndef MAKENSISU +installer:: + $(error "make installer" requires NSIS) +endif # MAKENSISU +else +installer:: + $(error "make installer" only supports Windows at this time) +endif + +# --------------------------------------------------------------------------------------------------------------------- + +# Handle the package manifest(s) if it is used +ifdef MOZ_PKG_MANIFEST_P +MOZ_PKG_MANIFEST = package-manifest + +$(MOZ_PKG_MANIFEST): $(MOZ_PKG_MANIFEST_P) $(GLOBAL_DEPS) + $(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) $< -o $@) + +GARBAGE += $(MOZ_PKG_MANIFEST) +endif + +# --------------------------------------------------------------------------------------------------------------------- + +# Create the mozbuildinfo json file +.PHONY: json-metadata +json-metadata: + @$(RM) -f $(DIST)/$(PKG_JSON_FILENAME) + $(PYTHON) $(MOZINST_PATH)/informulate.py \ + $(DIST)/$(PKG_JSON_FILENAME) \ + BUILDID=$(BUILDID) \ + MOZ_PKG_PLATFORM=$(PKG_BUILD_TARGET) + +# --------------------------------------------------------------------------------------------------------------------- + +# Stage and strip the package +stage-package: $(MOZ_PKG_MANIFEST) json-metadata + @echo 'Staging application files...' + OMNIJAR_NAME=$(OMNIJAR_NAME) \ + NO_PKG_FILES="$(NO_PKG_FILES)" \ + $(PYTHON) $(MOZINST_PATH)/packager.py $(DEFINES) $(ACDEFINES) \ + --format $(MOZ_PACKAGER_FORMAT) \ + $(if $(MOZ_PKG_REMOVALS),$(addprefix --removals ,$(MOZ_PKG_REMOVALS))) \ + $(if $(filter-out 0,$(MOZ_PKG_FATAL_WARNINGS)),,--ignore-errors) \ + $(if $(OPTIMIZEJARS),--optimizejars) \ + $(addprefix --compress ,$(JAR_COMPRESSION)) \ + $(MOZ_PKG_MANIFEST) '$(DIST)' '$(DIST)'/$(PKG_STAGE_DIR)$(if $(MOZ_PKG_MANIFEST),,$(_BINPATH)) \ + $(if $(filter omni,$(MOZ_PACKAGER_FORMAT)),$(if $(NON_OMNIJAR_FILES),--non-resource $(NON_OMNIJAR_FILES))) + $(PYTHON) $(MOZINST_PATH)/find-dupes.py $(DIST)/$(PKG_STAGE_DIR) + @(cd $(DIST)/$(PKG_STAGE_DIR) && $(CREATE_PRECOMPLETE_CMD)) + +# --------------------------------------------------------------------------------------------------------------------- + +# Package the application as an archive +archive: stage-package + @echo 'Compressing application archive...' +ifeq ($(OS_ARCH),WINNT) + cd $(DIST); $(CYGWIN_WRAPPER) $(PKG_ARCHIVER_CMD) $(PKG_ARCHIVE_FILENAME) $(PKG_STAGE_DIR) +else + cd $(DIST); XZ_OPT=-9e $(PKG_ARCHIVER_CMD) $(PKG_ARCHIVE_FILENAME) $(PKG_STAGE_DIR) +endif + +# --------------------------------------------------------------------------------------------------------------------- + +update: $(call mkdir_deps,$(ABS_DIST)/$(PKG_STAGE_DIR)) + @echo 'Creating update mar (xz compressed)...' + MAR=$(DIST)/host/bin/mar$(HOST_BIN_SUFFIX) \ + $(MOZILLA_DIR)/system/packager/make-update.sh \ + '$(DIST)/$(PKG_UPDATE_FILENAME)' '$(DIST)/$(PKG_STAGE_DIR)' + +# --------------------------------------------------------------------------------------------------------------------- + +update-bz2: $(call mkdir_deps,$(ABS_DIST)/$(PKG_STAGE_DIR)) + @echo 'Creating update mar (bz2 compressed)...' + MAR_OLD_FORMAT=1 MAR=$(DIST)/host/bin/mar$(HOST_BIN_SUFFIX) \ + $(MOZILLA_DIR)/system/packager/make-update.sh \ + '$(DIST)/$(PKG_BASENAME).complete.mar' '$(DIST)/$(PKG_STAGE_DIR)' + +# --------------------------------------------------------------------------------------------------------------------- + +# Package debugging symbols +.PHONY: symbols +symbols: +ifeq ($(OS_ARCH),WINNT) + @echo 'Staging debugging symbols...' + @$(RM) -rf $(DIST)/$(PKG_SYMBOLS_STAGE_DIR) $(DIST)/$(PKG_SYMBOLS_FILENAME) + cd $(topobjdir); find . -type f -name "*.pdb" \ + -not -path "./dist/*" \ + -not -name "generated.pdb" \ + -not -name "vc*.pdb" \ + -exec install -Dv {} ./dist/$(PKG_SYMBOLS_STAGE_DIR)/{} \; + @echo 'Compressing debugging symbols...' + cd $(DIST); $(CYGWIN_WRAPPER) $(PKG_ARCHIVER_CMD) $(PKG_SYMBOLS_FILENAME) $(PKG_SYMBOLS_STAGE_DIR) +else + $(error "make symbols" only supports Windows at this time) +endif + +# --------------------------------------------------------------------------------------------------------------------- + +# For some reason when manually regenerating the chrome files with a fully built dist/bin it fucks up compiling +# the startupcache. +# So we only invoke this phony-target purging and regenerating when the application is NOT fully built. +# Otherwise one should treat the locale and skin targets like any other packaging target, namely, issuing a build +# command to regenerate. +# tl;dr hacks are hack-y. +.PHONY: regenerate-chrome +regenerate-chrome: + @echo '(Re)generating chrome files...' + @test -f $(topobjdir)/source-repo.h || $(MAKE) -C $(DEPTH) export + @$(RM) -rf $(DIST)/bin/chrome.manifest $(DIST)/bin/chrome; + @$(MAKE) -C $(DEPTH) chrome + +# --------------------------------------------------------------------------------------------------------------------- + +# Create an en-US language pack without needing a whole custom build system codepath +.PHONY: locale +locale: + @$(RM) -rf $(DIST)/$(PKG_XPI_L10N_STAGE_DIR) $(DIST)/$(PKG_XPI_L10N_FILENAME) + @test -f $(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX) || $(MAKE) regenerate-chrome + @echo 'Staging l10n files...' + @$(NSINSTALL) -D $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/chrome + @$(TOOLCHAIN_PREFIX)cp -rv $(DIST)/bin/chrome/en-US.manifest $(DIST)/bin/chrome/en-US $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/chrome + @echo manifest chrome/en-US.manifest > $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/chrome.manifest + $(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ + $(GREPKGR_PATH)/locale-install.rdf.in -o $(DIST)/$(PKG_XPI_L10N_STAGE_DIR)/install.rdf) + @echo 'Compressing l10n files...' + cd $(DIST)/$(PKG_XPI_L10N_STAGE_DIR); $(ZIP) -Dr9X ../../$(PKG_XPI_L10N_FILENAME) * + +# --------------------------------------------------------------------------------------------------------------------- + +# Create an os-dependent skin without needing a whole custom build system codepath +.PHONY: skin +skin: + @$(RM) -rf $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR) $(DIST)/$(PKG_XPI_SKIN_FILENAME) + @test -f $(DIST)/bin/$(MOZ_APP_NAME)$(BIN_SUFFIX) || $(MAKE) regenerate-chrome + @echo 'Staging theme files...' + @$(NSINSTALL) -D $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/chrome + @$(TOOLCHAIN_PREFIX)cp -rv $(DIST)/bin/chrome/classic.manifest $(DIST)/bin/chrome/classic $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/chrome + @$(TOOLCHAIN_PREFIX)cp -rv $(DIST)/bin/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.manifest $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR) + @echo manifest chrome/classic.manifest >> $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/chrome.manifest + $(call py_action,preprocessor,-Fsubstitution $(DEFINES) $(ACDEFINES) \ + $(GREPKGR_PATH)/skin-install.rdf.in -o $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR)/install.rdf) + @echo 'Compressing theme files...' + cd $(DIST)/$(PKG_XPI_SKIN_STAGE_DIR); $(ZIP) -Dr9X ../../$(PKG_XPI_SKIN_FILENAME) * + +# ===================================================================================================================== diff --git a/system/packager/skin-install.rdf.in b/system/packager/skin-install.rdf.in new file mode 100644 index 000000000..e646ff95d --- /dev/null +++ b/system/packager/skin-install.rdf.in @@ -0,0 +1,21 @@ +<?xml version="1.0"?> + +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + <Description about="urn:mozilla:install-manifest" + em:type="4" +#expand em:id="default-theme@__MOZ_APP_NAME__" + em:version="@MOZ_APP_VERSION@" + em:name="Default Application Theme" + em:creator="Open Source Contributors" + em:strictCompatibility="true" + em:internalName="classic/1.0" + em:license="MPL-2.0"> + + <em:targetApplication> + <Description em:id="@MOZ_APP_ID@" + em:minVersion="@MOZ_APP_VERSION@" + em:maxVersion="@MOZ_APP_VERSION@"/> + </em:targetApplication> + </Description> +</RDF> |