mirror of
https://github.com/imputnet/helium.git
synced 2026-08-20 00:57:32 +02:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ce4603ecf | |||
| 6cce6332c7 | |||
| 8f89dcfa97 | |||
| 830b7bcc4b | |||
| 06da4cfcdc | |||
| f34f4e8bd2 | |||
| 27d17fa340 | |||
| fc37b27f9a | |||
| a290073661 | |||
| 0814b98d6b | |||
| b6eaed2233 | |||
| d13d58652f | |||
| fde4fe86b6 |
+1
-1
@@ -43,7 +43,7 @@ mkdir -p build/download_cache
|
||||
```sh
|
||||
./utils/domain_substitution.py apply -r domain_regex.list -f domain_substitution.list -c build/domsubcache.tar.gz build/src
|
||||
|
||||
./utils/name_substitution.sh" sub build/src
|
||||
python3 ./utils/name_substitution.py" --sub -t build/src
|
||||
```
|
||||
|
||||
5. Build GN. If you are using `depot_tools` to checkout Chromium or you already have a GN binary, you should skip this step.
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ sha256 = cd954c7257f126be871f79ecf8fff143425708d5d33501d0ba870fa466dafbe7
|
||||
output_path = ./components/resources/default_100_percent/search_engine_choice
|
||||
|
||||
[onboarding]
|
||||
version = 202505031903
|
||||
version = 202505121619
|
||||
url = https://github.com/imputnet/helium-onboarding/releases/download/%(version)s/helium-onboarding-%(version)s.tar.gz
|
||||
download_filename = onboarding-page-%(version)s.tar.gz
|
||||
sha256 = a8f2ba7665b98191ef343f0134fadea4d73c5954bbc4d2413d10c8fb5e9f8f4c
|
||||
sha256 = 48e0a8e4a9ecbfd28e0ba3366c9f4d1035878e4f9085751571510be73d85994d
|
||||
output_path = ./components/helium_onboarding
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/chrome/browser/resources/settings/about_page/about_page.html
|
||||
+++ b/chrome/browser/resources/settings/about_page/about_page.html
|
||||
@@ -47,7 +47,7 @@
|
||||
</style>
|
||||
<settings-section page-title="$i18n{aboutPageTitle}" section="about">
|
||||
<div class="cr-row two-line first">
|
||||
- <img id="product-logo" on-click="onProductLogoClick_"
|
||||
+ <img id="product-logo"
|
||||
srcset="chrome://theme/current-channel-logo@1x 1x,
|
||||
chrome://theme/current-channel-logo@2x 2x"
|
||||
alt="$i18n{aboutProductLogoAlt}"
|
||||
@@ -0,0 +1,40 @@
|
||||
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
|
||||
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
|
||||
@@ -172,7 +172,7 @@ using PermanentFolderType = BookmarkPare
|
||||
bool animations_enabled = true;
|
||||
|
||||
// Thickness of the separator (|) in dips (density-independent pixels).
|
||||
-constexpr int kBookmarkBarSeparatorThickness = 2;
|
||||
+constexpr int kBookmarkBarSeparatorThickness = 1;
|
||||
|
||||
gfx::ImageSkia* GetImageSkiaNamed(int id) {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
|
||||
@@ -350,8 +350,8 @@ class BookmarkBarView::ButtonSeparatorVi
|
||||
|
||||
public:
|
||||
ButtonSeparatorView() {
|
||||
- const int leading_padding = 8;
|
||||
- const int trailing_padding = 8;
|
||||
+ const int leading_padding = 3;
|
||||
+ const int trailing_padding = 3;
|
||||
separator_thickness_ = kBookmarkBarSeparatorThickness;
|
||||
const gfx::Insets border_insets =
|
||||
gfx::Insets::TLBR(0, leading_padding, 0, trailing_padding);
|
||||
@@ -697,7 +697,7 @@ void BookmarkBarView::Layout(PassKey) {
|
||||
}
|
||||
|
||||
int x = GetLeadingMargin();
|
||||
- static constexpr int kBookmarkBarTrailingMargin = 8;
|
||||
+ static constexpr int kBookmarkBarTrailingMargin = 6;
|
||||
int width = View::width() - x - kBookmarkBarTrailingMargin;
|
||||
|
||||
const int button_height = GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT);
|
||||
@@ -818,7 +818,7 @@ void BookmarkBarView::Layout(PassKey) {
|
||||
// the bookmark buttons.
|
||||
if (saved_tab_group_bar_width > 0) {
|
||||
// Possibly update the paddings of the separator
|
||||
- constexpr int kSeparatorPadding = 8;
|
||||
+ constexpr int kSeparatorPadding = 6;
|
||||
const int left_padding = saved_tab_group_bar_->IsOverflowButtonVisible()
|
||||
? 0
|
||||
: kSeparatorPadding;
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.cc
|
||||
+++ b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.cc
|
||||
@@ -754,6 +754,7 @@ bool TabGroupEditorBubbleView::IsGroupSh
|
||||
}
|
||||
|
||||
bool TabGroupEditorBubbleView::ShouldShowSavedFooter() const {
|
||||
+ return false;
|
||||
PrefService* pref_service = browser_->profile()->GetPrefs();
|
||||
return (CanSaveGroups() && pref_service &&
|
||||
saved_tab_group_prefs::GetLearnMoreFooterShownCount(pref_service) <
|
||||
@@ -1,5 +1,14 @@
|
||||
--- a/chrome/browser/ui/layout_constants.cc
|
||||
+++ b/chrome/browser/ui/layout_constants.cc
|
||||
@@ -29,7 +29,7 @@ int GetLayoutConstant(LayoutConstant con
|
||||
case BOOKMARK_BAR_HEIGHT: {
|
||||
// The fixed margin ensures the bookmark buttons appear centered relative
|
||||
// to the white space above and below.
|
||||
- const int bookmark_bar_attached_vertical_margin = 6;
|
||||
+ const int bookmark_bar_attached_vertical_margin = 3;
|
||||
return GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT) +
|
||||
bookmark_bar_attached_vertical_margin;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ int GetLayoutConstant(LayoutConstant con
|
||||
case LOCATION_BAR_CHILD_INTERIOR_PADDING:
|
||||
return 3;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/chrome/browser/resources/signin/profile_picker/profile_picker_app.html.ts
|
||||
+++ b/chrome/browser/resources/signin/profile_picker/profile_picker_app.html.ts
|
||||
@@ -8,8 +8,6 @@ import type {ProfilePickerAppElement} fr
|
||||
|
||||
export function getHtml(this: ProfilePickerAppElement) {
|
||||
return html`<!--_html_template_start_-->
|
||||
-<img id="banner-right" alt="">
|
||||
-<img id="banner-left" alt="">
|
||||
|
||||
<cr-view-manager id="viewManager">
|
||||
<profile-picker-main-view id="mainView" slot="view">
|
||||
--- a/chrome/browser/resources/signin/profile_picker/profile_picker_main_view.css
|
||||
+++ b/chrome/browser/resources/signin/profile_picker/profile_picker_main_view.css
|
||||
@@ -146,11 +146,6 @@ cr-icon[icon='profiles:add'] {
|
||||
--iron-icon-stroke-color: var(--google-grey-700);
|
||||
}
|
||||
|
||||
-#browseAsGuestButton {
|
||||
- margin-inline-start: var(--footer-spacing);
|
||||
- padding: 8px 16px;
|
||||
-}
|
||||
-
|
||||
#browseAsGuestButton > cr-icon {
|
||||
margin-inline-end: 0;
|
||||
--iron-icon-height: 24px;
|
||||
@@ -161,10 +156,10 @@ cr-checkbox {
|
||||
--cr-checkbox-label-color: var(--cr-secondary-text-color);
|
||||
--cr-checkbox-label-padding-start: 8px;
|
||||
justify-content: flex-end;
|
||||
- margin-inline-end: var(--footer-spacing);
|
||||
- margin-inline-start: auto;
|
||||
- padding-inline-end: 5px;
|
||||
- padding-inline-start: 5px;
|
||||
+}
|
||||
+
|
||||
+.footer {
|
||||
+ justify-content: space-evenly;
|
||||
}
|
||||
|
||||
#button-sign-in {
|
||||
--- a/chrome/browser/resources/signin/profile_picker/profile_picker_main_view.html.ts
|
||||
+++ b/chrome/browser/resources/signin/profile_picker/profile_picker_main_view.html.ts
|
||||
@@ -20,7 +20,7 @@ ${function() {
|
||||
<div class="flex-container">
|
||||
<div class="title-container">
|
||||
<div id="images-container">
|
||||
- <img id="product-logo" @click="${this.onProductLogoClick_}"
|
||||
+ <img id="product-logo"
|
||||
src="product_logo.svg" role="presentation">
|
||||
<img id="glic-logo" ?hidden="${!isGlicVersion()}" role="presentation">
|
||||
</div>
|
||||
@@ -9,6 +9,14 @@
|
||||
BuildSyncInfo();
|
||||
BuildAutofillButtons();
|
||||
}
|
||||
@@ -901,6 +901,7 @@ void ProfileMenuView::BuildIdentityWithC
|
||||
}
|
||||
|
||||
void ProfileMenuView::BuildAutofillSettingsButton() {
|
||||
+ return;
|
||||
CHECK(!browser()->profile()->IsGuestSession());
|
||||
AddFeatureButton(
|
||||
l10n_util::GetStringUTF16(IDS_PROFILE_MENU_AUTOFILL_SETTINGS_BUTTON),
|
||||
--- a/chrome/browser/ui/views/profiles/profile_menu_view_base.cc
|
||||
+++ b/chrome/browser/ui/views/profiles/profile_menu_view_base.cc
|
||||
@@ -690,8 +690,6 @@ void ProfileMenuViewBase::SetProfileIden
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
--- a/third_party/devtools-frontend/src/front_end/panels/recorder/RecorderController.ts
|
||||
+++ b/third_party/devtools-frontend/src/front_end/panels/recorder/RecorderController.ts
|
||||
@@ -1449,9 +1449,11 @@ export class RecorderController extends
|
||||
}
|
||||
></devtools-button>
|
||||
<div class="feedback">
|
||||
+ <!--
|
||||
<x-link class="x-link" href=${
|
||||
FEEDBACK_URL
|
||||
} jslog=${VisualLogging.link('feedback').track({click: true})}>${i18nString(UIStrings.sendFeedback)}</x-link>
|
||||
+ -->
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
<devtools-shortcut-dialog
|
||||
--- a/third_party/devtools-frontend/src/front_end/entrypoints/devtools_app/devtools_app.ts
|
||||
+++ b/third_party/devtools-frontend/src/front_end/entrypoints/devtools_app/devtools_app.ts
|
||||
@@ -26,7 +26,6 @@ import '../../panels/web_audio/web_audio
|
||||
import '../../panels/webauthn/webauthn-meta.js';
|
||||
import '../../panels/layer_viewer/layer_viewer-meta.js';
|
||||
import '../../panels/recorder/recorder-meta.js';
|
||||
-import '../../panels/whats_new/whats_new-meta.js';
|
||||
|
||||
import * as Root from '../../core/root/root.js';
|
||||
import * as Main from '../main/main.js';
|
||||
--- a/third_party/devtools-frontend/src/front_end/entrypoints/main/MainImpl.ts
|
||||
+++ b/third_party/devtools-frontend/src/front_end/entrypoints/main/MainImpl.ts
|
||||
@@ -959,8 +959,10 @@ export class MainMenuItem implements UI.
|
||||
}, {jslogContext: id});
|
||||
}
|
||||
|
||||
+ /*
|
||||
const helpSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.help), false, 'help');
|
||||
helpSubMenu.appendItemsAtLocation('mainMenuHelp');
|
||||
+ */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ helium/settings/remove-autofill.patch
|
||||
helium/settings/fix-page-names.patch
|
||||
helium/settings/disable-safety-hub-page.patch
|
||||
helium/settings/remove-results-help-link.patch
|
||||
helium/settings/remove-about-page-easter-egg.patch
|
||||
|
||||
helium/hop/setup.patch
|
||||
helium/hop/disable-password-manager.patch
|
||||
@@ -183,3 +184,7 @@ helium/ui/improve-toast.patch
|
||||
helium/ui/square-interstitial-buttons.patch
|
||||
helium/ui/remove-reading-list-from-app-menu.patch
|
||||
helium/ui/center-window-on-launch.patch
|
||||
helium/ui/remove-devtools-annoyances.patch
|
||||
helium/ui/bookmarks-bar-padding.patch
|
||||
helium/ui/profile-picker-cleanup.patch
|
||||
helium/ui/disable-tab-group-editor-footer.patch
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_179_610)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M256 79.7288C256 76.6897 256.001 73.6504 255.983 70.611C255.967 68.0507 255.938 65.491 255.868 62.932C255.718 57.3544 255.389 51.7289 254.397 46.2134C253.391 40.6184 251.748 35.4111 249.159 30.3275C246.614 25.3309 243.29 20.7586 239.323 16.7947C235.357 12.8307 230.784 9.50832 225.785 6.96479C220.696 4.37529 215.483 2.73304 209.882 1.72737C204.366 0.736929 198.739 0.408542 193.161 0.257863C190.601 0.188582 188.04 0.159378 185.478 0.143533C182.437 0.124893 179.396 0.126446 176.355 0.126446L141.048 0H114.64L79.9568 0.126446C76.91 0.126446 73.8632 0.124893 70.8164 0.143533C68.2496 0.159378 65.684 0.188582 63.1181 0.257863C57.5275 0.408542 51.8878 0.73724 46.3586 1.72893C40.75 2.73428 35.5294 4.37591 30.4336 6.96355C25.4246 9.50738 20.8412 12.8301 16.867 16.7947C12.8934 20.7583 9.56265 25.3296 7.01292 30.3253C4.4169 35.4114 2.77093 40.6218 1.76247 46.2199C0.769548 51.7333 0.44054 57.3568 0.289241 62.932C0.22027 65.4913 0.190445 68.051 0.174911 70.611C0.156271 73.6507 0 77.4264 0 80.4657L0.000932032 114.668L0 141.359L0.157824 176.288C0.157824 179.331 0.156581 182.375 0.174911 185.418C0.190445 187.982 0.22027 190.545 0.289551 193.108C0.44054 198.693 0.770169 204.326 1.76403 209.849C2.77217 215.451 4.41783 220.666 7.01168 225.756C9.56172 230.76 12.8931 235.338 16.867 239.308C20.8409 243.277 25.423 246.604 30.4312 249.151C35.53 251.744 40.7531 253.389 46.3652 254.396C51.8918 255.388 57.5297 255.717 63.1181 255.867C65.684 255.937 68.2499 255.966 70.8167 255.982C73.8635 256 76.91 255.999 79.9568 255.999L114.953 256H141.427L176.355 255.999C179.396 255.999 182.437 256 185.478 255.982C188.04 255.966 190.601 255.937 193.161 255.867C198.741 255.716 204.37 255.387 209.889 254.394C215.486 253.388 220.697 251.744 225.783 249.152C230.782 246.605 235.357 243.278 239.323 239.308C243.289 235.339 246.613 230.761 249.158 225.759C251.749 220.666 253.392 215.449 254.398 209.843C255.389 204.322 255.718 198.69 255.869 193.108C255.938 190.545 255.967 187.982 255.983 185.418C256.002 182.375 256 179.331 256 176.288C256 176.288 255.998 141.975 255.998 141.359V114.64C255.998 114.185 256 79.7288 256 79.7288" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M256 79.7288C256 76.6897 256.001 73.6504 255.983 70.611C255.967 68.0507 255.938 65.491 255.868 62.932C255.718 57.3544 255.389 51.7289 254.397 46.2134C253.391 40.6184 251.748 35.4111 249.159 30.3275C246.614 25.3309 243.29 20.7586 239.323 16.7947C235.357 12.8307 230.784 9.50832 225.785 6.96479C220.696 4.37529 215.483 2.73304 209.882 1.72737C204.366 0.736929 198.739 0.408542 193.161 0.257863C190.601 0.188582 188.04 0.159378 185.478 0.143533C182.437 0.124893 179.396 0.126446 176.355 0.126446L141.048 0H114.64L79.9568 0.126446C76.91 0.126446 73.8632 0.124893 70.8164 0.143533C68.2496 0.159378 65.684 0.188582 63.1181 0.257863C57.5275 0.408542 51.8878 0.73724 46.3586 1.72893C40.75 2.73428 35.5294 4.37591 30.4336 6.96355C25.4246 9.50738 20.8412 12.8301 16.867 16.7947C12.8934 20.7583 9.56265 25.3296 7.01292 30.3253C4.4169 35.4114 2.77093 40.6218 1.76247 46.2199C0.769548 51.7333 0.44054 57.3568 0.289241 62.932C0.22027 65.4913 0.190445 68.051 0.174911 70.611C0.156271 73.6507 0 77.4264 0 80.4657L0.000932032 114.668L0 141.359L0.157824 176.288C0.157824 179.331 0.156581 182.375 0.174911 185.418C0.190445 187.982 0.22027 190.545 0.289551 193.108C0.44054 198.693 0.770169 204.326 1.76403 209.849C2.77217 215.451 4.41783 220.666 7.01168 225.756C9.56172 230.76 12.8931 235.338 16.867 239.308C20.8409 243.277 25.423 246.604 30.4312 249.151C35.53 251.744 40.7531 253.389 46.3652 254.396C51.8918 255.388 57.5297 255.717 63.1181 255.867C65.684 255.937 68.2499 255.966 70.8167 255.982C73.8635 256 76.91 255.999 79.9568 255.999L114.953 256H141.427L176.355 255.999C179.396 255.999 182.437 256 185.478 255.982C188.04 255.966 190.601 255.937 193.161 255.867C198.741 255.716 204.37 255.387 209.889 254.394C215.486 253.388 220.697 251.744 225.783 249.152C230.782 246.605 235.357 243.278 239.323 239.308C243.289 235.339 246.613 230.761 249.158 225.759C251.749 220.666 253.392 215.449 254.398 209.843C255.389 204.322 255.718 198.69 255.869 193.108C255.938 190.545 255.967 187.982 255.983 185.418C256.002 182.375 256 179.331 256 176.288C256 176.288 255.998 141.975 255.998 141.359V114.64C255.998 114.185 256 79.7288 256 79.7288" fill="#5566B1"/>
|
||||
<path d="M122.494 51.4321C122.494 48.6035 124.787 46.3105 127.615 46.3105C130.444 46.3105 132.737 48.6035 132.737 51.4321V203.797C132.737 206.625 130.444 208.918 127.615 208.918C124.787 208.918 122.494 206.625 122.494 203.797V51.4321Z" fill="white"/>
|
||||
<path d="M56.1722 63.3416C54.1722 61.3415 54.1722 58.0987 56.1722 56.0987C58.1723 54.0986 61.4151 54.0986 63.4151 56.0987L199.899 192.582C201.899 194.582 201.899 197.825 199.899 199.825C197.899 201.825 194.656 201.825 192.656 199.825L56.1722 63.3416Z" fill="white"/>
|
||||
<path d="M192.655 56.0982C194.655 54.0981 197.898 54.0981 199.898 56.0982C201.898 58.0983 201.898 61.341 199.898 63.3411L63.4148 199.825C61.4147 201.825 58.172 201.825 56.1719 199.825C54.1718 197.824 54.1718 194.582 56.1719 192.582L192.655 56.0982Z" fill="white"/>
|
||||
<path d="M204.182 122.876C207.01 122.876 209.303 125.169 209.303 127.998C209.303 130.826 207.01 133.119 204.182 133.119L51.8168 133.119C48.9883 133.119 46.6953 130.826 46.6953 127.998C46.6953 125.169 48.9883 122.876 51.8168 122.876H204.182Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_179_610">
|
||||
<rect width="256" height="256" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@@ -53,3 +53,5 @@ branding/product_icon/256x256.png chrome/app/theme/chromium/linux/product_logo_2
|
||||
|
||||
branding/product_icon/16x16.png chrome/app/theme/default_100_percent/chromium/linux/product_logo_16.png
|
||||
branding/product_icon/32x32.png chrome/app/theme/default_100_percent/chromium/linux/product_logo_32.png
|
||||
|
||||
branding/product_logo.svg chrome/app/theme/chromium/product_logo.svg
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2
|
||||
5
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2025 The Helium Authors
|
||||
# You can use, redistribute, and/or modify this source code under
|
||||
# the terms of the GPL-3.0 license that can be found in the LICENSE file.
|
||||
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import tarfile
|
||||
import asyncio
|
||||
import os
|
||||
import re
|
||||
|
||||
REPLACEMENT_REGEXES_STR = [
|
||||
# stuff we don't want to replace
|
||||
(r'(\w+) Root Program', r'\1_unreplace Root Program'),
|
||||
(r'(\w+) Web( S|s)tore', r'\1_unreplace Web Store'),
|
||||
(r'(\w+) Remote Desktop', r'\1_unreplace Remote Desktop'),
|
||||
(r'("BEGIN_LINK_CHROMIUM")(.*?Chromium)(.*?<ph name="END_LINK_CHROMIUM")', r'\1\2_unreplace\3'),
|
||||
|
||||
# main replacement(s)
|
||||
(r'(?:Google )?Chrom(e|ium)(?!\w)', r'Helium'),
|
||||
|
||||
# post-replacement cleanup
|
||||
(r'((?:Google )?Chrom(e|ium))_unreplace', r'\1'),
|
||||
(r'_unreplace', r'')
|
||||
]
|
||||
|
||||
REPLACEMENT_REGEXES = list(
|
||||
map(
|
||||
lambda line: (re.compile(line[0]), line[1]),
|
||||
REPLACEMENT_REGEXES_STR
|
||||
)
|
||||
)
|
||||
|
||||
def replace(str):
|
||||
for regex, replacement in REPLACEMENT_REGEXES:
|
||||
str = re.sub(regex, replacement, str)
|
||||
return str
|
||||
|
||||
def replacement_sanity():
|
||||
before_after = [
|
||||
('Chrome Root Program', 'Chrome Root Program'),
|
||||
('Chrome Web Store', 'Chrome Web Store'),
|
||||
('Chromium Web Store', 'Chromium Web Store'),
|
||||
('Chrome Remote Desktop', 'Chrome Remote Desktop'),
|
||||
('Google Chrome', 'Helium'),
|
||||
('Chrome Google Chrome Chrome Chromium', 'Helium Helium Helium Helium'),
|
||||
('Chrome', 'Helium'),
|
||||
('Chromium', 'Helium'),
|
||||
]
|
||||
|
||||
for a, b in before_after:
|
||||
assert(replace(a) == b)
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument('--sub', action='store_true')
|
||||
group.add_argument('--unsub', action='store_true')
|
||||
parser.add_argument('--backup-path', metavar='<tarball-path>', type=Path)
|
||||
parser.add_argument('-t', metavar='source_tree', type=Path, required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.unsub and not args.backup_path:
|
||||
raise Exception("backup_path is missing, but unsub was specified")
|
||||
|
||||
return args
|
||||
|
||||
def get_substitutable_files(tree):
|
||||
out = tree / 'out'
|
||||
|
||||
for root, _, files in os.walk(tree):
|
||||
root = Path(root)
|
||||
if out in root.parents:
|
||||
continue
|
||||
|
||||
yield from map(
|
||||
lambda filename: root / filename,
|
||||
filter(
|
||||
lambda filename: not filename.startswith('.') and (
|
||||
filename.endswith('.xtb') or filename.endswith('.grd') or filename.endswith('.grdp')
|
||||
),
|
||||
files
|
||||
)
|
||||
)
|
||||
|
||||
async def substitute_file(tree, path, tarball = None):
|
||||
arcname = str(path.relative_to(tree))
|
||||
text = None
|
||||
|
||||
with open(path, 'r') as f:
|
||||
text = f.read()
|
||||
|
||||
replaced = replace(text)
|
||||
if text != replaced:
|
||||
print(f"Replaced strings in {arcname}")
|
||||
if tarball:
|
||||
tarball.add(path, arcname=arcname, recursive=False)
|
||||
with open(path, 'w') as f:
|
||||
f.write(replaced)
|
||||
|
||||
def do_unsubstitution(tree, tarpath):
|
||||
with tarfile.open(str(tarpath), 'r:gz') as tar:
|
||||
tar.extractall(path=tree, filter='fully_trusted')
|
||||
tarpath.unlink()
|
||||
|
||||
async def do_substitution(tree, tarpath):
|
||||
with tarfile.open(str(tarpath), 'w:gz') if tarpath else open(os.devnull, 'w') as cache_tar:
|
||||
pending_substitutions = map(
|
||||
lambda path: substitute_file(tree, path, cache_tar if tarpath else None),
|
||||
get_substitutable_files(tree)
|
||||
)
|
||||
await asyncio.gather(*pending_substitutions)
|
||||
|
||||
async def main():
|
||||
replacement_sanity()
|
||||
args = parse_args()
|
||||
|
||||
if not (args.t / "OWNERS").exists():
|
||||
raise Exception("wrong src directory")
|
||||
|
||||
if args.sub:
|
||||
if args.backup_path is not None and args.backup_path.exists():
|
||||
raise Exception("unsub tarball already exists, aborting")
|
||||
await do_substitution(args.t, args.backup_path)
|
||||
elif args.unsub and args.backup_path:
|
||||
do_unsubstitution(args.t, args.backup_path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2025 The Helium Authors
|
||||
# You can use, redistribute, and/or modify this source code under
|
||||
# the terms of the GPL-3.0 license that can be found in the LICENSE file.
|
||||
|
||||
set -e
|
||||
|
||||
ACTION="$1"
|
||||
SOURCE_DIR="$2"
|
||||
BACKUP_TAR_PATH="$3"
|
||||
|
||||
REGEXES=(
|
||||
# stuff we don't want to replace
|
||||
's/(\w+) Root Program/\1_unreplace Root Program/g'
|
||||
's/(\w+) Web( S|s)tore/\1_unreplace Web Store/g'
|
||||
's/(\w+) Remote Desktop/\1_unreplace Remote Desktop/g'
|
||||
's/("BEGIN_LINK_CHROMIUM")(.*?Chromium)(.*?<ph name="END_LINK_CHROMIUM")/\1\2_unreplace\3/g'
|
||||
|
||||
# main replacement(s)
|
||||
's/(?:Google )?Chrom(e|ium)(?!\w)/Helium/g'
|
||||
|
||||
# post-replacement cleanup
|
||||
's/((?:Google )?Chrom(e|ium))_unreplace/\1/g'
|
||||
's/_unreplace//g'
|
||||
)
|
||||
|
||||
REGEX_CHAIN=$(IFS=';'; echo "${REGEXES[*]}")
|
||||
|
||||
sanity_check() {
|
||||
if ! [ -f OWNERS ]; then
|
||||
echo "wrong src directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_sub() {
|
||||
if [ "$BACKUP_TAR_PATH" != "" ] && [ -f "$BACKUP_TAR_PATH" ]; then
|
||||
echo "$(basename "$BACKUP_TAR_PATH") exists -- name substitution has already been done." >&2
|
||||
echo "if you are really sure you wanna do this, delete it" >&2
|
||||
exit 1
|
||||
elif [ "$BACKUP_TAR_PATH" != "" ]; then
|
||||
BACKUP_TAR_PATH=$(greadlink -f "$BACKUP_TAR_PATH")
|
||||
fi
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*) SED_CMD=gsed;;
|
||||
*) SED_CMD=sed;;
|
||||
esac
|
||||
|
||||
cd "$SOURCE_DIR" && sanity_check
|
||||
|
||||
FILE_LIST="$(find . -type f -not -path '*/.*' -not -path '*/out/*' -name '*.grd*' -o -name '*.xtb')"
|
||||
|
||||
if [ "$BACKUP_TAR_PATH" != "" ]; then
|
||||
echo "$FILE_LIST" \
|
||||
| xargs tar cvf "$BACKUP_TAR_PATH" >/dev/null 2>/dev/null
|
||||
fi
|
||||
|
||||
while IFS= read -r file_path; do
|
||||
if [[ $file_path == ./out/* ]] || [[ $file_path == *.new ]]; then
|
||||
continue;
|
||||
fi
|
||||
|
||||
if [ "$DEBUG" = 1 ]; then
|
||||
cp "$file_path" "$file_path.new"
|
||||
perl -pi -e "$REGEX_CHAIN" "$file_path.new"
|
||||
diff -Naur "$file_path" "$file_path.new" || true
|
||||
mv "$file_path.new" "$file_path"
|
||||
else
|
||||
perl -pi -e "$REGEX_CHAIN" "$file_path" &
|
||||
fi
|
||||
done <<< "$FILE_LIST"
|
||||
|
||||
wait
|
||||
}
|
||||
|
||||
do_unsub() {
|
||||
if [ "$BACKUP_TAR_PATH" = "" ] && ! [ -f "$BACKUP_TAR_PATH" ]; then
|
||||
echo "BACKUP_TAR_PATH missing or file does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BACKUP_TAR_PATH=$(greadlink -f "$BACKUP_TAR_PATH")
|
||||
cd "$SOURCE_DIR" && sanity_check
|
||||
tar xvf "$BACKUP_TAR_PATH"
|
||||
rm "$BACKUP_TAR_PATH"
|
||||
}
|
||||
|
||||
do_str() {
|
||||
perl -pe "$REGEX_CHAIN" <<< "$1"
|
||||
}
|
||||
|
||||
case $ACTION in
|
||||
sub) do_sub;;
|
||||
unsub) do_unsub;;
|
||||
str) do_str "$2";;
|
||||
*) echo "usage: $0 <sub | unsub> source_dir [backup_tarball_path]" >&2
|
||||
exit 1
|
||||
esac
|
||||
Reference in New Issue
Block a user