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