Release Chroot(able) Development Image Generator (RFC, beta)


urjaman

"I Know. We're going for a ride."
Joined
Jan 6, 2009
Messages
1,111
Age
33
Location
Finland
Website
urja.dev
This was a "why hasnt anyone done that now, i'll do it"-type idea and now I found out why nobody had done that... A weekend of testing passed without me noticing that I had other stuff to do in life :p


So this is for the developers, and as such I thought that it isnt worth the pain to pnd this first beta, but the idea is/was that it is pnd-able (add pxml, make squashfs, tada.. or almost) and user-interfaces with zenity and notify-send, but for now (testing, beta) you should run it from a terminal to see any possible error messages, etc.


Requirements:


- SuperZaxxon 1.52 (running from NAND or SD, doesnt matter)


- 1GiB of free space on sd (FAT) or on an ext2/3/4 partition (minimum 1GiB) that you create and mount yourself - if you're running from SD you can make a folder in your root fs.


I recommend that if you intend to build anything big (eg. kernel) you have atleast 2GiB.


The package is http://urjaman.dyndn...enerator.tar.gz << there (18MiB).


( Sorry that I have ~1 Mbps uplink... my download time estimate for a single downloader is about 2.5min, but if you all trash my uplink now, then 2.5min*users... )


Feel free to post a mirror if you like this, I didnt include a copying file but consider this stuff GPL v3.


Usage:


# Download the package (wget is more reliable than firefox on a bad link)


# cd to the directory that you want to use for extracting the generator.


# I abused my NAND home dir :p , it is upto you where you do this.


# And yeah, to mention, this thing is not 100% clean on the host fs (NAND if you're running from it),


# if you use the image option it does create a mount point (empty directory) on /mnt/devloop


# So i've only tested extracting it on a linux fs (ubifs), it might work on FAT too, but that is untested


wget http://urjaman.dyndn...enerator.tar.gz


# Unpack the tar.gz:


tar xvf chroot-devimg-generator.tar.gz


# cd to the directory created


cd chroot-devimg-generator


# Here I'd look around and lol at my script names and quantity&quality.


# Also if you dont trust me - you should not trust me, I dont :p -


# you can take a look at what this stuff does:


# nano run.sh run_root.sh create-dev-chroot.sh enter-chroot-exec.sh chroot-make-dev.sh init.sh inchroot-init.sh


# Run it


./run.sh


It will (propably) first use gksudo to gain root privileges, then ask you a set of questions:


- Do you want to create a loopback image or do you have a ext* fs ready for this?


- If loopback image, image filename and size.


- Are you sure? (It doesnt do (or atleast shouldnt) anything before this and will just exit if you say no).


Then it will autonomously if wanted create loopback image and make an ext2 fs on it or just change to the directory you specified if image not wanted, and copy essentially your linux OS to the image/directory, and then chroot to it and install a set of ipk's (that are carried inside the package to avoid the need to ask user for internet connection halfway through) to the image to enable compilation.


The set of ipk's is currently quite minimal, and all I've tested is building a kernel menuconfig :p


There will be a zenity infobox telling you when all this is done, and when you press ok (and later times when you use run.sh) a terminal will popup with a shell inside the chroot.


To be noted: /media and /home are bind-mounted from your host fs so that you have your normal settings and sd cards / usb sticks available inside the chroot.


Resolv.conf is copied from host to chroot fs when the terminal is opened or if resolv.conf of host doesnt have any nameservers, we insert one with google ns (8.8.8.8) to the chroot.. you can change this if you want to, it is how i like it.


You should run sudo opkg update on the chroot before installing more -dev packages from the openpandora feed. The generator doesnt do this for the same reason it carries ipkgs.


But yeah with this system you should be able to safely compile stuff on the pandora, including installing opkgs without hurting your host system - you can test the more dangerous angstrom ipks too.


If you want to change/undo the config, edit/remove the chroot_cfg file.


So this is just a quite early beta of an idea, and I'm not sure if I will have the time to maintain this, but if it works for enough people I might polish it a bit and make a pnd. So feedback please. And sorry for the rambling post, too much to say and no idea of in what order to say...


EDIT: Yeah, forgot this, this is how I make and mount my testing ext4 fs (for speeed!)


# unmount the partition first if it is mounted


mkfs.ext4 -O^has_journal -L <LABEL> /dev/<device>


mkdir /media/<LABEL>


mount -o noatime,barrier=0 /dev/<device> /media/<LABEL>


!!! This makes it really unsafe to remove your SD card without unmounting first, and also bad things can happen on power loss, but it is fast... (async ext4 without journal, barrier and atimes...)


EDIT2: And yeah a known problem: If you kill the script doing the mounting, chrooting, unmounting sequence somehow (like kill the terminal it is running in using the X in the corner), the bind mounts (and the loopback mount if you use an image) might be left behind. I should add some better cleanup capability / resilience...


If that happens, just do this


sudo su


. chroot_cfg


cd "$TGTPATH"


umount media


umount home


umount sys


umount proc


umount dev


// And if loopback:


cd -


umount /mnt/devloop # (or "$TGTPATH")
 
Last edited by a moderator:
Yeah it essentially clones the OS-related parts of Zaxxon (everything but special directories, user home, media, mnt) to a different place and installs the compiler (mostly copied from the op feed) there - it installs a few selected pkgs from the angstrom feed too (make, git, u-boot-mkimage) that seem to be safe. Since we now have a working opkg with the openpandora feed, you can then just install all the necessary dev headers (for whathever you're building) and build & test in the alternative chrooted zaxxon.


If you copy/add the home directory for yourself, you could also use the resulting fs as an SD clone of your NAND system and with a few additions (it needs to be on a real partition, the kernel image needs to be there and boot.txt is needed) you could boot from it (eg. do what Pandora SD installer does but without the image. ).


EDIT: I have not tested this. And I think that you need to also copy the /dev directory that is on the root filesystem below the tmpfs mounted by udev. You can do that by bind-mounting "/" somewhere (mounts above / wont then be visible there and you can see the real rootfs content.) There might be a few other small bits and pieces that are not currently copied, ... but with a little work it could be made to do everything, but now the focus was on a "development build jail" type chroot.
 
Last edited by a moderator:
Back
Top