Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopadilha committed Jan 6, 2015
1 parent 58c64a7 commit 9340d5f
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .gitignore
@@ -0,0 +1,55 @@
### Build directory tree ###
download/*
target/*
logfile*
*.tgz
origin/*

### proftpd-admin ###
www

### Linux ###
*~

# KDE directory preferences
.directory

### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
43 changes: 42 additions & 1 deletion README.md
@@ -1,4 +1,45 @@
fsx
===

FSX DroboApp build scripts
This is a set of scripts to package a DroboApp from scratch, i.e., download sources, unpackage, compile, install, and package in a TGZ file. The `master` branch contains the Drobo5N version, the `drobofs` branch contains the DroboFS version.

## I just want to install the DroboApp, what do I do?

Check the [releases](https://github.com/droboports/fsx/releases) page. If there are no releases available, then you have to compile.

## How to compile

First make sure that you have a [working cross-compiling VM](https://github.com/droboports/droboports.github.io/wiki/Setting-up-a-VM).

Log in the VM, pick a temporary folder (e.g., `~/build`), and then do:

```
git clone https://github.com/droboports/fsx.git
cd fsx
./build.sh
ls -la *.tgz
```

Each invocation creates a log file with all the generated output.

* `./build.sh distclean` removes everything, including downloaded files.
* `./build.sh clean` removes everything but downloaded files.
* `./build.sh package` repackages the DroboApp, without recompiling.

## Sources

* fsx: http://codemonkey.org.uk/projects/fsx/

## Help support the apps

If you like the repositories, or are using any of the apps from this site, please consider becoming a patreon or making a donation to support our efforts.

[![Patreon](http://www.patreon.com/images/logo_emblem.png)](http://www.patreon.com/Droboports)

[![Paypal](https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYFBRYLKSGNKA)

[![Flattr](https://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/177640/DroboPorts)

<sub>**Disclaimer**</sub>

<sub><sub>Drobo, DroboShare, Drobo FS, Drobo 5N, DRI and all related trademarks are the property of [Data Robotics, Inc](http://www.drobo.com/). This site is not affiliated, endorsed or supported by DRI in any way. The use of information and software provided on this website may be used at your own risk. The information and software available on this website are provided as-is without any warranty or guarantee. By visiting this website you agree that: (1) We take no liability under any circumstance or legal theory for any DroboApp, software, error, omissions, loss of data or damage of any kind related to your use or exposure to any information provided on this site; (2) All software are made “AS AVAILABLE” and “AS IS” without any warranty or guarantee. All express and implied warranties are disclaimed. Some states do not allow limitations of incidental or consequential damages or on how long an implied warranty lasts, so the above may not apply to you.</sub></sub>
19 changes: 19 additions & 0 deletions app.sh
@@ -0,0 +1,19 @@
### FSX ###
_build_fsx() {
local BASEURL="http://codemonkey.org.uk/projects/fsx"

_download_file "fsx.c" "${BASEURL}/fsx-linux.c"

mkdir -p "target/fsx"
cp -vf "download/fsx.c" "target/fsx/"
pushd "target/fsx"
${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o fsx fsx.c
mkdir -p "${DEST}/bin"
cp -vf "fsx" "${DEST}/bin/"
popd
}

_build() {
_build_fsx
_package
}
137 changes: 137 additions & 0 deletions build.sh
@@ -0,0 +1,137 @@
#!/usr/bin/env bash

### bash best practices ###
# exit on error code
set -o errexit
# exit on unset variable
set -o nounset
# return error of last failed command in pipe
set -o pipefail
# expand aliases
shopt -s expand_aliases
# print trace
set -o xtrace

### logfile ###
timestamp="$(date +%Y-%m-%d_%H-%M-%S)"
logfile="logfile_${timestamp}.txt"
echo "${0} ${@}" > "${logfile}"
# save stdout to logfile
exec 1> >(tee -a "${logfile}")
# redirect errors to stdout
exec 2> >(tee -a "${logfile}" >&2)

### environment setup ###
source crosscompile.sh
export NAME="$(basename ${PWD})"
export DEST="/mnt/DroboFS/Shares/DroboApps/${NAME}"
export DEPS="${PWD}/target/install"
export CFLAGS="${CFLAGS:-} -Os -fPIC"
export CXXFLAGS="${CXXFLAGS:-} ${CFLAGS}"
export CPPFLAGS="-I${DEPS}/include"
export LDFLAGS="${LDFLAGS:-} -Wl,-rpath,${DEST}/lib -L${DEST}/lib"
alias make="make -j8 V=1 VERBOSE=1"

### support functions ###
# Download a TGZ file and unpack it, removing old files.
# $1: file
# $2: url
# $3: folder
_download_tgz() {
[[ ! -d "download" ]] && mkdir -p "download"
[[ ! -d "target" ]] && mkdir -p "target"
[[ ! -f "download/${1}" ]] && wget -O "download/${1}" "${2}"
[[ -d "target/${3}" ]] && rm -vfr "target/${3}"
[[ ! -d "target/${3}" ]] && tar -zxvf "download/${1}" -C target
return 0
}

# Download a DroboApp and unpack it, removing old files.
# $1: file
# $2: url
# $3: folder
_download_app() {
[[ ! -d "download" ]] && mkdir -p "download"
[[ ! -d "target" ]] && mkdir -p "target"
[[ ! -f "download/${1}" ]] && wget -O "download/${1}" "${2}"
[[ -d "target/${3}" ]] && rm -vfr "target/${3}"
mkdir -p "target/${3}"
tar -zxvf "download/${1}" -C "target/${3}"
return 0
}

# Clone last commit of a single branch from git, removing old files.
# $1: branch
# $2: folder
# $3: url
_download_git() {
[[ ! -d "target" ]] && mkdir -p "target"
[[ -d "target/${2}" ]] && rm -vfr "target/${2}"
[[ ! -d "target/${2}" ]] && git clone --branch "${1}" --single-branch --depth 1 "${3}" "target/${2}"
return 0
}

# Download a file, overwriting existing.
# $1: file
# $2: url
_download_file() {
[[ ! -d "download" ]] && mkdir -p "download"
[[ ! -f "download/${1}" ]] && wget -O "download/${1}" "${2}"
return 0
}

# Download a file in a specific folder, overwriting existing.
# $1: file
# $2: url
# $3: folder
_download_file_in_folder() {
[[ ! -d "download/${3}" ]] && mkdir -p "download/${3}"
[[ ! -f "download/${3}/${1}" ]] && wget -O "download/${3}/${1}" "${2}"
return 0
}

# Create the DroboApp tgz file.
_create_tgz() {
local FILE="${PWD}/${NAME}.tgz"

if [[ -f "${FILE}" ]]; then
rm -v "${FILE}"
fi

pushd "${DEST}"
tar --verbose --create --numeric-owner --owner=0 --group=0 --gzip --file "${FILE}" *
popd
}

# Package the DroboApp
_package() {
mkdir -p "${DEST}"
[[ -d "src/dest" ]] && cp -vafR "src/dest"/* "${DEST}"/
find "${DEST}" -name "._*" -print -delete
_create_tgz
}

# Remove all compiled files.
_clean() {
rm -vfr "${DEPS}"
rm -vfr "${DEST}"
rm -vfr target/*
}

# Removes all files created during the build.
_dist_clean() {
_clean
rm -vf logfile*
rm -vfr download/*
}

### application-specific functions ###
source app.sh

case "${1:-}" in
clean) _clean ;;
distclean) _dist_clean ;;
package) _package ;;
"") _build ;;
*) _build_${1} ;;
esac
14 changes: 14 additions & 0 deletions crosscompile.sh
@@ -0,0 +1,14 @@
export DROBO="5n"
export TOOLCHAIN=~/xtools/toolchain/${DROBO}
export ARCH="armv7-a"
export HOST="arm-marvell-linux-gnueabi"
export PATH="${TOOLCHAIN}/bin:~/bin:$PATH"
export CFLAGS="-march=${ARCH} -mcpu=marvell-pj4 -mfpu=vfpv3-d16 -mfloat-abi=softfp"
export CXXFLAGS="${CFLAGS}"
export CC="${TOOLCHAIN}/bin/${HOST}-gcc"
export CXX="${TOOLCHAIN}/bin/${HOST}-g++"
export AR="${TOOLCHAIN}/bin/${HOST}-ar"
export AS="${TOOLCHAIN}/bin/${HOST}-as"
export RANLIB="${TOOLCHAIN}/bin/${HOST}-ranlib"
export STRIP="${TOOLCHAIN}/bin/${HOST}-strip"
export DROBOAPPS="/mnt/DroboFS/Shares/DroboApps"
4 changes: 4 additions & 0 deletions src/dest/install.sh
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
#
# empty install script

4 changes: 4 additions & 0 deletions src/dest/update.sh
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
#
# empty update script

15 changes: 15 additions & 0 deletions uncrosscompile.sh
@@ -0,0 +1,15 @@
export PATH=`echo $PATH | sed "s|$TOOLCHAIN/bin:||g"`
export -n DROBO
export -n TOOLCHAIN
export -n ARCH
export -n HOST
export -n CFLAGS
export -n CXXFLAGS
export -n CPPFLAGS
export -n LDFLAGS
export -n CC
export -n CXX
export -n AR
export -n AS
export -n RANLIB
export -n STRIP

0 comments on commit 9340d5f

Please sign in to comment.