-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_packages.sh
executable file
·71 lines (60 loc) · 1.54 KB
/
update_packages.sh
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
#!/bin/bash
# This updates Homebrew, MacPorts, the az command, and pre-commit (if any of these are installed). Also, cleans up afterwards.
echo="/bin/echo"
find="/usr/bin/find"
pip3="/usr/local/bin/pip3"
port="/opt/local/bin/port"
precommit="/Library/Frameworks/Python.framework/Versions/Current/bin/pre-commit"
pwd="/bin/pwd"
sudo="/usr/bin/sudo"
uname="/usr/bin/uname"
# Homebrew installs the 'brew' and 'az' commands at different paths if you're running Apple Silicon vs. Intel:
processor_type=$(${uname} -m)
if [ "${processor_type}" == "arm64" ]; then
brew="/opt/homebrew/bin/brew"
else
brew="/usr/local/bin/brew"
fi
# update homebrew
if [ -e ${brew} ]; then
${brew} update
${brew} upgrade
${brew} cleanup
else
${echo} "Homebrew not found."
fi
if [ "${processor_type}" == "arm64" ]; then
az="/opt/homebrew/bin/az"
else
az="/usr/local/bin/az"
fi
# update az cli
if [ -e ${az} ]; then
${az} upgrade
else
${echo} "az command not found."
fi
# update pip
if [ -e ${pip3} ]; then
${pip3} install --upgrade pip
else
${echo} "Please install Python to use pip."
fi
# update pre-commit
if [ -e ${pip3} ]; then
${pip3} install pre-commit
${find} ~/Documents -type f -name ".pre-commit-config.yaml" -execdir ${pwd} \; -execdir ${precommit} autoupdate \;
else
${echo} "Please install Python to use pre-commit."
fi
# update macports
if [ -e ${port} ]; then
${sudo} ${port} selfupdate
${sudo} ${port} upgrade outdated
${sudo} ${port} uninstall inactive
${sudo} ${port} uninstall leaves
${sudo} ${port} reclaim
else
${echo} "MacPorts not found."
fi
exit