Skip to content

Commit f0882e4

Browse files
committed
init
x86 works, uefi needs fixing
1 parent b4ed001 commit f0882e4

File tree

21 files changed

+2848
-0
lines changed

21 files changed

+2848
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*/extensions/*
2+
*/extensions64/*
3+
build/*
4+
5+
6+
*.iso

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
11
# TinyCore-Remaster-PHP
22
Simple PHP Script for creating custom tiny core images ( remastering )
3+
The images made through this script are PXE BOOTABLE.
4+
5+
`
6+
KERNEL /kernels/memdisk
7+
INITRD /images/you-tinycore.iso
8+
APPEND iso raw
9+
`
10+
11+
# usage
12+
0. Install Requirements
13+
1. Edit config.php
14+
2. Run php script
15+
`
16+
php -f build-tinycore.php
17+
`
18+
19+
or to specify arch. currently only x86 works.
20+
`
21+
php -f build-tinycore.php x86_64
22+
`
23+
24+
3. Enjoy
25+
26+
27+
28+
### requirements
29+
on the todo to make a list.
30+
31+
rsync
32+
xorriso
33+
advdef
34+
unsquashfs
35+
36+
### isohdpfx.bin
37+
this is from: apt-install isolinux && cp /usr/lib/ISOLINUX/isohdpfx.bin custom_image_files_64/bootfiles/isolinux/isohdpfx.bin
38+
put in repo for convenience.

build-tinycore-uefi.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
chdir(__DIR__);
4+
5+
function clean()
6+
{
7+
echo '==CLEAN==';
8+
echo shell_exec('rm -rf /tmp/newiso');
9+
echo shell_exec('sudo umount /mnt/tmp');
10+
echo shell_exec('rm -rf /mnt/tmp');
11+
echo shell_exec('rm -rf /tmp/extract');
12+
}
13+
14+
$fileDir = 'hn-specs64/';
15+
$iso = 'TinyCorePure64-13.1.iso';
16+
$outIso = '/tmp/tinycore-custom-uefi-hn-'.time().'.iso';
17+
$extensions = $fileDir.'extensions64';
18+
19+
clean();
20+
21+
echo PHP_EOL.'==EXTRACT=='.PHP_EOL;
22+
echo shell_exec('sudo mkdir /mnt/tmp');
23+
echo shell_exec('sudo mount '.$iso.' /mnt/tmp -o loop,ro');
24+
echo shell_exec('cp -a /mnt/tmp/boot /tmp');
25+
echo shell_exec('cp -a /mnt/tmp/cde /tmp');
26+
echo shell_exec('cp -a /mnt/tmp/EFI /tmp');
27+
echo shell_exec('mv /tmp/boot/corepure64.gz /tmp');
28+
echo shell_exec('sudo umount /mnt/tmp');
29+
30+
echo shell_exec('mkdir /tmp/extract');
31+
echo shell_exec('cd /tmp/extract && zcat /tmp/corepure64.gz | sudo cpio -i -H newc -d');
32+
33+
echo PHP_EOL.'==INSTALL EXTENSIONS=='.PHP_EOL;
34+
35+
$files = scandir($extensions);
36+
37+
foreach($files as $file)
38+
{
39+
$ext = pathinfo($file, PATHINFO_EXTENSION);
40+
if($ext == 'tcz')
41+
{
42+
echo 'Installing : '.$file.PHP_EOL;
43+
shell_exec('unsquashfs -f -d /tmp/extract '.$extensions.'/'.$file);
44+
}
45+
}
46+
47+
echo PHP_EOL.'==EDIT BOOT FILES=='.PHP_EOL;
48+
echo shell_exec('rsync -c -a '.$fileDir.'bootfiles64/ /tmp/boot');
49+
echo shell_exec('rsync -c -a '.$fileDir.'EFIfiles64/ /tmp/EFI');
50+
51+
echo PHP_EOL.'==EDIT FILES=='.PHP_EOL;
52+
echo shell_exec('rsync -c -a '.$fileDir.'files/ /tmp/extract');
53+
54+
55+
56+
#repacking
57+
echo PHP_EOL.'==PACKING corepure64.gz=='.PHP_EOL;
58+
echo shell_exec('sudo ldconfig -r /tmp/extract');
59+
60+
61+
echo shell_exec('sudo ldconfig -r /tmp/extract');
62+
echo shell_exec('cd /tmp/extract && sudo find | sudo cpio -o -H newc | gzip -2 > /tmp/corepure64.gz');
63+
64+
65+
echo PHP_EOL.'==REPACKING corepure64.gz=='.PHP_EOL;
66+
67+
//z4 for prod. z1 for dev
68+
echo shell_exec('cd /tmp/ && advdef -f -z4 /tmp/corepure64.gz');
69+
70+
71+
sleep(7);
72+
73+
#make iso
74+
echo PHP_EOL.'==MAKING ISO=='.PHP_EOL;
75+
//cd /tmp
76+
echo shell_exec('mv /tmp/corepure64.gz /tmp/boot');
77+
echo shell_exec('mkdir /tmp/newiso');
78+
echo shell_exec('mv /tmp/boot /tmp/newiso');
79+
echo shell_exec('mv /tmp/cde /tmp/newiso');
80+
echo shell_exec('mv /tmp/EFI /tmp/newiso');
81+
echo shell_exec('cp /usr/lib/ISOLINUX/isohdpfx.bin /tmp/newiso/boot/isolinux/isohdpfx.bin'); //requires apt-install isolinux
82+
//echo shell_exec('cd /tmp && mkisofs -l -J -R -V TC-custom -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o '.$outIso.' /tmp/newiso');
83+
echo shell_exec('cd /tmp/newiso && xorriso -as mkisofs -r -V "HN-Specs-TC64 UEFI" -o '.$outIso.' -isohybrid-mbr boot/isolinux/isohdpfx.bin -J -joliet-long -c boot/isolinux/boot.cat -b boot/isolinux/isolinux.bin -boot-load-size 4 -boot-info-table -no-emul-boot -eltorito-alt-boot -e "EFI/BOOT/efiboot.img" -no-emul-boot -isohybrid-gpt-basdat /tmp/newiso');
84+
85+
echo PHP_EOL.'==ISO CREATED=='.PHP_EOL;
86+
echo 'ISO: '.$outIso.PHP_EOL;
87+
88+
?>

build-tinycore.php

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
3+
//reqs
4+
//apt install mkisofs advancecomp
5+
6+
chdir(__DIR__);
7+
require_once('config.php');
8+
9+
$arch = 'x86';
10+
if(!empty($argv[1]))
11+
$arch = strtolower($argv[1]);
12+
13+
if(empty($_CONFIG[$arch]))
14+
{
15+
echo 'Invalid Arch; use: '.implode(',', array_keys($_CONFIG));
16+
exit;
17+
}
18+
19+
function clean()
20+
{
21+
global $_CONFIG;
22+
global $arch;
23+
24+
echo '==CLEAN==';
25+
echo shell_exec('rm -rf '.$_CONFIG[$arch]['temp_folder'].'/newiso');
26+
echo shell_exec('sudo umount '.$_CONFIG[$arch]['temp_mount']);
27+
echo shell_exec('rm -rf '.$_CONFIG[$arch]['temp_mount']);
28+
echo shell_exec('rm -rf '.$_CONFIG[$arch]['temp_folder'].'/extract');
29+
echo '==CLEAN DONE==';
30+
}
31+
32+
$fileDir = $_CONFIG[$arch]['files'];
33+
$outIso = $_CONFIG[$arch]['out_iso'];
34+
if(file_exists($outIso))
35+
{
36+
echo '==ISO EXISTS==';
37+
echo shell_exec('rm -rf '.$_CONFIG[$arch]['out_iso'].'');
38+
}
39+
40+
clean();
41+
42+
echo PHP_EOL.'==EXTRACT=='.PHP_EOL;
43+
echo shell_exec('sudo mkdir '.$_CONFIG[$arch]['temp_mount']);
44+
echo shell_exec('sudo mount '.$_CONFIG[$arch]['tinycore_iso'].' '.$_CONFIG[$arch]['temp_mount'].' -o loop,ro');
45+
echo shell_exec('cp -a '.$_CONFIG[$arch]['temp_mount'].'/boot /tmp');
46+
47+
#efi only
48+
if(is_dir($_CONFIG[$arch]['temp_mount'].'/cde'))
49+
echo shell_exec('cp -a '.$_CONFIG[$arch]['temp_mount'].'/cde /tmp');
50+
51+
if(is_dir($_CONFIG[$arch]['temp_mount'].'/EFI'))
52+
echo shell_exec('cp -a '.$_CONFIG[$arch]['temp_mount'].'/EFI /tmp');
53+
54+
55+
56+
echo shell_exec('mv '.$_CONFIG[$arch]['temp_folder'].'/boot/'.$_CONFIG[$arch]['core_file'].' '.$_CONFIG[$arch]['temp_folder'].'');
57+
echo shell_exec('sudo umount '.$_CONFIG[$arch]['temp_mount']);
58+
59+
echo shell_exec('mkdir '.$_CONFIG[$arch]['temp_folder'].'/extract');
60+
echo shell_exec('cd '.$_CONFIG[$arch]['temp_folder'].'/extract && zcat '.$_CONFIG[$arch]['temp_folder'].'/'.$_CONFIG[$arch]['core_file'].' | sudo cpio -i -H newc -d');
61+
62+
require_once('download_extensions.php');
63+
64+
echo PHP_EOL.'==INSTALL EXTENSIONS=='.PHP_EOL;
65+
66+
$files = scandir($_CONFIG[$arch]['extensions_folder']);
67+
68+
foreach($files as $file)
69+
{
70+
$ext = pathinfo($file, PATHINFO_EXTENSION);
71+
if($ext == 'tcz')
72+
{
73+
echo 'Installing : '.$file.PHP_EOL;
74+
shell_exec('unsquashfs -f -d '.$_CONFIG[$arch]['temp_folder'].'/extract '.$_CONFIG[$arch]['extensions_folder'].'/'.$file);
75+
}
76+
}
77+
78+
echo PHP_EOL.'==EDIT BOOT FILES=='.PHP_EOL;
79+
#/ is very important for rsync
80+
echo shell_exec('rsync -c -a '.$_CONFIG[$arch]['bootfiles'].'/ '.$_CONFIG[$arch]['temp_folder'].'/boot');
81+
if(!empty($_CONFIG[$arch]['efifiles']))
82+
echo shell_exec('rsync -c -a '.$_CONFIG[$arch]['efifiles'].'/ '.$_CONFIG[$arch]['temp_folder'].'/EFI');
83+
84+
85+
86+
echo PHP_EOL.'==EDIT FILES=='.PHP_EOL;
87+
echo shell_exec('rsync -c -a '.$_CONFIG[$arch]['files'].'/ '.$_CONFIG[$arch]['temp_folder'].'/extract');
88+
89+
90+
91+
if(!empty($_CONFIG[$arch]['sas_driver_hotfix']) && $_CONFIG[$arch]['sas_driver_hotfix'])
92+
{
93+
//driver hotfix
94+
echo PHP_EOL.'==MOVING DRIVERS=='.PHP_EOL;
95+
$tinyCoreKernel = '5.15.10-tinycore';
96+
shell_exec('mkdir '.$_CONFIG[$arch]['temp_folder'].'/extract/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi');
97+
shell_exec('cp -a '.$_CONFIG[$arch]['temp_folder'].'/extract/usr/local/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi/megaraid '.$extractDir.'/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi');
98+
shell_exec('cp -a '.$_CONFIG[$arch]['temp_folder'].'/extract/usr/local/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi/mpt3sas '.$extractDir.'/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi');
99+
shell_exec('cp -a '.$_CONFIG[$arch]['temp_folder'].'/extract/usr/local/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi/scsi_transport_sas.ko.gz '.$extractDir.'/lib/modules/'.$tinyCoreKernel.'/kernel/drivers/scsi');
100+
}
101+
102+
103+
#repacking
104+
echo PHP_EOL.'==PACKING '.$_CONFIG[$arch]['core_file'].'=='.PHP_EOL;
105+
echo shell_exec('sudo ldconfig -r '.$_CONFIG[$arch]['temp_folder'].'/extract');
106+
echo shell_exec('cd '.$_CONFIG[$arch]['temp_folder'].'/extract && sudo find | sudo cpio -o -H newc | gzip -2 > '.$_CONFIG[$arch]['temp_folder'].'/'.$_CONFIG[$arch]['core_file']);
107+
108+
echo PHP_EOL.'==REPACKING '.$_CONFIG[$arch]['core_file'].'=='.PHP_EOL;
109+
//z4 for prod. z0 for dev
110+
echo shell_exec('cd '.$_CONFIG[$arch]['temp_folder'].'/ && advdef -f -z'.compression_level.' '.$_CONFIG[$arch]['temp_folder'].'/'.$_CONFIG[$arch]['core_file']);
111+
112+
113+
sleep(7);
114+
115+
#make iso
116+
echo PHP_EOL.'==MAKING ISO=='.PHP_EOL;
117+
//cd /tmp
118+
echo shell_exec('mv '.$_CONFIG[$arch]['temp_folder'].'/'.$_CONFIG[$arch]['core_file'].' '.$_CONFIG[$arch]['temp_folder'].'/boot');
119+
echo shell_exec('mkdir '.$_CONFIG[$arch]['temp_folder'].'/newiso');
120+
echo shell_exec('mv '.$_CONFIG[$arch]['temp_folder'].'/boot '.$_CONFIG[$arch]['temp_folder'].'/newiso');
121+
122+
123+
124+
if($arch == 'x86_64')
125+
{
126+
echo shell_exec('mv '.$_CONFIG[$arch]['temp_folder'].'/cde '.$_CONFIG[$arch]['temp_folder'].'/newiso');
127+
echo shell_exec('mv '.$_CONFIG[$arch]['temp_folder'].'/EFI '.$_CONFIG[$arch]['temp_folder'].'/newiso');
128+
//uefi version
129+
echo shell_exec('cd '.$_CONFIG[$arch]['temp_folder'].' && xorriso -as mkisofs -r -V "'.$_CONFIG[$arch]['image_name'].'" -o '.$outIso.' -isohybrid-mbr newiso/boot/isolinux/isohdpfx.bin -J -joliet-long -c boot/isolinux/boot.cat -b boot/isolinux/isolinux.bin -boot-load-size 4 -boot-info-table -no-emul-boot -eltorito-alt-boot -e "EFI/BOOT/efiboot.img" -no-emul-boot -isohybrid-gpt-basdat '.$_CONFIG[$arch]['temp_folder'].'/newiso');
130+
}
131+
else
132+
echo shell_exec('cd '.$_CONFIG[$arch]['temp_folder'].' && mkisofs -l -J -R -V "'.$_CONFIG[$arch]['image_name'].'" -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o '.$outIso.' '.$_CONFIG[$arch]['temp_folder'].'/newiso');
133+
134+
if(file_exists($outIso))
135+
{
136+
clean();
137+
138+
echo PHP_EOL.'==ISO CREATED=='.PHP_EOL;
139+
echo 'ISO: '.$outIso.PHP_EOL;
140+
exit;
141+
}
142+
143+
echo PHP_EOL.'==FAILED TO CREATE ISO=='.PHP_EOL;
144+
145+
146+
147+
?>

compile_extensions/sedutils.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
//compile sed utils to make tcz package.
4+
//run in tinycore.
5+
6+
7+
shell_exec('mkdir /tmp/sedutils/');
8+
shell_exec('cd /tmp/sedutils/');
9+
/**
10+
* #install dependancies
11+
* tce-load -wi autoconf automake m4 util-macros libtool-dev gcc sed squashfs-tools compiletc
12+
13+
*
14+
* mkdir /tmp/sedutils/
15+
* git clone https://github.com/Drive-Trust-Alliance/sedutil.git
16+
* cd sedutil
17+
* autoreconf -i
18+
* ./configure --enable-silent-rules
19+
* make
20+
*
21+
* mkdir -p /tmp/sedutils_ext/usr/local/bin
22+
* cp /tmp/sedutils/sedutil/sedutil-cli /tmp/sedutils_ext/usr/local/bin
23+
* cp /tmp/sedutils/sedutil/sedutil-cli /usr/local/bin
24+
*
25+
* mksquashfs /tmp/sedutils_ext sedutil.tcz
26+
* https://inventory.era.ca/share/tinycore/sedutil.tcz
27+
*/
28+
?>

config.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
define('image_name', 'HotNoob 2024');
4+
define('compression_level', 0); //0 for quick testing, 4 for max
5+
6+
7+
#region x86 config
8+
$c_arch = 'x86';
9+
$_CONFIG[$c_arch]['tinycore_iso'] = 'tinycore.iso';
10+
$_CONFIG[$c_arch]['tinycore_version'] = '13.x';
11+
12+
$_CONFIG[$c_arch]['out_iso'] = '/tmp/hn-custom_tinycore-image.iso';
13+
$_CONFIG[$c_arch]['image_name'] = image_name.' x86';
14+
15+
$_CONFIG[$c_arch]['temp_folder'] = '/tmp';
16+
$_CONFIG[$c_arch]['temp_mount'] = '/mnt/tmp'; #where tinycore image gets mounted to
17+
18+
define('folder_x86', 'custom_image_files'); #only used for config below
19+
$_CONFIG[$c_arch]['files'] = folder_x86.'/files';
20+
$_CONFIG[$c_arch]['bootfiles'] = folder_x86.'/bootfiles';
21+
$_CONFIG[$c_arch]['extensions_folder'] = folder_x86.'/extensions';
22+
$_CONFIG[$c_arch]['extensions_txt'] = folder_x86.'/extensions.txt';
23+
24+
$_CONFIG[$c_arch]['core_file'] = 'core.gz';
25+
$_CONFIG[$c_arch]['sas_driver_hotfix'] = false;
26+
27+
#endregion x86
28+
29+
#region x64 config
30+
//x64 config / uefi image
31+
$c_arch = 'x86_64';
32+
$_CONFIG[$c_arch]['tinycore_iso'] = 'TinyCorePure64-13.1.iso';
33+
$_CONFIG[$c_arch]['tinycore_version'] = '13.x';
34+
35+
$_CONFIG[$c_arch]['out_iso'] = '/tmp/hn-custom_tinycore-image-64.iso';
36+
$_CONFIG[$c_arch]['image_name'] = image_name.' x64 UEFI';
37+
38+
$_CONFIG[$c_arch]['temp_folder'] = '/tmp';
39+
$_CONFIG[$c_arch]['temp_mount'] = '/mnt/tmp'; #where tinycore image gets mounted to
40+
41+
define('folder_x86_64', 'custom_image_files_64'); #only used for config below
42+
$_CONFIG[$c_arch]['bootfiles'] = folder_x86_64.'/bootfiles';
43+
$_CONFIG[$c_arch]['efifiles'] = folder_x86_64.'/EFIfiles';
44+
$_CONFIG[$c_arch]['extensions_folder'] = folder_x86_64.'/extensions';
45+
$_CONFIG[$c_arch]['extensions_txt'] = folder_x86_64.'/extensions.txt';
46+
47+
#using files dir for 32bit config
48+
$_CONFIG[$c_arch]['files'] = folder_x86.'/files';
49+
50+
$_CONFIG[$c_arch]['core_file'] = 'corepure64.gz';
51+
$_CONFIG[$c_arch]['sas_driver_hotfix'] = false;
52+
53+
#endregion x64 config
54+
55+
?>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
( '>')
3+
/) TC (\ TinyCore Linux
4+
(/-_--_-\) HotNoob Was Here 2022
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
display boot.msg
2+
default microcore
3+
label microcore
4+
kernel /boot/vmlinuz
5+
initrd /boot/core.gz
6+
append loglevel=3
7+
8+
label mc
9+
kernel /boot/vmlinuz
10+
append initrd=/boot/core.gz loglevel=3
11+
implicit 0
12+
prompt 0
13+
timeout 0
14+
F1 boot.msg
15+
F2 f2
16+
F3 f3
17+
F4 f4

0 commit comments

Comments
 (0)