Skip to content

Instantly share code, notes, and snippets.

View uebayasi's full-sized avatar

Masao Uebayashi uebayasi

  • Tombi Inc.
  • Yokohama, Kanagawa, Japan
View GitHub Profile
@uebayasi
uebayasi / make-stale-fail.patch
Created February 10, 2013 07:51
This makes NetBSD's make(1) behaviour when encountering stale depend from only printing error and continuing build, to exiting build. Stale dependency should be considred as an erroneous state of build (object) tree.
Index: usr.bin/make/dir.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/dir.c,v
retrieving revision 1.65
diff -u -p -r1.65 dir.c
--- usr.bin/make/dir.c 12 Jun 2012 19:21:50 -0000 1.65
+++ usr.bin/make/dir.c 10 Feb 2013 06:45:36 -0000
@@ -1463,9 +1463,15 @@ Dir_MTime(GNode *gn, Boolean recheck)
* so that we give that to the compiler.
*/
@uebayasi
uebayasi / gist:5678249
Created May 30, 2013 14:27
EdgeRouter LITE original "printenv"
bootcmd=fatload usb 0 $loadaddr vmlinux.64;bootoctlinux $loadaddr coremask=0x3 root=/dev/sda2 rootdelay=15 rw rootsqimg=squashfs.img rootsqwdir=w mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@3072k(eeprom)
bootdelay=0
baudrate=115200
download_baudrate=115200
nuke_env=protect off $(env_addr) +$(env_size);erase $(env_addr) +$(env_size)
autoload=n
ethact=octeth0
loadaddr=0x9f00000
numcores=2
stdin=serial
@uebayasi
uebayasi / zrc
Last active December 19, 2015 22:49
zrc - Run interactive zsh with a specified RC file
#! /bin/sh
set -e
rc=$1
tmpdir=$( mktemp -d /tmp/tmpzdotdir.XXXXXX )
cp "$rc" "${tmpdir}/.zshrc" &&
env ZDOTDIR="${tmpdir}" zsh -d
res=$?
rm -fr "${tmpdir}"
exit $res
@uebayasi
uebayasi / openbsd-minimal-install.md
Last active March 19, 2019 05:34
OpenBSD minimal install
  1. Prepare a filesystem for a new root
  • newfs a filesystem and mount and cd there
  1. Fill the new root
  • Extract baseXX.tgz to ${root}
    • doas tar xzpf baseXX.tgz -C ${root}
  • Extract ${root}/var/sysmerge/etc.tgz
    • doas tar xzpf ${root}/var/sysmerge/etc.tgz -C ${root}
  • Copy the kernel to ${root}/bsd
  1. Configure
  • ( cd ${root}/dev && sh MAKEDEV all )
@uebayasi
uebayasi / vmware-tips.md
Last active December 20, 2015 07:38
VMware tips (including Fusion)

Serial console

Forwarding as telnet

serial0.present = "TRUE"
serial0.fileType = "network"
serial0.fileName = "telnet://127.0.0.1:10001"
serial0.startConnected = "TRUE"

This worked for VMware Fusion 5. Should also work on VMware Workstation.

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
NetBSD 6.99.23 (GENERIC) #0: Thu Aug 8 19:07:01 UTC 2013
[email protected]:/home/builds/ab/HEAD/amd64/201308081710Z-obj/home/builds/ab/HEAD/src/sys/arch/amd64/compile/GENERIC
total memory = 98258 MB
avail memory = 95392 MB

Basic

  • Don't try "unprivileged" build from start.
    • First do cross-dirs/cross-tools/cross-distrib as root (sudo).
    • Then change owner/mode of obj directories. This will make development easier.
  • Always use cross build (for development).
    • Otherwise you'll overwrite your /usr/include during build.
    • Cross build can't make release on OpenBSD, unfortunately (because of gnu/, where Makefile.bsd-wrapper is used). So cross build is only for development.

Tips

  • Phony is evil
  • Keep makefiles contain only dependency
  • Don't define -DXXX in makefiles (makefile changes output content)
  • If do so, output has to depend on makefile itself (evil road...)
  • How to pass vars to sub-make ("VAR=val make" vs. "env VAR=val make" vs. "make VAR=val")
  • Evaluation order (variables are evaluated at statements like .if, .for, ...)
  • .SUFFIXES (inference rule) is GREAT
  • Don't treat directories as input/output
  • Concepts
    • "Tool"
    • "Host"
    • "Release"
    • "Sets"
    • "Object"
    • "Wrapper"
    • "Reach-over"
    • "METALOG"
  • Build order

Preparation and configuration

Host

dhcpd

/etch/dhcpd.conf
option domain-name "my.domain";