Commit 0b9255cd authored by aTc's avatar aTc

added installer

parent 347524b9
......@@ -8,7 +8,7 @@ Standards-Version: 3.9.5
Package: pyra-install
Architecture: all
Depends: ${misc:Depends}, coreutils (>= 8.26), util-linux (>= 2.29.2),
e2fsprogs (>= 1.43.4) ,f2fs-tools, bar
e2fsprogs (>= 1.43.4) ,f2fs-tools, pv
Description: Scripts and data files to install a PyraOS image
Scripts and u-boot files to install the OS image to
a bootable device.
......
/usr/share/pyra/u-boot/pyra-u-boot-4g /usr/share/pyra/installer/install/uboot
pyra-install.sh /usr/share/pyra/scripts/
pyra-install-uboot.sh /usr/share/pyra/scripts/
u-boot /usr/share/pyra/
installer /usr/share/pyra/
#!/bin/sh
UBOOT=install/uboot
DISKIMAGE=install.img
IMGMOUNT=/tmp/installsd
dd if=/dev/zero bs=1 count=0 seek=1700M of="${DISKIMAGE}"
DISK=$(losetup -f -P --show "${DISKIMAGE}")
echo "Installing U-Boot"
dd if="$UBOOT/MLO" of=${DISK} count=1 seek=1 bs=128k
dd if="$UBOOT/u-boot.img" of=${DISK} count=2 seek=1 bs=384k
echo "> 2.26.0"
sfdisk ${DISK} <<-__EOF__
1M,,0x83,*
__EOF__
PART=${DISK}p1
mkfs.vfat -n PYRAINSTALL ${PART}
mkdir ${IMGMOUNT}
mount ${PART} ${IMGMOUNT}
cp install/boot/* ${IMGMOUNT}/ -rv
cp install/rootfs.tgz ${IMGMOUNT}/
sync
umount ${IMGMOUNT}
losetup -d ${DISK}
rm ${IMGMOUNT} -rf
#!/bin/sh
set -e
PREREQS=""
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
. /usr/share/initramfs-tools/hook-functions
##
copy_exec /bin/setfont
copy_file binary /usr/share/consolefonts/Lat15-Terminus24x12.psf.gz
#installer
copy_exec /sbin/sfdisk
copy_exec /sbin/mkfs.ext4
copy_exec /bin/lsblk
copy_exec /sbin/mkfs.f2fs
copy_exec /bin/lsblk
copy_exec /usr/bin/pv
copy_exec /bin/bash
copy_file script /usr/share/pyra/scripts/pyra-install.sh
copy_file binary /usr/share/pyra/u-boot/pyra-u-boot-4g/MLO
copy_file binary /usr/share/pyra/u-boot/pyra-u-boot-4g/u-boot.img
#
# initramfs.conf
# Configuration file for mkinitramfs(8). See initramfs.conf(5).
#
# Note that configuration options from this file can be overridden
# by config files in the /etc/initramfs-tools/conf.d directory.
#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add most filesystem and all harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#
MODULES=most
#
# BUSYBOX: [ y | n | auto ]
#
# Use busybox shell and utilities. If set to n, klibc utilities will be used.
# If set to auto (or unset), busybox will be used if installed and klibc will
# be used otherwise.
#
BUSYBOX=auto
#
# KEYMAP: [ y | n ]
#
# Load a keymap during the initramfs stage.
#
KEYMAP=n
#
# COMPRESS: [ gzip | bzip2 | lz4 | lzma | lzop | xz ]
#
COMPRESS=gzip
#
# NFS Section of the config.
#
#
# DEVICE: ...
#
# Specify a specific network interface, like eth0
# Overridden by optional ip= or BOOTIF= bootarg
#
DEVICE=
#
# NFSROOT: [ auto | HOST:MOUNT ]
#
NFSROOT=auto
#
# RUNSIZE: ...
#
# The size of the /run tmpfs mount point, like 256M or 10%
# Overridden by optional initramfs.runsize= bootarg
#
RUNSIZE=10%
#!/bin/bash
set +e
PREREQS=""
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
dmesg -n 1
setfont Lat15-Terminus24x12.psf.gz
mkdir -p /media/sd1
mkdir -p /media/sd2
mount /dev/mmcblk3p1 /media/sd1
mount /dev/mmcblk5p1 /media/sd2
clear
pyr_version=$(tr -d '\0' </proc/device-tree/model 2>/dev/null)
read -a MEMINFO < /proc/meminfo
RAM=$(expr ${MEMINFO[1]} / 1000000)
echo "Pyra model : ${pyr_version}"
echo "Ram: $RAM GB"
ROOTFS=""
UBOOT=/usr/share/pyra/u-boot/pyra-u-boot-4g/
if [ -f "/media/sd1/rootfs.tgz" ] ; then
ROOTFS=/media/sd1/rootfs.tgz
#elif [ -f "/media/sd2/rootfs.tgz" ] ; then
# ROOTFS=/media/sd2/rootfs.tgz
fi
if [ -z "$ROOTFS" ] ; then
echo "rootfs.tgz not found on first partition of any sd card"
read -p "Press any key to poweroff" -n1 -s
poweroff -f
fi
echo $ROOTFS
/bin/bash /usr/share/pyra/scripts/pyra-install.sh $ROOTFS $UBOOT /dev/mmcblk0 inithwtest
echo ----------------------------------------
umount /media/sd1
#umount /media/sd2
read -p "Done. Press any key to poweroff" -n1 -s
poweroff -f
## /boot/extlinux/extlinux.conf
##
## IMPORTANT WARNING
##
## The configuration of this file is generated automatically.
## Do not edit this file manually, use: extlinux-update
## Use user.cfg for manually added entries
menu title Pyra Installer
timeout 10
default u0
label u0
menu label install
linux /vmlinuz-4.19.60-letux-lpae-pyra-nobat
append root=PARTUUID=dcee9988-02 console=ttyO2,115200n8 console=tty0 vram=12M omapfb.vram=0:8M,1:4M omapfb.rotate_type=0 omapdss.def_disp=lcd rootwait twl4030_charger.allow_usb=1 musb_hdrc.preserve_vbus=1 log_buf_len=8M ignore_loglevel earlyprintk drm_kms_helper.fbdev_rotation=8 fastboot
fdtdir /dtb/linux-image-4.19.60-letux-lpae-pyra-nobat
initrd /initrd.install
#!/bin/bash
check_exists() { if ! hash $1 2>/dev/null ; then echo $1 not found ; exit 1 ; fi ; }
check_exists dd
if [ "$#" -ne 2 ] ; then
echo "Usage: $0 u-boot-dir /dev/mmcblk0"
exit 1
fi
UBOOT=$1
DISK=$2
if [ ! -f "${UBOOT}/MLO" ] || [ ! -f "${UBOOT}/u-boot.img" ] ; then echo "u-boot files not found"; exit 1; fi
echo "Installing U-Boot..."
dd if="$UBOOT/MLO" of=${DISK} count=1 seek=1 bs=128k
dd if="$UBOOT/u-boot.img" of=${DISK} count=2 seek=1 bs=384k
echo "Done."
#!/bin/bash
ROOTFSMOUNT=/tmp/rootfs
version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" == "$1"; }
check_exists() { if ! hash $1 2>/dev/null ; then echo $1 not found ; exit 1 ; fi ; }
......@@ -10,13 +12,16 @@ check_exists mkfs.ext4
check_exists lsblk
check_exists id
check_exists mkfs.f2fs
check_exists lsblk
INITHWTEST=0
if [ "$#" -ne 3 ] ; then
echo "Usage: Write to device : $0 rootfs.tgz u-boot /dev/mmcblk1"
echo " Create image file : $0 rootfs.tgz u-boot rootfs.img"
exit 1
if [ "$#" -ne 3 ] ; then
if [ "$4" != "inithwtest" ]; then
echo "Usage: Write to device : $0 rootfs.tgz u-boot /dev/mmcblk1"
echo " Create image file : $0 rootfs.tgz u-boot rootfs.img"
exit 1
fi
INITHWTEST=1
fi
if [ $(id -u) -ne 0 ] ; then echo "Must be run as root"; exit 0; fi
......@@ -42,7 +47,7 @@ else
echo "Installing to $DISK , make sure all partitions are unmounted"
if [[ "$INITHWTEST" -ne 1 ]] ; then
read -p "Are you sure you want to continue? <y/N> " prompt
read -p "Are you sure you want to continue? <y(es)/N(o)>+enter" prompt
if ! [[ $prompt =~ [yY](es)* ]] ; then echo "Exiting.." ; exit 1 ; fi
fi
fi
......@@ -86,40 +91,54 @@ sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
__EOF__
fi
if [[ $? != 0 ]] ; then echo Partitioning failed.; exit 1; fi
echo "Formatting partitions"
#mkfs.ext4 -O ^64bit ${PART} -L rootfs
mkfs.ext4 -O ^64bit ${BOOTPART} -L boot
#/sbin/mkfs.ext4 -O ^64bit ${BOOTPART} -L boot
mke2fs -q -L boot ${BOOTPART}
# older mkfs.f2fs versions don't have -f, newer versions need -f if fs exists
# older versions don't report version either, so assume if -V fails, -f isn't there
mkfs.f2fs -V > /dev/null 2>/dev/null
if [[ $? == 0 ]] ; then
mkfs.f2fs ${PART} -f -l rootfs
else
mkfs.f2fs ${PART} -l rootfs
fi
#mkfs.f2fs -V > /dev/null 2>/dev/null
#if [[ $? == 0 ]] ; then
mkfs.f2fs -q -f -l rootfs ${PART}
#else
# mkfs.f2fs ${PART} -l rootfs
#fi
if [[ $? != 0 ]] ; then echo Formatting failed.; exit 1; fi
mkdir rootfs
mount ${PART} rootfs
mkdir rootfs/boot
mount ${BOOTPART} rootfs/boot
if [[ $? != 0 ]] ; then echo Mounting ${PART} failed.; exit 1; fi
sync
udevadm settle
echo $PART
echo $BOOTPART
echo ..................................
mkdir -p ${ROOTFSMOUNT}
mount ${PART} ${ROOTFSMOUNT}
mkdir -p ${ROOTFSMOUNT}/boot
mount ${BOOTPART} ${ROOTFSMOUNT}/boot
#if [[ $? != 0 ]] ; then echo Mounting ${PART} failed.; exit 1; fi
if [ $INITHWTEST -eq 1 ]; then
clear
fi
echo "Installing rootfs"
if hash bar 2>/dev/null ; then
bar $IMAGE | tar --numeric-owner -xzf - -C rootfs
if [ $INITHWTEST -eq 1 ]; then
pv -w 106 $IMAGE | tar --numeric-owner -xzf - -C ${ROOTFSMOUNT}
else
pv $IMAGE | tar --numeric-owner -xzf - -C ${ROOTFSMOUNT}
fi
else
echo Install "bar" for progress bar
tar --numeric-owner -xzf $IMAGE -C rootfs
echo "extracting... (install pv to see progress)"
tar --numeric-owner -xzf $IMAGE -C ${ROOTFSMOUNT}
fi
ROOTPARTUUID=$(blkid -p $PART -s PART_ENTRY_UUID -o value)
......@@ -132,12 +151,12 @@ BOOTPARTUUID=$(blkid -p $BOOTPART -s PART_ENTRY_UUID -o value)
#BOOTFSUUID=$(lsblk -n -o UUID $BOOTPART)
sed -i -e 's/linux \/boot/linux /g' rootfs/boot/extlinux/linux.cfg
sed -i -e 's/initrd \/boot/initrd /g' rootfs/boot/extlinux/linux.cfg
sed -i -e "s/append root=\/dev\/mmcblk0p1/append root=PARTUUID=$ROOTPARTUUID/g" rootfs/boot/extlinux/linux.cfg
sed -i -e "s/EXTLINUX_ROOT=\"root=\/dev\/mmcblk0p1\"/EXTLINUX_ROOT=\"root=PARTUUID=$ROOTPARTUUID\"/g" rootfs/etc/default/pyra-extlinux
sed -i -e 's/linux \/boot/linux /g' ${ROOTFSMOUNT}/boot/extlinux/linux.cfg
sed -i -e 's/initrd \/boot/initrd /g' ${ROOTFSMOUNT}/boot/extlinux/linux.cfg
sed -i -e "s/append root=\/dev\/mmcblk0p1/append root=PARTUUID=$ROOTPARTUUID/g" ${ROOTFSMOUNT}/boot/extlinux/linux.cfg
sed -i -e "s/EXTLINUX_ROOT=\"root=\/dev\/mmcblk0p1\"/EXTLINUX_ROOT=\"root=PARTUUID=$ROOTPARTUUID\"/g" ${ROOTFSMOUNT}/etc/default/pyra-extlinux
cat > rootfs/etc/fstab << EOF
cat > ${ROOTFSMOUNT}/etc/fstab << EOF
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
......@@ -150,13 +169,15 @@ PARTUUID=$BOOTPARTUUID /boot ext4 defaults 0 1
EOF
# cat ${ROOTFSMOUNT}/etc/fstab
if [[ $? != 0 ]] ; then echo Extracting $IMAGE failed.; umount ${PART} ; exit 1; fi
echo "Syncing"
sync
umount rootfs/boot
umount rootfs
umount ${ROOTFSMOUNT}/boot
umount ${ROOTFSMOUNT}
if [[ -n "$DISKIMAGE" ]] ; then losetup -d $DISK ; fi
rm rootfs -rf
rm ${ROOTFSMOUNT} -rf
echo "Done"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment