...
 
Commits (3)
The Debian Package pyra-install
----------------------------
Scripts to install PyraOS image
-- Pyra Dev <dev@pyra-handheld.com> Sat, 18 May 2019 00:32:27 +0200
pyra-install (0.1) unstable; urgency=medium
[ Pyra Dev ]
* Initial release.
[ ]
-- Pyra Dev <pyra-dev@pyra-handheld.com> Sat, 18 May 2019 01:15:24 +0200
Source: pyra-install
Section: misc
Priority: optional
Maintainer: Pyra Dev <dev@pyra-handheld.com>
Build-Depends: debhelper (>= 9)
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
Description: Scripts and data files to install a PyraOS image
Scripts and u-boot files to install the OS image to
a bootable device.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pyra-install
Source: http://dev.pyra-handheld.com/index.php/p/pyra-install/
Files: *
Copyright: 2019 Pyra Dev <dev@pyra-handheld.com>
License: MIT
Files: debian/*
Copyright: 2019 Pyra Dev <dev@pyra-handheld.com>
License: MIT
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pyra-install.sh /usr/share/pyra/scripts/
u-boot /usr/share/pyra/
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
# main packaging script based on dh7 syntax
%:
dh $@
# debmake generated override targets
# This is example for Cmake (See http://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
#!/bin/bash
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 ; }
if [ "$#" -ne 3 ] ; then echo "Usage: $0 : rootfs.tgz u-boot /dev/mmcblk1" ; exit 1 ; fi
if [ $(id -u) -ne 0 ] ; then echo "Must be run as root"; exit 0; fi
check_exists dd
check_exists sfdisk
check_exists mkfs.ext4
check_exists lsblk
check_exists id
UBOOT=$2
IMAGE=$1
DISK=$3
echo Image:$IMAGE Disk:$DISK U-Boot:$UBOOT
#if [ ! -d $UBOOT ] ; then echo "u-boot files not found"; exit 1; fi
if [ ! -f "${UBOOT}/MLO" ] || [ ! -f "${UBOOT}/u-boot.img" ] ; then echo "u-boot files not found"; exit 1; fi
if [ ! -f $IMAGE ] ; then echo "rootfs image $IMAGE not found."; exit 1; fi
lsblk $DISK
#if [[ $? != 0 ]] ; then echo Failed; exit 1; fi
echo "Installing to $DISK , make sure all partitions are unmounted"
read -p "Are you sure you want to continue? <y/N> " prompt
if ! [[ $prompt =~ [yY](es)* ]] ; then echo "Exiting.." ; exit 1 ; fi
#exit 0
if [[ $DISK == /dev/mmcblk* ]] ; then
PART=${DISK}p1
else
PART=${DISK}1
fi
echo "Clearing partition table"
dd if=/dev/zero of=${DISK} bs=1M count=10
if [[ $? != 0 ]] ; then echo Partitioning failed.; 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 "Creating partition"
SFVER=$(sfdisk -v | awk '{print $4}')
echo Found sfdisk version: ${SFVER}
if version_gt $SFVER 2.26.0; then
echo "> 2.26.0"
sfdisk ${DISK} <<-__EOF__
1M,,0x83,*
__EOF__
else
echo "< 2.26.0"
sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,,0x83,*
__EOF__
fi
if [[ $? != 0 ]] ; then echo Partitioning failed.; exit 1; fi
echo "Formatting partition"
mkfs.ext4 -O ^64bit ${PART} -L rootfs
if [[ $? != 0 ]] ; then echo Formatting failed.; exit 1; fi
mkdir rootfs
mount ${PART} ./rootfs
if [[ $? != 0 ]] ; then echo Mounting ${PART} failed.; exit 1; fi
echo "Installing rootfs"
if hash bar 2>/dev/null ; then
bar $IMAGE | tar --numeric-owner -xzf - -C rootfs
else
echo Install "bar" for progress bar
tar --numeric-owner -xzf $IMAGE -C rootfs
fi
if [[ $? != 0 ]] ; then echo Extracting $IMAGE failed.; umount ${PART} ; exit 1; fi
echo "Syncing"
sync
umount rootfs
rm rootfs -rf
echo "Done"
......@@ -76,7 +76,17 @@ 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
mkfs.f2fs ${PART} -f -l rootfs
# 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
if [[ $? != 0 ]] ; then echo Formatting failed.; exit 1; fi
......@@ -98,11 +108,11 @@ else
fi
ROOTPARTUUID=$(lsblk -n -o PARTUUID $PART)
BOOTPARTUUID=$(lsblk -n -o PARTUUID $BOOTPART)
# fs uuid sometimes failed, use PARTUUID for everything
ROOTFSUUID=$(lsblk -n -o UUID $PART)
BOOTFSUUID=$(lsblk -n -o UUID $BOOTPART)
echo BootFS-UUID: $BOOTFSUUID
echo RootFS-UUID: $ROOTFSUUID Part-UUID: $ROOTPARTUUID
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
......@@ -117,8 +127,8 @@ cat > rootfs/etc/fstab << EOF
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=$ROOTFSUUID / f2fs defaults 0 1
UUID=$BOOTFSUUID /boot ext4 defaults 0 1
PARTUUID=$ROOTPARTUUID / f2fs defaults 0 1
PARTUUID=$BOOTPARTUUID /boot ext4 defaults 0 1
EOF
......