Commit Graph

55 Commits

Author SHA1 Message Date
Oliver Smith 67fe5a62fd
treewide: fix typos found with codespell
Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230706211537.10438-2-ollieparanoid@postmarketos.org%3E
2023-07-13 10:07:53 +02:00
eval Nya 620f3af691
envkernel.sh: use realpath to deal with symlink
Suggest to change suffix to bash:
POSIX does not provide a way to detect sourced script path, and
the working method in this script is bash-specific. (The sh-method
would not working in some cases like shell in shell)

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230618045230.28622-1-11857526-nexplorer-3e@users.noreply.gitlab.com%3E
2023-07-05 10:02:18 +02:00
Julian Winkler ad7ec1635a
envkernel.sh: building x86 on x86_64 does not require a cross compiler
Add an exception for this case to use host compiler

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230416100903.53248-1-julian.winkler1@web.de%3E
2023-04-18 09:30:18 +02:00
Newbyte 397225667f
helpers/envkernel.sh: rename yaml-lint to yamllint
There's no package called yaml-lint in Alpine. Presumably, the intent
was to install yamllint here.

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20221105132937.34008-1-newbie13xd@gmail.com%3E
2022-11-05 17:55:21 +00:00
Dzmitry Sankouski 6a21898ce4
envkernel: add dependencies for running 'make dtbs_check'
Mainline device-tree patches development require linting.
Install needed packages to be able to perform dtbs_check task.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20221102160913.1896756-1-dsankouski@gmail.com%3E
2022-11-02 21:09:27 +01:00
Newbyte 8770aba287
helpers/envkernel.sh: return 0 from fish_compat if --fish is not present (MR 2221)
Right now this returns 1 when envkernel.sh is sourced for some reason. I
don't understand why exactly, but this seems like a sensible solution to
me.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2133
2022-10-25 08:50:06 +02:00
alikates c36e4a43ac
Revert "helpers/envkernel.sh: add gawk when initialising chroot (MR 2186)" (MR 2188)
This reverts commit 22117de4bd.

Closes: #2145

As of linux 5.19-rc2 and linux-next-20220614 this is not needed because
the script was fixed with [1].

[1]: https://lore.kernel.org/all/20220609204220.12112-1-atafalla@dnyon.com/
2022-07-16 11:53:29 +02:00
Newbyte fe28a39f79
helpers/envkernel.sh: disable ccache (MR 2189)
Not extensively tested, but this shouldn't be necessary given that
you get incremental builds with envkernel and may reduce build
times.
2022-07-16 11:37:46 +02:00
Newbyte 22117de4bd
helpers/envkernel.sh: add gawk when initialising chroot (MR 2186)
The Awk implementation from BusyBox cannot run the
arch/arm64/tools/gen-sysreg.awk script, and results in the
following error:

  GEN     arch/arm64/include/generated/asm/sysreg-defs.h
Error at 51: unhandled statement
make[2]: *** [../arch/arm64/tools/Makefile:24: arch/arm64/include/generated/asm/sysreg-defs.h] Error 1
make[2]: *** Deleting file 'arch/arm64/include/generated/asm/sysreg-defs.h'
make[1]: *** [../arch/arm64/Makefile:176: archprepare] Error 2
make[1]: Leaving directory '/mnt/linux/.output'
make: *** [Makefile:228: __sub-make] Error 2
make: Leaving directory '/mnt/linux'

Add gawk (GNU Awk) to work around this issue.
2022-06-10 22:20:40 +02:00
Newbyte 5389543c1a
helpers/envkernel.sh: use "$pmbootstrap" in cross_compiler_version() (MR 2173)
This fixes an issue where if pmbootstrap is accessed via a
different command than pmbootstrap on the user's system (I have it
set to pmb for example), cross_compiler_version() would try to use
a command that doesn't exist. On my system, this results in it
always asking if I want to install pmbootstrap every time I run
envkerenl.sh.
2022-03-24 00:25:01 +03:00
Clayton Craft 8a14d366ef
helpers/envkernel.sh: fix shellcheck failure (MR 2151)
A recent update to shellcheck made this line start failing:
In ./helpers/envkernel.sh line 59:
        export pmbootstrap_dir=$(realpath "$script_dir/..")
                               ^--------------------------^ SC2046 (warning): Quote this to prevent word splitting.
2021-12-19 18:16:56 +01:00
博麗霊夢 7541a0ca36
helper/envkernel.sh: fix for running envkernel on aarch64 host (MR 2135)
aarch64 is not recongised as arm64, and envkernel thinks that
cross-compiler is needed, while it shouldn't be.

Fixes #2075
2021-11-02 16:23:33 +03:00
Alexander Krotov f853ec18e5
helpers/envkernel.sh: support `aports` configuration variable (MR 2096) 2021-08-22 20:36:24 +02:00
BO41 e1aef47271
pmbootstrap: make use of consistent casing (MR 2090) 2021-08-12 17:06:11 +02:00
Minecrell f62242aeb1
helpers/envkernel.sh: Try harder to not generate Git version suffix (MR 2084)
The Git version suffixes usually generated automatically by the Linux
build system break packaging in Alpine because the flavor (e.g.
"-postmarketos-qcom-msm8916") will no longer match the module and
zImage path. So far setting LOCALVERSION= and disabling
CONFIG_LOCALVERSION_AUTO was sufficient to avoid the Git version
suffixes but this is no longer enough in Linux 5.14.

Instead, add a better fix by creating an empty .scmversion file
that will be used by the kernel instead of checking the Git status.
The advantage is that this works on Linux 5.14 and it should even
work when CONFIG_LOCALVERSION_AUTO is set.

The .scmversion code can be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/setlocalversion?h=v5.14-rc1#n38
2021-07-12 10:56:36 -07:00
Clayton Craft 76489653df
helpers/envkernel.sh: fix shellcheck disabled tests (MR 2072)
Shellcheck 0.7.2 has a change that gives many error conditions their own
SC30** codes, instead of including them in SC2039. This updates the
scripts in this package that "disable SC2039" to disable the new code.

New codes added in shellcheck: cfd68ee0c2ebfd0ab08a1d4bf628162b454dc207

[ci:skip-build] already built successfully in CI
2021-06-18 20:22:31 -07:00
Oliver Smith 0e2c3a853e
envkernel.sh: fix integer compare used for string (MR 2059)
Prevent stricter shells from crashing there if
$POSTMARKETOS_ENVKERNEL_ENBALED is an empty string. It was reported that
it crashes in ksh93, and busybox sh also complains about it.
2021-05-29 12:23:38 +02:00
MightyM17 c3526f3271
envkernel.sh: Add yaml-dev and g++ dependency. (MR 2039) 2021-03-23 12:41:32 +03:00
Ralf Rachinger 72e24f7f96
Use $XDG_CONFIG_HOME instead of hardcoded path (MR 1969) 2020-08-23 13:51:42 +02:00
Iskren Chernev 2dd707a7ea
envkernel.sh: Add reactivate, deactivate on re-source (MR 1918)
Some users prefer to re-source the script from time to time. Detect that
and deactivate first.
2020-06-02 11:34:46 +02:00
Minecrell be805653bb
helpers/envkernel.sh: Fix "Unable to deduce build architecture" (MR 1921)
After an abuild update in Alpine envkernel.sh now throws an error
when activating envkernel:

    ash: to: not found
    Run 'pmbootstrap log' for details.

This happens because functions.sh fails with:
    Unable to deduce build architecture. Install apk-tools, or set CBUILD.

For now it seems to be enough to set CBUILD appropriately to make it
work again.
2020-04-20 03:02:47 +03:00
Iskren Chernev 41a7089e21
envkernel.sh: various improvements (!1883)
* Change prompt
* Add deactivate
* Use /tmp/envkernel for run-scripts
2020-04-10 20:28:08 +02:00
Minecrell 4e31ddcdd8
helpers/envkernel.sh: expand a glob to get path to deviceinfo (!1899)
The device might not be in testing, but in main or community,
so let's stop hardcoding testing here.
2020-04-01 02:50:13 +03:00
Jami Kettunen 6877532f5d
envkernel.sh: fix sourcing since pma!1063 merge (!1892)
Change pmaports path `aports/device/device-*` to `aports/device/testing/device-*`
to match the directory structure changes after pmaports!1063 got merged.

Without this change sourcing `envkernel.sh` with up-to-date `pmbootstrap` & `aports` would fail with:

  ERROR: Please select a valid device in 'pmbootstrap init'
  See also: <https://postmarketos.org/troubleshooting>
2020-03-14 16:56:27 +01:00
Minecrell 6540c25a9b
envkernel.sh: add dependencies for x86_64 (!1870)
x86_64 kernels require some additional dependencies to build properly.

At this point, the list is getting quite long. Ideally we should only
install the build dependencies that are necessary for a particular
kernel package. Add a FIXME to document this for the future.
2020-02-07 19:20:40 +03:00
Minecrell 569c8ff5b0
envkernel.sh: fix x86_64 (arch == host_arch) (!1870)
Attempting to use envkernel.sh on x86_64 fails at the moment:

$ . ~/pmos/pmbootstrap/helpers/envkernel.sh
Initializing Alpine chroot (details: 'pmbootstrap log')
ERROR: unsatisfiable constraints:
  binutils-x86_64 (missing):
    required by: world[binutils-x86_64]
  gcc-x86_64 (missing):
    required by: world[gcc-x86_64]

We do not need to install a cross compiler if the device arch is
equal to the host architecture. Check if we need a cross compiler
earlier, and avoid installing it if not necessary.

Also rename "is_cc" to "need_cross_compiler". "is_cc" is confusingly
named since "cc" can refer to the compiler symlink ("C compiler")
or "cross compiler".
2020-02-07 19:20:01 +03:00
Daniele Debernardi b0ea7ad8a0
envkernel.sh: fix shellcheck errors (!1853) 2020-01-22 00:17:23 +01:00
Minecrell d45e88505d
envkernel.sh: Avoid changing local version based on Git repository state (!1844)
When git is installed, the Linux kernel build system appends suffixes
to the Linux kernel version based on the local repository state.
This means that we get different kernel versions when building the
package normally or with envkernel.sh.

This causes problems with Alpine's "installkernel" script,
which detects the kernel flavor based on the kernel version.
e.g. when building linux-postmarketos-qcom-msm8916 with git installed
the kernel image is installed to /boot/vmlinuz-g556e2c21dbac-dirty
where pmbootstrap (and anything else) cannot find it.

Two changes are necessary to prevent the kernel build system from
appending Git version information:

  1. Set LOCALVERSION= - this is done by this commit.
  2. Unset CONFIG_LOCALVERSION_AUTO
     - this needs to be done in each kernel config (when needed)
2019-12-23 21:11:51 +01:00
Oliver Smith b63b021c21
envkernel.sh: install findutils (!1838)
The kernel build system tries to use find -printf when
CONFIG_INITRAMFS_SOURCE is chosen, but busybox find doesn't support
that.

Fixes: #1849
2019-12-14 01:50:57 +01:00
Luca Weiss b3a9080398
helpers/envkernel.fish: add gcc4 support (!1842) 2019-12-14 00:18:21 +01:00
Antoine Fontaine 144a58b558
helpers/envkernel.sh: add gcc4 support (!1836) 2019-11-30 15:29:02 +01:00
Luca Weiss ff4965ddfc
Revert "envkernel.sh: fallback to old armhf hostspec (!1786)" (!1813)
The relevant packages have been rebuilt now so we can remove this
workaround.

This reverts commit 9cf3e741a1.
2019-09-18 22:16:39 +02:00
Oliver Smith 9cf3e741a1
envkernel.sh: fallback to old armhf hostspec (!1786)
The armhf hostspec triplet has changed during the Alpine 3.6 release
cylcle. It was recently adjusted in abuild's arch_to_hostspec()
function [1]. Cross compilers in postmarketOS that were built with a
previous version of abuild still have the old hostspec in the name.
Since we use the same function in envkernel.sh to get the cross compiler
name, it is currently failing here for armhf.

We can't simply bump the pkgrel to force a rebuild, because that would
make them go out of sync with the upstrem (non-cross) compiler packages.
That would break the workflow for fixing incompatibilities with Alpine
(see [2]).

Add a workaround to envkernel.sh, to detect if the installed armhf cross
compiler binaries still have the old name.

[1] https://github.com/alpinelinux/abuild/pull/56
[2] https://wiki.postmarketos.org/wiki/Repository_maintenance
2019-05-19 19:09:56 +02:00
Daniele Debernardi e8cba8b20a envkernel.sh: Add xz to the list of packages to install (!1783)
This is required when the kernel is configured to be compressed with
something different than gzip.
2019-05-09 22:14:15 +00:00
Oliver Smith f82e4fd66b
envkernel: support spaces in path (!1770)
Fixes the following error, when running envkernel.sh from a pmbootstrap
path with spaces:

bash: /home/lofenyy/Root/Cabinet/Projects/Phone: No such file or directory
See also: <https://postmarketos.org/troubleshooting>
2019-04-06 01:20:20 +02:00
Robert Yang 43326b551a
envkernel: Add run-script alias to run local scripts within the chroot (!1747)
Example usage:
For kernels that need to run dtbTool after make.
Create a script named post-make.sh in the kernel source directory:

  #!/bin/sh
  dtbTool -s 2048 -p "${srcdir}/scripts/dtc/" -o \
    "${builddir}/arch/arm/boot/dt.img" \
    "${builddir}/arch/arm/boot"

To run this script inside the chroot:
$ source ~/pmbootstrap/helpers/envkernel.sh
$ make lineageos_bacon_defconfig
$ make
$ run-script post-make.sh
2019-02-15 16:24:19 +01:00
Konrad Dybcio cf2e28d3c2 Switch helpers/envkernel.sh to openssl (!1742) 2019-01-22 08:03:06 +01:00
Oliver Smith f16bdaf0ca
Update copyright to 2019
Happy new year \o/
2019-01-02 09:31:20 +01:00
Robert Yang 101a396c90 envkernel: Add x86 architectures (!1733) 2018-12-29 14:33:27 -05:00
Robert Yang 4d6cd2270f envkernel: Support native compiles (!1733)
The cross compile environment variable only needs to be set when the
kernel is being built for a different architecture than the host system.
2018-12-29 14:33:25 -05:00
Robert Yang ce57fae12d envkernel: Set CC and HOSTCC (!1733)
It is necessary to override these environment variables to use an alternate
compiler such as gcc6.
2018-12-29 14:33:15 -05:00
Robert Yang 70126570a4 envkernel: Fix switching envkernel to different source path (!1733)
When there is already another kernel source path mounted then the old mount
should be removed. Otherwise the mount source will still be pointed at the
old kernel source.
2018-12-29 14:33:12 -05:00
Robert Yang 3e845e1edf envkernel: Run make command as user (!1733) 2018-12-29 13:53:56 -05:00
Oliver Smith 946417d314
Make --gcc6 work with fish; add 'source' to usage 2018-10-11 07:22:09 +02:00
Robert Yang a2484f2492 Add envkernel.sh argument to use gcc6 cross compiler 2018-10-10 19:02:25 -04:00
Robert Yang e27f11a705 Parse shell arguments passed to envkernel.sh 2018-10-10 19:02:25 -04:00
Robert Yang 9d198f1ea4 Clean kernel source directory before setting up make alias
When kbuild is using a separate directory for output files then it will
check if the kernel source directory is clean.
The build will throw an error when the source directory is not clean:

  .. is not clean, please run 'make mrproper'

Once envkernel.sh has aliased the make command then make mrproper will
be run in the context of .output directory. If the source directory is not
clean then user may be wondering why make mrproper doesn't clean it.

This change will ensure that the source directory is clean when envkernel
is setup.
2018-10-08 05:21:21 +00:00
Grant Miller 7eaf9de000 Implement bash tab completion 2018-08-27 21:35:05 +00:00
ryang c9fc3d9b85 envkernel: Don't use alias commands in the script itself
The pmbootstrap alias cannot be used within the script.
The reason is that aliases are not expanded in non-interactive shells.
reference: https://unix.stackexchange.com/q/1496

To fix this replace references to the pmbootstrap alias with
the $pmbootstrap variable
2018-08-27 20:31:32 +00:00
Daniil Yarancev f45c87eadc zsh autocompletion: fix filename in comment (#1564) 2018-06-14 20:19:58 +00:00