
https://bugzilla.novell.com/show_bug.cgi?id=349181 Summary: propose new functions for images (for image.sh script) Product: openSUSE.org Version: unspecified Platform: Other OS/Version: Other Status: NEW Severity: Enhancement Priority: P5 - None Component: System Imaging AssignedTo: ms@novell.com ReportedBy: postadal@novell.com QAContact: adrian@novell.com Found By: --- Hi Marcus, I'd like to propose some new functions for kiwi-head (or similar) that we used in SLEPOS10 in images.sh script for stripping, installing... 1. we used some striping functions in SLEPOS to reduce our images, could you add similar functions to kiwi-head? (I inspired by your implementation in KIWIConfig.sh:baseStripLocales) 2. function for easier installing busybox 3. I'd like to add some debug support to logging removed files and rpms see bellow: ---------- function SleposDebug { if test "$DEBUG" = 1; then echo "$@" >> "$DEBUG_LOGFILE" fi } # call rm -rf $@ and log debug records function SleposRmrf { SleposDebug "rm -rf $@" rm -rf $@ } # helper function for Strip* functions # stdin lines of files to check for removing # params - files which should be keep function strip_check_remove { local keepFiles="$@" while read file; do local baseFile=`/usr/bin/basename $file` local found="no" for keep in $keepFiles;do if echo $baseFile | grep -q $keep; then found="yes" break fi done if test $found = "no";then SleposRmrf $file fi done } # remove all documentation, except one given as parametr # params - name of package of which doc to keep function SleposStripDocs { local keepDocs="$@" local directories=" /opt/gnome/share/doc/packages /usr/share/doc/packages /opt/kde3/share/doc/packages " for dir in $directories; do find $dir -mindepth 1 -maxdepth 1 -type d 2>/dev/null | strip_check_remove $keepDocs done } # remove all locales files, except one given as parametr # params - name of keep locales function SleposStripLocales { local keepLocales="$@" local directories=" /opt/gnome/share/locale /usr/share/locale /opt/kde3/share/locale /usr/lib/locale /opt/gnome/share/man /usr/share/man /usr/local/man " for dir in $directories; do find $dir -mindepth 1 -maxdepth 1 -type d ! -name "man*" 2>/dev/null | strip_check_remove $keepLocales done } function SleposDebug { if test "$DEBUG" = 1; then echo "$@" >> "$DEBUG_LOGFILE" fi } # call rm -rf $@ and log debug records function SleposRmrf { SleposDebug "rm -rf $@" rm -rf $@ } # helper function for Strip* functions # stdin lines of files to check for removing # params - files which should be keep function strip_check_remove { local keepFiles="$@" while read file; do local baseFile=`/usr/bin/basename $file` local found="no" for keep in $keepFiles;do if echo $baseFile | grep -q $keep; then found="yes" break fi done if test $found = "no";then SleposRmrf $file fi done } # remove all documentation, except one given as parametr # params - name of package of which doc to keep function SleposStripDocs { local keepDocs="$@" local directories=" /opt/gnome/share/doc/packages /usr/share/doc/packages /opt/kde3/share/doc/packages " for dir in $directories; do find $dir -mindepth 1 -maxdepth 1 -type d 2>/dev/null | strip_check_remove $keepDocs done } # remove all locales files, except one given as parametr # params - name of keep locales function SleposStripLocales { local keepLocales="$@" local directories=" /opt/gnome/share/locale /usr/share/locale /opt/kde3/share/locale /usr/lib/locale /opt/gnome/share/man /usr/share/man /usr/local/man " for dir in $directories; do find $dir -mindepth 1 -maxdepth 1 -type d ! -name "man*" 2>/dev/null | strip_check_remove $keepLocales done } # remove all manual pages, except one given as parametr # params - name of keep man pages function SleposStripMans { local keepMans="$@" local directories=" /opt/gnome/share/man /usr/local/man /usr/share/man /opt/kde3/share/man/packages " for dir in $directories; do find $dir/man* -mindepth 1 -maxdepth 1 -type f 2>/dev/null | strip_check_remove $keepMans done } # remove all info files, except one given as parametr # params - name of keep info files function SleposStripInfos { local keepInfos="$@" local directories=" /usr/share/info " for dir in $directories; do find $dir -mindepth 1 -maxdepth 1 -type f 2>/dev/null | strip_check_remove $keepInfos done } # call rpm -e --nodeps for every param and log it function SleposRpme { for i in "$@";do SleposDebug "rpm -e --nodeps $i" rpm -e --nodeps $i done } # remove uneeded packages defined in packeg for deletion # see session <packages type="delete"> in config.xml function SleposStripRpms { SleposRpme `baseGetPackagesForDeletion` } # remove uneeded packages defined in packeg for deletion # see session <packages type="delete"> in config.xml function SleposStripRpms { SleposRpme `baseGetPackagesForDeletion` } # install busybox if is installed for all links from busybox/busybox.links # params - you can choose custom apps to install # use "-f" as the first param to replaced existing program by link to busybox # example: SleposInstallBusybox -f /bin/zcat /bin/vi function SleposInstallBusybox { local applets="" local force="no" local busyboxlinks="/usr/share/busybox/busybox.links" if ! rpm -q --quiet busybox; then 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 SleposDebug "ln -sf /usr/bin/busybox $applet" ln -sf /usr/bin/busybox "$applet" fi done } ====================== then I can easy call in image image.sh scrip e.g. following # Strips doc files, keep only listed SleposStripDocs # Strip locales, keep only listed SleposStripLocales en # Strip man pages SleposStripMans # Strip info files SleposStripInfos # Remove rest of evolution SleposRmrf /opt/gnome/lib/evolution-data-server-1.2 SleposRmrf /opt/gnome/share/evolution-data-server-1.6 # created links for all supported busybox apps if it was installed SleposInstallBusybox SleposStripRpms # Remove all YaST2 modules, when yast2-core is missing if ! rpm -q --quiet yast2-core; then SleposRmrf /usr/lib*/YaST2/plugin fi # Remove libzypp cache if libzypp is not installed if ! rpm -q --quiet libzypp; then SleposRmrf /var/lib/zypp fi -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.