--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/b669a1d1-6280-4404-9dc6-fa2f7dc67ed9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/3568d0f6-e987-4c15-988f-89e7fa552f5a%40googlegroups.com.
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/cf83fc45-7b21-41bd-9c39-1dd7c1034968%40googlegroups.com.
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/aed2316d-596f-4308-8f10-6f4e74f3e54a%40googlegroups.com.
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/57114e31-4c62-40d1-acb4-11ae50121898%40googlegroups.com.
I almost don't want to post this - it's early days and seems too good to be true - but DAYUM just look at that screenshot!
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/c221c153-b412-4e72-8738-5ef3a9e6065f%40googlegroups.com.
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/5a3c4707-0336-468b-8cf6-7d0d74b5baab%40googlegroups.com.
This document describes how to set up a complete PyCharm development environment for iocage
in a FreeBSD 10.3 VM.
Once you have everything configured, you’ll be able to do these 6 magical things:
We use the might and power of Pycharm Virtual Environments, plus a few sneaky scripts to make this all possible.
Buckle up, let’s get started!
Let’s get started by creating a silly little 2-CPU VM with 4GB RAM and a 20GB HDD.
csh
shell, and add me to the wheel
groupfreebsd-update fetch
freebsd-update install
reboot
pkg upgrade
pkg install sudo xclock x11auth open-vm-tools
Run visudo
to allow wheel dudes to sudo. Also in /etc/ssh/sshd_config, allow X forwarding.
Put this stuff in /etc/rc.conf:
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"
echo "autoboot_delay=3" >> /boot/loader.conf
Edit the /etc/login.conf
file. Add to the setenv
part:
LC_COLLATE=C
And add this to the end of the default:
section:
:charset=UTF-8:\
:lang=en_US.UTF-8:
then do as root:
cap_mkdb /etc/login.conf
TODO: write the VIMAGE kernel stuffs
sysrc zfs_enable=YES
Power off the VM, and add a second 20GB hard drive. Power it back on and create a zpool with no mountpoint (cos that’s how I roll):
zpool create -O canmount=off -m none tank /dev/da1
TODO: Add a local, lightweight web server to the mix, for the freebsd-update process
To save massive amounts of time during testing, we should have access to an on-premises FreeBSD mirror FTP server. Let’s just quickly create an anonymous FTP server inside our silly little VM.
We will need this directory structure in the ftp
user’s home directory:
9.3-RELEASE
10.3-RELEASE
11.0-RELEASE
Put these files from each release in the each release directory:
MANIFEST
base.txz
doc.txz
lib32.txz
Create the ftp user, with username ftp
. Just use adduser
for this as usual.
Log on as ftp
and start making some directories and files:
mkdir 9.3-RELEASE 10.3-RELEASE 11.0-RELEASE
Copy the distribution files in (just grab them from ftp.freebsd.org or install DVDs or whatever)
Enable the FTP server at boot, and configure it server with some appropriate options:
inetd
, rather spawn ftpd
as a daemonsysrc ftpd_enable=YES
sysrc ftpd_flags="-ADr -a 127.0.0.1"
Start the service:
service ftpd start
Cool beans. Now we will save a lot of time and bandwidth when testing, as we can just specify localhost
as the FTP server to download FreeBSD install files from.
Do this stuff as root:
pkg install git python36 llvm40
python3.6 -m ensurepip
pkg install intellij-pycharm
Ideally, we run PyCharm as an ordinary user, and use sudo
for running & debugging iocage, pytesting, etc. I have been struggling for days to get it to all work smoothly, but have finally come up with a nice way to do it that doesn’t harm kittens.
Do this as ordinary user. Notice that the version of PyCharm from FreeBSD packages is 2017.1 (as opposed to 2016.3 in the TrueOS repository).
SSH in to the box, start PyCharm:
ssh -X pycharmvm.lan
pycharm &
Go through the first few dialogs that pop up:
When the main welcome dialog box comes up, don’t try to open anything, let’s go straight to Configure > Settings > Project Interpreter
You can later activate the venv in terminal with:
source ~/iocage-env/bin/activate.csh
Before you do that though, let’s add the final touch of configuring this venv to allow use of sudo when running python3.6.
Configure python3.6 in our iocage venv to run without password with sudo:
sudo visudo -f /usr/local/etc/sudoers.d/iocage-env-python
Add a line of the form:
<user> <host> = (root) NOPASSWD: <full path to python>
For example:
jamie pycharmvm = (root) NOPASSWD: /usr/home/jamie/iocage-env/bin/python
We need our PYTHONPATH
environment variable preserved after the sudo
so put this in there as well:
Defaults env_keep += PYTHONPATH
Now create a script for launching python with sudo. Save it as python-sudo.sh in the venv’s bin directory:
#!/bin/sh
sudo ~/iocage-env/bin/python "$@"
And make it executable:
chmod +x ~/iocage-env/bin/python-sudo.sh
Now configure PyCharm to use this script. Assuming you’re back at the PyCharm welcome screen:
That should be it! Now things run inside PyCharm should be run as root when you select this Interpreter. If you get an error complaining that it can’t set it up, that the SDK seems invalid, then check the path in your python-sudo.sh script, and verify that it actually runs without asking for a password - source the venv and test it!
Oh, one last thing that I have found solved problems with running in the CLI that were not a problem running from the GUI. Under Edit Configurations… there are a couple of boxes checked that add content and source roots to PYTHONPATH
. We need to achieve somthing similar in the CLI venv, else it’ll complain that module iocage is not found.
Edit ~/iocage-env/bin/activate.csh, and add this line to it:
setenv PYTHONPATH "/home/<username>/iocage"
Do all this stuff logged on as a standard user, with the iocage venv sourced.
pip install Cython
(do this as root outside the venv):
python3.6 /usr/local/share/pycharm/helpers/pydev/setup_cython.py build_ext --inplace
In home directory, grab the iocage source:
git clone --recursive https://github.com/iocage/iocage
Build the ZFS libraries (inside the venv):
cd iocage
cd py-libzfs && python3.6 setup.py build && python3.6 setup.py install
Now open the ~/iocage in PyCharm. Just relax a bit and let it do its indexing things. Now open main.py. It works a bit, then complains that it’s missing some requirements. Install them. (They end up nicely in the venv site packages)
As a final touch is to create a “fake” iocage
executable. Put this in ~/iocage-env/bin/iocage:
#!/bin/sh
~/iocage-env/bin/python ~/iocage/iocage/main.py "$@"
And make it executable:
chmod +x ~/iocage-env/bin/iocage
Now we can run a fake little iocage from the CLI, but it’s actually running straight out of our source tree. Run iocage
on its own to run it as a standard user, or sudo iocage
to run as root. Sassy!
If all is well, you should be able to run main.py in the GUI now, and see in the console the standard usage message that iocage always gives when run without parameters.
To run it with a parameter, for example iocage list
, open up iocage/main.py, go to Run > Edit Configurations… Python > main. In the script parameters field you can enter list
(or whatever command you want to run).
To run as root, just go to the Project Interpreter settings, and make sure the iocage-env (1) is selected. To run as standard user, select the other one.
The last step in getting our complete development environment up and running is making sure we can run all the nice test suites.
Logged on as an ordinary user, source
the iocage-env
venv, cd to ~/iocage
and try running pytest
. You’ll see that a module is missing: We need to install the mock
module
source ./iocage-env/bin/activate.csh
cd ~/iocage
pytest
Install mock
in the venv:
pip install mock
Now pytest can be run as an ordinary to do unit tests, or sudo’d to run the full battery.
As an ordinary user, inside the venv, do this to run only the unit tests:
cd ~/iocage
pytest
Notice that we get a message at the end about having skipped conftest.py
, needing to be root to run. That’s fine, that’s cool.
As an ordinary user, we’ll sudo
to run basic functional tests:
cd ~/iocage
sudo pytest
Again conftest.py
is skipped, but this time because a zpool wasn’t specified. Glorious!
And the full-on cavalcade of tests:
Note: This will destroy all iocage datasets on the specified zpool! So specify your development pool here, not production!
cd ~/iocage
sudo pytest --zpool="tank" --server="localhost" --release="10.3-RELEASE"
Not necessary to get all this working, but needed if you actually want to start contributing ;)
TODO: Markdown is boss, install the plugin for it
TODO: set this up and export the config so it can later be pasted/imported for next time this all needs to be set up
One way to go about passing in CLI parameters is to set up multiple debug configurations for main.py:
Go to Run > Edit Configurations. Select main
. Let’s rename this to “01 - usage” and hit Apply. Now and hit the copy button. Name it for the command you want, for example: “02 - activate” and put in the CLI parameters in the Script parameters field, for example “activate tank”.
Some handy configurations to define:
Running from the command line is simple enough. For example run the clean
command:
cd ~/iocage/iocage
python-sudo.sh main.py clean --all
Better yet, make a script for that too. Save this as ~/iocage-env/bin/ioc
and make it executable:
#!/bin/sh
sudo /usr/home/jamie/iocage-env/bin/python -i /usr/home/jamie/iocage/iocage/main.py "$@"
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/9d82a55e-4b3b-48f0-b80d-c4b554cbb2a4%40googlegroups.com.
The reboot utility does not execute the scripts in /etc/rcnum.d or exe- cute shutdown actions in inittab(4). To ensure a complete shutdown of system services, use shutdown(1M) or init(1M) to reboot a Solaris system
- Brandon
--
You received this message because you are subscribed to the Google Groups "iocage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iocage+un...@googlegroups.com.
To post to this group, send email to ioc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iocage/a535aa7d-8d26-417d-8cd5-a619e1163fbb%40googlegroups.com.