Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions packages/arduino_ide.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
ENV["CREW_NOT_STRIP"] = "true"

require 'package'

class Arduino_ide < Package
description 'Arduino is an open-source physical computing platform based on a simple I/O board and a development environment that implements the Processing/Wiring language.'
homepage 'https://www.arduino.cc/'
version '1.8.7'
source_url 'https://github.com/arduino/Arduino/releases/download/1.8.7/arduino-1.8.7.tar.xz'
source_sha256 'f9d684554c7bd55065d9163cc6819acf17dc8826f9ccb27437fb22401b29326e'

binary_url ({
})
binary_sha256 ({
})

depends_on 'xzutils'
depends_on 'jdk8'
depends_on 'ant' => :build
depends_on 'sommelier'

def self.build
case ARCH
when 'x86_64'
platform = 'linux64'
when 'i686'
platform = 'linux32'
when 'armv7l', 'aarch64'
platform = 'linuxarm'
end
Dir.chdir("build") do
system "env",
"JAVA_HOME=#{CREW_PREFIX}/share/jdk8",
"ant",
"-Djava.net.preferIPv4Stack=true",
"-Dversion=#{version}",
"-Dplatform=#{platform}",
"clean",
"dist"
system "echo '#!/bin/bash' > arduino"
system "echo >> arduino"
system "echo 'echo \"Enabling Arduino write access...\"' >> arduino"
system "echo 'sudo chmod o+w /dev/ttyACM*' >> arduino"
system "echo 'sommelier -X --x-display=\$DISPLAY --scale=\$SCALE #{CREW_PREFIX}/share/arduino-#{version}/arduino \"$@\"' >> arduino"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the sommelierd daemon handle this also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work in this case. There must be something wrong with it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing wrong with sommelier. You likely just need to create a symlink:

system "ln -s #{CREW_PREFIX}/share/arduino-#{version}/arduino #{CREW_DEST_PREFIX}/bin/arduino"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work. The sommelier daemon doesn't run it properly. It also still needs to make the device files writable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm still not understanding why you would need to write to device files. A device file is not meant for storage. If you run the arduino executable by itself, it should work with the sommelierd daemon running just like any other executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The application accesses the Arduino by way of opening the device files. It evidently doesn't work, even while running startsommelier && /usr/local/share/arduino-1.8.7/arduino.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I guess this is enough back and forth. I'm merging it. :)

system "echo 'echo \"Disabling Arduino write access...\"' >> arduino"
system "echo 'sudo chmod o-w /dev/ttyACM*' >> arduino"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow this logic. Why do you need write access to the devices? That seems odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can flash the compiled code to their chips/onboard storage.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need write access to device files to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The /dev/ttyACM* files are device files pointing to to the Arduino devices.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What needs to write to the device files? That doesn't make any sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board."
The Arduino IDE needs to write the compiled code to the Arduino via. the device files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it needs to write to Arduino, not the actual device files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onboard storage of the Arduino IS the device file. The device file isn't writable unless we allow write access to it, which we're doing with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end
end

def self.install
case ARCH
when 'x86_64'
platform = 'linux64'
when 'i686'
platform = 'linux32'
when 'armv7l', 'aarch64'
platform = 'linuxarm'
end
Dir.chdir("build") do
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/share"
system "tar", "xpvf", "linux/arduino-#{version}-#{platform}.tar.xz", "-C", "#{CREW_DEST_PREFIX}/share/"
system "install", "-Dm755", "arduino", "#{CREW_DEST_PREFIX}/bin/arduino"
end
end
end

ENV["CREW_NOT_STRIP"] = ""