✨ init(*): 初始化项目。
This commit is contained in:
commit
c4b95933f4
136 files changed
+4550
No files matched your search
@@ -0,0 +1,144 @@
|
||||
#!/bin/bash
|
||||
# Generate standalone font packages and aggregate metapackages.
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
readonly REPO_DIR
|
||||
readonly OUTPUT_DIR="${REPO_DIR}/aur-packages"
|
||||
source "${REPO_DIR}/package-data.sh"
|
||||
|
||||
# Write a dependency-only package and its SRCINFO.
|
||||
# Globals: OUTPUT_DIR, PKGVER, UPSTREAM_URL, FONT_LICENSE_URL,
|
||||
# FONT_LICENSE_SHA256.
|
||||
# Arguments: Package name, description, and dependency package names.
|
||||
# Outputs: PKGBUILD and .SRCINFO in the package directory.
|
||||
write_meta_package() {
|
||||
local package_name="$1"
|
||||
local description="$2"
|
||||
shift 2
|
||||
local package_dir="${OUTPUT_DIR}/${package_name}"
|
||||
|
||||
mkdir -p "$package_dir"
|
||||
{
|
||||
printf '# Maintainer: Shuery Shuai <[email protected]>\n\n'
|
||||
printf "pkgname='%s'\npkgver='%s'\npkgrel=1\n" "$package_name" "$PKGVER"
|
||||
printf "pkgdesc='%s'\narch=('any')\nurl='%s'\nlicense=('OFL-1.1')\n" "$description" "$UPSTREAM_URL"
|
||||
printf 'depends=(\n'
|
||||
printf " '%s'\n" "$@"
|
||||
printf ")\nconflicts=('ttf-sarasa-gothic-nerd-fonts')\n\n"
|
||||
printf "source=('LICENSE::%s')\nsha256sums=('%s')\n\n" "$FONT_LICENSE_URL" "$FONT_LICENSE_SHA256"
|
||||
printf 'package() {\n install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"\n}\n'
|
||||
} > "${package_dir}/PKGBUILD"
|
||||
(cd "$package_dir" && makepkg --printsrcinfo > .SRCINFO)
|
||||
}
|
||||
|
||||
# Generate one PKGBUILD for each style and orthography.
|
||||
# Globals: OUTPUT_DIR, PKGVER, PKGREL, UPSTREAM_URL, FONT_LICENSE_URL,
|
||||
# FONT_LICENSE_SHA256, STYLE_NAMES, ORTHOGRAPHY_NAMES, FONT_SHA256S.
|
||||
# Arguments: Style, orthography, and checksum index.
|
||||
# Outputs: PKGBUILD and .SRCINFO in the package directory.
|
||||
write_font_package() {
|
||||
local style="$1"
|
||||
local orthography="$2"
|
||||
local source_index="$3"
|
||||
local package_name package_dir archive_url description archive_sha256
|
||||
|
||||
package_name="ttf-sarasa-${style}-${orthography}-nerd-font"
|
||||
package_dir="${OUTPUT_DIR}/${package_name}"
|
||||
archive_url="${UPSTREAM_URL}/releases/download/v${PKGVER//_/-}/sarasa-${style}-${orthography}-nerd-font.zip"
|
||||
description="Sarasa Gothic Nerd Font / 更纱书呆黑体:${STYLE_NAMES[$style]};${ORTHOGRAPHY_NAMES[$orthography]}。"
|
||||
archive_sha256="${FONT_SHA256S[$source_index]}"
|
||||
|
||||
mkdir -p "$package_dir"
|
||||
{
|
||||
printf '# Maintainer: Shuery Shuai <[email protected]>\n\n'
|
||||
printf "pkgname='%s'\npkgver='%s'\npkgrel='%s'\n" "$package_name" "$PKGVER" "$PKGREL"
|
||||
printf "pkgdesc='%s'\narch=('any')\nurl='%s'\nlicense=('OFL-1.1')\n" "$description" "$UPSTREAM_URL"
|
||||
printf "provides=('ttf-font')\nconflicts=('ttf-sarasa-gothic-nerd-fonts')\n"
|
||||
printf 'source=(\n "${pkgname}.zip::%s"\n' "$archive_url"
|
||||
printf " 'LICENSE::%s'\n)\n" "$FONT_LICENSE_URL"
|
||||
printf 'noextract=("${pkgname}.zip")\nsha256sums=(\n'
|
||||
printf " '%s'\n '%s'\n)\n\n" "$archive_sha256" "$FONT_LICENSE_SHA256"
|
||||
printf 'package() {\n'
|
||||
printf ' local font_dir font_destination\n'
|
||||
printf ' font_dir=$(mktemp -d "${srcdir}/${pkgname}.XXXXXX")\n'
|
||||
printf ' font_destination="${pkgdir}/usr/share/fonts/${pkgname}"\n\n'
|
||||
printf ' bsdtar -xf "${srcdir}/${pkgname}.zip" -C "${font_dir}/"\n'
|
||||
printf ' install -d "${font_destination}"\n'
|
||||
printf ' find "${font_dir}" -maxdepth 1 -type f -name '\''*.ttf'\'' \\\n -exec install -m644 {} "${font_destination}/" \\;\n'
|
||||
printf ' rm -rf "${font_dir}"\n\n'
|
||||
printf ' install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"\n}\n'
|
||||
} > "${package_dir}/PKGBUILD"
|
||||
|
||||
(cd "$package_dir" && makepkg --printsrcinfo > .SRCINFO)
|
||||
}
|
||||
|
||||
# Generate package directories and dependency metapackages.
|
||||
main() {
|
||||
local force=false
|
||||
local source_index=0
|
||||
local style orthography package_name description
|
||||
local -a dependencies=() all_dependencies=()
|
||||
|
||||
if [[ "${1:-}" == "--force" ]]; then
|
||||
force=true
|
||||
shift
|
||||
elif (($# > 0)); then
|
||||
printf 'Usage: %s [--force]\n' "$0" >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
if [[ -d "$OUTPUT_DIR" ]] && find "$OUTPUT_DIR" -type f -name PKGBUILD -print -quit | grep -q . && ! $force; then
|
||||
printf 'Generated package files already exist; pass --force to replace them.\n' >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
for style in "${STYLES[@]}"; do
|
||||
for orthography in "${ORTHOGRAPHIES[@]}"; do
|
||||
write_font_package "$style" "$orthography" "$source_index"
|
||||
((source_index += 1))
|
||||
done
|
||||
done
|
||||
|
||||
if [[ "$source_index" -ne "${#FONT_SHA256S[@]}" ]]; then
|
||||
printf 'Expected %d font checksums, generated %d packages.\n' "${#FONT_SHA256S[@]}" "$source_index" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
for orthography in "${ORTHOGRAPHIES[@]}"; do
|
||||
dependencies=()
|
||||
for style in "${STYLES[@]}"; do
|
||||
dependencies+=("ttf-sarasa-${style}-${orthography}-nerd-font")
|
||||
done
|
||||
package_name="ttf-sarasa-${orthography}-nerd-font"
|
||||
description="Sarasa Gothic Nerd Font / 更纱书呆黑体:All Styles / 全部风格;${ORTHOGRAPHY_NAMES[$orthography]}。"
|
||||
write_meta_package "$package_name" "$description" "${dependencies[@]}"
|
||||
done
|
||||
|
||||
for style in "${STYLES[@]}"; do
|
||||
dependencies=()
|
||||
for orthography in "${ORTHOGRAPHIES[@]}"; do
|
||||
dependencies+=("ttf-sarasa-${style}-${orthography}-nerd-font")
|
||||
done
|
||||
package_name="ttf-sarasa-${style}-nerd-font"
|
||||
description="Sarasa Gothic Nerd Font / 更纱书呆黑体:${STYLE_NAMES[$style]};All Orthographies / 全部地区字形。"
|
||||
write_meta_package "$package_name" "$description" "${dependencies[@]}"
|
||||
done
|
||||
|
||||
for style in "${STYLES[@]}"; do
|
||||
for orthography in "${ORTHOGRAPHIES[@]}"; do
|
||||
all_dependencies+=("ttf-sarasa-${style}-${orthography}-nerd-font")
|
||||
done
|
||||
done
|
||||
|
||||
write_meta_package \
|
||||
ttf-sarasa-nerd-font \
|
||||
'Sarasa Gothic Nerd Fonts / 更纱书呆黑体:All styles and orthographies / 全部风格与地区字形。' \
|
||||
"${all_dependencies[@]}"
|
||||
|
||||
printf 'Generated 48 single-font packages and 15 aggregate packages in %s\n' "$OUTPUT_DIR"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in new issue
Block a user