git branch transport
How to export / import the branch
bad-tree% git format-patch --stdout main..foo | \ssh remote "(cd some/path && git checkout main && \git checkout -b foo && git am)"
so that's it. We format the patches for everything from the mainline through the end of foo. It doesn't matter where 'foo' is off main. The main.. notation is such that it does the right thing (see gitrevisions(7) for all you could do here).
On the receiving side, we cd to git svn repo (or really any repo, this technique generalizes if you're moving patches between projects, though you may need to apply odd pipeline filters to change paths), make sure we have a clean tree with 'git checkout main' (though I suppose I could make that more robust). We create a new branch foo and then we apply the patch. Easy, simple, no muss, no fuss.
BTW I use '&&' above in case I've fat fingered anything, or there's already a foo branch, etc, it will fail as early as possible.
But what about when things go wrong...
One Last Hack
cd freebsdgit format-patch --stdout main..zstd sys/contrib/openzfs | \sed -e 's=/sys/contrib/openzfs/=/=g' | \(cd ../zfs ; git checkout master && git branch -b zstd && \git am)
This nicely moved the patches from one tree to the other to make it easier for me to create my pull request. Your milage may vary, and I've had to play around with the filter to make sure I didn't catch unwanted things in it... I've not taken the time to create a regexp for the lines that I need to apply the sed to for maximum safety, but so far I've gotten lucky that the above path isn't an any of the files I want to transport this way...
A 35 Year Old Bug in Patch.
What is the bug?
*** /usr/src/bin/sh/mac.h.old Fri Dec 24 18:44:31 1982--- /usr/src/bin/sh/mac.h Mon Jan 18 08:45:24 1993****************** 59,63 ****#define RQ '\''#define MINUS '-'#define COLON ':'-- #define MAX(a,b) ((a)>(b)?(a):(b))--- 59,61 ----
--------------------------|*** /usr/src/bin/sh/mac.h.old Fri Dec 24 18:44:31 1982|--- /usr/src/bin/sh/mac.h Mon Jan 18 08:45:24 1993--------------------------Patching file usr/src/bin/sh/mac.h using Plan A...No such line 62 in input file, ignoringHunk #1 succeeded at 53 with fuzz 1 (offset -6 lines).done
Which looks odd. Why is it complaining about a line that isn't there? why did it misapply the patch 6 lines earlier? It thinks it succeeded, but really added back the MAX macro line too early.
Where is the bug?
****************** 59,61 ****--- 59,63 ----#define RQ '\''#define MINUS '-'#define COLON ':'++ #define MAX(a,b) ((a)>(b)?(a):(b))
****************** 59,61 ****--- 59,63 ----
Side note: Old Style Context Diffs
Recovering 2.11BSD, fighting the patches
- The kernel logger (/dev/klog)
- The namei cache and argument encapsulation calling sequence
- readv(2)/writev(2) as system calls rather than emulation/compatibility routines
- Shadow password file implementation (the May 1989 4.3BSD update)
- A TMSCP (TK50/TU81) driver with standalone support (bootblock and standalone driver)
- Pronet and LH/DH IMP networking support
- The portable ascii archive file format (ar, ranlib)
- The Unibus Mapping Register (UMR) handling of the network was rewritten to avoid allocating excessive UMRs.
- The necessary mods to the IP portion of the networking were made to allow traceroute (which is present in 2.11BSD) to run.
- Long filenames in the file system
Fix:Apply the patch "/tmp/dif" (multiple files updated by it) andinstall the new scripts ":splfix.mfps" and "splfix.movb+mfps".
#! /bin/sh -vcd /usr/src/usr.binrm lint/*zcat PORT/lint.tar.Z | tar xf -cd lintrm :yyfix llib-*cp -p /tmp/libs libs
The Path Forward
The Slog Backward
The /GENALLSYS script is obsolete and has been removed
Bootstrapping 2.11BSD (original)
Bootstrapping ranlib (and to get there ld and nm)
cd /scratch/usr/src/bincc -o ld -O -i ld.c -I/scratch/usr/includecc -o nm -O -i nm.c -I/scratch/usr/include
Drop into the chroot
cp as /bin
cp as2 /lib
rm as as2
cp nm ld /binrm nm ldcp /bin/true /usr/bin/ranlib
Building libc.a and crt0.o
cd /usr/src/lib/libcmake clean# Hack around make sometimes failing to descend on some runs(cd pdp/compat-4.1; make)(cd pdp; make)makemake installmake clean
Building ranlib (for real)
cd /usr/src/usr.bincc -o ranlib -O -i ranlib.c -lccp ranlib /usr/binranlib /lib/libc.a
Finishing up the Bootstrapping
cd /usr/src/binmake ar stripcp ar strip /bin
cd /usr/src/usr.binmake xinstallcp xinstall /usr/bin/install
Doing the Build
cd /usr/srcmake cleanmake allmake installmake cleanmake allmake install
for i in ccom cpp c2 libc ccom cpp c2; do
(cd $i; make all install)
for i in lib[0-9A-Za-z]*; do
(cd $i; make all install; make clean)
doneln /usr/lib/libom.a /usr/lib/libm.acd ..
make installmake clean
Building the Kernel
cd /usr/src/sys/GENERICmake && make install && (cd / ; cp unix genunix; sh -x /GENALLSYS)
Building all the Standalone Programs
cd /sys/mdecmake && make install && make cleancd /sys/autoconfigmake && make install && make cleancd /sys/pdpstandmake && make install && make clean
2.11BSD Missing Patches
sim> boot rqboot: 73Boot: ra(0,0)unix2.11 BSD UNIX #1: Fri Mar 15 15:48:55 PST email@example.com:/usr/src/sys/GENERICphys mem = 4186112avail mem = 4008640user mem = 307200Apr 10 13:50:01 init: configure systemra 0 csr 172150 vector 154 attachedrl 0 csr 174400 vector 160 attachedtms 0 csr 174500 vector 260 attachedts 0 csr 172520 vector 224 attachedxp 0 csr 176700 vector 254 attachederase, kill ^U, intr ^C# date 9104151234date: can't write wtmp file.Mon Apr 15 12:34:00 PDT 1991# Fast boot ... skipping disk checks/dev/ra0c on /usr: Device busychecking quotas: done.Assuming non-networking system ...preserving editor filesclearing /tmpstandard daemons: update cron accounting.starting lpdstarting local daemons:.Mon Apr 15 12:34:01 PDT 19912.10 BSD UNIX (my.domain.name) (console)login:
-rw-r--r-- 1 imp imp 9777 Aug 31 1991 alloc.c-rw-r--r-- 1 imp imp 4817 Aug 31 1991 alloc11.c-rw-r--r-- 1 imp imp 12474 Aug 31 1991 doprnt.c-rw-r--r-- 1 imp imp 3299 Feb 23 1987 doprnt11.s-rw-r--r-- 1 imp imp 831 Aug 31 1991 printf.c-rw-r--r-- 1 imp imp 20446 Aug 31 1991 sh.c-rw-r--r-- 1 imp imp 1771 Aug 31 1991 sh.char.c
The Catch Up Patch
- Script to undo all the patches, including helper 'hints' scripts, where possible from existing artifacts.
- Miss patches reconstructed and integrated into the build
- Automated installing 2.11BSDpl195 image
- Automated bootstrapping back from 195 -> 0. There's a number of interesting problems here that I'll blog about soon
- Building the 2.11BSD pl 0 tapes automatically
- Test installing the pl 0 system from the pl 0 tapes.
- Getting the dates right (or failing that plausible) for the patched files
- Finishing the date audit and tracking all anomalies to ground.
- Cleaning up my helper scripts off the image
- Creating a github repo with all the patches in it
- Reproducing the build on a second system
- Getting the ownership right for some files (eg using the mtree hack to get the ownership and permissions right, generating it from the pl195 tape/image, etc)
- Getting dates right on /, right now restor(8) doesn't restore the date in one at a time mode, so these are all wrong.
- Fixing tmscp boot. It's broken. The tmscpboot.s, ported from tkboot.s, only existed for a short period of time and has been lost. My reconstruction has issues (it won't boot), and I've not delved into why.
- Creating automation to ensure that the 'catch up' kit will apply cleanly.
History of Reboot(2)
That sync; sync; sync Thing...
foreach mountpointwrite superblock with bwritefor each dirty inodewrite the inode with iupdatbflush
Why not do this in reboot(2)?
lock = 53.ioctl = 54.reboot = 55.mpx = 56.setinf = 59.
1, 0, syslock, /* 53 = lock user in core */3, 0, ioctl, /* 54 = ioctl */0, 0, nosys, /* 55 = readwrite (in abeyance) */4, 0, mpxchan, /* 56 = creat mpx comm channel */0, 0, nosys, /* 57 = reserved for USG */0, 0, nosys, /* 58 = reserved for USG */3, 0, exece, /* 59 = exece */
3, 0, ioctl, /* 54 = ioctl */1, 0, reboot, /* 55 = reboot */4, 0, mpxchan, /* 56 = creat mpx comm channel */