169eead77SJean-Baptiste Boric 269eead77SJean-Baptiste Boric# 369eead77SJean-Baptiste Boric# spec file handling 469eead77SJean-Baptiste Boric# 569eead77SJean-Baptiste Boric 669eead77SJean-Baptiste Boric# 769eead77SJean-Baptiste Boric# Add a directory to a spec file 869eead77SJean-Baptiste Boric# 969eead77SJean-Baptiste Boric# $1 : directory to add 1069eead77SJean-Baptiste Boric# $2 : spec file 11a7a79fa1SJean-Baptiste Boricadd_dir_spec() 12a7a79fa1SJean-Baptiste Boric{ 1369eead77SJean-Baptiste Boric echo "./$1 type=dir uid=0 gid=0 mode=0755" >> ${WORK_DIR}/$2 1469eead77SJean-Baptiste Boric} 1569eead77SJean-Baptiste Boric 1669eead77SJean-Baptiste Boric# 1769eead77SJean-Baptiste Boric# Add a file to a spec file 1869eead77SJean-Baptiste Boric# 1969eead77SJean-Baptiste Boric# $1 : file to add 2069eead77SJean-Baptiste Boric# $2 : spec file 21a7a79fa1SJean-Baptiste Boricadd_file_spec() 22a7a79fa1SJean-Baptiste Boric{ 2369eead77SJean-Baptiste Boric echo "./$1 type=file uid=0 gid=0 mode=0755 size=$(wc -c < ${ROOT_DIR}/${1})" >> ${WORK_DIR}/$2 2469eead77SJean-Baptiste Boric} 2569eead77SJean-Baptiste Boric 2669eead77SJean-Baptiste Boric# 2769eead77SJean-Baptiste Boric# Add a symbolic link to a spec file 2869eead77SJean-Baptiste Boric# 2969eead77SJean-Baptiste Boric# $1 : symlink to add 3069eead77SJean-Baptiste Boric# $2 : link to 3169eead77SJean-Baptiste Boric# $3 : spec file 32a7a79fa1SJean-Baptiste Boricadd_link_spec() 33a7a79fa1SJean-Baptiste Boric{ 3469eead77SJean-Baptiste Boric echo "./$1 type=link uid=0 gid=0 mode=0755 link=$2" >> ${WORK_DIR}/$3 3569eead77SJean-Baptiste Boric} 3669eead77SJean-Baptiste Boric 3769eead77SJean-Baptiste Boric# 3869eead77SJean-Baptiste Boric# workdir handling 3969eead77SJean-Baptiste Boric# 4069eead77SJean-Baptiste Boric 4169eead77SJean-Baptiste Boric# 4269eead77SJean-Baptiste Boric# Create the workdir (a directory where Minix is built using sets) 4369eead77SJean-Baptiste Boric# spec files are put in WORK_DIR, the file system created in ROOT_DIR 4469eead77SJean-Baptiste Boric# 4569eead77SJean-Baptiste Boric# $1 : sets to extract 46a7a79fa1SJean-Baptiste Boricbuild_workdir() 47a7a79fa1SJean-Baptiste Boric{ 482d6bbeb0SJean-Baptiste Boric mkdir -p ${ROOT_DIR} 49*0884854aSJean-Baptiste Boric 50*0884854aSJean-Baptiste Boric # Don't do anything if we don't use sets 51*0884854aSJean-Baptiste Boric if [ -n "$1" ] 52*0884854aSJean-Baptiste Boric then 53*0884854aSJean-Baptiste Boric # Extract sets 5469eead77SJean-Baptiste Boric for set in $1; do 5569eead77SJean-Baptiste Boric if [ ! -e ${SETS_DIR}/${set}.tgz ]; then 5669eead77SJean-Baptiste Boric echo "Missing ${SETS_DIR}/${set}.tgz, aborting" 5769eead77SJean-Baptiste Boric echo "Are the release sets tarballs created?" 5869eead77SJean-Baptiste Boric exit 1 5969eead77SJean-Baptiste Boric fi 6069eead77SJean-Baptiste Boric echo " * Extracting $set..." 6169eead77SJean-Baptiste Boric (cd ${ROOT_DIR}; ${CROSS_TOOLS}/nbpax -rnz -f ${SETS_DIR}/${set}.tgz .) 6269eead77SJean-Baptiste Boric done 6369eead77SJean-Baptiste Boric 642d6bbeb0SJean-Baptiste Boric # add rc (if any) 652d6bbeb0SJean-Baptiste Boric if [ -f ${RC} ]; then 662d6bbeb0SJean-Baptiste Boric cp ${RC} ${ROOT_DIR}/usr/etc/rc.local 672d6bbeb0SJean-Baptiste Boric fi 682d6bbeb0SJean-Baptiste Boric 6969eead77SJean-Baptiste Boric # Build login/password files 7069eead77SJean-Baptiste Boric ${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d ${ROOT_DIR} ${ROOT_DIR}/etc/master.passwd 7169eead77SJean-Baptiste Boric 7269eead77SJean-Baptiste Boric # Build specifications files 7369eead77SJean-Baptiste Boric cp ${ROOT_DIR}/etc/mtree/set* ${WORK_DIR} 7469eead77SJean-Baptiste Boric ${ROOT_DIR}/usr/bin/MAKEDEV -s -m all >> ${WORK_DIR}/extra.dev 75*0884854aSJean-Baptiste Boric fi 76a7a79fa1SJean-Baptiste Boric 77a7a79fa1SJean-Baptiste Boric if [ ${BUNDLE_SETS} -eq 1 ] 78a7a79fa1SJean-Baptiste Boric then 79a7a79fa1SJean-Baptiste Boric echo " * Bundling sets..." 80a7a79fa1SJean-Baptiste Boric workdir_add_sets 81a7a79fa1SJean-Baptiste Boric fi 8269eead77SJean-Baptiste Boric} 8369eead77SJean-Baptiste Boric 8469eead77SJean-Baptiste Boric# 8569eead77SJean-Baptiste Boric# Add tarball sets to the workdir (for installation CD) 8669eead77SJean-Baptiste Boric# 87a7a79fa1SJean-Baptiste Boricworkdir_add_sets() 88a7a79fa1SJean-Baptiste Boric{ 8969eead77SJean-Baptiste Boric # Add sets to the root 90a7a79fa1SJean-Baptiste Boric mkdir -p ${ROOT_DIR}/usr/${ARCH}/binary/sets; 91a7a79fa1SJean-Baptiste Boric add_dir_spec "usr/${ARCH}" extra.sets 92a7a79fa1SJean-Baptiste Boric add_dir_spec "usr/${ARCH}/binary" extra.sets 93a7a79fa1SJean-Baptiste Boric add_dir_spec "usr/${ARCH}/binary/sets" extra.sets 9469eead77SJean-Baptiste Boric 95a7a79fa1SJean-Baptiste Boric add_link_spec "${ARCH}" "usr/${ARCH}" extra.sets 96a7a79fa1SJean-Baptiste Boric 97a7a79fa1SJean-Baptiste Boric DEST_SETS_DIR="usr/${ARCH}/binary/sets" 9869eead77SJean-Baptiste Boric for set in ${SETS_DIR}/*.tgz; do 9969eead77SJean-Baptiste Boric # Copy set itself 10069eead77SJean-Baptiste Boric cp ${set} ${ROOT_DIR}/${DEST_SETS_DIR} 10169eead77SJean-Baptiste Boric add_file_spec "${DEST_SETS_DIR}/$(basename ${set})" extra.sets 10269eead77SJean-Baptiste Boric 10369eead77SJean-Baptiste Boric # Add file count 10469eead77SJean-Baptiste Boric COUNT_SRC=$(echo $(basename ${set}) | sed -e "s/\(.*\)\.tgz/\set.\1/") 10569eead77SJean-Baptiste Boric COUNT_NAME=$(echo $(basename ${set}) | sed -e "s/\.tgz/\.count/") 10669eead77SJean-Baptiste Boric if [ -e "${DESTDIR}/etc/mtree/${COUNT_SRC}" ] 10769eead77SJean-Baptiste Boric then 10869eead77SJean-Baptiste Boric wc -l < ${DESTDIR}/etc/mtree/${COUNT_SRC} > ${ROOT_DIR}/${DEST_SETS_DIR}/${COUNT_NAME} 10969eead77SJean-Baptiste Boric else 11069eead77SJean-Baptiste Boric # Can't find mtree file, set bogus number 11169eead77SJean-Baptiste Boric echo 1 > ${ROOT_DIR}/${DEST_SETS_DIR}/${COUNT_NAME} 11269eead77SJean-Baptiste Boric fi 11369eead77SJean-Baptiste Boric add_file_spec "${DEST_SETS_DIR}/${COUNT_NAME}" extra.sets 1140a6a1f1dSLionel Sambuc 1150a6a1f1dSLionel Sambuc # Add file sizes 1160a6a1f1dSLionel Sambuc SIZE_NAME=$(echo $(basename ${set}) | sed -e "s/\.tgz/\.size/") 1170a6a1f1dSLionel Sambuc ${CROSS_TOOLS}/nbpax -zvf ${set} . |grep -v 'bytes written in 1 secs [(]' | ${CROSS_TOOLS}/nbawk '{s+=$5} END{print s}' > ${ROOT_DIR}/${DEST_SETS_DIR}/${SIZE_NAME} 1180a6a1f1dSLionel Sambuc add_file_spec "${DEST_SETS_DIR}/${SIZE_NAME}" extra.sets 11969eead77SJean-Baptiste Boric done 12069eead77SJean-Baptiste Boric 12169eead77SJean-Baptiste Boric # Add checksums 12269eead77SJean-Baptiste Boric cp ${SETS_DIR}/MD5 ${ROOT_DIR}/${DEST_SETS_DIR} 12369eead77SJean-Baptiste Boric add_file_spec "${DEST_SETS_DIR}/MD5" extra.sets 12469eead77SJean-Baptiste Boric cp ${SETS_DIR}/SHA512 ${ROOT_DIR}/${DEST_SETS_DIR} 12569eead77SJean-Baptiste Boric add_file_spec "${DEST_SETS_DIR}/SHA512" extra.sets 12669eead77SJean-Baptiste Boric} 12769eead77SJean-Baptiste Boric 12869eead77SJean-Baptiste Boric# 129a7a79fa1SJean-Baptiste Boric# Add HDD files to the workdir 130a7a79fa1SJean-Baptiste Boric# 131a7a79fa1SJean-Baptiste Boricworkdir_add_hdd_files() 132a7a79fa1SJean-Baptiste Boric{ 133a7a79fa1SJean-Baptiste Boric # create a fstab entry in /etc 134a7a79fa1SJean-Baptiste Boric cat >${ROOT_DIR}/etc/fstab <<END_FSTAB 135a7a79fa1SJean-Baptiste Boric/dev/c0d0p1 /usr mfs rw 0 2 136a7a79fa1SJean-Baptiste Boric/dev/c0d0p2 /home mfs rw 0 2 137a7a79fa1SJean-Baptiste Boricnone /sys devman rw,rslabel=devman 0 0 138a7a79fa1SJean-Baptiste Boricnone /dev/pts ptyfs rw,rslabel=ptyfs 0 0 139a7a79fa1SJean-Baptiste BoricEND_FSTAB 140a7a79fa1SJean-Baptiste Boric add_file_spec "etc/fstab" extra.fstab 141a7a79fa1SJean-Baptiste Boric 142a7a79fa1SJean-Baptiste Boric # Add boot monitor 143a7a79fa1SJean-Baptiste Boric cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/boot_monitor 144a7a79fa1SJean-Baptiste Boric add_file_spec "boot_monitor" extra.boot 145a7a79fa1SJean-Baptiste Boric} 146a7a79fa1SJean-Baptiste Boric 147a7a79fa1SJean-Baptiste Boric# 14869eead77SJean-Baptiste Boric# Add CD boot files to the workdir 14969eead77SJean-Baptiste Boric# 150a7a79fa1SJean-Baptiste Boricworkdir_add_cd_files() 151a7a79fa1SJean-Baptiste Boric{ 152a7a79fa1SJean-Baptiste Boric # create a fstab entry in /etc 153a7a79fa1SJean-Baptiste Boric cat >${ROOT_DIR}/etc/fstab <<END_FSTAB 154a7a79fa1SJean-Baptiste Boricnone /sys devman rw,rslabel=devman 0 0 155a7a79fa1SJean-Baptiste Boricnone /dev/pts ptyfs rw,rslabel=ptyfs 0 0 156a7a79fa1SJean-Baptiste BoricEND_FSTAB 157a7a79fa1SJean-Baptiste Boric add_file_spec "etc/fstab" extra.fstab 158a7a79fa1SJean-Baptiste Boric 15969eead77SJean-Baptiste Boric # Add boot monitor 16069eead77SJean-Baptiste Boric cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/minixboot 16169eead77SJean-Baptiste Boric add_file_spec "minixboot" extra.cdfiles 16269eead77SJean-Baptiste Boric 16369eead77SJean-Baptiste Boric # Add README 16469eead77SJean-Baptiste Boric cp releasetools/release/cd/README.TXT ${ROOT_DIR}/README.TXT 16569eead77SJean-Baptiste Boric add_file_spec "README.TXT" extra.cdfiles 16669eead77SJean-Baptiste Boric} 16769eead77SJean-Baptiste Boric 16869eead77SJean-Baptiste Boric# 169a7a79fa1SJean-Baptiste Boric# Add ramdisk files to the workdir 170a7a79fa1SJean-Baptiste Boric# 171a7a79fa1SJean-Baptiste Boricworkdir_add_ramdisk_files() 172a7a79fa1SJean-Baptiste Boric{ 173a7a79fa1SJean-Baptiste Boric # create a fstab entry in /etc 174a7a79fa1SJean-Baptiste Boric cat >${ROOT_DIR}/etc/fstab <<END_FSTAB 175a7a79fa1SJean-Baptiste Boricnone /sys devman rw,rslabel=devman 0 0 176a7a79fa1SJean-Baptiste Boricnone /dev/pts ptyfs rw,rslabel=ptyfs 0 0 177a7a79fa1SJean-Baptiste BoricEND_FSTAB 178a7a79fa1SJean-Baptiste Boric add_file_spec "etc/fstab" extra.fstab 179a7a79fa1SJean-Baptiste Boric 180a7a79fa1SJean-Baptiste Boric # add early boot rc script 181a7a79fa1SJean-Baptiste Boric cp minix/drivers/storage/ramdisk/rc ${ROOT_DIR}/etc/rc.ramdisk 182a7a79fa1SJean-Baptiste Boric add_file_spec "etc/rc.ramdisk" extra.fstab 183a7a79fa1SJean-Baptiste Boric 184a7a79fa1SJean-Baptiste Boric # Add README 185a7a79fa1SJean-Baptiste Boric cp releasetools/release/cd/README.TXT ${ROOT_DIR}/README.TXT 186a7a79fa1SJean-Baptiste Boric add_file_spec "README.TXT" extra.cdfiles 187a7a79fa1SJean-Baptiste Boric} 188a7a79fa1SJean-Baptiste Boric 189a7a79fa1SJean-Baptiste Boric# 19069eead77SJean-Baptiste Boric# Extract kernel to designated directory 19169eead77SJean-Baptiste Boric# 19269eead77SJean-Baptiste Boric# $1: Directory where to extract 19369eead77SJean-Baptiste Boricworkdir_add_kernel() 19469eead77SJean-Baptiste Boric{ 19569eead77SJean-Baptiste Boric (cd ${ROOT_DIR}; ${CROSS_TOOLS}/nbpax -rnz -f ${SETS_DIR}/minix-kernel.tgz .) 19669eead77SJean-Baptiste Boric 19769eead77SJean-Baptiste Boric # Move kernel files to the correct directory 19869eead77SJean-Baptiste Boric if [ ! -d ${ROOT_DIR}/boot/$1 ] 19969eead77SJean-Baptiste Boric then 2002d6bbeb0SJean-Baptiste Boric mkdir -p ${ROOT_DIR}/boot/$1 20169eead77SJean-Baptiste Boric add_dir_spec "boot/$1" extra.kernel 20269eead77SJean-Baptiste Boric fi 20369eead77SJean-Baptiste Boric 20469eead77SJean-Baptiste Boric mv ${ROOT_DIR}/boot/minix/.temp/* ${ROOT_DIR}/boot/$1 20569eead77SJean-Baptiste Boric rm -rf ${ROOT_DIR}/boot/minix/.temp 20669eead77SJean-Baptiste Boric for i in $(cd ${ROOT_DIR}/boot/$1 && echo *) 20769eead77SJean-Baptiste Boric do 20869eead77SJean-Baptiste Boric add_file_spec "boot/$1/$i" extra.kernel 20969eead77SJean-Baptiste Boric done 21069eead77SJean-Baptiste Boric} 21169eead77SJean-Baptiste Boric 21269eead77SJean-Baptiste Boric# 21369eead77SJean-Baptiste Boric# Read METALOG and use mtree to convert the user and group names into uid and gids. 21469eead77SJean-Baptiste Boric# Used as the reference mtree for building file systems. 21569eead77SJean-Baptiste Boric# 21669eead77SJean-Baptiste Boriccreate_input_spec() 21769eead77SJean-Baptiste Boric{ 218*0884854aSJean-Baptiste Boric if [ -n "$SETS" ] 219*0884854aSJean-Baptiste Boric then 22069eead77SJean-Baptiste Boric cat ${WORK_DIR}/set* ${WORK_DIR}/extra* | ${CROSS_TOOLS}/nbmtree -N ${ROOT_DIR}/etc -C -K device > ${WORK_DIR}/input 221*0884854aSJean-Baptiste Boric else 222*0884854aSJean-Baptiste Boric cat ${WORK_DIR}/extra* | ${CROSS_TOOLS}/nbmtree -C > ${WORK_DIR}/input 223*0884854aSJean-Baptiste Boric fi 22469eead77SJean-Baptiste Boric 22569eead77SJean-Baptiste Boric if [ ${ASR_HACK} -eq 1 ] 22669eead77SJean-Baptiste Boric then 22769eead77SJean-Baptiste Boric # Hacky workaround for ASR-randomized service binaries since they don't get nicely packaged in a tarball 22872965c88SDavid van Moolenbroek # add any generated ASR-randomized service binaries 22969eead77SJean-Baptiste Boric # TODO: apply stricter file permissions for both these and the base /service binaries, against local attacks 23069eead77SJean-Baptiste Boric (cd ${DESTDIR} && find ./usr/service/asr -type f | sed 's/$/ type=file uid=0 gid=0 mode=0755/') >> ${WORK_DIR}/input 23169eead77SJean-Baptiste Boric cp -r ${DESTDIR}/usr/service/asr ${ROOT_DIR}/usr/service 23269eead77SJean-Baptiste Boric fi 23369eead77SJean-Baptiste Boric} 23469eead77SJean-Baptiste Boric 23569eead77SJean-Baptiste Boric# 23669eead77SJean-Baptiste Boric# Split mtree into partitions and create proto files for nbmkfs.mfs 23769eead77SJean-Baptiste Boric# 23869eead77SJean-Baptiste Boric# $1 : partitions to create (example: usr home) 23969eead77SJean-Baptiste Boriccreate_protos() 24069eead77SJean-Baptiste Boric{ 24169eead77SJean-Baptiste Boric # build filter 24269eead77SJean-Baptiste Boric FILTER_COMMAND="cat ${WORK_DIR}/input" 24369eead77SJean-Baptiste Boric for i in $1 24469eead77SJean-Baptiste Boric do 24569eead77SJean-Baptiste Boric FILTER_COMMAND="$FILTER_COMMAND | grep -v \"^./$i/\" " 24669eead77SJean-Baptiste Boric done 24769eead77SJean-Baptiste Boric 24869eead77SJean-Baptiste Boric # fill root.img (skipping entries inside partitions while keeping partition mount points) 24969eead77SJean-Baptiste Boric eval $FILTER_COMMAND | ${CROSS_TOOLS}/nbtoproto -b ${ROOT_DIR} -o ${WORK_DIR}/proto.root 25069eead77SJean-Baptiste Boric 25169eead77SJean-Baptiste Boric # create proto files for partitions using toproto 25269eead77SJean-Baptiste Boric for i in $1 25369eead77SJean-Baptiste Boric do 25469eead77SJean-Baptiste Boric cat ${WORK_DIR}/input | grep "^\./$i/\|^. " | sed "s,\./$i,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${ROOT_DIR}/$i -o ${WORK_DIR}/proto.$i 25569eead77SJean-Baptiste Boric done 25669eead77SJean-Baptiste Boric} 25769eead77SJean-Baptiste Boric 25869eead77SJean-Baptiste Boric# 2591717959aSRalf Neeb# Clone grub repository and build efi boot binary 2601717959aSRalf Neeb# 2611717959aSRalf Neebfetch_and_build_grub() 2621717959aSRalf Neeb{ 2631717959aSRalf Neeb if [ -d ${RELEASETOOLSDIR}/grub ] 2641717959aSRalf Neeb then 2651717959aSRalf Neeb echo grub is already checked out 2661717959aSRalf Neeb else 2671717959aSRalf Neeb git clone git://git.savannah.gnu.org/grub.git ${RELEASETOOLSDIR}/grub 2681717959aSRalf Neeb pushd ${RELEASETOOLSDIR}/grub 2691717959aSRalf Neeb # most recent known working commit at the time of writing 270702ec740Srlfnb git checkout a0bf403f66dbaca4edd8e667bfc397dd91c8d71c 2711717959aSRalf Neeb ./autogen.sh 2721717959aSRalf Neeb ./configure --with-platform=efi --target=i386 2731717959aSRalf Neeb make clean 2741717959aSRalf Neeb make -j ${JOBS} 2751717959aSRalf Neeb cd grub-core 2761717959aSRalf Neeb ../grub-mkimage -v -d . -o booti386.efi -O i386-efi -p /boot/efi normal part_msdos fat chain boot configfile multiboot minix3 gzio efi_uga 2771717959aSRalf Neeb ls -l booti386.efi 2781717959aSRalf Neeb popd 2791717959aSRalf Neeb fi 2801717959aSRalf Neeb} 2811717959aSRalf Neeb 2821717959aSRalf Neeb# 2831717959aSRalf Neeb# Create grub.cfg for efi boot 2841717959aSRalf Neeb# 2851717959aSRalf Neebcreate_grub_cfg() 2861717959aSRalf Neeb{ 2871717959aSRalf Neeb cat > ${EFI_DIR}/boot/efi/grub.cfg <<END_GRUBCFG 2881717959aSRalf Neeb 2891717959aSRalf Neebinsmod serial 2901717959aSRalf Neebinsmod minix3 2911717959aSRalf Neebinsmod gzio 2921717959aSRalf Neeb#insmod efi_uga 2931717959aSRalf Neeb#insmod video_fb 2941717959aSRalf Neebinsmod all_video 2951717959aSRalf Neeb 2961717959aSRalf Neebset timeout=30 2971717959aSRalf Neebset default=0 2981717959aSRalf Neeb 2991717959aSRalf Neebset gfxmode=text 3001717959aSRalf Neeb 3011717959aSRalf Neebmenuentry "Minix Boot" { 3021717959aSRalf Neeb set root=(hd0,1) 3031717959aSRalf Neeb multiboot /boot/minix_default/kernel rootdevname=c0d0p0 3041717959aSRalf Neeb module /boot/minix_default/mod01_ds 3051717959aSRalf Neeb module /boot/minix_default/mod02_rs 3061717959aSRalf Neeb module /boot/minix_default/mod03_pm 3071717959aSRalf Neeb module /boot/minix_default/mod04_sched 3081717959aSRalf Neeb module /boot/minix_default/mod05_vfs 3091717959aSRalf Neeb module /boot/minix_default/mod06_memory 3101717959aSRalf Neeb module /boot/minix_default/mod07_tty 3111717959aSRalf Neeb module /boot/minix_default/mod08_mib 3121717959aSRalf Neeb module /boot/minix_default/mod09_vm 3131717959aSRalf Neeb module /boot/minix_default/mod10_pfs 3141717959aSRalf Neeb module /boot/minix_default/mod11_mfs 3151717959aSRalf Neeb module /boot/minix_default/mod12_init 3161717959aSRalf Neeb} 3171717959aSRalf Neeb 3181717959aSRalf Neebmenuentry "Minix Boot (serial)" { 3191717959aSRalf Neeb set root=(hd0,1) 3201717959aSRalf Neeb multiboot /boot/minix_default/kernel rootdevname=c0d0p0 cttyline=0 ttybaud=115200 console=tty00 consdev=com0 3211717959aSRalf Neeb module /boot/minix_default/mod01_ds 3221717959aSRalf Neeb module /boot/minix_default/mod02_rs 3231717959aSRalf Neeb module /boot/minix_default/mod03_pm 3241717959aSRalf Neeb module /boot/minix_default/mod04_sched 3251717959aSRalf Neeb module /boot/minix_default/mod05_vfs 3261717959aSRalf Neeb module /boot/minix_default/mod06_memory 3271717959aSRalf Neeb module /boot/minix_default/mod07_tty 3281717959aSRalf Neeb module /boot/minix_default/mod08_mib 3291717959aSRalf Neeb module /boot/minix_default/mod09_vm 3301717959aSRalf Neeb module /boot/minix_default/mod10_pfs 3311717959aSRalf Neeb module /boot/minix_default/mod11_mfs 3321717959aSRalf Neeb module /boot/minix_default/mod12_init 3331717959aSRalf Neeb} 3341717959aSRalf NeebEND_GRUBCFG 3351717959aSRalf Neeb} 3361717959aSRalf Neeb 3371717959aSRalf Neeb# 338a7a79fa1SJean-Baptiste Boric# Create ramdisk image from root directory 339a7a79fa1SJean-Baptiste Boric# 340a7a79fa1SJean-Baptiste Boric# $1 : size of ramdisk (optional) 341a7a79fa1SJean-Baptiste Boriccreate_ramdisk_image() 342a7a79fa1SJean-Baptiste Boric{ 343a7a79fa1SJean-Baptiste Boric PATH=$(cd ${CROSS_TOOLS}; pwd):$PATH 344a7a79fa1SJean-Baptiste Boric if [ -z $1 ] 345a7a79fa1SJean-Baptiste Boric then 346a7a79fa1SJean-Baptiste Boric RAMSIZE="-x 5" 347a7a79fa1SJean-Baptiste Boric else 348a7a79fa1SJean-Baptiste Boric RAMSIZE="-b $(( $1 / 512 / 8))" 349a7a79fa1SJean-Baptiste Boric fi 350a7a79fa1SJean-Baptiste Boric 351a7a79fa1SJean-Baptiste Boric # Build image 352a7a79fa1SJean-Baptiste Boric _RAMDISKSIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${RAMSIZE} -I 0 ${WORK_DIR}/imgrd.mfs ${WORK_DIR}/proto.root) 353a7a79fa1SJean-Baptiste Boric (cd ${WORK_DIR}; ${TOOLCHAIN_TRIPLET}objcopy -Ibinary -Bi386 -Oi586-elf32-minix imgrd.mfs imgrd.o) 354a7a79fa1SJean-Baptiste Boric ${TOOLCHAIN_TRIPLET}clang --sysroot=${DESTDIR} -L ${DESTDIR}/usr/lib -static -o ${WORK_DIR}/mod06_memory ${OBJ}/minix/drivers/storage/memory/memory.o ${WORK_DIR}/imgrd.o -nodefaultlibs -lblockdriver -lchardriver -lsys -lminc 355a7a79fa1SJean-Baptiste Boric} 356a7a79fa1SJean-Baptiste Boric 357a7a79fa1SJean-Baptiste Boric# 35869eead77SJean-Baptiste Boric# Bundle packages (won't preinstall them) 35969eead77SJean-Baptiste Boric# 36069eead77SJean-Baptiste Boric# $1 : packages to bundle 36169eead77SJean-Baptiste Boricbundle_packages() 36269eead77SJean-Baptiste Boric{ 363*0884854aSJean-Baptiste Boric if [ -z $PACKAGE_DIR ] 36469eead77SJean-Baptiste Boric then 365*0884854aSJean-Baptiste Boric echo " * PACKAGE_DIR not set, skipping package bundling..." 36669eead77SJean-Baptiste Boric return 36769eead77SJean-Baptiste Boric fi 36869eead77SJean-Baptiste Boric 369*0884854aSJean-Baptiste Boric if [ ! -x "$(which $PKG_INFO)" ] 37069eead77SJean-Baptiste Boric then 371*0884854aSJean-Baptiste Boric echo "Error: PKG_INFO ("$(which $PKG_INFO)") not executable." 372*0884854aSJean-Baptiste Boric echo "Can't create package index without pkg_info." 373*0884854aSJean-Baptiste Boric echo "Bootstrap pkgsrc on host to get pkg_info." 37469eead77SJean-Baptiste Boric exit 1 37569eead77SJean-Baptiste Boric fi 37669eead77SJean-Baptiste Boric 377*0884854aSJean-Baptiste Boric # Bundle all available packages if no list was given 378*0884854aSJean-Baptiste Boric if [ -z "$1" ] 379*0884854aSJean-Baptiste Boric then 380*0884854aSJean-Baptiste Boric PACKAGES=$(for i in $(echo "$PACKAGE_DIR"/*.tgz); do basename $i | sed s/\.tgz//; done) 381*0884854aSJean-Baptiste Boric else 382*0884854aSJean-Baptiste Boric PACKAGES=$1 383*0884854aSJean-Baptiste Boric fi 384*0884854aSJean-Baptiste Boric 38569eead77SJean-Baptiste Boric DESTPACKAGES="usr/packages/$RELEASE_VERSION/$ARCH/All" 38669eead77SJean-Baptiste Boric RELEASEPACKAGE="${ROOT_DIR}/$DESTPACKAGES" 38769eead77SJean-Baptiste Boric index=pkg_summary 38869eead77SJean-Baptiste Boric 38969eead77SJean-Baptiste Boric # create directories 39069eead77SJean-Baptiste Boric mkdir -p $RELEASEPACKAGE 39169eead77SJean-Baptiste Boric add_dir_spec "usr/packages" extra.pkgsrc 39269eead77SJean-Baptiste Boric add_dir_spec "usr/packages/$RELEASE_VERSION" extra.pkgsrc 39369eead77SJean-Baptiste Boric add_dir_spec "usr/packages/$RELEASE_VERSION/$ARCH" extra.pkgsrc 39469eead77SJean-Baptiste Boric add_dir_spec "usr/packages/$RELEASE_VERSION/$ARCH/All" extra.pkgsrc 39569eead77SJean-Baptiste Boric add_link_spec "packages" "usr/packages" extra.pkgsrc 396*0884854aSJean-Baptiste Boric for pkgprefix in $PACKAGES 39769eead77SJean-Baptiste Boric do 39869eead77SJean-Baptiste Boric realfn=$(echo $PACKAGE_DIR/${pkgprefix}*.tgz | cut -d' ' -f1) 39969eead77SJean-Baptiste Boric if [ -f "$realfn" ] 40069eead77SJean-Baptiste Boric then 40169eead77SJean-Baptiste Boric # Copy package 40269eead77SJean-Baptiste Boric p="$(basename $realfn)" 40369eead77SJean-Baptiste Boric echo " * Bundling $p..." 40469eead77SJean-Baptiste Boric cp "$realfn" "$RELEASEPACKAGE/$p" 40569eead77SJean-Baptiste Boric add_file_spec "$DESTPACKAGES/$p" extra.pkgsrc 40669eead77SJean-Baptiste Boric else 40769eead77SJean-Baptiste Boric echo "Error: Can't find $pkgprefix in directory $PACKAGE_DIR for bundling package." 40869eead77SJean-Baptiste Boric exit 1 40969eead77SJean-Baptiste Boric fi 41069eead77SJean-Baptiste Boric done 41169eead77SJean-Baptiste Boric 41269eead77SJean-Baptiste Boric # Create packages index 41369eead77SJean-Baptiste Boric echo " * Generating package index..." 41469eead77SJean-Baptiste Boric indexname=$indexpath/$p.$index 41569eead77SJean-Baptiste Boric $PKG_INFO -X $RELEASEPACKAGE/*.tgz >> $RELEASEPACKAGE/$index 41669eead77SJean-Baptiste Boric 41769eead77SJean-Baptiste Boric # Compress index 41869eead77SJean-Baptiste Boric echo " * Compressing index..." 41969eead77SJean-Baptiste Boric bzip2 -f $RELEASEPACKAGE/$index 42069eead77SJean-Baptiste Boric add_file_spec "$DESTPACKAGES/$index.bz2" extra.pkgsrc 42169eead77SJean-Baptiste Boric} 42269eead77SJean-Baptiste Boric 42369eead77SJean-Baptiste Boric# 42469eead77SJean-Baptiste Boric# stuff executed automatically to set up environment 42569eead77SJean-Baptiste Boric# 42669eead77SJean-Baptiste Boric 427a7a79fa1SJean-Baptiste Boricusage() 428a7a79fa1SJean-Baptiste Boric{ 42969eead77SJean-Baptiste Boric echo "Usage: $0 [options]" 430a7a79fa1SJean-Baptiste Boric echo " -X xsrc Build with X11 located in \"xsrc\"" 431a7a79fa1SJean-Baptiste Boric echo " -x Add X11 sets to extraction list" 43269eead77SJean-Baptiste Boric echo " -b Add ASR service binaries to the image" 43369eead77SJean-Baptiste Boric echo " (said binaries must be built beforehand)" 43469eead77SJean-Baptiste Boric echo "" 43569eead77SJean-Baptiste Boric echo "Environment variables:" 43669eead77SJean-Baptiste Boric echo " CREATE_IMAGE_ONLY If set to 1, skip invocation of build.sh (default: 0)" 43769eead77SJean-Baptiste Boric echo " JOBS Number of CPUs to use for build.sh to use (default: 1)" 43869eead77SJean-Baptiste Boric echo " SETS Sets to extract for image (default: depends on script)" 43969eead77SJean-Baptiste Boric echo " BUILDVARS Extra options passed to build.sh (default: none)" 44069eead77SJean-Baptiste Boric echo "" 44169eead77SJean-Baptiste Boric echo " PACKAGE_DIR Path to packages to bundle (default: none)" 44269eead77SJean-Baptiste Boric echo " BUNDLE_PACKAGES List of packages to bundle (default: none)" 44369eead77SJean-Baptiste Boric echo " PKG_INFO Path to 'pkg_info' for bundling (default: pkg_info)" 444a7a79fa1SJean-Baptiste Boric echo "" 445a7a79fa1SJean-Baptiste Boric echo " BUNDLE_SETS If set to 1, bundle sets for setup (default: only for CD)" 44669eead77SJean-Baptiste Boric} 44769eead77SJean-Baptiste Boric 44869eead77SJean-Baptiste Boric# parse options 449a7a79fa1SJean-Baptiste Boricwhile getopts "ixX:bh" c 45069eead77SJean-Baptiste Boricdo 45169eead77SJean-Baptiste Boric case "$c" in 45269eead77SJean-Baptiste Boric i) echo "This method of generating the ISO installation media is obsolete." 45369eead77SJean-Baptiste Boric echo "Run ./releasetools/x86_cdimage.sh instead." 45469eead77SJean-Baptiste Boric exit 1;; 45569eead77SJean-Baptiste Boric 456a7a79fa1SJean-Baptiste Boric x) SETS="$SETS xbase xcomp xetc xfont xserver";; 457a7a79fa1SJean-Baptiste Boric 458a7a79fa1SJean-Baptiste Boric X) MKX11=yes 45969eead77SJean-Baptiste Boric export MKX11 46069eead77SJean-Baptiste Boric BUILDVARS="$BUILDVARS -X $OPTARG";; 46169eead77SJean-Baptiste Boric 46269eead77SJean-Baptiste Boric b) # bitcode build: increase partition sizes 463ee0944b4SDavid van Moolenbroek ROOT_SIZE="$((${ROOT_SIZE} + 192*(2**20)))" 464ee0944b4SDavid van Moolenbroek USR_SIZE="$((${USR_SIZE} + 256*(2**20)))" 46569eead77SJean-Baptiste Boric ASR_HACK=1;; 46669eead77SJean-Baptiste Boric 46769eead77SJean-Baptiste Boric h) usage 46869eead77SJean-Baptiste Boric exit 0;; 46969eead77SJean-Baptiste Boric 47069eead77SJean-Baptiste Boric :) usage 47169eead77SJean-Baptiste Boric exit 2;; 47269eead77SJean-Baptiste Boric 47369eead77SJean-Baptiste Boric \?) 47469eead77SJean-Baptiste Boric usage 47569eead77SJean-Baptiste Boric exit 2;; 47669eead77SJean-Baptiste Boric esac 47769eead77SJean-Baptiste Boricdone 47869eead77SJean-Baptiste Boric 47969eead77SJean-Baptiste Boric# 48069eead77SJean-Baptiste Boric# Are we going to build the minix sources? 48169eead77SJean-Baptiste Boric# 48269eead77SJean-Baptiste Boric 48369eead77SJean-Baptiste Boricif [ ${CREATE_IMAGE_ONLY} -eq 1 ] 48469eead77SJean-Baptiste Boricthen 48569eead77SJean-Baptiste Boric if [ ! -d ${DESTDIR} ] 48669eead77SJean-Baptiste Boric then 48769eead77SJean-Baptiste Boric echo "Minix source code doesn't appear to have been built." 48869eead77SJean-Baptiste Boric echo "Please try with \$CREATE_IMAGE_ONLY set to 0." 48969eead77SJean-Baptiste Boric exit 1 49069eead77SJean-Baptiste Boric fi 49169eead77SJean-Baptiste Boric if [ ! -d ${RELEASEDIR} ] 49269eead77SJean-Baptiste Boric then 49369eead77SJean-Baptiste Boric echo "Minix release tarball sets don't appear to have been created." 49469eead77SJean-Baptiste Boric echo "Please try with \$CREATE_IMAGE_ONLY set to 0." 49569eead77SJean-Baptiste Boric exit 1 49669eead77SJean-Baptiste Boric fi 49769eead77SJean-Baptiste Boric # FIXME: this won't change anything for tarballs 49869eead77SJean-Baptiste Boric #${CROSS_TOOLS}/nbmake-i386 -C releasetools do-hdboot 49969eead77SJean-Baptiste Boricelse 50069eead77SJean-Baptiste Boric echo "Going to build Minix source code..." 50169eead77SJean-Baptiste Boric # 50269eead77SJean-Baptiste Boric # Remove the generated files to allow us call build.sh without '-V SLOPPY_FLIST=yes'. 50369eead77SJean-Baptiste Boric # 50469eead77SJean-Baptiste Boric rm -f ${FSTAB} 50569eead77SJean-Baptiste Boric 50669eead77SJean-Baptiste Boric # 50769eead77SJean-Baptiste Boric # Now start the build. 50869eead77SJean-Baptiste Boric # 50969eead77SJean-Baptiste Boric sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u release 51069eead77SJean-Baptiste Boric 51169eead77SJean-Baptiste Boricfi 51269eead77SJean-Baptiste Boric 51369eead77SJean-Baptiste Boric# sanity check 51469eead77SJean-Baptiste Boricif [ -d "${WORK_DIR}/.git" ] 51569eead77SJean-Baptiste Boricthen 51669eead77SJean-Baptiste Boric echo "WORK_DIR directory has a Git repository in it, abort!" 51769eead77SJean-Baptiste Boric exit 1 51869eead77SJean-Baptiste Boricfi 51969eead77SJean-Baptiste Boric 52069eead77SJean-Baptiste Boric# clean working directory 52169eead77SJean-Baptiste Boricif [ -e "${WORK_DIR}" ] 52269eead77SJean-Baptiste Boricthen 52369eead77SJean-Baptiste Boric rm -rf "${WORK_DIR}" 52469eead77SJean-Baptiste Boricfi 52569eead77SJean-Baptiste Boricmkdir -p ${WORK_DIR} 52669eead77SJean-Baptiste Boric 52769eead77SJean-Baptiste Boric# get absolute paths to those directories 52869eead77SJean-Baptiste BoricCROSS_TOOLS=$(cd ${CROSS_TOOLS} && pwd) 52969eead77SJean-Baptiste BoricDESTDIR=$(cd ${DESTDIR} && pwd) 530a7a79fa1SJean-Baptiste BoricMODDIR=$(cd ${MODDIR} && pwd) 53169eead77SJean-Baptiste BoricOBJ=$(cd ${OBJ} && pwd) 53269eead77SJean-Baptiste BoricSETS_DIR=$(cd ${SETS_DIR} && pwd) 53369eead77SJean-Baptiste BoricWORK_DIR=$(cd ${WORK_DIR} && pwd) 53469eead77SJean-Baptiste BoricROOT_DIR=${WORK_DIR}/fs 535a7a79fa1SJean-Baptiste Boric 536a7a79fa1SJean-Baptiste Boric# get list of mods 537a7a79fa1SJean-Baptiste Boricmods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`" 538