Simple script and config (type-safe) for building custom Linux kernels for Firecracker MicroVMs

refactor: streamline git fetch and reset logic in build process

+9 -22
+9 -22
build.ts
··· 131 131 "linux-stable", 132 132 ]); 133 133 } else { 134 - // Update existing checkout to the desired ref 135 - await run([ 136 - "git", 137 - "-C", 138 - "linux-stable", 139 - "fetch", 140 - "--tags", 141 - "--force", 142 - "origin", 143 - ]); 144 - 145 134 // Shallow-fetch the specific ref (works for both branches and tags) 146 135 try { 147 136 await run([ ··· 151 140 "fetch", 152 141 "--depth=1", 153 142 "origin", 154 - `${REF}:${REF}`, 143 + REF, 155 144 ]); 156 145 } catch { 157 - await run([ 158 - "git", 159 - "-C", 160 - "linux-stable", 161 - "fetch", 162 - "origin", 163 - `${REF}:${REF}`, 164 - ]); 146 + await run(["git", "-C", "linux-stable", "fetch", "origin", REF]); 165 147 } 148 + 149 + await run(["git", "-C", "linux-stable", "reset", "--hard", REF]); 166 150 167 151 await run(["git", "-C", "linux-stable", "checkout", "-f", REF]); 168 152 } ··· 176 160 await Deno.writeTextFile(".config", cfg); 177 161 } 178 162 179 - await Deno.copyFile(".config", "linux-stable/.config"); 163 + Deno.chdir("linux-stable"); 164 + 165 + await run(["rm", "-rf", "Documentation/Kbuild"]); 166 + await run(["make", "mrproper"]); 180 167 181 - Deno.chdir("linux-stable"); 168 + await Deno.copyFile("../.config", ".config"); 182 169 183 170 const nproc = await getNproc(); 184 171 const makeProcess = new Deno.Command("make", {