-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-macos.sh
More file actions
executable file
·79 lines (61 loc) · 2.36 KB
/
Copy pathinstall-macos.sh
File metadata and controls
executable file
·79 lines (61 loc) · 2.36 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
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
# CS3223 Assignment 1
# Script to install PostgreSQL 17.2 on MacOS
source ./settings.sh
VERSION=17.2
ASSIGN_DIR=$HOME/NUS/Y3S2/CS3223/assignments/cs3223_assign1
DOWNLOAD_DIR=$HOME
SRC_DIR=${DOWNLOAD_DIR}/postgresql-${VERSION}
FILE=postgresql-${VERSION}.tar.gz
mkdir -p ${DOWNLOAD_DIR}
mkdir -p ${INSTALL_DIR}
mkdir -p ${PGDATA}
# Download PostgreSQL source files
if [ ! -e ${DOWNLOAD_DIR}/${FILE} ]; then
cd ${DOWNLOAD_DIR}
wget https://ftp.postgresql.org/pub/source/v${VERSION}/${FILE}
tar xvfz ${FILE}
fi
# Install PostgreSQL
cd ${SRC_DIR}
export CFLAGS="-O0"
# To process the Postgres documentation, you need to install additional tools.
# The following 2 lines should work on both Mac Intel and ARM.
# For MacPorts alternatives,
# see: https://www.postgresql.org/docs/current/docguide-toolsets.html#DOCGUIDE-TOOLSETS-INST-MACOS
# Remember to install Homebrew if you haven't!
brew install docbook docbook-xsl libxslt fop
export XML_CATALOG_FILES=$(brew --prefix)/etc/xml/catalog
# You may need to find the path to the icu4c package and add it to PKG_CONFIG_PATH variable
# This package is needed to build Postgres 17.2.
# The following line should work on both Mac Intel and ARM.
# If you still get an error, you may need to change the path slightly,
# see: https://viggy28.dev/article/postgres-v16-icu-installation-issue/
export PKG_CONFIG_PATH=$(brew --prefix icu4c)/lib/pkgconfig/:$PKG_CONFIG_PATH
./configure --prefix=${INSTALL_DIR} --enable-debug --enable-cassert
make clean && make world && make install
# Install test_bufmgr extension
if [ ! -d ${ASSIGN_DIR} ]; then
echo "Error: Assignment directory ${ASSIGN_DIR} missing!"
exit 1
fi
if [ ! -d ${SRC_DIR}/contrib/test_bufmgr ]; then
cp -r ${ASSIGN_DIR}/test_bufmgr ${SRC_DIR}/contrib
cd ${SRC_DIR}/contrib/test_bufmgr
make && make install
fi
chmod u+x ${ASSIGN_DIR}/*.sh
# Create a new database cluster.
if [ -d ${PGDATA} ]; then
rm -Rf ${PGDATA}
fi
${INSTALL_DIR}/bin/initdb -D ${PGDATA}
# Update ~/.zshrc
PROFILE=~/.zshrc # Change to ~/.bash_profile if your default shell is bash
echo >> ${PROFILE}
echo "export PATH=${INSTALL_DIR}/bin:\$PATH" >> ${PROFILE}
echo "export MANPATH=${INSTALL_DIR}/share/man:\$MANPATH" >> ${PROFILE}
echo "export PGDATA=${PGDATA}" >> ${PROFILE}
echo "export PGUSER=$(whoami)" >> ${PROFILE}
echo >> ${PROFILE}
exec zsh # Restart the shell. Use "source ~/.bash_profile" for bash