Project

General

Profile

Actions

Feature #5741

open

Patch folder for user patches

Added by saen acro almost 6 years ago. Updated almost 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Patches
Target version:
-
Start date:
2019-10-07
Due date:
% Done:

0%

Estimated time:

Description

Idea is simple folder named "patches" in main build folder
when there is a "*.patch" or "*.diff" to be applied to source and after compilation finish to be reverted /not to interrupt feature PULL/
aprouvment of Autobuild.sh --enable-patches

positives is:
easy implementation of patches
easy testing

This is example of oscam builder.
https://github.com/gorgone/s3_releases

#!/bin/bash

get_patch(){ _get_patch; };
_get_patch(){
    cd $pdir;
    [ -f patch.url ] && source patch.url;
    clear;
    echo -e $C;
    ologo;
    echo -e $WH;
    [ -f $PATCHNAME ] && echo -e "$Y   old patch found\n  remove  $P$PATCHNAME" && rm -f $PATCHNAME;
    echo -e $W"  load $PATCHNAME";
    wget -q -O$PATCHNAME $PATCHURL;
    [ -f $PATCHNAME ] && echo -e $G"   ok$W new $PATCHNAME loaded\n" || echo -e $R"   patch not found\n"$W;
};
_apply_menupatch(){
    [ -f "$workdir/SVN-IS-PATCHED" ] && quicksvnrestore $_toolchainname 2>/dev/null;
        cd "$pdir";
            (if [ "$(ls -1 "$pdir"/*.patch 2>/dev/null | wc -l)" -gt "0" ];then
                cd "$pdir";
                unset patchlist;patchlist=`ls *.patch | sort -st '/' -k1,1`;
                patchlog="$(mktemp)";
                for e in ${patchlist[@]};do
                    _w="ok";
                    cd "$svndir";
                    echo "PATCH : apply $e";
                    patch -f -p0 < "$pdir/$e" >>"$patchlog" 2>/dev/null;
                    hunks=$(grep -c1 '^Hunk' "$patchlog");
                    fails=$(grep -c1 'hunks FAILED' "$patchlog");
                    if [ "$hunks" -gt "0" ];then
                        echo "PATCH : $hunks x HUNK for $e";
                        _w="hunk";
                    fi;
                    if [ "$fails" -gt "0" ];then
                        echo "PATCH : $fails x FAILS for $e";
                        _w="fail";
                    fi;
                done;
                case $_w in
                    ok)
                            echo "PATCH : done all ok";
                            touch "$workdir/SVN-IS-PATCHED";;
                    hunk)
                            echo "PATCH : done with warnings save $e.log";
                            cat $patchlog >>"$ldir/$e.log";
                            ln -sf "$ldir/$e.log" "$workdir/lastpatch.log";
                            touch "$workdir/SVN-IS-PATCHED";;
                    fail)
                            echo "PATCH : break build save $e.log";
                            cat $patchlog >>"$ldir/$e.log";
                            ln -sf "$ldir/$e.log" "$workdir/lastpatch.log";
                            touch "$workdir/SVN-IS-PATCHED";;
                esac;
                rm -rf "$patchlog";
            fi;)|"$gui" "$st_" "$bt_" "$title_" "$pb_" 12 62;sleep 2;
};
_apply_consolepatch(){
    if [ ! -f "$workdir/SVN-IS-PATCHED" ];then
        cd "$pdir";
        if [ "$(ls -1 "$pdir"/*.patch 2>/dev/null | wc -l)" -gt "0" ];then
            unset patchlist;patchlist=`ls *.patch | sort -st '/' -k1,1`;
            patchlog="$(mktemp)";
            for e in ${patchlist[@]};do
                _w=0;cd "$svndir";
                echo -e "$y_l |     PATCH : apply $e";
                patch -F 10 -f -p0 < "$pdir/$e" >>"$patchlog" 2>/dev/null;
                hunks=$(grep -c1 "^Hunk" "$patchlog");
                fails=$(grep -c1 "hunks FAILED" "$patchlog");
                if [ "$hunks" -gt "0" ];then
                    echo -e "$y_l |     PATCH :$w_l $hunks x HUNK for $e";
                    _w=1;
                fi;
                if [ "$fails" -gt "0" ];then
                    echo -e  "$y_l |     PATCH :$r_n FAIL (breaking Build) = $fails";
                    echo -en "$w_l |   RESTORE :$c_w LAST SVN BACKUP in ";
                    for (( i=6; i>0; i--));do
                        sleep 1 & echo -en "$i\b";
                        wait;
                    done;
                    svnrestore lastsvn;
                    exit;
                fi;
                cat $patchlog >"$ldir/$e.log";
                ln -sf "$ldir/$e.log" "$workdir/lastpatch.log";
            done;
            rm -rf "$patchlog";
            if [ "$_w" -gt "0" ];then echo -e "$y_l |     PATCH : done with warnings";
                touch "$workdir/SVN-IS-PATCHED";
            else
                echo -e "$y_l |     PATCH :$g_l done all ok$rs_";
                touch "$workdir/SVN-IS-PATCHED";
            fi;
        else
            echo -en "$y_l |     PATCH : no patch found\n";
        fi;
    fi;
};

Actions

Also available in: Atom PDF