1 Star 0 Fork 30

桐小哥/kiwi

forked from src-openEuler/kiwi 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
openEuler-custom-make.patch 29.12 KB
一键复制 编辑 原始数据 按行查看 历史
桐小哥 提交于 2022-04-16 15:19 . update version to 9.21.7
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
diff --git a/kiwi/archive/cpio.py b/kiwi/archive/cpio.py
index 27d596c..f147aa1 100644
--- a/kiwi/archive/cpio.py
+++ b/kiwi/archive/cpio.py
@@ -16,8 +16,13 @@
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
# project
+from kiwi.runtime_config import RuntimeConfig
from kiwi.command import Command
+import os
+import logging
+
+log = logging.getLogger('kiwi')
class ArchiveCpio:
"""
@@ -27,6 +32,7 @@ class ArchiveCpio:
"""
def __init__(self, filename):
self.filename = filename
+ self.runtime_config = RuntimeConfig()
def create(self, source_dir, exclude=None):
"""
@@ -35,6 +41,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 08c5644..1e8a3b4 100644
--- a/kiwi/boot/image/builtin_kiwi.py
+++ b/kiwi/boot/image/builtin_kiwi.py
@@ -29,6 +29,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')
@@ -79,6 +80,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)
@@ -96,16 +98,21 @@ 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=None, basename=None, install_initrd=False):
"""
@@ -144,14 +151,15 @@ class BootImageKiwi(BootImageBase):
options=['-a']
)
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])
@@ -159,19 +167,34 @@ 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 ea33c6a..542a345 100644
--- a/kiwi/builder/kis.py
+++ b/kiwi/builder/kis.py
@@ -132,25 +132,27 @@ class KisBuilder:
self.system_setup.export_modprobe_setup(
self.boot_image_task.boot_root_directory
)
-
- # extract kernel from boot(initrd) root 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(initrd) root 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:
@@ -187,6 +189,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 a81be6a..cd28ec8 100644
--- a/kiwi/config/functions.sh
+++ b/kiwi/config/functions.sh
@@ -176,6 +176,34 @@ 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
+}
+
#======================================
# suseService
#--------------------------------------
@@ -361,10 +389,58 @@ function baseStripDocs {
grep -iv "copying\|license\|copyright")
rm -f "${docfiles}"
done
+ rm -rf `rpm -qad`
rm -rf /usr/share/info
rm -rf /usr/share/man
}
+#======================================
+# 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
+
+}
+
+#======================================
+# 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
+}
+
#======================================
# baseStripLocales
#--------------------------------------
@@ -374,13 +450,25 @@ 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}
+}
+
#======================================
# baseStripTranslations
#--------------------------------------
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}
}
#======================================
@@ -422,7 +510,7 @@ function baseStripAndKeep {
fi
done
if [ "${found}" = 0 ]; then
- Rm -rf "${file}"
+ rm_isnot_usrfile $file
fi
done
}
@@ -507,6 +595,45 @@ function Debug {
echo "+++++> (caller:${FUNCNAME[1]}:${FUNCNAME[2]} ) $*"
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
+}
+
#======================================
# stripUnusedLibs
#--------------------------------------
@@ -518,6 +645,8 @@ function baseStripUnusedLibs {
local needlibs
local found
local dir
+ local lnk
+ local new
local lib
local lddref
# /.../
@@ -525,33 +654,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
@@ -559,46 +688,42 @@ 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
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
}
@@ -622,60 +747,144 @@ function baseUpdateSysConfig {
fi
}
+#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
+
+}
+
#======================================
-# baseStripInitrd
+# baseStripInvalidLink
#--------------------------------------
-function baseStripInitrd {
- declare kiwi_initrd_system=${kiwi_initrd_system}
- declare kiwi_strip_tools=${kiwi_strip_tools}
- declare kiwi_strip_libs=${kiwi_strip_libs}
+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
#==========================================
# remove unneeded tools
#------------------------------------------
- local tools="${kiwi_strip_tools}"
- tools="${tools} $*"
- for path in /sbin /usr/sbin /usr/bin /bin;do
- baseStripTools "${path}" "${tools}"
- done
+ 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 unused libs
#------------------------------------------
- baseStripUnusedLibs "${kiwi_strip_libs}"
+ baseStripUnusedLibs $kiwi_strip_libs
#==========================================
- # remove package manager meta data
+ # remove images.sh
#------------------------------------------
- for p in dpkg rpm yum;do
- rm -rf "/var/lib/$p"
- done
-}
+ 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
-#======================================
-# suseStripInitrd
-#--------------------------------------
-function suseStripInitrd {
- baseStripInitrd "$@"
+ 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
+
+ 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
+ #==========================================
+ # remove invalid link file
+ #------------------------------------------
+ baseStripInvalidLink
}
#======================================
# rhelStripInitrd
#--------------------------------------
function rhelStripInitrd {
- baseStripInitrd "$@"
+ suseStripInitrd
}
-#======================================
-# debianStripInitrd
-#--------------------------------------
-function debianStripInitrd {
- baseStripInitrd "$@"
-}
#======================================
# rhelSplashToGrub
@@ -825,7 +1034,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
@@ -852,6 +1061,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
}
#======================================
@@ -976,10 +1193,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
@@ -1001,14 +1214,7 @@ function suseStripKernel {
# rhelStripKernel
#--------------------------------------
function rhelStripKernel {
- baseStripKernel
-}
-
-#======================================
-# debianStripKernel
-#--------------------------------------
-function debianStripKernel {
- baseStripKernel
+ suseStripKernel
}
#======================================
@@ -1160,4 +1366,18 @@ function baseQuoteFile {
mv "${conf}" "${file}"
}
-# vim: set noexpandtab:
+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
+}
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 e968f3c..ba13267 100644
--- a/kiwi/runtime_config.py
+++ b/kiwi/runtime_config.py
@@ -259,6 +259,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 self.config_data:
try:
diff --git a/kiwi/tasks/base.py b/kiwi/tasks/base.py
index 90f7c45..426e79b 100644
--- a/kiwi/tasks/base.py
+++ b/kiwi/tasks/base.py
@@ -74,7 +74,6 @@ class CliTask:
'check_minimal_required_preferences': [],
'check_efi_mode_for_disk_overlay_correctly_setup': [],
'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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tong_1001/kiwi.git
git@gitee.com:tong_1001/kiwi.git
tong_1001
kiwi
kiwi
master

搜索帮助