* [PATCH] image.bbclass: remove 'get_image_name' function
@ 2019-05-21 14:28 claudius.heine.ext
2019-05-23 12:46 ` Henning Schild
2019-05-24 13:06 ` Maxim Yu. Osipov
0 siblings, 2 replies; 4+ messages in thread
From: claudius.heine.ext @ 2019-05-21 14:28 UTC (permalink / raw)
To: isar-users; +Cc: Claudius Heine
From: Claudius Heine <ch@denx.de>
This function is only used in 'do_copy_boot_files' where a simple shell
function fits better.
Signed-off-by: Claudius Heine <ch@denx.de>
---
meta/classes/image.bbclass | 33 ++++++---------------------------
1 file changed, 6 insertions(+), 27 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 3eb261f..45ed8ba 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -64,29 +64,6 @@ inherit image-postproc-extension
# Extra space for rootfs in MB
ROOTFS_EXTRA ?= "64"
-def get_image_name(d, name_link):
- S = d.getVar("IMAGE_ROOTFS", True)
- path_link = os.path.join(S, name_link)
-
- # If path_link does not exist, it might be a symlink
- # in the target rootfs. This block attempts to resolve
- # it relative to the rootfs location.
- if not os.path.exists(path_link):
- path_link = os.path.join(
- S,
- os.path.relpath(
- os.path.realpath(path_link),
- "/",
- ),
- )
-
- if os.path.exists(path_link):
- base = os.path.basename(os.path.realpath(path_link))
- full = d.getVar("IMAGE_FULLNAME", True) + "." + base
- return [base, full]
-
- return ["", ""]
-
def get_rootfs_size(d):
import subprocess
rootfs_extra = int(d.getVar("ROOTFS_EXTRA", True))
@@ -149,12 +126,14 @@ addtask rootfs_install before do_build after do_unpack
do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
do_copy_boot_files() {
- if [ -n "${KERNEL_IMAGE}" ]; then
- cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
+ kernel="$(realpath -q '${IMAGE_ROOTFS}/vmlinuz')"
+ if [ -n "$kernel" ]; then
+ cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
fi
- if [ -n "${INITRD_IMAGE}" ]; then
- sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
+ initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
+ if [ -n "$initrd" ]; then
+ cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
fi
# Check DTB_FILE via inline python to handle unset case:
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] image.bbclass: remove 'get_image_name' function
2019-05-21 14:28 [PATCH] image.bbclass: remove 'get_image_name' function claudius.heine.ext
@ 2019-05-23 12:46 ` Henning Schild
2019-05-23 13:36 ` Claudius Heine
2019-05-24 13:06 ` Maxim Yu. Osipov
1 sibling, 1 reply; 4+ messages in thread
From: Henning Schild @ 2019-05-23 12:46 UTC (permalink / raw)
To: [ext] claudius.heine.ext@siemens.com; +Cc: isar-users, Claudius Heine
Am Tue, 21 May 2019 16:28:18 +0200
schrieb "[ext] claudius.heine.ext@siemens.com"
<claudius.heine.ext@siemens.com>:
> From: Claudius Heine <ch@denx.de>
>
> This function is only used in 'do_copy_boot_files' where a simple
> shell function fits better.
>
> Signed-off-by: Claudius Heine <ch@denx.de>
> ---
> meta/classes/image.bbclass | 33 ++++++---------------------------
> 1 file changed, 6 insertions(+), 27 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 3eb261f..45ed8ba 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -64,29 +64,6 @@ inherit image-postproc-extension
> # Extra space for rootfs in MB
> ROOTFS_EXTRA ?= "64"
>
> -def get_image_name(d, name_link):
> - S = d.getVar("IMAGE_ROOTFS", True)
> - path_link = os.path.join(S, name_link)
> -
> - # If path_link does not exist, it might be a symlink
> - # in the target rootfs. This block attempts to resolve
> - # it relative to the rootfs location.
> - if not os.path.exists(path_link):
> - path_link = os.path.join(
> - S,
> - os.path.relpath(
> - os.path.realpath(path_link),
> - "/",
> - ),
> - )
> -
> - if os.path.exists(path_link):
> - base = os.path.basename(os.path.realpath(path_link))
> - full = d.getVar("IMAGE_FULLNAME", True) + "." + base
> - return [base, full]
> -
> - return ["", ""]
> -
> def get_rootfs_size(d):
> import subprocess
> rootfs_extra = int(d.getVar("ROOTFS_EXTRA", True))
> @@ -149,12 +126,14 @@ addtask rootfs_install before do_build after
> do_unpack
> do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
> do_copy_boot_files() {
> - if [ -n "${KERNEL_IMAGE}" ]; then
> - cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d,
> 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
> + kernel="$(realpath -q '${IMAGE_ROOTFS}/vmlinuz')"
Will this work if ${IMAGE_ROOTFS}/vmlinuz is a symlink to
"/boot/vmlinuz-foo-bar"?
The funny thing with the kernel and the initrd is that we should
probably stop deploying them anyways. As far as i know there are
probably 2 users of them. The first is the qemu test script, which
should be fixed to use IMAGE_RFS/vmlinuz and deal with possible
symlinks.
The second one is the legacy bios wic. This one is also just broken
because it creates a boot partition with copies of kernel and initrd,
that debian does not even know about. So you will also never be able to
update the kernel with apt ... If any other imager needs the deployed
KERNEL and INITRD ... that other imager probably has the same issue.
So in the long run we should just drop that and fix those imagers to
turn the real /boot into the boot partition and fix up /etc/fstab.
Henning
> + if [ -n "$kernel" ]; then
> + cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
> fi
>
> - if [ -n "${INITRD_IMAGE}" ]; then
> - sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d,
> 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
> + initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
> + if [ -n "$initrd" ]; then
> + cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
> fi
>
> # Check DTB_FILE via inline python to handle unset case:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] image.bbclass: remove 'get_image_name' function
2019-05-23 12:46 ` Henning Schild
@ 2019-05-23 13:36 ` Claudius Heine
0 siblings, 0 replies; 4+ messages in thread
From: Claudius Heine @ 2019-05-23 13:36 UTC (permalink / raw)
To: Henning Schild; +Cc: isar-users, Claudius Heine
Hi Henning,
On 23/05/2019 14.46, Henning Schild wrote:
> Am Tue, 21 May 2019 16:28:18 +0200
> schrieb "[ext] claudius.heine.ext@siemens.com"
> <claudius.heine.ext@siemens.com>:
>
>> From: Claudius Heine <ch@denx.de>
>>
>> This function is only used in 'do_copy_boot_files' where a simple
>> shell function fits better.
>>
>> Signed-off-by: Claudius Heine <ch@denx.de>
>> ---
>> meta/classes/image.bbclass | 33 ++++++---------------------------
>> 1 file changed, 6 insertions(+), 27 deletions(-)
>>
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index 3eb261f..45ed8ba 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -64,29 +64,6 @@ inherit image-postproc-extension
>> # Extra space for rootfs in MB
>> ROOTFS_EXTRA ?= "64"
>>
>> -def get_image_name(d, name_link):
>> - S = d.getVar("IMAGE_ROOTFS", True)
>> - path_link = os.path.join(S, name_link)
>> -
>> - # If path_link does not exist, it might be a symlink
>> - # in the target rootfs. This block attempts to resolve
>> - # it relative to the rootfs location.
>> - if not os.path.exists(path_link):
>> - path_link = os.path.join(
>> - S,
>> - os.path.relpath(
>> - os.path.realpath(path_link),
>> - "/",
>> - ),
>> - )
>> -
>> - if os.path.exists(path_link):
>> - base = os.path.basename(os.path.realpath(path_link))
>> - full = d.getVar("IMAGE_FULLNAME", True) + "." + base
>> - return [base, full]
>> -
>> - return ["", ""]
>> -
>> def get_rootfs_size(d):
>> import subprocess
>> rootfs_extra = int(d.getVar("ROOTFS_EXTRA", True))
>> @@ -149,12 +126,14 @@ addtask rootfs_install before do_build after
>> do_unpack
>> do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
>> do_copy_boot_files() {
>> - if [ -n "${KERNEL_IMAGE}" ]; then
>> - cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d,
>> 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
>> + kernel="$(realpath -q '${IMAGE_ROOTFS}/vmlinuz')"
>
> Will this work if ${IMAGE_ROOTFS}/vmlinuz is a symlink to
> "/boot/vmlinuz-foo-bar"?
Do you have a different solution in mind?
Those links are created by linux-update-symlinks from the linux-base
package and I think that using absolute paths there will probably cause
many different issues, so I don't think they did that accidentally.
I tried around for a while to cover all different cases, but I stopped
because don't think that makes sense here until we find a case where
those links are absolute.
> The funny thing with the kernel and the initrd is that we should
> probably stop deploying them anyways. As far as i know there are
> probably 2 users of them. The first is the qemu test script, which
> should be fixed to use IMAGE_RFS/vmlinuz and deal with possible
> symlinks.
> The second one is the legacy bios wic. This one is also just broken
> because it creates a boot partition with copies of kernel and initrd,
> that debian does not even know about. So you will also never be able to
> update the kernel with apt ... If any other imager needs the deployed
> KERNEL and INITRD ... that other imager probably has the same issue.
If a post-install step removes the kernel+initrd from the /boot, then
the fitimage class still needs to find the kernel+dtb and possible the
initrd. This would be the case if you have a project that should be
deployed on a small nand. Updating via apt is not important there.
> So in the long run we should just drop that and fix those imagers to
> turn the real /boot into the boot partition and fix up /etc/fstab.
You don't have a boot partition on some devices.
regards,
Claudius
>
> Henning
>
>> + if [ -n "$kernel" ]; then
>> + cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
>> fi
>>
>> - if [ -n "${INITRD_IMAGE}" ]; then
>> - sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d,
>> 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
>> + initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
>> + if [ -n "$initrd" ]; then
>> + cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
>> fi
>>
>> # Check DTB_FILE via inline python to handle unset case:
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] image.bbclass: remove 'get_image_name' function
2019-05-21 14:28 [PATCH] image.bbclass: remove 'get_image_name' function claudius.heine.ext
2019-05-23 12:46 ` Henning Schild
@ 2019-05-24 13:06 ` Maxim Yu. Osipov
1 sibling, 0 replies; 4+ messages in thread
From: Maxim Yu. Osipov @ 2019-05-24 13:06 UTC (permalink / raw)
To: claudius.heine.ext, isar-users; +Cc: Claudius Heine
On 5/21/19 4:28 PM, claudius.heine.ext@siemens.com wrote:
> From: Claudius Heine <ch@denx.de>
>
> This function is only used in 'do_copy_boot_files' where a simple shell
> function fits better.
Applied to the 'next'.
Maxim.
> Signed-off-by: Claudius Heine <ch@denx.de>
> ---
> meta/classes/image.bbclass | 33 ++++++---------------------------
> 1 file changed, 6 insertions(+), 27 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 3eb261f..45ed8ba 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -64,29 +64,6 @@ inherit image-postproc-extension
> # Extra space for rootfs in MB
> ROOTFS_EXTRA ?= "64"
>
> -def get_image_name(d, name_link):
> - S = d.getVar("IMAGE_ROOTFS", True)
> - path_link = os.path.join(S, name_link)
> -
> - # If path_link does not exist, it might be a symlink
> - # in the target rootfs. This block attempts to resolve
> - # it relative to the rootfs location.
> - if not os.path.exists(path_link):
> - path_link = os.path.join(
> - S,
> - os.path.relpath(
> - os.path.realpath(path_link),
> - "/",
> - ),
> - )
> -
> - if os.path.exists(path_link):
> - base = os.path.basename(os.path.realpath(path_link))
> - full = d.getVar("IMAGE_FULLNAME", True) + "." + base
> - return [base, full]
> -
> - return ["", ""]
> -
> def get_rootfs_size(d):
> import subprocess
> rootfs_extra = int(d.getVar("ROOTFS_EXTRA", True))
> @@ -149,12 +126,14 @@ addtask rootfs_install before do_build after do_unpack
>
> do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
> do_copy_boot_files() {
> - if [ -n "${KERNEL_IMAGE}" ]; then
> - cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
> + kernel="$(realpath -q '${IMAGE_ROOTFS}/vmlinuz')"
> + if [ -n "$kernel" ]; then
> + cp -f "$kernel" '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}'
> fi
>
> - if [ -n "${INITRD_IMAGE}" ]; then
> - sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
> + initrd="$(realpath -q '${IMAGE_ROOTFS}/initrd.img')"
> + if [ -n "$initrd" ]; then
> + cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
> fi
>
> # Check DTB_FILE via inline python to handle unset case:
>
--
Maxim Osipov
ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn
Germany
+49 (151) 6517 6917
mosipov@ilbers.de
http://ilbers.de/
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-24 13:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 14:28 [PATCH] image.bbclass: remove 'get_image_name' function claudius.heine.ext
2019-05-23 12:46 ` Henning Schild
2019-05-23 13:36 ` Claudius Heine
2019-05-24 13:06 ` Maxim Yu. Osipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox