Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mozilla mirror, testing is in progress #91

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/zh/mozilla.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
mirrorId: mozilla
---

import MozillaConfigGenerator from '../../src/components/mozilla-config-generator'

> mozilla 镜像目前正在测试中,行为可能不稳定,预计将在9月下旬完成测试。当下,不建议在生产环境下使用此镜像。

此仓库为基于 Debian 的发行版提供了官方打包的 FireFox 浏览器,支持 amd64、arm64 架构。

目前,Debian 稳定版只包含了长期支持版本 `firefox-esr`,而 Ubuntu 的 FireFox 切换到了 Snap 包。有需要的用户可使用本仓库提供的 APT 源。

### 使用方法

下面的内容修改自 [Install Firefox on Linux](https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-distributions)。

首先,导入和检查 keyring:

```bash
sudo install -d -m 0755 /etc/apt/keyrings
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null
gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc | awk '/pub/{getline; gsub(/^ +| +$/,""); if($0 == "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3") print "\nThe key fingerprint matches ("$0").\n"; else print "\nVerification failed: the fingerprint ("$0") does not match the expected one.\n"}'
```

#### APT 配置

<MozillaConfigGenerator ubuntuVariant="ubuntu" />

如有需要,在 `/etc/apt/preferences.d/mozilla` 配置 APT 优先级:

```properties
Package: *
Pin: release a=mozilla
Pin-Priority: 1000
```

最后,更新 APT 缓存并安装:

```bash
sudo apt update && sudo apt install firefox
sudo apt install firefox-l10n-zh-cn # 可选:中文语言包
```
106 changes: 106 additions & 0 deletions src/components/mozilla-config-generator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import React, { useState } from 'react';
import {
FormControl,
InputLabel,
Select,
MenuItem,
Box,
Grid,
Typography,
FormControlLabel,
Switch,
FormGroup,
} from '@mui/material';
import { Trans } from 'gatsby-plugin-react-i18next';
import CodeBlock from './code-block';

type ArchTypes = "amd64" | "arm64";

const configGenOld = (
arch: ArchTypes,
): string => `deb [arch=${arch} signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://mirrors.zju.edu.cn/mozilla/apt mozilla main`;

const configGenNew = (
arch: ArchTypes,
) => `
Types: deb
URIs: https://mirrors.zju.edu.cn/mozilla/apt
Suites: mozilla
Components: main
Signed-By: /etc/apt/keyrings/packages.mozilla.org.asc
Architectures: ${arch}
`;

export default () => {
const [enableDeb822, setEnableDeb822] = useState(false);

type ArchTypes = "amd64" | "arm64";
const [arch, setArch] = useState("amd64" as ArchTypes);

return (
<Box>
<Grid
container
direction="row"
justifyContent="flex-start"
alignItems="flex-end"
>
<Grid item sx={{ mb: 1 }}>
<Typography component="p">请选择您的系统架构:</Typography>
</Grid>
<Grid item>
<FormControl variant="standard" sx={{ m: 1, minWidth: 120 }}>
<InputLabel id="simple-select-helper-label">
<Trans>系统架构</Trans>
</InputLabel>
<Select
labelId="simple-select-helper-label"
id="simple-select-helper"
label="Age"
onChange={event => {
setArch(event.target.value as ArchTypes);
}}
defaultValue={arch}
>
{Array<ArchTypes>("amd64", "arm64")
.map((v: ArchTypes) => {
return (
<MenuItem key={v} value={v}>
{v}
</MenuItem>
);
})}
</Select>
</FormControl>
</Grid>
</Grid>
<FormGroup>
<FormControlLabel
control={
<Switch
checked={enableDeb822}
onChange={e => setEnableDeb822(e.target.checked)}
/>
}
label="使用 DEB822 格式"
/>
</FormGroup>
<Grid container direction="column" my={2}>
<Grid container direction="row">
<Typography>请在</Typography>
<code
style={{ margin: "0 0.5rem", fontWeight: 400, color: "rgb(156, 39, 176)" }}
>
{enableDeb822
? "/etc/apt/sources.list.d/mozilla.sources"
: "/etc/apt/sources.list.d/mozilla.list"}
</code>
<Typography>添加 APT 源:</Typography>
</Grid>
</Grid>
<CodeBlock language="bash">
{enableDeb822 ? configGenNew(arch) : configGenOld(arch)}
</CodeBlock>
</Box>
);
};
3 changes: 3 additions & 0 deletions src/utils/title-mirror-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import debianIcon from '@iconify/icons-simple-icons/debian';
import deepinIcon from '@iconify/icons-simple-icons/deepin';
import dockerIcon from '@iconify/icons-simple-icons/docker';
import fedoraIcon from '@iconify/icons-simple-icons/fedora';
import firefoxIcon from '@iconify/icons-simple-icons/firefox';
import gentooIcon from '@iconify/icons-simple-icons/gentoo';
import gnuIcon from '@iconify/icons-simple-icons/gnu';
import gnuEmacsIcon from '@iconify/icons-simple-icons/gnuemacs';
Expand Down Expand Up @@ -87,6 +88,8 @@ export default function TitleMirrorIcon(
return <Icon height={size} icon={llvmIcon} color={color} />;
case 'manjaro':
return <Icon height={size} icon={manjaroIcon} color={color} />;
case 'mozilla':
return <Icon height={size} icon={firefoxIcon} color={color} />;
case 'npm':
return <Icon height={size} icon={npmIcon} color={color} />;
case 'opensuse':
Expand Down
Loading