-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
189 lines (159 loc) · 4.75 KB
/
Makefile
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Arch 系统配置自动化脚本
#
# Copyright (C) 2019 Cryven <codcodog at gmail dot com>
#
# 配置主要包括:
# - 基本配置
# - 工具安装
# - 工具配置
#
# 主要有以下几部分:
# 1. 基础系统安装,chroot 之后执行:`make`
# 2. 安装 grub (可选)
# - 分区若是 gpt 分区,/boot -> fat32
# - 分区若是 dos 分区,则直接安装 grub 即可
# 3. 初步配置完成之后,重启登录用户帐号,执行:`make install`
# 4. Vim YouCompleteMe 插件只是下载源码回来,并没进行安装
# 详情参考:https://github.com/ycm-core/YouCompleteMe#linux-64-bit
PACMAN = pacman
PACMAN_OPTION = -S --noconfirm
YAY = $(prefix)/yay
prefix ?= /usr/bin
current_dir ?= $(shell pwd)
GIT = $(prefix)/git
GIT_NAME = git
NPM = $(prefix)/npm
NPM_NAME = npm nodejs
GVIM = $(prefix)/gvim
GVIM_NAME = gvim
FZF = $(prefix)/fzf
FZF_NAME = fzf
AG = $(prefix)/ag
AG_NAME = the_silver_searcher
system_config = set_time set_user set_mirrors config_files install_tools
user_name = h2o
home = /home/$(user_name)
vim_dep = $(GIT) $(NPM) $(GVIM) $(FZF) $(AG)
GRUB_NAME = grub
GRUB = $(prefix)/$(GRUB_NAME)
dev_sdx ?= /dev/sda # 硬盘
tools ?= iw wpa_supplicant dialog bash-completion xorg xorg-xinit awesome \
terminator chromium firefox wqy-microhei fcitx fcitx-im fcitx-configtool fcitx-sunpinyin \
shadowsocks-qt5 ranger thunar ntfs-3g gvfs-mtp gvim httpie mysql-workbench bat ctags feh \
arandr openssh flameshot docker docker-compose cmake netctl dhcpcd tldr
aur_tools ?= xmind okular mycli office-code-pro
.PHONY: all
all: $(system_config)
@echo ''
@echo -e '\033[0;31mInitializing Arch System Done, But System Boot Not Installed Yet.\033[0m'
@echo -e '\033[0;31mRun `make grub` or install it manually.\033[0m'
@echo ''
.PHONY: set_time
set_time:
@echo ''
@echo 'Config charset and timezone.'
@sed -i -e '/#en_US\.UTF-8/s/^.//' -e '/#zh_CN\.UTF-8/s/^.//' /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
@$(PACMAN) $(PACMAN_OPTION) openntpd
@systemctl enable openntpd
.PHONY: set_user
set_user:
@echo ''
@echo 'Config User.'
echo codcodog > /etc/hostname
@echo ''
@echo 'Set password for root.'
@passwd
useradd -m -g users -G wheel,storage,power -s /bin/bash $(user_name)
@echo ''
@echo 'Set password for $(user_name)'
@passwd $(user_name)
@sed -i '/# %wheel ALL=(ALL) ALL/s/^..//' /etc/sudoers
.PHONY: set_mirrors
set_mirrors:
@echo ''
@echo 'Config mirrors.'
@sed -i '6 a # China\
Server = http://mirrors.163.com/archlinux/$$repo/os/$$arch\
Server = http://mirrors.aliyun.com/archlinux/$$repo/os/$$arch\
Server = http://mirrors.sohu.com/archlinux/$$repo/os/$$arch' /etc/pacman.d/mirrorlist
.PHONY: install_tools
install_tools:
@echo ''
@echo 'Install tools.'
@$(PACMAN) $(PACMAN_OPTION) $(tools)
$(home): set_user
.PHONY: config_files
config_files: $(home)
@echo ''
@echo 'Config tools.'
cp -f $(current_dir)/.Xmodmap $(home)
cp -f $(current_dir)/.bashrc $(home)
cp -f $(current_dir)/.gitconfig $(home)
cp -f $(current_dir)/.xinitrc $(home)
@if [[ ! -d $(home)/.config/awesome ]] ; then \
mkdir -p $(home)/.config/awesome; \
fi
@if [[ ! -d $(home)/.config/terminator ]] ; then \
mkdir -p $(home)/.config/terminator; \
fi
cp -f $(current_dir)/config $(home)/.config/terminator/config
cp -f $(current_dir)/rc.lua $(home)/.config/awesome/rc.lua
chown -R $(user_name):users $(home)/.config # Note: give permission back to user.
$(GRUB):
@$(PACMAN) $(PACMAN_OPTION) $(GRUB_NAME)
.PHONY: grub
grub: $(GRUB)
@echo ''
@echo 'Install grub'
grub-install --target=i386-pc --recheck $(dev_sdx)
grub-mkconfig -o /boot/grub/grub.cfg
$(YAY):
@echo ''
@echo 'Install yay.'
@if [[ -d /tmp/yay ]] ; then \
rm -rf /tmp/yay; \
fi
git clone https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay && makepkg -si
install: aur_tools vim
.PHONY: aur_tools
aur_tools: $(YAY)
@$(YAY) $(PACMAN_OPTION) $(aur_tools)
@systemctl restart openntpd # restart to adjust time.
.PHONY: docker_config
docker_config:
@echo ''
@echo 'Docker config for no sudo.'
@sudo groupadd docker || true
@sudo usermod -aG docker $$USER
$(GIT):
@echo ''
@echo 'Install $(GIT_NAME).'
@$(YAY) $(PACMAN_OPTION) $(GIT_NAME)
$(NPM):
@echo ''
@echo 'Install $(NPM_NAME).'
@$(YAY) $(PACMAN_OPTION) $(NPM_NAME)
@sudo $(NPM) install -g instant-markdown-d
$(GVIM):
@echo ''
@echo 'Install $(GVIM_NAME)'
@$(YAY) $(PACMAN_OPTION) $(GVIM_NAME)
$(FZF):
@echo ''
@echo 'Install $(FZF_NAME)'
@$(YAY) $(PACMAN_OPTION) $(FZF_NAME)
cp -f /usr/share/fzf/key-bindings.bash ~/.fzf.bash
$(AG):
@echo ''
@echo 'Install $(AG_NAME)'
@$(YAY) $(PACMAN_OPTION) $(AG_NAME)
.PHONY: vim
vim: $(vim_dep)
@echo ''
@echo 'Vim config.'
cp -rf $(current_dir)/.vim ~
cp -f $(current_dir)/.vimrc ~