Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3777692
D1402.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
23 KB
Referenced Files
None
Subscribers
None
D1402.diff
View Options
diff --git a/pillar/core/users.sls b/pillar/core/users.sls
--- a/pillar/core/users.sls
+++ b/pillar/core/users.sls
@@ -83,6 +83,7 @@
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDqWONhKh4+7o6C4wXV8QPsChqq7RYwg6oWSeBf0Ydom7QweAlkxYISJ2H24IrhKI2pXoxOZjz659/DeuhYMKZ3Djfuci1Ch3ZGyzD3w1Gdz0gXJXyqYFstfIvQBkUi8ET/lr2B6V7T7fEwb7CZq0T8NtkZpBiMRn9LdP6D+TT+YfPRiBg7gBeWUlU0rLP+kcT+7UQV2Nblh4yuxJMIgmhlZEKD6a8KMGOLQI4m0gunf6MvWy4eKurxfgM14c75e86fjUakwpfTPrPpeulR4Y9a0Cjbery38ws6ubRThnG4XNtCQHGwZ/+bJ5nzMnG887fzSocWPZSx8IctP9FuiwVCSDKOPn55wMgF490NcBaqadVtUTj5hVN73ojVvNr3vtTO/LVDt0GiKc9XkPRSiXbE4JZ2LzpPybUwkw/pSQuwgQ4Dvabv9OQsV9bzXQdRhOih0jqlMYAOpfXopk2rKBtvb930yBTgTnPxsyAtHmTkiWdvzAJ2gSjbgWdkGNRB48dL3HzJyaZXLUOyDIZquLmzXltd0ArYe1YcShfYncCXS3RtVxrj5Fj/bJoOvnhTe/aVXAa6eaOkAi5uZeoGZ7WbtlgL+ybohOOMcYDXlrM5QxYYf1uiArxFAfukk/7df0wSaP14qXDwKYaQIbMdIUs/Y08JBEooOGtrOcQXrKDBKw== Yggdrasil
yubico_keys:
- ccccccbjncrt
+ deploy_dotfiles_to_devserver: True
uid: 5001
erol:
fullname: Erol Unutmaz
diff --git a/roles/devserver/init.sls b/roles/devserver/init.sls
--- a/roles/devserver/init.sls
+++ b/roles/devserver/init.sls
@@ -9,4 +9,5 @@
include:
- .dns
- .userland-software
+ - .userland-home
- .webserver-wwwroot51
diff --git a/roles/devserver/userland-home/files/dereckson/.hgrc b/roles/devserver/userland-home/files/dereckson/.hgrc
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/.hgrc
@@ -0,0 +1,2 @@
+[extensions]
+prompt = /usr/home/dereckson/.software/hg-prompt/prompt.py
diff --git a/roles/devserver/userland-home/files/dereckson/.gitconfig b/roles/devserver/userland-home/files/dereckson/.gitconfig
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/.gitconfig
@@ -0,0 +1,14 @@
+[user]
+ name = Sébastien Santoro
+ email = dereckson@espace-win.org
+[achievement]
+ upload = false
+[core]
+ editor = nano
+[achievements]
+ upload = true
+[filter "lfs"]
+ clean = git-lfs clean -- %f
+ smudge = git-lfs smudge -- %f
+ process = git-lfs filter-process
+ required = true
diff --git a/roles/devserver/userland-home/files/dereckson/.nanorc b/roles/devserver/userland-home/files/dereckson/.nanorc
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/.nanorc
@@ -0,0 +1,4 @@
+set nowrap
+
+set tabsize 4
+#set tabstospaces
diff --git a/roles/devserver/userland-home/files/dereckson/.shell.yml b/roles/devserver/userland-home/files/dereckson/.shell.yml
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/.shell.yml
@@ -0,0 +1,12 @@
+aliases:
+ acquisitariat:
+ command: ['ssh', '-t', 'dwellers.nasqueron.org', 'mysql-acquisitariat-client']
+ devcentral:
+ handler: docker
+ args: ['devcentral']
+
+handlers:
+ docker:
+ server: "dwellers.nasqueron.org"
+ command: ['docker', 'exec', '-it', '{{%s}}', '{{%s-|bash}}']
+ interactive: True
diff --git a/roles/devserver/userland-home/files/dereckson/.tmux.conf b/roles/devserver/userland-home/files/dereckson/.tmux.conf
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/.tmux.conf
@@ -0,0 +1,42 @@
+#
+# tmux minimal DcK configuration file
+#
+
+# General settings
+# ᚾ identifies Nasqueron servers
+set -g prefix C-b
+set -g status-right '⫻ #h — %Y-%m-%d %H:%M ⫻ ᚾ '
+
+# Regular pane divide keys
+bind '"' split-window -c "#{pane_current_path}"
+bind % split-window -h -c "#{pane_current_path}"
+bind c new-window -c "#{pane_current_path}"
+
+# Resize shorcut keys
+bind < resize-pane -L 1
+bind > resize-pane -R 1
+bind - resize-pane -D 1
+bind + resize-pane -U 1
+
+# Toggle mouse on with ^B m
+bind m \
+ set -g mode-mouse on \;\
+ set -g mouse-resize-pane on \;\
+ set -g mouse-select-pane on \;\
+ set -g mouse-select-window on \;\
+ display 'Mouse mode ON'
+
+# Toggle mouse off with ^B M
+bind M \
+ set -g mode-mouse off \;\
+ set -g mouse-resize-pane off \;\
+ set -g mouse-select-pane off \;\
+ set -g mouse-select-window off \;\
+ display 'Mouse mode OFF'
+
+# Colors
+set -g status-bg colour241
+set -g status-fg colour7
+
+set -g pane-border-fg colour241
+set -g pane-active-border-fg colour238
diff --git a/roles/devserver/userland-home/files/dereckson/.zshrc b/roles/devserver/userland-home/files/dereckson/.zshrc
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/.zshrc
@@ -0,0 +1,212 @@
+# -------------------------------------------------------------
+# Zsh configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Wynter
+# Created: 2017-10-26
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Table of contents
+# -------------------------------------------------------------
+#
+# :: Completions
+# :: History
+# :: Prompt
+# :: Background jobs
+# :: Compatibility with csh
+# :: Environment
+# :: SSH
+# :: Keys bindings
+# :: External modules
+# :: VCS
+# :: Aliases for salt-wrapper
+# :: Misc aliases
+#
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Completions
+#
+# This section has been prepared with compinstall
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
+zstyle ':completion:*' completions 1
+zstyle ':completion:*' glob 1
+zstyle ':completion:*' matcher-list ''
+zstyle ':completion:*' max-errors 3
+zstyle ':completion:*' substitute 1
+
+autoload -Uz compinit
+compinit
+
+setopt extendedglob
+setopt no_nomatch
+
+# -------------------------------------------------------------
+# History
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+HISTFILE=~/.histfile
+HISTSIZE=10000
+SAVEHIST=10000
+setopt appendhistory
+
+# -------------------------------------------------------------
+# Prompt
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+prompt='%B%/%b ] '
+
+# -------------------------------------------------------------
+# Background jobs
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+setopt notify
+
+# -------------------------------------------------------------
+# Compatibility with csh
+#
+# makecheck / https://news.ycombinator.com/item?id=4201636
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+setenv () {
+ if [ "x$1" = "x" ] ; then
+ echo "$0: environment variable name required" >&2
+ elif [ "x$2" = "x" ] ; then
+ echo "$0: environment variable value required" >&2
+ else
+ export $1=$2
+ fi
+}
+
+unsetenv () {
+ if [ "x$1" = "x" ] ; then
+ echo "$0: environment variable name required" >&2
+ else
+ unset $1
+ fi
+}
+
+# -------------------------------------------------------------
+# Environment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+[[ $TERM == screen ]] && TERM=screen-256color
+
+BLOCKSIZE=K
+
+EDITOR=nano
+
+PAGER=less
+LESS=eiMqXR
+
+# -------------------------------------------------------------
+# SSH
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+source $HOME/bin/ssh-agent-session
+
+# -------------------------------------------------------------
+# Keys bindings
+#
+# http://zshwiki.org/home/zle/bindkeys
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+bindkey -e
+
+autoload zkbd
+source $HOME/.zkbd/screen-256color-portbld-freebsd11.0
+
+autoload -U up-line-or-beginning-search
+autoload -U down-line-or-beginning-search
+zle -N up-line-or-beginning-search
+zle -N down-line-or-beginning-search
+
+export WORDCHARS='*?_[]~=&;!#$%^(){}'
+
+[[ -n "$key[Home]" ]] && bindkey -- "$key[Home]" beginning-of-line
+[[ -n "$key[End]" ]] && bindkey -- "$key[End]" end-of-line
+[[ -n "$key[Insert]" ]] && bindkey -- "$key[Insert]" overwrite-mode
+[[ -n "$key[Backspace]" ]] && bindkey -- "$key[Backspace]" backward-delete-char
+[[ -n "$key[Delete]" ]] && bindkey -- "$key[Delete]" delete-char
+[[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search
+[[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search
+[[ -n "$key[Left]" ]] && bindkey -- "$key[Left]" backward-char
+[[ -n "$key[Right]" ]] && bindkey -- "$key[Right]" forward-char
+
+# -------------------------------------------------------------
+# External modules
+#
+# :: pm
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+source ~/.pm/pm.zsh
+plugins=(pm)
+
+# -------------------------------------------------------------
+# VCS
+#
+# :: alias to git-achievements
+# :: vcs_info prompt
+#
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+alias git=git-achievements
+compdef git-achievements=git
+
+setopt prompt_subst
+autoload -Uz vcs_info
+
+zstyle ':vcs_info:*' actionformats \
+ '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
+zstyle ':vcs_info:*' formats \
+ '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
+zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
+
+zstyle ':vcs_info:*' enable git cvs svn
+
+vcs_info_wrapper() {
+ vcs_info
+ if [ -n "$vcs_info_msg_0_" ]; then
+ echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
+ fi
+}
+RPROMPT=$'$(vcs_info_wrapper)'
+
+# -------------------------------------------------------------
+# Aliases for salt-wrapper
+#
+# https://docs.nasqueron.org/salt-wrapper/admin.html#shell-aliases
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+alias salt='salt-wrapper salt'
+alias salt-call='salt-wrapper salt-call'
+alias salt-cloud='salt-wrapper salt-cloud'
+alias salt-key='salt-wrapper salt-key'
+alias salt-run='salt-wrapper salt-run'
+alias salt-ssh='salt-wrapper salt-ssh'
+
+# -------------------------------------------------------------
+# Misc aliases
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+alias cd..='cd ..'
+alias cd...='cd ../..'
+alias cd....='cd ../../..'
+
+alias go='pm go'
+
+alias h=history
+alias n=nano
+
+alias si='french-conjugator --mode=subjunctive --tense=imperfect'
+alias t='t --task-dir ~/.tasks --list tasks'
+
+alias tclsh='rlwrap tclsh8.6'
+alias psysh='rlwrap psysh'
+
+if [[ -a ~/.zshrc-misc-aliases ]]; then
+ source ~/.zshrc-misc-aliases
+fi
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-create-ops-task b/roles/devserver/userland-home/files/dereckson/bin/arc-create-ops-task
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-create-ops-task
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+ARC=arc
+AWK=gawk
+URL="https://devcentral.nasqueron.org"
+
+if [ $# -eq 0 ]; then
+ echo "Usage: $0 <title of the task to create>"
+ exit 64
+fi
+TEXT=$1
+
+arcTaskCreatedId=$($ARC todo "$TEXT" --project servers --no-ansi --conduit-uri "$URL"/api | $AWK '{match($3,"T[0-9]+",a)}END{print a[0]}' | cut -d'T' -f 2)
+echo $URL/T"$arcTaskCreatedId"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-merge b/roles/devserver/userland-home/files/dereckson/bin/arc-merge
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-merge
@@ -0,0 +1,8 @@
+#!/bin/sh
+DIFF=$1
+
+git diff-index --quiet --cached HEAD -- && \
+git diff-files --quiet && \
+git pull && \
+arc patch --nobranch "$DIFF" && \
+git push
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-paste-diff b/roles/devserver/userland-home/files/dereckson/bin/arc-paste-diff
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-paste-diff
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+COLORDIFF=`which colordiff`
+
+if [ $# -ne 2 ]
+then
+ echo "Usage: `basename $0` <paste 1> <paste 2>"
+ exit 1
+fi
+
+if [ "$COLORDIFF" = "" ]; then
+ diff -u <(arc paste $1) <(arc paste $2)
+else
+ diff -u <(arc paste $1) <(arc paste $2) | colordiff
+fi
+
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file b/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file
@@ -0,0 +1,16 @@
+#!/bin/sh
+if [ $# -eq 0 ]
+then
+ echo "Usage: `basename $0` <filename>"
+ exit 1
+fi
+
+FILE=$1
+
+if [ ! -f $FILE ]
+then
+ echo "File not found: $FILE"
+ exit 2
+fi
+
+arc paste --title $FILE < $FILE
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo b/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo
@@ -0,0 +1,22 @@
+#!/bin/sh
+ROOT_DIR=`git rev-parse --show-toplevel 2>/dev/null`
+if [ "$?" -ne "0" ]; then
+ ROOT_DIR=`hg root 2>/dev/null`
+ if [ "$?" -ne "0" ]; then
+ echo "Doesn't seem to be a Git or Mercurial repository."
+ exit
+ fi
+fi
+
+if [ ! -f $ROOT_DIR/.arcconfig ]; then
+ echo 'Create a .arcconfig file with "repository.callsign" : "..." (without the leading r) option.'
+ exit
+fi
+
+CALLSIGN=`cat $ROOT_DIR/.arcconfig | jq '."repository.callsign"'`
+if [ "$CALLSIGN" = "null" ]; then
+ echo 'Add to your .arcconfig file a "repository.callsign" : "..." (without the leading r) option.'
+ exit
+fi
+
+echo "{ \"callsigns\": [$CALLSIGN] }" | arc call-conduit diffusion.looksoon > /dev/null
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-achievements b/roles/devserver/userland-home/files/dereckson/bin/git-achievements
new file mode 120000
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-achievements
@@ -0,0 +1 @@
+/home/dereckson/dev/dereckson/git-achievements/git-achievements
\ No newline at end of file
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-bye b/roles/devserver/userland-home/files/dereckson/bin/git-bye
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-bye
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+if [ "$BRANCH" = "master" ]; then
+ echo "You're already on the master branch."
+ exit 1
+fi
+
+# Updates master branch if there isn't any staged change and working tree is clean
+git checkout master
+git diff-index --quiet --cached HEAD -- && git diff-files --quiet && git pull
+
+git branch -D "$BRANCH"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-newbug b/roles/devserver/userland-home/files/dereckson/bin/git-newbug
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-newbug
@@ -0,0 +1,31 @@
+#!/bin/sh
+if [ $# -eq 0 ]
+then
+ echo "Usage: $(basename "$0") <name of the branch to create>"
+ exit 1
+fi
+
+BRANCH=$1
+
+REPO=$(git rev-parse --show-toplevel)
+REPO_RETCODE=$?
+
+if [ $REPO_RETCODE -ne 0 ]
+then
+ exit $REPO_RETCODE
+fi;
+
+REPO=$(basename "$REPO")
+
+if [ "$REPO" = "puppet" ]
+then
+ MASTER=production
+else
+ MASTER=master
+fi
+
+git checkout $MASTER
+git fetch --all
+git pull
+git pull origin $MASTER
+git checkout -b "$BRANCH"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-respawn b/roles/devserver/userland-home/files/dereckson/bin/git-respawn
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-respawn
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+if [ "$BRANCH" = "master" ]; then
+ echo "You're already on the master branch."
+ exit 1
+fi
+
+# Updates master branch if there isn't any staged change and working tree is clean
+git checkout master
+git diff-index --quiet --cached HEAD -- && git diff-files --quiet && git pull
+
+git branch -D "$BRANCH"
+
+# Fetch new branch
+if [ ${BRANCH:0:10} = "arcpatch-D" ]; then
+ arc patch ${BRANCH:9}
+fi
diff --git a/roles/devserver/userland-home/files/dereckson/bin/nanotab b/roles/devserver/userland-home/files/dereckson/bin/nanotab
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/nanotab
@@ -0,0 +1,2 @@
+#!/bin/sh
+nano -I -w "$@"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/ops-newuser b/roles/devserver/userland-home/files/dereckson/bin/ops-newuser
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/ops-newuser
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+ARC=arc
+SHELLUSERS=pillar/users/shellusers.sls
+PROJECT=Eglide
+KEYS_TEMPLATE=P267
+
+[ -z "$EDITOR" ] && EDITOR=nano
+
+if [ $# -ne 1 ]
+then
+ >&2 echo "Usage: $(basename "$0") <username>"
+ exit 64
+fi
+ACCOUNT=$1
+
+if [ ! -f $SHELLUSERS ]
+then
+ >&2 echo "You must run this at the top of a rOPS working copy."
+ exit 66
+fi
+
+LASTUID=$(grep 'uid: 2' $SHELLUSERS | sort | tail -n 1 | awk '{print $2}')
+NEWUID=$((LASTUID + 1))
+{
+ echo " $ACCOUNT:"
+ echo " fullname: $ACCOUNT"
+ echo " uid: $NEWUID"
+} >> $SHELLUSERS
+
+AUTHORIZED_KEYS=roles/shellserver/users/files/ssh_keys/$ACCOUNT
+$EDITOR $SHELLUSERS
+$ARC paste $KEYS_TEMPLATE | sed "s/%%username%%/$ACCOUNT/g; s/%%project%%/$PROJECT/g" > "$AUTHORIZED_KEYS"
+$EDITOR "$AUTHORIZED_KEYS"
+$ARC feature "account/$ACCOUNT"
+git status
diff --git a/roles/devserver/userland-home/files/dereckson/bin/port-patches-generator b/roles/devserver/userland-home/files/dereckson/bin/port-patches-generator
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/port-patches-generator
@@ -0,0 +1,164 @@
+#!/usr/bin/env tclsh8.6
+
+# FreeBSD ports patches generator
+# (c) 2012, Sébastien Santoro aka Dereckson. Released under BSD license.
+#
+# You have:
+# - a Git repository, where HEAD is a stable version of the code
+# (ie the result of make extract)
+#
+# - your working directory contained the modified files
+#
+# You want:
+# - generate patches for your FreeBSD port
+#
+# This script will:
+# - get from git status the list of modified files
+#
+# - write the relevant patch for each file in files/ port directory
+#
+# So an offered workflow is:
+# 1. cd <port directory>
+# 2. make extract
+# 3. cd work/<your application directory)
+# 4. git init .
+# 5. git add *
+# 6. git commit -a -m "dist version"
+# 7. (modify your files, so it compiles under FreeBSD)
+# 8. port-patches-generator
+#
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# #
+# Section I - Configuration #
+# #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Path to git executable
+set config(git) git
+
+# Verbose mode
+set config(verbose) 0
+
+# Overwrite existing patch files?
+set config(overwriteExistingPatches) 0
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# #
+# Section II - Helper procedures #
+# #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+###
+### FreeBSD ports
+###
+
+## Gets FreeBSD port's patch filename
+##
+## @param $file the files the patch modifies
+## @return the patch filename
+proc get_patch_filename {file} {
+ return patch-[string map {_ __ / -} $file]
+}
+
+###
+### Git
+###
+
+## Creates a patch from a modified file in a Git repository
+proc create_patch_from_git_file {file patchfile {useStagingArea 0}} {
+ global config
+ if $useStagingArea {
+ set command "$config(git) diff --no-prefix --cached $file"
+ } {
+ set command "$config(git) diff --no-prefix $file"
+ }
+ exec -- {*}$command > $patchfile
+}
+
+## Gets modified file from git status
+proc get_modified_files {} {
+ global config
+ set files {}
+ foreach "operation file" [exec $config(git) status --porcelain] {
+ if {$operation == "M"} {
+ lappend files $file
+ }
+ }
+ return $files
+}
+
+## Generates patches from Git working directory
+##
+## @param $patchesdir the patches directory
+##
+## @todo handle created files (A)
+## @todo handle copied files (C)
+## @todo handle renamed files (R)
+## @todo handle deleted files (D)
+proc generate_patches_from_git_working_directory {patchesdir} {
+ global config
+ foreach file [get_modified_files] {
+ # Determines the FreeBSD port file name and call git diff
+ set patchfile $patchesdir/[get_patch_filename $file]
+ if {!$config(overwriteExistingPatches) && [file exists $patchfile]} {
+ puts "* Ignoring $file ($patchfile already exists)"
+ } {
+ create_patch_from_git_file $file $patchfile
+ if $config(verbose) {puts "* Patching $file ($patchfile)"}
+ }
+ }
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# #
+# Section III - Procedural code #
+# #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+###
+### Step 1 - We need a patches directory
+###
+### The script will do one of the following operation
+### - create a files directory in the port, if this doesn't exist
+### - use an existing port files directory
+### - use the directory specified as script argument
+###
+
+set wrksrc [exec pwd]
+if {$argc == 0} {
+ # Autodetect the directory
+ #
+ # We're probably in /usr/ports/quux/foo/work/foo-a.b
+ # Patches directory is so ../../files
+ set pos [string first /work/ $wrksrc]
+ if {$pos == -1} {
+ puts "Please specify the directory where to save the patches."
+ exit
+ }
+ set patchesdir [string range $wrksrc 0 $pos]files
+ if [file isdirectory $patchesdir] {
+ # All rules!
+ } elseif [file exists $patchesdir] {
+ # Achievement unlocked: the weird error the developer tooks care of
+ puts "Your port patches directory should be $patchesdir but this is currently a file."
+ exit
+ } {
+ # Create the directory
+ file mkdir $patchesdir
+ }
+} {
+ # Patches directory specified as argument
+ if ![file isdirectory [set patchesdir [lindex $argv 0]]] {
+ puts "Directory not found: $patchesdir"
+ exit
+ }
+}
+
+###
+### Step 2 - Generate patches
+###
+### Currently, we use git status
+###
+
+generate_patches_from_git_working_directory $patchesdir
diff --git a/roles/devserver/userland-home/files/dereckson/bin/update-git-prompt b/roles/devserver/userland-home/files/dereckson/bin/update-git-prompt
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/update-git-prompt
@@ -0,0 +1,5 @@
+# Usage: add to your .cshrc file the following alias:
+# alias precmd 'source ~/bin/update-git-prompt'
+
+setenv GIT_BRANCH_CMD "sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'"
+set prompt="%B%/%b `$GIT_BRANCH_CMD`] "
diff --git a/roles/devserver/userland-home/init.sls b/roles/devserver/userland-home/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-home/init.sls
@@ -0,0 +1,20 @@
+# -------------------------------------------------------------
+# Salt — Provision dotfiles and other personal content
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2018-03-08
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% for username, user in salt['forest.get_users']().items() %}
+{% if 'deploy_dotfiles_to_devserver' in user %}
+dotfiles_to_devserver_{{username}}:
+ file.recurse:
+ - name: /home/{{ username }}
+ - source: salt://roles/devserver/userland-home/files/dereckson
+ - include_empty: True
+ - clean: False
+ - user: {{ username }}
+ - group: {{ username }}
+{% endif %}
+{% endfor %}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 02:14 (20 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2263761
Default Alt Text
D1402.diff (23 KB)
Attached To
Mode
D1402: Provision dotfiles and bin commands for dereckson on devserver role
Attached
Detach File
Event Timeline
Log In to Comment