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