Home Page › Forums › Network Management › ZeroShell › Create a Development Environment
- This topic is empty.
-
AuthorPosts
-
June 28, 2016 at 4:52 pm #44590
iulyb
MemberHi,
I decided to share my adventure with you. There is some great documents about this especially this http://www.renatomorano.net/?p=1154 Many thanks to Renato MoranoMy setup is a bit simpler and assume you already have a Virtual Box image like here:
https://www.zeroshell.org/forum/viewtopic.php?t=5275With your guest off
Virtual Box -> Add New Storage Attachment. -> Hard Disk
Pick VDI and size should be about 5-8 G. Select SSD if is the case.# We need to format and mount this.
Start ZS guest, login to console,root@zeroshell ~> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1G 0 disk
|-sda1 8:1 0 210M 0 part
|-sda2 8:2 0 320M 0 part /cdrom
|-sda3 8:3 0 320M 0 part
`-sda4 8:4 0 173M 0 part /DB
sdb 8:16 0 8G 0 disk
sr0 11:0 1 1024M 0 romOur new space is sdb, we need to create a partition, format and mount it.
Partition:
fdisk /dev/sdb
Pick n (new) select p (primary) use 1 as partition number and allocate all space (hit enter enter for defaults)
After partition was created use w to write changes to disk
Check to make sure (note sdb1):root@zeroshell ~> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1G 0 disk
|-sda1 8:1 0 210M 0 part
|-sda2 8:2 0 320M 0 part /cdrom
|-sda3 8:3 0 320M 0 part
`-sda4 8:4 0 173M 0 part /DB
sdb 8:16 0 8G 0 disk
`-sdb1 8:17 0 8G 0 part
sr0 11:0 1 1024M 0 rom
# Format:
mkfs.ext4 /dev/sdb1
# Mount:
# First create a mount point that will survive reboots. (needs to be under DB)
mkdir -p /DB/devel/headers
mkdir -p /DBdevel/cdrom
mount /dev/sdb1 /DB/devel
ln -s /DB/devel /devel
df -h
####### NOt used anymore #########
#Mount /usr as RW
#cd /cdrom
#tar -czvf /DB/devel/cdrom/usr.tar.gz usr
#cd /DB/devel/cdrom
#tar -xzvf usr.tar.gz
#rm /usr
#ln -s /DB/devel/cdrom/usr /usr
cd /DB/devel/headers
At this point we need to download some stuff. ZS has all we need
wget http://mirror.switch.ch/ftp/mirror/zeroshell/gcc-4.5.2-i386.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/gcc-include.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/glibc-2.8-includes-zs.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/binutils-2.17-i386.tar.bz2
wget http://mirror.switch.ch/ftp/mirror/zeroshell/static-lib-i386.tar.bz2
# Unpack..:
cat *.bz2 |tar -xjvf - -i
Here is the twist… the order is important !, there are 2 versions of gcc on these packages, we need 4.5 😉 .. so again:
tar -xjvf gcc-4.5.2-i386.tar.bz2
# Testing gcc
root@zeroshell devel> gcc -v
bash: /usr/bin/gcc: Permission denied# Add magic glue
PATH=/DB/devel/headers/usr/bin:$PATH
Testing our work:
root@zeroshell devel> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/DB/devel/headers/usr/bin/../libexec/gcc/i586-pc-linux-gnu/4.5.2/lto-wrapper
Target: i586-pc-linux-gnu
Configured with: ./configure --prefix=/usr --enable-languages=c,c++
Thread model: posix
gcc version 4.5.2 (GCC)
Now we are talking
Make sure gcc is 4.5 and not 3.3 !!!!!!!!!!!!Downloading kernels
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.15.tar.gz
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.9.tar.gz
tar -xzvf linux-4.1.15.tar.gz
mkdir usr/src
mv linux-4.1.15 usr/src/
cd /DB/devel/headers/usr/lib
ln -s /cdrom/lib/libdl-2.23.so libdl.so
ldconfig
# you get :
ldconfig: File /usr/local/lib/libstdc++.so is empty, not checked.
ldconfig: File /usr/local/lib/libstdc++.so.6.0.10 is empty, not checked.
Move kernel source in place and compile it
cd /DB/devel/headers/usr/src
ln -s linux-4.1.15 linux-4.1.15-ZS
ln -s linux-4.1.15 linux
cd linux-4.1.15
make mrproper
zcat /proc/config.gz >.configIf you not upgrade kernel skip :
make oldconfig
make menuconfigCompile
make
Repeat same steps for the other kernel. However you will config file for 4.4.9 supplied on ZS upgrade.
Test on a module:
#### i2ccd /DB/devel/work
wget http://pcengines.ch/file/i2cpiix4.tar.gz
tar -xzvf i2cpiix4.tar.gz
cd i2cpiix4
modinfo i2c-piix4.ko
rmmod i2c-piix4
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
#make -C /DB/devel/headers/usr/src/linux-4.4.9/modules/lib/modules/4.4.9-ZS/build M=$(pwd) modules
insmod i2c-piix4.ko
mkdir modules
make INSTALL_MOD_PATH=modules/ modules_install
#command for running kernel
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
#command for different kernel
make -C /DB/devel/headers/usr/src/linux-4.4.9/modules/lib/modules/4.4.9-ZS/build M=$(pwd)
Test our work:
modinfo xxxx.ko
Make a switch to dev script
This environment is not permanent so after each reboot we need to recreate it:
First create a location
mkdir /DB/opt
vi /DB/opt/setDevEnv.shThen add:
#/bin/bash
mount /dev/sdb1 /DB/devel
ln -s /DB/devel /devel
#rm /usr
#ln -s /DB/devel/cdrom/usr /usr
PATH=/devel/headers/usr/bin:$PATHCall this script with
source /DB/opt/setDevEnv.sh
June 29, 2016 at 4:38 pm #54175DrmCa
ParticipantWow, great, I’ve been struggling with getting compilation environment up for so long and never had time to figure it out. Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.