Skip to content

Commit

Permalink
Merge pull request #28 from SkycoinProject/feature/skybian-fixes
Browse files Browse the repository at this point in the history
Skybian fixes.
  • Loading branch information
志宇 authored Apr 24, 2020
2 parents c105134 + e300f94 commit d12cd4c
Show file tree
Hide file tree
Showing 29 changed files with 665 additions and 431 deletions.
6 changes: 3 additions & 3 deletions build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# PATCH version when you make backwards-compatible bug fixes.
#
# version must always start with "v" like: v0.1.45-rc
VERSION=v0.1.1
VERSION=v0.1.2
# This must match the tags in the github repository

# loading the actual path
Expand All @@ -18,11 +18,11 @@ ROOT=$(pwd)
# URL for the most recent version of this: https://dl.armbian.com/orangepiprime/archive/
ARMBIAN_DOWNLOAD_URL="https://dl.armbian.com/orangepiprime/archive/Armbian_20.02.1_Orangepiprime_stretch_current_5.4.20.7z"
# Skywire release download for OS running on destination skyminer
SKYWIRE_DOWNLOAD_URL="https://github.com/SkycoinProject/skywire-mainnet/releases/download/v0.2.1/skywire-v0.2.1-linux-arm64.tar.gz"
SKYWIRE_DOWNLOAD_URL="https://github.com/SkycoinProject/skywire-mainnet/releases/download/v0.2.3/skywire-v0.2.3-linux-arm64.tar.gz"

# Offset and sector size of the Armbian image for rootfs (found automatically if not set)
IMG_OFFSET="" # 8192
IMG_SECTOR="" # 512

# how much will we increase the original image in MB
BASE_IMG_ADDED_SPACE=768
BASE_IMG_ADDED_SPACE=512 # before: 768
174 changes: 88 additions & 86 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,43 +295,45 @@ rootfs_check()
# - Mount loop device
prepare_base_image()
{
# Armbian image is tight packed, and we need room for adding our
# bins, apps & configs, so we will make it bigger
# Armbian image is tight packed, and we need room for adding our
# bins, apps & configs, so we will make it bigger

# clean
info "Cleaning..."
rm -rf "${IMAGE_DIR:?}/*" &> /dev/null || true
# clean
info "Cleaning..."
rm -rf "${IMAGE_DIR:?}/*" &> /dev/null || true

# copy armbian image to base image location
info "Copying base image..."
cp "${PARTS_DIR}/armbian/${ARMBIAN_IMG}" "${BASE_IMG}" || return 1
# copy armbian image to base image location
info "Copying base image..."
cp "${PARTS_DIR}/armbian/${ARMBIAN_IMG}" "${BASE_IMG}" || return 1

# Add space to base image
# Add space to base image
if [[ "$BASE_IMG_ADDED_SPACE" -ne "0" ]]; then
info "Adding ${BASE_IMG_ADDED_SPACE}MB of extra space to the image..."
truncate -s +"${BASE_IMG_ADDED_SPACE}M" "${BASE_IMG}"
echo ", +" | sfdisk -N1 "${BASE_IMG}" # add free space to the part 1 (sfdisk way)
fi

info "Setting up loop device..."
setup_loop || return 1
rootfs_check || return 1
info "Setting up loop device..."
setup_loop || return 1
rootfs_check || return 1

info "Resizing root fs..."
sudo resize2fs "${IMG_LOOP}" || return 1
rootfs_check || return 1
info "Resizing root fs..."
sudo resize2fs "${IMG_LOOP}" || return 1
rootfs_check || return 1

info "Mounting root fs to ${FS_MNT_POINT}..."
sudo mount -t auto "${IMG_LOOP}" "${FS_MNT_POINT}" -o loop,rw
info "Mounting root fs to ${FS_MNT_POINT}..."
sudo mount -t auto "${IMG_LOOP}" "${FS_MNT_POINT}" -o loop,rw

info "Done!"
info "Done!"
}

copy_to_img()
{
# Copy skywire bins
info "Copying skywire bins..."
sudo cp -rf "$PARTS_SKYWIRE_DIR"/bin/* "$FS_MNT_POINT"/usr/bin/ || return 1
sudo cp "$ROOT"/static/skywire-startup "$FS_MNT_POINT"/usr/bin/ || return 1
sudo chmod +x "$FS_MNT_POINT"/usr/bin/skywire-startup || return 1
sudo cp "$ROOT"/static/skybian-firstrun "$FS_MNT_POINT"/usr/bin/ || return 1
sudo chmod +x "$FS_MNT_POINT"/usr/bin/skybian-firstrun || return 1

# Copy skywire tools
info "Copying skywire tools..."
Expand All @@ -349,12 +351,12 @@ copy_to_img()
# Copy systemd units
info "Copying systemd unit services..."
local SYSTEMD_DIR=${FS_MNT_POINT}/etc/systemd/system/
sudo cp -f "${ROOT}/static/skywire-startup.service" "${SYSTEMD_DIR}" || return 1
sudo cp -f "${ROOT}"/static/*.service "${SYSTEMD_DIR}" || return 1

info "Done!"
}

# fix some defaults on armian to skywire defaults
# fix some defaults on armbian to skywire defaults
chroot_actions()
{
# copy chroot scripts to root fs
Expand Down Expand Up @@ -392,47 +394,47 @@ chroot_actions()
# calculate md5, sha1 and compress
calc_sums_compress()
{
# change to final dest
cd "${FINAL_IMG_DIR}" ||
(error "Failed to cd." && return 1)
# change to final dest
cd "${FINAL_IMG_DIR}" ||
(error "Failed to cd." && return 1)

# info
info "Calculating the md5sum for the image, this may take a while"

# cycle for each one
for img in $(find -- *.img -maxdepth 1 -print0 | xargs --null) ; do
# MD5
info "MD5 Sum for image: $img"
md5sum -b "${img}" > "${img}.md5"

# sha1
info "SHA1 Sum for image: $img"
sha1sum -b "${img}" > "${img}.sha1"

# compress
info "Compressing, this will take a while..."
name=$(echo "${img}" | rev | cut -d '.' -f 2- | rev)
tar -cvf "${name}.tar" "${img}"*
xz -vzT0 "${name}.tar"
done

# info
info "Calculating the md5sum for the image, this may take a while"

# cycle for each one
for img in $(find -- *.img -maxdepth 1 -print0 | xargs --null) ; do
# MD5
info "MD5 Sum for image: $img"
md5sum -b "${img}" > "${img}.md5"

# sha1
info "SHA1 Sum for image: $img"
sha1sum -b "${img}" > "${img}.sha1"

# compress
info "Compressing, this will take a while..."
name=$(echo "${img}" | rev | cut -d '.' -f 2- | rev)
tar -cvf "${name}.tar" "${img}"*
xz -vzT0 "${name}.tar"
done

cd "${ROOT}" || return 1
info "Done!"
cd "${ROOT}" || return 1
info "Done!"
}

clean_image()
{
sudo umount "${FS_MNT_POINT}/sys"
sudo umount "${FS_MNT_POINT}/proc"
sudo umount "${FS_MNT_POINT}/dev/pts"
sudo umount "${FS_MNT_POINT}/dev"
sudo umount "${FS_MNT_POINT}/sys"
sudo umount "${FS_MNT_POINT}/proc"
sudo umount "${FS_MNT_POINT}/dev/pts"
sudo umount "${FS_MNT_POINT}/dev"

sudo sync
sudo umount "${FS_MNT_POINT}"
sudo sync
sudo umount "${FS_MNT_POINT}"

sudo sync
# only do so if IMG_LOOP is set
[[ -n "${IMG_LOOP}" ]] && sudo losetup -d "${IMG_LOOP}"
sudo sync
# only do so if IMG_LOOP is set
[[ -n "${IMG_LOOP}" ]] && sudo losetup -d "${IMG_LOOP}"
}

clean_output_dir()
Expand All @@ -452,46 +454,46 @@ clean_output_dir()
# build disk
build_disk()
{
# move to correct dir
cd "${IMAGE_DIR}" || return 1
# move to correct dir
cd "${IMAGE_DIR}" || return 1

# final name
local NAME="Skybian-${VERSION}"
# final name
local NAME="Skybian-${VERSION}"

# info
info "Building image for ${NAME}"
# info
info "Building image for ${NAME}"

# force a FS sync
info "Forcing a fs rsync to umount the real fs"
sudo sync
# force a FS sync
info "Forcing a fs rsync to umount the real fs"
sudo sync

# umount the base image
info "Umount the fs"
sudo umount "${FS_MNT_POINT}"
# umount the base image
info "Umount the fs"
sudo umount "${FS_MNT_POINT}"

# check integrity & fix minor errors
rootfs_check
# check integrity & fix minor errors
rootfs_check

# TODO [TEST]
# shrink the partition to a minimum size
# sudo resize2fs -M "${IMG_LOOP}"
#
# shrink the partition
# TODO [TEST]
# shrink the partition to a minimum size
# sudo resize2fs -M "${IMG_LOOP}"
#
# shrink the partition

# force a FS sync
info "Forcing a fs rsync to umount the loop device"
sudo sync
# force a FS sync
info "Forcing a fs rsync to umount the loop device"
sudo sync

# freeing the loop device
info "Freeing the loop device"
sudo losetup -d "${IMG_LOOP}"
# freeing the loop device
info "Freeing the loop device"
sudo losetup -d "${IMG_LOOP}"

# copy the image to final dir.
info "Copy the image to final dir"
cp "${BASE_IMG}" "${FINAL_IMG_DIR}/${NAME}.img"
# copy the image to final dir.
info "Copy the image to final dir"
cp "${BASE_IMG}" "${FINAL_IMG_DIR}/${NAME}.img"

# info
info "Image for ${NAME} ready"
# info
info "Image for ${NAME} ready"
}

# main build block
Expand Down
8 changes: 5 additions & 3 deletions cmd/skyimager-gui/statik/statik.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.13

require (
fyne.io/fyne v1.2.3
github.com/SkycoinProject/dmsg v0.1.0
github.com/SkycoinProject/dmsg v0.2.0
github.com/SkycoinProject/skycoin v0.27.0
github.com/SkycoinProject/skywire-mainnet v0.1.2
github.com/SkycoinProject/skywire-mainnet v0.2.3
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/mholt/archiver v3.1.1+incompatible
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/SkycoinProject/dmsg v0.0.0-20200306152741-acee74fa4514/go.mod h1:DzykXMLlx6Fx0fGjZsCIRas/MIvxW8DZpmDA6f2nCRk=
github.com/SkycoinProject/dmsg v0.1.0 h1:dHzzSWpIOlqA99wT7hR6ZOk/Wyv0x1F94u/BHOIKLuo=
github.com/SkycoinProject/dmsg v0.1.0/go.mod h1:MiX+UG/6fl3g+9rS13/fq7BwUQ2eOlg1yOBOnNf6J6A=
github.com/SkycoinProject/dmsg v0.2.0 h1:YAalAHTs89Ncu0AbuCz00umX/ITYPAkPRT2w4tp4odE=
github.com/SkycoinProject/dmsg v0.2.0/go.mod h1:MiX+UG/6fl3g+9rS13/fq7BwUQ2eOlg1yOBOnNf6J6A=
github.com/SkycoinProject/skycoin v0.26.0/go.mod h1:xqPLOKh5B6GBZlGA7B5IJfQmCy7mwimD9NlqxR3gMXo=
github.com/SkycoinProject/skycoin v0.27.0 h1:N3IHxj8ossHOcsxLYOYugT+OaELLncYHJHxbbYLPPmY=
github.com/SkycoinProject/skycoin v0.27.0/go.mod h1:xqPLOKh5B6GBZlGA7B5IJfQmCy7mwimD9NlqxR3gMXo=
github.com/SkycoinProject/skywire-mainnet v0.0.0-20200309204032-14af5342da86/go.mod h1:xuOpE5ZZU2kR39u0tJWtOpak/sJpnEFj1HpTxtyPU/A=
github.com/SkycoinProject/skywire-mainnet v0.1.2 h1:ehJpHzrCDSqbZoss1X+bDnK2Bv1BVYY0ESkUpiKYogA=
github.com/SkycoinProject/skywire-mainnet v0.1.2/go.mod h1:oQzKdioU8GxrSF1uiz5IPurAyaQlXkChcCDc/eth+7A=
github.com/SkycoinProject/skywire-mainnet v0.2.3 h1:jxSLVPO4oGHt7m0PoBR5yVTuz49CV4Z3JM4RgqkDi+A=
github.com/SkycoinProject/skywire-mainnet v0.2.3/go.mod h1:V4GfusVnax+suHTKdrz7ToC0yqsevtMxqyKLcDVnWSs=
github.com/SkycoinProject/yamux v0.0.0-20191213015001-a36efeefbf6a h1:6nHCJqh7trsuRcpMC5JmtDukUndn2VC9sY64K6xQ7hQ=
github.com/SkycoinProject/yamux v0.0.0-20191213015001-a36efeefbf6a/go.mod h1:IaE1dxncLQs4RJcQTZPikJfAZY4szH87u2h0lT0SDuM=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
Expand Down
Loading

0 comments on commit d12cd4c

Please sign in to comment.