Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # only handles program usage and parameter checking
- ##source `dirname $0`/spec2bb.inc
- ### @b this could be done by parsing the kde yaml files in the meego OBS, but not all rpm builders seem to use yaml files
- function packages()
- {
- echo -e 'PACKAGES=+"\\' >> ${OUTFILE}
- grep "%package" ${SPECFILE} |
- sort |
- sed 's/.*\ //' | #1. remove everything until after the first whitespace (crops %packages and -n or other options)
- sed ':a;N;$!ba;s/\n/ \\\n/g' | #2. replace newlines with "\\\n" see http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n
- sed 's/^/${PN}-/' | #3. add '${PN}-' before the package name
- sed '$s/$/ \\\n"/' >> ${OUTFILE} #4.replaces the last newline with '"' see http://unix.stackexchange.com/questions/20573/sed-insert-something-to-the-last-line
- }
- function packagefiles()
- {
- cat ${SPECFILE} | # Caution: do not sort $SPECFILE!
- sed -n -e '/%files/,$p' | #1. print everything after the first '%files'
- sed 's/%\(files\|defattr\|doc\|config\|dir\ \|verify\).*//' | #2. replace '%files', '%defattr', '%doc', '%config', '%dir' and '%verify' + the rest of the line with ''
- sed '/^$/d' | #3. remove multiple newlines after removing the precvious entries
- sed 's/# >> files\ */FILES_$\{PN\}-/' | #4. replace '# >> files' with 'FILES_${PN}-' (truncates spaces until next character)
- sed ':a;N;$!ba;s/\n%/ \\\n/g' | #5. add ' \' after line ends which are followed by '%' next line
- sed ':a;N;$!ba;s/\n#/ \\\n#/g' | #6. add ' \' after line ends which are followed by '#' on the next line
- sed 's/# << files.*/"/' | #7. replace '# << files' and the rest of the line with '"'
- sed 's/\(FILES_.*\S\)\s/\1=" /' | #8. add '=" ' after FILES_.*
- sed 's/^#.*//' | #9. replace leftover comment lines (starting with '#')
- sed '/^$/d' | #10. remove multiple newlines created at comment removal
- sed 's/\(FILES_.*\S\)\s/\n\1/' | #11. add newlines before 'FILES_.*'
- sed 's/FILES_${PN}-="\\/FILES_${PN}+="\\/' >> ${OUTFILE} #12. replace 'FILES_${PN}-="\' with FILES_${PN}+="\'
- }
- function kdepaths()
- {
- # post process the outfile to replace kde paths with bitbake paths
- touch ${OUTFILE}-tmp$$
- cat ${OUTFILE} |
- sed 's#{_datadir}#${datadir}#' | # not kde specific
- sed 's#{_kde_applicationsdir}#${datadir}/applications/kde4#' |
- sed 's#{_kde_appsdir}#${datadir}/apps#' |
- sed 's#{_kde_bindir}#${bindir}#' |
- sed 's#{_kde_configdir}#${datadir}/config#' |
- sed 's#{_kde_configkcfgdir}#${datadir}/config.kcfg#' |
- sed 's#{_kde_docdir}#${datadir}/doc/kde#' |
- sed 's#{_kde_htmldir}#${datadir}/doc/kde/HTML#' |
- sed 's#{_kde_iconsdir}#${datadir}/icons#' |
- sed 's#{_kde_includedir}#${includedir}#' |
- sed 's#{_kde_libdir}#${libdir}#' |
- sed 's#{_kde_libexecdir}#${libdir}/kde4/libexec#' |
- sed 's#{_kde_libkdeinitdir}#${libdir}/kde4/libkdeinit#' |
- sed 's/{_kde_mandir}/# FIXME: /' | # man files go to the ${PN}-doc package, not to individual subpackages
- sed 's#{_kde_modulesdir}#${libdir}/kde4#' |
- sed 's#{_kde_prefix}#${prefix}#' |
- sed 's#{_kde_sbindir}#${sbindir}#' |
- sed 's#{_kde_servicesdir}#${datadir}/services#' |
- sed 's#{_kde_servicetypesdir}#${datadir}/servicetypes#' |
- sed 's#{_kde_sharedir}#${datadir}/kde4#' |
- sed 's#{_kde_sysconfdir}#${sysconfdir}#' |
- sed 's#{_kde_wallpapersdir}#${datadir}/wallpapers#' > ${OUTFILE}-tmp$$
- rm ${OUTFILE}
- mv ${OUTFILE}-tmp$$ ${OUTFILE}
- }
- if [ -s ${OUTFILE} ]
- then
- echo "outfile already exists"
- exit 1
- fi
- touch ${OUTFILE}
- packages
- if [ -z ${PKGFILES} ]
- then
- packagefiles
- fi
- kdepaths
- if [ ${OUTFILE}="$$tmpfile.~" ]
- then
- cat "$$tmpfile.~"
- rm "$$tmpfile.~"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement