[gentoo-commits] data/api:master commit in: bin/

2023-07-24 Thread Sam James
commit: b4178a2fb069cc26372d3d29b165404bb362bbe2
Author: Sam James  gentoo  org>
AuthorDate: Tue Jul 25 02:08:40 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jul 25 02:08:40 2023 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=b4178a2f

bin: uidgid2wiki.awk needs gawk

Signed-off-by: Sam James  gentoo.org>

 bin/uidgid2wiki.awk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/uidgid2wiki.awk b/bin/uidgid2wiki.awk
index ed95994..6387e3b 100755
--- a/bin/uidgid2wiki.awk
+++ b/bin/uidgid2wiki.awk
@@ -1,5 +1,5 @@
-#!/usr/bin/awk -f
-# Copyright 2019-2021 Gentoo Authors
+#!/usr/bin/gawk -f
+# Copyright 2019-2023 Gentoo Authors
 # Distributed under the terms of the MIT license
 
 BEGIN {



[gentoo-commits] data/api:master commit in: bin/

2021-11-18 Thread Ulrich Müller
commit: 858cf068305e58a918ad60cc0337b8dc13e75cf5
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Nov 15 08:03:07 2021 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Mon Nov 15 13:46:19 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=858cf068

used_free_uidgids.sh: Make the recommended IDs stand out

By moving this output to the end and adding some colour.

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/used_free_uidgids.sh | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index 1838f11..dae2517 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -305,9 +305,14 @@ for r in "${selection_ranges[@]}"; do
(( free_total_pair += freepair ))
 done
 
-echo "Recommended GID only: ${gidonly:-${uidgidboth:-none}}"
-echo "Recommended UID only: ${uidonly:=${uidgidboth:-none}}"
-echo "Recommended UID+GID pair: ${uidgidboth:-none}"
 echo "Free UIDs: ${free_total_uid}"
 echo "Free GIDs: ${free_total_gid}"
 echo "Free UID+GID pairs: ${free_total_pair}"
+echo
+
+for out in "Recommended GID only: ${gidonly:-${uidgidboth:-none}}" \
+  "Recommended UID only: ${uidonly:-${uidgidboth:-none}}" \
+  "Recommended UID+GID pair: ${uidgidboth:-none}"; do
+[[ ${out} == *none ]] && colour=${colour_USED} || colour=${colour_FREE}
+echo -e "${out%%: *}: ${colour}${out#*: }${colour_RESET}"
+done



[gentoo-commits] data/api:master commit in: bin/, files/

2021-11-14 Thread Ulrich Müller
commit: 0dbd1739a5676f4a67a1bd448548b46a886edbc8
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sun Nov 14 19:46:22 2021 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Nov 14 19:46:22 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=0dbd1739

uid-gid.txt, used_free_uidgids.sh: Open 500..749 range

Per today's Council decision.

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/used_free_uidgids.sh | 2 +-
 files/uid-gid.txt| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index ff5fa31..1838f11 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -13,7 +13,7 @@
 #
 selection_ranges=(
499-101
-   #500-799
+   500-749
#60001-60999
 )
 debug=${debug:+1} # set non-zero to enable debug output.

diff --git a/files/uid-gid.txt b/files/uid-gid.txt
index f45905f..c164a25 100644
--- a/files/uid-gid.txt
+++ b/files/uid-gid.txt
@@ -591,8 +591,8 @@ strelaysrv  496 496 
acct
 stdiscosrv 497 497 
acct
 burp   498 498 
acct
 syncthing  499 499 
acct
--  500..999500..999
reservedDynamic allocation by user.eclass. Do not use!
 slurm  500 500 
historical  Moved to 400
+-  750..999750..999
reservedDynamic allocation by user.eclass. Do not use!
 -  1000..6 1000..6 
reserved`UID_MIN`..`UID_MAX` / `GID_MIN`..`GID_MAX` in login.defs
 ventrilo   37843784
historical  Used by media-sound/ventrilo-server-bin, removed in 
[15c6a556cef2](https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=15c6a556cef202a72f7226648ebea19fcffe834d)
 -  60001..6553360001..65532
reserved



[gentoo-commits] data/api:master commit in: bin/

2021-11-13 Thread Ulrich Müller
commit: dfe2af855cc35367bc2eae5d4be240d0c56515ba
Author: Jaco Kroon  uls  co  za>
AuthorDate: Fri Nov 12 18:24:20 2021 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sat Nov 13 20:08:44 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=dfe2af85

used_free_uidgids.sh: permit multiple ranges, and adjust stats accordingly.

Closes: https://github.com/gentoo/api-gentoo-org/pull/445
Signed-off-by: Jaco Kroon  uls.co.za>
[For now, comment out the additional ranges.]
Signed-off-by: Ulrich Müller  gentoo.org>

 bin/used_free_uidgids.sh | 205 +--
 1 file changed, 127 insertions(+), 78 deletions(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index bbc04e9..ff5fa31 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -7,12 +7,15 @@
 # So that you can contact me if you need help with the below insanity.
 #
 # Configuration options:
-# max => maximum value of uid/gid that we're interested in/willing to allocate
-#  from.  Can be set to - to go maximum possible 32-bit value.
+# selection_ranges => an array of start-stop values.  There is an assumption of
+#  incremental ordering, ie, start values should be in incrementing order, and
 # debug => if non-zero outputs some cryptic debug output (will inherit from 
environment).
 #
-min=101
-max=499
+selection_ranges=(
+   499-101
+   #500-799
+   #60001-60999
+)
 debug=${debug:+1} # set non-zero to enable debug output.
 
 #
@@ -172,93 +175,139 @@ fi
 
 ui=0 # index into uids array.
 gi=0 # index into gids array.
-idbase=${min} # "start" of range about to be output.
-freeuid=0 # count number of free UIDs
-freegid=0 # count number of free GIDs
-freepair=0 # count number of free UID+GID pairs.
 
-printf "%-*s%10s%10s\n" $(( ${#max} * 2 + 5 )) "#ID" UID GID
+free_total_uid=0
+free_total_gid=0
+free_total_pair=0
 
-while [[ ${idbase} -le ${max} ]]; do
-   # skip over uid and gid ranges that we're no longer interested in (end 
of range is
-   # lower than start of output range).
-   while [[ ${ui} -lt ${#uids[@]} && ${ranges_uid[uids[ui]]} -lt ${idbase} 
]]; do
-   (( ui++ ))
-   done
-   while [[ ${gi} -lt ${#gids[@]} && ${ranges_gid[gids[gi]]} -lt ${idbase} 
]]; do
-   (( gi++ ))
-   done
-   # Assume that range we're going to output is the remainder of the legal
-   # space we're interested in, and then adjust downwards as needed.  For 
each
-   # of the UID and GID space, if the start range is beyond the current 
output
-   # start we're looking at a FREE range, so downward adjust re (range 
end) to
-   # the next non-FREE range's start - 1, or if we're in the non-FREE 
range,
-   # adjust downward to that range's end.
-   re=${max}
-   uid_start=-1
-   gid_start=-1
-   if [[ ${ui} -lt ${#uids[@]} ]]; then
-   uid_start=${uids[ui]}
-   if [[ ${uid_start} -gt ${idbase} && ${uid_start} -le ${re} ]]; 
then
-   re=$(( ${uid_start} - 1 ))
-   fi
-   if [[ ${ranges_uid[uid_start]} -lt ${re} ]]; then
-   re=${ranges_uid[uid_start]}
-   fi
+for r in "${selection_ranges[@]}"; do
+   min=${r%-*} # "start" of range about to be output.
+   max=${r#*-} # "end" of range about to be output.
+   selection=min
+   if [[ $max -lt $min ]]; then
+   selection=max
+   t=${max}
+   max=${min}
+   min=${t}
fi
-   if [[ ${gi} -lt ${#gids[@]} ]]; then
-   gid_start=${gids[gi]}
-   if [[ ${gid_start} -gt ${idbase} && ${gid_start} -le ${re} ]]; 
then
-   re=$(( ${gid_start} - 1 ))
+
+   freeuid=0 # count number of free UIDs
+   freegid=0 # count number of free GIDs
+   freepair=0 # count number of free UID+GID pairs.
+
+   echo "Range: ${min}..${max} (${selection})"
+   printf "%-*s%10s%10s\n" $(( ${#max} * 2 + 5 )) "#ID" UID GID
+
+   idbase=${min}
+   while [[ ${idbase} -le ${max} ]]; do
+   # skip over uid and gid ranges that we're no longer interested 
in (end of range is
+   # lower than start of output range).
+   while [[ ${ui} -lt ${#uids[@]} && ${ranges_uid[uids[ui]]} -lt 
${idbase} ]]; do
+   (( ui++ ))
+   done
+   while [[ ${gi} -lt ${#gids[@]} && ${ranges_gid[gids[gi]]} -lt 
${idbase} ]]; do
+   (( gi++ ))
+   done
+   # Assume that range we're going to output is the remainder of 
the legal
+   # space we're interested in, and then adjust downwards as 
needed.  For each
+   # of the UID and GID space, if the start range is beyond the 
current output
+   # start we're looking at a FREE range, so downward adjust re 
(range end) to
+   # the next 

[gentoo-commits] data/api:master commit in: bin/

2021-11-11 Thread Ulrich Müller
commit: 00c33ca0ad587cd1d0097c20eb3f5bb966c6153f
Author: Ulrich Müller  gentoo  org>
AuthorDate: Thu Nov 11 10:46:20 2021 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Thu Nov 11 10:46:20 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=00c33ca0

used_free_uidgids.sh: Don't recommend ids below 100

By QA policy, these ids require explicit approval by the QA lead:
https://projects.gentoo.org/qa/policy-guide/user-group.html#pg0901

Signed-off-by: Ulrich Müller  gentoo.org>

 bin/used_free_uidgids.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index 24eafec..bbc04e9 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -11,6 +11,7 @@
 #  from.  Can be set to - to go maximum possible 32-bit value.
 # debug => if non-zero outputs some cryptic debug output (will inherit from 
environment).
 #
+min=101
 max=499
 debug=${debug:+1} # set non-zero to enable debug output.
 
@@ -171,7 +172,7 @@ fi
 
 ui=0 # index into uids array.
 gi=0 # index into gids array.
-idbase=0 # "start" of range about to be output.
+idbase=${min} # "start" of range about to be output.
 freeuid=0 # count number of free UIDs
 freegid=0 # count number of free GIDs
 freepair=0 # count number of free UID+GID pairs.



[gentoo-commits] data/api:master commit in: bin/

2021-02-17 Thread Joonas Niilola
commit: 0903218476eb66882c2375b37d81846e04caa109
Author: Joonas Niilola  gentoo  org>
AuthorDate: Wed Feb 17 15:38:58 2021 +
Commit: Joonas Niilola  gentoo  org>
CommitDate: Wed Feb 17 15:38:58 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=09032184

used_free_uidgids.sh: start counting down from 499

 - as 500 is reserved for dynamic allocation already.

Suggested-by: ulm
Signed-off-by: Joonas Niilola  gentoo.org>

 bin/used_free_uidgids.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index 7373736..24eafec 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -11,7 +11,7 @@
 #  from.  Can be set to - to go maximum possible 32-bit value.
 # debug => if non-zero outputs some cryptic debug output (will inherit from 
environment).
 #
-max=500
+max=499
 debug=${debug:+1} # set non-zero to enable debug output.
 
 #



[gentoo-commits] data/api:master commit in: bin/

2021-02-10 Thread Joonas Niilola
commit: de46c1117c4c8b88e78533cf3ac7ca78f641ca60
Author: Joonas Niilola  gentoo  org>
AuthorDate: Wed Feb 10 11:12:58 2021 +
Commit: Joonas Niilola  gentoo  org>
CommitDate: Wed Feb 10 11:12:58 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=de46c111

used_free_uidgids.sh: print "recommended pair"

Signed-off-by: Joonas Niilola  gentoo.org>

 bin/used_free_uidgids.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index 24cd682..7373736 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -257,7 +257,7 @@ done
 
 echo "Recommended GID only: ${gidonly:-${uidgidboth:-none}}"
 echo "Recommended UID only: ${uidonly:=${uidgidboth:-none}}"
-echo "Recommended UID+GID both: ${uidgidboth:-none}"
+echo "Recommended UID+GID pair: ${uidgidboth:-none}"
 echo "Free UIDs: ${freeuid}"
 echo "Free GIDs: ${freegid}"
 echo "Free UID+GID pairs: ${freepair}"



[gentoo-commits] data/api:master commit in: bin/

2021-02-10 Thread Joonas Niilola
commit: b445c58ef8f61c4794da60af3ab18b3fec33f78c
Author: Jaco Kroon  iewc  co  za>
AuthorDate: Wed Feb 10 07:44:27 2021 +
Commit: Joonas Niilola  gentoo  org>
CommitDate: Wed Feb 10 11:11:34 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=b445c58e

used_free_uidgids.sh: Also count the free UID+GID pairs.

Signed-off-by: Jaco Kroon  iewc.co.za>
Closes: https://github.com/gentoo/api-gentoo-org/pull/367
Signed-off-by: Joonas Niilola  gentoo.org>

 bin/used_free_uidgids.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index 3b43ac9..24cd682 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -174,6 +174,7 @@ gi=0 # index into gids array.
 idbase=0 # "start" of range about to be output.
 freeuid=0 # count number of free UIDs
 freegid=0 # count number of free GIDs
+freepair=0 # count number of free UID+GID pairs.
 
 printf "%-*s%10s%10s\n" $(( ${#max} * 2 + 5 )) "#ID" UID GID
 
@@ -238,6 +239,7 @@ while [[ ${idbase} -le ${max} ]]; do
if [[ "${gidstate}" == FREE ]]; then
if [[ "${uidstate}" == FREE ]]; then
uidgidboth=${re}
+   freepair=$(( freepair + re - idbase + 1 ))
else
gidonly=${re}
fi
@@ -258,3 +260,4 @@ echo "Recommended UID only: ${uidonly:=${uidgidboth:-none}}"
 echo "Recommended UID+GID both: ${uidgidboth:-none}"
 echo "Free UIDs: ${freeuid}"
 echo "Free GIDs: ${freegid}"
+echo "Free UID+GID pairs: ${freepair}"



[gentoo-commits] data/api:master commit in: bin/

2021-02-09 Thread Joonas Niilola
commit: 90316d9f915d2e0767b3b09cf2ec7d0cff9e8d06
Author: Jaco Kroon  iewc  co  za>
AuthorDate: Tue Feb  9 08:25:02 2021 +
Commit: Joonas Niilola  gentoo  org>
CommitDate: Tue Feb  9 08:45:21 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=90316d9f

used_free_uidgids.sh: syntax fixup

 bin/used_free_uidgids.sh: line 95: reasons{range_end+1]=RESERVED: 
command not found

Signed-off-by: Jaco Kroon  iewc.co.za>
Closes: https://github.com/gentoo/api-gentoo-org/pull/366
Signed-off-by: Joonas Niilola  gentoo.org>

 bin/used_free_uidgids.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
index b0ed417..3b43ac9 100755
--- a/bin/used_free_uidgids.sh
+++ b/bin/used_free_uidgids.sh
@@ -92,7 +92,7 @@ consume()
 
if [[ ${range_end} -lt ${ranges[k]} ]]; then
ranges[range_end+1]=${ranges[k]}
-   reasons{range_end+1]=${reasons[k]}
+   reasons[range_end+1]=${reasons[k]}
fi
[[ ${range_start} -gt ${k} ]] && ranges[k]=$(( 
range_start - 1 ))
break



[gentoo-commits] data/api:master commit in: bin/

2021-02-08 Thread Alec Warner
commit: f3639b24b860a182d375e5617fa77755b9f9a5a6
Author: Alec Warner  gentoo  org>
AuthorDate: Tue Feb  9 07:15:04 2021 +
Commit: Alec Warner  gentoo  org>
CommitDate: Tue Feb  9 07:15:04 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=f3639b24

used_free_uidgids.sh: new script to output uid gid information.

Signed-off-by: Alec Warner  gentoo.org>
Signed-off-by: Jaco Kroon  iewc.co.za>

 bin/used_free_uidgids.sh | 260 +++
 1 file changed, 260 insertions(+)

diff --git a/bin/used_free_uidgids.sh b/bin/used_free_uidgids.sh
new file mode 100755
index 000..b0ed417
--- /dev/null
+++ b/bin/used_free_uidgids.sh
@@ -0,0 +1,260 @@
+#! /bin/bash
+#
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+#
+# Author:  Jaco Kroon 
+# So that you can contact me if you need help with the below insanity.
+#
+# Configuration options:
+# max => maximum value of uid/gid that we're interested in/willing to allocate
+#  from.  Can be set to - to go maximum possible 32-bit value.
+# debug => if non-zero outputs some cryptic debug output (will inherit from 
environment).
+#
+max=500
+debug=${debug:+1} # set non-zero to enable debug output.
+
+#
+# Basic Design:
+#
+# There is nothing beautiful about this script, it's downright nasty and I
+# (Jaco Kroon ) will be the first to admit that.
+#
+# For each of the uid and gid ranges, we primarily keep two variables.
+# ranges and reason.  reason is simply one of USED or RESERVED.  Free ranges
+# are not mapped into these arrays.
+# ranges_ maps a start index onto an end index.  So for example, let's say
+# uid range 0..10 is USED (allocated, for whatever purposes):
+#
+# ranges_uid[0]=10
+# reasons_uid[0]=USED
+#
+# The above says that UID 0 to 10 is USED.
+#
+# We start with an initially empty set, and then insert into, either merging or
+# potentially splitting as we go, by way of the consume function, once 
completed
+# we compact some things and then output.
+#
+
+ranges_uid=()
+ranges_gid=()
+reason_uid=()
+reason_gid=()
+
+# Colours to be used if output is a TTY.
+colour_USED="\e[0;91m" # brightred
+colour_FREE="\e[0;92m" # brightgreen
+colour_RESERVED="\e[0;94m" # brightblue
+colour_RESET="\e[0m" # reset all styles.
+
+if ! [[ -t 1 ]]; then
+   colour_USED=
+   colour_FREE=
+   colour_RESERVED=
+   colour_RESET=
+fi
+
+# Find input file if not piped in on stdin, or show a warning about it on
+# stderr if we can't find the file.
+if [[ -t 0 ]]; then
+   def_infile="$(dirname "$0")/../files/uid-gid.txt"
+   if ! [[ -r "${def_infile}" ]] || ! exec <"${def_infile}"; then
+   echo "Reading from stdin (which happens to be a tty, you should 
pipe input file to stdin)" >&2
+   fi
+fi
+
+consume()
+{
+   # The basic principle here is that we can either add a new range, or 
split
+   # an existing range.  Partial overlaps not dealt with, nor range
+   # extensions.  Which would (I believe) negate the need for compact.
+   # TODO:  deal with range merging here, eg, if we have 0..10, and adding 
11, then
+   # we can simply adjust the range to 0..11, for example.
+   local variant="$1"
+   local ids="$2"
+   local type=$([[ "$3" == reserved ]] && echo RESERVED || echo USED)
+   local range_start="${ids%..*}"
+   local range_end="${ids#*..}"
+   declare -n ranges="ranges_${variant}"
+   declare -n reasons="reason_${variant}"
+
+   [[ -z "${ids}" ]] && return
+   [[ "${ids}" == - ]] && return
+
+   for k in "${!ranges[@]}"; do
+   # can the new range be inserted before the next range already 
in the set?
+   [[ ${k} -gt ${range_end} ]] && break
+   [[ ${ranges[k]} -lt ${range_start} ]] && continue
+   if [[ ${k} -le ${range_start} && ${range_end} -le ${ranges[k]} 
]]; then
+   # new range is contained completely inside.
+   [[ ${reasons[k]} == ${type} ]] && return # same type.
+   [[ ${type} == RESERVED ]] && return # USED takes 
precedence over RESERVED.
+
+   if [[ ${range_end} -lt ${ranges[k]} ]]; then
+   ranges[range_end+1]=${ranges[k]}
+   reasons{range_end+1]=${reasons[k]}
+   fi
+   [[ ${range_start} -gt ${k} ]] && ranges[k]=$(( 
range_start - 1 ))
+   break
+   else
+   echo "${range_start}..${range_end} (${type}) overlaps 
with ${k}..${ranges[k]} (${reasons[k]}"
+   echo "Cannot handle partial overlap."
+   exit 1
+   fi
+   done
+
+   ranges[range_start]="${range_end}"
+   reasons[range_start]="${type}"
+}
+
+compact()
+{
+   # This simply coalesces ranges that follow directly on each other.  In
+   # 

[gentoo-commits] data/api:master commit in: bin/

2021-01-24 Thread Michał Górny
commit: d1b70cbc373c4bed807f669744684d5eddae4d42
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sun Jan  3 18:08:17 2021 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jan 24 10:12:18 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=d1b70cbc

uidgid2wiki.awk: Fix typo

Signed-off-by: Ulrich Müller  gentoo.org>
Signed-off-by: Michał Górny  gentoo.org>

 bin/uidgid2wiki.awk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/uidgid2wiki.awk b/bin/uidgid2wiki.awk
index 8b91db1..9e690dc 100755
--- a/bin/uidgid2wiki.awk
+++ b/bin/uidgid2wiki.awk
@@ -1,7 +1,7 @@
 #!/usr/bin/awk -f
 
 BEGIN {
-   print ""
+   print ""
print "{|class=\"wikitable sortable\""
print "! Name"
print "! data-sort-type=\"number\" | UID"



[gentoo-commits] data/api:master commit in: bin/

2021-01-24 Thread Michał Górny
commit: 5c93bde003997957d8a799cf1b9c5855211a4c84
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sun Jan  3 18:09:04 2021 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jan 24 10:12:19 2021 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=5c93bde0

uidgid2wiki.awk: Add license header

Acked-by: Michał Górny  gentoo.org>
Signed-off-by: Ulrich Müller  gentoo.org>
Signed-off-by: Michał Górny  gentoo.org>

 bin/uidgid2wiki.awk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bin/uidgid2wiki.awk b/bin/uidgid2wiki.awk
index 9e690dc..ed95994 100755
--- a/bin/uidgid2wiki.awk
+++ b/bin/uidgid2wiki.awk
@@ -1,4 +1,6 @@
 #!/usr/bin/awk -f
+# Copyright 2019-2021 Gentoo Authors
+# Distributed under the terms of the MIT license
 
 BEGIN {
print ""



[gentoo-commits] data/api:master commit in: bin/

2019-12-08 Thread Michał Górny
commit: 444c52b1e90054355f4b5340aa04a9514a512bb7
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sun Dec  8 20:55:27 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Dec  8 20:59:43 2019 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=444c52b1

uidgid2wiki.awk: Suppress trailing whitespace in last column.

Signed-off-by: Ulrich Müller  gentoo.org>
Signed-off-by: Michał Górny  gentoo.org>

 bin/uidgid2wiki.awk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/uidgid2wiki.awk b/bin/uidgid2wiki.awk
index 2cc9f3b..8b91db1 100755
--- a/bin/uidgid2wiki.awk
+++ b/bin/uidgid2wiki.awk
@@ -53,7 +53,7 @@ function md2wiki(str) {
}
# notes
$1=$2=$3=$4=""
-   print "| " md2wiki(substr($0, 5))
+   print gensub(/[ \t]+$/, "", 1, "| " md2wiki(substr($0, 5)))
 }
 
 END {



[gentoo-commits] data/api:master commit in: bin/

2019-09-11 Thread Michał Górny
commit: c02a1619018fa7b239368086ff9c015073681600
Author: Michał Górny  gentoo  org>
AuthorDate: Wed Sep 11 08:20:54 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Sep 11 08:20:54 2019 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=c02a1619

bin/uidgid2wiki.awk: Print auto-gen comment

Signed-off-by: Michał Górny  gentoo.org>

 bin/uidgid2wiki.awk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bin/uidgid2wiki.awk b/bin/uidgid2wiki.awk
index 3c3e22f..2cc9f3b 100755
--- a/bin/uidgid2wiki.awk
+++ b/bin/uidgid2wiki.awk
@@ -1,6 +1,7 @@
 #!/usr/bin/awk -f
 
 BEGIN {
+   print ""
print "{|class=\"wikitable sortable\""
print "! Name"
print "! data-sort-type=\"number\" | UID"



[gentoo-commits] data/api:master commit in: bin/

2019-09-11 Thread Michał Górny
commit: a6353ac1d8f55e41e1de7a7c6b352becb1dec264
Author: Michał Górny  gentoo  org>
AuthorDate: Wed Sep 11 08:02:34 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Sep 11 08:02:34 2019 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=a6353ac1

bin: Add script to automate uid-gid table updates on wiki

Signed-off-by: Michał Górny  gentoo.org>

 bin/update-wiki-table.py | 101 +++
 1 file changed, 101 insertions(+)

diff --git a/bin/update-wiki-table.py b/bin/update-wiki-table.py
new file mode 100755
index 000..b845e7f
--- /dev/null
+++ b/bin/update-wiki-table.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python3
+
+import argparse
+import os.path
+import requests
+import subprocess
+import sys
+
+
+def main(argv):
+default_api_url = 'https://wiki.gentoo.org/api.php'
+default_script_path = os.path.join(os.path.dirname(__file__),
+   'uidgid2wiki.awk')
+default_title = 'UID_GID_Assignment_Table'
+
+argp = argparse.ArgumentParser(prog=argv[0])
+argp.add_argument('--api-url', default=default_api_url,
+  help='URL to MediaWiki API (default: {})'
+   .format(default_api_url))
+argp.add_argument('-p', '--password', required=True,
+  help='Bot password to log in with')
+argp.add_argument('--script', default=default_script_path,
+  help='Path to uidgid2wiki script')
+argp.add_argument('--title', default=default_title,
+  help='Title of page to edit (default: {})'
+   .format(default_title))
+argp.add_argument('-u', '--username', required=True,
+  help='Username to log in with')
+argp.add_argument('path', nargs=1, metavar='uid-gid.txt',
+  type=argparse.FileType('r', encoding='utf-8'),
+  help='UID/GID listing to process')
+args = argp.parse_args(argv[1:])
+
+# Get converted contents first.
+with subprocess.Popen([args.script],
+  stdin=args.path[0],
+  stdout=subprocess.PIPE) as s:
+page_data, _ = s.communicate()
+assert s.returncode == 0
+
+# MediaWiki API is just HORRIBLE!  Editing a page requires obtaining
+# a login token, logging in, obtaining a CSRF (!) token
+# and apparently preserving cookies as well!
+with requests.Session() as s:
+# get login token
+params = {
+'action': 'query',
+'meta': 'tokens',
+'type': 'login',
+'format': 'json',
+}
+with s.get(args.api_url, params=params) as r:
+token = r.json()['query']['tokens']['logintoken']
+
+# log in
+params = {
+'action': 'login',
+'lgname': args.username,
+'lgpassword': args.password,
+'lgtoken': token,
+'format': 'json',
+}
+with s.post(args.api_url, data=params) as r:
+assert r.json()['login']['result'] == 'Success', r.json()
+
+# get CSRF token (wtf?!)
+params = {
+'action': 'query',
+'meta': 'tokens',
+'format': 'json',
+}
+with s.get(args.api_url, params=params) as r:
+token = r.json()['query']['tokens']['csrftoken']
+
+# edit page (finally)
+params = {
+'action': 'edit',
+'title': args.title,
+'token': token,
+'format': 'json',
+'text': page_data,
+'summary': 'Automatic update from uid-gid.txt',
+'bot': True,
+}
+with s.post(args.api_url, data=params) as r:
+assert 'error' not in r.json(), r.json()
+print(r.json())
+
+# logout
+params = {
+'action': 'logout',
+'token': token,
+}
+with s.get(args.api_url, params=params) as r:
+pass
+
+return 0
+
+
+if __name__ == '__main__':
+sys.exit(main(sys.argv))



[gentoo-commits] data/api:master commit in: bin/

2019-08-24 Thread Michał Górny
commit: 62ba4e49e152f3f29e92b650eec6d06845bb1b86
Author: Michał Górny  gentoo  org>
AuthorDate: Sat Aug 24 17:58:13 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat Aug 24 17:58:13 2019 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=62ba4e49

Add uid-gid.txt → wiki conversion script

Signed-off-by: Michał Górny  gentoo.org>

 bin/uidgid2wiki.awk | 60 +
 1 file changed, 60 insertions(+)

diff --git a/bin/uidgid2wiki.awk b/bin/uidgid2wiki.awk
new file mode 100755
index 000..3c3e22f
--- /dev/null
+++ b/bin/uidgid2wiki.awk
@@ -0,0 +1,60 @@
+#!/usr/bin/awk -f
+
+BEGIN {
+   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 "| " md2wiki(substr($0, 5))
+}
+
+END {
+   print "|}"
+}



[gentoo-commits] data/api:master commit in: bin/

2018-08-07 Thread Michał Górny
commit: f4e95acad6b529d269e8b37b780707bf5734fc0d
Author: Eugene Bright  bright  gdn>
AuthorDate: Sun Aug  5 22:57:37 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Tue Aug  7 07:52:08 2018 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=f4e95aca

repositories: Add sorting script

 bin/gpl-3.0.txt  | 674 +++
 bin/sort_repositories.py | 162 
 2 files changed, 836 insertions(+)

diff --git a/bin/gpl-3.0.txt b/bin/gpl-3.0.txt
new file mode 100644
index 000..f288702
--- /dev/null
+++ b/bin/gpl-3.0.txt
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+   TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the

[gentoo-commits] data/api:master commit in: bin/

2015-12-26 Thread Alex Legler
commit: c0c412ef02302ccf9e306d091d429e7df3d6278f
Author: Alex Legler  a3li  li>
AuthorDate: Sat Dec 26 17:42:30 2015 +
Commit: Alex Legler  gentoo  org>
CommitDate: Sat Dec 26 17:42:30 2015 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=c0c412ef

Add projects.xml generation script

 bin/projects-xml.rb | 70 +
 1 file changed, 70 insertions(+)

diff --git a/bin/projects-xml.rb b/bin/projects-xml.rb
new file mode 100755
index 000..328cc93
--- /dev/null
+++ b/bin/projects-xml.rb
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby
+# Generates projects.xml as per GLEP-67 from projects.json via 
semantic-data-toolkit.
+# The file is only touched if contents change.
+#
+# Usage: projects-xml.rb 
+#
+# Alex Legler 
+
+require 'net/http'
+require 'json'
+require 'nokogiri'
+
+PROJECTS_JSON = URI('https://wiki.gentoo.org/rdf/projects.json')
+
+projects = begin
+  JSON.parse(Net::HTTP.get(PROJECTS_JSON))
+rescue JSON::ParserError
+  abort 'Cannot load projects.json.'
+end
+
+parent_map = Hash.new { |h, k| h[k] = [] }
+
+projects.each_pair do |id, project|
+  parent_map[project['parent']] << id if project.key? 'parent'
+end
+
+projects_xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
+  xml.doc.create_internal_subset('projects', nil, 
'http://www.gentoo.org/dtd/projects.dtd')
+  xml.projects do
+projects.each_pair do |id, project|
+  xml.project do
+xml.email project['email']
+xml.name project['name']
+xml.url project['href']
+xml.description project['description']
+
+if parent_map.key? id
+  parent_map[id].each do |subproject_id|
+attributes = { ref: projects[subproject_id]['email'] }
+attributes['inherit-members'] = '1' if 
projects[subproject_id]['propagates_members']
+
+xml.subproject nil, attributes
+  end
+end
+
+project['members'].sort { |a, b| a['nickname'].casecmp(b['nickname']) 
}.each do |member|
+  attributes = {}
+  attributes['is-lead'] = '1' if member['is_lead']
+
+  xml.member nil, attributes do
+xml.email member['email']
+xml.name member['name']
+xml.role member['role'] if member.key?('role') && 
!member['role'].empty?
+  end
+end
+  end
+end
+  end
+end
+
+output_file = ARGV[0]
+
+generated_xml = projects_xml.to_xml
+current_xml = begin
+  File.read(output_file)
+rescue Errno::ENOENT
+  ''
+end
+
+File.write(output_file, projects_xml.to_xml) unless generated_xml == 
current_xml



[gentoo-commits] data/api:master commit in: bin/

2015-08-15 Thread Alex Legler
commit: addbf0bd63ccc2a668cec82ed74ea115ce6f426d
Author: Alex Legler alex AT a3li DOT li
AuthorDate: Sat Aug 15 22:01:27 2015 +
Commit: Alex Legler a3li AT gentoo DOT org
CommitDate: Sat Aug 15 22:01:27 2015 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=addbf0bd

bump

 bin/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/README b/bin/README
index 508e77a..8f38534 100644
--- a/bin/README
+++ b/bin/README
@@ -1 +1 @@
-This directory contains scripts generating API data.
+This directory contains scripts for generating API data.



[gentoo-commits] data/api:master commit in: bin/

2015-08-15 Thread Alex Legler
commit: b654e7ba22f1d8bc3163dce3f2cf15828395b63b
Author: Alex Legler alex AT a3li DOT li
AuthorDate: Sat Aug 15 13:14:41 2015 +
Commit: Alex Legler a3li AT gentoo DOT org
CommitDate: Sat Aug 15 13:14:41 2015 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=b654e7ba

bump

 bin/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/README b/bin/README
index 81c3300..508e77a 100644
--- a/bin/README
+++ b/bin/README
@@ -1 +1 @@
-This directory is for scripts generating API data.
+This directory contains scripts generating API data.



[gentoo-commits] data/api:master commit in: bin/

2015-08-15 Thread Alex Legler
commit: 591af6234128c365155fef13eede5b39a7ffec27
Author: Alex Legler alex AT a3li DOT li
AuthorDate: Sat Aug 15 13:10:41 2015 +
Commit: Alex Legler a3li AT gentoo DOT org
CommitDate: Sat Aug 15 13:10:41 2015 +
URL:https://gitweb.gentoo.org/data/api.git/commit/?id=591af623

bump

 bin/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/README b/bin/README
index 9763692..81c3300 100644
--- a/bin/README
+++ b/bin/README
@@ -1 +1 @@
-This directory is for (future) scripts generating API data.
+This directory is for scripts generating API data.