
# Install Arduino development tools
#
class arduino {

    package { [ "uisp",
                "avr-libc",
                "avr-gcc-c++",
                "rxtx",
                "avrdude", ]:
        ensure => installed,
        before => File["/usr/local/bin/arduino"],
    }

    case $architecture {
        "x86_64": { $bits = "64" }
        default:  { $bits = "32" }
    }

    file { "/usr/local/src/arduino.tgz":
        ensure => present,
        source => "puppet:///files/packages/arduino${bits}.tgz",
        links  => follow,
        mode   => 0644,
        owner  => "root",
        group  => "root",
    }
    util::extract::tar { "/usr/local/lib/arduino":
        strip   => 1,
        source  => "/usr/local/src/arduino.tgz",
        require => File["/usr/local/src/arduino.tgz"],
    }

    file { "/usr/local/bin/arduino":
        ensure  => link,
        target  => "/usr/local/lib/arduino/arduino",
        owner   => "root",
        group   => "root",
        require => Util::Extract::Tar["/usr/local/lib/arduino"],
    }

}
