summaryrefslogtreecommitdiff
blob: 6387e3be82da0eb04269fb4fcb48fdc5d2b7d0d0 (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
58
59
60
61
62
63
#!/usr/bin/gawk -f
# Copyright 2019-2023 Gentoo Authors
# Distributed under the terms of the MIT license

BEGIN {
	print "<!-- DO NOT EDIT, generated automatically by uidgid2wiki.awk -->"
	print "{|class=\"wikitable sortable\""
	print "! Name"
	print "! data-sort-type=\"number\" | UID"
	print "! data-sort-type=\"number\" | GID"
	print "! Provider"
	print "! class=unsortable | Notes"
}

function md2wiki(str) {
	return gensub(/\[([^\]]+)\]\(([^)]+)\)/, "[\\2 \\1]", "g", str)
}

/^[^#]/ {
	print "|-"
	# name
	print "| " $1
	# uid
	print "| " $2
	# gid
	print "| " $3
	# provider
	switch ($4) {
		case "baselayout":
			print "| style=\"background: #cff;\" | baselayout (linux)"
			break
		case "baselayout-fbsd":
			print "| style=\"background: #ccf;\" | baselayout (fbsd)"
			break
		case "acct":
			printf "%s", "| style=\"background: #9fc;\" |"
			if ($2 != "-") printf " %s", "[https://gitweb.gentoo.org/repo/gentoo.git/tree/acct-user/" $1 " u:" $1 "]"
			if ($3 != "-") printf " %s", "[https://gitweb.gentoo.org/repo/gentoo.git/tree/acct-group/" $1 " g:" $1 "]"
			print ""
			break
		case "requested":
			print "| style=\"background: #ffe;\" | requested"
			break
		case "reserved":
			print "| style=\"background: #fcf;\" | reserved"
			break
		case "user.eclass":
			print "| style=\"background: #dca;\" | user.eclass"
			break
		case "historical":
			print "| style=\"background: #fee;\" | historical"
			break
		default:
			print "| " $4
	}
	# notes
	$1=$2=$3=$4=""
	print gensub(/[ \t]+$/, "", 1, "| " md2wiki(substr($0, 5)))
}

END {
	print "|}"
}