Skip to content

Commit

Permalink
Merge pull request mobile-nixos#210 from samueldr-wip/fix/204-fallout
Browse files Browse the repository at this point in the history
Fix fallout from mobile-nixos#204
  • Loading branch information
samueldr committed Sep 30, 2020
2 parents afdc907 + b4ff3a5 commit ffdba8f
Show file tree
Hide file tree
Showing 17 changed files with 182 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ local.nix

# Misc
*.swp
devices/*/kernel/config.*.old
63 changes: 62 additions & 1 deletion bin/kernel-normalize-config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,68 @@
# - Changing configuration options
# - Changing the kernel version

require "shellwords"
ROOT = File.join(__dir__, "..")
exec(File.join(ROOT, "bin", "menuconfig"), "--only-save", *ARGV)

def usage()
puts "Usage: #{$PROGRAM_NAME} <device_name>"
end

# Poor approximation to arguments parsing.
params, other_args = ARGV.partition { |s| s.match(/^--/) }

if other_args.empty?
$stderr.puts "Device name required."
usage
exit 1
end

DEVICE = other_args.shift

FILE =
# Is the device a path?
if DEVICE.match(%r{/})
Dir.glob(File.join(DEVICE, "kernel", "config.*")).sort.first
else
Dir.glob(File.join(Dir.pwd, "devices", DEVICE, "kernel", "config.*")).sort.first
end

unless params.empty?
$stderr.puts "Unknown parameters #{params.join(", ")}."
usage
exit 1
end

unless other_args.empty?
$stderr.puts "Unexpected arguments #{other_args.join(", ")}."
usage
exit 1
end

unless FILE
$stderr.puts "Could not find kernel configuration file for #{DEVICE}."
usage
exit 1
end

arg =
# Is the device a path?
if DEVICE.match(%r{/})
["--arg", "device", DEVICE]
else
["--argstr", "device", DEVICE]
end

Dir.chdir(ROOT) do
result = `#{[
"nix-build",
"--no-out-link",
*arg,
"-A", "config.mobile.boot.stage-1.kernel.package.normalizedConfig"
].shelljoin}`.strip

# We "cat" into the file to ensure we don't copy the store path access rights.
File.write(FILE, File.read(result))
end

# vim: ft=ruby
3 changes: 3 additions & 0 deletions bin/menuconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Dir.chdir(ROOT) do
else
system(tool, FILE)
end

# Force normalize at the end. Otherwise recent kernels (5.8+) will have the wrong compiler data.
exec(File.join(ROOT, "bin", "kernel-normalize-config"), *ARGV)
end

# vim: ft=ruby
17 changes: 15 additions & 2 deletions devices/asus-dumo/kernel/config.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.8.0 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 9.3.0"
CONFIG_CC_VERSION_TEXT="aarch64-unknown-linux-gnu-gcc (GCC) 9.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=90300
CONFIG_LD_VERSION=231010000
Expand Down Expand Up @@ -267,7 +267,6 @@ CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=4
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_ARCH_PROC_KCORE_TEXT=y
CONFIG_BROKEN_GAS_INST=y

#
# Platform selection
Expand Down Expand Up @@ -410,6 +409,7 @@ CONFIG_KUSER_HELPERS=y
#
CONFIG_ARM64_HW_AFDBM=y
CONFIG_ARM64_PAN=y
CONFIG_ARM64_LSE_ATOMICS=y
CONFIG_ARM64_USE_LSE_ATOMICS=y
CONFIG_ARM64_VHE=y
# end of ARMv8.1 architectural features
Expand All @@ -426,6 +426,9 @@ CONFIG_ARM64_CNP=y
#
# ARMv8.3 architectural features
#
CONFIG_CC_HAS_BRANCH_PROT_PAC_RET=y
CONFIG_CC_HAS_SIGN_RETURN_ADDRESS=y
CONFIG_AS_HAS_PAC=y
# end of ARMv8.3 architectural features

#
Expand All @@ -438,6 +441,7 @@ CONFIG_ARM64_AMU_EXTN=y
# ARMv8.5 architectural features
#
CONFIG_ARM64_BTI=y
CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI=y
CONFIG_ARM64_E0PD=y
CONFIG_ARCH_RANDOM=y
# end of ARMv8.5 architectural features
Expand All @@ -447,6 +451,7 @@ CONFIG_ARM64_MODULE_PLTS=y
# CONFIG_ARM64_PSEUDO_NMI is not set
CONFIG_RELOCATABLE=y
# CONFIG_RANDOMIZE_BASE is not set
CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y
# end of Kernel Features

#
Expand Down Expand Up @@ -683,6 +688,10 @@ CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
# end of GCOV-based kernel profiling

CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_GCC_PLUGINS=y
# CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set
# CONFIG_GCC_PLUGIN_LATENT_ENTROPY is not set
# CONFIG_GCC_PLUGIN_RANDSTRUCT is not set
# end of General architecture-dependent options

CONFIG_RT_MUTEXES=y
Expand Down Expand Up @@ -5392,6 +5401,10 @@ CONFIG_LSM="yama,loadpin,safesetid,integrity"
# Memory initialization
#
CONFIG_INIT_STACK_NONE=y
# CONFIG_GCC_PLUGIN_STRUCTLEAK_USER is not set
# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF is not set
# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL is not set
# CONFIG_GCC_PLUGIN_STACKLEAK is not set
# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set
# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set
# end of Memory initialization
Expand Down
6 changes: 3 additions & 3 deletions devices/asus-flo/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

isModular = false;

}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: {
installTargets = [ "zinstall" ];
postPatch = postPatch + ''
postPatch = ''
cp -v "${./compiler-gcc6.h}" "./include/linux/compiler-gcc6.h"
'';
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "zinstall" ];
postInstall = postInstall + ''
mkdir -p "$out/boot"
Expand Down
11 changes: 6 additions & 5 deletions devices/asus-x018d/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ in

isModular = false;

}).overrideAttrs({ postInstall ? "", postPatch ? "", nativeBuildInputs ? [], ... }: {
nativeBuildInputs = nativeBuildInputs ++ [
postPatch = ''
patchShebangs tools
'';

nativeBuildInputs = [
python2
];
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];
postPatch = postPatch + ''
patchShebangs tools
'';

postInstall = postInstall + ''
cp -v "$buildRoot/arch/arm64/boot/Image.gz-dtb" "$out/"
Expand Down
6 changes: 3 additions & 3 deletions devices/asus-z00t/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@

isModular = false;

}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: {
installTargets = [ "zinstall" ];
postPatch = postPatch + ''
postPatch = ''
cp -v "${./compiler-gcc6.h}" "./include/linux/compiler-gcc6.h"
'';
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "zinstall" ];
postInstall = postInstall + ''
${dtbTool}/bin/dtbTool -s 2048 -p "scripts/dtc/" -o "arch/arm64/boot/asus-z00t.img" "arch/arm/boot/"
cp "arch/arm64/boot/asus-z00t.img" "$out/dtbs/asus-z00t.img"
Expand Down
8 changes: 5 additions & 3 deletions devices/google-marlin/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ in
];

isModular = false;
}).overrideAttrs({ postInstall ? "", postPatch ? "", nativeBuildInputs, ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];
postPatch = postPatch + ''

postPatch = ''
# FIXME : factor out
(
# Remove -Werror from all makefiles
Expand All @@ -49,6 +48,9 @@ in
# Remove google's default dm-verity certs
rm -f *.x509
'';
}).overrideAttrs({ postInstall ? "", nativeBuildInputs, ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];

nativeBuildInputs = nativeBuildInputs ++ [ dtc ];

postInstall = postInstall + ''
Expand Down
8 changes: 5 additions & 3 deletions devices/google-walleye/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ in
];

isModular = false;
}).overrideAttrs({ postInstall ? "", postPatch ? "", nativeBuildInputs, ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];
postPatch = postPatch + ''

postPatch = ''
# FIXME : factor out
(
# Remove -Werror from all makefiles
Expand All @@ -47,6 +46,9 @@ in
done
)
'';
}).overrideAttrs({ postInstall ? "", nativeBuildInputs, ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];

nativeBuildInputs = nativeBuildInputs ++ [ dtc ];

postInstall = postInstall + ''
Expand Down
6 changes: 3 additions & 3 deletions devices/motorola-addison/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ in

isModular = false;

}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: {
installTargets = [ "zinstall" "dtbs" ];
postPatch = postPatch + ''
postPatch = ''
cp -v "${./compiler-gcc6.h}" "./include/linux/compiler-gcc6.h"
# FIXME : factor out
Expand All @@ -63,6 +61,8 @@ in
done
)
'';
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "zinstall" "dtbs" ];
postInstall = postInstall + ''
mkdir -p "$out/dtbs/"
''
Expand Down
6 changes: 3 additions & 3 deletions devices/oneplus-oneplus3/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@

isModular = false;

}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];
postPatch = postPatch + ''
postPatch = ''
cp -v "${./compiler-gcc6.h}" "./include/linux/compiler-gcc6.h"
# FIXME : factor out
Expand All @@ -47,6 +45,8 @@
done
)
'';
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];
postInstall = postInstall + ''
mkdir -p "$out/dtbs/"
cp -v "$buildRoot/arch/arm64/boot/Image.gz-dtb" "$out/"
Expand Down
18 changes: 15 additions & 3 deletions devices/pine64-pinephone-braveheart/kernel/config.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.8.0 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 9.3.0"
CONFIG_CC_VERSION_TEXT="aarch64-unknown-linux-gnu-gcc (GCC) 9.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=90300
CONFIG_LD_VERSION=231010000
Expand Down Expand Up @@ -259,7 +259,6 @@ CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=4
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_ARCH_PROC_KCORE_TEXT=y
CONFIG_BROKEN_GAS_INST=y

#
# Platform selection
Expand Down Expand Up @@ -403,6 +402,7 @@ CONFIG_KUSER_HELPERS=y
#
CONFIG_ARM64_HW_AFDBM=y
CONFIG_ARM64_PAN=y
CONFIG_ARM64_LSE_ATOMICS=y
CONFIG_ARM64_USE_LSE_ATOMICS=y
CONFIG_ARM64_VHE=y
# end of ARMv8.1 architectural features
Expand All @@ -419,6 +419,9 @@ CONFIG_ARM64_CNP=y
#
# ARMv8.3 architectural features
#
CONFIG_CC_HAS_BRANCH_PROT_PAC_RET=y
CONFIG_CC_HAS_SIGN_RETURN_ADDRESS=y
CONFIG_AS_HAS_PAC=y
# end of ARMv8.3 architectural features

#
Expand All @@ -431,6 +434,7 @@ CONFIG_ARM64_AMU_EXTN=y
# ARMv8.5 architectural features
#
CONFIG_ARM64_BTI=y
CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI=y
CONFIG_ARM64_E0PD=y
CONFIG_ARCH_RANDOM=y
# end of ARMv8.5 architectural features
Expand All @@ -440,6 +444,8 @@ CONFIG_ARM64_MODULE_PLTS=y
# CONFIG_ARM64_PSEUDO_NMI is not set
CONFIG_RELOCATABLE=y
# CONFIG_RANDOMIZE_BASE is not set
CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y
CONFIG_STACKPROTECTOR_PER_TASK=y
# end of Kernel Features

#
Expand Down Expand Up @@ -744,6 +750,9 @@ CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
# end of GCOV-based kernel profiling

CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_GCC_PLUGINS=y
# CONFIG_GCC_PLUGIN_LATENT_ENTROPY is not set
# CONFIG_GCC_PLUGIN_RANDSTRUCT is not set
# end of General architecture-dependent options

CONFIG_RT_MUTEXES=y
Expand Down Expand Up @@ -6524,6 +6533,10 @@ CONFIG_LSM="yama,loadpin,integrity,selinux,smack,tomoyo,apparmor"
# Memory initialization
#
CONFIG_INIT_STACK_NONE=y
# CONFIG_GCC_PLUGIN_STRUCTLEAK_USER is not set
# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF is not set
# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL is not set
# CONFIG_GCC_PLUGIN_STACKLEAK is not set
# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set
# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set
# end of Memory initialization
Expand Down Expand Up @@ -6883,7 +6896,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_DEBUG_INFO=y
# CONFIG_DEBUG_INFO_REDUCED is not set
# CONFIG_DEBUG_INFO_COMPRESSED is not set
# CONFIG_DEBUG_INFO_SPLIT is not set
# CONFIG_DEBUG_INFO_DWARF4 is not set
# CONFIG_DEBUG_INFO_BTF is not set
# CONFIG_GDB_SCRIPTS is not set
Expand Down
2 changes: 1 addition & 1 deletion devices/sony-pioneer/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ in

isModular = false;

}).overrideAttrs({ postInstall ? "", postPatch ? "", ... }: {
}).overrideAttrs({ postInstall ? "", ... }: {
installTargets = [ "zinstall" "Image.gz-dtb" "install" ];
postInstall = postInstall + ''
cp -v "$buildRoot/arch/arm64/boot/Image.gz-dtb" "$out/"
Expand Down
Loading

0 comments on commit ffdba8f

Please sign in to comment.