skzbsd-build

This commit is contained in:
Samuel Aubertin 2023-10-09 11:42:06 +02:00
commit ecfdba4335
16 changed files with 476 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
release

43
Makefile Normal file
View File

@ -0,0 +1,43 @@
.DEFAULT_GOAL := all
OPACK_TARGET= skzbsd-build-current
OPACK_SYS_VERSION= snapshots
OPACK_SYS_CPU= 8
OPACK_SYS_MEMORY= 32768
OPACK_SYS_DISK_SIZE= 65536
OPACK_AUTODISKLABEL_FILE= ./autodisklabel
OPACK_SYS_USER= build
OPACK_SYS_SETS= +* -game*
include ../skz-opack/src/opack.mk
.PHONY: sync provision cleanrelease halt
RELEASE= release
SRC= ../skzbsd-src
TARGET= SKZ-VIRT
cleanrelease:
rm -rf $(RELEASE)
ssh-config: opack
(echo Host $(OPACK_TARGET) && (vagrant ssh-config | sed '1d')) > $@
sync: ssh-config
scp -F ssh-config -q -r src $(OPACK_TARGET):/root/build
scp -F ssh-config -q -r $(SRC)/. $(OPACK_TARGET):/usr/src
provision: sync
vagrant ssh -c "make -C build all" || true
sleep 30 && while ! nc -z -w 10 $(shell grep HostName ssh-config | awk '{print $$2}') 22 2> /dev/null ; do sleep 10; printf '#'; done;\
$(RELEASE): provision
mkdir -p $@
vagrant ssh -c "BUILD_TARGET=$(TARGET) make -C build/release all" || vagrant ssh -c "cat /var/log/master_build.log.err"
scp -F ssh-config -q -r $(OPACK_TARGET):'/home/build/master/*' $@
halt: $(RELEASE)
vagrant halt
all: halt

11
autodisklabel Normal file
View File

@ -0,0 +1,11 @@
/ 1G
swap 1G-16G 2%
/tmp 1G-8G 2%
/var 1G-* 15%
/usr 8G-12G 2%
/usr/X11R6 2G-3G 2%
/usr/local 8G-12G 4%
/usr/src 8G-12G 4%
/usr/obj 6G-12G 9%
/home 4G-* 4%
/dest 20G-* 55%

11
src/Makefile Normal file
View File

@ -0,0 +1,11 @@
.SILENT:
SUBDIR+= system
SUBDIR+= sshd
SUBDIR+= ksh
SUBDIR+= vim
SUBDIR+= perf
SUBDIR+= build
SUBDIR+= reboot
.include <bsd.subdir.mk>

4
src/build/Makefile Normal file
View File

@ -0,0 +1,4 @@
all:
@-usermod -G wsrc,wheel -L build build
@-mkdir -p /home/build; chown build /home/build

3
src/ksh/Makefile Normal file
View File

@ -0,0 +1,3 @@
all:
cp kshrc /root/.kshrc
touch /root/.ksh_history

23
src/ksh/kshrc Normal file
View File

@ -0,0 +1,23 @@
. /etc/colors.inc
HISTCONTROL=ignoredumps
HISTSIZE=100000
HISTFILE=$HOME/.ksh_history
PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games
escape=$(print '\033')
ctrla=$(print '\001')
PS1=$(print '\001\015')
PS1=$PS1$ctrla$escape'[38;5;57m'$ctrla
PS1=$PS1$(logname)@$(hostname -s)
PS1=$PS1$escape'[38;5;55m'
PS1=$PS1':'
PS1=$PS1$escape'[38;5;75m'
PS1=$PS1'$(echo $PWD | sed s",$HOME,~,")'
PS1=$PS1$escape'[38;5;$(($? ? 97 : 27))m'
PS1=$PS1' $'
PS1=$PS1$escape'[0m'#ctrla' '
umask 027
TERM=xterm-256color
export PATH HISTFILE HISTSIZE LC_CTYPE HOME TERM PS1
eval $(keychain --eval -Q --quiet id_ed25519)

24
src/perf/Makefile Normal file
View File

@ -0,0 +1,24 @@
SUM?!=sha256 -q /etc/fstab
CACHEPERCENT=33
MAXFILES=65536
all:
@touch /etc/sysctl.conf
@[ $$(sysctl -n hw.ncpufound) == 1 ] && echo sp \
|| (sysctl hw.smt=1; grep smt /etc/sysctl.conf \
|| echo hw.smt=1 >> /etc/sysctl.conf)
@grep bufcachepercent /etc/sysctl.conf \
|| (echo kern.bufcachepercent=$(CACHEPERCENT) >> /etc/sysctl.conf \
&& sysctl kern.bufcachepercent=$(CACHEPERCENT))
@grep maxlocksperuid /etc/sysctl.conf \
|| (echo kern.maxlocksperuid=2048 >> /etc/sysctl.conf \
&& sysctl kern.maxlocksperuid=2048)
@grep kern.maxfiles /etc/sysctl.conf \
|| (echo kern.maxfiles=$(MAXFILES) >> /etc/sysctl.conf \
&& sysctl kern.maxfiles=$(MAXFILES))
@cp login.conf /etc/login.conf \
&& cap_mkdb /etc/login.conf
@sed -i s'/dest ffs rw/dest ffs rw,noperm/' /etc/fstab
@sed -i s'/nodev/noatime,nodev/' /etc/fstab
@-[ $$(sha256 -q /etc/fstab) == '$(SUM)' ] || echo "fstab" > /root/MUST_REBOOT && mount -s /dest

121
src/perf/login.conf Normal file
View File

@ -0,0 +1,121 @@
# $OpenBSD: login.conf,v 1.8 2019/11/05 19:03:46 solene Exp $
#
# Sample login.conf file. See login.conf(5) for details.
#
#
# Standard authentication styles:
#
# passwd Use only the local password file
# chpass Do not authenticate, but change user's password (change
# the YP password if the user has one, else change the
# local password)
# lchpass Do not login; change user's local password instead
# radius Use radius authentication
# reject Use rejected authentication
# skey Use S/Key authentication
# activ ActivCard X9.9 token authentication
# crypto CRYPTOCard X9.9 token authentication
# snk Digital Pathways SecureNet Key authentication
# tis TIS Firewall Toolkit authentication
# token Generic X9.9 token authentication
# yubikey YubiKey authentication
#
# Default allowed authentication styles
auth-defaults:auth=passwd,skey:
# Default allowed authentication styles for authentication type ftp
auth-ftp-defaults:auth-ftp=passwd:
#
# The default values
# To alter the default authentication types change the line:
# :tc=auth-defaults:\
# to read something like: (enables passwd, "myauth", and activ)
# :auth=passwd,myauth,activ:\
# Any value changed in the daemon class should be reset in default
# class.
#
default:\
:path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/local/bin /usr/local/sbin:\
:umask=022:\
:datasize-max=8192M:\
:datasize-cur=1024M:\
:maxproc-max=1024:\
:maxproc-cur=512:\
:openfiles-max=32535:\
:openfiles-cur=4096:\
:stacksize-cur=32M:\
:localcipher=blowfish,8:\
:tc=auth-defaults:\
:tc=auth-ftp-defaults:
build:\
:datasize-max=infinity:\
:datasize-cur=1024M:\
:maxproc-max=4096:\
:maxproc-cur=512:\
:openfiles-max=32535:\
:openfiles-cur=4096:\
:stacksize-cur=32M:\
:priority=-10:\
:tc=default:
#
# Settings used by /etc/rc and root
# This must be set properly for daemons started as root by inetd as well.
# Be sure to reset these values to system defaults in the default class!
#
daemon:\
:ignorenologin:\
:datasize=infinity:\
:maxproc=infinity:\
:openfiles-max=1024:\
:openfiles-cur=128:\
:stacksize-cur=8M:\
:localcipher=blowfish,9:\
:tc=default:
#
# Staff have fewer restrictions and can login even when nologins are set.
#
staff:\
:datasize-cur=512M:\
:datasize-max=infinity:\
:maxproc-max=512:\
:maxproc-cur=128:\
:ignorenologin:\
:requirehome@:\
:tc=default:
#
# Authpf accounts get a special motd and shell
#
authpf:\
:welcome=/etc/motd.authpf:\
:shell=/usr/sbin/authpf:\
:tc=default:
#
# Building ports with DPB uses raised limits
#
pbuild:\
:datasize-max=infinity:\
:datasize-cur=1024M:\
:maxproc-max=1024:\
:maxproc-cur=256:\
:priority=5:\
:tc=default:
#
# Override resource limits for certain daemons started by rc.d(8)
#
bgpd:\
:openfiles=512:\
:tc=daemon:
unbound:\
:openfiles=512:\
:tc=daemon:

5
src/reboot/Makefile Normal file
View File

@ -0,0 +1,5 @@
all:
echo 'MUST_REBOOT' | wall
sync
-(sleep 5; nohup reboot) &
-reboot

23
src/sshd/Makefile Normal file
View File

@ -0,0 +1,23 @@
TEMP?!=mktemp
/root/.ssh/id_ed25519:
ssh-keygen -N '' -t ed25519 -f $@ > /dev/null
/etc/banner:
printf 'OpenBSD builder\n' > $@
all: /root/.ssh/id_ed25519 /etc/banner
printf 'PasswordAuthentication yes\
\nPermitRootLogin yes\
\nBanner /etc/banner\
\nClientAliveInterval 120\
\nClientAliveCountMax 55040\
\n' > $(TEMP)
cat /etc/ssh/sshd_config >> $(TEMP)
sshd -tf $(TEMP)
cp $(TEMP) /etc/ssh/sshd_config
rm $(TEMP)
printf 'StrictHostKeyChecking no\
\nUserKnownHostsFile=/dev/null\n' > /etc/ssh/ssh_config
rcctl restart sshd > /dev/null

10
src/system/Makefile Normal file
View File

@ -0,0 +1,10 @@
PACKAGES=keychain-- htop-- git-- vim--no_x11-python3 ccache--
/etc/colors.inc:
cp colors $@ && chmod 644 $@
all: /etc/colors.inc
-pkg_add -I $(PACKAGES)
-pkg_add -I -D snap $(PACKAGES)
sed -i 's/\..*/.sk4.nz/' /etc/myname
rcctl disable sndiod slaacd check_quotas

66
src/system/colors Normal file
View File

@ -0,0 +1,66 @@
## Reset to normal: \033[0m
NORM="\033[0m"
## Colors:
BLACK="\033[0;30m"
GRAY="\033[1;30m"
RED="\033[0;31m"
LRED="\033[1;31m"
GREEN="\033[0;32m"
LGREEN="\033[1;32m"
YELLOW="\033[0;33m"
LYELLOW="\033[1;33m"
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
PURPLE="\033[0;35m"
PINK="\033[1;35m"
CYAN="\033[0;36m"
LCYAN="\033[1;36m"
LGRAY="\033[0;37m"
WHITE="\033[1;37m"
## Backgrounds
BLACKB="\033[0;40m"
REDB="\033[0;41m"
GREENB="\033[0;42m"
YELLOWB="\033[0;43m"
BLUEB="\033[0;44m"
PURPLEB="\033[0;45m"
CYANB="\033[0;46m"
GREYB="\033[0;47m"
## Attributes:
UNDERLINE="\033[4m"
BOLD="\033[1m"
INVERT="\033[7m"
## Cursor movements
CUR_UP="\033[1A"
CUR_DN="\033[1B"
CUR_LEFT="\033[1D"
CUR_RIGHT="\033[1C"
## Start of display (top left)
SOD="\033[1;1f"
## Example - Red underlined
#echo "${RED}${UNDERLINE}This is a test!${NORM}"
#
### Example - different colors
#echo "${RED}This ${YELLOW}is ${LBLUE}a ${INVERT}test!${NORM}"
#
### Example - cursor movement
#echo " ${CUR_RIGHT}Test"
#sleep 5
#
### Create a rotating thingy
#while true ; do
#echo -en "${CUR_LEFT}/"
#sleep 0.1
#echo -en "${CUR_LEFT}-"
#sleep 0.1
#echo -en "${CUR_LEFT}\\"
#sleep 0.1
#echo -en "${CUR_LEFT}|"
#done

16
src/vim/Makefile Normal file
View File

@ -0,0 +1,16 @@
/usr/local/share/vim/vimrc:
@cp vimrc $@
/usr/local/share/vim/vimfiles/bundle/Vundle.vim:
@git clone https://github.com/VundleVim/Vundle.vim.git $@
/usr/local/share/vim/vimfiles/colors:
@mkdir -p $@
/usr/local/share/vim/vimfiles/colors/mustang.vim: /usr/local/share/vim/vimfiles/colors
@cp mustang.vim $@
/root/.vim/bundle/:
cd /root; vim +PluginInstall +qall 2>&1 > /dev/null
all: /usr/local/share/vim/vimfiles/bundle/Vundle.vim /usr/local/share/vim/vimfiles/colors/mustang.vim /root/.vim/bundle/ /usr/local/share/vim/vimrc

52
src/vim/mustang.vim Normal file
View File

@ -0,0 +1,52 @@
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "mustang"
" Vim >= 7.0 specific colors
if version >= 700
hi CursorLine guibg=#2d2d2d ctermbg=236
hi CursorColumn guibg=#2d2d2d ctermbg=236
hi ColorColumn guibg=#000000 ctermbg=235
hi MatchParen guifg=#d0ffc0 guibg=#2f2f2f gui=bold ctermfg=157 ctermbg=237 cterm=bold
hi Pmenu guifg=#ffffff guibg=#444444 ctermfg=255 ctermbg=238
hi PmenuSel guifg=#000000 guibg=#b1d631 ctermfg=0 ctermbg=148
endif
" General colors
hi Cursor guifg=NONE guibg=#626262 gui=none ctermbg=241
hi Normal guifg=#e2e2e5 guibg=#202020 gui=none ctermfg=253 ctermbg=none
hi NonText guifg=#808080 guibg=#303030 gui=none ctermfg=244 ctermbg=none
hi LineNr guifg=#808080 guibg=#000000 gui=none ctermfg=244 ctermbg=232
hi StatusLine guifg=#d3d3d5 guibg=#444444 gui=italic ctermfg=253 ctermbg=238 cterm=italic
hi StatusLineNC guifg=#939395 guibg=#444444 gui=none ctermfg=246 ctermbg=238
hi VertSplit guifg=#444444 guibg=#444444 gui=none ctermfg=238 ctermbg=238
hi Folded guibg=#384048 guifg=#a0a8b0 gui=none ctermbg=4 ctermfg=248
hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=254 cterm=bold
hi Visual guifg=#faf4c6 guibg=#3c414c gui=none ctermfg=254 ctermbg=4
hi SpecialKey guifg=#808080 guibg=#343434 gui=none ctermfg=244 ctermbg=236
" Syntax highlighting
hi Comment guifg=#808080 gui=italic ctermfg=244
hi Todo guifg=#8f8f8f gui=italic ctermfg=245
hi Boolean guifg=#b1d631 gui=none ctermfg=148
hi String guifg=#b1d631 gui=italic ctermfg=148
hi Identifier guifg=#b1d631 gui=none ctermfg=148
hi Function guifg=#ffffff gui=bold ctermfg=255
hi Type guifg=#7e8aa2 gui=none ctermfg=103
hi Statement guifg=#7e8aa2 gui=none ctermfg=103
hi Keyword guifg=#ff9800 gui=none ctermfg=208
hi Constant guifg=#ff9800 gui=none ctermfg=208
hi Number guifg=#ff9800 gui=none ctermfg=208
hi Special guifg=#ff9800 gui=none ctermfg=208
hi PreProc guifg=#faf4c6 gui=none ctermfg=230
hi Todo guifg=#000000 guibg=#e6ea50 gui=italic
" Code-specific colors
hi pythonOperator guifg=#7e8aa2 gui=none ctermfg=103
hi Search cterm=NONE ctermbg=yellow

63
src/vim/vimrc Normal file
View File

@ -0,0 +1,63 @@
set nocompatible
filetype off
set rtp+=/usr/local/share/vim/vimfiles/bundle/Vundle.vim
call vundle#begin()
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
Plugin 'vim-airline/vim-airline'
call vundle#end()
"Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_c_compiler = "clang"
function! SyntasticCheckHook(errors)
if !empty(a:errors)
let g:syntastic_loc_list_height = min([len(a:errors), 6])
endif
endfunction
"Airline
let g:airline_powerline_fonts = 0
set noshowmode " to get rid of thing like --INSERT--
set noshowcmd " to get rid of display of last command
set shortmess+=F " to get rid of the file name displayed in the command line bar
"Global options
set backspace=indent,eol,start "allow backspacing over everything in insert mode
set history=500 "keep 50 lines of command line history
set ruler "show the cursor position all the time
set showcmd "display incomplete commands
set incsearch "do incremental searching
set nu "show line numbers
set expandtab "use spaces instead of tabs
"set tabstop=4 "insert 4 spaces whenever the tab key is pressed
"set shiftwidth=4 "set indentation to 4 spaces
set hlsearch "highlight search terms
set ic "Ignore Case during searches
set autoindent "start new line at the same indentation level
syntax enable "syntax highlighting
set cmdheight=1 "The commandbar height
set showmatch "Show matching bracets when text indicator is over them
set nobackup " do not keep backup files, it's 70's style cluttering
set noswapfile " do not write annoying intermediate swap files,
set ttimeoutlen=50 "Solves: there is a pause when leaving insert mode
set splitbelow " Horizontal splits open below current file
set splitright " Vertical splits open to the right of the current file
set wildmode=longest,list " Pressing <Tab> shows command suggestions similar
set t_Co=256
colorscheme mustang
set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file
"hi ColorColumn ctermbg=235
"let &colorcolumn=join(range(81,999),",")
autocmd BufRead,BufNewFile *.md *.latex *.tex set spell spelllang=en,fr