adde88

some openwrt functions

Oct 20th, 2020
822
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mf-update(){
  2.   if [ ! -f Makefile ]; then
  3.    echo "No Makefile found in folder."
  4.    return 0
  5.   fi
  6. #  export repo=`grep "PKG_SOURCE_URL" Makefile | awk -F"=" {'print $2'}`
  7.   export lcommit=`git ls-remote --heads src | grep master | awk {'print $1'} | head -1`
  8.   export oversion=`grep "PKG_SOURCE_VERSION:=" Makefile | awk -F"=" {'print $2'}| cut -b 7-`
  9.   export lrelease=`grep "PKG_RELEASE" Makefile | awk -F"=" {'print $2'}`
  10.   let nrelease="$lrelease+1"
  11. #  if [ -z "$repo" ]; then
  12. #    echo "Not a Git repository!"
  13. #    return 0
  14. #  fi
  15.   if [ "$lcommit" != "$oversion" ]; then
  16.     cd ./src
  17.     git pull
  18.     cd ..
  19. #    sed -i "s/^PKG_SOURCE_VERSION:=.*$/PKG_SOURCE_VERSION:=$lcommit/" Makefile
  20.     sed -i "s/^PKG_RELEASE:=.*$/PKG_RELEASE:=$nrelease/" Makefile
  21.     echo "Updated Makfile to use commit: $lcommit"
  22.     echo "OLD RELEASE: $lrelease"
  23.     echo "NEW RELEASE: $nrelease"
  24.     return 1
  25.   else
  26.     echo "Makefile is already up-to-date with latest commit!"
  27.     return 0
  28.   fi
  29. }
  30.  
RAW Paste Data