Minggu, 29 September 2013

Xathrya Sabertooth

Xathrya Sabertooth


Set Up Environment for Firefox OS Development – Firefox OS Simulator

Posted: 29 Sep 2013 01:34 AM PDT

Firefox OS is a smartphone and table Operating System developed by Mozilla. It is developed under the same brand of Mozilla’s famous web browser project, Mozilla Firefox. Mozilla has a big and clear vision. Firefox OS is developed to adapt the dynamic of the web. It anticipates users needs, adapts to every situation, and instantly delivers information user want.

The interesting part is, Mozilla has develop an add-on for developing and simulating Firefox OS on top of Firefox browser.

This article will discuss about how can we prepare a portable development environment and simulating Firefox OS.

About Firefox OS Simulator

Like implied by the name, Firefox OS simulator is a simulator for Firefox OS. As per September 29th 2013, the current Firefox OS Simulator is still at an early stage of development. Thus, it isn’t yet as reliable and complete. Mozilla also encourage to report bug to GitHub and participate to the development process.

The big concept Firefox OS has is an add-on for Firefox browser. Using this add-on we can test and debug Firefox OS app on the desktop. It is like Android Emulator, but lightweight and easy to use. But, as told above, don’t expect too much for now. But still, it’s quite promising ;)

So, what’s bundled to this add-on?

  1. the Simulator: Including Firefox OS desktop client. This is the higher layers of Firefox OS that runs on desktop. The simulator also includes some additional emulation features that aren’t in the standard Firefox OS desktop builds.
  2. the Dashboard: a tool hosted by the Firefox browser that enables you to start and stop the Simulator and to install, uninstall, and debug apps running in it. The Dashboard also helps you push apps to a real device, and checks app manifests for common problems.

Installing and Running the Simulator

Installing the simulator is really easy. As easy as installing any other Firefox add-on.

  1. Using Firefox, go to the Simulator’s page.
  2. Click “Add to Firefox”
  3. Once the add-on has been downloaded, you will be prompted to install it. Click “Install Now”.

The add-on is quite big in size, thus Firefox may freeze for several seconds while installing it. A dialog titled “Warning: Unresponsive script” might appear. If it does, just click “Continue” to wait for installation to finish.

The Dashboard opens automatically when you install the Simulator. You can reopen it at any time by going to the “Firefox” menu (or “Tools”), then “Web Developer”, then “Firefox OS Simulator”.

firefoxos-1

And here is the Dashboard for you:

firefoxos-2

Here, on the left panel is a button to activate the simulator.

The right panel will list all application you have developed and can be run on top of Firefox OS (simulator).

Managing Apps

Adding apps

To add a packaged app to the Simulator, open the Dashboard, click “Add Directory” and select the manifest file for your app.

To add a hosted app, enter a URL in the textbox where it says “URL for page or manifest.webapp”, then click “Add URL”. If the URL points to a manifest, then that manifest will be used. If it doesn’t, the Dashboard will generate a manifest for the URL: so you can add any website as an app just by entering its URL.

When you add an app, the Dashboard will run a series of tests on your manifest file, checking for common problems. See the section on Manifest Validation for details on what tests are run.

Unless manifest validation reveals that your app has errors, the Dashboard will then automatically run your app in the Simulator.

On each entry, you will see information about the app:

  • name, taken from the manifest
  • type, which will be one of “Packaged”, “Hosted”, or “Generated”
  • link to manifest file
  • result of manifest validation

You also got four commands:

  • “Refresh”: use this to update and reload the app in the Simulator after you have made changes to it. This also makes the Dashboard validate the manifest again. If you make changes to your app they will not be reflected automatically in the installed app: you will need to refresh the app to apply the changes.
  • “Connect”: use this to connect developer tools to the selected app. The Dashboard will start the Simulator and app if they aren’t already running.
  • “Remove” (“X”): use this to remove the app from the Simulator and the Dashboard. You can undo this action as long as the Dashboard tab is open.
  • “Receipt”: use this to test receipt verification for paid apps. After you select a type of receipt to test, the app will be reinstalled with a test receipt of the given type.

The Simulator Device

Here is what the simulator looks like. The simulator device will be opened on new Firefox window.

firefoxos-3

The simulator can be started in two different ways:

  • adding an app or click the “Refresh” or “Connect” button next to your app’s entry, the Dashboard will automatically run your app in the Simulator
  • clicking the button labeled “Stopped” on the left-hand side of the Dashboard, the Simulator will boot to the Home screen and you’ll need to navigate to your app

The simulator appear as window 320×480 pixels with a tool bar at the bottom and a menubar at the top that contains some extra features:

You can left-click on Firefox OS area to simulate touch events. To simulate drag, click and hold the button to your preferred area. Here is the example. The left is the default launcher and drag to right will bring you to menu.

Now we have seen toolbar. Let’s play around with it.

There are three buttons on toolbar. From left to right, these are: Home button, Screen Rotation button, and the Geolocation button.

  • the Home button takes you to the Home screen (or to the task list if you keep it pressed for a couple of seconds)
  • the Screen Rotation button switches the device between portrait and landscape orientation. This will generate the orientationchange event.
  • the Geolocation button triggers a dialog asking you to share your geographic location, either using your current coordinates or supplying custom coordinates: this will be made available to your app via the Geolocation API.

Developer Tools

You can attach developer tools to the Simulator, to help debug your app. At the moment you can only attach the JavaScript Debugger, the Web Console, the Style Editor, the Profiler and the Network Monitor. Mozilla promise bringing more support of developer tools.

To attach developer tools to the Simulator, click the “Connect” button for an app. The Dashboard will then open a developer toolbox pane at the bottom of the Dashboard tab and connect it to the app:

Web Console

The app can log to this console using the global console object, and it displays various other messages generated by the app: network requests, CSS and JS warnings/errors, and security errors.

Debugger

Using the Debugger, you can step through JavaScript code that is running in the connected app, manage breakpoints, and watch expressions to track down errors and problems faster.

Style Editor

You can view and edit CSS files referenced in the app using the connected Style Editor. Your changes will be applied to the app in real time, without needing to refresh the app.

Profiler

Using the Profiler tool connected to the app, you can to find out where your JavaScript code is spending too much time. The Profiler periodically samples the current JavaScript call stack and compiles statistics about the samples.

Network Monitor

Thanks to the new Network Monitor, you can analyze the status, headers, content and timing of all the network requests initiated by the app through a friendly interface.

Introduction to User-Mode Linux

Posted: 28 Sep 2013 12:00 PM PDT

User-Mode Linux is a safe, secure way of running Linux versions and Linux processes. It is a virtualization, but use different approach in compare to VirtualBox or VMWare. Run buggy software, experiment with new Linux kernels or distributions, and poke around in the internals of Linux, all without risking main Linux.

This article will give a brief introduction to User-Mode Linux and test what we can do with it.

Comparing User-Mode Linux with Other Virtualization Technology

UML (User-Mode Linux) differs from other virtualization technologies in being more of a virtual operating system (OS) rather than a virtual machine. Things like VMWare are virtual machine which emulate a physical platform from the CPU to the peripherals. In contrast, UML can be only a Linux guest. However, being a virtualOS allows UML to interact more fully with the host OS.

Other virtualization technologies such as Xen, BSD jail, Solaris zones, and chroot are integrated into the host OS, as opposed to UML, which runs in a process. This gives UML the advantage of being independent from the host OS version, at the cost of some performance. However, a lot (maybe all) of this performance can be regained without losing the flexibility and manageability that UML gains from being in userspace.

The benefit of virtualization accrue largely from the degree of isolation between users and processes inside the virtual machine or jail and those outside it.

The least complete virtualization is provided by chroot which only jails processes into a directory. In all other respects, the processes are unconfined. Even then, on Linux, chroot can't confine a process with root privileges, since its design allows superuser processes to escape.

Finally, technologies such as VMWare, Xen, and UML implement full virtualization and isolation. They all have fully virtualized devices with no restrictions on how they may be used. They also confine their processes with respect to CPU consumption by virtue of having a certain number of virtual processors they may use. They also all run separate instances of the OS, which may be different versions (and even a completely different OS in the case of VMWare) than the host.

The User-Mode Linux

User-Mode Linux is an ELF binary which run on userspace. It is like other process. However, the process itself is a modified copy of Linux kernel. Therefore, we can say that UML is a kernel and userspace program at same time (but it has different perspective).

You can obtain the kernel here: http://uml.devloop.org.uk/

That links provide a kernel up to the recent version. The older kernel is available. All are available in 32-bit and 64-bit architecture.

Also, you can download a filesystem on here: http://fs.devloop.org.uk/

The disk image are a companion for Kernel. It is optional, though recommended to be obtained.

For this article, I will use Kernel version 3.11.2 64-bit and file system Slackware 12.x 64-bit.

First Boot

Extract the kernel and filesystem. Here I have:

  1. kernel64-3.11.2
  2. Slamd64-12.1-root_fs

Let’s head to kernel first. Check and run the kernel:

chmod +x kernel64-3.11.2  ./kernel64-3.11.2 mem=512M

As told by above command, I run kernel and having virtual RAM about 512MB. Don’t worry if you encounter a kernel panic. It’s fair to assume that we didn’t specify any root filesystem (and that’s right).

Complete Boot UML

Now, after the first attempt, let’s boot UML in proper way. This time, we will boot kernel and specify a filesystem. The filesystem we use here is Slamd64-12.1-root_fs.

./kernel64-3.11.2 ubda=Slamd64-12.1-root_fs mem=512M

Now you can see the familiar login prompt on your terminal.

Add a Network Support

To add network capability to UML machine, we have to create a new TAP interface. We should allocate the TAP device to UML instance. Here, on you host Linux:

tunctl -t tap0

tap0 is the device name for our new interface.

Next, assign an IP address to it, assuming the IP address is 192.168.1.3 and on 192.168.1.0/24 network. Of course you need to adjust it to your network.

ifconfig tap0 192.168.1.3

Then modify the kernel invocation, by:

./kernel64-3.11.2 ubda=Slamd64-12.1-root_fs mem=512M eth0=tuntap,tap0,MAC_ADDR,IP_ADDR con0=fd:0,fd:1

Tidak ada komentar:

Posting Komentar