Getting started with ACF development

From Alpine Linux
Jump to: navigation, search
Out of date clock icon.svg
This material is obsolete ...

Please feel free to help us make an up-to-date version. (Discuss)

This document describes how to get started with ACF development using the setup-acf-dev script.

It is possible to set up a minimal alpine chroot on your desktop (Ubuntu/Debian/Fedore/Gentoo/whatever) where ACF development can be done. This way its not needed to run a fullblown virtual (or real) machine to do ACF development. While this enviroment will be somewhat limited (no grsecurity or other kernel specific stuff) it still does provide all the necessary stuff to do meaningful ACF development.

There is a small script to set up this environment here: http://dev.alpinelinux.org/~ncopa/setup-acf-dev

The script will:

  • Set up a small alpine chroot environment
  • Set up a user in the environment with sudo access
  • Install needed applications like subversion, http server and vim
  • Configure the http server
  • Check out ACF modules from svn repository and install them in the environemt
  • Create a simple .vimrc with useful key binding
  • Create a simple script to enter the chroot

Invoking the script

$ sudo ./setup-acf-dev 
usage: setup-acf-dev TARGETDIR
The following environment variables are used:"
  WGET        path to wget program (/usr/bin/wget)
  TAR         path to tar program (/usr/bin/tar)
  MIRROR      alpine mirror (http://dev.alpinelinux.org/alpine/v1.7)
  BASE        name of alpine base package (base.tar.bz2)
  ACFUSER     non-root username to use in chroot ($SUDO_USER)
  ACFSVN      svn repository base (svn://svn.alpinelinux.org/acf)
  MODULES     svn modules to checkout (core alpine-baselayout)
  CHROOT      chroot program. I.E 'linux32 chroot' (chroot)
  PORT        port for mini_httpd (80)
  http_proxy  proxy server ()

So if you for example use a 64 bit Gentoo desktop you can run the script as:

CHROOT='linux32 chroot' ./setup-acf-dev acfroot

Then will all chroot invocations be in probper 32 bit mode.

To just set up a chroot in the driectory acfroot you run the script as:

$ sudo ./setup-acf-dev acfroot
>>> Fetching http://dev.alpinelinux.org/alpine/v1.7/base.tar.bz2...
./
./var/
./var/db/
./var/db/apk/
./var/db/apk/uclibc-0.9.28.3.tar.gz
 
...

>>> Creating .vimrc...
>>> Creating enter-chroot script...
>>>
>>> Setup Completed. Enter the chroot environement with (as root):
>>>
>>>     acfroot/enter-chroot
>>>
>>> Once inside the chroot the privileges will drop to 'ncopa'.
>>> You can start and stop mini_httpd within chroot by executing:
>>>
>>>     sudo /etc/init.d/mini_httpd start
>>>     sudo /etc/init.d/mini_httpd stop
>>>
>>> You can specify the port in /etc/mini_httpd.conf
>>>
>>> Remember to install the acf module to activate changes:
>>>
>>>     sudo make install
>>>

Entering and leaving the ACF chroot

The help text will tell you how to enter the chroot. Please note that you need to execute teh enter-chroot script as root. The enter-chrrot script will mount a /proc inside the chroot and it will then change the permissions to the user created by the setup-acf-dev script

If you installed the ACF environment in teh acfroot directory you enter the chroot byt typing sudo acfroot/enter-chroot

On my gentoo system it looks like this:

ncopa@nc ~ $ sudo acfroot/enter-chroot 
Password:
Entering ACF develmopment chroot. Type 'exit' or press ctrl-d to leave.
~ $ 

Starting the web server

After entering the chroot you can start the webserver with:

sudo /etc/init.d/mini_httpd start

By default it will bind to port 80. If you need to change the port you can do that by editing /etc/mini_httpd.conf.

Point your web brower to http://localhost and you should see the Alpine webconf.

Working with the source files

After entering the chroot you have the acf modules checked out. Currently there are only 2 modules, alpine-buildroot and core. Enter the module you are interested in, make a change, and run sudo make install to install the changes. The .vimrc created has a keymap for F9 that will save file and execute sudo make install. So during normal development its jsut to press F9 and refresh the webbrowser to see the changes.

Adding files

If you want to add a file, you need to make the Makefile aware of your file. If you forget this step the file will not be included in the distribution source package and not in the final apk package. To detect those errors early, always install edited files with make install.

Before committing anything to svn, also make sure that make install works.

To be Continued

Setting up a acf-dev without chroot

The following assumes that you already have a functioning Alpine Linux and that you plan to run this on a Alpine Linux

  • Install needed packages
apk_add haserl mini_httpd subversion luaposix json4lua
  • Check out the acf-core (and acf-devtools)
svn co svn://svn.alpinelinux.org/acf/core/trunk /usr/share/acf
svn co svn://svn.alpinelinux.org/acf/devtools/trunk /usr/share/acf/app/devtools
  • Create needed folders and symlinks
mkdir -p /var/www/localhost/
ln -s /usr/share/acf/www/ /var/www/localhost/htdocs
  • Edit the /etc/mini_httpd.conf
nochroot
dir=/var/www/localhost/htdocs
user=nobody
logfile=/var/log/mini_httpd.log
cgipat=cgi-bin**
port=80
  • Edit the /etc/conf.d/mini_httpd
MINI_HTTPD_OPTS="-C /etc/mini_httpd.conf"
MINI_HTTPD_DOCROOT=/var/www/localhost/htdocs
  • Create/modify /etc/acf/acf.conf
mkdir /etc/acf/
echo "appdir=/usr/share/acf/app/
libdir=/usr/share/acf/lib/
skin=static" > /etc/acf/acf.conf
  • Startup your mini_httpd
/etc/init.d/mini_httpd start
  • Now update your projects

Browse to your ip-address to your acf-dev machine (using firefox or some other web-browser). Click on "DevTools" > "SVN status (for ACF)" and it helps you download all possible projects. It should work now!