Merge branch 'hykilpikonna:master' into master

This commit is contained in:
Harvey 2024-05-13 10:41:09 -05:00 committed by GitHub
commit 22c8d76193
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 691 additions and 110 deletions

1
.gitignore vendored
View file

@ -120,3 +120,4 @@ webhook-log
start_moderation.sh start_moderation.sh
gh_moderator.toml gh_moderator.toml
moderator-data moderator-data
hyfetch/git

View file

@ -10,7 +10,7 @@ This repo also serves as an updated version of the original `neofetch` since the
* Method 1: `pip install -U hyfetch` then run `neowofetch` * Method 1: `pip install -U hyfetch` then run `neowofetch`
* Method 2: `npx neowofetch` * Method 2: `npx neowofetch`
* Method 3: `P="$HOME/.local/bin/neowofetch" curl -L nf.hydev.org -o $P && chmod +x $P` * Method 3: `P="$HOME/.local/bin/neowofetch" && curl -L nf.hydev.org -o "$P" && chmod +x "$P"`
* Method 4: Run without install `bash <(curl -sL nf.hydev.org)` * Method 4: Run without install `bash <(curl -sL nf.hydev.org)`
@ -32,6 +32,7 @@ Currently, these distributions have existing packages for HyFetch:
* Universal [Lure.sh](https://lure.sh/): `lure in hyfetch` (Thanks to [@Elara6331](https://github.com/Elara6331)) * Universal [Lure.sh](https://lure.sh/): `lure in hyfetch` (Thanks to [@Elara6331](https://github.com/Elara6331))
* Arch Linux: `sudo pacman -S hyfetch` (Thanks to [@Aleksana](https://github.com/Aleksanaa) and [@Antiz96](https://github.com/Antiz96)) * Arch Linux: `sudo pacman -S hyfetch` (Thanks to [@Aleksana](https://github.com/Aleksanaa) and [@Antiz96](https://github.com/Antiz96))
* Fedora Linux: `sudo dnf install hyfetch` (packaged by [@topazus](http://github.com/topazus))
* Nix: `nix-env -i hyfetch` (Thanks to [@YisuiDenghua](https://github.com/YisuiDenghua)) * Nix: `nix-env -i hyfetch` (Thanks to [@YisuiDenghua](https://github.com/YisuiDenghua))
* Nix Profile: `nix profile install nixpkgs#hyfetch` * Nix Profile: `nix profile install nixpkgs#hyfetch`
* Guix: `guix install hyfetch` (Thanks to [@WammKD](https://github.com/WammKD)) * Guix: `guix install hyfetch` (Thanks to [@WammKD](https://github.com/WammKD))
@ -39,7 +40,7 @@ Currently, these distributions have existing packages for HyFetch:
* Homebrew: `brew install hyfetch` (Thanks to [@BKasin](https://github.com/BKasin) and [@osalbahr](https://github.com/osalbahr)) * Homebrew: `brew install hyfetch` (Thanks to [@BKasin](https://github.com/BKasin) and [@osalbahr](https://github.com/osalbahr))
* openSUSE Tumbleweed: `zypper in python311-hyfetch` (Thanks to [@BKasin](https://github.com/BKasin)) * openSUSE Tumbleweed: `zypper in python311-hyfetch` (Thanks to [@BKasin](https://github.com/BKasin))
* Gentoo: `emerge --ask app-misc/hyfetch` (Thanks to [@BKasin](https://github.com/BKasin)) * Gentoo: `emerge --ask app-misc/hyfetch` (Thanks to [@BKasin](https://github.com/BKasin))
* Debian `apt install hyfetch` (for Debian flavor >= [Trixie](https://packages.debian.org/trixie/hyfetch)) * Debian and Ubuntu `apt install hyfetch` (for Debian flavor >= [Trixie](https://packages.debian.org/trixie/hyfetch), Ubuntu flavor >= [Noble](https://packages.ubuntu.com/noble/hyfetch)) (Thanks to [@BKasin](https://github.com/BKasin))
[![Packaging status](https://repology.org/badge/vertical-allrepos/hyfetch.svg?columns=4&exclude_unsupported=1)](https://repology.org/project/hyfetch/versions) [![Packaging status](https://repology.org/badge/vertical-allrepos/hyfetch.svg?columns=4&exclude_unsupported=1)](https://repology.org/project/hyfetch/versions)

View file

@ -327,7 +327,7 @@ Container Linux by CoreOS, CRUX, Crystal Linux, Cucumber,
CutefishOS, CuteOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin, CutefishOS, CuteOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin,
DesaOS, Devuan, DietPi, digital UNIX, DracOS, DragonFly, Drauger, DesaOS, Devuan, DietPi, digital UNIX, DracOS, DragonFly, Drauger,
Droidian, Elementary, Elive, EncryptOS, EndeavourOS, Endless, Enso, Droidian, Elementary, Elive, EncryptOS, EndeavourOS, Endless, Enso,
EuroLinux, EvolutionOS, Exherbo, Exodia Predator OS, Fedora, EuroLinux, EvolutionOS, eweOS, Exherbo, Exodia Predator OS, Fedora,
FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeMiNT, Frugalware, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeMiNT, Frugalware,
Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense, Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense,
GNOME, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HamoniKR, GNOME, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HamoniKR,

View file

@ -1 +1 @@
VERSION = '1.4.11' VERSION = '1.5.0alpha1'

View file

@ -31,6 +31,7 @@ IS_WINDOWS = platform.system() == 'Windows'
CACHE_PATH = Path(os.getenv("LOCALAPPDATA") or os.getenv("XDG_CACHE_HOME") or Path.home() / '.cache') / 'hyfetch' CACHE_PATH = Path(os.getenv("LOCALAPPDATA") or os.getenv("XDG_CACHE_HOME") or Path.home() / '.cache') / 'hyfetch'
@dataclass @dataclass
class GlobalConfig: class GlobalConfig:
# Global color mode default to 8-bit for compatibility # Global color mode default to 8-bit for compatibility
@ -49,6 +50,4 @@ class GlobalConfig:
return 0.65 if term.lower() == 'dark' else 0.4 return 0.65 if term.lower() == 'dark' else 0.4
GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False, use_overlay=False) GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False, use_overlay=True)
GIT_URL = 'https://github.com/git-for-windows/git/releases/download/v2.37.2.windows.2/Git-2.37.2.2-32-bit.tar.bz2'

View file

@ -7,23 +7,21 @@ import shlex
import shutil import shutil
import subprocess import subprocess
import sys import sys
import tarfile
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from subprocess import check_output from subprocess import check_output
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from typing import Iterable from typing import Iterable
import pkg_resources
from .color_util import color, printc from .color_util import color, printc
from .constants import GLOBAL_CFG, GIT_URL, IS_WINDOWS from .constants import GLOBAL_CFG, IS_WINDOWS
from .distros import distro_detector from .distros import distro_detector
from .presets import ColorProfile from .presets import ColorProfile
from .serializer import from_dict from .serializer import from_dict
from .types import BackendLiteral, ColorAlignMode from .types import BackendLiteral, ColorAlignMode
RE_NEOFETCH_COLOR = re.compile('\\${c[0-9]}') RE_NEOFETCH_COLOR = re.compile('\\${c[0-9]}')
SRC = Path(__file__).parent
def literal_input(prompt: str, options: Iterable[str], default: str, show_ops: bool = True) -> str: def literal_input(prompt: str, options: Iterable[str], default: str, show_ops: bool = True) -> str:
@ -197,24 +195,13 @@ def get_command_path() -> str:
:return: Command path :return: Command path
""" """
cmd_path = pkg_resources.resource_filename(__name__, 'scripts/neowofetch') cmd_path = (if_file(SRC.parent / 'neofetch') or if_file(SRC / 'scripts/neowofetch'))
# Windows doesn't support symbolic links, but also I can't detect symbolic links... hard-code it here for now. if not cmd_path:
if IS_WINDOWS: printc("&cError: Neofetch script cannot be found")
pkg = Path(__file__).parent exit(127)
pth = (shutil.which("neowofetch") or
if_file(cmd_path) or
if_file(pkg / 'scripts/neowofetch') or
if_file(pkg.parent / 'neofetch') or
if_file(Path(cmd_path).parent.parent.parent / 'neofetch'))
if not pth: return str(cmd_path)
printc("&cError: Neofetch script cannot be found")
exit(127)
return str(pth)
return cmd_path
def ensure_git_bash() -> Path: def ensure_git_bash() -> Path:
@ -223,48 +210,19 @@ def ensure_git_bash() -> Path:
:returns git bash path :returns git bash path
""" """
if IS_WINDOWS: if not IS_WINDOWS:
# Find installation in default path return Path('/usr/bin/bash')
def_path = Path(r'C:\Program Files\Git\bin\bash.exe')
if def_path.is_file():
return def_path
# Detect third-party git.exe in path # Bundled git bash
git_exe = shutil.which("bash") or shutil.which("git.exe") or shutil.which("git") git_path = (if_file(SRC / 'git/bin/bash.exe')
if git_exe is not None: or if_file("C:/Program Files/Git/bin/bash.exe")
pth = Path(git_exe).parent or if_file("C:/Program Files (x86)/Git/bin/bash.exe"))
if (pth / r'bash.exe').is_file():
return pth / r'bash.exe'
elif (pth / r'bin\bash.exe').is_file():
return pth / r'bin\bash.exe'
# Find installation in PATH (C:\Program Files\Git\cmd should be in path) if not git_path.is_file():
pth = (os.environ.get('PATH') or '').lower().split(';') printc("&cError: Git Bash installation not found")
pth = [p for p in pth if p.endswith(r'\git\cmd')] sys.exit(127)
if pth:
return Path(pth[0]).parent / r'bin\bash.exe'
# Previously downloaded portable installation return git_path
path = Path(__file__).parent / 'min_git'
portable_bash_exe = path / r'bin\bash.exe'
if path.is_dir() and portable_bash_exe.is_file():
return portable_bash_exe
# No installation found, download a portable installation
Path.mkdir(path, parents=True, exist_ok=True)
pkg_path = path / 'package.tbz'
print('Git installation not found. Git Bash is required to use HyFetch/neofetch on Windows')
if literal_input('Would you like to download and install Git into HyFetch package directory? (if no is selected colors almost certainly won\'t work)', ['yes', 'no'], 'yes', False) == 'yes':
print('Downloading a portable version of Git...')
from urllib.request import urlretrieve
urlretrieve(GIT_URL, pkg_path)
print('Download finished! Extracting...')
with tarfile.open(pkg_path, 'r:bz2') as tbz_ref:
tbz_ref.extractall(path)
print('Done!')
return portable_bash_exe
else:
sys.exit()
def check_windows_cmd(): def check_windows_cmd():
@ -272,14 +230,14 @@ def check_windows_cmd():
Check if this script is running under cmd.exe. If so, launch an external window with git bash Check if this script is running under cmd.exe. If so, launch an external window with git bash
since cmd doesn't support RGB colors. since cmd doesn't support RGB colors.
""" """
if IS_WINDOWS: # if IS_WINDOWS:
import psutil # import psutil
# TODO: This line does not correctly identify cmd prompts... # # TODO: This line does not correctly identify cmd prompts...
if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe': # if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
print("cmd.exe doesn't support RGB colors, restarting in MinTTY...") # print("cmd.exe doesn't support RGB colors, restarting in MinTTY...")
cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit' # cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit'
os.system(cmd) # os.system(cmd)
sys.exit(0) # sys.exit(0)
def run_neofetch_cmd(args: str, pipe: bool = False) -> str | None: def run_neofetch_cmd(args: str, pipe: bool = False) -> str | None:
@ -293,8 +251,7 @@ def run_neofetch_cmd(args: str, pipe: bool = False) -> str | None:
cmd = get_command_path().replace("\\", "/").replace("C:/", "/c/") cmd = get_command_path().replace("\\", "/").replace("C:/", "/c/")
args = args.replace('\\', '/').replace('C:/', '/c/') args = args.replace('\\', '/').replace('C:/', '/c/')
full_cmd = [ensure_git_bash(), '-c', f"'{cmd}' {args}"] full_cmd = [ensure_git_bash(), cmd, *shlex.split(args)]
# print(full_cmd)
if pipe: if pipe:
return check_output(full_cmd).decode().strip() return check_output(full_cmd).decode().strip()
@ -353,10 +310,10 @@ def run(asc: str, backend: BackendLiteral, args: str = ''):
def run_qwqfetch(asc: str, args: str = ''): def run_qwqfetch(asc: str, args: str = ''):
""" """
Run neofetch with colors Run qwqfetch with colors
:param preset: Color palette :param asc: Ascii art
:param alignment: Color alignment settings :param args: Additional arguments to pass to qwqfetch
""" """
asc = asc.replace('\\', '\\\\') asc = asc.replace('\\', '\\\\')
@ -369,7 +326,8 @@ def run_qwqfetch(asc: str, args: str = ''):
except ImportError as e: # module not found etc except ImportError as e: # module not found etc
print("qwqfetch is not installed. Install it by executing:") # use print to output hint directly print("qwqfetch is not installed. Install it by executing:") # use print to output hint directly
print("pip install git+https://github.com/nexplorer-3e/qwqfetch") # TODO: public repo print("pip install git+https://github.com/nexplorer-3e/qwqfetch") # TODO: public repo
raise e exit(127)
def run_neofetch(asc: str, args: str = ''): def run_neofetch(asc: str, args: str = ''):
""" """
@ -401,6 +359,16 @@ def run_fastfetch(asc: str, args: str = '', legacy: bool = False):
:param args: Additional arguments to pass to fastfetch :param args: Additional arguments to pass to fastfetch
:param legacy: Set true when using fastfetch < 1.8.0 :param legacy: Set true when using fastfetch < 1.8.0
""" """
# Find fastfetch binary
ff_path = (shutil.which('fastfetch')
or if_file(SRC / 'fastfetch/usr/bin/fastfetch')
or if_file(SRC / 'fastfetch/fastfetch')
or if_file(SRC / 'fastfetch/fastfetch.exe'))
if not ff_path:
printc("&cError: fastfetch binary is not found. Please install fastfetch first.")
exit(127)
# Write temp file # Write temp file
with TemporaryDirectory() as tmp_dir: with TemporaryDirectory() as tmp_dir:
tmp_dir = Path(tmp_dir) tmp_dir = Path(tmp_dir)
@ -408,7 +376,7 @@ def run_fastfetch(asc: str, args: str = '', legacy: bool = False):
path.write_text(asc) path.write_text(asc)
# Call fastfetch with the temp file # Call fastfetch with the temp file
proc = subprocess.run(['fastfetch', '--raw' if legacy else '--file-raw', path.absolute(), *shlex.split(args)]) proc = subprocess.run([ff_path, '--raw' if legacy else '--file-raw', path.absolute(), *shlex.split(args)])
if proc.returncode == 144: if proc.returncode == 144:
printc("&6Error code 144 detected: Please upgrade fastfetch to >=1.8.0 or use the 'fastfetch-old' backend") printc("&6Error code 144 detected: Please upgrade fastfetch to >=1.8.0 or use the 'fastfetch-old' backend")

View file

@ -519,6 +519,27 @@ PRESETS: dict[str, ColorProfile] = {
'#5276D4', '#5276D4',
]).with_weights([1, 1, 1, 1, 1, 5, 5, 5])), ]).with_weights([1, 1, 1, 1, 1, 5, 5, 5])),
# sourced from https://commons.wikimedia.org/wiki/File:Girlflux_Pride_Flag.jpg
"girlflux": ColorProfile([
"f9e6d7",
"f2526c",
"bf0311",
"e9c587",
"bf0311",
"f2526c",
"f9e6d7",
]),
# sourced from https://www.deviantart.com/pride-flags/art/Genderflux-1-543925589
"genderflux": ColorProfile([
"f47694",
"f2a2b9",
"cecece",
"7ce0f7",
"3ecdf9",
"fff48d",
]),
"finsexual": ColorProfile([ "finsexual": ColorProfile([
"#B18EDF", "#B18EDF",
"#D7B1E2", "#D7B1E2",
@ -650,6 +671,14 @@ PRESETS: dict[str, ColorProfile] = {
"#F3EDBD", "#F3EDBD",
]), ]),
# sampled from https://es.m.wikipedia.org/wiki/Archivo:Fraysexual_flag.jpg
'fraysexual': ColorProfile([
'#226CB5',
'#94E7DD',
'#FFFFFF',
'#636363',
]),
# Meme flags # Meme flags
'beiyang': ColorProfile([ 'beiyang': ColorProfile([
'#DF1B12', '#DF1B12',

133
neofetch
View file

@ -235,6 +235,15 @@ package_managers="on"
# off: '17 packages (flatpak)' # off: '17 packages (flatpak)'
package_separate="on" package_separate="on"
# Reduce output of packages list by not showing programming language package managers or Steam games
#
# Flag: --package_minimal
#
# Example:
# default: 'Packages: 1 (npm), 991 (emerge), 3 (steam), 23 (flatpak-system)'
# minimal: 'Packages: 991 (emerge), 23 (flatpak-system)'
package_minimal=""
# Shell # Shell
@ -865,7 +874,7 @@ image_source="auto"
# Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Cobalt, Condres, Container Linux by CoreOS, # Chrom, Cleanjaro, Clear Linux OS, ClearOS, Clover, Cobalt, Condres, Container Linux by CoreOS,
# CRUX, Crystal Linux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOs, Darwin, Debian, # CRUX, Crystal Linux, Cucumber, CutefishOS, CuteOS, CyberOS, dahlia, DarkOs, Darwin, Debian,
# Deepin, DesaOS, Devuan, DietPi, digital UNIX, DracOS, DragonFly, Drauger, Droidian, Elementary, # Deepin, DesaOS, Devuan, DietPi, digital UNIX, DracOS, DragonFly, Drauger, Droidian, Elementary,
# Elive, EncryptOS, EndeavourOS, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, Exodia Predator OS, # Elive, EncryptOS, EndeavourOS, Endless, Enso, EuroLinux, EvolutionOS, eweOS, Exherbo, Exodia Predator OS,
# Fedora, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeMiNT, Frugalware, Funtoo, GalliumOS, # Fedora, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeMiNT, Frugalware, Funtoo, GalliumOS,
# Garuda, Gentoo, GhostBSD, glaucus, gNewSense, GNOME, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, # Garuda, Gentoo, GhostBSD, glaucus, gNewSense, GNOME, GNU, GoboLinux, GrapheneOS, Grombyang, Guix,
# Haiku, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, iglunix, instantOS, Interix, # Haiku, HamoniKR, HarDClanZ, Hash, Huayra, Hybrid, HydroOS, Hyperbola, iglunix, instantOS, Interix,
@ -1188,7 +1197,7 @@ get_distro() {
elif type -p lsb_release >/dev/null; then elif type -p lsb_release >/dev/null; then
# Debian does not include .x versions in /etc/os-version, but does in debian_version # Debian does not include .x versions in /etc/os-version, but does in debian_version
# So if that file exists, and we are not *buntu, build name from there # So if that file exists, and we are not *buntu, build name from there
if [[ -f /etc/debian_version ]] && [[ $(lsb_release -si) != *"buntu"* ]]; then if [[ -f /etc/debian_version ]] && [[ $(lsb_release -si) != *"buntu"* ]] && [[ $(lsb_release -si) != *"neon"* ]]; then
. /etc/os-release . /etc/os-release
case $distro_shorthand in case $distro_shorthand in
on) distro="${NAME}" ;; on) distro="${NAME}" ;;
@ -1589,8 +1598,8 @@ get_model() {
case $model in case $model in
Mac14,15): "MacBook Air (15-inch, M2, 2023)" ;; Mac14,15): "MacBook Air (15-inch, M2, 2023)" ;;
Mac14,14): "Mac Studio (M2 Max, 2023)" ;; Mac14,14): "Mac Studio (M2 Ultra, 2023)" ;;
Mac14,13): "Mac Studio (M2 Ultra, 2023)" ;; Mac14,13): "Mac Studio (M2 Max, 2023)" ;;
Mac14,8): "Mac Pro (2023)" ;; Mac14,8): "Mac Pro (2023)" ;;
Mac14,6 | Mac14,10): "MacBook Pro (16-inch, 2023)" ;; Mac14,6 | Mac14,10): "MacBook Pro (16-inch, 2023)" ;;
Mac14,5 | Mac14,9): "MacBook Pro (14-inch, 2023)" ;; Mac14,5 | Mac14,9): "MacBook Pro (14-inch, 2023)" ;;
@ -2066,11 +2075,38 @@ get_packages() {
} }
} }
# OS-independent package managers. # Programming language package managers.
has pipx && tot pipx list --short if [[ -z "$package_minimal" ]]; then
has cargo && _cargopkgs="$(cargo install --list | grep -v '^ ')" && tot echo "$_cargopkgs" has pipx && tot pipx list --short
has npm && pkgs_h=1 tot npm list -g --depth=0 has cargo && _cargopkgs="$(cargo install --list | grep -v '^ ')" && tot echo "$_cargopkgs"
has am && pac "$(am -f | grep 'PROGRAMS MANAGED BY' | cut -d' ' -f4)"a
# Special case for npm: If has npm, we should list folders under node_modules instead of using npm list.
# This is because npm list is very slow (2s)
if has npm; then
# Try to apply heuristics to find the global directory.
if [[ -d /usr/lib/node_modules ]]; then
dir /usr/lib/node_modules/*/
elif [[ -d /usr/local/lib/node_modules ]]; then
dir /usr/local/lib/node_modules/*/
else
# If neither exist, use npm root -g to get the global directory.
# (still ~10x faster than npm list)
npm_global=$(npm root -g)
[[ -d $npm_global ]] && dir "$npm_global"/*/
# This may not work in WSL2 (if npm is installed on Windows, not WSL).
# However, if npm is not installed on this WSL subsystem, it doesn't really count
# as a package manager for this subsystem, so let's ignore this case.
fi
fi
fi
if has pkgx && [[ -d "$HOME/.local/bin" ]]; then
# https://github.com/pkgxdev/pkgx/issues/985#issuecomment-2080999008
_pkgxpkgs="$(grep -rIhoP 'exec pkgx \+\K[^ ]+' "$HOME/.local/bin" | sort -u)"
tot echo "$_pkgxpkgs"
unset _pkgxpkgs
fi
# OS-specific package managers. # OS-specific package managers.
case $os in case $os in
@ -2100,8 +2136,8 @@ get_packages() {
has pm && tot-safe pm list packages has pm && tot-safe pm list packages
has evox && tot cat /var/evox/packages/DB has evox && tot cat /var/evox/packages/DB
has squirrel && tot ls /var/packages has squirrel && tot ls /var/packages
has pkgx && tot find "$HOME/.pkgx" -maxdepth 2 -mindepth 2 -type d
has anise && tot anise s --installed has anise && tot anise s --installed
has am && pac "$(am -f --less)"
# Using the dnf package cache is much faster than rpm. # Using the dnf package cache is much faster than rpm.
if has dnf && type -p sqlite3 >/dev/null && [[ -f /var/cache/dnf/packages.db ]]; then if has dnf && type -p sqlite3 >/dev/null && [[ -f /var/cache/dnf/packages.db ]]; then
@ -2136,19 +2172,30 @@ get_packages() {
shopt -u nullglob shopt -u nullglob
} }
# Steam games if [[ -z "$package_minimal" ]]; then
STEAM_P=".local/share/Steam/steamapps/common" # Steam games
if [[ -d "$HOME/$STEAM_P" ]]; then STEAM_P=".local/share/Steam/steamapps/common"
manager=steam && dir "$HOME/$STEAM_P/*/" if [[ -d "$HOME/$STEAM_P" ]]; then
elif [[ -d "$HOME/.var/app/com.valvesoftware.Steam/$STEAM_P" ]]; then manager=steam && dir "$HOME/$STEAM_P/*/"
manager=steam && dir "$HOME/.var/app/com.valvesoftware.Steam/$STEAM_P/*/" elif [[ -d "$HOME/.var/app/com.valvesoftware.Steam/$STEAM_P" ]]; then
elif [[ -d "$HOME/.steam/steam/steamapps/common" ]]; then manager=steam && dir "$HOME/.var/app/com.valvesoftware.Steam/$STEAM_P/*/"
manager=steam && dir "$HOME/.steam/steam/steamapps/common/*/" elif [[ -d "$HOME/.steam/steam/steamapps/common" ]]; then
manager=steam && dir "$HOME/.steam/steam/steamapps/common/*/"
fi
fi fi
# Other (Needs complex command) # Other (Needs complex command)
has kpm-pkg && ((packages+=$(kpm --get-selections | grep -cv deinstall$))) has kpm-pkg && ((packages+=$(kpm --get-selections | grep -cv deinstall$)))
nix-user-pkgs() {
if [ -d ~/.nix-profile ]; then
nix-store -qR ~/.nix-profile
elif [ -d "$XDG_STATE_HOME/nix/profile" ]; then
nix-store -qR "$XDG_STATE_HOME/nix/profile"
fi
nix-store -qR /etc/profiles/per-user/"$USER"
}
# Separate system and user packages # Separate system and user packages
if [[ $package_separate == on ]]; then if [[ $package_separate == on ]]; then
has guix && { has guix && {
@ -2158,10 +2205,6 @@ get_packages() {
} }
has nix-store && { has nix-store && {
nix-user-pkgs() {
nix-store -qR ~/.nix-profile
nix-store -qR /etc/profiles/per-user/"$USER"
}
manager=nix-system && tot nix-store -qR /run/current-system/sw manager=nix-system && tot nix-store -qR /run/current-system/sw
manager=nix-user && tot nix-user-pkgs manager=nix-user && tot nix-user-pkgs
manager=nix-default && tot nix-store -qR /nix/var/nix/profiles/default manager=nix-default && tot nix-store -qR /nix/var/nix/profiles/default
@ -2183,8 +2226,7 @@ get_packages() {
has nix-store && { has nix-store && {
nix-all() { nix-all() {
nix-store -qR ~/.nix-profile nix-user-pkgs
nix-store -qR /etc/profiles/per-user/"$USER"
nix-store -qR /run/current-system/sw nix-store -qR /run/current-system/sw
nix-store -qR /nix/var/nix/profiles/default nix-store -qR /nix/var/nix/profiles/default
} }
@ -2239,7 +2281,6 @@ get_packages() {
has brew && dir "$(brew --cellar)/* $(brew --caskroom)/*" has brew && dir "$(brew --cellar)/* $(brew --caskroom)/*"
has pkgin && tot pkgin list has pkgin && tot pkgin list
has dpkg && tot dpkg-query -f '.\n' -W has dpkg && tot dpkg-query -f '.\n' -W
has tea && tot find "$HOME/.tea" -maxdepth 2 -mindepth 2 -type d
has nix-store && { has nix-store && {
nix-user-pkgs() { nix-user-pkgs() {
@ -2375,7 +2416,7 @@ get_editor() {
[[ -z "$editor_full_path" ]] && return [[ -z "$editor_full_path" ]] && return
# Actually obtain the full path # Actually obtain the full path
editor_full_path="$(which "${editor_full_path}" 2>/dev/null)" editor_full_path="$(command -v "${editor_full_path}" 2>/dev/null)"
# Resolve symlink and get the original name # Resolve symlink and get the original name
[[ -L "$editor_full_path" ]] && editor_full_path="$(readlink -f "$editor_full_path")" [[ -L "$editor_full_path" ]] && editor_full_path="$(readlink -f "$editor_full_path")"
@ -2390,7 +2431,7 @@ get_editor() {
# Obtain editor version # Obtain editor version
case ${editor_name:=${editor_full_path##*/}} in case ${editor_name:=${editor_full_path##*/}} in
nano|vim|micro|emacs) nano|vim|nvim|micro|emacs)
editor_v=$("$editor_full_path" --version 2>&1) editor_v=$("$editor_full_path" --version 2>&1)
;; ;;
kak) kak)
@ -2505,9 +2546,20 @@ get_de() {
esac esac
((${KDE_SESSION_VERSION:-0} >= 4)) && de=${de/KDE/Plasma} ((${KDE_SESSION_VERSION:-0} >= 4)) && de=${de/KDE/Plasma}
((${KDE_SESSION_VERSION:-0} >= 6)) && de=${de/Plasma/Plasma6}
if [[ $de_version == on && $de ]]; then if [[ $de_version == on && $de ]]; then
case $de in case $de in
Plasma6*)
de_ver=$(plasmashell --version)
kf_ver=$(kinfo)
qt_ver=${kf_ver/Kernel*}
qt_ver=${qt_ver/*:}
qt_ver=$(trim "$qt_ver")
kf_ver=${kf_ver/Qt*}
kf_ver=${kf_ver/*:}
kf_ver=$(trim "$kf_ver")
;;
Plasma*) Plasma*)
de_ver=$(plasmashell --version) de_ver=$(plasmashell --version)
kf_ver=$(kf5-config --version) kf_ver=$(kf5-config --version)
@ -2541,7 +2593,7 @@ get_de() {
de+=" $de_ver" de+=" $de_ver"
[[ $de == "Plasma"* ]] && de+=" [KF5 $kf_ver] [Qt $qt_ver]" [[ $de == "Plasma"* ]] && de="Plasma $de_ver [KF $kf_ver] [Qt $qt_ver]"
fi fi
# TODO: # TODO:
@ -6345,6 +6397,7 @@ INFO:
--title_fqdn on/off Hide/Show Fully Qualified Domain Name in title. --title_fqdn on/off Hide/Show Fully Qualified Domain Name in title.
--package_managers on/off Hide/Show Package Manager names. (on, tiny, off) --package_managers on/off Hide/Show Package Manager names. (on, tiny, off)
--package_separate on/off Whether to separate system/user modes for supported package managers --package_separate on/off Whether to separate system/user modes for supported package managers
--package_minimal Reduce output of packages list by not showing programming language package managers or Steam games
--os_arch on/off Hide/Show OS architecture. --os_arch on/off Hide/Show OS architecture.
--speed_type type Change the type of cpu speed to display. --speed_type type Change the type of cpu speed to display.
Possible values: current, min, max, bios, Possible values: current, min, max, bios,
@ -6502,7 +6555,7 @@ ASCII:
CutefishOS, CuteOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin, CutefishOS, CuteOS, CyberOS, dahlia, DarkOs, Darwin, Debian, Deepin,
DesaOS, Devuan, DietPi, digital UNIX, DracOS, DragonFly, Drauger, DesaOS, Devuan, DietPi, digital UNIX, DracOS, DragonFly, Drauger,
Droidian, Elementary, Elive, EncryptOS, EndeavourOS, Endless, Enso, Droidian, Elementary, Elive, EncryptOS, EndeavourOS, Endless, Enso,
EuroLinux, EvolutionOS, Exherbo, Exodia Predator OS, Fedora, EuroLinux, EvolutionOS, eweOS, Exherbo, Exodia Predator OS, Fedora,
FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeMiNT, Frugalware, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeMiNT, Frugalware,
Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense, Funtoo, GalliumOS, Garuda, Gentoo, GhostBSD, glaucus, gNewSense,
GNOME, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HamoniKR, GNOME, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, Haiku, HamoniKR,
@ -6614,6 +6667,7 @@ get_args() {
"--title_fqdn") title_fqdn="$2" ;; "--title_fqdn") title_fqdn="$2" ;;
"--package_managers") package_managers="$2" ;; "--package_managers") package_managers="$2" ;;
"--package_separate") package_separate="$2" ;; "--package_separate") package_separate="$2" ;;
"--package_minimal") package_minimal="1" ;;
"--os_arch") os_arch="$2" ;; "--os_arch") os_arch="$2" ;;
"--cpu_cores") cpu_cores="$2" ;; "--cpu_cores") cpu_cores="$2" ;;
"--cpu_speed") cpu_speed="$2" ;; "--cpu_speed") cpu_speed="$2" ;;
@ -9613,6 +9667,27 @@ ${c1}\e[1;32m dddddddddddddddddddddddd
EOF EOF
;; ;;
"eweOS"*)
set_colors 7 11 9 8 1
read -rd '' ascii_data <<'EOF'
${c2} #####%%%
${c2} ##%%${c3}////${c2}%%%%%${c3}///
${c2} #%%%%${c3}////((((////${c2}%
${c1} *@@@@@@@${c3}/${c5},,,${c3}/////${c5},,,${c2}%${c1}@@@@@@@
${c1} .@@@@@@@@@@@${c3}////////${c2}%%%${c1}@@@@@@@@@@@@
${c1} @@@${c4}...${c1}@@@@@@${c3}////${c2}%%${c3}////${c1}@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@@@@@@@@@@@@@@@@@@
${c1} @@@@@@ @@@@@@
${c1} @@@ @@@
EOF
;;
"Exherbo"*) "Exherbo"*)
set_colors 4 7 1 set_colors 4 7 1
read -rd '' ascii_data <<'EOF' read -rd '' ascii_data <<'EOF'

View file

@ -31,6 +31,7 @@ setup(
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
], ],
packages=find_namespace_packages(), packages=find_namespace_packages(),
package_data={'hyfetch': ['hyfetch/*']}, package_data={'hyfetch': ['hyfetch/*']},

366
tools/bash_ignore.txt Normal file
View file

@ -0,0 +1,366 @@
git-bash.exe
git-cmd.exe
cmd
tmp
dev
bin/git.exe
bin/sh.exe
usr/share
usr/ssl
usr/libexec
usr/lib
usr/bin/git*
usr/bin/*vim*
usr/bin/*ssl*
usr/bin/*perl*
usr/bin/*gpg*
usr/bin/*ssh*
usr/bin/*crypto*
usr/bin/*view*
usr/bin/*svn*
usr/bin/ex*.exe
mingw32/share
mingw32/lib
mingw32/etc
mingw32/doc
mingw32/libexec
mingw32/bin/git*
mingw32/bin/Git*
mingw32/bin/Avalonia*
mingw32/bin/xz*
mingw32/bin/*ssl*
mingw32/bin/scalar.exe
mingw32/bin/libSkiaSharp.dll
mingw32/bin/*crypto*
mingw32/bin/*Microsoft.Identity*
mingw32/bin/*bz*
mingw32/bin/tcl*
mingw32/bin/*brotli*
mingw32/bin/av*
mingw32/bin/pdftotext.exe
mingw32/bin/libiconv-2.dll
mingw32/bin/libHarfBuzzSharp.dll
mingw32/bin/SkiaSharp.dll
mingw32/bin/libcurl-4.dll
mingw32/bin/libgmp-10.dll
mingw32/bin/System.Text.Json.dll
mingw32/bin/gcmcore.dll
mingw32/bin/curl.exe
# Automatically determined by access time
usr/bin/rebase.exe
usr/bin/rebaseall
usr/bin/start
usr/bin/column.exe
usr/bin/dash.exe
usr/bin/getopt.exe
usr/bin/znew
usr/bin/zless
usr/bin/zipinfo.exe
usr/bin/zipgrep
usr/bin/zgrep
usr/bin/zforce
usr/bin/zfgrep
usr/bin/zegrep
usr/bin/zdiff
usr/bin/zcmp
usr/bin/zcat
usr/bin/yes.exe
usr/bin/yat2m.exe
usr/bin/xxd.exe
usr/bin/xgettext.exe
usr/bin/xargs.exe
usr/bin/winpty.exe
usr/bin/wordpad
usr/bin/winpty.dll
usr/bin/winpty-debugserver.exe
usr/bin/winpty-agent.exe
usr/bin/whoami.exe
usr/bin/who.exe
usr/bin/which.exe
usr/bin/watchgnupg.exe
usr/bin/vi
usr/bin/vdir.exe
usr/bin/users.exe
usr/bin/updatedb
usr/bin/update-ca-trust
usr/bin/unzipsfx.exe
usr/bin/unzip.exe
usr/bin/unlink.exe
usr/bin/unix2mac.exe
usr/bin/unix2dos.exe
usr/bin/unexpand.exe
usr/bin/uncompress
usr/bin/umount.exe
usr/bin/u2d.exe
usr/bin/tzset.exe
usr/bin/tty.exe
usr/bin/tsort.exe
usr/bin/tset.exe
usr/bin/trust.exe
usr/bin/truncate.exe
usr/bin/true.exe
usr/bin/tr.exe
usr/bin/tput.exe
usr/bin/touch.exe
usr/bin/toe.exe
usr/bin/timeout.exe
usr/bin/tig.exe
usr/bin/tic.exe
usr/bin/test.exe
usr/bin/tee.exe
usr/bin/tar.exe
usr/bin/tail.exe
usr/bin/tac.exe
usr/bin/tabs.exe
usr/bin/sync.exe
usr/bin/sum.exe
usr/bin/stty.exe
usr/bin/strace.exe
usr/bin/stat.exe
usr/bin/ssp.exe
usr/bin/split.exe
usr/bin/sleep.exe
usr/bin/shuf.exe
usr/bin/shred.exe
usr/bin/sha512sum.exe
usr/bin/sha384sum.exe
usr/bin/sha256sum.exe
usr/bin/sha224sum.exe
usr/bin/sha1sum.exe
usr/bin/sftp.exe
usr/bin/sexp-conv.exe
usr/bin/setmetamode.exe
usr/bin/setfacl.exe
usr/bin/seq.exe
usr/bin/sdiff.exe
usr/bin/scp.exe
usr/bin/runcon.exe
usr/bin/rnano.exe
usr/bin/rmdir.exe
usr/bin/rm.exe
usr/bin/restore
usr/bin/reset.exe
usr/bin/regtool.exe
usr/bin/recode-sr-latin.exe
usr/bin/realpath.exe
usr/bin/readlink.exe
usr/bin/pwd.exe
usr/bin/ptx.exe
usr/bin/psl.exe
usr/bin/psl-make-dafsa
usr/bin/ps.exe
usr/bin/profiler.exe
usr/bin/printf.exe
usr/bin/printenv.exe
usr/bin/pr.exe
usr/bin/pldd.exe
usr/bin/pkcs1-conv.exe
usr/bin/pinky.exe
usr/bin/pinentry.exe
usr/bin/pinentry-w32.exe
usr/bin/pathchk.exe
usr/bin/patch.exe
usr/bin/paste.exe
usr/bin/passwd.exe
usr/bin/p11-kit.exe
usr/bin/od.exe
usr/bin/numfmt.exe
usr/bin/nproc.exe
usr/bin/notepad
usr/bin/nohup.exe
usr/bin/nl.exe
usr/bin/nice.exe
usr/bin/ngettext.exe
usr/bin/nettle-pbkdf2.exe
usr/bin/nettle-lfib-stream.exe
usr/bin/nettle-hash.exe
usr/bin/nano.exe
usr/bin/mv.exe
usr/bin/msys-z.dll
usr/bin/msys-wind-0.dll
usr/bin/msys-unistring-2.dll
usr/bin/msys-ticw6.dll
usr/bin/msys-tasn1-6.dll
usr/bin/msys-sqlite3-0.dll
usr/bin/msys-smartcols-1.dll
usr/bin/msys-serf-1-0.dll
usr/bin/msys-sasl2-3.dll
usr/bin/msys-roken-18.dll
usr/bin/msys-psl-5.dll
usr/bin/msys-pcre2-posix-3.dll
usr/bin/msys-pcre2-8-0.dll
usr/bin/msys-p11-kit-0.dll
usr/bin/msys-npth-0.dll
usr/bin/msys-nettle-8.dll
usr/bin/msys-magic-1.dll
usr/bin/msys-lz4-1.dll
usr/bin/msys-ksba-8.dll
usr/bin/msys-krb5-26.dll
usr/bin/msys-kafs-0.dll
usr/bin/msys-idn2-0.dll
usr/bin/msys-hx509-5.dll
usr/bin/msys-hogweed-6.dll
usr/bin/msys-heimntlm-0.dll
usr/bin/msys-heimbase-1.dll
usr/bin/msys-gssapi-3.dll
usr/bin/msys-gobject-2.0-0.dll
usr/bin/msys-gnutls-30.dll
usr/bin/msys-gmodule-2.0-0.dll
usr/bin/msys-glib-2.0-0.dll
usr/bin/msys-gio-2.0-0.dll
usr/bin/msys-gettextsrc-0-19-8-1.dll
usr/bin/msys-gettextlib-0-19-8-1.dll
usr/bin/msys-gcrypt-20.dll
usr/bin/msys-fido2-1.dll
usr/bin/msys-ffi-7.dll
usr/bin/msys-expat-1.dll
usr/bin/msys-edit-0.dll
usr/bin/msys-crypt-0.dll
usr/bin/msys-com_err-1.dll
usr/bin/msys-cbor-0.11.dll
usr/bin/msys-bz2-1.dll
usr/bin/msys-assuan-0.dll
usr/bin/msys-asn1-8.dll
usr/bin/msys-aprutil-1-0.dll
usr/bin/msys-apr-1-0.dll
usr/bin/msguniq.exe
usr/bin/msgunfmt.exe
usr/bin/msgmerge.exe
usr/bin/msginit.exe
usr/bin/msggrep.exe
usr/bin/msgfmt.exe
usr/bin/msgfilter.exe
usr/bin/msgexec.exe
usr/bin/msgen.exe
usr/bin/msgconv.exe
usr/bin/msgcomm.exe
usr/bin/msgcmp.exe
usr/bin/msgcat.exe
usr/bin/msgattrib.exe
usr/bin/mpicalc.exe
usr/bin/mount.exe
usr/bin/mktemp.exe
usr/bin/mkpasswd.exe
usr/bin/mknod.exe
usr/bin/mkgroup.exe
usr/bin/mkfifo.exe
usr/bin/mkdir.exe
usr/bin/mintty.exe
usr/bin/mintheme
usr/bin/minidumper.exe
usr/bin/md5sum.exe
usr/bin/mac2unix.exe
usr/bin/lsattr.exe
usr/bin/ls.exe
usr/bin/logname.exe
usr/bin/locate.exe
usr/bin/locale.exe
usr/bin/ln.exe
usr/bin/link.exe
usr/bin/lesskey.exe
usr/bin/lessecho.exe
usr/bin/less.exe
usr/bin/ldh.exe
usr/bin/ldd.exe
usr/bin/kill.exe
usr/bin/kbxutil.exe
usr/bin/join.exe
usr/bin/install.exe
usr/bin/infotocap.exe
usr/bin/infocmp.exe
usr/bin/iconv.exe
usr/bin/hostname.exe
usr/bin/hostid.exe
usr/bin/hmac256.exe
usr/bin/head.exe
usr/bin/gzip.exe
usr/bin/gzexe
usr/bin/gunzip
usr/bin/gsettings.exe
usr/bin/groups.exe
usr/bin/gobject-query.exe
usr/bin/gmondump.exe
usr/bin/glib-compile-schemas.exe
usr/bin/gkill.exe
usr/bin/gio-querymodules.exe
usr/bin/gettextize
usr/bin/gettext.sh
usr/bin/gettext.exe
usr/bin/getflags
usr/bin/getfacl.exe
usr/bin/getemojis
usr/bin/getconf.exe
usr/bin/gencat.exe
usr/bin/gdbus.exe
usr/bin/gawk.exe
usr/bin/gawk-5.0.0.exe
usr/bin/gapplication.exe
usr/bin/funzip.exe
usr/bin/fold.exe
usr/bin/fmt.exe
usr/bin/find.exe
usr/bin/file.exe
usr/bin/fgrep
usr/bin/false.exe
usr/bin/factor.exe
usr/bin/envsubst.exe
usr/bin/env.exe
usr/bin/egrep
usr/bin/echo.exe
usr/bin/dumpsexp.exe
usr/bin/du.exe
usr/bin/dos2unix.exe
usr/bin/docx2txt.pl
usr/bin/docx2txt
usr/bin/dirmngr.exe
usr/bin/dirmngr-client.exe
usr/bin/dircolors.exe
usr/bin/dir.exe
usr/bin/diff3.exe
usr/bin/diff.exe
usr/bin/df.exe
usr/bin/dd.exe
usr/bin/date.exe
usr/bin/d2u.exe
usr/bin/cygwin-console-helper.exe
usr/bin/cygcheck.exe
usr/bin/cut.exe
usr/bin/csplit.exe
usr/bin/cp.exe
usr/bin/comm.exe
usr/bin/cmp.exe
usr/bin/clear.exe
usr/bin/cksum.exe
usr/bin/chroot.exe
usr/bin/chown.exe
usr/bin/chmod.exe
usr/bin/chgrp.exe
usr/bin/chcon.exe
usr/bin/chattr.exe
usr/bin/cat.exe
usr/bin/captoinfo.exe
usr/bin/c_rehash
usr/bin/bzless
usr/bin/bzip2recover.exe
usr/bin/bzip2.exe
usr/bin/bzgrep
usr/bin/bzfgrep
usr/bin/bzegrep
usr/bin/bzdiff
usr/bin/bzcmp
usr/bin/bzcat.exe
usr/bin/bunzip2.exe
usr/bin/bashbug
usr/bin/basenc.exe
usr/bin/basename.exe
usr/bin/base64.exe
usr/bin/base32.exe
usr/bin/backup
usr/bin/b2sum.exe
usr/bin/autopoint
usr/bin/astextplain
usr/bin/arch.exe
usr/bin/applygnupgdefaults
usr/bin/addgnupghome
usr/bin/[.exe

28
tools/build_bash.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# This script is used to build a customized Git Bash for windows pacakge that only include bash and no other unnecessary files
set -e
# Get script directory
DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$DIR/../dist"
# Get the git distribution if it doesn't exist
if [ ! -f /tmp/git.tar.bz2 ]; then
# NOTE: Git for Windows v2.44 is the last release to support Windows 7 and 8
URL="https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/Git-2.44.0-32-bit.tar.bz2"
echo "> Downloading git distribution"
wget -q $URL -O /tmp/git.tar.bz2
fi
# Unzip the git distribution to git directory
# Ignore the unnecessary files
# rm -rf git
if [ ! -d /tmp/git ]; then
mkdir -p /tmp/git
echo "> Unzipping git distribution"
tar -xf /tmp/git.tar.bz2 --exclude-from="$DIR/bash_ignore.txt" -C /tmp/git
fi
# Copy the git distribution
cp -r /tmp/git ./git

113
tools/build_pkg.sh Executable file
View file

@ -0,0 +1,113 @@
#!/usr/bin/env bash
FASTFETCH_VERSION="2.10.2"
FASTFETCH_DL="https://github.com/fastfetch-cli/fastfetch/releases/download/$FASTFETCH_VERSION/"
# Get script directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/.."
set -e
# Remove the old build
rm -rf dist/
rm -rf build/
# Remove git from the source code before building
rm -rf hyfetch/git/
# Build python from setup.py
python3 setup.py sdist bdist_wheel
# Check
twine check dist/*.tar.gz
twine check dist/*.whl
# =================
# Build for windows
cd dist
# Get the file name
# file="$(ls | grep .whl)" use glob instead
file=$(echo *-none-any.whl)
# Build bash pacakge
"$DIR/build_bash.sh"
# Unzip the wheel
echo "> Unzipping $file"
rm -rf wheel
unzip -qq "$file" -d wheel
# TODO: Find a way to exclude the tools folder
rm -rf wheel/tools
# Copy the git distribution to the wheel
cp -r git/ wheel/hyfetch/
# Embed fastfetch binary
echo "> Embedding fastfetch binary"
wget -q "$FASTFETCH_DL/fastfetch-windows-i686.zip" -O fastfetch-windows.zip
mkdir -p wheel/hyfetch/fastfetch
bsdtar -zxf fastfetch-windows.zip -C wheel/hyfetch/fastfetch
rm -rf fastfetch-windows.zip
# Change the file name (replace -none-any with -win_amd64)
new_name=${file/-any/-win32}
# Zip the wheel to win_amd64.whl
cd wheel && zip -qq -y -r "../$new_name" * && cd ..
cp "$new_name" "${new_name/.whl/-win_amd64.whl}"
# Check again
twine check "$new_name"
# =================
# Build for linux
# Now we're done with windows, delete the git folder
rm -rf wheel/git
function build_for_platform() {
ff_platform=$1
wheel_platform=$2
echo "Building for $ff_platform"
# Download the fastfetch binary
wget -q "$FASTFETCH_DL/fastfetch-$ff_platform.zip" -O "fastfetch-$ff_platform.zip"
# Delete the old fastfetch folder
rm -rf wheel/hyfetch/fastfetch
# Unzip the fastfetch binary
# unzip -qq "fastfetch-$ff_platform.zip" -d wheel/hyfetch/fastfetch
mkdir -p wheel/hyfetch/fastfetch
bsdtar -zxf "fastfetch-$ff_platform.zip" -C wheel/hyfetch/fastfetch --strip-components 1
rm -rf "fastfetch-$ff_platform.zip"
# Change the file name
new_name=${file/-any/-"$wheel_platform"}
# Zip the wheel to platform.whl
cd wheel && zip -qq -y -r "../$new_name" * && cd ..
# Check again
twine check "$new_name"
}
# See https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/
# The official fastfetch build uses Ubuntu 20.04 with glibc 2.31
build_for_platform "linux-amd64" "manylinux_2_31_x86_64"
build_for_platform "linux-aarch64" "manylinux_2_31_aarch64"
# There doesn't seem to be tags for freebsd?
# build_for_platform "freebsd-amd64" "freebsd_x86_64"
# build_for_platform "freebsd-aarch64" "freebsd_aarch64"
build_for_platform "musl-amd64" "musllinux_1_1_x86_64"
build_for_platform "musl-aarch64" "musllinux_1_1_aarch64"
# The official fastfetch build uses macOS 12.0
build_for_platform "macos-universal" "macosx_11_0_x86_64"
build_for_platform "macos-universal" "macosx_11_0_arm64"
# TODO: linux_riscv64
# Finally, remove temporary files
rm -rf wheel git