The following is the "spec" file used to build the Fedora 17 arduino packages for arduino-1.0.1
Name:		arduino
Epoch:		1
Version:	1.0.1
Release:	1%{?dist}
Summary:	An IDE for Arduino-compatible electronics prototyping platforms
Group:		Development/Tools
License:	GPLv2+ and LGPLv2+ and CC-BY-SA
URL:		http://www.arduino.cc/

# There are lots of binaries in the "source" tarball.  Remove them with:
# curl -L http://arduino.googlecode.com/files/arduino-0022-src.tar.gz | tar -xzvf - && rm -r arduino-0022/build/linux/dist/tools/* && find arduino-0022 \( -type d \( -name macosx -o -name windows \) -o -type f \( -iname '*.jar' -or -iname '*.tgz' -or -iname '*.so' \) \) -print0 | xargs -0 rm -rf && tar -cJf arduino-0022.tar.bz2 arduino-0022
# See also http://code.google.com/p/arduino/issues/detail?id=193
Source0:	%{name}-%{version}.tar.xz

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:	noarch

# Use unbundled libs:
Patch0:		arduino-script.patch
Patch7:		arduino-no-avrdude64.patch
# Requested upstream in http://github.com/arduino/Arduino/pull/5:
Patch3:		arduino-use-system-rxtx.patch

# Requested upstream in http://github.com/arduino/Arduino/pull/6:
Patch4:		arduino-icons-etc.patch

Patch6:		arduino-add-to-groups.patch

BuildRequires:	java-devel >= 1:1.6.0 jpackage-utils ant ant-apache-regexp desktop-file-utils ecj jna rxtx git
Requires:	%{name}-core = %{epoch}:%{version}-%{release}, %{name}-doc = %{epoch}:%{version}-%{release}
Requires:	java >= 1:1.6.0 xorg-x11-fonts-Type1 ecj jna rxtx
Requires:	zenity perl polkit


%description
Arduino is an open-source electronics prototyping platform based on
flexible, easy-to-use hardware and software. It's intended for artists,
designers, hobbyists, and anyone interested in creating interactive
objects or environments.

This package contains an IDE that can be used to develop and upload code
to the micro-controller.


%package -n %{name}-core
Summary:	Files required for compiling code for Arduino-compatible micro-controllers
Group:		Development/Tools
Requires:	avr-gcc avr-gcc-c++ avr-libc avrdude


%description -n %{name}-core
Arduino is an open-source electronics prototyping platform based on
flexible, easy-to-use hardware and software. It's intended for artists,
designers, hobbyists, and anyone interested in creating interactive
objects or environments.

This package contains the core files required to compile and upload
Arduino code.


%package -n %{name}-doc
Summary:	Documentation for the Arduino micro-controller platform
Group:		Development/Tools
Requires:	avr-gcc avr-gcc-c++ avr-libc avrdude


%description -n %{name}-doc
Arduino is an open-source electronics prototyping platform based on
flexible, easy-to-use hardware and software. It's intended for artists,
designers, hobbyists, and anyone interested in creating interactive
objects or environments.

This package contains reference documentation.


%prep
%setup -q -n %{name}-%{version}
find -name '*.class' -exec rm -f '{}' \;
find -name '*.jar' -exec rm -f '{}' \;
%patch6 -p1
chmod a+rx build/linux/%{name}-add-groups
%patch0
%patch3 -p1
%patch7 -p1

echo -e "\n# By default, don't notify the user of a new upstream version." \
        "\n# https://bugzilla.redhat.com/show_bug.cgi?id=773519" \
        "\nupdate.check=false" \
    >> build/shared/lib/preferences.txt

# "git apply" fails silently if pwd is git-controlled.
pwd=`pwd`
cd /
git apply --directory=$pwd %{PATCH4}
cd $pwd

build-jar-repository -p -s app/lib/ ecj jna RXTXcomm


%build
cd core/methods
ant
cd ..
ant
cd ../build
echo %{version} | ant dist
tar -xf linux/%{name}-%{version}-linux.tgz


%install
cd build/%{name}-%{version}

mkdir -p $RPM_BUILD_ROOT/%{_bindir}
cp -a arduino $RPM_BUILD_ROOT/%{_bindir}/

mkdir -p $RPM_BUILD_ROOT/%{_datadir}/%{name}
cp -a hardware lib libraries examples $RPM_BUILD_ROOT/%{_datadir}/%{name}/
rm $RPM_BUILD_ROOT/%{_datadir}/%{name}/lib/*.jar
rm -r $RPM_BUILD_ROOT/%{_datadir}/%{name}/hardware/tools

mkdir -p $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}-%{version}
cp -a reference $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}-%{version}/
ln -s %{_defaultdocdir}/%{name}-%{version}/reference $RPM_BUILD_ROOT/%{_datadir}/%{name}/reference

# Requested upstream in http://github.com/arduino/Arduino/pull/4:
find $RPM_BUILD_ROOT -type f -iname *.jpg -or -iname *.java -or -iname *.pde -or -iname *.h -or -iname *.cpp -or -iname *.c -or -iname *.txt -or -iname makefile -or -iname key*.txt -or -iname pref*.txt | xargs chmod -x;

cp -a lib/core.jar lib/pde.jar $RPM_BUILD_ROOT/%{_datadir}/%{name}/

mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}
mv $RPM_BUILD_ROOT/%{_datadir}/%{name}/hardware/%{name}/boards.txt \
   $RPM_BUILD_ROOT/%{_datadir}/%{name}/hardware/%{name}/programmers.txt \
   $RPM_BUILD_ROOT/%{_datadir}/%{name}/lib/preferences.txt \
   $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/
ln -s %{_sysconfdir}/%{name}/boards.txt \
   $RPM_BUILD_ROOT/%{_datadir}/%{name}/hardware/%{name}/boards.txt
ln -s %{_sysconfdir}/%{name}/programmers.txt \
   $RPM_BUILD_ROOT/%{_datadir}/%{name}/hardware/%{name}/programmers.txt
ln -s %{_sysconfdir}/%{name}/preferences.txt \
   $RPM_BUILD_ROOT/%{_datadir}/%{name}/lib/preferences.txt

mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
cp -p ../linux/%{name}.1 $RPM_BUILD_ROOT/%{_mandir}/man1/

desktop-file-install --dir=${RPM_BUILD_ROOT}%{_datadir}/applications ../linux/%{name}.desktop

for dir in ../linux/icons/*; do
    size=`basename $dir`
    mkdir -p $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/$size/apps
    cp $dir/%{name}.png $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/$size/apps/
done

mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}
cp -a ../linux/%{name}-add-groups $RPM_BUILD_ROOT/%{_libexecdir}/

mkdir -p $RPM_BUILD_ROOT/%{_datadir}/polkit-1/actions
cp -a ../linux/cc.arduino.add-groups.policy $RPM_BUILD_ROOT/%{_datadir}/polkit-1/actions


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/*
%{_datadir}/%{name}/*.jar
%{_datadir}/%{name}/lib/
%{_datadir}/applications/*
%{_datadir}/icons/hicolor/*/apps/%{name}.png
%{_datadir}/polkit-1/actions/cc.arduino.add-groups.policy
%{_libexecdir}/%{name}-add-groups
%{_mandir}/man1/%{name}.1.gz
%{_datadir}/%{name}/reference


%files -n %{name}-core
%defattr(-,root,root,-)
%doc license.txt readme.txt todo.txt
%config(noreplace) %{_sysconfdir}/%{name}/boards.txt
%config(noreplace) %{_sysconfdir}/%{name}/programmers.txt
%config(noreplace) %{_sysconfdir}/%{name}/preferences.txt
%{_datadir}/%{name}/examples/
%{_datadir}/%{name}/hardware/
%{_datadir}/%{name}/libraries/


%files -n %{name}-doc
%defattr(-,root,root,-)
%{_defaultdocdir}/%{name}-%{version}/


%changelog
* Sun Jul 22 2012 Peter Oliver  - 1:1.0.1-1
- Update to 1.0.1.
- Compress source with xz.

* Fri May  4 2012 Peter Oliver  - 1:1.0-4
- Pass version number to "ant build" (fixes #815079).

* Sat Jan 14 2012 Peter Oliver  - 1:1.0-3
- Change the default preferences so that we don't notify the user that a
  new upstream version has been released (#773519).

* Thu Jan 12 2012 Fedora Release Engineering  - 1:1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Mon Jan  2 2012 Peter Oliver  - 1:1.0-2
- Add arduino-no-avrdude64.patch to prevent copying of (for us,
  unbundled) avrdude64.

* Mon Jan  2 2012 Peter Oliver  - 1:1.0-1
- Update to 1.0 (#753103).
- Drop arduino-use-system-avrdude.patch and arduino-boards-txt.patch,
  since they're no-longer needed.
- Move preferences.txt to /etc.

* Mon Sep 12 2011 Peter Oliver  - 0022-5
- Treat boards.txt and programmers.txt as config files (#726135).
- Make building with "fedpkg local" work.

* Fri Jul 15 2011 Peter Oliver  - 0022-4
- Include missing examples (#722351).

* Mon Feb 07 2011 Fedora Release Engineering  - 0022-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Fri Dec 31 2010 Peter Oliver  - 0022-2
- Prompt the user if they are not a member of the required groups,
  rather than failing silently.

* Thu Dec 30 2010 Peter Oliver  - 0022-1
- Update to 0022 release (#666309).
- Use the new upstream source tarball rather than git.
- Drop oro requirement and related patch, since it is no-longer used.

* Fri Dec 17 2010 Peter Oliver  - 0021-2
- Patch boards.txt to use the "arduino" programmer type for Uno boards,
  allowing Fedora's version of avrdude to work with these boards.

* Thu Oct  7 2010 Peter Oliver  - 0021-1
- New upstream release 0021.
- Add patch for new upstream icons.
- Override device scan in RXTX to allow use of Arduino Uno.

* Mon Sep 20 2010 Peter Oliver  - 0019-6
- Explictly mention documentation with doc macro.
- Move reference documentation into -doc package.

* Thu Sep  9 2010 Peter Oliver  - 0019-5
- Add missing BuildRequires.
- Use build-jar-repository to locate java libraries to build against.
- Eliminate cross-package symlinks.

* Wed Sep  8 2010 Peter Oliver  - 0019-4
- Make sure all jars are removed from the source bundle.
- Add missing documentation.

* Tue Sep  7 2010 Peter Oliver  - 0019-3
- Split into two packages, making the IDE optional to install.
- Build during the build phase not the install phase.
- More dependencies.

* Mon Sep  6 2010 Peter Oliver  - 0019-2
- Expanded dependencies.

* Sun Sep  5 2010 Peter Oliver  - 0019-1
- Initial version.  Based in part on the Debian package.

Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org