summaryrefslogtreecommitdiffstats
path: root/tools/patch-tool-mxe
blob: b7720e6523af703c2005cdaa24c59f4d5443dca7 (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
59
60
61
62
63
#!/usr/bin/env bash

# Tool for converting between MXE patch files and git repos
# Imports and exports patch files in "git format-patch" format.

cmd=$1
pkg=$2
patch_name=${3:-1-fixes}

setupEnv() {
  # MXE directory
  export mxedir=$(cd $(dirname $0) && cd .. && pwd)
}

function init_git {
  setupEnv
  make -C $mxedir init-git-$pkg
}

function export_patch {
  setupEnv
  make -C $mxedir export-patch-$pkg PATCH_NAME=${patch_name}
}

function import_patch {
  setupEnv
  make -C $mxedir import-patch-$pkg PATCH_NAME=${patch_name}
}

function import_all_patches {
  setupEnv
  make -C $mxedir import-all-patches-$pkg
}

case "$cmd" in
  init)
    init_git $pkg
    ;;
  import)
    import_patch $pkg
    ;;
  import-all)
    import_all_patches $pkg
    ;;
  export)
    export_patch $pkg
    ;;
  *)
    echo "Unrecognized command '${cmd}'" >&2
    cat <<EOS
    Usage: $0 COMMAND PACKAGENAME [PATCHNAME]
    where COMMAND is one of:
      init - create a git directory for the package with the raw source
      import - apply the "pkgname-PATCHNAME.patch" patch commits
      import-all - apply commits from all the patches of the package
      export - create/replace the "pkgname-PATCHNAME.patch" patch with a patch of all commits since init.

    If PATCHNAME is not set, it is default to "1-fixes".
EOS
    exit 1
    ;;
esac