Skip to content

Commit

Permalink
Rename "vendor" module to "apv"
Browse files Browse the repository at this point in the history
"vendor" is too generic for what this module does. Just call it after
the main tool used: android-prepare-vendor (apv)
  • Loading branch information
danielfullmer committed Jul 12, 2020
1 parent 708ceff commit f7f588d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let
./modules/apps/prebuilt.nix
./modules/apps/seedvault.nix
./modules/apps/updater.nix
./modules/apv.nix
./modules/assertions.nix
./modules/base.nix
./modules/emulator.nix
Expand All @@ -51,7 +52,6 @@ let
./modules/release.nix
./modules/resources.nix
./modules/source.nix
./modules/vendor.nix
./modules/webview.nix
];
});
Expand Down
4 changes: 2 additions & 2 deletions flavors/grapheneos/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }:
with lib;
let
grapheneOSRelease = "${config.vendor.buildID}.2020.07.06.20";
grapheneOSRelease = "${config.apv.buildID}.2020.07.06.20";

supportedDeviceFamilies = [ "taimen" "muskie" "crosshatch" "bonito" "generic"];

Expand All @@ -15,7 +15,7 @@ in mkIf (config.flavor == "grapheneos") (mkMerge [

source.dirs = lib.importJSON (./. + "/repo-${grapheneOSRelease}.json");

vendor.buildID = mkDefault "QQ3A.200705.002";
apv.buildID = mkDefault "QQ3A.200705.002";

# Not strictly necessary for me to set these, since I override the jsonFile
source.manifest.url = mkDefault "https://github.com/GrapheneOS/platform_manifest.git";
Expand Down
10 changes: 5 additions & 5 deletions flavors/vanilla/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ in mkIf (config.flavor == "vanilla") (mkMerge [
(mkIf (elem config.deviceFamily supportedDeviceFamilies) {
buildNumber = mkDefault "2020.07.07.09";
buildDateTime = mkDefault 1594138015;
vendor.buildID = mkDefault "QQ3A.200705.002";
apv.buildID = mkDefault "QQ3A.200705.002";
source.manifest.rev = mkDefault "android-10.0.0_r40";
})
{
Expand Down Expand Up @@ -98,7 +98,7 @@ in mkIf (config.flavor == "vanilla") (mkMerge [
(mkIf (config.deviceFamily == "marlin") {
warnings = [ "marlin and sailfish are no longer receiving monthly security updates from Google. Support is left just for testing" ];

vendor.buildID = "QP1A.191005.007.A3";
apv.buildID = "QP1A.191005.007.A3";
source.manifest.rev = "android-10.0.0_r40";

# HACK to use recent android source, but with old vendor files...
Expand Down Expand Up @@ -137,14 +137,14 @@ in mkIf (config.flavor == "vanilla") (mkMerge [
source.manifest.rev = "android-r-beta-2";
}
(mkIf (config.device == "crosshatch") {
vendor.buildID = mkIf (config.device == "crosshatch") "RPB2.200611.009";
vendor.img = mkIf (config.device == "crosshatch") (pkgs.fetchurl {
apv.buildID = mkIf (config.device == "crosshatch") "RPB2.200611.009";
apv.img = mkIf (config.device == "crosshatch") (pkgs.fetchurl {
url = "https://dl.google.com/developers/android/rvc/images/factory/crosshatch-rpb2.200611.009-factory-a34559bf.zip";
sha256 = "a34559bfb4ff4bd948e87d576964c8da3f1429d56ca3512c6426d6ecda8917c2";
});

# Use older OTA image
vendor.ota = mkIf (config.device == "crosshatch") (pkgs.fetchurl {
apv.ota = mkIf (config.device == "crosshatch") (pkgs.fetchurl {
url = "https://dl.google.com/dl/android/aosp/crosshatch-ota-qq3a.200605.001-68685f95.zip";
sha256 = "68685f957d8af0a925a26f1c0c11b9a7629df6e08dad70038c87c923a805d4aa";
});
Expand Down
30 changes: 16 additions & 14 deletions modules/vendor.nix → modules/apv.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{ config, pkgs, lib, ... }:

# Robotnix module for android-prepare-vendor (apv)

with lib;
let
cfg = config.vendor;
cfg = config.apv;

apiStr = builtins.toString config.apiLevel;
android-prepare-vendor = pkgs.android-prepare-vendor.override { api = config.apiLevel; };
Expand Down Expand Up @@ -59,38 +61,38 @@ let
'';
in
{
options = {
vendor.img = mkOption {
options.apv = {
img = mkOption {
default = null;
type = types.nullOr types.path;
description = "A factory image .zip from upstream whose vendor contents should be extracted and included in the build";
};

vendor.ota = mkOption {
ota = mkOption {
default = null;
type = types.nullOr types.path;
description = "An ota from upstream whose vendor contents should be extracted and included in the build (Android 10 builds need an OTA as well)";
};

vendor.systemBytecode = mkOption {
systemBytecode = mkOption {
type = types.listOf types.str;
default = [];
};

vendor.systemOther = mkOption {
systemOther = mkOption {
type = types.listOf types.str;
default = [];
};

vendor.buildID = mkOption {
buildID = mkOption {
type = types.str;
description = "Build ID associated with the upstream img/ota (used to select images)";
internal = true;
};
};

config = mkIf (cfg.img != null) {
build.vendor = {
build.apv = {
origfiles =
buildVendorFiles {
inherit (config) device;
Expand All @@ -108,15 +110,15 @@ in
pkgs.runCommand "repaired-system-${config.device}-${cfg.buildID}" {} ''
mkdir -p $out
${android-prepare-vendor}/scripts/system-img-repair.sh \
--input ${config.build.vendor.unpackedImg}/system/system \
--input ${config.build.apv.unpackedImg}/system/system \
--output $out \
--method OATDUMP \
--oatdump ${android-prepare-vendor}/hostTools/Linux/api-${apiStr}/bin/oatdump \
--bytecode-list ${bytecodeList} \
--timestamp 1
'';

files = pkgs.runCommand "vendor-files-${config.device}-${cfg.buildID}" {} (with config.build.vendor; ''
files = pkgs.runCommand "vendor-files-${config.device}-${cfg.buildID}" {} (with config.build.apv; ''
mkdir -p tmp
ln -s ${repairedSystem}/system tmp/system
Expand Down Expand Up @@ -158,18 +160,18 @@ in
builtVendor = unpackImg config.factoryImg;
in pkgs.runCommand "vendor-diff" {} ''
mkdir -p $out
ln -s ${config.build.vendor.unpackedImg} $out/upstream
ln -s ${config.build.apv.unpackedImg} $out/upstream
ln -s ${builtVendor} $out/built
find ${config.build.vendor.unpackedImg}/vendor -printf "%P\n" | sort > $out/upstream-vendor
find ${config.build.apv.unpackedImg}/vendor -printf "%P\n" | sort > $out/upstream-vendor
find ${builtVendor}/vendor -printf "%P\n" | sort > $out/built-vendor
diff -u $out/upstream-vendor $out/built-vendor > $out/diff-vendor || true
find ${config.build.vendor.unpackedImg}/system -printf "%P\n" | sort > $out/upstream-system
find ${config.build.apv.unpackedImg}/system -printf "%P\n" | sort > $out/upstream-system
find ${builtVendor}/system -printf "%P\n" | sort > $out/built-system
diff -u $out/upstream-system $out/built-system > $out/diff-system || true
'';
};

# TODO: Re-add support for vendor_overlay if it is ever used again
source.dirs."vendor/google_devices".src = "${config.build.vendor.files}/vendor/google_devices";
source.dirs."vendor/google_devices".src = "${config.build.apv.files}/vendor/google_devices";
};
}
8 changes: 4 additions & 4 deletions modules/google.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ let
then "${unpackedImg}/${optionalString (config.deviceFamily == "marlin") "system/system/"}product"
else systemPath;

unpackedImg = if (config.vendor.img != null)
then config.build.vendor.unpackedImg
else (import ../default.nix { # If vendor is not set--say for generic/emulator targets, use the vendor files from crosshatch
unpackedImg = if (config.apv.img != null)
then config.build.apv.unpackedImg
else (import ../default.nix { # If apv is not enabled--say for generic/emulator targets, use the vendor files from crosshatch
configuration = {
device = "crosshatch";
flavor = "vanilla";
inherit (config) androidVersion;
};
}).build.vendor.unpackedImg;
}).build.apv.unpackedImg;
in
{
# TODO: Add other google stuff. Ensure that either google play services or microg is enabled if these are.
Expand Down
6 changes: 3 additions & 3 deletions modules/pixel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let
otaList = lib.importJSON ./pixel-otas.json;
fetchItem = json: let
matchingItem = lib.findSingle
(v: (v.device == config.device) && (hasInfix "(${config.vendor.buildID}," v.version)) # Look for left paren + upstream buildNumber + ","
(v: (v.device == config.device) && (hasInfix "(${config.apv.buildID}," v.version)) # Look for left paren + upstream buildNumber + ","
(throw "no items found for vendor img/ota")
(throw "multiple items found for vendor img/ota")
json;
Expand Down Expand Up @@ -44,8 +44,8 @@ mkMerge [

kernel.name = mkIf (config.deviceFamily == "taimen" || config.deviceFamily == "muskie") (mkDefault "wahoo");
kernel.configName = mkDefault config.deviceFamily;
vendor.img = mkDefault (fetchItem imgList);
vendor.ota = mkDefault (fetchItem otaList);
apv.img = mkDefault (fetchItem imgList);
apv.ota = mkDefault (fetchItem otaList);

source.excludeGroups = mkDefault [
# Exclude all devices by default
Expand Down

0 comments on commit f7f588d

Please sign in to comment.