summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a33784e2639fc9b3ed0dcdbf410beb032f0f2f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pkgbase="rt-env"
pkgname="rt-env-git"
pkgver=1.1.2.226.3549
pkgrel=1
pkgdesc="RT_Thread env!"
arch=("x86_64")
license=("Apache-2.0" "GPL-2.0")
depends=('git' 'scons' 'python')
url="https://github.com/RT-Thread/env"

source=(env::git+https://github.com/RT-Thread/env.git
	packages::git+https://github.com/RT-Thread/packages.git)
sha512sums=('SKIP'
            'SKIP')

_env_root="/opt/rt-thread/tools/env"
_env_cmd_root="${_env_root}/tools/scripts"
_pkgs_root="${_env_root}/packages/packages"

pkgver() {
	_envver=`cd env && git describe --long --tags | sed 's/-/\./g; s/^v//; s/g.*$//'`
	_packagesver=`cd packages && git rev-list --count HEAD`
	echo $_envver$_packagesver
}

build() {
	mkdir -p "${srcdir}${_pkgs_root}"
	mkdir -p "${srcdir}${_env_cmd_root}"
	mkdir -p "${srcdir}${_env_root}/local_pkgs"
	cp -r ${srcdir}/env/* "${srcdir}${_env_cmd_root}"
	cp -r ${srcdir}/packages/* "${srcdir}${_pkgs_root}"
	echo 'source "$PKGS_DIR/packages/Kconfig"' > ${srcdir}${_pkgs_root}/../Kconfig
	echo 'export PATH='${_env_root}'/tools/scripts:$PATH' > "${srcdir}${_env_root}/env.sh"
}

package() {
	install -d -m755 "${pkgdir}${_env_root}"
	cp -rf ${srcdir}${_env_root}/* "${pkgdir}${_env_root}"
	_lnenv=${HOME}/.env
	echo "if [ \"\`readlink ${_lnenv}\`\" == \"${_env_root}\" ];then exit 0; fi;
if [ -L ${_lnenv}  ] || [ -d ${_lnenv}  ];
	then rm -rf ${_lnenv}-old; mv ${_lnenv} ${_lnenv}-old; fi;
ln -s ${_env_root} ${_lnenv}" > "${pkgdir}${_env_root}/lnenv.sh"
	chown -R $USER:`id -g -n $USER` ${pkgdir}${_env_root}
}

(
    echo "post_install() {"
	echo 'echo "** -------------------------------------------------------------------------- **"'
	echo "echo \"**        The following command is to generate a linked file to ~/.env !      **\""
	echo "echo \"**         The main purpose is to unify with official usage methods !         **\""
	echo "echo \"**  Note: This command may delete the ~/.env-old file. Be sure to backup it!  **\""
	echo 'echo "** -------------------------------------------------------------------------- **"'
	echo "echo \"** ----------- please execute   ${_env_root}/lnenv.sh ----------- **\""
	echo 'echo "** -------------------------------------------------------------------------- **"'
    echo "}"
) > "${startdir}/${pkgname}.install"
true && install="${pkgname}.install"