firefox: final changes to fix trisquel's search engine icons.

This commit is contained in:
Luis Guzmán 2024-12-27 17:08:04 +00:00
parent d41388e84b
commit fcdc3464a6
2 changed files with 81 additions and 10 deletions

View file

@ -0,0 +1,64 @@
#! /usr/bin/python3
#
# Script to add trisquel's icons on search engine options.
#
# Copyright (C) 2024 Luis Guzmán <ark@switnet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# File path
moz_build_path = "services/settings/dumps/main/moz.build"
# New entries to add
new_entries = [
"search-config-icons/b99ed276-9557-4492-8bbb-d59826381893",
"search-config-icons/b99ed276-9557-4492-8bbb-d59826381893.meta.json",
"search-config-icons/b5fd21a8-e369-477f-a3f2-b47a370f9030",
"search-config-icons/b5fd21a8-e369-477f-a3f2-b47a370f9030.meta.json",
]
# Read the moz.build file
with open(moz_build_path, "r") as file:
lines = file.readlines()
# Locate the section for `search-config-icons`
start_idx = None
for idx, line in enumerate(lines):
if "FINAL_TARGET_FILES.defaults.settings.main[\"search-config-icons\"] += [" in line:
start_idx = idx
break
if start_idx is None:
raise RuntimeError("Could not find the 'search-config-icons' section in moz.build")
# Extract existing entries
start_idx += 1
end_idx = start_idx
while end_idx < len(lines) and lines[end_idx].strip() != "]":
end_idx += 1
current_entries = [line.strip().strip(",") for line in lines[start_idx:end_idx]]
# Combine and sort all entries
all_entries = sorted(set(current_entries + [f'"{entry}"' for entry in new_entries]))
# Replace the section in moz.build
lines[start_idx:end_idx] = [f" {entry},\n" for entry in all_entries]
# Write the updated content back to the file
with open(moz_build_path, "w") as file:
file.writelines(lines)
print("> Added trisquel's search engine icons to 'moz.build'")

View file

@ -19,7 +19,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
VERSION=118
VERSION=119
EXTERNAL='deb-src http://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu $UPSTREAM main'
REPOKEY=9BDB3D89CE49EC21
@ -182,15 +182,22 @@ cp $DATA/newtab/*.png browser/components/newtab/data/content/tippytop/images/
/bin/sed "/\"data\": \[/ r $DATA/searchplugins/trisquel-v2.json" -i ./services/settings/dumps/main/search-config-v2.json
/bin/sed "/\"data\": \[/ r $DATA/searchplugins/trisquel-packages-v2.json" -i ./services/settings/dumps/main/search-config-v2.json
# Setup trisquel's searchengine icons
ICONS_FOLDER="services/settings/dumps/main/search-config-icons"
for id in \
"b99ed276-9557-4492-8bbb-d59826381893" \
"b5fd21a8-e369-477f-a3f2-b47a370f9030"
do
## customize id value
echo "$id" | grep -q "b99ed276" && json_name="trisquel.json"
echo "$id" | grep -q "b5fd21a8" && json_name="trisquel-packages.json"
## copy icons and json definitons.
cp $DATA/trisquel-search-icons/b99ed276-9557-4492-8bbb-d59826381893.png \
services/settings/dumps/main/search-config-icons/b99ed276-9557-4492-8bbb-d59826381893
cp $DATA/trisquel-search-icons/b99ed276-trisquel.json \
services/settings/dumps/main/search-config-icons/b99ed276-9557-4492-8bbb-d59826381893.meta.json
cp $DATA/trisquel-search-icons/b5fd21a8-e369-477f-a3f2-b47a370f9030.png \
services/settings/dumps/main/search-config-icons/b5fd21a8-e369-477f-a3f2-b47a370f9030
cp $DATA/trisquel-search-icons/b5fd21a8-trisquel-packages.json \
services/settings/dumps/main/search-config-icons/b5fd21a8-e369-477f-a3f2-b47a370f9030.meta.json
cp "$DATA/trisquel-search-icons/$id.png" "$ICONS_FOLDER/$id"
cp "$DATA/trisquel-search-icons/${id:0:8}-${json_name}" "$ICONS_FOLDER/$id.meta.json"
done
## Add references to moz.build
python3 $DATA/trisquel-search-icons/update_mozbuild.py
## Set json in search-config-icons.json
jq --slurpfile newIcon1 "$DATA/trisquel-search-icons/b99ed276-trisquel.json" \
--slurpfile newIcon2 "$DATA/trisquel-search-icons/b5fd21a8-trisquel-packages.json" \
'.data += [$newIcon1[0], $newIcon2[0]]' services/settings/dumps/main/search-config-icons.json > tmp-s-c-i.json && \