#!/bin/sh # This script will inform the total number of committers per repo at # the end of the run. This information should be manually updated in # the file documentation/content/en/books/dev-model/_index.adoc # This file will also calculate the total number of ports and create # and create the portsstatus.svg graph which can be committed _MAINTAINER=bofh@FreeBSD.org _BLACK=$(tput setaf 0) _BLINK=$(tput blink) _BLUE=$(tput setaf 4) _BOLD=$(tput bold) _CURRENTYEAR=$(date "+%Y") _CYAN=$(tput setaf 6) _DOCSDIR="$_TMPDIR/docs" _GREEN=$(tput setaf 2) _LIME_YELLOW=$(tput setaf 190) _MAGENTA=$(tput setaf 5) _NORMAL=$(tput sgr0) _POWDER_BLUE=$(tput setaf 153) _PURPLE=$(tput setaf 125) _RED=$(tput setaf 1) _REVERSE=$(tput smso) _STARTYEAR="1994" _TAN=$(tput setaf 222) _TMPDIR=$(mktemp -d) _INPUT=$_TMPDIR/portsstatus.dat _OUTPUT=$_TMPDIR/portsstatus.svg _PORTSDIR="$_TMPDIR/ports" _SRCDIR="$_TMPDIR/src" _UNDERLINE=$(tput smul) _WHITE=$(tput setaf 7) _YELLOW=$(tput setaf 3) command_exists() { command -v "$@" >/dev/null 2>&1 } e_header() { printf "\n${_BOLD}${_MAGENTA}========== %s ==========${_NORMAL}\n" "$@" } e_arrow() { printf "➜ %s\n" "$@" } e_success() { printf "${_GREEN}✔ %s${_NORMAL}\n" "$@" } e_error() { printf "${_RED}✖ %s${_NORMAL}\n" "$@" } e_warning() { printf "${_TAN}➜ %s${_NORMAL}\n" "$@" } e_underline() { printf "${_UNDERLINE}${_BOLD}%s${_NORMAL}\n" "$@" } e_bold() { printf "${_BOLD}%s${_NORMAL}\n" "$@" } e_note() { printf "${_UNDERLINE}${_BOLD}${_BLUE}Note:${_NORMAL} ${_YELLOW}%s${_NORMAL}\n" "$@" } check_git() { e_header "Checking if git is installed" if command_exists git; then _GITCMD=$(command -v git) e_success "git command found" else e_error "git is not installed" e_note "Install git with 'pkg install git'" exit fi } check_gnuplot() { e_header "Checking if gnuplotis installed" if command_exists gnuplot; then _GITCMD=$(command -v gnuplot) e_success "gnuplot command found" else e_error "gnuplot is not installed" e_note "Install gnuplot with 'pkg install gnuplot-lite'" exit fi } create_tmp() { e_header "Creating temporary working directory" if [ -z "$_TMPDIR" ]; then e_error "Failed to create temporary working directory" exit else e_success "Successfully created temporary working directory "$_TMPDIR"" fi } create_ports() { e_header "Creating temporary ports directory" mkdir -p $_PORTSDIR if [ -z "$_PORTSDIR" ]; then e_error "Failed to create temporary ports directory" exit else e_success "Successfully created temporary ports directory "$_PORTSDIR"" fi e_header "Creating ports repo" git clone -q https://git.freebsd.org/ports.git "$_PORTSDIR" e_success "Successfully created the temporary ports tree" } create_src() { e_header "Creating temporary src directory" mkdir -p $_SRCDIR if [ -z "$_SRCDIR" ]; then e_error "Failed to create temporary src directory" exit else e_success "Successfully created temporary src directory "$_SRCSDIR"" fi e_header "Creating src repo" git clone -q https://git.freebsd.org/src.git "$_SRCDIR" e_success "Successfully created the temporary src tree" } create_docs() { e_header "Creating temporary docs directory" mkdir -p $_DOCSDIR if [ -z "$_DOCSDIR" ]; then e_error "Failed to create temporary docs directory" exit else e_success "Successfully created temporary docs directory "$_DOCSDIR"" fi e_header "Creating docs repo" git clone -q https://git.freebsd.org/docs.git "$_DOCSDIR" e_success "Successfully created the temporary docs tree" } calculate_ports() { cd "$_PORTSDIR" git config advice.detachedHead false for i in `jot - 1995 ${_CURRENTYEAR}` do _BASECOMMIT=$(git log main --before="$i"-01-01 -n 1 --pretty="%h") git checkout -q $_BASECOMMIT _TOTALPORTS=$(git ls-files -- '*/*/Makefile' | wc -l) echo $i,$_TOTALPORTS >> $_TMPDIR/ports.dat done } calculate_ports_committers() { cd "$_PORTSDIR" git config advice.detachedHead false git config --add remote.freebsd.fetch '+refs/internal/*:refs/internal/*' git fetch git checkout -b admin internal/admin for i in `jot - 1995 ${_CURRENTYEAR}` do _BASECOMMIT=$(git log main --before="$i"-01-01 -n 1 --pretty="%h") git checkout -q $_BASECOMMIT _TOTALPORTS=$(git ls-files -- '*/*/Makefile' | wc -l) echo $i,$_TOTALPORTS >> $_TMPDIR/ports.dat done } create_graph () { e_header "Creating graph" gnuplot <