summaryrefslogtreecommitdiff
path: root/elpa/bin/deploy-to-core
blob: 917f6469de7b58c5a9ef552805a554ae49ae6374 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash

shopt -s extglob

ensure_dir(){
    mkdir -p working
    mkdir -p ../lisp/elpa
    mkdir -p ../lisp/elpa/$SUBDIR
    mkdir -p ../test/lisp/elpa
    mkdir -p ../test/lisp/elpa/$SUBDIR
}


generate_source(){
    git_treeish=$1
    package_name=$2

    mkdir -p working/$package_name

    cd repo
    if [ "$EXTERNAL" = true ] ; then
        git archive $git_treeish | tar xv --directory ../working/$package_name
    else
        git archive $git_treeish packages/$package_name | \
            tar xv --strip=2 --directory ../working/$package_name
    fi

    cd ..
}

deploy_source(){
    package_name=$1

    cd working/$package_name
    if [ -e core-deploy.sh ]
    then
        ## General extensibility point for complicated packages
        ./core-deploy.sh
    else
        if ls *!(tests)*.el >/dev/null 2>&1;
        then
            cp -v *!(tests)*.el ../../../lisp/elpa/$SUBDIR
        fi

        if ls *.texi > /dev/null 2>&1;
        then
            cp -v *.texi ../../../lisp/elpa/$SUBDIR
        fi

        if ls *tests*.el > /dev/null 2>&1;
        then
            cp -v *tests*.el ../../../test/lisp/elpa/$SUBDIR
        fi

        if ls tests/*.el > /dev/null 2>&1;
        then
            cp -v tests/*.el ../../../test/lisp/elpa/$SUBDIR
        fi
    fi
}


SUBDIR=
EXTERNAL=false

while getopts "ed:" opt; do
  case $opt in
    e)
        EXTERNAL=true
        ;;
    d)
        SUBDIR=$OPTARG
        ;;
  esac
done

shift $((OPTIND -1))

ensure_dir
generate_source $1 $2
deploy_source $2