Skip to content

Commit

Permalink
add download and mount scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Nov 24, 2018
1 parent 708e3ae commit 22a3471
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
image/
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cerbero"]
path = cerbero
url = https://gitlab.freedesktop.org/gstreamer/cerbero.git
branch = 1.14
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sudo: required

language: bash

before_install:
- sudo apt-get update

script:
- download.sh
- mount.sh
1 change: 1 addition & 0 deletions cerbero
Submodule cerbero added at b7933b
16 changes: 16 additions & 0 deletions download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Downloads latest raspbian lite image

ZIP=raspbian_lite.zip
IMG=raspbian_lite.img
URL=https://downloads.raspberrypi.org/raspbian_lite_latest

echo "Downloading latest raspbian lite release"
mkdir -p image
wget $URL -O image/${ZIP}

echo "Extracting image"
unzip image/${ZIP} -d image/

FILE=`zipinfo -1 image/${ZIP}`
mv image/${FILE} image/${IMG}
26 changes: 26 additions & 0 deletions mount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Mounts raspbian image inside cerbero build system

IMG='raspbian_lite.img'
MNT='cerbero/config/raspbian_sysroot'

# Attach loopback device
LOOP_DEV=`losetup -f --show image/${IMG}`
echo "Attached base loopback at: $LOOP_DEV"

# Fetch and parse partition info
LOOP=`basename ${LOOP_DEV}`
SECTOR_SIZE=`cat /sys/block/${LOOP}/queue/hw_sector_size`
ROOT_START=`fdisk -l $LOOP_DEV | grep ${LOOP_DEV}p2 | awk '{print $2}'`
echo "Located root partition at sector $ROOT_START (sector size: ${SECTOR_SIZE}B)"

mkdir -p $MNT
mount image/${IMG} -o loop,offset=$(($ROOT_START*$SECTOR_SIZE)),rw $MNT
if [[ $? != 0 ]]; then
echo "Error mounting root partition"
else
echo "Mounted root partition to $MNT"
fi

losetup -d $LOOP_DEV
echo "Closed loopback $LOOP_DEV"

0 comments on commit 22a3471

Please sign in to comment.