diff --git a/copy.go b/copy.go
new file mode 100644
index 0000000..a728e49
--- /dev/null
+++ b/copy.go
@@ -0,0 +1,99 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+)
+
+// applyCopyPatch handles `t:copy` type patches for copying and replacing files or directories
+func applyCopyPatch(inputPath, outputPath string) error {
+ fmt.Printf("Copying from %s to %s\n", inputPath, outputPath)
+
+ // Check if the source exists
+ info, err := os.Stat(inputPath)
+ if os.IsNotExist(err) {
+ return fmt.Errorf("input path does not exist: %s", inputPath)
+ }
+
+ // Handle files and directories differently
+ if info.IsDir() {
+ // Copy a directory
+ return copyDirectory(inputPath, outputPath)
+ } else {
+ // Copy a single file
+ return copyFile(inputPath, outputPath, info.Mode())
+ }
+}
+
+// copyFile copies a single file and replaces the destination if it exists
+func copyFile(srcFilePath, dstFilePath string, fileMode os.FileMode) error {
+ // Ensure the destination directory exists
+ destDir := filepath.Dir(dstFilePath)
+ if err := os.MkdirAll(destDir, os.ModePerm); err != nil {
+ return fmt.Errorf("failed to create destination directory: %s", destDir)
+ }
+
+ // Open source file
+ srcFile, err := os.Open(srcFilePath)
+ if err != nil {
+ return fmt.Errorf("failed to open source file: %s", srcFilePath)
+ }
+ defer srcFile.Close()
+
+ // Create destination file
+ dstFile, err := os.Create(dstFilePath)
+ if err != nil {
+ return fmt.Errorf("failed to create destination file: %s", dstFilePath)
+ }
+ defer dstFile.Close()
+
+ // Copy contents from source to destination
+ if _, err := io.Copy(dstFile, srcFile); err != nil {
+ return fmt.Errorf("failed to copy file: %v", err)
+ }
+
+ // Set file permissions
+ if err := os.Chmod(dstFilePath, fileMode); err != nil {
+ return fmt.Errorf("failed to set file permissions: %v", err)
+ }
+
+ fmt.Printf("File copied: %s -> %s\n", srcFilePath, dstFilePath)
+ return nil
+}
+
+// copyDirectory copies the contents of a directory and replaces the destination if it exists
+func copyDirectory(srcDirPath, dstDirPath string) error {
+ // Ensure the destination directory exists
+ if err := os.MkdirAll(dstDirPath, os.ModePerm); err != nil {
+ return fmt.Errorf("failed to create destination directory: %s", dstDirPath)
+ }
+
+ // Walk through the directory and copy each file/directory
+ return filepath.Walk(srcDirPath, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+
+ // Compute the destination path
+ relPath, err := filepath.Rel(srcDirPath, path)
+ if err != nil {
+ return fmt.Errorf("failed to compute relative path: %v", err)
+ }
+ destPath := filepath.Join(dstDirPath, relPath)
+
+ if info.IsDir() {
+ // Create the destination directory
+ if err := os.MkdirAll(destPath, os.ModePerm); err != nil {
+ return fmt.Errorf("failed to create directory: %s", destPath)
+ }
+ } else {
+ // Copy the file
+ if err := copyFile(path, destPath, info.Mode()); err != nil {
+ return err
+ }
+ }
+ return nil
+ })
+}
diff --git a/main.go b/main.go
index 932b8d9..2e449df 100755
--- a/main.go
+++ b/main.go
@@ -154,8 +154,7 @@ func applyPatch(patchPath, rootPath string) error {
return fmt.Errorf("patch file must specify output (o:) file")
}
- if patchType != "new" {
- // Replace the original file with the temporary file
+ if patchType != "new" && patchType != "copy" {
err = os.Rename(inputFilePath, outputFilePath)
if err != nil {
return fmt.Errorf("failed to replace output file: %v", err)
@@ -170,6 +169,8 @@ func applyPatch(patchPath, rootPath string) error {
return applyStandardModifications(outputFilePath, modifications)
case "new":
return applyNewModifications(outputFilePath, modifications)
+ case "copy":
+ return applyCopyPatch(inputFilePath, outputFilePath)
default:
fmt.Printf("Type not specified defaulting to standard")
return applyStandardModifications(outputFilePath, modifications)
diff --git a/pre-compile-patches/branding/PrivateBrowsing_150.png b/pre-compile-patches/branding/PrivateBrowsing_150.png
new file mode 100644
index 0000000..35109a0
Binary files /dev/null and b/pre-compile-patches/branding/PrivateBrowsing_150.png differ
diff --git a/pre-compile-patches/branding/PrivateBrowsing_70.png b/pre-compile-patches/branding/PrivateBrowsing_70.png
new file mode 100644
index 0000000..68c4618
Binary files /dev/null and b/pre-compile-patches/branding/PrivateBrowsing_70.png differ
diff --git a/pre-compile-patches/branding/VisualElements_150.png b/pre-compile-patches/branding/VisualElements_150.png
new file mode 100644
index 0000000..380e059
Binary files /dev/null and b/pre-compile-patches/branding/VisualElements_150.png differ
diff --git a/pre-compile-patches/branding/VisualElements_70.png b/pre-compile-patches/branding/VisualElements_70.png
new file mode 100644
index 0000000..5e8eb8b
Binary files /dev/null and b/pre-compile-patches/branding/VisualElements_70.png differ
diff --git a/pre-compile-patches/branding/background.png b/pre-compile-patches/branding/background.png
new file mode 100644
index 0000000..b066942
Binary files /dev/null and b/pre-compile-patches/branding/background.png differ
diff --git a/pre-compile-patches/branding/content/about-logo-private.png b/pre-compile-patches/branding/content/about-logo-private.png
new file mode 100644
index 0000000..59761f0
Binary files /dev/null and b/pre-compile-patches/branding/content/about-logo-private.png differ
diff --git a/pre-compile-patches/branding/content/about-logo-private@2x.png b/pre-compile-patches/branding/content/about-logo-private@2x.png
new file mode 100644
index 0000000..1f67349
Binary files /dev/null and b/pre-compile-patches/branding/content/about-logo-private@2x.png differ
diff --git a/pre-compile-patches/branding/content/about-logo.png b/pre-compile-patches/branding/content/about-logo.png
new file mode 100644
index 0000000..51d9e58
Binary files /dev/null and b/pre-compile-patches/branding/content/about-logo.png differ
diff --git a/pre-compile-patches/branding/content/about-logo.svg b/pre-compile-patches/branding/content/about-logo.svg
new file mode 100644
index 0000000..a84b9db
--- /dev/null
+++ b/pre-compile-patches/branding/content/about-logo.svg
@@ -0,0 +1,74 @@
+
+
diff --git a/pre-compile-patches/branding/content/about-logo@2x.png b/pre-compile-patches/branding/content/about-logo@2x.png
new file mode 100644
index 0000000..66b5a59
Binary files /dev/null and b/pre-compile-patches/branding/content/about-logo@2x.png differ
diff --git a/pre-compile-patches/branding/content/about-wordmark.svg b/pre-compile-patches/branding/content/about-wordmark.svg
new file mode 100644
index 0000000..8b58c7f
--- /dev/null
+++ b/pre-compile-patches/branding/content/about-wordmark.svg
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/pre-compile-patches/branding/content/about.png b/pre-compile-patches/branding/content/about.png
new file mode 100644
index 0000000..aaa24a9
Binary files /dev/null and b/pre-compile-patches/branding/content/about.png differ
diff --git a/pre-compile-patches/branding/content/document_pdf.svg b/pre-compile-patches/branding/content/document_pdf.svg
new file mode 100644
index 0000000..02e3409
--- /dev/null
+++ b/pre-compile-patches/branding/content/document_pdf.svg
@@ -0,0 +1,32 @@
+
+
\ No newline at end of file
diff --git a/pre-compile-patches/branding/content/firefox-wordmark.svg b/pre-compile-patches/branding/content/firefox-wordmark.svg
new file mode 100644
index 0000000..e5eb91c
--- /dev/null
+++ b/pre-compile-patches/branding/content/firefox-wordmark.svg
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/pre-compile-patches/branding/default128.png b/pre-compile-patches/branding/default128.png
new file mode 100644
index 0000000..3c7f73a
Binary files /dev/null and b/pre-compile-patches/branding/default128.png differ
diff --git a/pre-compile-patches/branding/default16.png b/pre-compile-patches/branding/default16.png
new file mode 100644
index 0000000..3143ffa
Binary files /dev/null and b/pre-compile-patches/branding/default16.png differ
diff --git a/pre-compile-patches/branding/default22.png b/pre-compile-patches/branding/default22.png
new file mode 100644
index 0000000..dc3b5f8
Binary files /dev/null and b/pre-compile-patches/branding/default22.png differ
diff --git a/pre-compile-patches/branding/default24.png b/pre-compile-patches/branding/default24.png
new file mode 100644
index 0000000..4f1fbc2
Binary files /dev/null and b/pre-compile-patches/branding/default24.png differ
diff --git a/pre-compile-patches/branding/default256.png b/pre-compile-patches/branding/default256.png
new file mode 100644
index 0000000..ccc1735
Binary files /dev/null and b/pre-compile-patches/branding/default256.png differ
diff --git a/pre-compile-patches/branding/default32.png b/pre-compile-patches/branding/default32.png
new file mode 100644
index 0000000..796c0e9
Binary files /dev/null and b/pre-compile-patches/branding/default32.png differ
diff --git a/pre-compile-patches/branding/default48.png b/pre-compile-patches/branding/default48.png
new file mode 100644
index 0000000..e58dedd
Binary files /dev/null and b/pre-compile-patches/branding/default48.png differ
diff --git a/pre-compile-patches/branding/default64.png b/pre-compile-patches/branding/default64.png
new file mode 100644
index 0000000..67d8df1
Binary files /dev/null and b/pre-compile-patches/branding/default64.png differ
diff --git a/pre-compile-patches/branding/disk.icns b/pre-compile-patches/branding/disk.icns
new file mode 100644
index 0000000..aec8f85
Binary files /dev/null and b/pre-compile-patches/branding/disk.icns differ
diff --git a/pre-compile-patches/branding/document.icns b/pre-compile-patches/branding/document.icns
new file mode 100644
index 0000000..fe169ab
Binary files /dev/null and b/pre-compile-patches/branding/document.icns differ
diff --git a/pre-compile-patches/branding/document.ico b/pre-compile-patches/branding/document.ico
new file mode 100644
index 0000000..022a499
Binary files /dev/null and b/pre-compile-patches/branding/document.ico differ
diff --git a/pre-compile-patches/branding/document_pdf.ico b/pre-compile-patches/branding/document_pdf.ico
new file mode 100644
index 0000000..df71d45
Binary files /dev/null and b/pre-compile-patches/branding/document_pdf.ico differ
diff --git a/pre-compile-patches/branding/firefox.icns b/pre-compile-patches/branding/firefox.icns
new file mode 100644
index 0000000..bd7b1f6
Binary files /dev/null and b/pre-compile-patches/branding/firefox.icns differ
diff --git a/pre-compile-patches/branding/firefox.ico b/pre-compile-patches/branding/firefox.ico
new file mode 100644
index 0000000..3d1065c
Binary files /dev/null and b/pre-compile-patches/branding/firefox.ico differ
diff --git a/pre-compile-patches/branding/firefox64.ico b/pre-compile-patches/branding/firefox64.ico
new file mode 100644
index 0000000..f9a6bf2
Binary files /dev/null and b/pre-compile-patches/branding/firefox64.ico differ
diff --git a/pre-compile-patches/branding/pbmode.ico b/pre-compile-patches/branding/pbmode.ico
new file mode 100644
index 0000000..931df8f
Binary files /dev/null and b/pre-compile-patches/branding/pbmode.ico differ
diff --git a/pre-compile-patches/branding/stubinstaller/bgstub.jpg b/pre-compile-patches/branding/stubinstaller/bgstub.jpg
new file mode 100644
index 0000000..148be5f
Binary files /dev/null and b/pre-compile-patches/branding/stubinstaller/bgstub.jpg differ
diff --git a/pre-compile-patches/branding/wizHeader.bmp b/pre-compile-patches/branding/wizHeader.bmp
new file mode 100644
index 0000000..57697a0
Binary files /dev/null and b/pre-compile-patches/branding/wizHeader.bmp differ
diff --git a/pre-compile-patches/branding/wizHeaderRTL.bmp b/pre-compile-patches/branding/wizHeaderRTL.bmp
new file mode 100644
index 0000000..73b6904
Binary files /dev/null and b/pre-compile-patches/branding/wizHeaderRTL.bmp differ
diff --git a/pre-compile-patches/branding/wizWatermark.bmp b/pre-compile-patches/branding/wizWatermark.bmp
new file mode 100644
index 0000000..7129ce2
Binary files /dev/null and b/pre-compile-patches/branding/wizWatermark.bmp differ
diff --git a/pre-compile-patches/logo-replace copy.patch b/pre-compile-patches/logo-replace copy.patch
new file mode 100644
index 0000000..8842fb1
--- /dev/null
+++ b/pre-compile-patches/logo-replace copy.patch
@@ -0,0 +1,3 @@
+t: copy
+i: /patcher/pre-compile-patches/branding
+o: /browser/branding/official
diff --git a/pre-compile-patches/logo-replace-nightly.patch b/pre-compile-patches/logo-replace-nightly.patch
new file mode 100644
index 0000000..99f2c82
--- /dev/null
+++ b/pre-compile-patches/logo-replace-nightly.patch
@@ -0,0 +1,3 @@
+t: copy
+i: /patcher/pre-compile-patches/branding
+o: /browser/branding/nightly
diff --git a/pre-compile-patches/logo-replace-unofficial.patch b/pre-compile-patches/logo-replace-unofficial.patch
new file mode 100644
index 0000000..a4c3bb7
--- /dev/null
+++ b/pre-compile-patches/logo-replace-unofficial.patch
@@ -0,0 +1,3 @@
+t: copy
+i: /patcher/pre-compile-patches/branding
+o: /browser/branding/unofficial
diff --git a/pre-compile-patches/logo-replace.patch b/pre-compile-patches/logo-replace.patch
new file mode 100644
index 0000000..8842fb1
--- /dev/null
+++ b/pre-compile-patches/logo-replace.patch
@@ -0,0 +1,3 @@
+t: copy
+i: /patcher/pre-compile-patches/branding
+o: /browser/branding/official
diff --git a/pre-compile-patches/logo-stop-updates-nightly.patch b/pre-compile-patches/logo-stop-updates-nightly.patch
new file mode 100644
index 0000000..3720a01
--- /dev/null
+++ b/pre-compile-patches/logo-stop-updates-nightly.patch
@@ -0,0 +1,26 @@
+t: pref
+i: /browser/branding/nightly/pref/firefox-branding.js
+o: /browser/branding/nightly/pref/firefox-branding.js
+
++// Disable updates
++pref("app.update.enabled", false);
++pref("app.update.auto", false);
++pref("app.update.checkInstallTime", false);
+
++// Redirect update URLs to prevent fetching updates
++pref("app.update.url.manual", "https://localhost");
++pref("app.update.url.details", "https://localhost");
++pref("app.releaseNotesURL", "https://localhost");
++pref("app.releaseNotesURL.aboutDialog", "https://localhost");
+
++// Disable welcome and update pages
++pref("startup.homepage_override_url", "");
++pref("startup.homepage_welcome_url", "");
++pref("startup.homepage_welcome_url.additional", "");
+
++// Prevent update prompts
++pref("app.update.promptWaitTime", 0);
++pref("app.update.badgeWaitTime", 0);
+
++// Lock branding-related preferences (if applicable)
++pref("browser.startup.homepage", "about:blank");
diff --git a/pre-compile-patches/logo-stop-updates-unofficial.patch b/pre-compile-patches/logo-stop-updates-unofficial.patch
new file mode 100644
index 0000000..001fe37
--- /dev/null
+++ b/pre-compile-patches/logo-stop-updates-unofficial.patch
@@ -0,0 +1,26 @@
+t: pref
+i: /browser/branding/unofficial/pref/firefox-branding.js
+o: /browser/branding/unofficial/pref/firefox-branding.js
+
++// Disable updates
++pref("app.update.enabled", false);
++pref("app.update.auto", false);
++pref("app.update.checkInstallTime", false);
+
++// Redirect update URLs to prevent fetching updates
++pref("app.update.url.manual", "https://localhost");
++pref("app.update.url.details", "https://localhost");
++pref("app.releaseNotesURL", "https://localhost");
++pref("app.releaseNotesURL.aboutDialog", "https://localhost");
+
++// Disable welcome and update pages
++pref("startup.homepage_override_url", "");
++pref("startup.homepage_welcome_url", "");
++pref("startup.homepage_welcome_url.additional", "");
+
++// Prevent update prompts
++pref("app.update.promptWaitTime", 0);
++pref("app.update.badgeWaitTime", 0);
+
++// Lock branding-related preferences (if applicable)
++pref("browser.startup.homepage", "about:blank");
diff --git a/run.sh b/run.sh
index 852c5a8..5ab7fd2 100755
--- a/run.sh
+++ b/run.sh
@@ -41,7 +41,7 @@ if [[ ! -d "$PATCHES_SOURCE" ]]; then
fi
# Run the Go application with the specified path and patches
-go run main.go pref.go standard.go new.go --path "$ROOT_PATH" --patches "$PATCHES_SOURCE"
+go run main.go pref.go standard.go new.go copy.go --path "$ROOT_PATH" --patches "$PATCHES_SOURCE"
# Exit with the status of the last command
exit $?