blob: 5b135243cba4a6c59c3c9515849f178bb9550552 (
plain) (
blame)
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
|
#!/bin/sh
## Abraham Porter - do things with ports
## Configuration
doas="doas"
terminal="alacritty"
pager="rofi -location 2 -width -81 -e"
## Error codes
OK=0
NO_ACTION_PROVIDED=3
NO_PORT_PROVIDED=4
NO_PKG_DESCR_FOUND=5
NO_WANT_ANOTHER_PROVIDED=6
## Lets user choose a port from a list of FreshPorts search results.
search_port() {
query="$(dmenu -p 'Search?')"
fetch -qo - "https://www.freshports.org/search.php?stype=name&method=match&num=500&format=plaintext&query=$query"\
| dmenu -p "Port?"
}
## Gets an action from the user with dmenu
get_action() {
action=$(dmenu -p "Abraham Porter" << EOH
1. print pkg-descr
2. set options
3. set options, add to pkglist
4. set options, build pkg
5. set options, build pkg, add to pkglist
6. add to pkglist
7. set options on pkglist
8. build entire pkglist (lengthy and intensive!)
EOH
)
echo "$action" | cut -d'.' -f1
}
### Handle printing a package description file
#handle_print_pkg_desc() {
# port=$(get_port)
# [ -z $port ] && exit $NO_PORT_PROVIDED
# pkg_descr="$ports_dir"/$port/pkg-descr
# [ ! -f "$pkg_descr" ] && exit $NO_PKG_DESCR_FOUND
# text=$(cat "$ports_dir"/$port/pkg-descr)
# $pager "$text"
#}
### Handle appending a port to the pkglist. Skips appending if already present
#handle_append_pkglist() {
# port="$1"
# grep -q $port "$pkglist" && exit $OK
# cp "$pkglist" "$pkglist".bak
# echo $port >> "$pkglist"
# sort "$pkglist" -o "$pkglist"
# echo $port
#}
### Handle running poudriere options on a single port
#handle_poudriere_options_single() {
# port="$1"
# $terminal -e $doas poudriere options -c $port
# echo $port
#}
### Handle running poudriere bulk on a single port
#handle_poudriere_bulk_single() {
# port="$1"
# notify-send "Poudriere bulk started" "$port"
# $terminal -e $doas poudriere bulk -j "$jail" $port
# notify-send "Poudriere bulk finished" "$port"
#}
### Handle running poudriere options on pkglist
#handle_poudriere_options_pkglist() {
# $terminal -e $doas poudriere options -f "$pkglist"
#}
### Handle running poudriere bulk on pkglist
#handle_poudriere_bulk_pkglist() {
# notify-send "Poudriere bulk started" "(pkglist)"
# $terminal -e $doas poudriere bulk -j "$jail" -f "$pkglist"
# notify-send "Poudriere bulk finished" "(pkglist)"
#}
get_another() {
choice=$(dmenu -p "Do you want another?" << EOH
no
yes
EOH
)
[ $choice = "no" ] && return 1
[ $choice = "yes" ] && return 0
exit $NO_WANT_ANOTHER_PROVIDED
}
## Main
while true ; do
port="$(search_port)"
#action=$(get_action)
#case $action in
# 1)
# # 1. print pkg-descr
# handle_print_pkg_desc
# ;;
# 2)
# # 2. set options
# handle_poudriere_options_single $(get_port)
# ;;
# 3)
# # 3. set options, add to pkglist
# handle_poudriere_options_single $(handle_append_pkglist $(get_port))
# ;;
# 4)
# # 4. set options, build pkg
# handle_poudriere_bulk_single $(handle_poudriere_options_single $(get_port))
# ;;
# 5)
# # 5. set options, build pkg, add to pkglist
# handle_poudriere_bulk_single $(handle_poudriere_options_single $(handle_append_pkglist $(get_port)))
# ;;
# 6)
# # 6. add to pkglist
# handle_append_pkglist $(get_port)
# ;;
# 7)
# # 7. set options on pkglist
# handle_poudriere_options_pkglist
# ;;
# 8)
# # 8. build entire pkglist (lengthy and intensive!)
# handle_poudriere_bulk_pkglist
# ;;
# *)
# exit $NO_ACTION_PROVIDED
# ;;
#esac
echo $port
get_another || exit $OK
done
|