acpica_prep.sh revision 284583
190380Smsmith#!/bin/sh 290380Smsmith# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 284583 2015-06-18 23:14:45Z jkim $ 390380Smsmith# 490380Smsmith# Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout 590380Smsmith# 690380Smsmith 798146Siwasakiif [ ! $# -eq 1 ]; then 898146Siwasaki echo "usage: $0 acpica_archive" 998146Siwasaki exit 1098146Siwasakifi 1198146Siwasaki 1290380Smsmithsrc=$1 13235945Sjkimwrk="$(realpath .)/_acpi_ca_unpack" 14235945Sjkimdst="$(realpath .)/acpi_ca_destination" 1590380Smsmith 16123333Snjl# files that should keep their full directory path 17231844Sjkimfulldirs="common compiler components include os_specific" 18193529Sjkim 1990380Smsmith# files to remove 20231844Sjkimstripdirs="generate libraries tests tools" 21281396Sjkimstripfiles="Makefile README accygwin.h acdragonfly.h acdragonflyex.h \ 22284583Sjkim acefi.h acefiex.h achaiku.h acintel.h aclinux.h aclinuxex.h \ 23284583Sjkim acmacosx.h acmsvc.h acnetbsd.h acos2.h acwin.h acwin64.h \ 24284583Sjkim new_table.txt osbsdtbl.c osefitbl.c osefixf.c osfreebsdtbl.c \ 25284583Sjkim oslinuxtbl.c osunixdir.c osunixmap.c oswindir.c oswintbl.c \ 26284583Sjkim oswinxf.c readme.txt utclib.c" 27193529Sjkim 28151946Sjkim# include files to canonify 29284583Sjkimsrc_headers="acapps.h acbuffer.h acclib.h accommon.h acconfig.h \ 30284583Sjkim acdebug.h acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h \ 31284583Sjkim achware.h acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h \ 32284583Sjkim acobject.h acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h \ 33284583Sjkim acpixf.h acpredef.h acresrc.h acrestyp.h acstruct.h actables.h \ 34284583Sjkim actbl.h actbl1.h actbl2.h actbl3.h actypes.h acutils.h acuuid.h \ 35284583Sjkim amlcode.h amlresrc.h platform/acenv.h platform/acenvex.h \ 36272444Sjkim platform/acfreebsd.h platform/acgcc.h" 37213806Sjkimcomp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h \ 38234623Sjkim aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h" 39193529Sjkimplatform_headers="acfreebsd.h acgcc.h" 4090380Smsmith 4190380Smsmith# pre-clean 4290380Smsmithecho pre-clean 43193529Sjkimrm -rf ${wrk} ${dst} 4490380Smsmithmkdir -p ${wrk} 4590380Smsmithmkdir -p ${dst} 4690380Smsmith 4790380Smsmith# unpack 4890380Smsmithecho unpack 4990380Smsmithtar -x -z -f ${src} -C ${wrk} 5090380Smsmith 5190380Smsmith# strip files 5290380Smsmithecho strip 5390380Smsmithfor i in ${stripdirs}; do 54209746Sjkim find ${wrk} -name ${i} -type d -print | xargs rm -r 5590380Smsmithdone 5690380Smsmithfor i in ${stripfiles}; do 57151946Sjkim find ${wrk} -name ${i} -type f -delete 5890380Smsmithdone 5990380Smsmith 60193529Sjkim# copy files 61123333Snjlecho copying full dirs 62123333Snjlfor i in ${fulldirs}; do 63209746Sjkim find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst} 64123333Snjldone 65193529Sjkimecho copying remaining files 66209746Sjkimfind ${wrk} -type f -print | xargs -J % mv % ${dst} 6790380Smsmith 68151604Sobrien# canonify include paths 69151946Sjkimfor H in ${src_headers}; do 70220663Sjkim find ${dst} -name "*.[chly]" -type f -print | \ 71193529Sjkim xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g" 72151946Sjkimdone 73151946Sjkimfor H in ${comp_headers}; do 74235945Sjkim find ${dst}/common ${dst}/compiler ${dst}/components \ 75235945Sjkim -name "*.[chly]" -type f | \ 76151946Sjkim xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g" 77151946Sjkimdone 78193529Sjkimfor H in ${platform_headers}; do 79209746Sjkim find ${dst}/include/platform -name "*.h" -type f -print | \ 80193529Sjkim xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g" 81193529Sjkimdone 82151604Sobrien 8390380Smsmith# post-clean 8490380Smsmithecho post-clean 8598146Siwasakirm -rf ${wrk} 86114244Snjl 87114244Snjl# assist the developer in generating a diff 88228110Sjkimecho "Directories you may want to 'svn diff':" 89228110Sjkimecho " sys/contrib/dev/acpica sys/dev/acpica \\" 90268351Smarcelecho " sys/amd64/acpica sys/i386/acpica sys/x86/acpica \\" 91268351Smarcelecho " sys/amd64/include sys/i386/include include \\" 92228110Sjkimecho " sys/boot sys/conf sys/modules/acpi usr.sbin/acpi" 93