Skip to content

Commit

Permalink
Merge pull request #95 from skycoin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jdknives authored Mar 17, 2021
2 parents e4c661f + 8fb7594 commit b1a726b
Show file tree
Hide file tree
Showing 22 changed files with 1,024 additions and 322 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ TEST_OPTS:=$(TEST_OPTS_BASE) -tags no_ci

IMG_BOOT_PARAMS:='[{"local_ip":"192.168.0.2","gateway_ip":"192.168.0.1","local_sk":"34992ada3a6daa4fbb5ad8b5b958d993ad4e5ed0f51b5ba822c8370212030826","hypervisor_pks":["027c823e9e183f3a89c5c200705f2017c0df253a66bdfae5aa0755d191713b7520"]}]'

.PHONY: dep

dep:
GO111MODULE=on go mod vendor -v

check: lint test ## Run linters and tests

install-linters: ## Install linters
Expand Down
11 changes: 7 additions & 4 deletions build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# PATCH version when you make backwards-compatible bug fixes.
#
# version must always start with "v" like: v0.1.45-rc
VERSION=v0.1.3

VERSION=v0.2.0
# This must match the tags in the github repository

# loading the actual path
Expand All @@ -16,10 +17,12 @@ ROOT=$(pwd)
# Internet resources
# Armbian latest image dynamic link is https://dl.armbian.com/orangepiprime/Debian_stretch_next.7z
# URL for the most recent version of this: https://dl.armbian.com/orangepiprime/archive/
ARMBIAN_DOWNLOAD_URL="https://archive.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/skycoin/skywire/releases/download/v0.3.0/skywire-v0.3.0-linux-arm64.tar.gz"

ARMBIAN_DOWNLOAD_URL="https://archive.armbian.com/orangepiprime/archive/Armbian_20.05.2_Orangepiprime_stretch_current_5.4.43.img.xz"

# Skywire release download for OS running on destination skyminer
SKYWIRE_VERSION=v0.4.0
SKYWIRE_DOWNLOAD_URL="https://github.com/skycoin/skywire/releases/download/$SKYWIRE_VERSION/skywire-$SKYWIRE_VERSION-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
Expand Down
127 changes: 66 additions & 61 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ PARTS_SKYWIRE_DIR=${PARTS_DIR}/skywire
PARTS_TOOLS_DIR=${PARTS_DIR}/tools

# Image related variables.
ARMBIAN_IMG_7z=""
ARMBIAN_IMG_XZ=""
ARMBIAN_IMG=""
ARMBIAN_VERSION=""
ARMBIAN_KERNEL_VERSION=""
Expand Down Expand Up @@ -163,9 +163,6 @@ get_skywire()
mkdir "${PARTS_SKYWIRE_DIR}/bin"
tar xvzf "${_DST}" -C "${PARTS_SKYWIRE_DIR}/bin" || return 1

info "Renaming 'hypervisor' to 'skywire-hypervisor'..."
mv "${PARTS_SKYWIRE_DIR}/bin/hypervisor" "${PARTS_SKYWIRE_DIR}/bin/skywire-hypervisor" || 0

info "Cleaning..."
rm -rf "${PARTS_SKYWIRE_DIR}/bin/README.md" "${PARTS_SKYWIRE_DIR}/bin/CHANGELOG.md" || return 1

Expand All @@ -174,83 +171,91 @@ get_skywire()

download_armbian()
{
local _DST=${PARTS_ARMBIAN_DIR}/armbian.7z # Download destination file name.
info "Downloading image from ${ARMBIAN_DOWNLOAD_URL}..."
wget -c "${ARMBIAN_DOWNLOAD_URL}" ||
(error "Image download failed." && return 1)

info "Downloading image from ${ARMBIAN_DOWNLOAD_URL} to ${_DST} ..."
wget -c "${ARMBIAN_DOWNLOAD_URL}" -O "${_DST}" ||
(error "Download failed." && return 1)
info "Downloading checksum from ${ARMBIAN_DOWNLOAD_URL}.sha..."
wget -c "${ARMBIAN_DOWNLOAD_URL}.sha" ||
(error "Checksum download failed." && return 1)
}

# Get the latest ARMBIAN image for Orange Pi Prime
get_armbian()
{
local ARMBIAN_IMG_7z="armbian.7z"

# change to dest dir
cd "${PARTS_ARMBIAN_DIR}" ||
(error "Failed to cd." && return 1)
# change to dest dir
cd "${PARTS_ARMBIAN_DIR}" ||
(error "Failed to cd." && return 1)

# user info
info "Getting Armbian image, clearing dest dir first."
local ARMBIAN_IMG_XZ="$(ls Armbian*img.xz || true)"

# test if we have a file in there
if [ -r armbian.7z ] ; then
# user info
info "Getting Armbian image, clearing dest dir first."

# use already downloaded image file
notice "Reusing already downloaded file"
else
# no image in there, must download
info "No cached image, downloading.."
# test if we have a file in there
if [ -r "${ARMBIAN_IMG_XZ}" ] ; then

# download it
download_armbian
fi
# todo: doesn't seem to work, always downloads the image
# todo: download checksum separately, and use it to validate local copy

# extract and check it's integrity
info "Armbian file to process is '${ARMBIAN_IMG_7z}'."

# check if extracted image is in there to save time
if [ -n "$(ls Armbian*.img || true)" ] ; then
# image already extracted nothing to do
notice "Armbian image already extracted"
else
# extract armbian
info "Extracting image..."
if ! 7z e "${ARMBIAN_IMG_7z}" ; then
error "Extracting failed, file is corrupt? Re-run the script to get it right."
rm "${ARMBIAN_IMG_7z}" &> /dev/null || true
exit 1
fi
fi
# use already downloaded image file
notice "Reusing already downloaded file"
else
# no image in there, must download
info "No cached image, downloading.."

# check integrity
info "Testing image integrity..."
if ! $(command -v sha256sum) -c --status -- *.sha ; then
error "Integrity of the image is compromised, re-run the script to get it right."
rm -- *img *txt *sha *7z &> /dev/null || true
exit 1
fi
# download it
download_armbian

# get image filename
ARMBIAN_IMG=$(ls Armbian*.img || true)
local ARMBIAN_IMG_XZ="$(ls Armbian*img.xz || true)"
fi

# imge integrity
info "Image integrity assured via sha256sum."
notice "Final image file is ${ARMBIAN_IMG}"
# extract and check it's integrity
info "Armbian file to process is '${ARMBIAN_IMG_XZ}'."

# get version & kernel version info
ARMBIAN_VERSION=$(echo "${ARMBIAN_IMG}" | awk -F '_' '{ print $2 }')
ARMBIAN_KERNEL_VERSION=$(echo "${ARMBIAN_IMG}" | awk -F '_' '{ print $6 }' | rev | cut -d '.' -f2- | rev)
# check integrity
info "Testing image integrity..."
if ! $(command -v sha256sum) -c --status -- *.sha ; then
error "Integrity of the image is compromised, re-run the script to get it right."
rm -- armbian *txt *sha *xz &> /dev/null || true
exit 1
fi

# info to the user
notice "Armbian version: ${ARMBIAN_VERSION}"
notice "Armbian kernel version: ${ARMBIAN_KERNEL_VERSION}"
# check if extracted image is in there to save time
if [ -n "$(ls Armbian*.img || true)" ] ; then
# image already extracted nothing to do
notice "Armbian image already extracted"
else
# extract armbian
info "Extracting image..."
if ! 7z e "${ARMBIAN_IMG_XZ}" ; then
error "Extracting failed, file is corrupt? Re-run the script to get it right."
rm "${ARMBIAN_IMG_XZ}" &> /dev/null || true
exit 1
fi
fi

# get image filename
ARMBIAN_IMG=$(ls Armbian*.img || true)

# imge integrity
info "Image integrity assured via sha256sum."
notice "Final image file is ${ARMBIAN_IMG}"

# get version & kernel version info
ARMBIAN_VERSION=$(echo "${ARMBIAN_IMG}" | awk -F '_' '{ print $2 }')
ARMBIAN_KERNEL_VERSION=$(echo "${ARMBIAN_IMG}" | awk -F '_' '{ print $6 }' | rev | cut -d '.' -f2- | rev)

# info to the user
notice "Armbian version: ${ARMBIAN_VERSION}"
notice "Armbian kernel version: ${ARMBIAN_KERNEL_VERSION}"
}

get_all()
{
get_armbian || return 1
get_skywire || return 1
get_armbian || return 1
get_tools || return 1
}

Expand All @@ -259,7 +264,7 @@ get_all()
setup_loop()
{
# find free loop device
IMG_LOOP=$(losetup -f)
IMG_LOOP=$(sudo losetup -f)

# find image sector size (if not user-defined)
[[ -z $IMG_SECTOR ]] &&
Expand Down Expand Up @@ -439,7 +444,7 @@ clean_image()
clean_output_dir()
{
# Clean parts.
cd "${PARTS_ARMBIAN_DIR}" && find . -type f ! -name '*.7z' -delete
cd "${PARTS_ARMBIAN_DIR}" && find . -type f ! -name '*.xz' -delete
cd "${PARTS_SKYWIRE_DIR}" && find . -type f ! -name '*.tar.gz' -delete && rm -rf bin
cd "${FINAL_IMG_DIR}" && find . -type f ! -name '*.tar.gz' -delete

Expand Down
23 changes: 8 additions & 15 deletions cmd/skyconf/skyconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,11 @@ func init() {
flag.StringVar(&filename, "if", filenameDefault, "input file to read from")
}

var hvName string
var configFile string

func init() {
const hvNameDefault = "/etc/skywire-hypervisor.json"
flag.StringVar(&hvName, "hvf", hvNameDefault, "hypervisor config output file")
}

var vName string

func init() {
const vNameDefault = "/etc/skywire-visor.json"
flag.StringVar(&vName, "vf", vNameDefault, "visor config output file")
const configFileDefault = "/etc/skywire-config.json"
flag.StringVar(&configFile, "c", configFileDefault, "skywire config output file")
}

var keyFile string
Expand Down Expand Up @@ -76,12 +69,12 @@ func main() {
logger.Fatalf("failed to read params: %v", err)
}
conf := prepconf.Config{
VisorConf: vName,
HypervisorConf: hvName,
TLSKey: keyFile,
TLSCert: certFile,
BootParams: params,
Filename: configFile,
TLSKey: keyFile,
TLSCert: certFile,
}
if err := prepconf.Prepare(logger, conf, params); err != nil {
if err := prepconf.GenerateConfigFile(conf, logger); err != nil {
logger.Fatalf("failed to ensure config file: %v", err)
}
if err := params.PrintEnvs(os.Stdout); err != nil {
Expand Down
17 changes: 12 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ module github.com/skycoin/skybian
go 1.13

require (
fyne.io/fyne v1.2.3
fyne.io/fyne v1.4.0
github.com/go-gl/glfw v0.0.0-20181213070059-819e8ce5125f // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/mholt/archiver v3.1.1+incompatible
github.com/rakyll/statik v0.1.7
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.7.0
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/skycoin/dmsg v0.0.0-20201018132543-a08c07be4640
github.com/skycoin/skycoin v0.26.0
github.com/skycoin/skywire v0.3.0
github.com/skycoin/dmsg v0.0.0-20201216183836-dae8a7acfc14
github.com/skycoin/skycoin v0.27.1
github.com/skycoin/skywire v0.2.4-0.20201222094854-2e3d9f8fb380
github.com/stretchr/testify v1.6.1
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344
nhooyr.io/websocket v1.8.4 // indirect
)

// Uncomment it for tests with alternative branches and run `make dep`

// replace github.com/skycoin/skywire => ../skywire
Loading

0 comments on commit b1a726b

Please sign in to comment.