Skip to content

Commit f9d7972

Browse files
committed
Add install-pacman.sh
1 parent 58bbe78 commit f9d7972

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

vendor/bin/install_pacman.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
3+
# Based on: https://github.com/mcgitty/pacman-for-git
4+
# My Fork: https://github.com/daxgames/pacman-for-git
5+
6+
export bin_source=${1:-https://github.com/daxgames/pacman-for-git/raw/refs/heads/main}
7+
8+
if [[ "$HOSTTYPE" == "i686" ]]; then
9+
pacman=(
10+
pacman-6.0.0-4-i686.pkg.tar.zst
11+
pacman-mirrors-20210703-1-any.pkg.tar.zst
12+
msys2-keyring-1~20210213-2-any.pkg.tar.zst
13+
)
14+
15+
zstd=zstd-1.5.0-1-i686.pkg.tar.xz
16+
zstd_win=https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-v1.5.5-win32.zip
17+
else
18+
pacman=(
19+
pacman-6.0.1-18-x86_64.pkg.tar.zst
20+
pacman-mirrors-20220205-1-any.pkg.tar.zst
21+
msys2-keyring-1~20220623-1-any.pkg.tar.zst
22+
)
23+
24+
zstd=zstd-1.5.2-1-x86_64.pkg.tar.xz
25+
zstd_win=https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-v1.5.5-win64.zip
26+
fi
27+
28+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
29+
echo Downloading pacman files...
30+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
31+
for f in "${pacman[@]}"; do
32+
echo "Running: curl -sLkf -o \"$HOME/Downloads/$f\" \"${bin_source}/$f\""
33+
curl -sLkf -o "$HOME/Downloads/$f" "${bin_source}/$f" || exit 1
34+
done
35+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
36+
37+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
38+
echo Downloading zstd binaries...
39+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
40+
echo "Running: curl -sLkf -o \"$HOME/Downloads/$zstd\" \"${bin_source}/$zstd\""
41+
curl -sLkf -o "$HOME/Downloads/$zstd" "${bin_source}/$zstd" || exit 1
42+
echo "Running: curl -sLkf -o \"$HOME/Downloads/$(basename \"${zstd_win}\")\" \"$zstd_win\""
43+
curl -sLkf -o "$HOME/Downloads/$(basename "${zstd_win}")" "$zstd_win" || exit 1
44+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
45+
46+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
47+
echo Downloading pacman.conf...
48+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
49+
echo "Running: curl -Lk https://raw.githubusercontent.com/msys2/MSYS2-packages/7858ee9c236402adf569ac7cff6beb1f883ab67c/pacman/pacman.conf"
50+
curl -sLk https://raw.githubusercontent.com/msys2/MSYS2-packages/7858ee9c236402adf569ac7cff6beb1f883ab67c/pacman/pacman.conf -o /etc/pacman.conf || exit 1
51+
52+
pushd "$HOME/Downloads"
53+
[[ -d "$(basename "${zstd_win}" | sed 's/\.zip$//')" ]] && \
54+
rm -rf "$(basename "${zstd_win}" | sed 's/\.zip$//')"
55+
unzip "$HOME/Downloads/$(basename "${zstd_win}")"
56+
export PATH="$PATH:$HOME/Downloads/$(basename "${zstd_win}" | sed 's/\.zip$//')"
57+
popd
58+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
59+
60+
cd /
61+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
62+
echo Installing pacman files...
63+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
64+
echo "Extracting zstd to /usr..."
65+
tar x --xz -vf "$HOME/Downloads/$zstd" usr
66+
67+
for f in "${pacman[@]}"; do
68+
echo "Extracting $f to /usr and /etc..."
69+
tar x --zstd -vf "$HOME/Downloads/$f" usr etc 2>/dev/null
70+
done
71+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
72+
73+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
74+
echo Initializing pacman...
75+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
76+
mkdir -p /var/lib/pacman
77+
ln -sf "$(which gettext)" /usr/bin/
78+
pacman-key --init
79+
pacman-key --populate msys2
80+
pacman -Syu --noconfirm
81+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
82+
83+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
84+
echo Getting package versions for the installed Git release
85+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
86+
t=$(grep -E 'mingw-w64-[ix_0-9]+-git ' /etc/package-versions.txt)
87+
echo "Found package version line: $t"
88+
89+
curl --help >/dev/null 2>&1 || { echo "ERROR: curl is not installed properly."; exit 1; }
90+
91+
echo "Getting commit ID that matches '$t' from github pacman-for-git..."
92+
t=$(curl -sLk "${bin_source}/version-tags.txt" | grep "$t")
93+
echo "Full line from version-tags.txt: '$t'"
94+
95+
[[ "$t" == "" ]] && echo "ERROR: Commit ID not logged in github pacman-for-git." && exit 1
96+
echo -e "Using commit ID: '${t##* }'"
97+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
98+
99+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
100+
echo Downloading package database files for the installed Git release
101+
echo =-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
102+
b=64 && [[ "$t" == *-i686-* ]] && b=32
103+
URL="https://github.com/git-for-windows/git-sdk-$b/raw/${t##* }"
104+
while read -r p v; do
105+
d="/var/lib/pacman/local/$p-$v"
106+
mkdir -p "$d"
107+
echo "$d"
108+
109+
for f in desc files mtree; do
110+
curl -fsSL "$URL$d/$f" -o "$d/$f"
111+
done
112+
113+
[[ ! -f "$d/desc" ]] && rmdir "$d" && echo "Missing $d"
114+
done < /etc/package-versions.txt
115+
echo -e "\n=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"

0 commit comments

Comments
 (0)