summaryrefslogtreecommitdiff
path: root/getters/ncurses.sh
blob: 2939937a9ddcd5d1bbb382c13d9aed04d3f2594f (plain)
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
#!/usr/bin/env sh

PACKAGES="lib32ncurses-dev
lib32ncurses6
lib32ncursesw6
lib32tinfo6
lib64ncurses-dev
lib64ncurses6
lib64ncursesw6
lib64tinfo6
libncurses-dev
libncurses5
libncurses5-dev
libncurses6
libncursesw5
libncursesw5-dev
libncursesw6
libncursesw6-udeb
libtinfo-dev
libtinfo5
libtinfo6
libtinfo6-udeb
ncurses-base
ncurses-bin
ncurses-doc
ncurses-examples
ncurses-term"

DESTINATION="$(dirname "$0")/../ncurses/"

get_source() {
	echo "$PACKAGES" | while read -r package; do
		apt-file list "$package" | grep -Eo "/usr/share/man/.*"
	done
}

# Copy files to source
get_source | while read -r line; do
	unset CATEGORY
	unset XCATEGORY
	CATEGORY="$(echo "$line" | grep -Eo "[0-9][^.]*\.gz$" | sed 's/\.gz$//')"

	# Check if the category is NX (e.g., 3ncurses -> 3X)
	if [ $(echo "$CATEGORY" | wc -m) -gt 2 ]; then
		XCATEGORY="$(echo "$CATEGORY" | cut -c -1)X"
	fi

	# Copy file, and rename if necessary
	if [ -n "$XCATEGORY" ]; then
		mkdir -p "$DESTINATION/man$XCATEGORY"
		cp "$line" "$DESTINATION/man$XCATEGORY/$(basename "$line" | sed "s/$CATEGORY/$XCATEGORY/")"
	else
		mkdir -p "$DESTINATION/man$CATEGORY"
		cp "$line" "$DESTINATION/man$CATEGORY"
	fi

done