kiwi/openEuler-custom-make.patch
2023-11-20 10:23:44 +08:00

1023 lines
32 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff --git a/kiwi/archive/cpio.py b/kiwi/archive/cpio.py
index 27d596c..042f1cd 100644
--- a/kiwi/archive/cpio.py
+++ b/kiwi/archive/cpio.py
@@ -17,7 +17,11 @@
#
# project
from kiwi.command import Command
+from kiwi.runtime_config import RuntimeConfig
+import os
+import logging
+log = logging.getLogger('kiwi')
class ArchiveCpio:
"""
@@ -27,6 +31,7 @@ class ArchiveCpio:
"""
def __init__(self, filename):
self.filename = filename
+ self.runtime_config = RuntimeConfig()
def create(self, source_dir, exclude=None):
"""
@@ -35,6 +40,62 @@ class ArchiveCpio:
:param string source_dir: data source directory
:param list exclude: list of excluded items
"""
+ if self.runtime_config.get_custom_hw_systemflag():
+ delete_list = ['vmlinuz*', 'initrd*', 'initramfs*', 'grub']
+ for delete_file in delete_list:
+ rm_boot_cmd = 'rm -rf '+ source_dir + '/boot/' + delete_file
+ os.system(rm_boot_cmd)
+ sec_flag = "false"
+ pwd = os.getcwd()
+ secDir = pwd + '/kiwi/eulerlinuxiso/'
+ secfile = secDir + 'security_s.conf'
+ if os.path.isfile(secfile):
+ sec_flag = "true"
+ log.info('Starting to do security hardening...')
+ sec_com = pwd + '/security-tool/sysenhance.sh -s -c ' + pwd + '/security-tool/security.conf -u ' + secfile + ' -d ' + source_dir
+ sec_com = 'sh '+ sec_com + ' -l /tmp/sysenhance.log > /tmp/sysenhancelog 2>&1'
+ os.system(sec_com)
+ Command.run(
+ ['rm', '-f', secfile]
+ )
+ log.info("Security hardening log file at /tmp/sysenhance.log")
+ else:
+ log.info("Skip security hardening...")
+
+ if self.runtime_config.get_custom_hw_release_type() == 'TAR':
+ resolve_file = secDir + 'resolve.sh'
+ change_uid_files = source_dir + '/usr/openEuler/conf/change_uid_files'
+ change_gid_files = source_dir + '/usr/openEuler/conf/change_gid_files'
+ if os.path.isfile(resolve_file):
+ log.info('Starting to resolve none-owner problem...')
+ Command.run(
+ ['cp', resolve_file, source_dir + '/tmp']
+ )
+ Command.run(
+ ['chmod', 'u+x', source_dir + '/tmp/resolve.sh']
+ )
+ Command.run(
+ ['chroot', source_dir, '/tmp/resolve.sh']
+ )
+ Command.run(
+ ['rm', '-f', source_dir + '/tmp/resolve.sh']
+ )
+ if not os.path.isfile(change_uid_files) or not os.path.isfile(change_gid_files):
+ log.info('Failed to Resolve the non-owner problem...')
+ else:
+ log.info("Skip resolve none-owner...")
+
+ if self.runtime_config.get_custom_hw_systemflag():
+ find_command = ['cd', source_dir, '&&', 'find', '.']
+ cpio_command = [
+ 'cpio', '-H', 'newc', '--create', '--quiet', '|', 'pigz', '-9', '>', self.filename
+ ]
+ bash_command = find_command + ['|'] + cpio_command + ['&&'] + ['cd -']
+ Command.run(
+ ['bash', '-c', ' '.join(bash_command)]
+ )
+ return
+
find_excludes = []
find_command = ['cd', source_dir, '&&', 'find', '.']
cpio_command = [
diff --git a/kiwi/boot/image/builtin_kiwi.py b/kiwi/boot/image/builtin_kiwi.py
index 5b26798..30d30bc 100644
--- a/kiwi/boot/image/builtin_kiwi.py
+++ b/kiwi/boot/image/builtin_kiwi.py
@@ -33,6 +33,7 @@ from kiwi.archive.cpio import ArchiveCpio
from kiwi.utils.compress import Compress
from kiwi.path import Path
from kiwi.boot.image.base import BootImageBase
+from kiwi.runtime_config import RuntimeConfig
log = logging.getLogger('kiwi')
@@ -99,6 +100,7 @@ class BootImageKiwi(BootImageBase):
system.install_system(
manager
)
+ self.runtime_config = RuntimeConfig()
profile = Profile(self.boot_xml_state)
profile.add('kiwi_initrdname', boot_image_name)
@@ -121,16 +123,22 @@ class BootImageKiwi(BootImageBase):
self.setup.import_overlay_files(
follow_links=True
)
+
+ if self.runtime_config.get_custom_hw_systemflag():
+ self.setup.setup_groups()
+ self.setup.setup_users()
self.setup.call_config_script()
- system.pinch_system(
- manager=manager, force=True
- )
+ if not self.runtime_config.get_custom_hw_systemflag():
+ system.pinch_system(
+ manager=manager, force=True
+ )
# make sure system instance is cleaned up before setting up
del system
self.setup.call_image_script()
- self.setup.create_init_link_from_linuxrc()
+ if not self.runtime_config.get_custom_hw_systemflag():
+ self.setup.create_init_link_from_linuxrc()
def create_initrd(
self, mbrid: Optional[SystemIdentifier] = None,
@@ -169,15 +177,16 @@ class BootImageKiwi(BootImageBase):
data.sync_data(
options=Defaults.get_sync_options()
)
- boot_directory = temp_boot_root_directory + '/boot'
- Path.wipe(boot_directory)
- if mbrid:
- log.info(
- '--> Importing mbrid: %s', mbrid.get_id()
- )
- Path.create(boot_directory)
- image_identifier = boot_directory + '/mbrid'
- mbrid.write(image_identifier)
+
+ if not self.runtime_config.get_custom_hw_systemflag():
+ Path.wipe(boot_directory)
+ if mbrid:
+ log.info(
+ '--> Importing mbrid: %s', mbrid.get_id()
+ )
+ Path.create(boot_directory)
+ image_identifier = boot_directory + '/mbrid'
+ mbrid.write(image_identifier)
cpio = ArchiveCpio(
os.sep.join([self.target_dir, kiwi_initrd_basename])
@@ -185,19 +194,33 @@ class BootImageKiwi(BootImageBase):
# the following is a list of directories which were needed
# during the process of creating an image but not when the
# image is actually booting with this initrd
- exclude_from_archive = [
- '/' + Defaults.get_shared_cache_location(),
- '/image', '/usr/lib/grub*'
- ]
+ if self.runtime_config.get_custom_hw_systemflag():
+ exclude_from_archive = [
+ '/' + Defaults.get_shared_cache_location(),
+ '/image'
+ ]
+ else:
+ exclude_from_archive = [
+ '/' + Defaults.get_shared_cache_location(),
+ '/image', '/usr/lib/grub*'
+ ]
# the following is a list of directories to exclude which
- # are not needed inside of the initrd
- exclude_from_archive += [
- '/usr/share/doc', '/usr/share/man', '/home', '/media', '/srv'
- ]
+ #
+ if self.runtime_config.get_custom_hw_systemflag():
+ exclude_from_archive += [
+ '/media'
+ ]
+ else:
+ exclude_from_archive += [
+ '/usr/share/doc', '/usr/share/man', '/home', '/media', '/srv'
+ ]
cpio.create(
source_dir=temp_boot_root_directory,
exclude=exclude_from_archive
)
+ if self.runtime_config.get_custom_hw_systemflag():
+ self.initrd_filename = kiwi_initrd_basename
+ return
log.info(
'--> xz compressing archive'
)
diff --git a/kiwi/builder/kis.py b/kiwi/builder/kis.py
index 55da66f..271f46b 100644
--- a/kiwi/builder/kis.py
+++ b/kiwi/builder/kis.py
@@ -140,24 +140,27 @@ class KisBuilder:
self.boot_image_task.boot_root_directory
)
- # extract kernel from boot system
- kernel = Kernel(self.boot_image_task.boot_root_directory)
- kernel_data = kernel.get_kernel()
- if kernel_data:
- self.kernel_filename = ''.join(
- [
- os.path.basename(self.image_name), '-',
- kernel_data.version, '.kernel'
- ]
- )
- kernel.copy_kernel(
- self.target_dir, self.kernel_filename
- )
+ if self.runtime_config.get_custom_hw_product_type() == 'DPROJ':
+ log.info('Skin copy kernel for DPROJ')
else:
- raise KiwiKisBootImageError(
- 'No kernel in boot image tree %s found' %
- self.boot_image_task.boot_root_directory
- )
+ # extract kernel from boot system
+ kernel = Kernel(self.boot_image_task.boot_root_directory)
+ kernel_data = kernel.get_kernel()
+ if kernel_data:
+ self.kernel_filename = ''.join(
+ [
+ os.path.basename(self.image_name), '-',
+ kernel_data.version, '.kernel'
+ ]
+ )
+ kernel.copy_kernel(
+ self.target_dir, self.kernel_filename
+ )
+ else:
+ raise KiwiKisBootImageError(
+ 'No kernel in boot image tree %s found' %
+ self.boot_image_task.boot_root_directory
+ )
# extract hypervisor from boot(initrd) root system
if self.xen_server:
@@ -198,6 +201,8 @@ class KisBuilder:
cmdline += ' {}'.format(self.custom_cmdline)
with open(self.append_file, 'w') as append:
append.write(cmdline)
+ if self.runtime_config.get_custom_hw_systemflag():
+ return self.result
# put results into a tarball
if not self.xz_options:
diff --git a/kiwi/config/functions.sh b/kiwi/config/functions.sh
index 98915af..0a7afb3 100644
--- a/kiwi/config/functions.sh
+++ b/kiwi/config/functions.sh
@@ -173,10 +173,22 @@ function baseStripLocales {
baseStripAndKeep "${keepLocales}"
}
+#======================================
+# baseStripGconv
+#--------------------------------------
+function baseStripGconv {
+ local keepGconv="$@"
+
+ find /usr/lib/gconv -mindepth 1 -maxdepth 1 -type f 2>/dev/null |\
+ baseStripAndKeep ${keepGconv}
+
+ find /usr/lib64/gconv -mindepth 1 -maxdepth 1 -type f 2>/dev/null |\
+ baseStripAndKeep ${keepGconv}
+}
+
function baseStripTranslations {
- local keepMatching="$*"
- find /usr/share/locale -name "*.mo" |\
- grep -v "${keepMatching}" | xargs rm -f
+ local keepMatching="$@"
+ find /usr/share/locale -name "*.mo" | baseStripAndKeep ${keepMatching}
}
function baseStripUnusedLibs {
@@ -187,6 +199,8 @@ function baseStripUnusedLibs {
local needlibs
local found
local dir
+ local lnk
+ local new
local lib
local lddref
# /.../
@@ -194,33 +208,33 @@ function baseStripUnusedLibs {
# on files in *bin*
# ---
ldconfig
- rm -f /tmp/needlibs
- for i in /usr/bin/* /bin/* /sbin/* /usr/sbin/* /lib/systemd/systemd-*;do
- for n in $(ldd "$i" 2>/dev/null | cut -f2- -d "/" | cut -f1 -d " ");do
- if [ ! -e "/$n" ];then
+ rm -f /opt/needlibs
+ for i in /usr/bin/* /bin/* /sbin/* /usr/sbin/*;do
+ for n in $(ldd $i 2>/dev/null | cut -f2- -d\/ | cut -f1 -d " ");do
+ if [ ! -e /$n ];then
continue
fi
- lddref="/$n"
+ lddref=/$n
while true;do
- if lib=$(readlink "${lddref}"); then
- lddref="${lib}"
+ lib=$(readlink $lddref)
+ if [ $? -eq 0 ];then
+ lddref=$lib
continue
fi
break
done
- lddref=$(basename "${lddref}")
- echo "${lddref}" >> /tmp/needlibs
+ lddref=$(basename $lddref)
+ echo $lddref >> /opt/needlibs
done
done
count=0
- for i in $(sort /tmp/needlibs | uniq);do
+ for i in `cat /opt/needlibs | sort | uniq`;do
for d in \
/lib /lib64 /usr/lib /usr/lib64 \
- /usr/X11R6/lib /usr/X11R6/lib64 \
- /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
+ /usr/X11R6/lib /usr/X11R6/lib64
do
if [ -e "$d/$i" ];then
- needlibs[${count}]="$d/$i"
+ needlibs[$count]=$d/$i
count=$((count + 1))
fi
done
@@ -228,47 +242,41 @@ function baseStripUnusedLibs {
# /.../
# add exceptions
# ----
- for libname in $1; do
- for libfile in \
- /lib*/"$libname"* /usr/lib*/"$libname"* \
- /lib/x86_64-linux-gnu/"$libname"* \
- /usr/lib/x86_64-linux-gnu/"$libname"* \
- /usr/X11R6/lib*/"$libname"*
- do
- if [ -e "$libfile" ];then
- needlibs[$count]=$libfile
- count=$((count + 1))
+ while [ ! -z $1 ];do
+ for i in /lib*/$1* /usr/lib*/$1* /usr/X11R6/lib*/$1*;do
+ if [ -e $i ];then
+ needlibs[$count]=$i
+ count=`expr $count + 1`
fi
done
+ shift
done
# /.../
# find unused libs and remove it, dl loaded libs
# seems not to be that important within the initrd
# ----
- rm -f /tmp/needlibs
+ rm -f /opt/needlibs
for i in \
/lib/lib* /lib64/lib* /usr/lib/lib* \
- /usr/lib64/lib* /usr/X11R6/lib*/lib* \
- /lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/lib*
+ /usr/lib64/lib* /usr/X11R6/lib*/lib*
do
found=0
- if [ ! -e "$i" ];then
+ if [ ! -e $i ];then
continue
fi
- if [ -d "$i" ];then
+ if [ -d $i ];then
continue
fi
- if [ -L "$i" ];then
+ if [ -L $i ];then
continue
fi
for n in ${needlibs[*]};do
- if [ "$i" = "$n" ];then
+ if [ $i = $n ];then
found=1; break
fi
done
- if [ "${found}" -eq 0 ];then
- echo "Removing library: $i"
- rm "$i"
+ if [ $found -eq 0 ];then
+ rm_isnot_usrfile $i
fi
done
}
@@ -289,27 +297,160 @@ function baseUpdateSysConfig {
fi
}
-function baseStripInitrd {
- declare kiwi_initrd_system=${kiwi_initrd_system}
- declare kiwi_strip_tools=${kiwi_strip_tools}
- declare kiwi_strip_libs=${kiwi_strip_libs}
+
+#find all need tool which һ
+function baseStripAllTools {
+ local needtools=$1
+ local newneedtools=
+ local cmdfile
+ local count=0
+ for need in $needtools;do
+ cmdfile=$(which $need)
+ if [ $? -eq 0 ];then
+ newneedtools[$count]=$(basename $cmdfile)
+ count=$((count + 1))
+ while true;do
+ needtool=$(readlink $cmdfile)
+ if [ $? -eq 0 ];then
+ newneedtools[$count]=$(basename $needtool)
+ count=$((count + 1))
+ cmdfile=$needtool
+ continue
+ fi
+ newneedtools[$count]=$(basename $cmdfile)
+ count=$((count + 1))
+ break
+ done
+
+ fi
+ done
+
+ for path in /sbin /usr/sbin /usr/bin /bin;do
+ baseStripTools "$path" "${newneedtools[*]}"
+ done
+
+}
+
+# function baseStripInitrd {
+# declare kiwi_initrd_system=${kiwi_initrd_system}
+# declare kiwi_strip_tools=${kiwi_strip_tools}
+# declare kiwi_strip_libs=${kiwi_strip_libs}
+# #==========================================
+# # Check for initrd system
+# #------------------------------------------
+# if [ "${kiwi_initrd_system}" = "dracut" ]; then
+# echo "dracut initrd system requested, initrd strip skipped"
+# return
+# fi
+# #==========================================
+# # remove unneeded tools
+# #------------------------------------------
+# local tools="${kiwi_strip_tools}"
+# tools="${tools} $*"
+# for path in /sbin /usr/sbin /usr/bin /bin;do
+# baseStripTools "${path}" "${tools}"
+# done
+# }
+
+#======================================
+# baseStripInvalidLink
+#--------------------------------------
+function baseStripInvalidLink {
+ local path
+ local link_file
+ for path in /etc /lib /lib64 /usr /var;do
+ find $path -type l -follow -exec ls {} \; | while read link_file
+ do
+ ls -l $link_file | grep -E "/proc|fd/" 1>/dev/null 2>&1
+ [ $? != 0 ] && rm -f $link_file
+ done
+ done
+}
+
+#======================================
+# suseStripInitrd
+#--------------------------------------
+function suseStripInitrd {
#==========================================
- # Check for initrd system
+ # Remove unneeded files
#------------------------------------------
- if [ "${kiwi_initrd_system}" = "dracut" ]; then
- echo "dracut initrd system requested, initrd strip skipped"
- return
- fi
+ echo $kiwi_strip_delete | xargs rm -rfv
+ local tools="$kiwi_strip_tools"
+ tools="$tools $@"
+ #for path in /sbin /usr/sbin /usr/bin /bin;do
+ # baseStripTools "$path" "$tools"
+ #done
+ baseStripAllTools "$tools"
+
+ #create busybox cmd link
+ baseSetupBusyBox -f
+
#==========================================
- # remove unneeded tools
+ # remove unused libs
#------------------------------------------
- local tools="${kiwi_strip_tools}"
- tools="${tools} $*"
- for path in /sbin /usr/sbin /usr/bin /bin;do
- baseStripTools "${path}" "${tools}"
- done
+ baseStripUnusedLibs $kiwi_strip_libs
+ #==========================================
+ # remove images.sh
+ #------------------------------------------
+ rm -f /image/images.sh
+ #==========================================
+ # remove unused root directories
+ #------------------------------------------
+ #rm -rf /root
+ #rm -rf /home
+ #rm -rf /media
+ #rm -rf /srv
+ #==========================================
+ # remove unused doc directories
+ #------------------------------------------
+ rm -rf /usr/share/doc
+ rm -rf /usr/share/man
+ #==========================================
+ find /sbin /usr/sbin /usr/bin /bin -maxdepth 1 -type f |xargs rpm -qf --qf '%{name}\n' |sort -u > /opt/need_rpmlst
+ find /sbin /usr/sbin /usr/bin /bin -maxdepth 1 -type l |xargs rpm -qf --qf '%{name}\n' |sort -u >> /opt/need_rpmlst
+
+ find /lib /lib64 /usr/lib /usr/lib64 \
+ /usr/X11R6/lib /usr/X11R6/lib64 \
+ -maxdepth 1 -type f |grep so |xargs rpm -qf --qf '%{name}\n' |sort -u >> /opt/need_rpmlst
+
+ find /lib/modules/ -type f -name "*.ko" |xargs rpm -qf --qf '%{name}\n' |sort -u >> /opt/need_rpmlst
+ for i in `baseGetPackagesForDeletion`;do
+ grep -q ^${i}$ /opt/need_rpmlst
+ if [ $? -ne 0 ];then
+ Rpm -e --nodeps --noscripts $i
+ else
+ echo ${i} | tee -a /var/log/cancel_uninstallrpm
+ chmod 640 /var/log/cancel_uninstallrpm
+ fi
+ done
+
+ # remove invalid link file
+ #------------------------------------------
+ baseStripInvalidLink
}
+function strip_rpm {
+ #==========================================
+ # remove rpm cmd, until get src rpm list
+ #------------------------------------------
+
+ if [ "$sys_cut" = "yes" ];then
+
+ #zypper#
+ Rpm -e --nodeps zypper libzypp satsolver-tools
+
+ #smart
+ Rpm -e --nodeps smart smart-gui
+
+ Rpm -e --nodeps rpm
+
+ for p in dpkg rpm smart zypp YaST2;do
+ rm -rf /var/lib/$p
+ done
+ fi
+}
+
+
function baseStripFirmware {
# /.../
# check all kernel modules if they require a firmware and
@@ -412,7 +553,7 @@ function baseStripModules {
if [[ ${file} =~ ${mod} ]] && [[ ! ${file} =~ "updates" ]];then
echo "baseStripModules: Update driver found for ${mod}"
echo "baseStripModules: Removing old version: ${file}"
- rm -f "${file}"
+ rm_isnot_usrfile $file
fi
done
done
@@ -478,10 +619,6 @@ function baseStripKernel {
if [ "${kiwi_initrd_system}" = "dracut" ]; then
echo "dracut initrd system requested, kernel strip skipped"
else
- for delete in ${kiwi_strip_delete};do
- echo "Removing file/directory: ${delete}"
- rm -rf "${delete}"
- done
baseCreateKernelTree
baseStripKernelModules
baseFixupKernelModuleDependencies
@@ -594,14 +731,40 @@ function suseInsertService {
baseInsertService "$@"
}
+
+
+#======================================
+# suseActivateAllServices ---- add
+#--------------------------------------
+function suseRemoveAllServices {
+ # /.../
+ # Check all services in /etc/init.d/ and activate them
+ # by calling insertService
+ # -----
+ for i in /etc/init.d/*;do
+ if [ -x $i ] && [ -f $i ];then
+ echo $i | grep -q skel
+ if [ $? = 0 ];then
+ continue
+ fi
+ echo $i | grep -q halt
+ if [ $? = 0 ];then
+ continue
+ fi
+ echo $i | grep -q reboot
+ if [ $? = 0 ];then
+ continue
+ fi
+ suseRemoveService ${i##*/}
+ fi
+ done
+}
+
function suseService {
# function kept for compatibility
baseService "$@"
}
-function suseStripInitrd {
- baseStripInitrd "$@"
-}
function suseStripKernel {
baseStripKernel
@@ -677,6 +840,46 @@ function Debug {
fi
}
+
+#======================================
+# baseSetupBusyBox
+#--------------------------------------
+function baseSetupBusyBox {
+ # /.../
+ # activates busybox if installed for all links from
+ # the busybox/busybox.links file - you can choose custom apps to
+ # be forced into busybox with the "-f" option as first parameter
+ # ---
+ # example: baseSetupBusyBox -f /bin/zcat /bin/vi
+ # ---
+ local applets=""
+ local force=no
+ local busyboxlinks=/usr/share/busybox/busybox.links
+ if [ ! -f "/usr/sbin/busybox" ]; then
+ echo "Busybox not installed... skipped"
+ return 0
+ fi
+ if [ $# -gt 0 ] && [ "$1" = "-f" ]; then
+ force=yes
+ shift
+ fi
+ if [ $# -gt 0 ]; then
+ for i in "$@"; do
+ if grep -q "^$i$" "$busyboxlinks"; then
+ applets="${applets} $i"
+ fi
+ done
+ else
+ applets=`cat "$busyboxlinks"`
+ fi
+ for applet in $applets; do
+ if [ ! -f "$applet" ] || [ "$force" = "yes" ]; then
+ echo "Busybox Link: ln -sf /usr/sbin/busybox $applet"
+ ln -sf /usr/sbin/busybox "$applet"
+ fi
+ done
+}
+
function baseQuoteFile {
# /.../
# Quote file to be shell sourceable
@@ -715,6 +918,14 @@ function baseSyncKernelTree {
rm -rf /lib/modules/*
cp -a /kernel-tree/* /lib/modules/
rm -rf /kernel-tree
+ if [ -d /lib/modules/openEuler ]; then
+ kversion=($(ls /lib/modules/|grep -v 'openEuler'))
+ for((i=0;i<${#kversion[@]};i++))
+ do
+ rm -rf /lib/modules/${kversion[i]}/openEuler
+ ln -sf /lib/modules/openEuler /lib/modules/${kversion[i]}/openEuler
+ done
+ fi
}
function baseFixupKernelModuleDependencies {
@@ -797,7 +1008,7 @@ function baseStripAndKeep {
fi
done
if [ "${found}" = 0 ]; then
- Rm -rf "${file}"
+ rm_isnot_usrfile $file
fi
done
}
@@ -816,6 +1027,11 @@ function baseStripTools {
while IFS= read -r -d $'\0' file; do
found=0
base=$(/usr/bin/basename "${file}")
+ if [ "${base}" = "rpm" ]; then
+ # Keep the RPM command, and delete by sys_cut=yes
+ echo "sys_cut keep rpm cmd."
+ found=1
+ fi
for need in ${tools};do
if [ "${base}" = "$need" ];then
found=1
@@ -846,16 +1062,133 @@ function deprecated {
exit 1
}
+#======================================
+# baseStripcustomBep
+#--------------------------------------
+function baseStripcustomBep {
+ # /.../
+ # remove custom difference files
+ # ----
+ local hookdir=$1
+ local hookscript=$hookdir/S00bep
+
+ [ ! -d "$hookdir" ] && return
+ [ ! -f "$hookscript" ] && return
+ chmod u+x $hookscript &>/dev/null
+ dos2unix $hookscript &>/dev/null
+ if [ -x "$hookscript" ]; then
+ /bin/bash $hookscript
+ fi
+ rm -rf $hookdir
+ rm -rf /usr/custom/usrfile/$hookdir
+
+}
#======================================
-# Deprecated methods
+# baseStripBep
#--------------------------------------
+function baseStripBep {
+ # /.../
+ # remove log,dnf, files
+ # ----
+ local dbepfiles=""
+ local directories="
+ /var/log/
+ /var/lib/systemd/catalog
+ "
+ local dbephookdir="/usr/openEuler/hook/bep_delete_hook"
+ for dir in $directories; do
+ dbepfiles=$(find $dir -type f)
+ for file in $dbepfiles
+ do
+ echo -n > $file
+ done
+ done
+ rm -f /var/lib/dnf/history*
+ rm -f /var/lib/rpm/__db.00*
+ baseStripcustomBep $dbephookdir
+}
+
+function rm_isnot_usrfile {
+ local rm_file=$1
+ local usrrpm_filelst='/opt/usrrpm_filelst'
+ if [ -f $usrrpm_filelst ];then
+ grep -q ^${rm_file}$ $usrrpm_filelst
+ if [ $? -eq 0 ];then
+ return 0
+ fi
+ fi
+
+ echo "Removing file: $rm_file"
+ rm -rf ${rm_file}
+
+ return 0
+}
+
+function rhelStripKernel {
+ suseStripKernel
+}
+
+function rhelStripInitrd {
+ suseStripInitrd
+}
+
+function baseStripDocs {
+ # /.../
+ # remove all documentation, except
+ # copying license copyright
+ # ----
+ local docfiles
+ local dir
+ local directories="
+ /opt/gnome/share/doc/packages
+ /usr/share/doc/packages
+ /opt/kde3/share/doc/packages
+ "
+ for dir in ${directories}; do
+ docfiles=$(find "${dir}" -type f |\
+ grep -iv "copying\|license\|copyright")
+ rm -f "${docfiles}"
+ done
+ rm -rf `rpm -qad`
+ rm -rf /usr/share/info
+ rm -rf /usr/share/man
+}
+
function baseCleanMount {
- deprecated "${FUNCNAME[0]}" <<- EOF
- Cleanup operations are a responsibility of the kiwi code
- EOF
+ for path in /proc/sys/fs/binfmt_misc /proc /dev/pts /sys;do
+ [ -d "${path}" ] && umount "${path}" &>/dev/null
+ done
+}
+
+function suseConfig {
+ return
+}
+
+#======================================
+# Rpm
+#--------------------------------------
+function Rpm {
+ # /.../
+ # all rpm function & anounce it to log
+ # ----
+ Debug "rpm $*"
+ rpm "$@"
}
+#======================================
+# baseGetPackagesForDeletion
+#--------------------------------------
+function baseGetPackagesForDeletion {
+ declare kiwi_delete=${kiwi_delete}
+ echo "${kiwi_delete}"
+}
+
+
+#======================================
+# Deprecated methods
+#--------------------------------------
+
function baseMount {
deprecated "${FUNCNAME[0]}" <<- EOF
Mounting of kernel and other base filesystems are a
@@ -877,18 +1210,6 @@ function baseSetupUserPermissions {
EOF
}
-function suseConfig {
- deprecated "${FUNCNAME[0]}" <<- EOF
- suse script no longer present
- EOF
-}
-
-function baseGetPackagesForDeletion {
- deprecated "${FUNCNAME[0]}" <<- EOF
- Provided by the kiwi_delete environment variable
- EOF
-}
-
function baseGetProfilesUsed {
deprecated "${FUNCNAME[0]}" <<- EOF
Provided by the kiwi_profiles environment variable
@@ -902,13 +1223,6 @@ function baseStripMans {
EOF
}
-function baseStripDocs {
- deprecated "${FUNCNAME[0]}" <<- EOF
- Documentation lives at different places and a method
- to do this in a common way should not be a responsibility
- of kiwi
- EOF
-}
function baseStripInfos {
deprecated "${FUNCNAME[0]}" <<- EOF
@@ -917,18 +1231,6 @@ function baseStripInfos {
EOF
}
-function Rpm {
- deprecated "${FUNCNAME[0]}" <<- EOF
- Please call rpm as it fits in the caller scope
- EOF
-}
-
-function rhelStripInitrd {
- deprecated "${FUNCNAME[0]}" <<- EOF
- Useful only in the context of a kiwi created initrd
- This concept was never exposed to RHEL/Fedora
- EOF
-}
function debianStripInitrd {
deprecated "${FUNCNAME[0]}" <<- EOF
@@ -937,12 +1239,6 @@ function debianStripInitrd {
EOF
}
-function rhelStripKernel {
- deprecated "${FUNCNAME[0]}" <<- EOF
- Useful only in the context of a kiwi created initrd
- This concept was never exposed to RHEL/Fedora
- EOF
-}
function debianStripKernel {
deprecated "${FUNCNAME[0]}" <<- EOF
diff --git a/kiwi/path.py b/kiwi/path.py
index b763211..b2ce909 100644
--- a/kiwi/path.py
+++ b/kiwi/path.py
@@ -150,7 +150,7 @@ class Path:
)
path_elements = path.split(os.sep)
protected_elements = [
- 'boot', 'dev', 'proc', 'run', 'sys', 'tmp', 'home', 'mnt'
+ 'boot', 'dev', 'proc', 'run', 'sys', 'tmp', 'home', 'mnt', 'opt', 'var', 'bin', 'sbin', 'etc', 'lib', 'root', 'tmp'
]
for path_index in reversed(range(0, len(path_elements))):
sub_path = os.sep.join(path_elements[0:path_index])
diff --git a/kiwi/runtime_config.py b/kiwi/runtime_config.py
index 11863c3..5fb93dc 100644
--- a/kiwi/runtime_config.py
+++ b/kiwi/runtime_config.py
@@ -345,6 +345,56 @@ class RuntimeConfig:
)
return disabled_checks or ''
+ def get_custom_hw_systemflag(self):
+ """
+ Returns custom_hw SYSTEMFLAG
+
+ """
+ hw_systemflag = self._get_attribute(
+ element='custom_hw', attribute='SYSTEMFLAG'
+ )
+ return hw_systemflag or None
+
+ def get_custom_hw_product_type(self):
+ """
+ Returns custom_hw PRODUCT_TYPE
+
+ """
+ hw_product_type = self._get_attribute(
+ element='custom_hw', attribute='PRODUCT_TYPE'
+ )
+ return hw_product_type or None
+
+ def get_custom_hw_release_type(self):
+ """
+ Returns custom_hw RELEASE_TYPE
+
+ """
+ hw_release_type = self._get_attribute(
+ element='custom_hw', attribute='RELEASE_TYPE'
+ )
+ return hw_release_type or None
+
+ def get_custom_hw_relese_bootloader_type(self):
+ """
+ Returns custom_hw RELEASE_BOOTLOADER_TYPE
+
+ """
+ hw_relese_bootloader_type = self._get_attribute(
+ element='custom_hw', attribute='RELEASE_BOOTLOADER_TYPE'
+ )
+ return hw_relese_bootloader_type or None
+
+ def get_custom_hw_release_iso_cmdline(self):
+ """
+ Returns custom_hw RELEASE_ISO_CMDLINE
+
+ """
+ hw_relese_iso_cmdline = self._get_attribute(
+ element='custom_hw', attribute='RELEASE_ISO_CMDLINE'
+ )
+ return hw_relese_iso_cmdline or None
+
def _get_attribute(self, element, attribute):
if RUNTIME_CONFIG:
try:
diff --git a/kiwi/tasks/base.py b/kiwi/tasks/base.py
index 68b7bd5..d714770 100644
--- a/kiwi/tasks/base.py
+++ b/kiwi/tasks/base.py
@@ -75,7 +75,6 @@ class CliTask:
'check_efi_mode_for_disk_overlay_correctly_setup': [],
'check_initrd_selection_required': [],
'check_boot_description_exists': [],
- 'check_consistent_kernel_in_boot_and_system_image': [],
'check_container_tool_chain_installed': [],
'check_volume_setup_defines_reserved_labels': [],
'check_volume_setup_defines_multiple_fullsize_volumes': [],
--
2.33.0