aboutsummaryrefslogtreecommitdiffstats
path: root/tools/scc-cmds/patch.cmd
blob: 099c111f0aff2c35d9194916dbd2e48dff77a6c2 (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
# take a patch file, and make sure it is relative to where the patch.queue is
# being written. This is a standard requirement for most patch managers .. and
# it just makes life easier
patch() {
    local patch_name=$1
    local simple_patch_name=$(basename ${patch_name})

    if [ -n "${verbose}" ]; then
        echo "patch: $1 [${cbranch_name}]" >&2
    fi

    if [ ! -d "${outdir}/patches/${cbranch_name}" ]; then
        mkdir -p "${outdir}/patches/${cbranch_name}"
    fi

    relative_patch_name=${patch_name}
    relative_patch_dir=""
    if [ -n "${prefix}" ]; then
        relative_patch_name=${relative_patch_name/$prefix}
        relative_patch_dir=$(dirname ${relative_patch_name})
        mkdir -p ${outdir}/patches/${cbranch_name}/${relative_patch_dir}
    fi

    # we could compare the source and dest, and either warn or clobber, but for now, we just clobber
    cp -f "$patch_name" "${outdir}/patches/${cbranch_name}/${relative_patch_dir}"

    # output to the global and branch specific queue
    eval echo "\"patches/${cbranch_name}/${relative_patch_dir}/${simple_patch_name}\"" >> "${patchqueue}"
    if [ -n "${branch_patch_queue}" ]; then
       eval echo "\"patches/${cbranch_name}/${relative_patch_dir}/${simple_patch_name}\"" >> "${branch_patch_queue}"
    fi
    # outfile_append is the meta-series
    eval echo "\"patch patches/${cbranch_name}/${relative_patch_dir}/${simple_patch_name}\"" $outfile_append
}