Skip to content

Commit 94f453e

Browse files
committed
modules/release: refactor otaDir to add LineageOS support
writeOtaMetadata is moved up, because it's used by releaseScript and otaDir This isn't a no-op for the other flavors, because it changes otaDir into a runCommand and copies (or rather "cat"s) the metadata, whereas it was a symlink until now
1 parent 4b62ab3 commit 94f453e

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

modules/release.nix

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,24 @@ in
156156
);
157157
}).${config.apps.updater.flavor};
158158

159+
writeOtaMetadata = path: {
160+
grapheneos = ''
161+
cat ${otaMetadata} > ${path}/${config.device}-${config.channel}
162+
'';
163+
lineageos = ''
164+
sed -e "s:\"ROM_SIZE\":$(du -b ${ota} | cut -f1):" ${otaMetadata} > ${path}/${config.device}.json
165+
'';
166+
}.${config.apps.updater.flavor};
167+
159168
# TODO: target-files aren't necessary to publish--but are useful to include if prevBuildDir is set to otaDir output
160-
otaDir = pkgs.linkFarm "${config.device}-otaDir" (
161-
(map (p: {name=p.name; path=p;}) ([ ota otaMetadata ] ++ (lib.optional config.incremental incrementalOta)))
162-
++ [{ name="${config.device}-target_files-${config.buildNumber}.zip"; path=targetFiles; }]
163-
);
169+
otaDir = pkgs.runCommand "${config.device}-otaDir" {} ''
170+
mkdir -p $out
171+
ln -s "${ota}" "$out/${ota.name}"
172+
ln -s "${targetFiles}" "$out/${config.device}-target_files-${config.buildNumber}.zip"
173+
${lib.optionalString config.incremental ''ln -s ${incrementalOta} "$out/${incrementalOta.name}"''}
174+
175+
${writeOtaMetadata (placeholder "out")}
176+
'';
164177

165178
# TODO: Do this in a temporary directory. It's ugly to make build dir and ./tmp/* dir gets cleared in these scripts too.
166179
releaseScript =
@@ -191,12 +204,7 @@ in
191204
echo Building factory image
192205
${factoryImgScript { targetFiles=signedTargetFiles.name; img=img.name; out=factoryImg.name; }}
193206
echo Writing updater metadata
194-
${optionalString (config.apps.updater.flavor != "lineageos") ''
195-
cat ${otaMetadata} > ${config.device}-${config.channel}
196-
''}
197-
${optionalString (config.apps.updater.flavor == "lineageos") ''
198-
sed -e "s:ROM_SIZE:$(du -b ${ota.name}):" ${otaMetadata} > ${config.device}.json
199-
''}
207+
${writeOtaMetadata "."}
200208
''; }));
201209
};
202210
}

0 commit comments

Comments
 (0)