-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpush-opam.sh
executable file
·130 lines (107 loc) · 3.92 KB
/
push-opam.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh -e
#############################################################################
#
# This file is managed by ocp-autoconf.
#
# Remove it from `manage_files` in 'ocp-autoconf.config' if you want to
# modify it manually.
#
#############################################################################
# To use this script:
# * Check that ocp-autoconf.config contains the correct version
# * Call 'ocp-autoconf' to generate 'opam'
# * Call './configure' to generate autoconf/Makefile.config
# * Call './push-opam -k' to check variables
# * Verify that the sources are available at the download url
# (on github, it means releasing the current commit with the version as tag)
# * Run './push-opam', go on your fork, and do a pull-request
# In case of error, use './push-opam -r' to revert changes locally and remotely
echo Reading information from ./autoconf/Makefile.config
echo " (generated by ./configure)"
. ./autoconf/Makefile.config
echo PACKAGE_VERSION=${PACKAGE_VERSION}
echo PACKAGE_NAME=${PACKAGE_NAME}
echo OPAM_REPO=${OPAM_REPO}
echo OPAM_REPO_FORK_REMOTE=${OPAM_REPO_FORK_REMOTE}
echo OPAM_REPO_OFFICIAL_REMOTE=${OPAM_REPO_OFFICIAL_REMOTE}
echo DOWNLOAD_URL_PREFIX=${DOWNLOAD_URL_PREFIX}
echo
VERSION=${PACKAGE_VERSION}
PACKAGE=${PACKAGE_NAME}
case "$1" in
"") break;;
-k) exit 0;;
-r)
echo Reverting changes to opam-repo
cd ${OPAM_REPO} && \
git checkout master &&
git branch -D ${PACKAGE}.${VERSION} &&
git push ${OPAM_REPO_FORK_REMOTE} :${PACKAGE}.${VERSION};
echo You can now restart.
echo
exit 0
;;
esac
if test -f ${OPAM_REPO}/.git/refs/heads/${PACKAGE}.${VERSION}; then
echo "Error: branch ${PACKAGE}.${VERSION} already exists in OPAM_REPO."
echo " Use './push-opam.sh -r' to remove it locally and remotely."
echo
exit 2
fi
if test -f ocp-autoconf.d/descr ; then :; else
echo Missing required file 'descr'
echo
exit 2
fi
echo Upgrading HEAD of OPAM_REPO...
(cd ${OPAM_REPO} && git checkout master && git pull ${OPAM_REPO_OFFICIAL_REMOTE} master)
echo
if [ ! -e ${OPAM_REPO}/packages ]; then
echo "Error: directory ${OPAM_REPO}/packages does not exist";
echo
exit 2
fi
if [ -e ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION} ]; then
echo "Error: directory for ${VERSION} already exists"
echo ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}
echo
exit 2
fi
URL=${DOWNLOAD_URL_PREFIX}${VERSION}.tar.gz
echo Downloading archive from ${URL}...
TMPFILE=/tmp/push-ocaml.tmp
rm -f ${TMPFILE}
CMD="wget -q -O ${TMPFILE} ${URL}"
echo $CMD
$CMD || (echo "Error: could not download archive."; echo; exit 2)
echo
echo "Copying files in ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}"
echo
CMD="mkdir -p ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}"
echo $CMD
$CMD
CMD="cp opam ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}/"
echo $CMD
$CMD
CMD="cp ocp-autoconf.d/descr ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}/"
echo $CMD
$CMD || echo OK
if test -f ocp-autoconf.d/findlib; then
CMD="cp ocp-autoconf.d/findlib ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}/"
echo $CMD
$CMD || echo OK
fi
echo Computing checksum on ${TMPFILE}...
md5sum ${TMPFILE}
MD5SUM=$(md5sum ${TMPFILE} | cut -b 1-32)
echo 'archive: "'${URL}'"' > ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}/url
echo 'checksum: "'${MD5SUM}'"' >> ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}/url
echo
echo Generated url file:
cat ${OPAM_REPO}/packages/${PACKAGE}/${PACKAGE}.${VERSION}/url
echo
(cd ${OPAM_REPO} &&
git checkout -b ${PACKAGE}.${VERSION} &&
git add packages/${PACKAGE}/${PACKAGE}.${VERSION} &&
git commit -m "Add ${PACKAGE}.${VERSION}" packages/${PACKAGE}/${PACKAGE}.${VERSION} &&
git push ${OPAM_REPO_FORK_REMOTE} ${PACKAGE}.${VERSION}) || echo "Error: cleanup with git branch -D ${PACKAGE}.${VERSION}"