55_main () {
66 if _should_install_pkgx; then
77 _install_pkgx " $@ "
8- _install_pre_reqs
98 elif [ $# -eq 0 ]; then
109 echo /usr/local/bin/" $( pkgx --version) already installed" >&2
1110 echo /usr/local/bin/" $( pkgm --version) already installed" >&2
@@ -47,70 +46,6 @@ _is_ci() {
4746 [ -n " $CI " ] && [ $CI != 0 ]
4847}
4948
50- _install_pre_reqs () {
51- if _is_ci; then
52- apt () {
53- # we should use apt-get not apt in CI
54- # weird shit ref: https://askubuntu.com/a/668859
55- export DEBIAN_FRONTEND=noninteractive
56- cmd=$1
57- shift
58- $SUDO apt-get $cmd --yes -qq -o=Dpkg::Use-Pty=0 $@
59- }
60- else
61- apt () {
62- case " $1 " in
63- update)
64- echo " ensure you have the \` pkgx\` pre-requisites installed:" >&2
65- ;;
66- install)
67- echo " apt-get" " $@ " >&2
68- ;;
69- esac
70- }
71- yum () {
72- echo " ensure you have the \` pkgx\` pre-requisites installed:" >&2
73- echo " yum" " $@ " >&2
74- }
75- pacman () {
76- echo " ensure you have the \` pkgx\` pre-requisites installed:" >&2
77- echo " pacman" " $@ " >&2
78- }
79- fi
80-
81- if test -f /etc/debian_version; then
82- apt update
83-
84- # minimal but required or networking doesn’t work
85- # https://packages.debian.org/buster/all/netbase/filelist
86- A=" netbase"
87-
88- # difficult to pkg in our opinion
89- B=libudev-dev
90-
91- # ca-certs needed until we bundle our own root cert
92- C=ca-certificates
93-
94- case $( cat /etc/debian_version) in
95- jessie/sid|8.* |stretch/sid|9.* )
96- apt install libc-dev libstdc++-4.8-dev libgcc-4.7-dev $A $B $C ;;
97- buster/sid|10.* )
98- apt install libc-dev libstdc++-8-dev libgcc-8-dev $A $B $C ;;
99- bullseye/sid|11.* )
100- apt install libc-dev libstdc++-10-dev libgcc-9-dev $A $B $C ;;
101- bookworm/sid|12.* |* )
102- apt install libc-dev libstdc++-11-dev libgcc-11-dev $A $B $C ;;
103- esac
104- elif test -f /etc/fedora-release; then
105- $SUDO yum --assumeyes install libatomic
106- elif test -f /etc/arch-release; then
107- # installing gcc isn't my favorite thing, but even clang depends on it
108- # on archlinux. it provides libgcc. since we use it for testing, the risk
109- # to our builds is very low.
110- $SUDO pacman --noconfirm -Sy gcc libatomic_ops libxcrypt-compat
111- fi
112- }
113-
11449_install_pkgx () {
11550 if _is_ci; then
11651 progress=" --no-progress-meter"
@@ -122,23 +57,27 @@ _install_pkgx() {
12257
12358 if [ $# -eq 0 ]; then
12459 if [ -f /usr/local/bin/pkgx ]; then
125- echo " upgrading: /usr/local/bin/pkg[xm] " >&2
60+ echo " upgrading: /usr/local/bin/pkgx " >&2
12661 else
127- echo " installing: /usr/local/bin/pkg[xm] " >&2
62+ echo " installing: /usr/local/bin/pkgx " >&2
12863 fi
12964
13065 # using a named pipe to prevent curl progress output trumping the sudo password prompt
13166 pipe=" $tmpdir /pipe"
13267 mkfifo " $pipe "
13368
134- curl --silent --fail --proto ' =https' -o " $tmpdir /pkgm" \
135- https://pkgxdev.github.io/pkgm/pkgm.ts
136-
13769 curl $progress --fail --proto ' =https' " https://pkgx.sh/$( uname) /$( uname -m) " .tgz > " $pipe " &
13870 $SUDO sh -c "
13971 mkdir -p /usr/local/bin
14072 tar xz --directory /usr/local/bin < '$pipe '
141- install -m 755 " $tmpdir /pkgm" /usr/local/bin
73+ if [ ! -f /usr/local/bin/pkgm ]; then
74+ echo '#!/usr/bin/env -S pkgx -q! pkgm' > /usr/local/bin/pkgm
75+ chmod +x /usr/local/bin/pkgm
76+ fi
77+ if [ ! -f /usr/local/bin/mash ]; then
78+ echo '#!/usr/bin/env -S pkgx -q! mash' > /usr/local/bin/mash
79+ chmod +x /usr/local/bin/mash
80+ fi
14281 " &
14382 wait
14483
@@ -151,7 +90,8 @@ _install_pkgx() {
15190
15291 # tell the user what version we just installed
15392 pkgx --version
154- pkgm --version
93+ pkgx pkgm@latest --version
94+ pkgx mash@latest --version
15595
15696 else
15797 curl $progress --fail --proto ' =https' \
@@ -201,8 +141,4 @@ _should_install_pkgx() {
201141}
202142
203143_prep
204- if [ " $PKGX_INSTALL_PREREQS " != 1 ]; then
205- _main " $@ "
206- else
207- _install_pre_reqs
208- fi
144+ _main " $@ "
0 commit comments