SOP of modifying ONIE source code

I would modify grep source code as example.

Step

  1. Build first
  2. Modify file in build/<machine>
  3. make again, and verify
  4. stg export -d <dir> back to patch
  5. prepare patches and build again
  6. update ONIE

1) Build first

bmc@bmc-R2-1208R-EV:~/workspace/onie-local/build-config$ make MACHINEROOT=../machine/fxn MACHINE=katana all
=== Finished making onie-x86_64-katana-r0 fxn/master-02241005-dirty ===

2) Modify code in build/<machine>

In my example, machine is katana; therefore, codes are in build/katana-r0/.
And I modify grep in busybox:

bmc@bmc-R2-1208R-EV:~/workspace/onie-local/build/katana-r0/busybox/busybox-1.25.1$ git diff
diff --git a/findutils/grep.c b/findutils/grep.c
index aeb7977..0602d30 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -680,6 +680,7 @@ static int grep_dir(const char *dir)
 int grep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int grep_main(int argc UNUSED_PARAM, char **argv)
 {
+       puts("TEST TEST ABC\n");
        FILE *file;
        int matched;
        llist_t *fopt = NULL;

3) Build and verify

make MACHINEROOT=../machine/fxn MACHINE=katana all
====  Building busybox-1.25.1 ====
make[1]: Entering directory '/home/bmc/workspace/onie-local/build/katana-r0/busybox/busybox-1.25.1'
scripts/kconfig/conf -s Config.in
...
xorriso : UPDATE : 279 files added in 1 seconds
Added to ISO image: directory '/'='/home/bmc/workspace/onie-local/build/katana-r0/recovery/iso-sysroot'
Created: /home/bmc/workspace/onie-local/build/images/onie-updater-x86_64-katana-r0
=== Finished making onie-x86_64-katana-r0 fxn/master-02241028 ===
NIE:/ # scp bmc@172.16.128.62:/home/bmc/workspace/onie-local/build/katana-r0/busybox/busybox-1.25.1/busybox /tmp

Host '172.16.128.62' is not in the trusted hosts file.
(ecdsa-sha2-nistp256 fingerprint md5 42:fe:02:bb:42:c6:8c:d0:f4:6f:cd:fc:38:7a:d7:1e)
Do you want to continue connecting? (y/n) y
bmc@172.16.128.62's password:
busybox                                       100%  652KB 652.2KB/s   00:00
ONIE:/ # /tmp/busybox grep
TEST TEST ABC

BusyBox v1.25.1 (2020-02-24 10:23:28 CST) multi-call binary.
...

4) export patches

stg new -m 'add message to grep'
stg refresh && stg show
stg series # check new layer is created
stg export -d /tmp/patch --patch -- add-message-to-grep
ls /tmp/patch/ # check

# remove original patch
rm ~/workspace/onie-local/machine/fxn/katana/busybox/patches/*

# copy back to source code
cp /tmp/patch/* ~/workspace/onie-local/machine/fxn/katana/busybox/patches/

# commit if you want

5) prepare patch and build again

make MACHINEROOT=../machine/fxn MACHINE=katana busybox-clean
make MACHINEROOT=../machine/fxn MACHINE=katana busybox-patch
make MACHINEROOT=../machine/fxn MACHINE=katana busybox-build

# make all
make MACHINEROOT=../machine/fxn MACHINE=katana all

6) self update ONIE

onie-self-update -ve http://172.16.128.62/Irene/onie/build/images/onie-updater-x86_64-katana-r0

grep 2>/dev/null | head
# TEST TEST ABC

Reference:

  1. Contributing to ONIE

Leave a comment

Design a site like this with WordPress.com
Get started