-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild-and-install.sh
More file actions
executable file
·70 lines (59 loc) · 2 KB
/
Copy pathbuild-and-install.sh
File metadata and controls
executable file
·70 lines (59 loc) · 2 KB
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
#!/usr/bin/env bash
# build-and-install.sh by Wouter Wijsman (wwijsman@live.nl)
# Exit on errors
set -e
## Remove $CC and $CXX for configure
unset CC
unset CXX
## Make sure PSPDEV is set
if [ -z "${PSPDEV}" ]; then
echo "The PSPDEV environment variable has not been set"
exit 1
fi
## Enter the script directory.
cd "$(dirname "$0")"
WORKDIR="${PWD}"
## MacOS specific environment variables
if [ "$(uname -s)" == "Darwin" ]; then
export PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$(brew --prefix bash)/bin:$PATH"
export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig"
fi
## Clean up from previous builds
rm -rf temp_build pkg src psp-pacman-*-*.pkg.tar.gz
## Install makepkg from source if it isn't already available and build the package
if ! which makepkg > /dev/null; then
echo "Did not find makepkg, downloading and building pacman from source"
source PSPBUILD
export pkgdir="${PWD}/temp_build/psp-pacman"
mkdir -p "${pkgdir}"
rm -rf pacman-v${pkgver}
wget -nc ${source[0]}
tar -xvf pacman-v${pkgver}.tar.gz
prepare
cd "$WORKDIR"
build
cd "$WORKDIR"
package
cd "$WORKDIR"
export PATH="${pkgdir}/share/pacman/bin:${PATH}"
if (( EUID == 0 )); then
CARCH="$(./get-arch)" PSPDEV="${pkgdir}" makepkg -p PSPBUILD --asroot .
else
CARCH="$(./get-arch)" PSPDEV="${pkgdir}" makepkg -p PSPBUILD .
fi
else
CARCH="$(./get-arch)" makepkg -p PSPBUILD .
fi
## Create the required directories for installation
mkdir -m 755 -p "${PSPDEV}/var/lib/pacman"
## Add the directory with pacman's binaries to the start of the PATH
export PATH="${PWD}/pkg/psp-pacman/share/pacman/bin:${PATH}"
export LD_LIBRARY_PATH="${PWD}/pkg/psp-pacman/lib:${LD_LIBRARY_PATH}"
## The package in $PSPDEV using the pacman that was build
./pkg/psp-pacman/share/pacman/bin/pacman \
--root "${PSPDEV}" \
--dbpath "${PSPDEV}/var/lib/pacman" \
--config "pacman.conf" \
--arch "$(./get-arch)" \
--noconfirm \
-U psp-pacman-*-*.pkg.tar.gz