forked from archzfs/archzfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.sh
executable file
·161 lines (126 loc) · 3.94 KB
/
push.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
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
#!/bin/bash
#
# push.sh is a script for pushing the archzfs package sources to AUR as well as
# the archzfs.com website
#
args=("$@")
script_name=$(basename $0)
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
push=0
push_repo=0
if ! source ${script_dir}/lib.sh; then
echo "!! ERROR !! -- Could not load lib.sh!"
exit 155
fi
source_safe "${script_dir}/conf.sh"
usage() {
echo "${script_name} - Pushes the packages sources to AUR using burp."
echo
echo "Usage: ${script_name} [options] [mode]"
echo
echo "Options:"
echo
echo " -h: Show help information."
echo " -n: Dryrun; Output commands, but don't do anything."
echo " -d: Show debug info."
echo " -r: Push the archzfs repositories."
echo " -p: Commit changes and push."
echo
echo "Modes:"
echo
for ml in "${mode_list[@]}"; do
mn=$(echo ${ml} | cut -f2 -d:)
md=$(echo ${ml} | cut -f3 -d:)
if [[ ${#mn} -gt 3 ]]; then
echo -e " ${mn}\t ${md}"
else
echo -e " ${mn}\t\t ${md}"
fi
done
echo " all Select and use all available packages"
echo
echo "Example Usage:"
echo
echo " ${script_name} std :: Show package changes."
echo " ${script_name} std -p :: Push the default package sources."
echo " ${script_name} lts -p :: Push the lts package sources."
exit 155
}
generate_mode_list
if [[ $# -lt 1 ]]; then
usage
fi
for (( a = 0; a < $#; a++ )); do
if [[ ${args[$a]} == "-n" ]]; then
dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
elif [[ ${args[$a]} == "-p" ]]; then
push=1
elif [[ ${args[$a]} == "-r" ]]; then
push_repo=1
elif [[ ${args[$a]} == "-h" ]]; then
usage
else
check_mode "${args[$a]}"
debug "have modes '${modes[*]}'"
fi
done
if [[ ${#modes[@]} -eq 0 && ${push_repo} -eq 0 ]]; then
echo
error "A mode must be selected!"
usage
fi
msg "$(date) :: ${script_name} started..."
push_packages() {
for pkg in "${pkg_list[@]}"; do
msg "Packaging ${pkg}..."
debug "PWD=${PWD}"
run_cmd_no_output "cd \"${script_dir}/packages/${kernel_name}/${pkg}\" && git rev-parse --show-superproject-working-tree"
if [[ -z "${run_cmd_output}" ]]; then
error "${pkg} is not a submodule! Skipping"
continue
fi
local cmd="cd \"${script_dir}/packages/${kernel_name}/${pkg}\" && "
if [[ ${push} -eq 1 ]]; then
if [[ ! -z ${kernel_version_full} ]]; then
vers=$(kernel_version_full_no_hyphen ${kernel_version_full})-${zfs_pkgrel}
elif [[ ! -z ${zfs_pkgver} ]]; then
vers=$zfs_pkgver
else
vers="latest git commit"
fi
cmd+="git --no-pager diff && echo && echo && git checkout master && git add . && "
cmd+="git commit -m 'Semi-automated update for $vers'; git push"
else
cmd+="git --no-pager diff"
fi
run_cmd "${cmd}"
done
}
push_repo() {
if [[ ${dry_run} -eq 1 ]]; then
dry="-n"
elif [[ ${push_repo} -ne 1 ]]; then
return
fi
run_cmd "rsync -vrtlh --delete-before ${repo_basepath}/${repo_name} ${package_backup_dir} webfaction:/home/jalvarez/webapps/default/ ${dry}"
run_cmd_check 1 "Could not push packages to webfaction!"
}
push_repo
if [[ ${#modes[@]} -eq 0 ]]; then
exit
fi
for (( i = 0; i < ${#modes[@]}; i++ )); do
mode=${modes[i]}
kernel_name=${kernel_names[i]}
get_kernel_update_funcs
debug_print_default_vars
export script_dir mode kernel_name
source_safe "src/kernels/${kernel_name}.sh"
for func in "${update_funcs[@]}"; do
debug "Evaluating '${func}'"
"${func}"
push_packages
done
done