-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-everything
More file actions
executable file
·123 lines (117 loc) · 4.63 KB
/
update-everything
File metadata and controls
executable file
·123 lines (117 loc) · 4.63 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#! /usr/local/bin/python3
import argparse
import subprocess
def updateEveryting(args):
if not (args.python or args.brew or args.conda or args.vim or args.vim
or args.explicit):
subprocess.run(
"brew update && brew upgrade && brew cask upgrade && brew cleanup --prune=14",
shell=True)
subprocess.run(
"pip3 freeze --all | sed 's/==.*//g' | pip3 install -U -r /dev/stdin -c ~/.packages/pip_frozen.req",
shell=True,
)
subprocess.run(
"pipdeptree | grep '^[a-z,A-Z]' | sed 's/==.*//' | pip3 install -U -r /dev/stdin",
shell=True)
subprocess.run("vim +PackUpdateClose", shell=True)
subprocess.run("env ZSH=$ZSH sh $ZSH/tools/upgrade.sh", shell=True)
if args.brew:
subprocess.run("brew update && brew upgrade", shell=True)
if args.python:
# This will fix the versions listed in pip_frozen.req
subprocess.run(
r"pip3 freeze --all | sed 's/==.*//g' | pip3 install -U -r /dev/stdin -c ~/.packages/pip_frozen.req",
shell=True,
)
subprocess.run(
"pipdeptree | grep '^[a-z,A-Z]' | sed 's/==.*//' | pip3 install -U -r /dev/stdin",
shell=True)
if args.conda:
subprocess.run("conda upgrade -y --all", shell=True)
if args.vim:
subprocess.run("vim +PackUpdateClose", shell=True)
if args.zsh:
subprocess.run("env ZSH=$ZSH sh $ZSH/tools/upgrade.sh", shell=True)
if args.gem:
subprocess.run("gem update", shell=True)
if args.ycm:
subprocess.run(
"git -C ~/.vim/pack/minpac/start/YouCompleteMe/ submodule update --init --recursive",
shell=True)
subprocess.run(
"python3 ~/.vim/pack/minpac/start/YouCompleteMe/install.py",
shell=True)
if args.clean:
subprocess.run("brew cleanup; gem cleanup; conda clean --all -y",
shell=True)
if args.backup:
subprocess.run(r"brew ls | sed 's/ /\r/g' > ~/.packages/brew.req",
shell=True)
subprocess.run(r"brew cask ls | sed 's/ /\r/g' > ~/.packages/brew.req",
shell=True)
subprocess.run(r"pip3 freeze > ~/.packages/python.req", shell=True)
subprocess.run("gem list > ~/.packages/gems.req", shell=True)
subprocess.run(
"bup index /Users/admin --exclude-from='/Users/admin/.bup_ignore' && bup save -n dotfiles /Users/admin",
shell=True,
)
subprocess.run(
"git -C $HOME add .packages && git -C $HOME commit -am 'Backup' && git -C $HOME push",
shell=True,
)
parser = argparse.ArgumentParser(
description=
"Updates system package managers. With no arguments pip3, conda, vim plugins, oh_my_zsh and homebrew will be updated. Called with arguments only the given package managers will be updated. With the exception of gem. Running with no flags is equivalent to update-everything -pcvbz."
)
parser.add_argument("--python",
"-p",
action="store_true",
help="Update all pip3 packages.")
parser.add_argument(
"--conda",
"-c",
action="store_true",
help="Update all conda packages, no confirmation.",
)
parser.add_argument("--vim",
"-v",
action="store_true",
help="Update all vundle plugins.")
parser.add_argument("--brew",
"-b",
action="store_true",
help="Update all homebrew packages.")
parser.add_argument("--zsh",
"-z",
action="store_true",
help="Update Oh My ZSH.")
parser.add_argument("--gem",
"-g",
action="store_true",
help="Update ruby gems.")
parser.add_argument("--ycm",
"-y",
action="store_true",
help="Recompile the YouCompleteMe vim plugin.")
parser.add_argument(
"--explicit",
"-e",
action="store_true",
help="Only update package managers passed explicitly by flag.",
)
parser.add_argument(
"--clean",
action="store_true",
help=
"Cleanup caches, unused or intermediate files. Used in the obvious way in brew and gem commands.",
)
parser.add_argument(
"--backup",
action="store_true",
help=
"Backup dotfiles to ~/Dropbox/Documents/backups/dotfiles. This also saves a list of installed python, brew, and gem packages into requirements files in ~/.packages",
)
args = parser.parse_args()
if __name__ == "__main__":
updateEveryting(args)