190380Smsmith#!/bin/sh 290380Smsmith# $FreeBSD: stable/10/sys/contrib/dev/acpica/acpica_prep.sh 306536 2016-09-30 22:40:58Z 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" 21281687Sjkimstripfiles="Makefile README accygwin.h acdragonfly.h acdragonflyex.h \ 22306536Sjkim acefi.h acefiex.h achaiku.h acintel.h aclinux.h aclinuxex.h \ 23306536Sjkim acmacosx.h acmsvc.h acmsvcex.h acnetbsd.h acos2.h acqnx.h \ 24306536Sjkim acwin.h acwin64.h acwinex.h new_table.txt osbsdtbl.c osefitbl.c \ 25306536Sjkim osefixf.c osfreebsdtbl.c oslinuxtbl.c osunixdir.c osunixmap.c \ 26306536Sjkim oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c" 27193529Sjkim 28151946Sjkim# include files to canonify 29306536Sjkimsrc_headers="acapps.h acbuffer.h acclib.h accommon.h acconfig.h \ 30306536Sjkim acdebug.h acdisasm.h acdispat.h acevents.h acexcep.h acglobal.h \ 31306536Sjkim achware.h acinterp.h aclocal.h acmacros.h acnames.h acnamesp.h \ 32306536Sjkim acobject.h acopcode.h acoutput.h acparser.h acpi.h acpiosxf.h \ 33306536Sjkim acpixf.h acpredef.h acresrc.h acrestyp.h acstruct.h actables.h \ 34306536Sjkim actbl.h actbl1.h actbl2.h actbl3.h actypes.h acutils.h acuuid.h \ 35306536Sjkim amlcode.h amlresrc.h platform/acenv.h platform/acenvex.h \ 36281075Sdim 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 \\" 90228110Sjkimecho " sys/amd64/acpica sys/i386/acpica sys/ia64/acpica sys/x86/acpica \\" 91228110Sjkimecho " sys/amd64/include sys/i386/include sys/ia64/include \\" 92228110Sjkimecho " sys/boot sys/conf sys/modules/acpi usr.sbin/acpi" 93