dot

packages and services management
Log | Files | Refs | README

commit 7636f5c346bce3a28e6e7c7805fdda0a48865dc5
parent b2dd4c2ff1a77773afc3e604d137434ba516965c
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat, 29 Jul 2017 18:57:50 +0200

*/url -> */tar - [0-9]-* -> pkg-*

Diffstat:
D1-download | 21---------------------
Rabduco/url -> abduco/tar | 0
Ratreus/url -> atreus/tar | 0
Mbin/edit | 3++-
Mbin/irc | 251++++++-------------------------------------------------------------------------
Mbin/txt | 50+++++++++++++++++++++++++++++---------------------
Rbusybox/url -> busybox/tar | 0
Rcgo/url -> cgo/tar | 0
Rcollectd/url -> collectd/tar | 0
Rdarkhttpd/url -> darkhttpd/tar | 0
Rdma/url -> dma/tar | 0
Rdmenu/url -> dmenu/tar | 0
Rdwm/url -> dwm/tar | 0
Renchive/url -> enchive/tar | 0
Rffmpeg/url -> ffmpeg/tar | 0
Rgeomyidae/url -> geomyidae/tar | 0
Rgit/url -> git/tar | 0
Rii/url -> ii/tar | 0
Riomenu/url -> iomenu/tar | 0
Rired/url -> ired/tar | 0
Rjq/url -> jq/tar | 0
Rless/url -> less/tar | 0
Rlex/url -> lex/tar | 0
Rlibbearssl/url -> libbearssl/tar | 0
Rlibc/url -> libc/tar | 0
Rlibixp/url -> libixp/tar | 0
Rliblzma/url -> liblzma/tar | 0
Rlibnacl/url -> libnacl/tar | 0
Rlibopenssl/url -> libopenssl/tar | 0
Rlibopus/url -> libopus/tar | 0
Rlibtool/url -> libtool/tar | 0
Rlibtox/url -> libtox/tar | 0
Rlibutf/url -> libutf/tar | 0
Rlibvpx/url -> libvpx/tar | 0
Rm4/url -> m4/tar | 0
Rman-freebsd/url -> man-freebsd/tar | 0
Rman-linux/url -> man-linux/tar | 0
Rman-openbsd/url -> man-openbsd/tar | 0
Rman-plan9/url -> man-plan9/tar | 0
Rman-posix/url -> man-posix/tar | 0
Rmandoc/url -> mandoc/tar | 0
Rmblaze/url -> mblaze/tar | 0
Rmbsync/url -> mbsync/tar | 0
Rmpop/url -> mpop/tar | 0
Rmsmtp/url -> msmtp/tar | 0
Rmupdf/url -> mupdf/tar | 0
Rnafe/url -> nafe/tar | 0
Rnewsyslog/url -> newsyslog/tar | 0
Rngircd/url -> ngircd/tar | 0
R2-build -> pkg-build | 0
R4-config -> pkg-configure | 0
Apkg-download | 21+++++++++++++++++++++
R3-install -> pkg-install | 0
R0-profile -> pkg-profile | 0
R6-remove -> pkg-remove | 0
R5-service -> pkg-service | 0
Rpopa3d/url -> popa3d/tar | 0
Rquark/url -> quark/tar | 0
Rratox/url -> ratox/tar | 0
Rretawq/url -> retawq/tar | 0
Rsent/url -> sent/tar | 0
Rst/url -> st/tar | 0
Rstunnel/url -> stunnel/tar | 0
Rvar/url -> var/tar | 0
Rwendy/url -> wendy/tar | 0
Ryacc/url -> yacc/tar | 0
Ryasm/url -> yasm/tar | 0
67 files changed, 70 insertions(+), 276 deletions(-)

diff --git a/1-download b/1-download @@ -1,21 +0,0 @@ -. "${0%/*}/0-profile" - -read url < "$ETC/$1/url" - -[ -e "$SRC/$1" ] && exit 1 - -mkdir -p "$SRC/$1" && cd "$SRC/$1" - -wget -O - "$url" | case "$url" in -(*.tar.bz2 | *.tbz2) bunzip2 -d ;; -(*.tar.gz | *.tgz ) gzip -d ;; -(*.tar.xz | *.txz ) xz -d ;; -(*.tar ) tee ;; -esac | tar -xf - - -if [ $(ls "$SRC/$1" | wc -l) = 1 ] -then - dir=$(ls "$SRC/$1") - find "$SRC/$1" -mindepth 2 -maxdepth 2 -exec mv {} "$SRC/$1" ';' - rmdir "$SRC/$1/$dir" -fi diff --git a/abduco/url b/abduco/tar diff --git a/atreus/url b/atreus/tar diff --git a/bin/edit b/bin/edit @@ -1 +1,2 @@ -EDITOR='rlwrap ex' VISUAL='rlwrap ex' less -N "$@" +command -v rlwarp && EDITOR='rlwrap ex' || EDITOR=ex +EDITOR=$EDITOR VISUAL=$EDITOR exec less -N "$@" diff --git a/bin/irc b/bin/irc @@ -12,98 +12,31 @@ DIR="$HOME/.cache/irc" # Write a message to a server -write() -{ - local srv="$1" msg="$2" +local srv="$1" msg="$2" - printf '\r%s\n' "$msg" >> "$srv/IN" -} +printf '\r%s\n' "$msg" >> "$srv/IN" # Start netcat, identify the client and user, and monitor the response. -connect() -{ - local srv="$1" - [ -f "$srv/NICK" ] && user="$(tail "$srv/NICK")" - [ -z "$user" ] && user="$NICK" +mkdir -p "$VAR/irc/$1" +[ -p "$srv/in" ] || mkfifo "$srv/in" - mkdir -p "$srv" - [ -p "$srv/IN" ] || mkfifo "$srv/IN" +# Connect to irc server, send command from the pipe, parse the messages. +tail -f "$1/in" | brssl client "$srv":6667 | while IFS= read -r msg +do + printf %s "$msg" | awk -v srv="$1" ' + /^PING/ { + sub("PING", "PONG") + print > "in" + next + } + { print } + ' +done & - printf "$user" > "$srv/NICK" - - # Connect to irc server, send command from the pipe, parse the messages. - tail -f "$srv/IN" | nc "$srv" 6667 | tee -a ~/log | while IFS= read -r msg - do parse_message "$srv" - done & - - write "$srv" "NICK $user" - write "$srv" "USER $user +i * :$FULLNAME" -} - - -# Parse command from user input and print IRC messages. - -input() -{ - local srv chan arg user - - printf 'irc: Logs started in %s\n\n \033[1m>\033[0m ' "$DIR" 1>&2 - - while read cmd - do - [ "$srv" ] && user="$(tail "$srv/NICK")" - - # Parse command and arguments - if [ -z "${cmd##/*}" ] - then arg="${cmd#* }" cmd="${cmd#/}" cmd="${cmd%% *}" - else arg="$cmd" cmd='' - fi - cmd="$(printf %s "$cmd" | tr [a-z] [A-Z])" - - # Write message according to command - case "$cmd" in - C | CONNECT | S | SERVER ) - srv="$arg" chan='' - if [ -z "$(ps ax -o args | grep "^nc $srv 6667")" ] - then connect "$srv" & - fi - ;; - M | MSG | PRIVMSG ) - arg="${arg%% *} :${arg#* }" - write "$srv" "PRIVMSG $arg" - print_msg "$user" "$arg" PRIVMSG "$srv" >> "$srv/$arg" - ;; - J | JOIN ) - chan="$arg" - write "$srv" "JOIN $arg" - ;; - ME | ACTION ) - write "$srv" "PRIVMSG $chan :${C_A}ACTION ${arg}${C_A}" - ;; - TOPIC | LIST | MOTD ) - write "$srv" "TOPIC ${arg-chan}" - ;; - ID | IDENTIFY ) - printf '\033[A\r\033[K' 1>&2 - printf ' \033[30;1m%s %s\033[0;1m > \033[0m' \ - "$srv" "$chan" 1>&2 - printf '/IDENTIFY *****\n' 1>&2 - write "$srv" "PRIVMSG NickServ :IDENTIFY $arg" - ;; - '' ) - write "$srv" "PRIVMSG $chan :$arg" - print_msg "$user" "$arg" PRIVMSG "$srv" >> "$srv/$chan" - ;; - * ) - write "$srv" "$cmd $arg" - ;; - esac - - printf ' \033[30;1m%s %s\033[0;1m > \033[0m' "$srv" "$chan" 1>&2 - done -} +echo "NICK $user" > "$1/in" +echo "USER $user +i * :$FULLNAME" > "$1/in" # Maintain the connection open and print formatted message @@ -121,151 +54,3 @@ input() # # SPACE = %x20 ; space character # crlf = %x0D %x0A ; "carriage return" "linefeed" - -parse_message() -{ - local srv="$1" - - # Parse server message - local prefix='' nick='' cmd='' trail='' sep='' - local params='' middle='' chan='' user="$(tail "$srv/NICK")" - - # Remove the useless '\r' character - msg="${msg#$CR}" msg="${msg%$CR}" - - # Prefix (and nick) - if [ -z "${msg##:*}" ] - then - prefix="${msg%% *}" prefix="${prefix#:}" - [ -z "${prefix%%*!*}" ] && nick="${prefix%%!*}" - msg="${msg#* }" - fi - - # Command - cmd="${msg%% *}" msg="${msg#* }" - - # Parameters - params="${msg# *}" - case "$params" in - :* ) - trail="${params#:}" - ;; - *:* ) - trail="${params#*:}" middle="${params%% :*}" - ;; - * ) - middle="$params" - ;; - esac - - # Channel and extra command action - case "$cmd" in - JOIN | PART ) - chan="${middle:-$trail}" - ;; - PRIVMSG ) - [ "$middle" = "$user" ] && chan="$nick" || chan="$middle" - ;; - NICK ) - chan=SERVER - [ "$nick" = "$user" ] && printf '%s\n' "$trail" > "$srv/NICK" - ;; - QUIT | NOTICE | [0-9][0-9][0-9] | * | '' ) - chan=SERVER - ;; - esac - - # Execute action - case "$cmd" in - PING ) - write "$srv" "PONG $trail" - ;; - QUIT | NICK ) - grep -l -r "$nick" | while read chan - do - chan="${chan#$srv/}" - print_msg "$nick" "$trail" "$cmd" "$srv" "$chan" \ - >> "$srv/$chan" - done - ;; - *) - print_msg "$nick" "$trail" "$cmd" "$srv" "$chan" >> "$srv/$chan" - ;; - esac - - # Bot actions - case "$trail" in - 'VERSION'* ) write "$srv" "PRIVMSG $nick :VERSION nc + sh" ;; - esac -} - - -# Print formatted message - -print_msg() -{ - local nick="$1" trail="$2" cmd="$3" srv="$4" chan="$5" - local user="$(tail "$srv/NICK")" last_cmd last_nick - - case "$cmd" in - QUIT ) cmd='<' ;; - JOIN ) cmd='>' ;; - PRIVMSG ) cmd='|' ;; - NOTICE ) cmd='!' ;; - PART ) cmd='~' ;; - ERROR ) cmd='X' ;; - MODE ) cmd='+' ;; - NICK ) cmd='=' ;; - esac - - # Single line separator at the right place. - - for n in $(tac "$srv/$chan" | cut -c 1-$NICK_LEN) - do last_nick="$n"; break - done - - last_cmd="$(tail -n 1 "$srv/$chan" | cut -c $(($NICK_LEN + 2))-)" - last_cmd="${last_cmd%% *}" - - if [ "$cmd" = '|' ] \ - && [ "$last_nick" != "$nick" ] \ - || [ "$cmd" != "$last_cmd" ] - then printf "%${NICK_LEN}s |\n" - fi - - # Print the message - printf '%s\n' "$trail" | fold -s -w $((80 - $NICK_LEN - ${#cmd})) \ - | while read line - do - printf "%${NICK_LEN}s %1s %s\n" "$nick" "$cmd" "$line" - nick='' - done -} - - -main() -{ - # Kill background jobs and delete named pipes while quitting - - # Prepare the irc log directory - [ -d "$DIR" ] || mkdir -p "$DIR" - cd "$DIR" - printf '%s\n' "$NICK" > "NICK" - - case "$1" in - -i ) - trap 'find . -name IN -exec rm {} ";"; kill -9 0' INT EXIT - input - ;; - -o ) - IFS="$NL" - less $(find . -mindepth 2 -type f ! -name NICK) - unset IFS - ;; - * ) - printf 'USAGE:\tirc [-i|-o]\n' - ;; - esac -} - -main "$@" diff --git a/bin/txt b/bin/txt @@ -1,50 +1,58 @@ awk ' -!ELEMENT && /^$/ { next } +!BLOCK && /^$/ { next } -ELEMENT && /^$/ { - print "</" ELEMENT ">\n" - ELEMENT = "" +BLOCK && /^$/ { + print "</" BLOCK ">\n" + BLOCK = "" next } -!ELEMENT && /^\t/ { + +# --- print blocks ------------------------------------------------------------- + +!BLOCK && /^\t/ { print "<pre>" do { sub("^\t", "", $0) print $0 } while (getline && $0 !~ /^[^\t]/) print "</pre>" - ELEMENT = "" + BLOCK = "" } -!ELEMENT && match($0, /^=+ /) { +!BLOCK && match($0, /^=+ /) { sub(/^=* */, "", $0) sub(/ *=*$/, "", $0) - lv = RLENGTH - 1 - id = match($0, /^[0-9.]*/) ? substr($0, 1, RLENGTH) : "" - print "\n<h" lv " id=\"" id "\">" $0 "</h" lv ">\n" - ELEMENT = "" + print "\n<h" RLENGTH - 1 ">" $0 "</h" RLENGTH - 1 ">\n" + BLOCK = "" next } -(!ELEMENT || ELEMENT == "li") && /^- / { + +# --- identify block ----------------------------------------------------------- + +!BLOCK && /^- / { + BLOCK = "li" sub(/^- /, "", $0) - if (ELEMENT == "li") print "</li>\n" - print "<li>\n" $0 - ELEMENT = "li" - next } -# other rules go here +!BLOCK { + BLOCK = "p" +} + -!ELEMENT { - print "<p>\n" $0 - ELEMENT = "p" +# --- print identified blocks -------------------------------------------------- + +BLOCK { + print "<" BLOCK ">" $0 next } { print } -END { if (ELEMENT) print "</" ELEMENT ">" } +END { + if (BLOCK) print "</" BLOCK ">" + if (CONTEXT) print "</" CONTEXT ">" +} ' "$@" diff --git a/busybox/url b/busybox/tar diff --git a/cgo/url b/cgo/tar diff --git a/collectd/url b/collectd/tar diff --git a/darkhttpd/url b/darkhttpd/tar diff --git a/dma/url b/dma/tar diff --git a/dmenu/url b/dmenu/tar diff --git a/dwm/url b/dwm/tar diff --git a/enchive/url b/enchive/tar diff --git a/ffmpeg/url b/ffmpeg/tar diff --git a/geomyidae/url b/geomyidae/tar diff --git a/git/url b/git/tar diff --git a/ii/url b/ii/tar diff --git a/iomenu/url b/iomenu/tar diff --git a/ired/url b/ired/tar diff --git a/jq/url b/jq/tar diff --git a/less/url b/less/tar diff --git a/lex/url b/lex/tar diff --git a/libbearssl/url b/libbearssl/tar diff --git a/libc/url b/libc/tar diff --git a/libixp/url b/libixp/tar diff --git a/liblzma/url b/liblzma/tar diff --git a/libnacl/url b/libnacl/tar diff --git a/libopenssl/url b/libopenssl/tar diff --git a/libopus/url b/libopus/tar diff --git a/libtool/url b/libtool/tar diff --git a/libtox/url b/libtox/tar diff --git a/libutf/url b/libutf/tar diff --git a/libvpx/url b/libvpx/tar diff --git a/m4/url b/m4/tar diff --git a/man-freebsd/url b/man-freebsd/tar diff --git a/man-linux/url b/man-linux/tar diff --git a/man-openbsd/url b/man-openbsd/tar diff --git a/man-plan9/url b/man-plan9/tar diff --git a/man-posix/url b/man-posix/tar diff --git a/mandoc/url b/mandoc/tar diff --git a/mblaze/url b/mblaze/tar diff --git a/mbsync/url b/mbsync/tar diff --git a/mpop/url b/mpop/tar diff --git a/msmtp/url b/msmtp/tar diff --git a/mupdf/url b/mupdf/tar diff --git a/nafe/url b/nafe/tar diff --git a/newsyslog/url b/newsyslog/tar diff --git a/ngircd/url b/ngircd/tar diff --git a/2-build b/pkg-build diff --git a/4-config b/pkg-configure diff --git a/pkg-download b/pkg-download @@ -0,0 +1,21 @@ +. "${0%/*}/0-profile" + +read tar < "$ETC/$1/tar" + +[ -e "$SRC/$1" ] && exit 1 + +mkdir -p "$SRC/$1" && cd "$SRC/$1" + +wget -O - "$tar" | case "$tar" in +(*.tar.bz2 | *.tbz2) bunzip2 -d ;; +(*.tar.gz | *.tgz ) gzip -d ;; +(*.tar.xz | *.txz ) xz -d ;; +(*.tar ) tee ;; +esac | tar -xf - + +if [ $(ls "$SRC/$1" | wc -l) = 1 ] +then + dir=$(ls "$SRC/$1") + find "$SRC/$1" -mindepth 2 -maxdepth 2 -exec mv {} "$SRC/$1" ';' + rmdir "$SRC/$1/$dir" +fi diff --git a/3-install b/pkg-install diff --git a/0-profile b/pkg-profile diff --git a/6-remove b/pkg-remove diff --git a/5-service b/pkg-service diff --git a/popa3d/url b/popa3d/tar diff --git a/quark/url b/quark/tar diff --git a/ratox/url b/ratox/tar diff --git a/retawq/url b/retawq/tar diff --git a/sent/url b/sent/tar diff --git a/st/url b/st/tar diff --git a/stunnel/url b/stunnel/tar diff --git a/var/url b/var/tar diff --git a/wendy/url b/wendy/tar diff --git a/yacc/url b/yacc/tar diff --git a/yasm/url b/yasm/tar