#!/usr/bin/env bash

# PORTBUILD generated by manup packaging scripts on 2015-09-09 12:24:30
# Visit http://manup.mreschke.net/README
# Copyright (c) 2012, Matthew Reschke

##############################################################################################
# Variables below can NOT reference other variables, manup will not expand them.
# So url=http://example.com/source/$name-$ver is not acceptable.
# Though all variables can be accessed in the build_* functions.
# The ONLY exception to this rule is the config=(...) array, where $prefix is available

# There are also more bash variables available than you see here.
# The /usr/local/lib/manup/functions.sh is sourced before this file. Check it out.
# There are also a few set by manup, like $prefix, $fakeroot, $is_installed, $installed_ver
# Visit http://manup.mreschke.com for details

# All variables and build_* function must be present, even if empty.
# Since a bash function cannot be empty, just put in some placeholder
# like null=nothing

# These files will be overwritten with every 'manup sync' command.
##############################################################################################


# Port Information
name="nodejs"
ver=4.2.3
rel=11
desc="Node.js JavaScript runtime"

# Port Dependencies
# dep=(someport anotherport) are required dependencies
# depopt=(someport anotherport) are optional dependencies
dep=()
depopt=()

# Port Configuration Files
# These files will NOT be overwritten during port upgrade but instead will be copied as xxxx.manupnew files
# This avoids your defined config files from being overwritten during upgrades
# configs=(/etc/myport/my.conf, /etc/defaults/myport, $prefix/share/myother.conf)
configs=()

# Port file details
fileurl="http://manup.mreschke.net/nwq/nodejs/nodejs-4.2.3-11.tar.gz"
filesize=11618091
md5sum="80a1f1cb53b26b0bfa5643d33fe8965f"

# Packaging Options
keep_symlinks=true


##############################################################################################
# In all of these function, your current directory is the tmp build directory,
# which is usually /tmp/manup/yourrepo/yourpackage/package-ver/
# After port_fakeroot runs the code to be deployed is copied to $fakeroot
##############################################################################################

port_configure() {
	# Configure the source code (use manup $prefix variable)
	#./configure --prefix=$prefix
:;}

port_build() {
	# Build/Compile the source code
	#make
	#make TARGET=linux2628 USE-STATIC_PCRE=1 USE_OPENSSL=1
:;}

port_fakeroot() {
	# Install all package contents into $fakeroot
	# If port is source code, then instead of using 'make install' use the included Auto-DESTDIR (make-redir) tool
	# A helper function called make_install will perform this action: make-redir DESTDIR=$fakeroot PREFIX=$prefix install
	# You can always run the make-redir command yourself if your install requires more flags:
	# make-redir MAKDIR=/usr/share/man OTHERFLAGSHERE=/something DESTDIR=$fakeroot PREFIX=$prefix install
	#make_install

	# If not source code and no make install is required then just copy the files into $fakeroot
	# A helper function called copy_to_fakeroot is used, this just runs: tar cf - . | (cd $fakeroot ; tar -xf -)
    copy_to_fakeroot
:;}

port_preinstall() {
	# Perform any pre-install functions
	# Your current directory at this point is the build dir (/tmp/manup/somerepo/yourpackage/package-ver/)
	# Your files are pending in $fakeroot, so 'cd $fakeroot' to mod files before install...
:;}

port_install() {
	# Install all package contents from $fakeroot into /
	# install_files is helper function to do this, it simply runs: cd $fakeroot; tar cf - . | (cd / ; tar -xvhf -)
	# Your current directory at this point is the build dir (/tmp/manup/somerepo/yourpackage/package-ver/)
	# The $is_installed or $installed_ver variables are handy here to determine if fresh install or upgrading...
	install_files
:;}

port_postinstall() {
	# Perform any post-install functions
	# There are output helper functions like out, error, notice, message
	# The $is_installed or $installed_ver variables are handy here to determine if fresh install or upgrading...
	#if $is_installed; then echo "You were just upgraded to from $installed_ver"; fi
	#if [ "$installed_ver" == "1.0.2" ]; then echo "I am going to perform 1.0.2 to 1.0.3 upgrade code now"; fi
	#notice "Please update this and that important thing"
	#message "Installed, Thanks!"
	#cd /tmp && curl -L https://npmjs.org/install.sh | sh
:;}

port_preuninstall() {
	# Perform any pre-uninstall functions
:;}

port_postuninstall() {
	# Perform any post-uninstall functions
:;}

##############################################################################################
