Name:           acpica-tools
Version:        20140424
Release:        1%{?_dist_release}
Summary:        ACPICA tools for the development and debug of ACPI tables

Group:          Development/Languages
License:        GPLv2
URL:            https://www.acpica.org/

Source0:        https://acpica.org/sites/acpica/files/acpica-unix2-%{version}.tar.gz
Source1:        https://acpica.org/sites/acpica/files/acpitests-unix-%{version}.tar.gz
Source2:        README.Fedora
Source3:        iasl.1
Source4:        acpibin.1
Source5:        acpidump.1
Source6:        acpiexec.1
Source7:        acpihelp.1
Source8:        acpinames.1
Source9:        acpisrc.1
Source10:       acpixtract.1
Source11:       badcode.asl.result
Source12:       grammar.asl.result
Source13:       run-misc-tests.sh
Source14:       COPYING

Patch0:         debian-big_endian.patch
Patch1:         debian-unaligned.patch
Patch2:         name-miscompare.patch
Patch3:         aapits-linux.patch
Patch4:         asllookup-miscompare.patch
Patch5:         aapits-makefile.patch
Patch6:		re-enable-big-endian.patch

BuildRequires:  bison patchutils flex

# The previous iasl package contained only a very small subset of these tools
# and it produced only the iasl package listed below; further, the pmtools
# package -- which provides acpidump -- also provides a /usr/sbin/acpixtract
# that we don't really want to collide with
Provides:       acpixtract >= 20120913-7
Provides:       iasl = %{version}-%{release}
Obsoletes:      iasl < 20120913-8

# The pmtools package provides an obsolete and deprecated version of the
# acpidump command from lesswatts.org which has now been taken off-line.
# ACPICA, however, is providing a new version and we again do not want to
# conflict with the command name.
Provides:       acpidump >= 20100513-5
Provides:       pmtools = %{version}-%{release}
Obsoletes:      pmtools < 20100513-6

%description
The ACPI Component Architecture (ACPICA) project provides an OS-independent
reference implementation of the Advanced Configuration and Power Interface
Specification (ACPI).  ACPICA code contains those portions of ACPI meant to
be directly integrated into the host OS as a kernel-resident subsystem, and
a small set of tools to assist in developing and debugging ACPI tables.

This package contains only the user-space tools needed for ACPI table
development, not the kernel implementation of ACPI.  The following commands
are installed:
   -- iasl: compiles ASL (ACPI Source Language) into AML (ACPI Machine
      Language), suitable for inclusion as a DSDT in system firmware.
      It also can disassemble AML, for debugging purposes.
   -- acpibin: performs basic operations on binary AML files (e.g.,
      comparison, data extraction)
   -- acpidump: write out the current contents of ACPI tables
   -- acpiexec: simulate AML execution in order to debug method definitions
   -- acpihelp: display help messages describing ASL keywords and op-codes
   -- acpinames: display complete ACPI name space from input AML
   -- acpisrc: manipulate the ACPICA source tree and format source files
      for specific environments
   -- acpixtract: extract binary ACPI tables from acpidump output (see
      also the pmtools package)

This version of the tools is being released under GPLv2 license.

%prep
%setup -q -n acpica-unix2-%{version}
%setup -q -T -D -a 1 -n acpica-unix2-%{version}
gzip -dc %{SOURCE1} | tar -x --strip-components=1 -f -

%patch0 -p1 -b .debian-big_endian
%patch1 -p1 -b .debian-unaligned
%patch2 -p1 -b .name-miscompare
%patch3 -p1 -b .aapits-linux
%patch4 -p1 -b .asllookup-miscompare
%patch5 -p1 -b .aapits-makefile
%patch6 -p1 -b .re-enable-big-endian

cp -p %{SOURCE2} README.Fedora
cp -p %{SOURCE3} iasl.1
cp -p %{SOURCE4} acpibin.1
cp -p %{SOURCE5} acpidump.1
cp -p %{SOURCE6} acpiexec.1
cp -p %{SOURCE7} acpihelp.1
cp -p %{SOURCE8} acpinames.1
cp -p %{SOURCE9} acpisrc.1
cp -p %{SOURCE10} acpixtract.1
cp -p %{SOURCE11} badcode.asl.result
cp -p %{SOURCE12} grammar.asl.result
cp -p %{SOURCE13} tests/run-misc-tests.sh
chmod a+x tests/run-misc-tests.sh
cp -p %{SOURCE14} COPYING

# spurious executable permissions on text files in upstream
chmod a-x changes.txt
chmod a-x source/compiler/new_table.txt


%build
make OPT_CFLAGS="%{optflags}"


%install
# Install the binaries
mkdir -p %{buildroot}%{_bindir}
install -pD generate/unix/bin*/* %{buildroot}%{_bindir}/
mv %{buildroot}%{_bindir}/acpidump %{buildroot}%{_bindir}/acpidump-acpica
mv %{buildroot}%{_bindir}/acpixtract %{buildroot}%{_bindir}/acpixtract-acpica

# Install the man pages
mkdir -p %{buildroot}%{_mandir}/man1
install -pDm 0644 -p -D *.1 %{buildroot}%{_mandir}/man1/
mv %{buildroot}%{_mandir}/man1/acpixtract.1 \
   %{buildroot}%{_mandir}/man1/acpixtract-acpica.1
mv %{buildroot}%{_mandir}/man1/acpidump.1 \
   %{buildroot}%{_mandir}/man1/acpidump-acpica.1

%check
cd tests

# ASL tests
./aslts.sh                         # relies on non-zero exit
[ $? -eq 0 ] || exit 1

# API tests
cd aapits
make
cd asl
ASL=%{buildroot}%{_bindir}/iasl make
cd ../bin
./aapitsrun
[ $? -eq 0 ] || exit 1
cd ../..

# misc tests
./run-misc-tests.sh %{buildroot}%{_bindir} %{version}

# Template tests
cd templates
make
if [ -f diff.log ]
then
    if [ -s diff.log ]
    then
        exit 1                  # implies errors occurred
    fi
fi
cd ..


%post
alternatives --install %{_bindir}/acpixtract acpixtract \
                       %{_bindir}/acpixtract-acpica 120 \
               --slave %{_mandir}/man1/acpixtract.1.gz acpixtract.1.gz \
                       %{_mandir}/man1/acpixtract-acpica.1.gz

alternatives --install %{_bindir}/acpidump acpidump \
                       %{_bindir}/acpidump-acpica 120 \
               --slave %{_mandir}/man1/acpidump.1.gz acpidump.1.gz \
                       %{_mandir}/man1/acpidump-acpica.1.gz


%postun
if [ ! -e %{_bindir}/acpixtract-acpica ]
then
    alternatives --remove acpixtract %{_bindir}/acpixtract-acpica
fi
if [ ! -e %{_bindir}/acpidump-acpica ]
then
    alternatives --remove acpidump %{_bindir}/acpidump-acpica
fi


%files
%doc changes.txt source/compiler/new_table.txt
%doc README.Fedora COPYING
%{_bindir}/*
%{_mandir}/*/*


%changelog
* Sun Jul 13 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 20140424-1
- initial build for Vine Linux

* Fri Jun 6 2014 Dan Horák <dan[at]danny.cz> - 20140424-3
- refresh the big endian patch so it applies correctly, fixes build on big endians

* Thu May 22 2014 Al Stone <ahs3@redhat.com> - 20140424-2
- Add ppc64le as a 64-bit arch in run-misc-tests.sh.  Closes BZ#1098614.
- Re-enable big-endian support in iasl.

* Wed May 7 2014 Al Stone <ahs3@redhat.com> - 20140424-1
- Update to latest upstream.  Closes BZ#1091189.

* Fri Apr 4 2014 Al Stone <ahs3@redhat.com> - 20140325-1
- Update to latest upstream.  Closes BZ#1080791.
- Incorporated patch to fix broken symlinks.  Closes BZ#1074256.
- Add patch to fix missing .o files in aapits tests.

* Wed Feb 26 2014 Al Stone <ahs3@redhat.com> - 20140214-1
- Update to latest upstream.  Closes BZ#1053396.
- Remove temporary patch so that AAPITS will build and run.
- Add patch to print asllookup.c warning properly on big endian;
  Closes BZ#1069178.

* Tue Jan 21 2014 Al Stone <ahs3@redhat.com> - 20140114-1
- Update to latest upstream.  Closes BZ#1053396.
- Remove temporary patch to add Makefile missing from upstream tarball.
- Add temporary patch so that AAPITS will build and run.

* Tue Jan 7 2014 Al Stone <ahs3@redhat.com> - 20131218-1
- Update to latest upstream.  Closes BZ#1044951.
- Add temporary patch to add Makefile missing from upstream tarball.

* Mon Nov 25 2013 Al Stone <ahs3@redhat.com> - 20131115-1
- Update to latest upstream.  Closes BZ#1031255.
- Add a little code to workaround build problems that can occur (the tests
  will fail) when a build starts before midnight, but ends after midnight
- Remove patch to include Makefile.config that was missing from tarball.

* Wed Oct 09 2013 Al Stone <ahs3@redhat.com> - 20130927-1
- Update to latest upstream.  Closes BZ#1013090.
- Add temporary patch to include Makefile.config being missing from tarball.

* Fri Sep 13 2013 Michael Schwendt <mschwendt@fedoraproject.org> - 20130823-5
- correct iasl obs_ver

* Tue Sep 10 2013 Dean Nelson <dnelson@redhat.com> - 20130823-4
- Fix run-misc-tests.sh script to properly set the number of BITS to 64
  when run on a s390x system.

* Tue Sep 10 2013 Michael Schwendt <mschwendt@fedoraproject.org> - 20130823-3
- correct pmtools obs_ver

* Tue Aug 27 2013 Al Stone <ahs3@redhat.com> - 20130823-2
- Add in a copy of the GPLv2 text in order to comply with the requirement
  to always redistribute the terms of the license.

* Mon Aug 26 2013 Al Stone <ahs3@redhat.com> - 20130823-1
- Update to latest upstream source.

* Tue Aug 20 2013 Al Stone <ahs3@redhat.com> - 20130725-2
- Fix several rpmlint items (listed below)
- Add versions to explicit provides for acpixtract, acpidump
- Not all setup steps used -q
- Setup executable test script (run-misc-tests.sh) differently
- Removed unneeded commented out line with macros in it
- Removed mixed use of spaces and tabs (all spaces now)
- Corrected source URLs (upstream moved)

* Sun Aug 18 2013 Al Stone <ahs3@redhat.com> - 20130725-1
- Update to latest upstream source.

* Wed Jul 24 2013 Al Stone <ahs3@redhat.com> - 20130626-1
- Update to latest upstream source.
- Move acpidump to acpidump-acpica so it be an alternative properly
- Add basic man page for acpidump
- Enable use of AAPITS tests during the check step

* Sun Jun 02 2013 Al Stone <ahs3@redhat.com> - 20130517-2
- Correct an oversight: we provide an acpidump in conflict with the
  version in pmtools (which appears to be dead upstream) but had not
  made it an alternative before

* Tue May 28 2013 Al Stone <ahs3@redhat.com> - 20130517-1
- Update to latest upstream source.
- Remove acpica-tools-config.patch -- now in upstream
- Remove iasl-signed-char.patch -- now in upstream
- Updated debian-big_endian.patch
- Updated debian-unaligned.patch

* Mon May 13 2013 Al Stone <ahs3@redhat.com> - 20130328-1
- Update to latest upstream source.

* Wed Mar 20 2013 Al Stone <ahs3@redhat.com> - 20130214-2
- Incorporate use of optflags macro in the build.
- Remove extraneous rm -rf of buildroot.
- Remove extraneous use of defattr in the files section.
- Incorporate use of parallel make.
- Remove extraneous use of the clean section.
- Use simpler globbing in the files section.
- Use simpler globbing in the install section.
- Remove obsolete git notes from README.Fedora.
- Remove ExcludeArch restrictions.

* Mon Feb 18 2013 Al Stone <ahs3@redhat.com> - 20130214-1
- New upstream.
- Remove most of the config file patch; still need to remove -m{32,64}.
- Clarify the licensing; this source is dual-licensed and is being released
  under the GPLv2 as allowed by the original Intel license.
- Redo the misc tests so they compare results properly.

* Wed Feb 06 2013 Al Stone <ahs3@redhat.com> - 20130117-6
- Added a zero-fill to a date used in comparing testing results so that the
  comparison would be correct on days numbered < 10.

* Thu Jan 31 2013 Al Stone <ahs3@redhat.com> - 20130117-5
- Simplify versioning scheme and revert to the original scheme in use by
  iasl, which is use the latest official tarball date (2013017) as the
  version and 1%{?dist} as the release, to be incremented for packaging
  and bug fixes as needed.

* Wed Jan 30 2013 Al Stone <ahs3@redhat.com> - 20130117-4
- Do a little reset: go back to using just the original upstream tarball
  instead of the latest git; the snapshot approach was more complicated
  than needed.
- Upstream tarballs split commands from test suites, so had to add the
  test suite back in as another Source: file.
- Change versioning scheme to include the APCI specification level (5.0),
  the latest official tarball date (2013017) and a revision level  (the
  .1 at the end) for packaging and bug fixes as needed.
- Changed the License field to reflect the source tarball change; the release
  tarball is dual-licensed, Intel ACPI or GPLv2.
- Updated patches to apply cleanly as needed.
- Corrected Obsoletes and Provides version numbers.

* Mon Jan 28 2013 Al Stone <ahs3@redhat.com> - 20130117-3
- Reconcile Fedora and Debian patches to be as alike as possible

* Mon Jan 28 2013 Al Stone <ahs3@redhat.com> - 20130117-2
- Verify ExcludeArch restrictions -- the architectures excluded can have
  no use for these tools.  Hardware support for ACPI is simply not
  implemented for them.
- Corrected versioning to note this source came from a git pull.
- Add License file as upstream has not yet provided one (and has not for
  many years).
- Insert properly versioned Provides and Obsoletes for iasl.
- Corrected files to use man.1* (vs man.1.gz) to allow flexibility in the
  compression being used.

* Wed Jan 23 2013 Al Stone <ahs3@redhat.com> - 20130117-1
- Clone from the current iasl package, with the intent of replacing it
- Update source to latest upstream
- NB: ACPICA documentation would normally be included in a source tarball.
  But, since it is not clearly redistributable, it is not included in the
  source RPM for this package.
- Build all ACPICA tools, not just iasl (and hence the package replacement)
- Add in brief man pages
- Set up acpixtract from this package as an alternative to the same command
  in the pmtools package
- Run the check step once built

