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 debugger disassembler dispatcher events \ 18 executer hardware include namespace os_specific parser \ 19 resources tables utilities" 20 21# files to remove 22stripdirs="generate tests tools" 23stripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h \ 24 acos2.h accygwin.h acefi.h acwin.h acwin64.h osunixdir.c \ 25 oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c" 26 27# include files to canonify 28src_headers="acapps.h accommon.h acconfig.h acdebug.h acdisasm.h \ 29 acdispat.h acevents.h acexcep.h acglobal.h achware.h acinterp.h \ 30 aclocal.h acmacros.h acnames.h acnamesp.h acobject.h acopcode.h \ 31 acoutput.h acparser.h acpi.h acpiosxf.h acpixf.h acpredef.h \ 32 acresrc.h acrestyp.h acstruct.h actables.h actbl.h actbl1.h \ 33 actbl2.h actbl3.h actypes.h acutils.h amlcode.h amlresrc.h \ 34 platform/acenv.h platform/acfreebsd.h platform/acgcc.h" 35comp_headers="aslcompiler.h asldefine.h aslglobal.h aslmessages.h \ 36 asltypes.h dtcompiler.h dttemplate.h" 37platform_headers="acfreebsd.h acgcc.h" 38 39# pre-clean 40echo pre-clean 41rm -rf ${wrk} ${dst} 42mkdir -p ${wrk} 43mkdir -p ${dst} 44 45# unpack 46echo unpack 47tar -x -z -f ${src} -C ${wrk} 48 49# strip files 50echo strip 51for i in ${stripdirs}; do 52 find ${wrk} -name ${i} -type d -print | xargs rm -r 53done 54for i in ${stripfiles}; do 55 find ${wrk} -name ${i} -type f -delete 56done 57 58# copy files 59echo copying full dirs 60for i in ${fulldirs}; do 61 find ${wrk} -name ${i} -type d -print | xargs -J % mv % ${dst} 62done 63echo copying remaining files 64find ${wrk} -type f -print | xargs -J % mv % ${dst} 65 66# canonify include paths 67for H in ${src_headers}; do 68 find ${dst} -name "*.[chly]" -type f -print | \ 69 xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/$H\>|g" 70done 71for H in ${comp_headers}; do 72 find ${dst}/common ${dst}/compiler -name "*.[chly]" -type f | \ 73 xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/compiler/$H\>|g" 74done 75for H in ${platform_headers}; do 76 find ${dst}/include/platform -name "*.h" -type f -print | \ 77 xargs sed -i "" -e "s|[\"<]$H[\">]|\<contrib/dev/acpica/include/platform/$H\>|g" 78done 79 80# post-clean 81echo post-clean 82rm -rf ${wrk} 83 84# assist the developer in generating a diff 85echo "Directories you may want to 'svn diff':" 86echo " sys/contrib/dev/acpica sys/dev/acpica \\" 87echo " sys/amd64/acpica sys/i386/acpica sys/ia64/acpica sys/x86/acpica \\" 88echo " sys/amd64/include sys/i386/include sys/ia64/include \\" 89echo " sys/boot sys/conf sys/modules/acpi usr.sbin/acpi" 90