sartura / replica

Replica.one is an easy to use build system designed to deliver both secure and flexible firmware images.
MIT License
26 stars 12 forks source link

how to pre-install tools #9

Closed Sheng2216 closed 3 years ago

Sheng2216 commented 3 years ago

How can we pre-install network management tools, such as iw, ifconfig, sshd, wpa_supplicant, hostapd, etc? So far the only approach we learned is to add the package’s name to the "package" file, I assume since we don't have Portage installed, we can use "package.use" & "package.use.mask" to achieve similar features just like the USE flag. However, these "configurations" are always separately located in different files, which eventually consumes extra effort to check all the files before building a new image. Is there a better way to manage the packages in just one place?

Sometimes we added the package's names to the "package" file and removed it from the "package. mask". After that, we rebuild the image, but we cannot find the packages we want to install after we burn the image into the sd card, what might cause this problem?

jpetrina commented 3 years ago

Given that Replica leverages Portage for its package management, the profile mechanism described in the Package Manager Specification 7 is currently the only supported way to select packages for installation i.e. there is no centralized place to manage packages.

However, the specification does not imply any particular organization method so you may choose to "flatten" out the tree structure as you see fit and remove any inheritance from the configuration. This would be closer to the "one-place-for-everything" approach. If this is acceptable, I suggest creating a new repository overlay.

I cannot comment on the described issue though, can you provide a more detailed information and/or reproduce steps?

Sheng2216 commented 3 years ago

Given that Replica leverages Portage for its package management, the profile mechanism described in the Package Manager Specification 7 is currently the only supported way to select packages for installation i.e. there is no centralized place to manage packages.

However, the specification does not imply any particular organization method so you may choose to "flatten" out the tree structure as you see fit and remove any inheritance from the configuration. This would be closer to the "one-place-for-everything" approach. If this is acceptable, I suggest creating a new repository overlay.

I cannot comment on the described issue though, can you provide a more detailed information and/or reproduce steps?

We first try to add gcc & make,we got no errors at all when building the image, but can't find them after we burned the image. Then we tried to add dev-lang/python:3.8 to the package file, but then got the error "python needs interpreter", then I add dev-lang/python-exec to the package file, and I got the error like this :

#23 1664.8  * Messages for package dev-lang/python-3.8.11 merged to /usr/aarch64-unknown-linux-gnu/:
#23 1664.8  * ERROR: dev-lang/python-3.8.11::gentoo failed (configure phase):
#23 1664.8  *   econf failed
#23 1664.8  * 
#23 1664.8  * Call stack:
#23 1664.8  *               ebuild.sh, line  127:  Called src_configure
#23 1664.8  *             environment, line 3022:  Called econf 'ac_cv_header_stropts_h=no' '--enable-shared' '--enable-ipv6' '--infodir=${prefix}/share/info' '--mandir=${prefix}/share/man' '--with-computed-gotos' '--with-dbmliborder=' '--with-libc=' '--enable-loadable-sqlite-extensions' '--without-ensurepip' '--with-system-expat' '--with-system-ffi'
#23 1664.8  *        phase-helpers.sh, line  711:  Called __helpers_die 'econf failed'
#23 1664.8  *   isolated-functions.sh, line  112:  Called die
#23 1664.8  * The specific snippet of code:
#23 1664.8  *           die "$@"
#23 1664.8  * 
#23 1664.8  * If you need support, post the output of `emerge --info '=dev-lang/python-3.8.11::gentoo'`,
#23 1664.8  * the complete build log and the output of `emerge -pqv '=dev-lang/python-3.8.11::gentoo'`.
#23 1664.8  * The complete build log is located at '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-lang/python-3.8.11/temp/build.log'.
#23 1664.8  * The ebuild environment file is located at '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-lang/python-3.8.11/temp/environment'.
#23 1664.8  * Working directory: '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-lang/python-3.8.11/work/Python-3.8.11'
#23 1664.8  * S: '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-lang/python-3.8.11/work/Python-3.8.11'
#23 1664.8 
#23 1664.8 
...
#23 1664.8  * After world updates, it is important to remove obsolete packages with

#23 1664.8  * emerge --depclean. Refer to `man emerge` for more information.

executor failed running [/bin/bash -l -c set_repository_conf ${SYSROOT} replica 100 &&     set_portage_profile ${SYSROOT} replica replica/rpi4 &&     cross-emerge -vt --keep-going=n --deep --with-bdeps=y --newuse --newrepo @world]: exit code: 1
make: *** [Makefile:124: build_rpi4] Error 1
jpetrina commented 3 years ago

We first try to add gcc & make,we got no errors at all when building the image, but can't find them after we burned the image. Then we tried to add dev-lang/python:3.8 to the package file, but then got the error "python needs interpreter", then I add dev-lang/python-exec to the package file, and I got the error like this :

*snip*

We would appreciate any detailed information you can provide us with regards to these issues, having a separate fork with a branch demonstrating this issue would be preferable. However, we seldom support having GCC available on the target platforms given that the package requires a large amount of space. For the same reason, we avoid bundling Python and Portage.

jsmolic commented 3 years ago

Hello @Sheng-IoT, you mentioned in the first comment that sometimes you can't find packages you added on the Raspberry Pi image. Can I ask which packages are you having there problems with so i can help you with those?\ Generally if you want to add new package to the image, you just need to add it to the packages file, but some packages might not be so trivial. For example, regarding your Python build issue, Gentoo has a mechanism that supports having multiple python versions installed at the same time, and it is handled via PYTHON_TARGETS USE flags (you can read more about it here). Gentoo profiles define default value for PYTHON_TARGETS, and currently it is 3.9, 3.8 is deprecated and Gentoo will slowly start to move away from supporting 3.8 (more details on that here). The python build issue you hit (no python interpreter) happened because Replica tried to compile python 3.8, while the build environment only contained 3.9 version, and no 3.8 since 3.9 is default version and we didn't modify the default configuration, so naturally the compilation fails because you don't have 3.8 in the build system, but on the other hand you are able to cross-compile Python-3.9. I would reccomend using the default python target 3.9, so if you want to have python on your image it is enough to add dev-lang/python to the packages file. If you want to have other python implementations, it should be done via USE flag configurations, so you would have to modify package.use file on the Raspberry pi profile as well on the repos/host profile (but I suggest for now just using the default Python 3.9). However, I must note that currently Gentoo does not fully support cross compilation of Python packages and it is a highly experimental feature at this point.

Regarding gcc, cross compiling gcc can be a complicated process and probably requires additional configuration, for example mixing gcc versions between host, target and rootfs version can cause host/target misdetection and will probably fail, so you have to ensure consistent gcc versions. As @jpetrina mentioned we avoid building gcc for our images because it takes up a lot of space on the device. In order to help out I would need more details such as which gcc version was cross-compiled and how to reproduce the build (preferably on a seperate branch somewhere).

jsmolic commented 3 years ago

I think we resolved all points here so I'll close the issue, @Sheng-IoT if there is anything else, feel free to reach out. Thanks!