跳过 Firefox 可选主题包冲突

main
wangqiyang 3 days ago
parent 49090536c7
commit bdb33b94e7

@ -46,6 +46,10 @@ var forbiddenFirefoxDebPackages = map[string]struct{}{
"util-linux": {}, "util-linux": {},
} }
var optionalFirefoxDebPackages = map[string]string{
"lubuntu-icon-theme": "theme package may conflict with existing adwaita-icon-theme-full and is not required by Firefox",
}
type firefoxBundleInstallPlan struct { type firefoxBundleInstallPlan struct {
TotalPackageCount int TotalPackageCount int
HasFirefoxPackage bool HasFirefoxPackage bool
@ -94,6 +98,8 @@ func installFirefox() error {
return err return err
} }
baseSystemPackages := strings.Join(plan.BaseSystemPackages, " ") baseSystemPackages := strings.Join(plan.BaseSystemPackages, " ")
optionalSkipPackages := strings.Join(optionalFirefoxDebPackageNames(), " ")
kioskInfof("firefox install package filter baseSystemPackages=%q optionalSkipPackages=%q", baseSystemPackages, optionalSkipPackages)
var p struct { var p struct {
DebPkgPath string `json:"DebPkgPath"` DebPkgPath string `json:"DebPkgPath"`
@ -129,9 +135,11 @@ echo ""
echo "3. filter Firefox deb packages..." echo "3. filter Firefox deb packages..."
base_system_packages=%s base_system_packages=%s
optional_skip_packages=%s
mkdir -p /opt/firefox-installable mkdir -p /opt/firefox-installable
selected_count=0 selected_count=0
skipped_installed_count=0 skipped_installed_count=0
skipped_optional_count=0
selected_missing_base_count=0 selected_missing_base_count=0
selected_regular_count=0 selected_regular_count=0
firefox_selected=0 firefox_selected=0
@ -170,6 +178,14 @@ for deb in /opt/firefox-deb/*.deb; do
continue continue
fi fi
case " $optional_skip_packages " in
*" $pkg "*)
echo "skip optional package: $file package=$pkg"
skipped_optional_count=$((skipped_optional_count + 1))
continue
;;
esac
case " $base_system_packages " in case " $base_system_packages " in
*" $pkg "*) *" $pkg "*)
if [ "$installed" -eq 1 ]; then if [ "$installed" -eq 1 ]; then
@ -193,7 +209,7 @@ for deb in /opt/firefox-deb/*.deb; do
select_deb select_deb
selected_regular_count=$((selected_regular_count + 1)) selected_regular_count=$((selected_regular_count + 1))
done done
echo "selected packages: $selected_count, selected missing base: $selected_missing_base_count, selected regular: $selected_regular_count, skipped installed: $skipped_installed_count" echo "selected packages: $selected_count, selected missing base: $selected_missing_base_count, selected regular: $selected_regular_count, skipped installed: $skipped_installed_count, skipped optional: $skipped_optional_count"
if [ "$selected_count" -eq 0 ]; then if [ "$selected_count" -eq 0 ]; then
echo "error: no packages selected for install" echo "error: no packages selected for install"
exit 1 exit 1
@ -205,7 +221,12 @@ fi
echo "" echo ""
echo "4. install selected Firefox packages..." echo "4. install selected Firefox packages..."
cd /opt/firefox-installable && sudo dpkg -i ./*.deb || { echo "error: install selected Firefox deb packages failed"; exit 1; } cd /opt/firefox-installable || { echo "error: enter installable package directory failed"; exit 1; }
install_status=0
sudo dpkg -i ./*.deb || install_status=$?
if [ "$install_status" -ne 0 ]; then
echo "warning: selected Firefox deb package install returned status $install_status, verify Firefox next"
fi
echo "" echo ""
echo "5. verify Firefox..." echo "5. verify Firefox..."
@ -213,7 +234,7 @@ firefox --version || { echo "error: Firefox verification failed"; exit 1; }
echo "" echo ""
echo "=== Firefox install complete ===" echo "=== Firefox install complete ==="
`, shellQuote(bundlePath), shellQuote(baseSystemPackages))) `, shellQuote(bundlePath), shellQuote(baseSystemPackages), shellQuote(optionalSkipPackages)))
command.Stdout = os.Stdout command.Stdout = os.Stdout
command.Stderr = os.Stderr command.Stderr = os.Stderr
@ -351,6 +372,15 @@ func unsafeFirefoxDebPackages(packages []string) []string {
return blocked return blocked
} }
func optionalFirefoxDebPackageNames() []string {
names := make([]string, 0, len(optionalFirefoxDebPackages))
for name := range optionalFirefoxDebPackages {
names = append(names, name)
}
sort.Strings(names)
return names
}
func shellQuote(value string) string { func shellQuote(value string) string {
return "'" + strings.ReplaceAll(value, "'", "'\\''") + "'" return "'" + strings.ReplaceAll(value, "'", "'\\''") + "'"
} }

@ -58,6 +58,14 @@ func TestFirefoxBundleInstallPlanDetectsBasePackages(t *testing.T) {
} }
} }
func TestOptionalFirefoxDebPackageNames(t *testing.T) {
got := optionalFirefoxDebPackageNames()
want := []string{"lubuntu-icon-theme"}
if !stringSlicesEqual(got, want) {
t.Fatalf("optionalFirefoxDebPackageNames() = %v, want %v", got, want)
}
}
func stringSlicesEqual(left []string, right []string) bool { func stringSlicesEqual(left []string, right []string) bool {
if len(left) != len(right) { if len(left) != len(right) {
return false return false

Loading…
Cancel
Save