aboutsummaryrefslogtreecommitdiff
path: root/tlobsd-getbiber
blob: d3d899a939382a2387633d8f33714cf439d0994d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
#
# $TeX Live for OpenBSD, 2024/06/08 $

TLBINDIR=$(dirname $0)
BINREPO=https://www.ekdosis.org/texlive
TMPDIR=$(mktemp -d)
OPENBSD_VERSION=$(sysctl -n kern.version | awk 'FNR == 1 { print $2 }' | sed 's/\.//')
UPDATING=$(curl -s ${BINREPO}/status.txt | grep updating= | sed 's/.*=//')
BIBERNAMES="biber biber-ms"

if [[ ! -w ${TLBINDIR} ]]; then
    echo "You do not have write permissions to ${TLBINDIR}"
    exit 1
fi

if [[ ${tlobsd} -ne 1 ]];then
    echo "Please use 'tlobsd getbiber' instead of this command."
    exit 1
fi


if [[ ${UPDATING} == "yes" ]];then
    echo "The binaries are being updated.  Please re-run this command later."
else
    for bibername in $BIBERNAMES
    do
	echo ""
	echo "Downloading ${bibername}..."
	echo ""
	if curl --output /dev/null --silent --head --fail ${BINREPO}/${bibername}-openbsd${OPENBSD_VERSION}.xz;
	then
	    curl ${BINREPO}/${bibername}-openbsd${OPENBSD_VERSION}.xz \
		 -o ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz
	    curl ${BINREPO}/${bibername}-openbsd${OPENBSD_VERSION}.xz.asc \
		 -o ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz.asc
	    gpg --verify ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz.asc
	    if [[ $? -eq 0 ]];then
		unxz ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz
		cp ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION} ${TLBINDIR}/${bibername}
		chmod +x ${TLBINDIR}/${bibername}
		echo ""
		echo "Installation of ${bibername}-openbsd${OPENBSD_VERSION} complete."
	    else
		echo ""
		echo "The signature could not be verified."
		echo "  Please import the public key used to sign ${bibername}-openbsd${OPENBSD_VERSION}.xz"
		echo "  as described on the TeX Live for OpenBSD web page, or verify this file from"
		echo "  the user account that was used to install TeX Live for OpenBSD.  (Assumably,"
		echo "  this user has already imported the public key into his keyring.  Any user"
		echo "  whose keyring contains the public key of TeX Live for OpenBSD can be used.)"
		echo ""
		echo "  The file to be verified can be found here: ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz."
		echo ""
		echo "  Would you like me to attempt to verify the file from an account that has"
		echo "  the public key in its keyring?"
		echo ""
		read whattodo?"[Y]es/[C]ontinue without verifying/[A]bort installation) [Y]: "
		[[ "${whattodo}" == '' ]] && whattodo=y
		case $whattodo in
		    [yY] )
			read username?"Enter any user name whose keyring contains the public key of TeX Live for OpenBSD: "
			chmod 755 ${TMPDIR}
			doas -u ${username} gpg --verify ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz.asc
    			if [[ $? -eq 0 ]];then
			    unxz ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz
			    cp ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION} ${TLBINDIR}/${bibername}
			    chmod +x ${TLBINDIR}/${bibername}
			    echo ""
			    echo "Installation of ${bibername}-openbsd${OPENBSD_VERSION} complete."
    			else
			    exit 1
    			fi
			;;
		    [cC] )
			unxz ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION}.xz
			cp ${TMPDIR}/${bibername}-openbsd${OPENBSD_VERSION} ${TLBINDIR}/${bibername}
			chmod +x ${TLBINDIR}/${bibername}
			echo ""
			echo "Installation of ${bibername}-openbsd${OPENBSD_VERSION} complete."
			;;
		    * )
			echo "Aborting..."
			exit 1
			;;
		esac
	    fi
	else
	    echo "${bibername}-openbsd${OPENBSD_VERSION} is not (yet) available. Please check again later."
	fi
    done
fi