1#!/bin/sh 2# $FreeBSD$ 3# 4# Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout 5# 6 7if [ ! $# -eq 1 ]; then 8 echo "usage: $0 acpica_archive" 9 exit 10fi 11 12src=$1 13wrk=`realpath ./_acpi_ca_unpack` 14dst=`realpath ./acpi_ca_destination` 15 16# files that should keep their full directory path 17fulldirs="common compiler components include os_specific" 18 19# files to remove 20stripdirs="generate libraries tests tools" 21stripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h \ 22 acos2.h accygwin.h acefi.h acwin.h acwin64.h osunixdir.c \ 23 oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c" 24 25# include files to canonify 26src_headers="acapps.h accommon.h acconfig.h acdebug.h acdisasm.h \ 27 acdispat.h acevents.h acexcep.h acglobal.h achware.h acinterp.h \ 28 aclocal.h acmacros.h acnames.h acnamesp.h acobject.h acopcode.h \ 29 acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h acpredef.h \ 30 acresrc.h acrestyp.h acstruct.h actables.h actbl.h actbl1.h \ 31 actbl2.h actbl3.h actypes.h acutils.h amlcode.h amlresrc.h \ 32 platform/acenv.h platform/acfreebsd.h platform/acgcc.h" 33comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h \ 34 aslsupport.l asltypes.h dtcompiler.h dttemplate.h preprocess.h" 35platform_headers="acfreebsd.h acgcc.h" 36 37# pre-clean 38echo pre-clean 39rm -rf ${wrk} ${dst} 40mkdir -p ${wrk} 41mkdir -p ${dst} 42 43# unpack 44echo unpack 45tar -x -z -f ${src} -C ${wrk} 46 47# strip files 48echo strip 49for i in ${stripdirs}; do 50 find ${wrk} -name ${i} -type d -print | xargs rm -r 51done 52for i in ${stripfiles}; do 53 find ${wrk} -name ${i} -type f -delete 54done 55 56# copy files 57echo copying full dirs 58for i in ${fulldirs}; do 59 find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst} 60done 61echo copying remaining files 62find ${wrk} -type f -print | xargs -J % mv % ${dst} 63 64# canonify include paths 65for H in ${src_headers}; do 66 find ${dst} -name "*.[chly]" -type f -print | \ 67 xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g" 68done 69for H in ${comp_headers}; do 70 find ${dst}/common ${dst}/compiler -name "*.[chly]" -type f | \ 71 xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g" 72done 73for H in ${platform_headers}; do 74 find ${dst}/include/platform -name "*.h" -type f -print | \ 75 xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g" 76done 77 78# post-clean 79echo post-clean 80rm -rf ${wrk} 81 82# assist the developer in generating a diff 83echo "Directories you may want to 'svn diff':" 84echo " sys/contrib/dev/acpica sys/dev/acpica \\" 85echo " sys/amd64/acpica sys/i386/acpica sys/ia64/acpica sys/x86/acpica \\" 86echo " sys/amd64/include sys/i386/include sys/ia64/include \\" 87echo " sys/boot sys/conf sys/modules/acpi usr.sbin/acpi" 88