A fully Go userland with Linux bootloaders! u-root can create a one-binary root file system (initramfs) containing a busybox-like set of tools written in Go.

Overview

u-root

Build Status codecov Go Report Card GoDoc Slack License

Description

u-root embodies four different projects.

  • Go versions of many standard Linux tools, such as ls, cp, or shutdown. See cmds/core for most of these.

  • A way to compile many Go programs into a single binary with busybox mode.

  • A way to create initramfs (an archive of files) to use with Linux kernels.

  • Go bootloaders that use kexec to boot Linux or multiboot kernels such as ESXi, Xen, or tboot. They are meant to be used with LinuxBoot. With that, parsers for GRUB config files or syslinux config files are to make transition to LinuxBoot easier.

⚠️ Go Modules are Broken ⚠️

u-root itself builds fine with modules. When adding commands to your busybox which are outside u-root, make sure to export GO111MODULE=off both when geting the command (so that the command is found under $GOPATH/src and when running the u-root command (so that you can run the u-root command from any directory).

For example:

GO111MODULE=off go get github.com/nsf/godit
GO111MODULE=off u-root all github.com/nsf/godit

Usage

Make sure your Go version is >=1.15. Make sure your GOPATH is set up correctly.

Download and install u-root:

go get github.com/u-root/u-root

You can now use the u-root command to build an initramfs. Here are some examples:

# Build an initramfs of all the Go cmds in ./cmds/core/... (default)
u-root

# Generate an archive with bootloaders
#
# core and boot are templates that expand to sets of commands
u-root core boot

# Generate an archive with only these given commands
u-root cmds/core/{init,ls,ip,dhclient,wget,cat,elvish}

# Generate an archive with all of the core tools with some exceptions
u-root core -cmds/core/{ls,losetup}

# Generate an archive with a tool outside of u-root
u-root cmds/core/{init,ls,elvish} github.com/u-root/cpu/cmds/cpud

The default set of packages included is all packages in github.com/u-root/u-root/cmds/core/....

In addition to using paths to specify Go source packages to include, you may also use Go package import paths (e.g. golang.org/x/tools/imports) to include commands. Only the main package and its dependencies in those source directories will be included. For example:

You can build the initramfs built by u-root into the kernel via the CONFIG_INITRAMFS_SOURCE config variable or you can load it separately via an option in for example Grub or the QEMU command line or coreboot config variable.

Extra Files

You may also include additional files in the initramfs using the -files flag. If you add binaries with -files are listed, their ldd dependencies will be included as well. As example for Debian, you want to add two kernel modules for testing, executing your currently booted kernel:

NOTE: these files will be placed in the $HOME dir in the initramfs.

u-root -files "$HOME/hello.ko $HOME/hello2.ko"
qemu-system-x86_64 -kernel /boot/vmlinuz-$(uname -r) -initrd /tmp/initramfs.linux_amd64.cpio

To specify the location in the initramfs, use : . For example:

u-root -files "root-fs/usr/bin/runc:usr/bin/run"

Init and Uinit

u-root has a very simple (exchangable) init system controlled by the -initcmd and -uinitcmd command-line flags.

  • -initcmd determines what /init is symlinked to. -initcmd may be a u-root command name or a symlink target.
  • -uinitcmd is run by the default u-root init after some basic file system setup. There is no default, users should optionally supply their own. -uinitcmd may be a u-root command name with arguments or a symlink target with arguments.
  • After running a uinit (if there is one), init will start a shell determined by the -defaultsh argument.

We expect most users to keep their -initcmd as init, but to supply their own uinit for additional initialization or to immediately load another operating system.

All three command-line args accept both a u-root command name or a target symlink path. Only -uinitcmd accepts command-line arguments, however. For example,

../bbin/echo # lrwxrwxrwx 0 root root 9 Dec 31 1969 init -> bbin/init qemu-system-x86_64 -kernel $KERNEL -initrd /tmp/initramfs.linux_amd64.cpio -nographic -append "console=ttyS0" # ... # [ 0.848021] Freeing unused kernel memory: 896K # 2020/05/01 04:04:39 Welcome to u-root! # _ # _ _ _ __ ___ ___ | |_ # | | | |____| '__/ _ \ / _ \| __| # | |_| |____| | | (_) | (_) | |_ # \__,_| |_| \___/ \___/ \__| # # Go Gopher # ~/> ">
u-root -uinitcmd="echo Go Gopher" ./cmds/core/{init,echo,elvish}

cpio -ivt < /tmp/initramfs.linux_amd64.cpio
# ...
# lrwxrwxrwx   0 root     root           12 Dec 31  1969 bin/uinit -> ../bbin/echo
# lrwxrwxrwx   0 root     root            9 Dec 31  1969 init -> bbin/init

qemu-system-x86_64 -kernel $KERNEL -initrd /tmp/initramfs.linux_amd64.cpio -nographic -append "console=ttyS0"
# ...
# [    0.848021] Freeing unused kernel memory: 896K
# 2020/05/01 04:04:39 Welcome to u-root!
#                              _
#   _   _      _ __ ___   ___ | |_
#  | | | |____| '__/ _ \ / _ \| __|
#  | |_| |____| | | (_) | (_) | |_
#   \__,_|    |_|  \___/ \___/ \__|
#
# Go Gopher
# ~/>

Passing command line arguments like above is equivalent to passing the arguments to uinit via a flags file in /etc/uinit.flags, see Extra Files.

Additionally, you can pass arguments to uinit via the uroot.uinitargs kernel parameters, for example:

../bbin/echo # lrwxrwxrwx 0 root root 9 Dec 31 1969 init -> bbin/init qemu-system-x86_64 -kernel $KERNEL -initrd /tmp/initramfs.linux_amd64.cpio -nographic -append "console=ttyS0 uroot.uinitargs=Go" # ... # [ 0.848021] Freeing unused kernel memory: 896K # 2020/05/01 04:04:39 Welcome to u-root! # _ # _ _ _ __ ___ ___ | |_ # | | | |____| '__/ _ \ / _ \| __| # | |_| |____| | | (_) | (_) | |_ # \__,_| |_| \___/ \___/ \__| # # Go Gopher # ~/> ">
u-root -uinitcmd="echo Gopher" ./cmds/core/{init,echo,elvish}

cpio -ivt < /tmp/initramfs.linux_amd64.cpio
# ...
# lrwxrwxrwx   0 root     root           12 Dec 31  1969 bin/uinit -> ../bbin/echo
# lrwxrwxrwx   0 root     root            9 Dec 31  1969 init -> bbin/init

qemu-system-x86_64 -kernel $KERNEL -initrd /tmp/initramfs.linux_amd64.cpio -nographic -append "console=ttyS0 uroot.uinitargs=Go"
# ...
# [    0.848021] Freeing unused kernel memory: 896K
# 2020/05/01 04:04:39 Welcome to u-root!
#                              _
#   _   _      _ __ ___   ___ | |_
#  | | | |____| '__/ _ \ / _ \| __|
#  | |_| |____| | | (_) | (_) | |_
#   \__,_|    |_|  \___/ \___/ \__|
#
# Go Gopher
# ~/>

Note the order of the passed arguments in the above example.

The command you name must be present in the command set. The following will not work:

u-root -uinitcmd="echo Go Gopher" ./cmds/core/{init,elvish}
# 2020/04/30 21:05:57 could not create symlink from "bin/uinit" to "echo": command or path "echo" not included in u-root build: specify -uinitcmd="" to ignore this error and build without a uinit

You can also refer to non-u-root-commands; they will be added as symlinks. We don't presume to know whether your symlink target is correct or not.

This will build, but not work unless you add a /bin/foobar to the initramfs.

u-root -uinitcmd="/bin/foobar Go Gopher" ./cmds/core/{init,elvish}

This will boot the same as the above.

u-root -uinitcmd="/bin/foobar Go Gopher" -files /bin/echo:bin/foobar ./cmds/core/{init,elvish}

This will bypass the regular u-root init and just launch a shell:

">
u-root -initcmd=elvish ./cmds/core/{elvish,ls}

cpio -ivt < /tmp/initramfs.linux_amd64.cpio
# ...
# lrwxrwxrwx   0 root     root            9 Dec 31  1969 init -> bbin/elvish

qemu-system-x86_64 -kernel $KERNEL -initrd /tmp/initramfs.linux_amd64.cpio -nographic -append "console=ttyS0"
# ...
# [    0.848021] Freeing unused kernel memory: 896K
# failed to put myself in foreground: ioctl: inappropriate ioctl for device
# ~/>

(It fails to do that because some initialization is missing when the shell is started without a proper init.)

Cross Compilation (targeting different architectures and OSes)

Cross-OS and -architecture compilation comes for free with Go. In fact, every PR to the u-root repo is built against the following architectures: amd64, x86 (i.e. 32bit), mipsle, armv7, arm64, and ppc64le.

Further, we run integration tests on linux/amd64, freebsd/amd64 and linux/arm64, using several CI systems. If you need to add another CI system, processor or OS, please let us know.

To cross compile for an ARM, on Linux:

GOARCH=arm u-root

If you are on OSX, and wish to build for Linux on AMD64:

GOOS=linux GOARCH=amd64 u-root

Testing in QEMU

A good way to test the initramfs generated by u-root is with qemu:

qemu-system-x86_64 -nographic -kernel path/to/kernel -initrd /tmp/initramfs.linux_amd64.cpio

Note that you do not have to build a special kernel on your own, it is sufficient to use an existing one. Usually you can find one in /boot.

If you quickly need to obtain a kernel, for example, when you are on a non-Linux system, you can assemble a URL to download one through Arch Linux's iPXE menu file. It would download from ${mirrorurl}iso/${release}/arch/boot/x86_64/vmlinuz, so just search for a mirror URL you prefer and a release version, for example, http://mirror.rackspace.com/archlinux/iso/2019.10.01/arch/boot/x86_64/vmlinuz.

Framebuffer

For framebuffer support, append a VESA mode via the vga kernel parameter:

qemu-system-x86_64 \
  -kernel path/to/kernel \
  -initrd /tmp/initramfs.linux_amd64.cpio \
  -append "vga=786"

For a list of modes, refer to the Linux kernel documentation.

Entropy / Random Number Generator

Some utilities, e.g., dhclient, require entropy to be present. For a speedy virtualized random number generator, the kernel should have the following:

CONFIG_VIRTIO_PCI=y
CONFIG_HW_RANDOM_VIRTIO=y
CONFIG_CRYPTO_DEV_VIRTIO=y

Then you can run your kernel in QEMU with a virtio-rng-pci device:

qemu-system-x86_64 \
    -device virtio-rng-pci \
    -kernel vmlinuz \
    -initrd /tmp/initramfs.linux_amd64.cpio

In addition, you can pass your host's RNG:

qemu-system-x86_64 \
    -object rng-random,filename=/dev/urandom,id=rng0 \
    -device virtio-rng-pci,rng=rng0 \
    -kernel vmlinuz \
    -initrd /tmp/initramfs.linux_amd64.cpio

SystemBoot

SystemBoot is a set of bootloaders written in Go. It is meant to be a distribution for LinuxBoot to create a system firmware + bootloader. All of these use kexec to boot. The commands are in cmds/boot.

  • pxeboot: a network boot client that uses DHCP and HTTP or TFTP to get a boot configuration which can be parsed as PXELinux or iPXE configuration files to get a boot program.

  • boot: finds all bootable kernels on local disk, shows a menu, and boots them. Supports (basic) GRUB, (basic) syslinux, (non-EFI) BootLoaderSpec, and ESXi configurations.

  • fbnetboot: a network boot client that uses DHCP and HTTP to get a boot program based on Linux, and boots it. To be merged with pxeboot.

  • localboot: a tool that finds bootable kernel configurations on the local disks and boots them.

  • systemboot: a wrapper around fbnetboot and localboot that just mimicks a BIOS/UEFI BDS behaviour, by looping between network booting and local booting. Use -uinitcmd argument to the u-root build tool to make it the boot program.

This project started as a loose collection of programs in u-root by various LinuxBoot contributors, as well as a personal experiment by Andrea Barberio that has since been merged in. It is now an effort of a broader community and graduated to a real project for system firmwares.

More detailed information about the build process for a full LinuxBoot firmware image using u-root/systemboot and coreboot can be found in the LinuxBoot book chapter about LinuxBoot using coreboot, u-root and systemboot.

You can build systemboot like this:

u-root -build=bb -uinitcmd=systemboot core github.com/u-root/u-root/cmds/boot/{systemboot,localboot,fbnetboot}

Compression

You can compress the initramfs. However, for xz compression, the kernel has some restrictions on the compression options and it is suggested to align the file to 512 byte boundaries:

xz --check=crc32 -9 --lzma2=dict=1MiB \
   --stdout /tmp/initramfs.linux_amd64.cpio \
   | dd conv=sync bs=512 \
   of=/tmp/initramfs.linux_amd64.cpio.xz

Getting Packages of TinyCore

Using the tcz command included in u-root, you can install tinycore linux packages for things you want.

You can use QEMU NAT to allow you to fetch packages. Let's suppose, for example, you want bash. Once u-root is running, you can do this:

% tcz bash

The tcz command computes and fetches all dependencies. If you can't get to tinycorelinux.net, or you want package fetching to be faster, you can run your own server for tinycore packages.

You can do this to get a local server using the u-root srvfiles command:

% srvfiles -p 80 -d path-to-local-tinycore-packages

Of course you have to fetch all those packages first somehow :-)

Build an Embeddable U-root

You can build this environment into a kernel as an initramfs, and further embed that into firmware as a coreboot payload.

In the kernel and coreboot case, you need to configure ethernet. We have a dhclient command that works for both ipv4 and ipv6. Since v6 does not yet work that well for most people, a typical invocation looks like this:

% dhclient -ipv4 -ipv6=false

Or, on newer linux kernels (> 4.x) boot with ip=dhcp in the command line, assuming your kernel is configured to work that way.

Build Modes

u-root can create an initramfs in two different modes, specified by -build:

  • bb mode: One busybox-like binary comprising all the Go tools you ask to include. See here for how it works.

    In this mode, u-root copies and rewrites the source of the tools you asked to include to be able to compile everything into one busybox-like binary.

  • binary mode: each specified binary is compiled separately and all binaries are added to the initramfs.

Updating Dependencies

go get -u
go mod tidy
go mod vendor

Hardware

If you want to see u-root on real hardware, this board is a good start.

Contributions

For information about contributing, including how we sign off commits, please see CONTRIBUTING.md.

Improving existing commands (e.g., additional currently unsupported flags) is very welcome. In this case it is not even required to build an initramfs, just enter the cmds/ directory and start coding. A list of commands that are on the roadmap can be found here.

Comments
  • Strategy for keeping Elvish updated to upstream?

    Strategy for keeping Elvish updated to upstream?

    Hi, I am the main developer of Elvish here, and I noticed that the Elvish version in u-root is now pretty old; there has been a lot of changes recently.

    I am interested in hearing about your strategy of keeping Elvish updated. So far there seems to be two main divergences:

    • u-root's fork does not have the daemon.

      This can be avoided by some refactoring on Elvish's end; in the internal API the daemon is already optional. It requires some more work to be able to a version of Elvish without the daemon from the same codebase though, but it should be doable.

    • u-root's fork does not use reflect.Value.Call.

      This is much harder to conciliate. I expect that you may need to continue redoing this change when merging Elvish.

    I can see some other smaller divergences - these that can be upstreamed instead of committed in u-root's fork (and I encourage you to do so!).

    Discussion 
    opened by xiaq 37
  • cover pkg/ipmi 2 try

    cover pkg/ipmi 2 try

    • Abstract syscall implementation behind interface
    • Hide syscalls behind interface to improve testability
    • Add mock tests for ipmi
    • Add vm tests for ipmi Signed-off-by: Christopher Meis [email protected]
    automerge Awaiting reviewer coverage 
    opened by ChriMarMe 27
  • Enable dead code elimination to reduce binary size

    Enable dead code elimination to reduce binary size

    Go's dead code elimination algorithm is described and implemented here. TLDR is: elimination of unused public methods at link time will be inhibited if reflection function calling are used anywhere.

    quick and dirty experiment shows that if DCE remains enabled, the uncompressed CPIO image size of just core goes down by ~2.3M: 15165376 -> 12707776, a 16% reduction. with all exp commands, it's about the same: 19130524 - 16562332, about 14%

    current uses of reflection in u-root are:

    1. elvish, to invoke built-in functions (here).
    2. dmidecode, to parse structs (addressed by #1476)
    3. text/template - uses reflection in struct attribute access, used in go/doc package, which is imported by go/build package.

    (3) is the toughest to address, it's all in go core libraries. but the payoff is significant, might be worth exploring.

    opened by rojer 25
  • block: fix FilterGUID

    block: fix FilterGUID

    Hey @insomniacslk @tfg13 @pmazzini do y'all use this logic? Because it is broken as far as I can tell. Take a look at this small change emphasizing what this actually does.

    Since the only usage of this doesn't do what the code seems to think it does -- can I get rid of this function and fix it so it returns the partition?

    automerge 
    opened by hugelgupf 23
  • Source mode possibly broken

    Source mode possibly broken

    I'm playing around with u-root as a replacement for Dracut in rapido (https://github.com/rapido-linux/rapido)

    I currently encounter the following error on boot:

    /usr/bin/qemu-kvm -smp cpus=2 -m 512 -kernel <bzImage> -initrd ./initrds/myinitrd -append 'ip=192.168.1.1:::255.255.255.0:rapido1 rd.systemd.unit=emergency rd.shell=1 console=ttyS0 rd.lvm=0 rd.luks=0' -pidfile ./initrds/rapido_vm1.pid -device e1000,netdev=nw1,mac=<mac> -netdev tap,id=nw1,script=no,downscript=no,ifname=tap0 -nographic
    ...
    package github.com/u-root/u-root/cmds/installcommand
            imports runtime: open /go/src/runtime/asm_ppc64x.h: no such file or directory
    2018/07/27 16:25:30 exit status 1
    2018/07/27 16:25:30 init: No suitable executable found in [/inito /bbin/uinit /buildbin/uinit /bbin/sh /bbin/rush /buildbin/sh /buildbin/rush]
    2018/07/27 16:25:30 init: Waiting for orphaned children
    2018/07/27 16:25:30 init: All commands exited
    2018/07/27 16:25:30 init: Syncing filesystems
    2018/07/27 16:25:30 init: Exiting...
    

    The image was generated by current master (569a17126131f2f320dd70ec9151a262e9e25846) on openSUSE Leap 42.3 with go 1.9.7 via:

    u-root (master)> ./u-root -format=cpio -build=source -o myinitrd ./cmds/{ls,ip,dhclient,cat,init,rush,installcommand}
    2018/07/27 18:24:26 Disabling CGO for u-root...
    2018/07/27 18:24:26 Build environment: GOARCH=amd64 GOOS=linux GOROOT=/usr/lib64/go/1.9 GOPATH=/home/ddiss/go:/usr/share/go/1.9/contrib CGO_ENABLED=0
    2018/07/27 18:24:26 Filename is initramfs.cpio
    2018/07/27 18:24:26 Collecting package files and dependencies...
    2018/07/27 18:24:28 Building go toolchain...
    2018/07/27 18:24:58 Successfully wrote initramfs.
    

    I'm not very familiar with Go, so would appreciate if someone could point me in the right direction here.

    Bug 
    opened by ddiss 18
  • Support more ways to load kernel modules early

    Support more ways to load kernel modules early

    This path implements two new ways of loading kernel modules early. Sometimes building monolithic kernels are not really feasible and people use their kernel and kernel modules included int he initrd image. This brings problems like how to supply the desired driver into /lib/modules/*.ko as you would need to have an explicit -file parameter for each module.

    This introduces two new ways to get around this:

    • Through configuration files in /etc/modules-load.d
    • Through modules_load kernel parameter

    These options are popularized through the systemd project and documented here;

    https://www.freedesktop.org/software/systemd/man/kernel-command-line.html#modules_load= https://www.freedesktop.org/software/systemd/man/modules-load.d.html

    I'm also wondering if we'd be interested in supporting a new u-root argument -module which would create a /etc/modules-load.d/default.conf file in the initrd, but this can come later.

    Awaiting reviewer 
    opened by Foxboron 17
  • Added pkg/mei

    Added pkg/mei

    Package mei adds a wrapper to MEI, the Intel ME Interface. See https://www.kernel.org/doc/Documentation/misc-devices/mei/mei.txt . This is a partial implementation that exposes an MEI client and an MKHI client on top of it.

    Signed-off-by: Andrea Barberio [email protected]

    opened by insomniacslk 17
  • No network interface / kernel modules

    No network interface / kernel modules

    I booted up u-root bb build with qemu, but there is no network interface (only unconfigured "lo") and no network drivers.

    Is there some more documentation how to get a working network interface up with dhcp? Maybe additional modules are needed ("/lib/" is empty)?

    opened by pwFoo 16
  • cpio: fix to allow a same file as source for multiple extra files

    cpio: fix to allow a same file as source for multiple extra files

    If a same file is specified as source for multiple extra files, e.g. -files 'README.md:a.txt' -files 'README.md:b.txt', the contents of the second and subsequent files, e.g. b.txt, are empty. This is because ReaderAt is not initialized after the second time if the inode of source is duplicated.

    $ go run . -files 'README.md:a.txt' -files 'README.md:b.txt' cmds/core/{init,elvish}
    $ lsinitramfs -l /tmp/initramfs.linux_amd64.cpio
    -rw-rw-r--   0 root     root        16228 Jan  1  1970 a.txt # file is written successfully.
    -rw-rw-r--   0 root     root            0 Jan  1  1970 b.txt # file is empty.
    
    Awaiting author 
    opened by bobuhiro11 15
  • Switch to upstream elvish

    Switch to upstream elvish

    This change does the following:

    • Move u-root's fork of elvish to exp/felvish
    • Import the new elvish as core/elvish
    • Update vendor directory with new dependencies

    Size difference:

    With go version 1.13:
    16571556 new_elvish.cpio
     4398452 new_elvish.cpio.xz
    15309988 old_elvish.cpio
     4052772 old_elvish.cpio.xz
    
    With go version 1.16:
    13679780 new_elvish.cpio
     3519348 new_elvish.cpio.xz
    11701412 old_elvish.cpio
     3059740 old_elvish.cpio.xz
    

    Signed-off-by: Ryan O'Leary [email protected]

    Awaiting author 
    opened by rjoleary 15
  • refactor boot commands to use pkg/boot and avoid unnecessary file copy

    refactor boot commands to use pkg/boot and avoid unnecessary file copy

    This relates to: https://github.com/u-root/u-root/issues/751 https://github.com/u-root/u-root/issues/1054 https://github.com/u-root/u-root/pull/1283 https://github.com/u-root/u-root/pull/1241

    I'm currently starting from the boot/boot command as it uses less packages so almost everything is in the same file.

    opened by JulienVdG 15
  • libinit: log errors instead of hard aborting module loading

    libinit: log errors instead of hard aborting module loading

    While rewriting stuff in https://github.com/u-root/u-root/pull/2482 I apparently overlooked the fact that we'd abort if any the functions fail. InstallModulesFromDir is always going to return an error unless there is /lib/modules/*.ko which means we won't be looking at the other places.

    A quickfix is to just never return an error on module loading. Another option would be to make the error from InstallModulesFromDir more granular so we can differentiate between "we found no files in this directory" and "we failed to load modules from this directory".

    I'm unsure what people would prefer?

    opened by Foxboron 2
  • localboot -grub -d :mounted:[];no boot configuration found

    localboot -grub -d :mounted:[];no boot configuration found

    Describe the bug When I run Linuxboot on a server that can boot into the operating system normally, I enter localboot -grub -d on the u-root command line but I can't recognize the hard disk in the system, and when I can directly find the grub configuration on another server and boot into the operating system, is there any problem with localboot?

    **u-root command line input /#localboot -grub -d /#mounted: [] /#No boot configuration found

    Additional context I really wanna to know why localboot do this ,can you resolve my doubts?Thanks!

    Bug 
    opened by hanxinwu1 8
  • localboot:No boot configuration found

    localboot:No boot configuration found

    When I try to boot into the operating system with localboot, I write commands "localboot -grub" and output "trying to mount all the available block devices with all the supported file system types" and "No boot configuration found", which is why. My server can boot into the operating system through grub. image

    opened by hanxinwu1 0
  • u-root builds should fail and do not, creating initramfs with missing commands

    u-root builds should fail and do not, creating initramfs with missing commands

    Describe the bug I found that even when cpud had compile errors, the u-root tool would create an initramfs with no error. This must be fixed.

    To Reproduce

    [email protected]:~/go/src/github.com/u-root/u-root$ echo bad >>cmds/core/date/date.go
    [email protected]:~/go/src/github.com/u-root/u-root$ ./u-root
    17:39:21 Disabling CGO for u-root...
    17:39:21 Build environment: GOARCH=amd64 GOOS=linux GOROOT=/usr/lib/go-1.18 GOPATH=/home/rminnich/go CGO_ENABLED=0
    17:39:21 WARNING: You are not using one of the recommended Go versions (have = go1.18.1, recommended = [go1.17]).
    			Some packages may not compile.
    			Go to https://golang.org/doc/install to find out how to install a newer version of Go,
    			or use https://godoc.org/golang.org/dl/go1.17 to install an additional version of Go.
    17:39:21 NOTE: building with the new gobusybox; to get the old behavior check out commit 8b790de
    17:39:21 Skipping package "cmds/core/bind": no buildable Go source files in /home/rminnich/go/src/github.com/u-root/u-root/cmds/core/bind
    17:39:21 Skipping package "cmds/core/installcommand": no buildable Go source files in /home/rminnich/go/src/github.com/u-root/u-root/cmds/core/installcommand
    17:39:21 Skipping package "cmds/core/timeout": no buildable Go source files in /home/rminnich/go/src/github.com/u-root/u-root/cmds/core/timeout
    /home/rminnich/go/src/github.com/u-root/u-root/cmds/core/date/date.go:263:1: expected declaration, found bad
    17:39:30 Successfully built "/tmp/initramfs.linux_amd64.cpio" (size 12553752).
    [email protected]:~/go/src/github.com/u-root/u-root$ ls -l /tmp/initramfs.linux_amd64.cpio
    -rw-r--r-- 1 rminnich rminnich 12553752 Jul 25 17:39 /tmp/initramfs.linux_amd64.cpio
    

    Expected behavior Well, for sure, a failed build should not result in "Successfully built." This has the potential to brick every system using u-root for firmware. I am at a loss to understand how this ever got in.

    Bug 
    opened by rminnich 0
  • random build failures

    random build failures

    Describe the bug

    When building a cpio, I sometimes / randomly (it sometimes works when trying again, with no changes!) get an error, which seems to be a race/concurrency issue somehow.

    To Reproduce Not exactly sure; here's what I run:

    #!/bin/sh
    
    set -e
    
    # with the Ubuntu 1.18, we get hanging prompts / input b0rked, whyever
    export PATH="/home/dama/bin/go1.17.10/bin:$PATH" # note: this is from the official Golang download archive
    
    go run . -o /tmp/u-root-x86.cpio -uroot-source . \
      -files ~/.ssh/cpu_rsa.pub:key.pub \
      -files ~/.ssh/cpu_rsa:key \
      -files ~/Pictures/Wallpapers/landscape_1024.png:wall.png \
      core boot ../cpu/cmds/cpud ./cmds/exp/fbsplash
    

    Note: the cpu repo I'm using is modified to use u-root v1.0.1, whereas current main uses v0.8.0. Otherwise I get an error with version conflicts.

    Expected behavior Here is what a successful build looks like:

    23:48:09 Disabling CGO for u-root...
    23:48:09 Build environment: GOARCH=amd64 GOOS=linux GOROOT=/home/dama/bin/go1.17.10 GOPATH=/home/dama/go CGO_ENABLED=0
    23:48:09 NOTE: building with the new gobusybox; to get the old behavior check out commit 8b790de
    23:48:09 Skipping package "cmds/core/bind": no buildable Go source files in /home/dama/Projects/u-root/cmds/core/bind
    23:48:09 Skipping package "cmds/core/bind": no buildable Go source files in /home/dama/Projects/u-root/cmds/core/bind
    23:48:12 GBB_STRICT is not set.
    23:48:12 [WARNING] github.com/u-root/cpu/cmds/cpud depends on github.com/u-root/u-root @ version v1.0.1
    23:48:12        Using github.com/u-root/u-root @ directory /home/dama/Projects/u-root to build it.
    23:48:20 Successfully built "/tmp/u-root-x86.cpio" (size 14713740).
    

    Additional context

    Here's what an error looks like (always the same with upath):

    23:40:45 Disabling CGO for u-root...
    23:40:45 Build environment: GOARCH=amd64 GOOS=linux GOROOT=/home/dama/bin/go1.17.10 GOPATH=/home/dama/go CGO_ENABLED=0
    23:40:45 NOTE: building with the new gobusybox; to get the old behavior check out commit 8b790de
    23:40:45 Skipping package "cmds/core/bind": no buildable Go source files in /home/dama/Projects/u-root/cmds/core/bind
    23:40:45 Skipping package "cmds/core/bind": no buildable Go source files in /home/dama/Projects/u-root/cmds/core/bind
    23:40:47 GBB_STRICT is not set.
    23:40:47 [WARNING] github.com/u-root/cpu/cmds/cpud depends on github.com/u-root/u-root @ version v1.0.1
    23:40:47        Using github.com/u-root/u-root @ directory /home/dama/Projects/u-root to build it.
    23:40:55 Gobusybox error: go build with modules failed: error building go package in "/tmp/u-root3654909780/builder3928348015/src/bb.u-root.com/bb": # github.com/u-root/u-root/pkg/cpio
    ../../github.com/u-root/u-root/pkg/cpio/fs_unix.go:113:16: undefined: upath.SafeFilepathJoin
    # github.com/u-root/u-root/pkg/tarutil
    ../../github.com/u-root/u-root/pkg/tarutil/tar.go:207:15: undefined: upath.SafeFilepathJoin
    , exit status 2
    23:40:55 Build error: error building: preserving bb generated source directory at /tmp/u-root3654909780/builder3928348015 due to error. To debug build, `cd /tmp/u-root3654909780/builder3928348015/src/bb.u-root.com/bb` and use `go build` to build, or `go mod [why|tidy|graph]` to debug dependencies, or `go list -m all` to list all dependency versions:
    go build with modules failed: error building go package in "/tmp/u-root3654909780/builder3928348015/src/bb.u-root.com/bb": # github.com/u-root/u-root/pkg/cpio
    ../../github.com/u-root/u-root/pkg/cpio/fs_unix.go:113:16: undefined: upath.SafeFilepathJoin
    # github.com/u-root/u-root/pkg/tarutil
    ../../github.com/u-root/u-root/pkg/tarutil/tar.go:207:15: undefined: upath.SafeFilepathJoin
    , exit status 2
    exit status 1
    
    Bug 
    opened by orangecms 0
Releases(v0.9.0)
Owner
Golang systems software
null
Execute a binary from memory, without touching the disk. Linux only.

Memit Execute a binary from memory, without touching the disk. Linux only. Available as both a Go module and a binary. Using the Go module The Command

Liam Galvin 235 Sep 12, 2022
Go-Utils is a library containing a collection of Golang utilities

Go-Utils is a library containing a collection of Golang utilities

Skillz 0 Jun 2, 2022
Automatically set GOMAXPROCS to match Linux container CPU quota.

automaxprocs Automatically set GOMAXPROCS to match Linux container CPU quota. Installation go get -u go.uber.org/automaxprocs Quick Start import _ "go

Uber Go 2.2k Sep 25, 2022
Like tools/cmd/stringer with bitmask features

Bitmasker Bitmasker is a tool used to automate the creation of helper methods when dealing with bitmask-type constant flags. Given the name of an unsi

Go Curses 0 Nov 25, 2021
Elf binary infector written in Golang

Elf binary infector written in Golang. It can be used for infecting executables of type ET_DYN and ET_EXEC with a payload of your creation. Utilizing the classic elf text segment padding algorithm by Silvio Cesar, your payload (parasite) will run before native functionality of the binary effectively backooring the binary.

null 150 Jul 27, 2022
Julia Set Generator Written In Golang

Julia Set Generator Written In Golang This is a simple (naive) Julia Set generator written in Golang. The project utilizes concurrent workers to speed

null 1 Nov 5, 2021
dqlx is a fully featured DGraph Schema and Query Builder for Go.

dqlx is a fully featured DGraph Schema and Query Builder for Go. It aims to simplify the interaction with the awesome Dgraph database allowing you to fluently compose any queries and mutations of any complexity. It also comes with a rich Schema builder to easily develop and maintain your Dgraph schema.

Fabrizio 51 Sep 6, 2022
Fully featured, spec-compliant HTML5 server-sent events library

go-sse Lightweight, fully spec-compliant HTML5 server-sent events library. Table of contents go-sse Table of contents Installation and usage Implement

Teodor Maxim 159 Aug 16, 2022
get windows system call number dynamically, it doesn't need the system call table.

GetSyscallID get windows system call number dynamically, it doesn't need the system call table. Try download go get github.com/akkuman/getsyscallid/cm

null 7 Jun 1, 2022
A utility library to do files/io/bytes processing/parsing in file-system or network.

goreader A utility library to do files/io/bytes processing/parsing in file-system or network. These features are really common to be implemented for a

VOrishirne 4 Nov 1, 2021
Flock is a project which provides a Go solution for system level file locks for all platforms Golang supports.

Flock is a project which provides a Go solution for system level file locks for all platforms Golang supports.

Ken Sipe 0 Feb 8, 2022
Cogger is a standalone binary and a golang library that reads an internally tiled geotiff

Cogger is a standalone binary and a golang library that reads an internally tiled geotiff (optionally with overviews and masks) and rewrites it

Airbus DS GEO S.A. 74 Sep 23, 2022
This library provides an ASTERIX Frame(binary data) decoding/parsing(json,xml) capabilities for Go.

GoAsterix This library provides an ASTERIX Frame(binary data) decoding/parsing(json,xml) capabilities for Go. ASTERIX ASTERIX (All Purpose Structured

MMK 3 Jun 1, 2022
A set of instrumentation features for collecting relevant tracing data as well as secure an application

Go Agent goagent provides a set of instrumentation features for collecting relevant tracing data as well as secure an application by blocking requests

null 0 Dec 21, 2021
redis-util business-friendly encapsulation of redis operations, such as the common cache set get operation

redis-util 方便业务使用的redis操作封装,比如常见的缓存set get操作, 一行代码搞定,不像开源库需要写好多行 使用方法

connor 1 Oct 22, 2021
Simple utility to get/set the PWM duty cycle and to measure the RPM for a fan connected to the 4-pin header on the CM4IO.

cm4iofan Simple utility to get/set the PWM duty cycle and to measure the RPM for a fan connected to the 4-pin header on the CM4IO. Requirements Enable

Thomas Maier 5 Mar 31, 2022
This Go package allows you to set handler functions that run when named events occur

This Go package allows you to set handler functions that run when named events occur

James 1 Feb 10, 2022
Golang 1.18+ Generics implementation of Set methods

Golang Generics: Set A golang 1.18+ implementation of Set using Go generics Installation $ go get -u github.com/chrispappas/golang-generics-set Quick

Chris Pappas 13 Aug 19, 2022
safe and easy casting from one type to another in Go

cast Easy and safe casting from one type to another in Go Don’t Panic! ... Cast What is Cast? Cast is a library to convert between different go types

Steve Francia 2.5k Sep 25, 2022