Signed-off-by: Yu Chuan 13186087857@163.com --- jobs/iso2rootfs.yaml | 4 ++++ tests/iso2rootfs | 34 ++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/jobs/iso2rootfs.yaml b/jobs/iso2rootfs.yaml index c67faf44147d..a84f7583de94 100644 --- a/jobs/iso2rootfs.yaml +++ b/jobs/iso2rootfs.yaml @@ -34,6 +34,10 @@ iso2rootfs: # - no_fstab: will comment all line in /etc/fstab. config_rootfs:
+ ## install pkgs for result rootfs + ## - example: vim, git, xxx + rootfs_install_pkgs: + ################# # dailybuild related fields ################# diff --git a/tests/iso2rootfs b/tests/iso2rootfs index cd64044f0833..8625b6484d89 100755 --- a/tests/iso2rootfs +++ b/tests/iso2rootfs @@ -203,17 +203,24 @@ get_cgz() tar -xf "${cgz_path_t}" -C "${CGZ_PATH}" }
-install_pkgs() +get_pkg_installer() { - local pkg_installer - command -v yum && pkg_installer="yum" + local installer + + has_cmd yum && installer=yum + has_cmd apt && installer=apt
- [[ -n "$pkg_installer" ]] || die "cannot find pkg installer." + [ -n "$installer" ] || die "cannot find pkg installer." + echo $installer +} + +install_pkgs() +{ + local installer=$(get_pkg_installer)
- local pt for pt do - "$pkg_installer" install -y "$pt" || die "cannot install pkg: $pt." + "$installer" install -y "$pt" || die "cannot install pkg: $pt." done }
@@ -367,11 +374,26 @@ disable_fstab() sed -i 's/^([^#])/# \1/g' "${ROOTFS_DES_DIR}/etc/fstab" }
+install_pkgs_for_rootfs() +{ + [ -n "$rootfs_install_pkgs" ] || return 0 + + local installer=$(get_pkg_installer) + + if [ "$installer" == "yum" ]; then + "$installer" install -y --skip-broken --installroot=${ROOTFS_DES_DIR} ${rootfs_install_pkgs//,/ } + elif [ "$installer" == "apt" ]; then + "$installer" install -y --ignore-missing --fix-missing --fix-broken -o RootDir=${ROOTFS_DES_DIR} ${rootfs_install_pkgs//,/ } + fi +} + config_rootfs() { config_dns_resolver disable_selinux disable_fstab + + install_pkgs_for_rootfs }
############ test rootfs ############