From 68e6a54522aa86cae7a1531d185226b77b3391f9 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Wed, 1 Feb 2017 15:00:18 -0800 Subject: [PATCH] update_emulation: new script to update packages/emulation/* --- tools/mkpkg/update_emulation | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 tools/mkpkg/update_emulation diff --git a/tools/mkpkg/update_emulation b/tools/mkpkg/update_emulation new file mode 100755 index 0000000000..5913a6ba43 --- /dev/null +++ b/tools/mkpkg/update_emulation @@ -0,0 +1,69 @@ +#!/bin/sh +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2016 Team LibreELEC +# +# LibreELEC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# LibreELEC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreELEC. If not, see . +################################################################################ + +git_clone() { + # git_clone https://repo.url branch ./target_dir [githash] + echo "[mkpkg] Checking out $1 ..." + if [ ! -d "$3" ]; then + git clone --recursive "$1" -b $2 "$3" + else + if [ -d "$3" ] ; then + cd "$3" + git checkout $2 >/dev/null 2>/dev/null + git pull + cd .. + fi + fi + if [ ! -z "$4" ] ; then + cd "$3" + git fetch >/dev/null 2>/dev/null + git branch -D $4 >/dev/null 2>/dev/null + git checkout $4 -b ref-$4 >/dev/null 2>/dev/null + cd .. + fi +} + +resolve_hash() { + if [ -d "$1" ] ; then + cd "$1" + git rev-parse --short $2 2>/dev/null + fi +} + +if [ -z "$1" ]; then + for package in $(find ../../packages/emulation/* -name package.mk); do + . $package + git_clone $PKG_SITE master $PKG_NAME.git + + if [ -f ../../packages/emulation/$PKG_NAME/package.mk ] ; then + # update package.mk + RESOLVED_HASH=$(resolve_hash $PKG_NAME.git master) + sed -i "s|PKG_VERSION=.*|PKG_VERSION=\"$RESOLVED_HASH\"|g" ../../packages/emulation/$PKG_NAME/package.mk + fi + done +else + . ../../packages/emulation/$1/package.mk + git_clone $PKG_SITE master $PKG_NAME.git + + if [ -f ../../packages/emulation/$PKG_NAME/package.mk ] ; then + # update package.mk + RESOLVED_HASH=$(resolve_hash $PKG_NAME.git master) + sed -i "s|PKG_VERSION=.*|PKG_VERSION=\"$RESOLVED_HASH\"|g" ../../packages/emulation/$PKG_NAME/package.mk + fi +fi