Compare commits
355 Commits
Author | SHA1 | Date | |
---|---|---|---|
d0b8d56db4 | |||
0bc98d2bf8 | |||
10e566b640 | |||
8b6c1367f0 | |||
8be0311320 | |||
aecf691938 | |||
fcc2302ac9 | |||
096b6d6f69 | |||
0d5bc034b1 | |||
92246206dc | |||
519f8d5656 | |||
cafae574a8 | |||
88643910fb | |||
ceea7ef522 | |||
d85e5aae68 | |||
e4fcd8d6cf | |||
ac040bff56 | |||
af92aad66e | |||
702d3cfe09 | |||
8794727a6a | |||
78c85dcc7d | |||
6b784c66d3 | |||
4902ab352f | |||
193a41413a | |||
e9c5cbbdbf | |||
3013fcd2d1 | |||
5bbf2f8715 | |||
5c9a10871d | |||
de810c1bd7 | |||
f32788002f | |||
a7cbefbe18 | |||
f852838441 | |||
33c3a3ca36 | |||
70def57d53 | |||
b451ee800b | |||
f97c3c4598 | |||
acd4178c8b | |||
b6d3b83d1e | |||
9d003905df | |||
27d32d110e | |||
7dcd16b2ca | |||
dab56b358f | |||
51a0c3a449 | |||
b95cb79e69 | |||
d4241631f2 | |||
8fda5d4d82 | |||
a69962724a | |||
64394b8110 | |||
9ad95404ec | |||
ac8340c0d6 | |||
f23570f228 | |||
79af8764e1 | |||
94f1ffcf9a | |||
1c15fcfb25 | |||
5a0fa63a96 | |||
bbcfce5260 | |||
db0354041e | |||
c7d8a76d80 | |||
058a0baa7e | |||
38c75eea33 | |||
4cee459385 | |||
f47b80b1cc | |||
092e90e004 | |||
e53a62198a | |||
68bacbc599 | |||
681b2e5ec7 | |||
a6d6fd03e4 | |||
c3cbf7c0e8 | |||
ced497545e | |||
ee1a94af6f | |||
2c09744bbd | |||
7d21e2fa60 | |||
7e78d60c90 | |||
537b80a4c4 | |||
db8fa88b9b | |||
f93a093134 | |||
a49c4ec447 | |||
1c8a7cbbdf | |||
73f032afda | |||
8b9ee4a7b2 | |||
c3c5a9009e | |||
4fba9537b5 | |||
a191ef0eb3 | |||
5f2e54f58a | |||
90a0d85269 | |||
6e6d92d5a2 | |||
8f2eb49563 | |||
4ee59fdbd2 | |||
d1493a2edf | |||
c6db4b05c9 | |||
3f8d3fb9b2 | |||
77ecc7566d | |||
aca1323856 | |||
a6b14a1aa9 | |||
2e6f2dd33e | |||
fe8a60addd | |||
ef649ef1c4 | |||
a044057f9f | |||
8623f8bfd8 | |||
f47f80416d | |||
177629094c | |||
f5a01c61a6 | |||
f492d02d7d | |||
367e2f7dee | |||
144f1b0eb6 | |||
faa153d41e | |||
d435051d50 | |||
9afdb96444 | |||
eaf4e0220c | |||
3b032d1d8c | |||
6032d80cdb | |||
66ce879682 | |||
3b15ee14b7 | |||
949a4c35df | |||
d77d29fd37 | |||
4d8a804eee | |||
60f8e3cff0 | |||
73791f2c58 | |||
8aaf239342 | |||
9ab37c25c2 | |||
491357aebb | |||
bf3085f435 | |||
f6543e78fa | |||
ea098185e1 | |||
52f9b3e9e0 | |||
55224a3ecb | |||
bbcc9460b4 | |||
8e4e790104 | |||
487dbb2824 | |||
f05b31368f | |||
fa602e75e0 | |||
45b347da76 | |||
5927784c85 | |||
59a1ad0317 | |||
3e0f261856 | |||
85e7950c4e | |||
58d61d51e3 | |||
b59c024914 | |||
82c5f79f27 | |||
5241fa7e82 | |||
a89e2b9a13 | |||
f72d0b3663 | |||
56f41ede80 | |||
a59ea180af | |||
e3e4104f4e | |||
4f12cc4969 | |||
1da0a6d971 | |||
a66a8f8029 | |||
2dd4d2632d | |||
6dd2bb37bc | |||
79c00b9f50 | |||
f4dbf4b5c2 | |||
13e52f18d5 | |||
1979751f33 | |||
ed2de4963a | |||
ae9e5c3be5 | |||
457d02194c | |||
7107f7884f | |||
159432b669 | |||
c73ba35d74 | |||
2d950512e4 | |||
30e8c88970 | |||
eff79c5bf8 | |||
e6ee8dbd5b | |||
9643cf4103 | |||
bb64fe0188 | |||
1617e30950 | |||
f0eaac941b | |||
c0b7304aa4 | |||
7a268ce0c8 | |||
49a1ed773b | |||
99ab1fe252 | |||
112abc68c6 | |||
f2bb820de8 | |||
0f96bedecd | |||
70548ea687 | |||
67497d1d4f | |||
50d38312db | |||
82ab9d49c9 | |||
24f57a4cd4 | |||
0c9f7b442e | |||
03d939419c | |||
ea9bd6e623 | |||
6fc6b0bda6 | |||
2979f8d61b | |||
25b48ad735 | |||
5df925c70b | |||
34796d0b38 | |||
9076297743 | |||
49f415f364 | |||
bdc9145d01 | |||
49bda1c6c3 | |||
82337b4343 | |||
9ab269e0f7 | |||
d73319d4ea | |||
aee7f737b1 | |||
14d27be655 | |||
f5d91a52fc | |||
ecc3ed74a2 | |||
dd9fb71c1b | |||
094174a2b6 | |||
a939e6217a | |||
10b3f8eff0 | |||
4cf07b63e5 | |||
0669999e60 | |||
a6bcf08a21 | |||
77cfdacce8 | |||
1815ade013 | |||
374848a5a0 | |||
c35c462647 | |||
ea17d50b69 | |||
ef98426c64 | |||
cbe63c0c85 | |||
ee91237d64 | |||
0febe8f777 | |||
fd294840b1 | |||
aeec210b02 | |||
24f394ce84 | |||
becb15708b | |||
0e2960e708 | |||
92a3d43064 | |||
16b2ff1ce9 | |||
07e9b8a75d | |||
56923432c9 | |||
74876ce852 | |||
272860e5fe | |||
c0f51ea3ac | |||
dc7de5b07c | |||
641029e7ec | |||
9cfdccccc0 | |||
19233fce7d | |||
dd369356c5 | |||
0315d1a69d | |||
8751a555bc | |||
d7fa8c819b | |||
d99d231b47 | |||
8fa299b2f2 | |||
e0f9129ac5 | |||
2b8d183d22 | |||
4ff95a4a86 | |||
47661108aa | |||
a52cecc4c5 | |||
035e78eba8 | |||
f9a0a4f5bd | |||
45749c8a4a | |||
53163c856a | |||
a218041054 | |||
7029416146 | |||
61710ad694 | |||
b84e90b7db | |||
3927887baf | |||
740eb19d7c | |||
46a9b5cf33 | |||
c23ffef2a9 | |||
9367503886 | |||
466141bd3e | |||
3a7772cb70 | |||
c1617df152 | |||
91ad537c95 | |||
52ea72fb98 | |||
2d68892ef4 | |||
0deefe9b43 | |||
1471140bd4 | |||
d7f48ae5af | |||
8576dc1d8c | |||
2674eed1f2 | |||
ac6f81462a | |||
06d4c75c90 | |||
88ab767d1b | |||
abe0683b5f | |||
9778194a65 | |||
2036752464 | |||
ec6b60b45d | |||
54379b55d4 | |||
ccf4cda924 | |||
f43a210165 | |||
5aa631ff10 | |||
c1285c09cf | |||
8235cba011 | |||
0a7f28e6e3 | |||
1df35a2641 | |||
e0ee0726c8 | |||
625c2b3ed2 | |||
a0314b874b | |||
95c366a940 | |||
ec39f8f7cb | |||
6d278e3a20 | |||
24afa0b07b | |||
03a198fec4 | |||
432f79fa29 | |||
4b8773011b | |||
0168057f06 | |||
84d27d1f44 | |||
6cf3e9f99f | |||
878663f2f0 | |||
25f1c4bb8c | |||
87a184e585 | |||
2f6984ed3b | |||
aabe20a9ad | |||
9f98345aad | |||
d3705b31c7 | |||
76032ddcb4 | |||
12b3759777 | |||
0e1067c930 | |||
12d8eafdc4 | |||
0601482f54 | |||
4021d4f7a1 | |||
9a8b1355f7 | |||
1514f95b2b | |||
1f088616ad | |||
eebf7f263d | |||
ffff0b1c10 | |||
e66061e4c3 | |||
298ad4d73c | |||
71fec6c77a | |||
dcff130bdf | |||
5170d2815a | |||
455ca50f06 | |||
0d02eac831 | |||
dd53d60b85 | |||
c1ed68dd78 | |||
17c9e4d33a | |||
a518dbe02a | |||
b36a8a552e | |||
b9803712a2 | |||
b3e82e19b4 | |||
e6f4f990e4 | |||
13c5359c92 | |||
b37324962c | |||
79e63cd2a3 | |||
f842044af6 | |||
1e2ba88e57 | |||
61a6f72850 | |||
cd1132a916 | |||
a36d759531 | |||
2ee18817c4 | |||
00adf496ba | |||
a5f3beda83 | |||
0be3a1fc97 | |||
005fe6a6f5 | |||
25cc256ba5 | |||
7f92f0fd95 | |||
4a281ed9dc | |||
761ae3b3fb | |||
179121211e | |||
c9da095026 | |||
6e2a4ded8c | |||
ada79d6f76 | |||
dbaaa43f7f | |||
e6556e1063 | |||
a4ccca0e26 | |||
11951519dc | |||
d2b7713cff | |||
2a89f70381 | |||
ba9a55182e |
103
Makefile
@ -1,33 +1,37 @@
|
||||
# Makefile for autodist
|
||||
# Copyright (C) 2006-2009 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Copyright (C) 2006-2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
PACKAGE = autodist
|
||||
|
||||
include VERSION
|
||||
|
||||
prefix = /usr
|
||||
exec_prefix = ${prefix}
|
||||
sysconfdir = /etc
|
||||
sbindir = ${exec_prefix}/sbin
|
||||
bindir = ${exec_prefix}/bin
|
||||
datadir = ${prefix}/share
|
||||
initrddir = ${sysconfdir}/rc.d/init.d
|
||||
mandir = ${prefix}/usr/share/man
|
||||
sysconfigdir= ${sysconfdir}/sysconfig
|
||||
configdir = ${sysconfdir}/autodist
|
||||
localstatedir= /var
|
||||
piddir= ${localstatedir}/run/autodist
|
||||
prefix := /usr
|
||||
exec_prefix := ${prefix}
|
||||
sysconfdir := /etc
|
||||
sbindir := ${exec_prefix}/sbin
|
||||
bindir := ${exec_prefix}/bin
|
||||
datadir := ${prefix}/share
|
||||
unitdir := ${prefix}/lib/systemd/system
|
||||
libexecdir := ${prefix}/libexec
|
||||
mandir := ${prefix}/usr/share/man
|
||||
sysconfigdir := ${sysconfdir}/sysconfig
|
||||
configdir := ${sysconfdir}/autodist
|
||||
localstatedir := /var
|
||||
piddir := /run/autodist
|
||||
cgidir := ${localstatedir}/www/cgi-bin
|
||||
htmldir := ${localstatedir}/www/html
|
||||
|
||||
srcdir = .
|
||||
DESTDIR =
|
||||
|
||||
INSTALL = /usr/bin/install
|
||||
INSTALL_PROGRAM = ${INSTALL} -m 755
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
INSTALL_DIR = ${INSTALL} -d -m 755
|
||||
INSTALL_SCRIPT = ${INSTALL_PROGRAM}
|
||||
INSTALL := /usr/bin/install
|
||||
INSTALL_PROGRAM := ${INSTALL} -m 755
|
||||
INSTALL_DATA := ${INSTALL} -m 644
|
||||
INSTALL_DIR := ${INSTALL} -d -m 755
|
||||
INSTALL_SCRIPT := ${INSTALL_PROGRAM}
|
||||
|
||||
pck_datadir = $(localstatedir)/$(PACKAGE)
|
||||
pck_datadir = $(datadir)/$(PACKAGE)
|
||||
pck_statedir = $(localstatedir)/$(PACKAGE)
|
||||
pck_logdir = $(localstatedir)/$(PACKAGE)/log
|
||||
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
@ -43,49 +47,70 @@ install-dirs:
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/cron.hourly
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/cron.daily
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/sysconfig
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/logrotate.d
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(bindir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(sbindir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(cgidir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(htmldir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(unitdir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/template/autoupdate/spec-patches-build/old
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/template/autoupdate/spec-patches-update/old
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)/template/autoupdate/spec-patches-build/old
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)/template/autoupdate/spec-patches-update/old
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/prepare/{ok,failed}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/update/{ok,failed}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/build/{ok,failed}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/install/{ok,failed}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/send/{ok,failed}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/RPM/{SPECS,SRPMS,BUILD,SOURCES,RPMS/{noarch,i586,ppc,x86_64,arm}}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(piddir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(pck_statedir)/RPM/{SPECS,SRPMS,BUILD,SOURCES,RPMS/{noarch,i586,x86_64,arm,aarch64}}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(libexecdir)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(localstatedir)/webbuild/{cache,home,notes,tmp,users,uploads}
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(prefix)/lib/tmpfiles.d/
|
||||
|
||||
install-programs:
|
||||
@$(INSTALL_SCRIPT) autodist $(DESTDIR)$(bindir)/autodist
|
||||
@$(INSTALL_SCRIPT) autodist-tool $(DESTDIR)$(bindir)/autodist-tool
|
||||
@$(INSTALL_SCRIPT) autodist-launcher $(DESTDIR)$(bindir)/autodist-launcher
|
||||
@$(INSTALL_SCRIPT) autoport $(DESTDIR)$(bindir)/autoport
|
||||
@$(INSTALL_SCRIPT) autoport-launcher $(DESTDIR)$(bindir)/autoport-launcher
|
||||
@$(INSTALL_SCRIPT) autoport-chroot $(DESTDIR)$(sbindir)/autoport-chroot
|
||||
@$(INSTALL_SCRIPT) automaint $(DESTDIR)$(sbindir)/automaint
|
||||
@$(INSTALL_SCRIPT) autodist-inspect $(DESTDIR)$(bindir)/autodist-inspect
|
||||
@$(INSTALL_SCRIPT) autodist-repository $(DESTDIR)$(sbindir)/autodist-repository
|
||||
@$(INSTALL_SCRIPT) autodist-upstream-updates $(DESTDIR)$(sbindir)/autodist-upstream-updates
|
||||
@$(INSTALL_SCRIPT) autoport-fix-environment $(DESTDIR)$(bindir)/autoport-fix-environment
|
||||
@$(INSTALL_SCRIPT) etc/autodist/scripts/* $(DESTDIR)$(configdir)/scripts/
|
||||
@$(INSTALL_SCRIPT) autodist-cgi $(DESTDIR)$(cgidir)/autodist
|
||||
@$(INSTALL_SCRIPT) webbuild/webbuild-cgi $(DESTDIR)$(cgidir)/webbuild
|
||||
@$(INSTALL_SCRIPT) webbuild/webbuild-sudo $(DESTDIR)$(libexecdir)/webbuild-sudo
|
||||
@$(INSTALL_SCRIPT) webbuild/webbuild-checkpassword $(DESTDIR)$(libexecdir)/webbuild-checkpassword
|
||||
@$(INSTALL_SCRIPT) webbuild/webbuild-functions $(DESTDIR)$(pck_datadir)/webbuild-functions
|
||||
@$(INSTALL_SCRIPT) webbuild/webbuild-functions-private $(DESTDIR)$(pck_datadir)/webbuild-functions-private
|
||||
@$(INSTALL_SCRIPT) telegram/openmamba_bot.py $(DESTDIR)$(pck_datadir)/openmamba_bot.py
|
||||
@$(INSTALL_SCRIPT) telegram/requirements.txt $(DESTDIR)$(pck_datadir)/requirements.txt
|
||||
@$(INSTALL_SCRIPT) repology-openmamba.py $(DESTDIR)$(pck_datadir)/repology-openmamba.py
|
||||
@cp -a webbuild/html/* $(DESTDIR)$(htmldir)
|
||||
|
||||
install-data:
|
||||
@$(INSTALL_DATA) etc/autodist/config $(DESTDIR)$(configdir)/config
|
||||
@$(INSTALL_DATA) etc/autodist/distdb $(DESTDIR)$(configdir)/distdb
|
||||
@$(INSTALL_DATA) etc/autodist/distdb.i586 $(DESTDIR)$(configdir)/distdb.i586
|
||||
@$(INSTALL_DATA) etc/autodist/distdb.arm $(DESTDIR)$(configdir)/distdb.arm
|
||||
@$(INSTALL_DATA) etc/autodist/distdb.x86_64 $(DESTDIR)$(configdir)/distdb.x86_64
|
||||
@$(INSTALL_DATA) etc/autodist/distdb.ppc $(DESTDIR)$(configdir)/distdb.ppc
|
||||
@$(INSTALL_DATA) etc/autodist/unstage $(DESTDIR)$(configdir)/unstage
|
||||
@$(INSTALL_DATA) etc/autodist/unstage.i586 $(DESTDIR)$(configdir)/unstage.i586
|
||||
@$(INSTALL_DATA) etc/autodist/unstage.arm $(DESTDIR)$(configdir)/unstage.arm
|
||||
@$(INSTALL_DATA) etc/autodist/unstage.x86_64 $(DESTDIR)$(configdir)/unstage.x86_64
|
||||
@$(INSTALL_DATA) etc/autodist/unstage.ppc $(DESTDIR)$(configdir)/unstage.ppc
|
||||
@$(INSTALL_DATA) etc/autodist/distdb.d/*.db $(DESTDIR)$(configdir)/distdb.d/
|
||||
@$(INSTALL_DATA) etc/autodist/blacklist $(DESTDIR)$(configdir)/blacklist
|
||||
@$(INSTALL_DATA) etc/autodist/distdb.d/* $(DESTDIR)$(configdir)/distdb.d/
|
||||
@$(INSTALL_DATA) etc/sudoers.d/autoport $(DESTDIR)$(sysconfdir)/sudoers.d/autoport
|
||||
@$(INSTALL_DATA) webbuild/webbuild-sudoers $(DESTDIR)$(sysconfdir)/sudoers.d/webbuild
|
||||
@$(INSTALL_DATA) webbuild/webbuild-admin $(DESTDIR)$(localstatedir)/webbuild/users/admin.conf
|
||||
@$(INSTALL_SCRIPT) etc/sysconfig/autoport $(DESTDIR)$(sysconfdir)/sysconfig/autoport
|
||||
@$(INSTALL_SCRIPT) etc/cron.hourly/65-openmamba-autobuild-autoport $(DESTDIR)$(sysconfdir)/cron.hourly/
|
||||
@$(INSTALL_SCRIPT) etc/cron.daily/40-openmamba-autodist-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/
|
||||
@$(INSTALL_DATA) autospec-conf $(DESTDIR)$(pck_datadir)/.autospec
|
||||
@touch $(DESTDIR)$(pck_datadir)/template/autoupdate/auto.success
|
||||
@touch $(DESTDIR)$(pck_datadir)/template/autoupdate/auto.skip
|
||||
@$(INSTALL_SCRIPT) etc/cron.hourly/60-autodist-update $(DESTDIR)$(sysconfdir)/cron.hourly/
|
||||
@$(INSTALL_SCRIPT) etc/cron.hourly/65-autoport $(DESTDIR)$(sysconfdir)/cron.hourly/
|
||||
@$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/
|
||||
@$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-upstream-updates $(DESTDIR)$(sysconfdir)/cron.daily/
|
||||
@$(INSTALL_SCRIPT) etc/logrotate.d/webbuild $(DESTDIR)$(sysconfdir)/logrotate.d/webbuild
|
||||
@$(INSTALL_DATA) autospec-conf $(DESTDIR)$(pck_statedir)/.autospec
|
||||
@$(INSTALL_DATA) autodist-bashrc $(DESTDIR)$(pck_statedir)/.bashrc
|
||||
@$(INSTALL_DATA) autodist-bash_profile $(DESTDIR)$(pck_statedir)/.bash_profile
|
||||
@$(INSTALL_DATA) autodist-tmpfilesd $(DESTDIR)$(prefix)/lib/tmpfiles.d/autodist.conf
|
||||
@$(INSTALL_DATA) telegram/openmambabot.service $(DESTDIR)$(unitdir)/openmambabot.service
|
||||
@touch $(DESTDIR)$(pck_statedir)/template/autoupdate/auto.success
|
||||
@touch $(DESTDIR)$(pck_statedir)/template/autoupdate/auto.skip
|
||||
|
||||
install: \
|
||||
install-dirs \
|
||||
|
14
autodist-bash_profile
Normal file
@ -0,0 +1,14 @@
|
||||
# .bash_profile
|
||||
|
||||
# Get the aliases and functions
|
||||
if [ -f ~/.bashrc ]; then
|
||||
. ~/.bashrc
|
||||
fi
|
||||
|
||||
# User specific environment and startup programs
|
||||
if [ -d $HOME/bin ]; then
|
||||
PATH=$PATH:$HOME/bin
|
||||
fi
|
||||
export PATH
|
||||
|
||||
unset USERNAME
|
8
autodist-bashrc
Normal file
@ -0,0 +1,8 @@
|
||||
# .bashrc
|
||||
|
||||
# User specific aliases and functions
|
||||
|
||||
# Source global definitions
|
||||
if [ -f /etc/bashrc ]; then
|
||||
. /etc/bashrc
|
||||
fi
|
379
autodist-cgi
Executable file
@ -0,0 +1,379 @@
|
||||
#!/bin/bash
|
||||
. /etc/sysconfig/autoport
|
||||
. /usr/share/autodist/webbuild-functions
|
||||
|
||||
NUM=`echo "$QUERY_STRING" | sed -n 's/^.*NUM=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
HOST=`echo "$QUERY_STRING" | sed -n 's/^.*HOST=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
REP=`echo "$QUERY_STRING" | sed -n 's/^.*REP=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
AS_HOST=`echo "$QUERY_STRING" | sed -n 's/^.*AS_HOST=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
SHOWLOG=`echo "$QUERY_STRING" | sed -n 's/^.*SHOWLOG=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
SHOWINDEX=`echo "$QUERY_STRING" | sed -n 's/^.*SHOWINDEX=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
LINES=`echo "$QUERY_STRING" | sed -n 's/^.*LINES=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
FORMAT=`echo "$QUERY_STRING" | sed -n 's/^.*FORMAT=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||
|
||||
function resolve_logname() {
|
||||
local l=$1
|
||||
local jobname=$2
|
||||
|
||||
unset SUBJOBNAME OPERATIONNAME OPERATIONSTATUS
|
||||
|
||||
SUBJOBNAME=`echo $l | sed "s|.*/${jobname}_\(.*\)\..*|\1|"`
|
||||
[ "${SUBJOBNAME:0:1}" = "_" ] && SUBJOBNAME=$l
|
||||
[ "$SUBJOBNAME" = "$l" ] && SUBJOBNAME=`echo $l | sed "s|.*/\(.*\)\..*|\1|"`
|
||||
SUBJOBNAME=${SUBJOBNAME/__*}
|
||||
[ "${BUILDOPERATION[$b]}" ] && \
|
||||
OPERATIONNAME=${BUILDOPERATION[$b]} || OPERATIONNAME=`echo $l | sed "s|\(.*\)/.*/.*|\1|"`
|
||||
[ "${BUILDOPERATIONSTATUS[$b]}" ] && \
|
||||
OPERATIONSTATUS=${BUILDOPERATIONSTATUS[$b]} || OPERATIONSTATUS=`echo $l | sed "s|.*/\(.*\)/.*|\1|"`
|
||||
}
|
||||
|
||||
[ ! "$FORMAT" ] && FORMAT=html
|
||||
|
||||
[ "$LINES" ] || LINES=5
|
||||
|
||||
[ "$HOST" ] || HOST=0
|
||||
[ "$AS_HOST" ] || AS_HOST=0
|
||||
|
||||
[ "$AS_HOST" -a "$HOST" != "0" ] && HOST_ADD="&HOST=$HOST"
|
||||
|
||||
if [ "$AS_HOST" = "0" -a "$FORMAT" = "xml" ]; then
|
||||
echo -e "Content-type: text/xml\nPragma: no-cache\n"
|
||||
echo -n "<autodist><output><![CDATA["
|
||||
RELOADTIME=3600000
|
||||
else
|
||||
echo -e "Content-type: text/html; charset=UTF-8\n"
|
||||
fi
|
||||
|
||||
if [ "$SHOWINDEX" ]; then
|
||||
echo "Host $AS_HOST:"
|
||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
[ "${AUTOPORT_ARCH[$i]}" ] || continue
|
||||
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
|
||||
|
||||
RNUM=-1
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
RNUM=`expr $RNUM + 1`
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
echo "<a href=\"?NUM=$i&REP=$RNUM$HOST_ADD\">$r(${AUTOPORT_ARCH[$i]})</a> "
|
||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
echo "<a href=\"?NUM=$i&REP=$RNUM$HOST_ADD\">$r(${AUTOPORT_ARCH[$i]})</a> "
|
||||
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
echo "<a href=\"?NUM=$i&REP=$RNUM$HOST_ADD\">$r(${AUTOPORT_ARCH[$i]})</a> "
|
||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
echo "<a href=\"?NUM=$i&REP=$RNUM$HOST_ADD\">$r(${AUTOPORT_CROSS[$i]};${AUTOPORT_ARCH[$i]})</a> "
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "<br>"
|
||||
exit 0
|
||||
elif [ "$AS_HOST" = "0" ]; then
|
||||
echo "Show: [<a href=\"?NUM=\">All hosts</a>] [<a href=\"?SHOWLOG=monitor\">Build hosts monitor</a>]<br>"
|
||||
for h in `seq 0 ${#AUTOPORT_CGI_HOST[*]}`; do
|
||||
curl --connect-timeout 20 "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&SHOWINDEX=1" 2>/dev/null
|
||||
done
|
||||
echo "<hr>"
|
||||
fi
|
||||
|
||||
[ ! "$SHOWLOG" -a "$HOST" = "$AS_HOST" ] && echo "<h2>Host: `hostname -s` (`uname -m`, kernel `uname -r`)</h2>"
|
||||
|
||||
if [ "$SHOWLOG" -a "$HOST" != "$AS_HOST" ]; then
|
||||
curl "${AUTOPORT_CGI_HOST[$HOST]}?AS_HOST=$HOST&SHOWLOG=$SHOWLOG&NUM=$NUM&REP=$REP&LOG=$LOG" 2>/dev/null
|
||||
else
|
||||
|
||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
if [ "$SHOWLOG" = "monitor" ]; then
|
||||
echo "<h2>Build hosts monitor</h2>"
|
||||
icecream-monitor $ICECREAM_MONITOR_HOST listcs | \
|
||||
while read line; do
|
||||
[ "${line:0:8}" = "200 done" ] && printon=
|
||||
if [ "$printon" ]; then
|
||||
set -- $line
|
||||
case $2 in
|
||||
\(*) echo "<b>$line</b><br>" ;;
|
||||
*) echo "$line<br>" ;;
|
||||
esac
|
||||
fi
|
||||
[ "${line:0:6}" = "listcs" ] && printon=1
|
||||
done
|
||||
echo "<br>"
|
||||
RELOADTIME=15000
|
||||
break
|
||||
fi
|
||||
RNUM=-1
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
[ "${AUTOPORT_ARCH[$i]}" ] || continue
|
||||
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
|
||||
RNUM=`expr $RNUM + 1`
|
||||
LOGDIR=`environment_logdir $i`
|
||||
AUTOPORTLOGDIR=`environment_autoport_logdir $i`
|
||||
ENVROOTDIR=`environment_rootdir $i`
|
||||
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
LOGFILE="$LOGDIR/autodist.log"
|
||||
LASTLOGFILE="$LOGDIR/autodist-last.log"
|
||||
STATEFILE="$LOGDIR/autoupdate-current"
|
||||
LASTSTATEFILE="$LOGDIR/autoupdate-last"
|
||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
LOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}-last.log"
|
||||
AUTODISTLOGFILE="$AUTOPORTLOGDIR/${AUTOPORT_ARCH[$i]}/$r-current.log"
|
||||
AUTODISTSTATEFILE="$AUTOPORTLOGDIR/autoport-$r-current"
|
||||
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
LOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}-last.log"
|
||||
AUTODISTLOGFILE="$AUTOPORTLOGDIR/${AUTOPORT_ARCH[$i]}/$r-current.log"
|
||||
AUTODISTSTATEFILE="$AUTOPORTLOGDIR/autoport-$r-current"
|
||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
LOGFILE="$LOGDIR/autoport-cross-$r-${AUTOPORT_CROSS[$i]}.log"
|
||||
LASTLOGFILE="$LOGDIR/autoport-cross-$r-${AUTOPORT_CROSS[$i]}-last.log"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
if [ "$SHOWLOG" ]; then
|
||||
if [ "$HOST" = "$AS_HOST" -a "$NUM" = "$i" -a "$REP" = "$RNUM" ]; then
|
||||
echo -n "<p><h2>$SHOWLOG log in "
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
echo -n "update"
|
||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
echo -n "${AUTOPORT_CHROOT[i]} chroot"
|
||||
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
echo -n "native"
|
||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
echo -n "cross"
|
||||
fi
|
||||
echo " environment for ${AUTOPORT_ARCH[$i]}"
|
||||
[ "${SHOWLOG}" = "current" -o "${SHOWLOG}" = "last" -a ! "${AUTOPORT_UPDATE[$i]}" ] && echo -n " ($r)"
|
||||
echo -n ":</h2>"
|
||||
cat << _EOF
|
||||
<div class="downloadbox" align="center">
|
||||
<div class="output outputbox">
|
||||
_EOF
|
||||
echo -n "<pre><code>"
|
||||
if [ "$SHOWLOG" = "current" ]; then
|
||||
RELOADTIME=3600000
|
||||
cat $LOGFILE | parse_build_output
|
||||
elif [ "$SHOWLOG" = "last" ]; then
|
||||
cat $LASTLOGFILE | parse_build_output
|
||||
LASTLOGDETAILS=`tail $LASTLOGFILE | grep "See .* for details" | sed "s|.*See \(.*\) for details.*|\1|"`
|
||||
cat $ENVROOTDIR/$LASTLOGDETAILS | parse_build_output
|
||||
else
|
||||
# Security check
|
||||
[ "${SHOWLOG/\/\.}" != "${SHOWLOG}" ] && continue
|
||||
BUILDLOGDIR="$LOGDIR"
|
||||
if [ "${SHOWLOG/\/ok\/}" != "${SHOWLOG}" -o "${SHOWLOG/\failed\/}" != "${SHOWLOG}" ]; then
|
||||
SHOWLOGPKG=${SHOWLOG/*\/}
|
||||
[ "${SHOWLOGPKG}" ] || continue
|
||||
echo "<table style=\"color:black;width:auto;\"><tr><td colspan=3>Last ${SHOWLOGPKG} logs:</td>"
|
||||
for t in prepare update build install send; do
|
||||
echo -n "<tr><td>$t:</td><td>"
|
||||
[ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "<td><a style=\"color:green;text-decoration:none\" target=_autodist href=\"?NUM=$i&REP=$RNUM$HOST_ADD&SHOWLOG=${t}/ok/${SHOWLOGPKG}\">OK</a></td>" || echo "<td></td>"
|
||||
[ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "<td><a style=\"color:green;text-decoration:none\" target=_autodist href=\"?NUM=$i&REP=$RNUM$HOST_ADD&SHOWLOG=${t}/failed/${SHOWLOGPKG}\">FAILED</a></td>" || echo "<td></td>"
|
||||
echo "</tr>"
|
||||
done
|
||||
echo "</table>"
|
||||
fi
|
||||
if [ -r ${BUILDLOGDIR}${SHOWLOG} ]; then
|
||||
LOGFILESIZE=`stat -c %s ${BUILDLOGDIR}${SHOWLOG}`
|
||||
LOGDATE=`stat -c %y ${BUILDLOGDIR}${SHOWLOG}`
|
||||
echo -n "<b>${SHOWLOG} ($LOGDATE; $LOGFILESIZE):</b>"
|
||||
if [ $LOGFILESIZE -lt 131072 ]; then
|
||||
cat ${BUILDLOGDIR}${SHOWLOG} | parse_build_output
|
||||
else
|
||||
head -c 65535 ${BUILDLOGDIR}${SHOWLOG} | parse_build_output
|
||||
echo "<br><font style=\"background-color:yellow;color:black\"><------ CUT (long file) ------></font>"
|
||||
tail -c 65535 ${BUILDLOGDIR}${SHOWLOG} | parse_build_output
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo -n "</pre></code>"
|
||||
echo -n "</div></div>"
|
||||
# break
|
||||
fi
|
||||
[ "${AUTOPORT_UPDATE[$i]}" ] && break
|
||||
elif [ ! "$SHOWLOG" ]; then
|
||||
RELOADTIME=600000
|
||||
[[ "$NUM" && "$NUM" != "$i" ]] && continue
|
||||
[[ "$HOST" = "$AS_HOST" ]] || continue
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
echo "<b>* <a target=_autodist href=\"?NUM=$i&REP=$RNUM&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:autodist update)"
|
||||
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i&REP=$RNUM$HOST_ADD\">log</a> <a target=_autodist href=\"?SHOWLOG=last&NUM=$i&REP=$RNUM$HOST_ADD\">last</a> ]</b>"
|
||||
fi
|
||||
|
||||
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
echo "<b>* <a target=_autodist href=\"?NUM=$i&REP=$RNUM&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:chroot autoport</a> chroot:${AUTOPORT_CHROOT[$i]})"
|
||||
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i&REP=$RNUM$HOST_ADD\">log</a> <a target=_autodist href=\"?SHOWLOG=last&NUM=$i&REP=$RNUM$HOST_ADD\">last</a> ]</b>"
|
||||
fi
|
||||
|
||||
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
echo "<b>* <a target=_autodist href=\"?NUM=$i&REP=$RNUM&HOST=$AS_HOST\">$r</a>(${AUTOPORT_ARCH[$i]}) (type:native autoport)"
|
||||
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i&REP=$RNUM$HOST_ADD\">log</a> <a target=_autodist href=\"?SHOWLOG=last&NUM=$i&REP=$RNUM$HOST_ADD\">last</a> ]</b>"
|
||||
fi
|
||||
|
||||
if [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
echo "<b>* <a target=_autodist href=\"?NUM=$i&REP=$RNUM&HOST=$AS_HOST\">cross-platform</a> autoport (arch:${AUTOPORT_CROSS[$i]})</b>"
|
||||
echo " [ <a target=_autodist href=\"?SHOWLOG=current&NUM=$i&REP=$RNUM$HOST_ADD\">last</a> ]</b>"
|
||||
fi
|
||||
cat << _EOF
|
||||
<div class="downloadbox" align="center">
|
||||
<div align="left" class="showlogbox">
|
||||
_EOF
|
||||
echo -n "<pre style='margin:1px;word-wrap:normal;white-space:pre;'>"
|
||||
unset BUILDNOWIDX BUILDLOG BUILDNOW BUILDNOWSTATUS SCHEDULED STARTTIME AUTODIST_PID ENDTIME
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
BUILDNOWIDX=0
|
||||
STARTTIME=`head $LOGFILE | grep "%% Autodist started" | sed "s|.* @ ||"`
|
||||
AUTODIST_PID=`head $LOGFILE | grep "%% Autodist started" | sed "s|.*PID \([0-9]*\) .*|\1|"`
|
||||
SCHEDULED=`head $LOGFILE | grep "%% autoupdate jobs:" | sed "s|.*autoupdate jobs: ||"`
|
||||
ENDTIME=`tail $LOGFILE | grep "%% All jobs done @" | sed "s|.*@ ||"`
|
||||
while read line; do
|
||||
set -- $line
|
||||
for c in `seq 0 ${#BUILDNOW[*]}`; do
|
||||
if [ "${BUILDNOW[c]}" = "$1" ]; then
|
||||
BUILDNOWIDX=$c
|
||||
break
|
||||
else
|
||||
BUILDNOWIDX=$c
|
||||
fi
|
||||
done
|
||||
BUILDNOW[$BUILDNOWIDX]="$1"
|
||||
[ "$4" ] && BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} `echo $4 | sed "s|.*autodist/log/||"`"
|
||||
# BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $2/$3/$1.i586"
|
||||
BUILDNOWSTATUS[$BUILDNOWIDX]=$3
|
||||
BUILDNOWIDX=`expr $BUILDNOWIDX + 1`
|
||||
done < $STATEFILE
|
||||
else
|
||||
STARTTIME=`head $LOGFILE | grep "^+ .*start at " | sed "s|.*start at ||"`
|
||||
# AUTODIST_PID=`head $LOGFILE | grep "%% Autodist started" | sed "s|.*PID \([0-9]*\) .*|\1|"`
|
||||
SCHEDULED=`head -n 40 $LOGFILE | grep -m 1 "^> .*Scheduled jobs: " | sed "s|.*Scheduled jobs: ||"`
|
||||
ENDTIME=`tail $LOGFILE | grep "^- .*end at " | sed "s|.*end at ||"`
|
||||
if [ -e "$AUTODISTSTATEFILE" ]; then
|
||||
while read line; do
|
||||
set -- $line
|
||||
for c in `seq 0 ${#BUILDNOW[*]}`; do
|
||||
if [ "${BUILDNOW[c]}" = "$1" ]; then
|
||||
BUILDNOWIDX=$c
|
||||
break
|
||||
else
|
||||
BUILDNOWIDX=$c
|
||||
fi
|
||||
done
|
||||
BUILDNOW[$BUILDNOWIDX]="$1"
|
||||
if [ "$4" ]; then
|
||||
BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} `echo $4 | sed "s|.*/log/||"`"
|
||||
else
|
||||
if [ "$2" = "port" ]; then
|
||||
CURRLOGFILE=build/$3/$1.${AUTOPORT_ARCH[$i]}
|
||||
else
|
||||
CURRLOGFILE=$2/$3/$1.${AUTOPORT_ARCH[$i]}
|
||||
fi
|
||||
BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $CURRLOGFILE"
|
||||
fi
|
||||
# BUILDLOG[$BUILDNOWIDX]="${BUILDLOG[$BUILDNOWIDX]} $2/$3/$1.i586"
|
||||
BUILDNOWSTATUS[$BUILDNOWIDX]=$3
|
||||
BUILDNOWIDX=`expr $BUILDNOWIDX + 1`
|
||||
done < $AUTODISTSTATEFILE
|
||||
for p in `dirname $LOGFILE`/current.*; do
|
||||
CURRENT_FILE=`basename $p`
|
||||
AUTODIST_PID=${p/*.}
|
||||
grep "autodist" /proc/$AUTODIST_PID/status &>/dev/null && break
|
||||
AUTODIST_PID=
|
||||
done
|
||||
fi
|
||||
fi
|
||||
[ "$STARTTIME" ] && echo "<b>Start:</b> $STARTTIME"
|
||||
[ "$SCHEDULED" ] && echo "<b>Scheduled jobs:</b> $SCHEDULED"
|
||||
LASTJOBNAME=
|
||||
for b in `seq 0 ${#BUILDNOW[*]}`; do
|
||||
# set -- ${BUILDNOW[$b]}
|
||||
JOBNAME=${BUILDNOW[$b]}
|
||||
[ "$JOBNAME" ] || continue
|
||||
if [ "$JOBNAME" != "$LASTJOBNAME" ]; then
|
||||
[ "$LASTJOBNAME" -a "$JOBNAME" ] && echo
|
||||
if [ "${BUILDLOG[$b]}" ]; then
|
||||
resolve_logname ${BUILDLOG[$b]/* } $JOBNAME
|
||||
if [ "${OPERATIONSTATUS}" = "ok" ]; then
|
||||
WEBBUILD_APPEND="&LOGSTATUSOK=true"
|
||||
else
|
||||
WEBBUILD_APPEND="&LOGSTATUSOK=false"
|
||||
fi
|
||||
echo -n "<a target=_webbuild href=\"$AUTOPORT_WEBBUILD_HOST?REQUEST=autobuildedit&ENVIRONMENT=$i&PACKAGE=$JOBNAME&LOGTYPE=$OPERATIONNAME${WEBBUILD_APPEND}\"><b>$JOBNAME</b></a>: "
|
||||
else
|
||||
echo -n "<a target=_webbuild href=\"$AUTOPORT_WEBBUILD_HOST?ENVIRONMENT=$i&PACKAGE=$JOBNAME\"><b>$JOBNAME</b></a>: "
|
||||
fi
|
||||
fi
|
||||
rowcnt=0
|
||||
if [ "${BUILDLOG[$b]}" ]; then
|
||||
for l in ${BUILDLOG[$b]}; do
|
||||
resolve_logname $l $JOBNAME
|
||||
# if [ $rowcnt -ge 4 ]; then
|
||||
# echo
|
||||
# rowcnt=0
|
||||
# fi
|
||||
case $OPERATIONNAME-$OPERATIONSTATUS in
|
||||
build-ok|send-ok|install-ok|retryinstall-ok)
|
||||
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\">$OPERATIONNAME:$OPERATIONSTATUS</a>"
|
||||
;;
|
||||
update-failed|autoupdate-failed)
|
||||
if [ "${BUILDNOWSTATUS[$b]}" = "4" ]; then
|
||||
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\"><font color=green>$OPERATIONNAME:up-to-date</font></a>"
|
||||
elif [ "${BUILDNOWSTATUS[$b]}" = "3" ]; then
|
||||
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\"><font color=darkgoldenrod>$OPERATIONNAME:unknown</font></a>"
|
||||
elif [ "${BUILDNOWSTATUS[$b]}" = "2" ]; then
|
||||
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\"><font color=darkgoldenrod>$OPERATIONNAME:newer</font></a>"
|
||||
else
|
||||
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\"><font color=red>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
|
||||
fi
|
||||
;;
|
||||
*-ok) echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\"><font color=black>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
|
||||
;;
|
||||
*)
|
||||
echo -n "<a target=_autodist href=\"?SHOWLOG=$l&NUM=$i&REP=$RNUM$HOST_ADD\"><font color=red>$OPERATIONNAME:$OPERATIONSTATUS</font></a>"
|
||||
;;
|
||||
esac
|
||||
# [ "$SUBJOBNAME" != "$JOBNAME" ] && echo -en "(<a href=\"$AUTOPORT_WEBBUILD_HOST?ENVIRONMENT=$i&PACKAGE=$SUBJOBNAME\" target=\"webbuild\">$SUBJOBNAME</a>)"
|
||||
echo -n " "
|
||||
rowcnt=`expr $rowcnt + 1`
|
||||
done
|
||||
fi
|
||||
if [[ $b -eq $BUILDNOWIDX-1 && ! "$ENDTIME" ]]; then
|
||||
echo -n "<font color=green>${BUILDOPERATION[$b]}(in progress...)</font>"
|
||||
fi
|
||||
LASTJOBNAME=$JOBNAME
|
||||
done
|
||||
[ "$LASTJOBNAME" ] && echo
|
||||
if [ "$ENDTIME" ]; then
|
||||
echo "<b>End:</b> $ENDTIME"
|
||||
elif [ "$AUTODIST_PID" ]; then
|
||||
echo "<b>End: <a target=_autodist href=\"?SHOWLOG=current.$AUTODIST_PID&NUM=$i&REP=$RNUM$HOST_ADD\">in progress</a></b>"
|
||||
fi
|
||||
echo
|
||||
# grep -v "^=" $LOGFILE | tail -n "$LINES" | sed "s|.*\r||"
|
||||
# echo
|
||||
echo "</pre></div></div>"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# only root host (0) calls other hosts
|
||||
if [ "$AS_HOST" = "0" -a ! "$SHOWLOG" ]; then
|
||||
for h in `seq 1 ${#AUTOPORT_CGI_HOST[*]}`; do
|
||||
WBHOSTURL=`echo ${AUTOPORT_CGI_HOST[$h]} | sed "s|^\(http[s]*://[^/]*\).*$|\1|"`
|
||||
if [ "$WBHOSTURL" ]; then
|
||||
curl -m1 -s -I ${WBHOSTURL} >/dev/null || continue
|
||||
if [ "$NUM" -a "$HOST" = "$h" ]; then
|
||||
curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES&NUM=$NUM&REP=$RNUM&HOST=$HOST" 2>/dev/null
|
||||
elif [ ! "$NUM" ]; then
|
||||
curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES" 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ "$AS_HOST" = "0" ]; then
|
||||
echo "<p><i>Generated by autodist CGI interface. Last update: `date`</i>"
|
||||
if [ "$FORMAT" = "xml" ]; then
|
||||
echo -n "]]></output>"
|
||||
[ "$RELOADTIME" ] && echo -n "<reloadtime>$RELOADTIME</reloadtime>"
|
||||
echo "</autodist>"
|
||||
fi
|
||||
fi
|
33
autodist-inspect
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
[ -e /etc/autodist/config ] || {
|
||||
echo "ERROR: missing configuration file /etc/autodist/config."
|
||||
exit 1
|
||||
}
|
||||
|
||||
. /etc/autodist/config
|
||||
|
||||
shopt -s nocaseglob
|
||||
checkpkg=$1
|
||||
|
||||
if [ ! "$checkpkg" ]; then
|
||||
echo "Usage:
|
||||
$0 query"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ "$LOCAL_REPS_BASE_DIR" -a -e "$LOCAL_REPS_BASE_DIR" ] || {
|
||||
echo "ERROR: LOCAL_REPS_BASE_DIR needs to be defined and local repositories to exists."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "=== distromatic sources: ==="
|
||||
head -n2 ${LOCAL_REPS_BASE_DIR}/distromatic/base/sources
|
||||
grep -i $checkpkg ${LOCAL_REPS_BASE_DIR}/distromatic/base/sources
|
||||
#tail -n+2 ${PREFIX}/distromatic/base/deps-* | grep -i $checkpkg
|
||||
echo -e "\n=== distdb: ==="
|
||||
grep -i $checkpkg ${LOCAL_REPS_BASE_DIR}/base/distdb
|
||||
for repo in base devel-makedist devel-autodist devel-misc; do
|
||||
echo -e "\n=== ${repo}: ==="
|
||||
ls ${LOCAL_REPS_BASE_DIR}/${repo}/SRPMS.base/*$checkpkg* 2>/dev/null
|
||||
ls ${LOCAL_REPS_BASE_DIR}/${repo}/RPMS.*/*$checkpkg* 2>/dev/null
|
||||
done
|
77
autodist-launcher
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist launcher
|
||||
# (c) 2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/autodist/config
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
# Disable icecc
|
||||
export PATH=/usr/bin:$PATH
|
||||
|
||||
i=$1
|
||||
|
||||
[ "$i" ] || {
|
||||
echo "Usage: autodist-launcher autodist_conf"
|
||||
exit 1
|
||||
}
|
||||
|
||||
PIDFILE=/run/autodist/autodist-launcher-${i}.pid
|
||||
[ -e $PIDFILE ] && {
|
||||
PIDCHECK=`cat $PIDFILE`
|
||||
[ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && {
|
||||
echo "autodist-launcher for configuration $i already running; exiting."
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
echo $$ > $PIDFILE
|
||||
trap "rm -f $PIDFILE; exit 1" SIGQUIT SIGINT SIGKILL SIGTERM
|
||||
|
||||
HOUR=`date +%H`
|
||||
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
|
||||
|
||||
AUTODIST_PIDFILE=/run/autodist/autodist.pid
|
||||
LOGFILE=/var/autodist/log/autodist.log
|
||||
LASTLOGFILE=/var/autodist/log/autodist-last.log
|
||||
|
||||
if [ -e $AUTODIST_PIDFILE ]; then
|
||||
PIDCHECK=`cat $AUTODIST_PIDFILE`
|
||||
if [ "$PIDCHECK" -a -e /proc/$PIDCHECK ]; then
|
||||
echo "autodist already running; exiting."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
[ "${AUTOPORT_ARCH[$i]}" ] || continue
|
||||
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
|
||||
|
||||
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then
|
||||
CMD_PREFIX=linux32
|
||||
else
|
||||
CMD_PREFIX=
|
||||
fi
|
||||
|
||||
# TODO: parametrize DISTROMATIC_REPOSITORY and following log files
|
||||
DISTROMATIC_REPOSITORY=devel-future
|
||||
|
||||
REPLOGFILE=$LOCAL_REPS_BASE_DIR/$r/autodist.log
|
||||
REPLASTLOGFILE=$LOCAL_REPS_BASE_DIR/$r/autodist-last.log
|
||||
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
|
||||
if [ ! "$AUTOPORT_UPDATE_NO_DISTROMATIC" ]; then
|
||||
distromatic -q -t $DISTROMATIC_REPOSITORY --gensrcpkglist > $LOCAL_REPS_BASE_DIR/$DISTROMATIC_REPOSITORY/srcpkglist 2>/dev/null
|
||||
fi
|
||||
|
||||
#autodist-upstream-updates -q -h -u -r $DISTROMATIC_REPOSITORY -o $r \
|
||||
# > $LOCAL_REPS_BASE_DIR/distromatic/$r/_popular.html
|
||||
autodist-upstream-updates -q -u -r $DISTROMATIC_REPOSITORY -o $r
|
||||
|
||||
[ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE
|
||||
su -l autodist -c "$CMD_PREFIX autodist -a --server $r" > $LOGFILE
|
||||
[ -e $REPLOGFILE ] && mv $REPLOGFILE $REPLASTLOGFILE
|
||||
cp $LOGFILE $REPLOGFILE
|
||||
fi
|
||||
done
|
||||
rm -f ${PIDFILE}
|
1117
autodist-repository
Executable file
1
autodist-tmpfilesd
Normal file
@ -0,0 +1 @@
|
||||
d /run/autodist 775 autodist packager
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist-tool
|
||||
# Copyright (c) 2008-2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Copyright (c) 2008-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/autodist/config
|
||||
me=(${0##*/} $VERSION "Tue Oct 28 2008")
|
||||
@ -14,7 +14,6 @@ SOURCESDIR=$AUTOUPDATEDIR/sources/
|
||||
SRCPKGLIST=/var/ftp/pub/openmamba/$AUTODIST_REPOSITORY/srcpkglist
|
||||
SUCCESSLISTDIR=$AUTOUPDATEDIR
|
||||
SKIPPEDLISTDIR=$AUTOUPDATEDIR
|
||||
DISTDBFILE=/etc/autodist/distdb
|
||||
|
||||
#eval `autospec -q --eval="srpms_dir"`
|
||||
#eval `autospec -q --eval="rpms_dir"`
|
||||
@ -30,10 +29,10 @@ ${me[0]} ${me[1]}
|
||||
echo "
|
||||
|
||||
"$"Usage"":
|
||||
$me makepatch package [build|update|remove]
|
||||
$me schedule job_regexp
|
||||
$me unschedule job_regexp
|
||||
$me skip job_regexp
|
||||
$me makepatch package [auto|build|update|remove]
|
||||
$me schedule job_regexp..
|
||||
$me unschedule job_regexp..
|
||||
$me skip job_regexp..
|
||||
"
|
||||
|
||||
}
|
||||
@ -83,10 +82,29 @@ if [ "$COMMAND" = "makepatch" ]; then
|
||||
rm -f $AUTOUPDATEDIR/spec-patches-build/$JOB.spec.patch
|
||||
echo
|
||||
exit 0
|
||||
elif [ "$OPERATION" = "auto" ]; then
|
||||
if [ -e $spec_dir/.$JOB.spec.autodist.prebuild -a ! -e $AUTOUPDATEDIR/spec-patches-update/$JOB.spec.patch ]; then
|
||||
OPERATION=build
|
||||
elif [ -e $spec_dir/.$JOB.spec.autodist.preupdate -a ! -e $AUTOUPDATEDIR/spec-patches-build/$JOB.spec.patch ]; then
|
||||
OPERATION=update
|
||||
else
|
||||
echo "Error: unable to autodetect patch type."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo diff $spec_dir/.$JOB.spec.autodist.pre$OPERATION $spec_dir/$JOB.spec > \
|
||||
$AUTOUPDATEDIR/spec-patches-$OPERATION/$JOB.spec.patch
|
||||
if [ ! -e $spec_dir/.$JOB.spec.autodist.pre$OPERATION ]; then
|
||||
echo "Error: pre$OPERATION specfile missing; make sure you prepare and update the package using autodist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OPERATION" = "build" -a -e $AUTOUPDATEDIR/spec-patches-update/$JOB.spec.patch ]; then
|
||||
echo "Error: trying to make a build patch when an update patch already exists! Remove or create a update patch instead."
|
||||
exit 1
|
||||
elif [ "$OPERATION" = "update" -a -e $AUTOUPDATEDIR/spec-patches-build/$JOB.spec.patch ]; then
|
||||
echo "Error: trying to make an update patch when a build patch already exists! Remove or create a build patch instead."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
diff $spec_dir/.$JOB.spec.autodist.pre$OPERATION $spec_dir/$JOB.spec > \
|
||||
$AUTOUPDATEDIR/spec-patches-$OPERATION/$JOB.spec.patch
|
||||
@ -114,7 +132,7 @@ elif [ "$COMMAND" = "schedule" ]; then
|
||||
# while read line; do
|
||||
# set -- $line
|
||||
# if [ "`echo \" $1 \" | grep \" $JOB \"`" ]; then
|
||||
if [ "`grep \"^$JOB \" $SRCPKGLIST`" -o "`grep \"^$JOB=(\" $DISTDBFILE`" ]; then
|
||||
if [ "`grep \"^$JOB \" $SRCPKGLIST`" -o "`autodist --list-jobs | grep ^$JOB$`" ]; then
|
||||
echo "Job $JOB scheduled for automatic update or rebuild"
|
||||
sed -i "/^$JOB .*/d" $AUTOUPDATEDIR/manual.in
|
||||
echo "$JOB $JOBVER 0" >> $AUTOUPDATEDIR/manual.in || exit 1
|
||||
@ -146,7 +164,7 @@ elif [ "$COMMAND" = "skip" ]; then
|
||||
if [ "$SKIPPEDLINE" ]; then
|
||||
sed -i "/^$PKGNAME /d" $SKIPPEDLISTDIR/*.skip
|
||||
fi
|
||||
if [ "`grep \"^$JOB \" $SRCPKGLIST`" -o "`grep \"^$JOB=(\" $DISTDBFILE`" ]; then
|
||||
if [ "`grep \"^$JOB \" $SRCPKGLIST`" -o "`autodist --list-jobs | grep ^$JOB$`" ]; then
|
||||
echo "$JOB $DATE_NOW 101" >> $SKIPPEDLISTDIR/auto.skip
|
||||
echo "Job $JOB skipped from automatic builds"
|
||||
else
|
||||
|
380
autodist-upstream-updates
Executable file
@ -0,0 +1,380 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist upstream updates - find upstream packages updates from different internet resources
|
||||
# Copyright (c) 2004-2023 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
|
||||
#[ -r /etc/sysconfig/openmamba-central ] || {
|
||||
# echo "Error: this program must be run as root; aborting." >&2
|
||||
# exit 1
|
||||
#}
|
||||
. /etc/autodist/config
|
||||
DISTROMATIC_PREFIX=/distribution/distromatic.html?
|
||||
DISTROMATIC_REPOSITORY=base
|
||||
DISTDB=/etc/autodist/distdb
|
||||
BLACKLISTDB=/etc/autodist/blacklist
|
||||
DISTDBDIR=/etc/autodist/distdb.d
|
||||
XORG_RELEASE=current
|
||||
|
||||
[ -r $DISTDB ] && {
|
||||
. $DISTDB
|
||||
[ -d $DISTDBDIR ] && \
|
||||
for f in `ls $DISTDBDIR/*.db`; do
|
||||
. $f
|
||||
done
|
||||
}
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "openmamba-upstream-updates - finds upstream packages updates from different internet resources"
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo "openmamba-upstream-updates [-h|-m][-r repository][-o output_repository]"
|
||||
echo
|
||||
echo " -h: generate distromatic HTML output"
|
||||
echo " -m: report missing packages only"
|
||||
echo " -s: skip fetching and parsing upstream updates"
|
||||
echo " -u: output not up-to-date packages only"
|
||||
echo " -q: produces quite output"
|
||||
echo " -r repository: specify the distromatic base (default: base)"
|
||||
echo " -o repository: specify the repository for output data (default: same as base repository)"
|
||||
echo
|
||||
}
|
||||
|
||||
get_job_vector() {
|
||||
local JNAME=$1
|
||||
local JNAME_ESCAPED=`echo $JNAME | tr - _ | tr . _ | tr @ _`
|
||||
|
||||
# resolve JOB_NAME from distdb
|
||||
local jobtmpfile=`mktemp`
|
||||
# hack to get an array variable named as $j assigned to the JOB array
|
||||
echo "echo \${$JNAME_ESCAPED[*]}" > $jobtmpfile
|
||||
JOB=(`. $jobtmpfile`)
|
||||
rm -f $jobtmpfile
|
||||
|
||||
if [ ${#JOB[*]} -eq 0 ]; then
|
||||
# create a default job with given JOB_NAME
|
||||
JOB=($JNAME "" "")
|
||||
elif [ ${#JOB[*]} -eq 1 ]; then
|
||||
# no variables defined, add an empty job
|
||||
JOB=(${JOB[*]} "" "")
|
||||
fi
|
||||
JOB_PKGS=(${JOB[0]//,/ })
|
||||
JOB_VARNAMES=(${JOB[1]//,/ })
|
||||
}
|
||||
|
||||
function version_compare()
|
||||
{
|
||||
local A B
|
||||
A=$1
|
||||
B=$2
|
||||
|
||||
if [[ ${1} =~ ^[0-9]+$ && ${2} =~ ^[0-9]+$ ]]; then
|
||||
if [ $((10#${A/[a-zA-Z_]*})) -gt $((10#${B/[a-zA-Z_]*})) ]; then
|
||||
return 1
|
||||
elif [ $((10#${A/[a-zA-Z_]*})) -lt $((10#${B/[a-zA-Z_]*})) ]; then
|
||||
return 2
|
||||
fi
|
||||
else
|
||||
if [[ ${1} =~ ^[0-9]+$ || "$A" > "$B" ]]; then
|
||||
return 1
|
||||
elif [[ "$A" < "$B" ]]; then
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function version_find_bigger()
|
||||
{
|
||||
local VER1 VER2 FPOS CUTVER1 CUTVER2
|
||||
|
||||
VER1=$1
|
||||
VER2=$2
|
||||
FPOS=1
|
||||
while true; do
|
||||
CUTVER1=`echo $VER1. | cut -d. -f $FPOS`
|
||||
CUTVER2=`echo $VER2. | cut -d. -f $FPOS`
|
||||
if [ "$CUTVER1" -a ! "$CUTVER2" ]; then
|
||||
return 1
|
||||
elif [ "$CUTVER2" -a ! "$CUTVER1" ]; then
|
||||
return 2
|
||||
elif [ ! "$CUTVER1" -a "$CUTVER2" ]; then
|
||||
return 0
|
||||
else
|
||||
version_compare $CUTVER1 $CUTVER2
|
||||
case $? in
|
||||
1) return 1 ;;
|
||||
2) return 2 ;;
|
||||
esac
|
||||
fi
|
||||
FPOS=`expr $FPOS + 1`
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
-h) distromatic_html=1 ;;
|
||||
-m) if [ "$distromatic_html" ]; then
|
||||
echo "Error: options -h and -m cannot be used together."
|
||||
usage
|
||||
exit 1
|
||||
else
|
||||
missing_only=1
|
||||
fi ;;
|
||||
-s) skip_parsing=1 ;;
|
||||
-u) needupdate_only=1 ;;
|
||||
-r) [ "$2" ] || {
|
||||
echo "Error: option -r requires repository name as parameter"
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
DISTROMATIC_REPOSITORY=$2
|
||||
shift
|
||||
;;
|
||||
-o) [ "$2" ] || {
|
||||
echo "Error: option -o requires repository name as parameter"
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
OUTPUT_REPOSITORY=$2
|
||||
shift
|
||||
;;
|
||||
-q) quiet=1 ;;
|
||||
*) echo "Error: invalid option $1."; usage; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$OUTPUT_REPOSITORY" ] || OUTPUT_REPOSITORY=$DISTROMATIC_REPOSITORY
|
||||
|
||||
CACHE_DIR=${LOCAL_REPS_BASE_DIR}/$OUTPUT_REPOSITORY/autoupdate/
|
||||
PKGLIST_FILE=${LOCAL_REPS_BASE_DIR}/$DISTROMATIC_REPOSITORY/srcpkglist
|
||||
BUILDS_FILE=${LOCAL_REPS_BASE_DIR}/distromatic/$DISTROMATIC_REPOSITORY/builds-i586
|
||||
BUILDLIST_FILE=$CACHE_DIR/upstream-updates.in
|
||||
CONFIG_DIR=$CACHE_DIR
|
||||
UPDATES_DB=$CACHE_DIR/upstream-updates
|
||||
ALIASES_DB=$CACHE_DIR/aliases
|
||||
MANUALVER_DB=$CACHE_DIR/manualver
|
||||
BLACKLIST_DB_PREFIX=$CACHE_DIR/blacklist.
|
||||
|
||||
[ -s $PKGLIST_FILE ] || {
|
||||
echo "Error: file $PKGLIST_FILE is missing or empty; aborting." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -r $ALIASES_DB ] || {
|
||||
echo "Error: file $ALIASES_DB cannot be read; aborting." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
parse_arch_linux() {
|
||||
# parse Arch Linux package list
|
||||
[ "$quiet" ] || echo -n "Parsing Arch Linux packages list..." >&2
|
||||
#for page in `seq 1 45`; do
|
||||
for rep in core community extra; do
|
||||
# SOURCEURL="https://www.archlinux.org/packages/?page=$page&sort=-last_update&q=&arch=i686&maintainer=&flagged="
|
||||
SOURCEURL="http://lug.mtu.edu/archlinux/$rep/os/x86_64/"
|
||||
curl -L -s "$SOURCEURL" | \
|
||||
grep ".pkg." | grep -v ".sig\"" | \
|
||||
while read line; do
|
||||
line=`echo $line | sed "s|.*href=\"\([^\"]*\)\">.*|\1|"`
|
||||
pkg=`echo $line | sed "s|\(.*\)-[^-]*-[^-]*-[^-]*|\1|"`
|
||||
ver=`echo $line | sed "s|.*-\([^-]*\)-[^-]*-[^-]*|\1|;s|.*%3a||i;s|%2b.*||i"`
|
||||
alias=`grep "^$pkg " $ALIASES_DB`
|
||||
# Skip blackisted
|
||||
if [ -e ${BLACKLIST_DB_PREFIX}arch ]; then
|
||||
grep -q "^$pkg$" ${BLACKLIST_DB_PREFIX}arch && continue
|
||||
fi
|
||||
[ "$alias" ] || alias=`grep "^lib$pkg " $ALIASES_DB`
|
||||
[ "$alias" ] && pkgalias=${alias/* /} || pkgalias=$pkg
|
||||
line=`grep -i "^$pkgalias:" $buildstmp || grep -i "^lib$pkgalias:" $buildstmp || grep -i " $pkgalias[^-_A-Za-z0-9]" $buildstmp`
|
||||
if [ "$line" ]; then
|
||||
[ "$pkg" != "$pkgalias" ] && alias=$pkgalias || alias=
|
||||
[ "$pkg" -a "$ver" ] && {
|
||||
echo "$pkg $ver $SOURCEURL ${alias}" >> $tmpfile
|
||||
}
|
||||
fi
|
||||
done
|
||||
done
|
||||
rm -f $buildstmp
|
||||
}
|
||||
|
||||
parse_xorg() {
|
||||
# parse X.org stable packages list
|
||||
[ "$quiet" ] || echo "Parsing X.org release ftp directory..." >&2
|
||||
SOURCEURL="ftp://ftp.x.org/pub/$XORG_RELEASE/src/everything/"
|
||||
curl -L -s $SOURCEURL -l | sed "s|\.tar\..*||" | sort -u |
|
||||
while read line; do
|
||||
if [ "$line" ]; then
|
||||
ver=`echo $line | sed "s|.*-||"`
|
||||
pkg="${line/-$ver}"
|
||||
if [ -e ${BLACKLIST_DB_PREFIX}xorg ]; then
|
||||
grep -q "^$pkg$" ${BLACKLIST_DB_PREFIX}xorg && continue
|
||||
fi
|
||||
alias=`grep "^$pkg " $ALIASES_DB`
|
||||
if [ ! "$alias" -a "${pkg:0:5}" == "xf86-" ]; then
|
||||
alias="$pkg xorg-drv-${pkg/xf86-}"
|
||||
else
|
||||
[ "$alias" ] || alias=`grep "^lib$pkg " $ALIASES_DB`
|
||||
fi
|
||||
[ "$pkg" -a "$ver" ] && echo "$pkg $ver $SOURCEURL ${alias/* /}" >> $tmpfile
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
parse_gnome() {
|
||||
# parse Gnome stable packages list
|
||||
[ "$quiet" ] || echo "Parsing GNOME stable versions file..." >&2
|
||||
for f in versions-stable versions-stable-extras; do
|
||||
SOURCEURL="https://people.gnome.org/~vuntz/tmp/versions/$f"
|
||||
curl -s -L $SOURCEURL | grep -v "^#" |
|
||||
while read line; do
|
||||
if [ "$line" ]; then
|
||||
IFS=":"
|
||||
set -- $line
|
||||
pkg="$2"
|
||||
if [ -e ${BLACKLIST_DB_PREFIX}gnome ]; then
|
||||
grep -q "^$pkg$" ${BLACKLIST_DB_PREFIX}gnome && continue
|
||||
fi
|
||||
ver="$3"
|
||||
alias=`grep "^$pkg " $ALIASES_DB`
|
||||
[ "$alias" ] || alias=`grep "^lib$pkg " $ALIASES_DB`
|
||||
if [ "$pkg" -a "$ver" ]; then
|
||||
ver1=$(echo $ver | cut -d. -f1)
|
||||
ver2=$(echo $ver | cut -d. -f2)
|
||||
if [ "$ver2" -a $(($ver2 % 2)) -ne 0 ]; then
|
||||
# skip unstable versions with odd numbers
|
||||
continue
|
||||
else
|
||||
echo "$pkg $ver $SOURCEURL ${alias/* /}" >> $tmpfile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
parse_distromatic() {
|
||||
# parse distrowatch.com packages list
|
||||
[ "$quiet" ] || echo "Parsing Distrowatch packages list..." >&2
|
||||
SOURCEURL="https://distrowatch.com/packages.php"
|
||||
lynx -width 300 -dump $SOURCEURL |
|
||||
while read line; do
|
||||
[ "`echo $line | grep "Package Version Note"`" ] && start_print=1
|
||||
[ "`echo $line | grep "____________________"`" ] && unset start_print
|
||||
[ "$start_print" ] && {
|
||||
set -- $line
|
||||
pkg="${1/\[*\]/}"
|
||||
ver="${2/\[*\]/}"
|
||||
alias=`grep "^$pkg " $ALIASES_DB`
|
||||
[ "$pkg" != "chromium" ] && \
|
||||
echo "$pkg $ver $SOURCEURL ${alias/* /}" >> $tmpfile
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
if [ ! "$skip_parsing" ]; then
|
||||
#tmpfile=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
|
||||
buildstmp=`mktemp -q -t autodist-upstream-updates.XXXXXXXX`
|
||||
tail -n+2 $BUILDS_FILE > $buildstmp
|
||||
|
||||
#parse_arch_linux
|
||||
#parse_xorg
|
||||
#parse_gnome
|
||||
#parse_distromatic
|
||||
/usr/share/autodist/repology-openmamba.py > $UPDATES_DB.tmp
|
||||
if [ $? -eq 0 ]; then
|
||||
#cat $tmpfile | sort -uf > $UPDATES_DB.tmp
|
||||
#rm -f $tmpfile
|
||||
|
||||
> $UPDATES_DB
|
||||
unset lastpkg
|
||||
while read pkg ver upsource alias; do
|
||||
# skip updates to unstable versions
|
||||
unset found_beta
|
||||
for b in alpha beta rc "~"; do
|
||||
[ "${ver/$b}" != "${ver}" ] && found_beta=1
|
||||
done
|
||||
[ "$found_beta" ] && continue
|
||||
if [ "$pkg" = "$lastpkg" ]; then
|
||||
# echo "Warning: duplicate found: $pkg lastver: $lastver ver: $ver" >&2
|
||||
version_find_bigger $lastver $ver
|
||||
vercmp=$?
|
||||
if [ $vercmp -eq 2 ]; then
|
||||
sed -i "/^$lastpkg $lastver /d" $UPDATES_DB
|
||||
echo "$pkg $ver $upsource $alias" >> $UPDATES_DB
|
||||
fi
|
||||
else
|
||||
echo "$pkg $ver $upsource $alias" >> $UPDATES_DB
|
||||
fi
|
||||
lastpkg=$pkg
|
||||
lastver=$ver
|
||||
done < $UPDATES_DB.tmp
|
||||
fi
|
||||
rm -f $UPDATES_DB.tmp
|
||||
fi
|
||||
|
||||
> $UPDATES_DB.missing
|
||||
> $BUILDLIST_FILE
|
||||
while read pkg ver upsource alias; do
|
||||
grep "^$pkg$" $BLACKLISTDB >/dev/null && continue
|
||||
unset pkgline
|
||||
unset found_manual
|
||||
unset found_alias
|
||||
pkgline=`grep -i "^$pkg " $MANUALVER_DB` && found_manual=1
|
||||
if [ ! "$found_manual" ]; then
|
||||
if [ "$alias" ]; then
|
||||
get_job_vector $alias
|
||||
lastjob=${#JOB_PKGS[*]}
|
||||
pkgline=`grep "^${JOB_PKGS[$lastjob-1]} " $PKGLIST_FILE` && found_alias=1
|
||||
else
|
||||
get_job_vector $pkg
|
||||
lastjob=${#JOB_PKGS[*]}
|
||||
pkgline=`grep "^${JOB_PKGS[$lastjob-1]} " $PKGLIST_FILE`
|
||||
[ "$pkgline" ] || {
|
||||
get_job_vector lib${pkg}
|
||||
lastjob=${#JOB_PKGS[*]}
|
||||
pkgline=`grep "^${JOB_PKGS[$lastjob-1]} " $PKGLIST_FILE` && {
|
||||
found_alias=1
|
||||
alias=lib${pkg}
|
||||
}
|
||||
}
|
||||
fi
|
||||
fi
|
||||
if [ "$pkgline" -a ! "$missing_only" ]; then
|
||||
set -- $pkgline
|
||||
pkgname=$1
|
||||
pkgver=$2
|
||||
pkgrep=$4
|
||||
version_find_bigger $pkgver ${ver/-/.}
|
||||
vercmp=$?
|
||||
#echo "$pkgname - version_find_bigger $pkgver ${ver/-/.} result=$vercmp"
|
||||
[ "${vercmp}" != "2" -a "$needupdate_only" ] && continue
|
||||
[ "$found_manual" ] && pkgname=$3
|
||||
[ "$found_alias" -o "$found_manual" ] && nameadd="$pkg" || unset nameadd
|
||||
unset veradd
|
||||
[ ${vercmp} = 2 ] && veradd="<a href=\"$upsource\"><font color=red>$ver</font></a>"
|
||||
[ ${vercmp} = 1 ] && veradd="$ver"
|
||||
[ "$veradd" -o "$nameadd" ] && {
|
||||
[ "$veradd" -a "$nameadd" ] && \
|
||||
verappend="($nameadd;$veradd)" ||
|
||||
verappend="(${nameadd}${veradd})"
|
||||
} || unset verappend
|
||||
if [ "$distromatic_html" = "1" ]; then
|
||||
echo "<a href=\"${DISTROMATIC_PREFIX}tag=${pkgrep}&pkg=${JOB_PKGS[0]}.source\">${JOB_PKGS[0]} $pkgver</a> $verappend<br>"
|
||||
else
|
||||
echo "$pkg $pkgver ($ver)"
|
||||
fi
|
||||
[ $vercmp = 2 ] && {
|
||||
if [ "$found_alias" ]; then
|
||||
echo "$alias +$ver 0 $upsource" >> $BUILDLIST_FILE
|
||||
else
|
||||
echo "$pkg +$ver 0 $upsource" >> $BUILDLIST_FILE
|
||||
fi
|
||||
}
|
||||
elif [ ! "$pkgline" ]; then
|
||||
echo "$pkg ($ver) $upsource" >> $UPDATES_DB.missing
|
||||
fi
|
||||
done < $UPDATES_DB
|
291
automaint
Executable file
@ -0,0 +1,291 @@
|
||||
#!/bin/bash
|
||||
# automaint -- batch automatic maintainance tool of the autodist suite
|
||||
# Copyright (C) 2013-2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
# Released under the terms of the GNU GPL release 3 license
|
||||
#
|
||||
VERSION=0.9.7
|
||||
# First in vector is base arch
|
||||
. /etc/autodist/config
|
||||
|
||||
me=(${0##*/} $VERSION "Sat Mar 20 2011")
|
||||
|
||||
function usage() {
|
||||
echo "\
|
||||
${me[0]} ${me[1]}
|
||||
"$"Copyright (C) 2013-2021 Silvan Calarco <silvan.calarco@mambasoft.it>""
|
||||
"$"Released under the terms of the GNU GPL v3 license"
|
||||
echo "
|
||||
"$"Batch automatic maintainance tool of the autodist suite.""
|
||||
|
||||
"$"Usage"":
|
||||
$me [-s repository -d repository ] [-p repository] [-h] [-v]
|
||||
|
||||
-d repository "$"Main destination repository
|
||||
-p repository "$"Port repository
|
||||
-s repository "$"Automatic/Staging builds source repository
|
||||
|
||||
-h "$"Show this help and exit
|
||||
-t "$"Test mode (no change will be made)
|
||||
-v "$"Verbose output
|
||||
"
|
||||
|
||||
}
|
||||
|
||||
# for webbuild message
|
||||
function cgi_encodevar() {
|
||||
local string="${1}"
|
||||
local strlen=${#string}
|
||||
local encoded=""
|
||||
|
||||
for (( pos=0 ; pos<strlen ; pos++ )); do
|
||||
c=${string:$pos:1}
|
||||
case "$c" in
|
||||
[-_.~a-zA-Z0-9] ) o="${c}" ;;
|
||||
* ) printf -v o '%%%02x' "'$c"
|
||||
esac
|
||||
encoded+="${o}"
|
||||
done
|
||||
echo "${encoded}" # You can either set a return variable (FASTER)
|
||||
# REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
|
||||
}
|
||||
|
||||
# get_pkg_buildinfo - uses distromatic generated build file for
|
||||
# getting information on the repository
|
||||
#
|
||||
# $1: distromatic files base url for repository
|
||||
# $2: architecture
|
||||
# $3: pkg name
|
||||
function get_pkg_buildinfo() {
|
||||
|
||||
local pkg i a local_arch local_distromatic
|
||||
|
||||
[ $1 ] && local_distromatic=$1 || exit 1
|
||||
[ $2 ] && local_arch=$2 || exit 1
|
||||
[ $3 ] && pkg=$3
|
||||
|
||||
if [ ! "$pkg" ]; then
|
||||
[ -e $local_distromatic/builds-${local_arch}.sh ] && . $local_distromatic/builds-${local_arch}.sh
|
||||
return 0
|
||||
fi
|
||||
|
||||
pkg_archs=();
|
||||
for a in ${archs[*]}; do
|
||||
[ "$a" = "${local_arch}" ] && continue
|
||||
pkg_header=();
|
||||
DISTROMATIC_BUILD_FILE=$local_distromatic/builds-$a.sh
|
||||
[ -e $DISTROMATIC_BUILD_FILE ] && . $DISTROMATIC_BUILD_FILE
|
||||
[ ${pkg_header[0]} ] && pkg_archs=(${pkg_archs[*]} $a)
|
||||
done
|
||||
|
||||
pkg_header=();
|
||||
pkg_builds=();
|
||||
pkg_obsoletes=();
|
||||
pkg_list=();
|
||||
|
||||
DISTROMATIC_BUILD_FILE=$local_distromatic/builds-${local_arch}.sh
|
||||
[ -e $DISTROMATIC_BUILD_FILE ] && . $DISTROMATIC_BUILD_FILE
|
||||
[ ${pkg_header[0]} ] && pkg_archs=(${pkg_archs[*]} ${local_arch})
|
||||
|
||||
# {
|
||||
# echo "Error: missing distromatic generated file $DISTROMATIC_BUILD_FILE; aborting."
|
||||
# return;
|
||||
# }
|
||||
# . $DISTROMATIC_BUILD_FILE
|
||||
|
||||
for i in ${pkg_list[*]}; do
|
||||
if [ "$i" == "${pkg_header[0]}" ]; then
|
||||
pkg_name=${pkg_header[0]};
|
||||
# Note: pkg_arch reported in builds file is just last arch source was
|
||||
# built for, so we use repository arch instead
|
||||
pkg_arch=${pkg_header[1]};
|
||||
[ "$pkg_arch" = "noarch" ] || pkg_arch=${local_arch}
|
||||
pkg_version=${pkg_header[2]};
|
||||
pkg_release=${pkg_header[3]};
|
||||
pkg_group=${pkg_header[4]};
|
||||
pkg_license=${pkg_header[5]};
|
||||
pkg_size=${pkg_header[6]};
|
||||
pkg_buildtime=${pkg_header[7]};
|
||||
pkg_altrep=${pkg_header[8]};
|
||||
pkg_repository=${pkg_header[9]};
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
unset pkg_name pkg_arch pkg_version pkg_release \
|
||||
pkg_group pkg_license pkg_size pkg_buildtime pkg_altrep pkg_repository
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
[ $# -gt 0 ] || { usage ; exit 1; }
|
||||
|
||||
for ((i=1; i<=$#; i++)); do
|
||||
case ${!i} in
|
||||
-s) shift
|
||||
SOURCE_REPOSITORY="${!i}"
|
||||
;;
|
||||
-d) shift
|
||||
DEST_REPOSITORY="${!i}"
|
||||
;;
|
||||
-p) shift
|
||||
PORT_REPOSITORY="${!i}"
|
||||
;;
|
||||
-t) TESTMODE=1
|
||||
;;
|
||||
-v) VERBOSE=1
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$SOURCE_REPOSITORY" -a "$DEST_REPOSITORY" ] || { usage; exit 1; }
|
||||
|
||||
[ "$SOURCE_REPOSITORY" = "$DEST_REPOSITORY" ] && {
|
||||
echo "ERROR: source and destination repository cannot be the same; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "$TESTMODE" ] && echo "** TEST MODE enabled: no changes will be made **"
|
||||
|
||||
for a in `seq 1 ${#AUTODIST_ARCHS[*]}`; do
|
||||
. $LOCAL_REPS_BASE_DIR/distromatic/$SOURCE_REPOSITORY/builds-${AUTODIST_ARCHS[$a-1]}.sh
|
||||
pkglist[$a-1]="${pkg_list[*]}"
|
||||
warningslist[$a-1]="${warnings_list[*]}"
|
||||
needportlist[$a-1]="${needport_list[*]}"
|
||||
done
|
||||
|
||||
tmpfile=`mktemp -q -t $me.XXXXXXXX` || {
|
||||
echo "ERROR: cannot create temporary files." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
for a in `seq 1 ${#AUTODIST_ARCHS[*]}`; do
|
||||
echo -n "${pkglist[$a-1]} " >> $tmpfile
|
||||
done
|
||||
allpkgs="`cat $tmpfile | xargs -n 1 | sort -u | xargs`"
|
||||
rm -f $tmpfile
|
||||
|
||||
for p in ${allpkgs}; do
|
||||
pkgcontinue=
|
||||
needsport=
|
||||
|
||||
for w in ${warningslist[*]}; do
|
||||
[ "$p" = "$w" ] && { pkgcontinue=1; break; }
|
||||
done
|
||||
[ "$pkgcontinue" ] && continue
|
||||
|
||||
for a in `seq 1 ${#AUTODIST_ARCHS[*]}`; do
|
||||
# Get pkg info from port repository
|
||||
get_pkg_buildinfo $LOCAL_REPS_BASE_DIR/distromatic/$PORT_REPOSITORY ${AUTODIST_ARCHS[$a-1]} $p
|
||||
# If not found get info from main repository
|
||||
if [ ! "$pkg_name" ]; then
|
||||
get_pkg_buildinfo $LOCAL_REPS_BASE_DIR/distromatic/$DEST_REPOSITORY ${AUTODIST_ARCHS[$a-1]} $p
|
||||
fi
|
||||
|
||||
if [ "$pkg_name" ]; then
|
||||
old_pkg_version=$pkg_version
|
||||
old_pkg_release=$pkg_release
|
||||
old_pkg_repository=$pkg_repository
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$pkg_name" ] || {
|
||||
[ "$VERBOSE" ] && echo "$p: not present in $DEST_REPOSITORY; skipping."
|
||||
continue
|
||||
}
|
||||
|
||||
[ "$VERBOSE" ] && echo "$p: old release in $DEST_REPOSITORY is $old_pkg_version-$old_pkg_release"
|
||||
|
||||
for o in ${needportlist[*]}; do
|
||||
[ "$p" = "$o" ] && { needsport=1; break; }
|
||||
done
|
||||
#[ "$needsport" ] && continue
|
||||
[ "$needsport" -a ! "$PORT_REPOSITORY" ] && continue
|
||||
|
||||
for a in `seq 1 ${#AUTODIST_ARCHS[*]}`; do
|
||||
get_pkg_buildinfo $LOCAL_REPS_BASE_DIR/distromatic/$SOURCE_REPOSITORY ${AUTODIST_ARCHS[$a-1]} $p
|
||||
[ "$pkg_name" ] && break
|
||||
done
|
||||
|
||||
[ "$pkg_name" ] || {
|
||||
[ "$VERBOSE" ] && echo "$p: not present in $SOURCE_REPOSITORY; skipping."
|
||||
continue
|
||||
}
|
||||
|
||||
[ "$VERBOSE" ] && echo "$p: new release in $SOURCE_REPOSITORY is $pkg_version-$pkg_release"
|
||||
|
||||
if [ "$pkg_version" = "$old_pkg_version" ]; then
|
||||
if [ "$pkg_release" = "$old_pkg_release" ]; then
|
||||
echo "$p: same release as upstream; skipping."
|
||||
continue
|
||||
fi
|
||||
update_type="release"
|
||||
else
|
||||
OIFS=$IFS
|
||||
IFS='.'
|
||||
read -ra SVER <<< "$old_pkg_version"
|
||||
read -ra VER <<< "$pkg_version"
|
||||
IFS=$OIFS
|
||||
dotdiff=`expr ${#VER[*]} - ${#SVER[*]}`
|
||||
for i in `seq 1 ${#SVER[*]}`; do
|
||||
[ "${SVER[i-1]}" != "${VER[i-1]}" ] && break
|
||||
done
|
||||
if [ "$i" = "${#SVER[*]}" -a $dotdiff -eq 0 ]; then
|
||||
# e.g. SVER=0.11.3 -> VER=0.11.4
|
||||
if [[ 64#${VER[i-1]} -gt 64#89 && 64#${SVER[i-1]} -lt 64#80 ]]; then
|
||||
[ "$VERBOSE" ] && echo "$p: dubious beta upgrade from ${SVER[i-1]} to ${VER[i-1]}; skipping."
|
||||
continue
|
||||
fi
|
||||
update_type="minor"
|
||||
#elif [ $dotdiff -lt 0 ]; then
|
||||
# [ "$VERBOSE" ] && echo "$p: newer version has less dots than older ${#VER[*]} < ${#SVER[*]}; skipping."
|
||||
# continue
|
||||
#elif [ "$i" != "${#SVER[*]}" ]; then
|
||||
# # e.g. SVER=0.11 -> VER=1.0
|
||||
# [ "$VERBOSE" ] && echo "$p: not a minor version update at position $i/${#SVER[*]}: ${SVER[i-1]} != ${VER[i-1]}; skipping."
|
||||
# continue
|
||||
elif [ "${SVER[i-1]}" = "${VER[i-1]}" -a $dotdiff -ge 1 ]; then
|
||||
# e.g. SVER=0.11.2 -> VER=0.11.2.3
|
||||
update_type="minor"
|
||||
elif [[ 64#${VER[i-1]} -gt 64#89 && 64#${SVER[i-1]} -lt 64#80 ]]; then
|
||||
[ "$VERBOSE" ] && echo "$p: dubious beta upgrade from ${SVER[i-1]} to ${VER[i-1]}; skipping."
|
||||
continue
|
||||
elif [[ 64#${VER[i-1]} -gt 64#${SVER[i-1]} && $i -gt 1 ]]; then
|
||||
# e.g. SVER=1.0.2 -> VER=1.0.3.dev1234
|
||||
update_type="minor"
|
||||
#else
|
||||
# [ "$VERBOSE" ] && echo "$p: major version update ${SVER[i-1]} vs ${VER[i-1]}; skipping"
|
||||
# continue
|
||||
fi
|
||||
fi
|
||||
#if [ ! "${needsport}" ]; then
|
||||
if [ "$old_pkg_repository" == "$PORT_REPOSITORY" -o "$old_pkg_repository" == "$DEST_REPOSITORY" ]; then
|
||||
echo "$p: importing from $SOURCE_REPOSITORY to $PORT_REPOSITORY ($pkg_version-$pkg_release -> $old_pkg_version-$old_pkg_release)"
|
||||
if [ ! "$TESTMODE" ]; then
|
||||
autodist-repository import $SOURCE_REPOSITORY $p -d $PORT_REPOSITORY -y >/dev/null
|
||||
if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then
|
||||
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\
|
||||
MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b>$PORT_REPOSITORY</b> for porting\"`" >/dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#fi
|
||||
#elif [ "$old_pkg_repository" == "$DEST_REPOSITORY" ]; then
|
||||
# echo "$p: importing from $SOURCE_REPOSITORY to $DEST_REPOSITORY ($pkg_version-$pkg_release -> $old_pkg_version-$old_pkg_release; update type: $update_type)"
|
||||
# if [ ! "$TESTMODE" ]; then
|
||||
# autodist-repository import $SOURCE_REPOSITORY $p -d $DEST_REPOSITORY -y >/dev/null
|
||||
# if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then
|
||||
# curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\
|
||||
#MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b>$DEST_REPOSITORY</b>\"`" >/dev/null
|
||||
# fi
|
||||
# fi
|
||||
# else
|
||||
# echo "$p: upstream package repository $pkg_repository does not match with $DEST_REPOSITORY; skipping."
|
||||
# fi
|
||||
done
|
||||
|
||||
exit 0
|
546
autoport
@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
# autoport -- batch cross-build tool based on autodist
|
||||
# Copyright (C) 2011-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Copyright (C) 2011-2023 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
# Released under the terms of the GNU GPL release 3 license
|
||||
#
|
||||
VERSION=0.9.1
|
||||
BASE_ARCH=i586
|
||||
BASE_REPOSITORY=devel
|
||||
PORT_REPOSITORY=devel
|
||||
VERSION=1.3.3
|
||||
|
||||
BASE_REPOSITORY=base
|
||||
PORT_REPOSITORY=base
|
||||
|
||||
. /etc/autodist/config
|
||||
|
||||
@ -16,13 +16,13 @@ me=(${0##*/} $VERSION "Sat Mar 20 2011")
|
||||
function usage() {
|
||||
echo "\
|
||||
${me[0]} ${me[1]}
|
||||
"$"Copyright (C) 2011-2012 Silvan Calarco <silvan.calarco@mambasoft.it>""
|
||||
"$"Copyright (C) 2011-2023 Silvan Calarco <silvan.calarco@mambasoft.it>""
|
||||
"$"Released under the terms of the GNU GPL v3 license"
|
||||
echo "
|
||||
"$"Batch port and cross-build tool based on autodist.""
|
||||
|
||||
"$"Usage"":
|
||||
$me [-a][-f][-x arch1[,arch2],..][-r repository][-d release_repository]{--fix|job ...}
|
||||
$me [-a][-f][-x arch1[,arch2],..][-r repository][-d release_repository][-s \"script_args\"]{--fix|job ...}
|
||||
|
||||
-a "$"Automatic mode (use cache)
|
||||
-b "$"Batch port all packages in port repository to sync with base repository
|
||||
@ -32,10 +32,14 @@ ${me[0]} ${me[1]}
|
||||
-nr "$"Don't recurse build
|
||||
--fix "$"Fix .la files for cross linking and exit
|
||||
-r "$"Work on given repository (default: $PORT_REPOSITORY)
|
||||
-d "$"Release packages to given repository (default: $PORT_REPOSITORY)
|
||||
-x "$"Operate in cross build mode
|
||||
-d "$"Release packages to given repository (default: work repository)
|
||||
-h "$"Show this help and exit
|
||||
-s \"script_args\" "$"Send script_args as arguments for autodist update-specfile script
|
||||
-u changelog "$"Rebuild packages with given changelog
|
||||
-ud "$"Rebuild dependent packages that need rebuild
|
||||
-v "$"More verbose output
|
||||
-x "$"Operate in cross build mode
|
||||
--user user "$"Pass calling user name for Webbuild social messages
|
||||
|
||||
arch "$"Target architecture
|
||||
job "$"Job specification for autodist""
|
||||
@ -43,6 +47,63 @@ ${me[0]} ${me[1]}
|
||||
|
||||
}
|
||||
|
||||
function autoport_log() {
|
||||
local pkg=$1
|
||||
local operation=$2
|
||||
local result=$3
|
||||
local loggrep=`grep "?= See" $4 | sed "s|?= See ||"`
|
||||
local logfiles=""
|
||||
|
||||
for f in $loggrep; do
|
||||
logfiles="$logfiles $f"
|
||||
done
|
||||
[ "$pkg" -a "$operation" -a "$result" -a "$BATCH_MODE" ] || return
|
||||
echo "$pkg $operation $result $logfiles" >> $DATADIR/autoport-$PORT_REPOSITORY-current
|
||||
}
|
||||
|
||||
# for webbuild message
|
||||
function cgi_encodevar() {
|
||||
local string="${1}"
|
||||
local strlen=${#string}
|
||||
local encoded=""
|
||||
|
||||
for (( pos=0 ; pos<strlen ; pos++ )); do
|
||||
c=${string:$pos:1}
|
||||
case "$c" in
|
||||
[-_.~a-zA-Z0-9] ) o="${c}" ;;
|
||||
* ) printf -v o '%%%02x' "'$c"
|
||||
esac
|
||||
encoded+="${o}"
|
||||
done
|
||||
echo "${encoded}" # You can either set a return variable (FASTER)
|
||||
# REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
|
||||
}
|
||||
|
||||
function get_pkg_srcinfo() {
|
||||
|
||||
local pkg local_distromatic pkg_line
|
||||
|
||||
unset src_name src_version src_buildtime src_repository src_epoch src_release
|
||||
|
||||
[ $1 ] && local_distromatic=$1 || exit 1
|
||||
[ $2 ] && pkg=$2 || return 1
|
||||
|
||||
[ -e $local_distromatic/srcpkglist ] || return 2
|
||||
|
||||
pkg_line=`grep "^$pkg " $local_distromatic/srcpkglist`
|
||||
[ "$pkg_line" ] || return 3
|
||||
|
||||
set -- $pkg_line
|
||||
|
||||
src_name=$1
|
||||
src_version=$2
|
||||
src_buildtime=$3
|
||||
src_repository=$4
|
||||
src_epoch=$5
|
||||
src_release=$6
|
||||
src_milestone=`echo $src_release | sed "s|[0-9.]*\(.*\)|\1|"`
|
||||
}
|
||||
|
||||
# get_pkg_buildinfo - uses distromatic generated build file for
|
||||
# getting information on the repository
|
||||
#
|
||||
@ -63,7 +124,7 @@ function get_pkg_buildinfo() {
|
||||
fi
|
||||
|
||||
pkg_archs=();
|
||||
for a in ${archs[*]}; do
|
||||
for a in ${AUTODIST_ARCHS[*]}; do
|
||||
[ "$a" = "${local_arch}" ] && continue
|
||||
pkg_header=();
|
||||
DISTROMATIC_BUILD_FILE=$local_distromatic/builds-$a.sh
|
||||
@ -86,24 +147,23 @@ function get_pkg_buildinfo() {
|
||||
# }
|
||||
# . $DISTROMATIC_BUILD_FILE
|
||||
|
||||
for i in ${pkg_list[*]}; do
|
||||
if [ "$i" == "${pkg_header[0]}" ]; then
|
||||
pkg_name=${pkg_header[0]};
|
||||
# Note: pkg_arch reported in builds file is just last arch source was
|
||||
# built for, so we use repository arch instead
|
||||
pkg_arch=${pkg_header[1]};
|
||||
[ "$pkg_arch" = "noarch" ] || pkg_arch=${local_arch}
|
||||
pkg_version=${pkg_header[2]};
|
||||
pkg_release=${pkg_header[3]};
|
||||
pkg_group=${pkg_header[4]};
|
||||
pkg_license=${pkg_header[5]};
|
||||
pkg_size=${pkg_header[6]};
|
||||
pkg_buildtime=${pkg_header[7]};
|
||||
pkg_altrep=${pkg_header[8]};
|
||||
pkg_repository=${pkg_header[9]};
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
if [ "${pkg_header[0]}" ]; then
|
||||
pkg_name=${pkg_header[0]};
|
||||
# Note: pkg_arch reported in builds file is just last arch source was
|
||||
# built for, so we use repository arch instead
|
||||
pkg_arch=${pkg_header[1]};
|
||||
[ "$pkg_arch" = "noarch" ] || pkg_arch=${local_arch}
|
||||
pkg_version=${pkg_header[2]};
|
||||
pkg_release=${pkg_header[3]};
|
||||
pkg_group=${pkg_header[4]};
|
||||
pkg_license=${pkg_header[5]};
|
||||
pkg_size=${pkg_header[6]};
|
||||
pkg_buildtime=${pkg_header[7]};
|
||||
pkg_altrep=${pkg_header[8]};
|
||||
pkg_repository=${pkg_header[9]};
|
||||
pkg_epoch=${pkg_header[10]};
|
||||
return 0
|
||||
fi
|
||||
unset pkg_name pkg_arch pkg_version pkg_release \
|
||||
pkg_group pkg_license pkg_size pkg_buildtime pkg_altrep pkg_repository
|
||||
|
||||
@ -124,7 +184,7 @@ _EOF
|
||||
|
||||
function find_source_by_provide() {
|
||||
local pkg=`echo $2 | sed "s|(|\\\\\[|g;s|)|\\\\\]|g;s|:|_|g"`
|
||||
grep "^$pkg:" $DATADIR/$1/sources-$BASE_ARCH | \
|
||||
grep "^$pkg:" $DATADIR/$1/sources-* | \
|
||||
awk '{ $1=""; print $0 }' | \
|
||||
sed "s|[[:space:]]_| |g"
|
||||
}
|
||||
@ -139,21 +199,28 @@ function find_requirements() {
|
||||
local OUTFILE=$1
|
||||
|
||||
if [ "`grep " is needed by " $OUTFILE`" ]; then
|
||||
grep " is needed by " $OUTFILE | awk '{ print $1 }' | sort -u > $tf1
|
||||
grep " is needed by " $OUTFILE | awk '{ print $1 }' | tr -d \' > $tf1
|
||||
elif [ "`grep " matches no packages" $OUTFILE`" ]; then
|
||||
grep " matches no packages" $OUTFILE | awk '{ print $2 }' | tr -d \' | sort -u > $tf1
|
||||
grep " matches no packages" $OUTFILE | awk '{ print $2 }' | tr -d \' | sed "s|@.*||" > $tf1
|
||||
elif [ "`grep " no package provides " $OUTFILE`" ]; then
|
||||
grep " no package provides " $OUTFILE | sed "s|.* no package provides ||" | sort -u > $tf1
|
||||
grep " no package provides " $OUTFILE | sed "s|.* no package provides ||" > $tf1
|
||||
fi
|
||||
|
||||
[ `stat -c %s $tf1` -gt 0 ] && {
|
||||
echo -n " | missing requirements: "
|
||||
> $tf
|
||||
cat $tf1 | while read line; do
|
||||
REQ=`find_source_by_provide $PORT_REPOSITORY $line`
|
||||
[ "$REQ" ] && \
|
||||
echo "${REQ}" >> $tf || \
|
||||
sort -u $tf1 | while read line; do
|
||||
REQ=`find_source_by_provide $PORT_REPOSITORY ${line}`
|
||||
if [ "$REQ" ]; then
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $REQ
|
||||
if [ "$pkg_name" ]; then
|
||||
echo -n "$line(notrebuilding) "
|
||||
else
|
||||
echo "${REQ}" >> $tf
|
||||
fi
|
||||
else
|
||||
echo -n "$line(unresolved) "
|
||||
fi
|
||||
done
|
||||
> $tf1
|
||||
cat $tf | sort -u 2>/dev/null | while read line; do
|
||||
@ -171,9 +238,43 @@ function find_requirements() {
|
||||
return 0
|
||||
}
|
||||
|
||||
fetch_repfiles() {
|
||||
local u
|
||||
|
||||
f=${DATADIR}/${PORT_REPOSITORY}/srcpkglist
|
||||
if [ ! -e ${f} -o "`find ${f} -mmin +60 2>/dev/null`" ]; then
|
||||
[ "$VERBOSE_MODE" = "1" ] && echo "Fetching ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist"
|
||||
curl -f -L -s ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist -o ${f} ||
|
||||
echo "Warning: unable to fetch ${REPS_BASE_URL}/$PORT_REPOSITORY/srcpkglist"
|
||||
fi
|
||||
for a in ${AUTODIST_ARCHS[*]}; do
|
||||
f=${DATADIR}/${PORT_REPOSITORY}/sources-${a}
|
||||
if [ ! -e ${f} -o "`find ${f} -mmin +60 2>/dev/null`" ]; then
|
||||
[ "$VERBOSE_MODE" = "1" ] && echo "Fetching $PORT_REPOSITORY_DISTROMATIC_URL/sources-${a}"
|
||||
curl -f -L -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-${a} -o ${f} ||
|
||||
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-${a}"
|
||||
fi
|
||||
f=${DATADIR}/${PORT_REPOSITORY}/builds-${a}.sh
|
||||
if [ ! -e ${f} -o "`find ${f} -mmin +60 2>/dev/null`" ]; then
|
||||
[ "$VERBOSE_MODE" = "1" ] && echo "Fetching $PORT_REPOSITORY_DISTROMATIC_URL/builds-${a}.sh"
|
||||
curl -f -L -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-${a}.sh -o ${f} ||
|
||||
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-${a}.sh"
|
||||
fi
|
||||
done
|
||||
for u in ${AUTOPORT_UNSTAGE_ARCHS}; do
|
||||
[ "$u" = "$TARGET_ARCH" ] && {
|
||||
rm -f $DATADIR/$PORT_REPOSITORY/unstage.$TARGET_ARCH
|
||||
return
|
||||
}
|
||||
done
|
||||
[ "$VERBOSE_MODE" = "1" ] && echo "Fetching ${REPS_BASE_URL}/${PORT_REPOSITORY/-*}/unstage.$TARGET_ARCH"
|
||||
curl -f -L -s ${REPS_BASE_URL}/${PORT_REPOSITORY/-*}/unstage.$TARGET_ARCH -o $DATADIR/$PORT_REPOSITORY/unstage.$TARGET_ARCH ||
|
||||
echo "Warning: unable to fetch ${REPS_BASE_URL}/${PORT_REPOSITORY/-*}/unstage.$TARGET_ARCH"
|
||||
}
|
||||
|
||||
[ $# -gt 0 ] || { usage ; exit 1; }
|
||||
|
||||
BUILD_ARCH=`uname -i`
|
||||
[ "$BUILD_ARCH" ] || BUILD_ARCH=`uname -m`
|
||||
|
||||
case $BUILD_ARCH in
|
||||
i386|i486|i686) BUILD_ARCH=i586 ;;
|
||||
@ -190,6 +291,17 @@ for ((i=1; i<=$#; i++)); do
|
||||
-b) BATCH_MODE=1 ;;
|
||||
-f) FORCE_MODE=1 ;;
|
||||
-v) VERBOSE_MODE=1 ;;
|
||||
-u) REBUILD_MODE=1
|
||||
shift
|
||||
REBUILD_CHANGELOG="${!i}"
|
||||
[ "$REBUILD_CHANGELOG" ] || {
|
||||
echo "ERROR: changelog not given as -u option parameter; aborting."
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
-ud) REBUILD_DEPENDANT_MODE=1
|
||||
DONT_RECURSE=1
|
||||
;;
|
||||
-npa) DONT_PREPARE_ANY=1
|
||||
DONT_PREPARE=1 ;;
|
||||
-np) DONT_PREPARE=1 ;;
|
||||
@ -198,6 +310,9 @@ for ((i=1; i<=$#; i++)); do
|
||||
-r) shift
|
||||
PORT_REPOSITORY="${!i}"
|
||||
;;
|
||||
-s) shift
|
||||
SCRIPT_ARGS="${!i}"
|
||||
;;
|
||||
-d) shift
|
||||
DEST_REPOSITORY="${!i}"
|
||||
;;
|
||||
@ -205,6 +320,13 @@ for ((i=1; i<=$#; i++)); do
|
||||
TARGET_ARCHS="`echo ${!i} | tr , ' '`"
|
||||
CROSS_MODE=1
|
||||
;;
|
||||
--user) let i+=1
|
||||
[ "${!i}" ] || {
|
||||
echo "Error: --user parameter not given, aborting."
|
||||
exit 1
|
||||
}
|
||||
WEBBUILD_USER_CMDLINE="${!i}"
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@ -216,14 +338,21 @@ done
|
||||
|
||||
[ "$DEST_REPOSITORY" ] || DEST_REPOSITORY=$PORT_REPOSITORY
|
||||
|
||||
if [ "$BATCH_MODE" ]; then
|
||||
PIDFILE="/run/autodist/autoport-${BUILD_ARCH}-${PORT_REPOSITORY}.pid"
|
||||
[ -e $PIDFILE ] && {
|
||||
PIDCHECK=`cat $PIDFILE`
|
||||
[ "$PIDCHECK" -a -e /proc/$PIDCHECK -a ! "$DISABLE_PID_CHECK" ] && {
|
||||
echo "Error: autoport -b already running with PID=$PIDCHECK.Aborting."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
echo $$ > $PIDFILE
|
||||
trap "rm -f $PIDFILE; exit 1" SIGQUIT SIGINT SIGKILL SIGTERM
|
||||
fi
|
||||
|
||||
for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
|
||||
[ "$BASE_ARCH" = "$TARGET_ARCH" -a "$PORT_REPOSITRY" = "$DEST_REPOSITORY" ] && {
|
||||
echo "Error: base and target arch ($BASE_ARCH) are the same as well as port and release repositories ($PORT_REPOSITORY); skipping."
|
||||
continue
|
||||
}
|
||||
|
||||
archs=($BASE_ARCH $TARGET_ARCH)
|
||||
JOBS_SKIPPED=()
|
||||
JOBS_CANTPREPARE=()
|
||||
JOBS_CANTINSTALL=()
|
||||
@ -237,88 +366,103 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
BASE_REPOSITORY_DISTROMATIC_URL=${DISTROMATIC_BASE_URL}$BASE_REPOSITORY
|
||||
PORT_REPOSITORY_DISTROMATIC_URL=${DISTROMATIC_BASE_URL}$PORT_REPOSITORY
|
||||
|
||||
[ "$AUTO_MODE" -a -e $DATAARCHDIR/last ] && . $DATAARCHDIR/last
|
||||
JOB=(${JOB_CMDLINE[*]} ${JOB_MISSINGREQ[*]} ${JOB_FAILED[*]})
|
||||
[ "$FIX_MODE" -o "$BATCH_MODE" -o "${JOB[*]}" ] || { usage ; exit 1; }
|
||||
|
||||
[ -d $DATAARCHDIR ] || mkdir -p $DATAARCHDIR
|
||||
[ -d $DATADIR/$BASE_REPOSITORY ] || mkdir -p $DATADIR/$BASE_REPOSITORY
|
||||
[ -d $DATADIR/$PORT_REPOSITORY ] || mkdir -p $DATADIR/$PORT_REPOSITORY
|
||||
|
||||
logfile=$DATAARCHDIR/log
|
||||
[ -e $logfile ] && mv -f $logfile $DATAARCHDIR/loglast
|
||||
logdate=`date +"%F@%T"`
|
||||
logfile=$DATAARCHDIR/$logdate.log
|
||||
[ -e $DATAARCHDIR/$PORT_REPOSITORY-current.log ] && mv $DATAARCHDIR/$PORT_REPOSITORY-current.log $DATAARCHDIR/$PORT_REPOSITORY-last.log
|
||||
> $logfile
|
||||
ln -sf $logdate.log $DATAARCHDIR/$PORT_REPOSITORY-current.log
|
||||
|
||||
BUILD_PLATFORM=`rpm --target $TARGET_ARCH --eval %{_build}`
|
||||
BUILD_CPU=`echo $BUILD_PLATFORM | cut -d- -f1`
|
||||
TARGET_PLATFORM=`rpm --target $TARGET_ARCH --eval %{_target_platform}`
|
||||
TARGET_CPU=`echo $TARGET_PLATFORM | cut -d- -f1`
|
||||
SPECDIR=`rpm --eval %{_specdir}`
|
||||
eval `autospec --eval spec_dir | tail -n1`
|
||||
if [ "$spec_dir" ]; then
|
||||
SPECDIR=$spec_dir
|
||||
else
|
||||
SPECDIR=`rpm --eval %{_specdir}`
|
||||
fi
|
||||
|
||||
echo "Build platform is $BUILD_PLATFORM"
|
||||
echo "Target platform is $TARGET_PLATFORM"
|
||||
echo "Port repository is $PORT_REPOSITORY"
|
||||
echo "Release repository is $DEST_REPOSITORY"
|
||||
|
||||
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH -o $DATADIR/$PORT_REPOSITORY/sources-$BASE_ARCH ||
|
||||
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$BASE_ARCH"
|
||||
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/sources-$TARGET_CPU -o $DATADIR/$PORT_REPOSITORY/sources-$TARGET_CPU ||
|
||||
echo "Warning: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/sources-$TARGET_CPU"
|
||||
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh -o $DATADIR/$PORT_REPOSITORY/builds-$BASE_ARCH.sh ||
|
||||
echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh"
|
||||
curl -s $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh -o $DATADIR/$PORT_REPOSITORY/builds-$TARGET_ARCH.sh ||
|
||||
echo "Error: unable to fetch $PORT_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
|
||||
fetch_repfiles
|
||||
|
||||
[ "$AUTO_MODE" -a -e $DATAARCHDIR/last ] && . $DATAARCHDIR/last
|
||||
if [ "$REBUILD_DEPENDANT_MODE" ]; then
|
||||
for j in ${JOB_CMDLINE[*]}; do
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $j
|
||||
port_pkg_list=${pkg_needrebuild[*]}
|
||||
port_pkg_builds=" ${pkg_builds[*]} "
|
||||
port_pkg_epoch=$pkg_epoch
|
||||
port_pkg_version=$pkg_version
|
||||
port_pkg_release=$pkg_release
|
||||
currrebuild=
|
||||
currjobscriptargs=
|
||||
JOBNUM=0
|
||||
for p in ${port_pkg_list}; do
|
||||
if [ "${p/@*}" != "$currrebuild" ]; then
|
||||
[ $JOBNUM -gt 0 ] && JOB_SCRIPTARGS[$JOBNUM-1]="$currjobscriptargs"
|
||||
currjobscriptargs=
|
||||
currrebuild=${p/@*}
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $currrebuild
|
||||
JOB=(${JOB[*]} $currrebuild)
|
||||
let JOBNUM+=1
|
||||
fi
|
||||
currprovider=${p/*@}
|
||||
if [ "${currprovider/-devel}" == "$currprovider" ]; then
|
||||
currprovider=${currprovider}-devel
|
||||
fi
|
||||
add_epoch=""
|
||||
[ "${port_pkg_epoch}" ] && add_epoch="${port_pkg_epoch}:"
|
||||
currjobscriptargs="$currjobscriptargs --buildreq ${currprovider} >= ${add_epoch}${port_pkg_version}-${port_pkg_release} "
|
||||
done
|
||||
[ "$currjobscriptargs" ] && JOB_SCRIPTARGS[$JOBNUM-1]="$currjobscriptargs"
|
||||
echo "Package dependant from $j to rebuild: ${JOB[*]}"
|
||||
done
|
||||
else
|
||||
JOB=(${JOB_CMDLINE[*]} ${JOB_MISSINGREQ[*]} ${JOB_FAILED[*]})
|
||||
fi
|
||||
[ "$FIX_MODE" -o "$BATCH_MODE" -o "${JOB[*]}" ] || { echo "Nothing to do."; exit 0; }
|
||||
|
||||
if [ "$BATCH_MODE" ]; then
|
||||
|
||||
[ "${JOB[*]}" ] && {
|
||||
echo "Error: no jobs allowed in batch mode; aborting."
|
||||
exit 1
|
||||
}
|
||||
curl -s $BASE_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh -o $DATADIR/$BASE_REPOSITORY/builds-$BASE_ARCH.sh ||
|
||||
echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$BASE_ARCH.sh"
|
||||
curl -s $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh -o $DATADIR/$BASE_REPOSITORY/builds-$TARGET_ARCH.sh ||
|
||||
echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH
|
||||
# old files cleanup
|
||||
rm -f $DATADIR/$BASE_REPOSITORY/builds-*.sh
|
||||
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH
|
||||
port_pkg_list=${pkg_list[*]}
|
||||
|
||||
for p in ${port_pkg_list}; do
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $p
|
||||
target_pkg_name=$pkg_name
|
||||
target_pkg_ver=$pkg_version
|
||||
target_pkg_rel=$pkg_release
|
||||
[ "$pkg_name" ] || get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $TARGET_ARCH $p
|
||||
if [ "$pkg_name" ]; then
|
||||
base_pkg_ver=$pkg_version
|
||||
base_pkg_rel=$pkg_release
|
||||
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH $p
|
||||
[ "$pkg_name" ] || {
|
||||
echo "Error: internal error, should never be here; aborting."
|
||||
exit 1
|
||||
}
|
||||
port_pkg_ver=$pkg_version
|
||||
port_pkg_rel=$pkg_release
|
||||
|
||||
if [ "$target_pkg_name" ]; then
|
||||
pkg_milestone=`echo $target_pkg_release | sed "s|[0-9.]*\(.*\)|\1|"`
|
||||
if [ "$target_pkg_ver" != "$port_pkg_ver" ]; then
|
||||
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${target_pkg_ver}-${target_pkg_rel}($BASE_ARCH); port needed."
|
||||
JOB=(${JOB[*]} $p)
|
||||
elif [ "$target_pkg_rel" != "$port_pkg_rel" ]; then
|
||||
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${target_pkg_ver}-${target_pkg_rel}($BASE_ARCH); port needed."
|
||||
JOB=(${JOB[*]} $p)
|
||||
elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then
|
||||
echo "Package $pkg_name($TARGET_ARCH) was not built for '$REBUILD_MILESTONE' milestone; rebuild needed."
|
||||
JOB=(${JOB[*]} $p)
|
||||
else
|
||||
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) is up to date."
|
||||
fi
|
||||
else
|
||||
echo "$p#${port_pkg_ver}-${port_pkg_rel}($BASE_ARCH) is in port repository but $p#${base_pkg_ver}-${base_pkg_rel}($TARGET_ARCH) is in base repository; port needed."
|
||||
if [ "$REBUILD_MILESTONE" ]; then
|
||||
for p in ${port_pkg_list}; do
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $p
|
||||
target_pkg_name=$pkg_name
|
||||
target_pkg_ver=$pkg_version
|
||||
target_pkg_rel=$pkg_release
|
||||
target_pkg_milestone=`echo $target_pkg_rel | sed "s|[0-9.]*\(.*\)|\1|"`
|
||||
if [ "$target_pkg_milestone" != "$REBUILD_MILESTONE" ]; then
|
||||
JOB=(${JOB[*]} $p)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "Packages to rebuild: ${JOB[*]}"
|
||||
fi
|
||||
echo "Packages to port: ${needport_list[*]}"
|
||||
for p in ${needport_list[*]}; do
|
||||
JOB=(${JOB[*]} $p)
|
||||
done
|
||||
|
||||
[ -e $DATADIR/autoport-$PORT_REPOSITORY-current ] && \
|
||||
mv $DATADIR/autoport-$PORT_REPOSITORY-current $DATADIR/autoport-$PORT_REPOSITORY-last
|
||||
fi
|
||||
|
||||
step=0
|
||||
@ -326,15 +470,20 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
tmpfile1=`mktemp`
|
||||
|
||||
[ -e $DATAARCHDIR/sentjobs ] || > $DATAARCHDIR/sentjobs
|
||||
find $DATAARCHDIR/sentjobs -cmin 120 && {
|
||||
find $DATAARCHDIR/sentjobs -cmin 120 >/dev/null && {
|
||||
> $DATAARCHDIR/sentjobs
|
||||
}
|
||||
|
||||
[ -e $DATAARCHDIR/preparedjobs ] || > $DATAARCHDIR/preparedjobs
|
||||
find $DATAARCHDIR/preparedjobs -ctime 1 && {
|
||||
find $DATAARCHDIR/preparedjobs -ctime 1 >/dev/null && {
|
||||
> $DATAARCHDIR/preparedjobs
|
||||
}
|
||||
|
||||
[ -e $DATAARCHDIR/updatedjobs ] || > $DATAARCHDIR/updatedjobs
|
||||
find $DATAARCHDIR/updatedjobs -ctime 1 >/dev/null && {
|
||||
> $DATAARCHDIR/updatedjobs
|
||||
}
|
||||
|
||||
sudo autoport-fix-environment $TARGET_ARCH
|
||||
|
||||
[ "$FIX_MODE" ] && exit 0
|
||||
@ -343,13 +492,14 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
|
||||
while [ "${JOB[*]}" ]; do
|
||||
step=`expr $step + 1`
|
||||
[ $step -gt 1 ] && fetch_repfiles
|
||||
[ "$BATCH_MODE" -a $step -gt $AUTOPORT_MAX_STEPS ] && {
|
||||
echo "Maximum steps count reached for batch mode; exiting. See $logfile for details."
|
||||
break
|
||||
}
|
||||
echo "=========="
|
||||
echo "Step $step"
|
||||
echo "Scheduled jobs: ${JOB[*]}"
|
||||
echo "# Step $step"
|
||||
echo "> Scheduled jobs: ${JOB[*]}"
|
||||
echo
|
||||
JOB_MISSINGREQ_OLD=(${JOB_MISSINGREQ[*]})
|
||||
JOB_MISSINGREQ=()
|
||||
@ -358,50 +508,68 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
JOB_FAILED=()
|
||||
JOB_CANTINSTALL_OLD=(${JOB_CANTINSTALL[*]})
|
||||
for JOB_NUM in `seq 1 ${#JOB[*]}`; do
|
||||
JOB_CURRENT=${JOB[$JOB_NUM-1]}
|
||||
if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage 2>/dev/null`" -o \
|
||||
"`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" ]; then
|
||||
echo -n "$JOB_CURRENT: "
|
||||
JOB_CURRENT=${JOB[$JOB_NUM-1]/\#*}
|
||||
if [ "${JOB_CURRENT}" != "${JOB[$JOB_NUM-1]}" ]; then
|
||||
JOB_CURRENT_VERSION=${JOB[$JOB_NUM-1]/*\#}
|
||||
else
|
||||
JOB_CURRENT_VERSION=
|
||||
fi
|
||||
if [ ! -s $DATADIR/$PORT_REPOSITORY/unstage.${TARGET_ARCH} -o \
|
||||
"`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" -o \
|
||||
"`grep "^${JOB_CURRENT}$" $DATADIR/$PORT_REPOSITORY/unstage.${TARGET_ARCH} 2>/dev/null`" ]; then
|
||||
echo -n "^ $JOB_CURRENT: "
|
||||
STAGEOPTS=
|
||||
else
|
||||
echo -n "$JOB_CURRENT(staging): "
|
||||
echo -n "^ $JOB_CURRENT(staging): "
|
||||
STAGEOPTS="$AUTOPORT_STAGEVARS"
|
||||
fi
|
||||
if [ "$CROSS_MODE" -a "${JOB_CURRENT:0:5}" == "perl-" ]; then
|
||||
echo " (SKIPPED) [unable to cross-build perl modules]"
|
||||
echo "< (SKIPPED) [unable to cross-build perl modules]"
|
||||
JOB_SKIPPED=(${JOB_SKIPPED[*]} $JOB_CURRENT)
|
||||
continue
|
||||
fi
|
||||
[ "`grep ^$JOB_CURRENT\$ $DATAARCHDIR/sentjobs`" -a ! "$FORCE_MODE" ] && {
|
||||
echo " (SKIPPED) [already sent]"
|
||||
echo "< (SKIPPED) [already sent]"
|
||||
JOB_SKIPPED=(${JOB_SKIPPED[*]} $JOB_CURRENT)
|
||||
continue
|
||||
}
|
||||
if [ "${JOB_MAYBEINSTALLED_NEW[*]}" = "" -a \
|
||||
"${JOB_MISSINGREQ_OLD[*]}" != "" -a \
|
||||
"`echo "( ${JOB_FAILED_OLD[*]} )"| grep " $JOB_CURRENT "`" ]; then
|
||||
echo " (FAILED) [nothing new since previous attempt]"
|
||||
echo "< (FAILED) [nothing new since previous attempt]"
|
||||
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
|
||||
continue
|
||||
fi
|
||||
pkg_release=
|
||||
pkg_version=
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH ${JOB_CURRENT} || \
|
||||
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH ${JOB_CURRENT} || \
|
||||
get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $TARGET_ARCH ${JOB_CURRENT} || \
|
||||
get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $BASE_ARCH ${JOB_CURRENT}
|
||||
pkg_milestone=`echo $pkg_release | sed "s|[0-9.]*\(.*\)|\1|"`
|
||||
pkg_numrelease=`echo $pkg_release | sed "s|\([0-9.]*\).*|\1|"`
|
||||
get_pkg_srcinfo $DATADIR/$PORT_REPOSITORY ${JOB_CURRENT} || {
|
||||
echo "< (FAILED) [error $? in get_pkg_srcinfo]"
|
||||
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
|
||||
continue
|
||||
}
|
||||
if [ "$JOB_CURRENT_VERSION" -a \
|
||||
"$JOB_CURRENT_VERSION" != "$src_version" -a \
|
||||
"$JOB_CURRENT_VERSION" != "$src_version-$src_release" ]; then
|
||||
echo "< (FAILED) [wrong version $src_version-$src_release != $JOB_CURRENT_VERSION]"
|
||||
JOB_FAILED=(${JOB_FAILED[*]} $JOB_CURRENT)
|
||||
continue
|
||||
fi
|
||||
|
||||
DONT_PREPARE_THIS=
|
||||
RELEASE_UPDATED=
|
||||
grep -q ^$JOB_CURRENT\$ $DATAARCHDIR/preparedjobs && RELEASE_UPDATED=1
|
||||
for p in ${JOB_CMDLINE[*]}; do
|
||||
[ "$p" = "${JOB_CURRENT}" -o "$DONT_PREPARE_ANY" ] || continue
|
||||
[ -e ${SPECDIR}/${JOB_CURRENT}.spec ] && DONT_PREPARE_THIS="$DONT_PREPARE"
|
||||
done
|
||||
[ ! "$DONT_PREPARE_THIS" -a ! "`grep ^$JOB_CURRENT\$ $DATAARCHDIR/preparedjobs`" ] && {
|
||||
echo -n "prepare"
|
||||
[ "$VERBOSE_MODE" ] && echo "
|
||||
%% COMMAND: LANG=C LC_ALL=C autodist -p ${JOB_CURRENT} --server $PORT_REPOSITORY --repository $PORT_REPOSITORY --severity 2 -- $STAGEOPTS"
|
||||
LANG=C LC_ALL=C autodist -p ${JOB_CURRENT} --server $PORT_REPOSITORY --repository $PORT_REPOSITORY --severity 2 -- $STAGEOPTS &>>$logfile
|
||||
if [ ! "$REBUILD_DEPENDANT_MODE" -a "$step" = "1" ]; then
|
||||
REPOSITORY_STRICT_ADD="--repository-strict"
|
||||
else
|
||||
REPOSITORY_STRICT_ADD=""
|
||||
fi
|
||||
# [ "$VERBOSE_MODE" ] && echo "
|
||||
#%% COMMAND: LANG=C LC_ALL=C autodist -p ${JOB_CURRENT} --server $PORT_REPOSITORY --repository $PORT_REPOSITORY $REPOSITORY_STRICT_ADD --severity 2 -- $STAGEOPTS"
|
||||
LANG=C LC_ALL=C autodist -p ${JOB_CURRENT} --server $PORT_REPOSITORY --repository $PORT_REPOSITORY $REPOSITORY_STRICT_ADD --severity 2 -- $STAGEOPTS &>$tmpfile
|
||||
[ $? -gt 0 ] && {
|
||||
RES=`find_source_by_provide $PORT_REPOSITORY $JOB_CURRENT`
|
||||
for j in ${RES}; do
|
||||
@ -414,38 +582,74 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
echo "(FAILED) "
|
||||
fi
|
||||
JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT)
|
||||
autoport_log ${JOB_CURRENT} prepare failed $tmpfile
|
||||
continue
|
||||
} || {
|
||||
spec_version=`grep -m1 "^Version:" ${SPECDIR}/${JOB_CURRENT}.spec | awk '{ print $2}'`
|
||||
spec_release=`grep -m1 "^Release:" ${SPECDIR}/${JOB_CURRENT}.spec | awk '{ print $2}'`
|
||||
if [ "${spec_version}-${spec_release}" != "$src_version-$src_release" ]; then
|
||||
echo "< (FAILED) [wrong version ${src_version}-${src_release} != ${spec_version}-${spec_release}]"
|
||||
JOB_CANTPREPARE=(${JOB_CANTPREPARE[*]} $JOB_CURRENT)
|
||||
autoport_log ${JOB_CURRENT} prepare failed $tmpfile
|
||||
continue
|
||||
fi
|
||||
echo $JOB_CURRENT >> $DATAARCHDIR/preparedjobs
|
||||
echo -n "(OK) "
|
||||
autoport_log ${JOB_CURRENT} prepare ok $tmpfile
|
||||
}
|
||||
if [ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ]; then
|
||||
if [ "$REBUILD_MODE" = "1" -o "$REBUILD_DEPENDANT_MODE" = "1" ]; then
|
||||
echo -n "update"
|
||||
[ "$VERBOSE_MODE" ] && echo "
|
||||
%% COMMAND: LANG=C LC_ALL=C autodist -u -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"automatic port from $PORT_REPOSITORY\""
|
||||
LANG=C LC_ALL=C autodist -u -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"automatic port from $PORT_REPOSITORY\" &>>$logfile
|
||||
if [ "$REBUILD_DEPENDANT_MODE" ]; then
|
||||
SCRIPT_ARGS="${JOB_SCRIPTARGS[$JOB_NUM-1]}"
|
||||
changelogadd="`echo ${SCRIPT_ARGS} | sed "s|--buildreq|,|g;s| ||g;s|^,||g"`"
|
||||
REBUILD_CHANGELOG="rebuilt by autoport with build requirements: '${changelogadd}'"
|
||||
fi
|
||||
# [ "$VERBOSE_MODE" ] && echo "
|
||||
#%% COMMAND: LANG=C LC_ALL=C autodist -u --rebuild -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"$REBUILD_CHANGELOG\" --- \"$SCRIPT_ARGS\""
|
||||
LANG=C LC_ALL=C autodist -u --rebuild -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"$REBUILD_CHANGELOG\" --- $SCRIPT_ARGS &>$tmpfile
|
||||
[ $? -gt 0 ] && {
|
||||
echo "(FAILED) "
|
||||
autoport_log ${JOB_CURRENT} update failed $tmpfile
|
||||
continue
|
||||
} || {
|
||||
autoport_log ${JOB_CURRENT} update ok $tmpfile
|
||||
echo -n "(OK) "
|
||||
RELEASE_UPDATED=1
|
||||
echo $JOB_CURRENT >> $DATAARCHDIR/updatedjobs
|
||||
}
|
||||
elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then
|
||||
elif [ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ]; then
|
||||
echo -n "update"
|
||||
[ "$pkg_repository" -a "$pkg_version" -a "$pkg_release" ] || {
|
||||
# [ "$VERBOSE_MODE" ] && echo "
|
||||
#%% COMMAND: LANG=C LC_ALL=C autodist -u -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"automatic port from $PORT_REPOSITORY\""
|
||||
LANG=C LC_ALL=C autodist -u -r ${JOB_CURRENT} --severity 2 -- $STAGEOPTS --changelog \"automatic port from $PORT_REPOSITORY\" --- $SCRIPT_ARGS &>$tmpfile
|
||||
cat $tmpfile >> $logfile
|
||||
[ $? -gt 0 ] && {
|
||||
echo "(FAILED) "
|
||||
autoport_log ${JOB_CURRENT} update failed $tmpfile
|
||||
continue
|
||||
} || {
|
||||
autoport_log ${JOB_CURRENT} update ok $tmpfile
|
||||
echo -n "(OK) "
|
||||
RELEASE_UPDATED=1
|
||||
}
|
||||
elif [ "$REBUILD_MILESTONE" -a "$src_milestone" != "$REBUILD_MILESTONE" ]; then
|
||||
echo -n "update"
|
||||
[ "$src_repository" -a "$src_version" -a "$src_release" ] || {
|
||||
echo "(FAILED) [can't get repository information for this package]"
|
||||
continue
|
||||
}
|
||||
src_release_num=`echo $src_release | sed "s|\([0-9.]*\).*|\1|"`
|
||||
# [ "$VERBOSE_MODE" ] && echo "
|
||||
#%% COMMAND: LANG=C LC_ALL=C autospec -u ${JOB_CURRENT} -a4 --changelog \"$REBUILD_MILESTONE milestone rebuild\" $src_version $src_release_num${REBUILD_MILESTONE}"
|
||||
# FIXME: should be implemented in autodist
|
||||
LANG=C LC_ALL=C autospec -u ${JOB_CURRENT} -a4 ${pkg_version} ${pkg_numrelease}${REBUILD_MILESTONE} \
|
||||
--changelog "$REBUILD_MILESTONE milestone rebuild" &>$tmpfile
|
||||
LANG=C LC_ALL=C autospec -u ${JOB_CURRENT} -a4 --changelog "$REBUILD_MILESTONE milestone rebuild" $src_version $src_release_num${REBUILD_MILESTONE} &>$tmpfile
|
||||
[ $? -gt 0 ] && {
|
||||
if [ "$VERBOSE_MODE" ]; then
|
||||
echo
|
||||
echo "Failed output:"
|
||||
echo "=============="
|
||||
echo "= Failed output:"
|
||||
echo "================"
|
||||
cat $tmpfile
|
||||
echo "=============="
|
||||
echo "================"
|
||||
echo
|
||||
fi
|
||||
cat $tmpfile >> $logfile
|
||||
@ -453,28 +657,37 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
echo "(FAILED)"
|
||||
JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'`
|
||||
[ "$JOB_LOG" ] || JOB_LOG=$tmpfile
|
||||
autoport_log ${JOB_CURRENT} update failed $tmpfile
|
||||
continue
|
||||
} || {
|
||||
cat $tmpfile >> $logfile
|
||||
echo -n "(OK) "
|
||||
autoport_log ${JOB_CURRENT} update ok $tmpfile
|
||||
RELEASE_UPDATED=1
|
||||
}
|
||||
fi
|
||||
}
|
||||
echo -n "port"
|
||||
[ "$pkg_repository" ] || {
|
||||
if [ ! "$src_repository" -a "$DONT_PREPARE_THIS" != "1" ]; then
|
||||
echo "(FAILED) [can't get repository information for this package]"
|
||||
autoport_log ${JOB_CURRENT} port failed
|
||||
continue
|
||||
}
|
||||
[ "$PORT_REPOSITORY" != "$DEST_REPOSITORY" ] && pkg_repository="$DEST_REPOSITORY"
|
||||
[ ! "$DONT_PREPARE_THIS" -a "$PORT_REPOSITORY" = "$DEST_REPOSITORY" -a ! "$REBUILD_MILESTONE" ] && NOSRPM_OPTS="--nosrpm" || NOSRPM_OPTS="--force"
|
||||
LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $pkg_repository --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS &>$tmpfile
|
||||
fi
|
||||
SEND_REPOSITORY=$DEST_REPOSITORY
|
||||
if [ ! "$RELEASE_UPDATED" -a ! "$DONT_PREPARE_THIS" ]; then
|
||||
SEND_REPOSITORY=$src_repository
|
||||
fi
|
||||
[ ! "$DONT_PREPARE_THIS" -a ! "$RELEASE_UPDATED" ] && NOSRPM_OPTS="--nosrpm" || NOSRPM_OPTS="--force"
|
||||
# [ "$VERBOSE_MODE" ] && echo "
|
||||
#%% COMMAND: LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $SEND_REPOSITORY --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS"
|
||||
LANG=C LC_ALL=C autodist -b -s ${JOB_CURRENT} --arch $TARGET_ARCH --server $SEND_REPOSITORY --repository $PORT_REPOSITORY --severity 2 $FORCE_FLAG -- $STAGEOPTS $NOSRPM_OPTS &>$tmpfile
|
||||
[ $? -gt 0 ] && {
|
||||
if [ "$VERBOSE_MODE" ]; then
|
||||
echo
|
||||
echo "Failed output:"
|
||||
echo "=============="
|
||||
echo "= Failed output:"
|
||||
echo "================"
|
||||
cat $tmpfile
|
||||
echo "=============="
|
||||
echo "================"
|
||||
echo
|
||||
fi
|
||||
cat $tmpfile >> $logfile
|
||||
@ -483,23 +696,34 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'`
|
||||
[ "$JOB_LOG" ] || JOB_LOG=$tmpfile
|
||||
[ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG
|
||||
autoport_log ${JOB_CURRENT} port failed $tmpfile
|
||||
continue
|
||||
} || {
|
||||
cat $tmpfile >> $logfile
|
||||
JOB_SENT=(${JOB_SENT[*]} $JOB_CURRENT)
|
||||
echo $JOB_CURRENT >> $DATAARCHDIR/sentjobs
|
||||
echo -n "(OK) "
|
||||
autoport_log ${JOB_CURRENT} port ok $tmpfile
|
||||
if [ "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then
|
||||
if [ "$WEBBUILD_USER_CMDLINE" ]; then
|
||||
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
|
||||
MESSAGE=`cgi_encodevar \"(invoked by $WEBBUILD_USER_CMDLINE) ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$SEND_REPOSITORY</b>\"`" >/dev/null
|
||||
else
|
||||
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=$WEBBUILD_SECRET&USER_EMAIL=$WEBBUILD_EMAIL&\
|
||||
MESSAGE=`cgi_encodevar \"ported <b>$JOB_CURRENT</b> to <b>$TARGET_ARCH</b> and sent it to <b>$SEND_REPOSITORY</b>\"`" >/dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
echo -n "install"
|
||||
LANG=C LC_ALL=C autodist -i ${JOB_CURRENT} --arch $TARGET_ARCH --force --severity 2 -- $STAGEOPTS &>>$tmpfile
|
||||
LANG=C LC_ALL=C autodist -i ${JOB_CURRENT} --arch $TARGET_ARCH --force --severity 2 -- $STAGEOPTS &>$tmpfile
|
||||
# --server $DEST_REPOSITORY --repository $PORT_REPOSITORY
|
||||
[ $? -gt 0 ] && {
|
||||
if [ "$VERBOSE_MODE" ]; then
|
||||
echo
|
||||
echo "Failed output:"
|
||||
echo "=============="
|
||||
echo "= Failed output:"
|
||||
echo "================"
|
||||
cat $tmpfile
|
||||
echo "=============="
|
||||
echo "================"
|
||||
echo
|
||||
fi
|
||||
cat $tmpfile >> $logfile
|
||||
@ -512,7 +736,8 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT)
|
||||
JOB_LOG=`grep "^?= See " $tmpfile | awk '{ print $3 }'`
|
||||
[ "$JOB_LOG" ] || JOB_LOG=$tmpfile
|
||||
find_requirements $JOB_LOG
|
||||
[ ! "$REBUILD_MILESTONE" ] && find_requirements $JOB_LOG
|
||||
autoport_log ${JOB_CURRENT} install failed $tmpfile
|
||||
continue
|
||||
} || {
|
||||
cat $tmpfile >> $logfile
|
||||
@ -520,6 +745,7 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT)
|
||||
JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT)
|
||||
echo -n "(OK)"
|
||||
autoport_log ${JOB_CURRENT} install ok $tmpfile
|
||||
}
|
||||
echo
|
||||
done
|
||||
@ -528,8 +754,8 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
JOB_CANTINSTALL=()
|
||||
for JOB_NUM in `seq 1 ${#JOB_CANTINSTALL_OLD[*]}`; do
|
||||
JOB_CURRENT=${JOB_CANTINSTALL_OLD[$JOB_NUM-1]}
|
||||
if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage 2>/dev/null`" -o \
|
||||
"`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" ]; then
|
||||
if [ "`grep "^${JOB_CURRENT}$" /etc/autodist/unstage.${TARGET_ARCH} 2>/dev/null`" -o \
|
||||
"`grep "^${JOB_CURRENT}$" $DATADIR/$PORT_REPOSITORY/unstage.$TARGET_ARCH 2>/dev/null`" ]; then
|
||||
echo -n "$JOB_CURRENT: "
|
||||
STAGEOPTS=
|
||||
else
|
||||
@ -542,10 +768,10 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
[ $? -gt 0 ] && {
|
||||
if [ "$VERBOSE_MODE" ]; then
|
||||
echo
|
||||
echo "Failed output:"
|
||||
echo "=============="
|
||||
echo "= Failed output:"
|
||||
echo "================"
|
||||
cat $tmpfile
|
||||
echo "=============="
|
||||
echo "================"
|
||||
echo
|
||||
fi
|
||||
cat $tmpfile >> $logfile
|
||||
@ -566,22 +792,23 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
JOB_MAYBEINSTALLED_NEW=(${JOB_MAYBEINSTALLED_NEW[*]} $JOB_CURRENT)
|
||||
JOB_COMPLETED=(${JOB_COMPLETED[*]} $JOB_CURRENT)
|
||||
echo -n "(OK)"
|
||||
autoport_log ${JOB_CURRENT} retryinstall ok $tmpfile
|
||||
}
|
||||
echo
|
||||
done
|
||||
fi
|
||||
echo "Skipped jobs: ${JOB_SKIPPED[*]}"
|
||||
echo "Unpreparable jobs: ${JOB_CANTPREPARE[*]}"
|
||||
echo "Missing requirements: ${JOB_MISSINGREQ[*]}"
|
||||
echo "Completed jobs: ${JOB_COMPLETED[*]}"
|
||||
echo "Installation error for: ${JOB_CANTINSTALL[*]}"
|
||||
echo "Failed jobs: ${JOB_FAILED[*]}"
|
||||
echo "| Skipped jobs: ${JOB_SKIPPED[*]}"
|
||||
echo "| Unpreparable jobs: ${JOB_CANTPREPARE[*]}"
|
||||
echo "| Missing requirements: ${JOB_MISSINGREQ[*]}"
|
||||
echo "| Completed jobs: ${JOB_COMPLETED[*]}"
|
||||
echo "| Installation error for: ${JOB_CANTINSTALL[*]}"
|
||||
echo "| Failed jobs: ${JOB_FAILED[*]}"
|
||||
write_last_file
|
||||
|
||||
[ "${JOB[*]}" == "${JOB_FAILED[*]}" -a \
|
||||
"${JOB_MISSINGREQ[*]}" == "" -a \
|
||||
"${JOB_CANTINSTALL_OLD[*]}" == "${JOB_CANTINSTALL[*]}" ] && {
|
||||
echo "Loop detected. Finishing. See $logfile for details."
|
||||
echo "! Loop detected. Finishing. See $logfile for details."
|
||||
rm -f $tmpfile $tmpfile1
|
||||
exit 1
|
||||
}
|
||||
@ -590,5 +817,6 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
|
||||
done
|
||||
rm -f $tmpfile $tmpfile1
|
||||
done
|
||||
echo "All jobs completed. See $logfile for details."
|
||||
exit 0
|
||||
echo "* All jobs completed. See $logfile for details."
|
||||
[ "$BATCH_MODE" ] && rm -f $PIDFILE
|
||||
exit ${#JOB_FAILED[*]}
|
||||
|
@ -1,11 +1,13 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autoport-chroot
|
||||
# (c) 2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# (c) 2012-2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
CHROOT_TARGET=$1
|
||||
shift
|
||||
CHROOT_COMMAND=$@
|
||||
|
||||
function usage() {
|
||||
echo "\
|
||||
@ -16,7 +18,7 @@ $0
|
||||
"$"Enters autoport chroot environment.""
|
||||
|
||||
"$"Usage"":
|
||||
$me chroot_target
|
||||
$me chroot_target [command [args..]]
|
||||
"
|
||||
}
|
||||
|
||||
@ -35,8 +37,19 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
else
|
||||
CMD_PREFIX=
|
||||
fi
|
||||
echo "Entering ${AUTOPORT_CHROOT[$i]} autoport chroot environment"
|
||||
$CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l ${AUTOPORT_CHROOT_USER[$i]}
|
||||
if [ "$CHROOT_COMMAND" ]; then
|
||||
$CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l $SU_APPEND ${AUTOPORT_CHROOT_USER[$i]} -c "${CHROOT_COMMAND}"
|
||||
else
|
||||
echo "Entering ${AUTOPORT_CHROOT[$i]} autoport chroot environment"
|
||||
hostname=`hostname`
|
||||
grep $hostname /var/autoport/${AUTOPORT_CHROOT[$i]}/etc/hosts >/dev/null || {
|
||||
sed -i "s|\(^127.0.0.1[[:space:]]*\)|\1$hostname |" /var/autoport/${AUTOPORT_CHROOT[$i]}/etc/hosts
|
||||
}
|
||||
[ -e /var/autoport/${AUTOPORT_CHROOT[$i]}/etc/profile.d/autoport.sh ] || {
|
||||
echo "PS1='[\u@${AUTOPORT_CHROOT[$i]} \W]\$ '" > /var/autoport/${AUTOPORT_CHROOT[$i]}/etc/profile.d/autoport.sh
|
||||
}
|
||||
$CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l $SU_APPEND ${AUTOPORT_CHROOT_USER[$i]}
|
||||
fi
|
||||
exit 0
|
||||
done
|
||||
|
||||
|
@ -30,7 +30,7 @@ function fix_la_files() {
|
||||
sed -i "s|libdir='/usr/$TARGET_PLATFORM/${_lib}'|libdir='/usr/${_lib}'|g" /usr/${_lib}/*.la
|
||||
sed -i "s|libdir='/$TARGET_PLATFORM/${_lib}'|libdir='/usr/${_lib}'|g" /usr/${_lib}/*.la
|
||||
sed -i "s|/usr/$TARGET_PLATFORM/${_lib}|/usr/${_lib}|g" /usr/${_lib}/*.la
|
||||
sed -i "s|[:space:]/usr/$TARGET_PLATFORM/${_lib}|[:space:]/usr/${_lib}/lib|g" /usr/${_lib}/*.la
|
||||
sed -i "s|[[:space:]]/usr/$TARGET_PLATFORM/${_lib}|[[:space:]]/usr/${_lib}/lib|g" /usr/${_lib}/*.la
|
||||
}
|
||||
done
|
||||
}
|
||||
@ -41,7 +41,7 @@ function fix_la_files_cross() {
|
||||
sed -i "s|libdir='/usr/${_lib}'|libdir='/usr/$TARGET_PLATFORM/${_lib}'|g" /usr/$TARGET_PLATFORM/${_lib}/*.la
|
||||
sed -i "s|libdir='/${_lib}'|libdir='/usr/$TARGET_PLATFORM/${_lib}'|g" /usr/$TARGET_PLATFORM/${_lib}/*.la
|
||||
sed -i "s|/usr/${_lib}|/usr/$TARGET_PLATFORM/${_lib}|g" /usr/$TARGET_PLATFORM/${_lib}/*.la
|
||||
sed -i "s|[:space:]/lib/${_lib}|[:space:]/usr/$TARGET_PLATFORM/${_lib}/lib|g" /usr/$TARGET_PLATFORM/${_lib}/*.la
|
||||
sed -i "s|[[:space:]]/lib/${_lib}|[[:space:]]/usr/$TARGET_PLATFORM/${_lib}/lib|g" /usr/$TARGET_PLATFORM/${_lib}/*.la
|
||||
}
|
||||
done
|
||||
}
|
||||
|
111
autoport-launcher
Executable file
@ -0,0 +1,111 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autoport launcher
|
||||
# (c) 2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
#. /etc/sysconfig/openmamba-central
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0
|
||||
|
||||
i=$1
|
||||
|
||||
[ "$i" ] || {
|
||||
echo "Usage: autoport-launcher autoport_conf"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
|
||||
|
||||
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && exit 0
|
||||
|
||||
PIDFILE=/run/autodist/autoport-launcher-${i}.pid
|
||||
[ -e $PIDFILE ] && {
|
||||
PIDCHECK=`cat $PIDFILE`
|
||||
[ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && {
|
||||
echo "autoport-launcher for configuration $i already running; exiting."
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
echo $$ > $PIDFILE
|
||||
trap "rm -f $PIDFILE; exit 1" SIGQUIT SIGINT SIGKILL SIGTERM
|
||||
|
||||
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then
|
||||
CMD_PREFIX=linux32
|
||||
else
|
||||
CMD_PREFIX=
|
||||
fi
|
||||
|
||||
UPDATE_DONE=
|
||||
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
|
||||
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
AUTOPORT_PIDFILE="/run/autodist/autoport-${AUTOPORT_ARCH[$i]}-$r.pid"
|
||||
LOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-native-$r-${AUTOPORT_ARCH[$i]}-last.log"
|
||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
AUTOPORT_PIDFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/run/autodist/autoport-${AUTOPORT_ARCH[$i]}-$r.pid"
|
||||
LOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-chroot-$r-${AUTOPORT_CHROOT[$i]}-last.log"
|
||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
AUTOPORT_PIDFILE="/run/autoport/autoport-${AUTOPORT_ARCH[$i]}-$r.pid"
|
||||
LOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-cross-$r-${AUTOPORT_CROSS[$i]}-last.log"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$UPDATE_DONE" == "" ]; then
|
||||
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in ${AUTOPORT_ARCH[$i]} native environment"
|
||||
echo "= Updating packages in ${AUTOPORT_ARCH[$i]} native environment..." >> $LOGFILE
|
||||
LANG=C dnf update -y >> $LOGFILE
|
||||
UPDATE_DONE=1
|
||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in ${AUTOPORT_CHROOT[$i]} chroot environment"
|
||||
#echo "= Updating packages in ${AUTOPORT_CHROOT[$i]} chroot environment..." >> $LOGFILE
|
||||
LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} dnf update -y > /dev/null
|
||||
#[ "${AUTOPORT_CHROOT_ICECREAM[$i]}" ] && LANG=C /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} /etc/init.d/icecream start
|
||||
UPDATE_DONE=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e $AUTOPORT_PIDFILE ]; then
|
||||
PIDCHECK=`cat $AUTOPORT_PIDFILE`
|
||||
if [ "$PIDCHECK" -a -e /proc/$PIDCHECK ]; then
|
||||
echo "autoport for configuration $i already running; continuing."
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE
|
||||
|
||||
echo "+ Autoport start at `date`" > $LOGFILE
|
||||
echo "============================================" >> $LOGFILE
|
||||
|
||||
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
echo "= Working on $r(${AUTOPORT_ARCH[$i]}) in native mode" >> $LOGFILE
|
||||
su -l ${AUTOPORT_CHROOT_USER[$i]} -c "$CMD_PREFIX autoport -b -r $r" >> $LOGFILE
|
||||
AUTODIST_HOME=`getent passwd ${AUTOPORT_CHROOT_USER[$i]} | cut -d: -f6`
|
||||
cat $AUTODIST_HOME/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE
|
||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
echo "= Working on $r(${AUTOPORT_CHROOT[$i]}) in chroot mode..." >> $LOGFILE
|
||||
$CMD_PREFIX /usr/sbin/chroot /var/autoport/${AUTOPORT_CHROOT[$i]} su -l ${AUTOPORT_CHROOT_USER[$i]} -c "autoport -b -r $r" >> $LOGFILE
|
||||
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "autodist" ]; then
|
||||
cat /var/autoport/${AUTOPORT_CHROOT[$i]}/var/autodist/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE
|
||||
else
|
||||
cat /var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autoport/${AUTOPORT_ARCH[$i]}/$r-current.log >> $LOGFILE
|
||||
fi
|
||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r(${AUTOPORT_CROSS[$i]}) in cross-platform mode"
|
||||
echo "= Working on $r(${AUTOPORT_CROSS[$i]}) in cross-platform mode" >> $LOGFILE
|
||||
su -l autodist -c "autoport -b -x ${AUTOPORT_CROSS[$i]} -r $r" >> $LOGFILE
|
||||
cat /var/autodist/.autoport/${AUTOPORT_CROSS[$i]}/$r-current.log >> $LOGFILE
|
||||
fi
|
||||
|
||||
echo "- Autoport end at `date`" >> $LOGFILE
|
||||
echo "============================================" >> $LOGFILE
|
||||
|
||||
done
|
||||
rm -f ${PIDFILE}
|
@ -3,7 +3,7 @@
|
||||
DISTRO="openmamba"
|
||||
VENDOR="openmamba"
|
||||
|
||||
curl_opts_netlink="--connect-timeout 15 --retry 3 --limit-rate 400k -Y 1 -C -s"
|
||||
curl_opts_netlink="--connect-timeout 15 --retry 3 -s"
|
||||
|
||||
packager_fullname="Automatic Build System"
|
||||
packager_email="autodist@mambasoft.it"
|
||||
@ -20,9 +20,9 @@ source_dir="/var/autodist/RPM/SOURCES"
|
||||
build_dir="/var/autodist/RPM/BUILD"
|
||||
tmppath_dir="/var/tmp/autodist"
|
||||
|
||||
ftp_alias[0]="devel"
|
||||
ftpurl_ro_rpms[0]="ftp://ftp.openmamba.org/pub/openmamba/devel/RPMS.@arch@"
|
||||
ftpurl_ro_srpms[0]="ftp://ftp.openmamba.org/pub/openmamba/devel/SRPMS.base"
|
||||
ftp_alias[0]="base"
|
||||
ftpurl_ro_rpms[0]="ftp://ftp.openmamba.org/pub/openmamba/base/RPMS.@arch@"
|
||||
ftpurl_ro_srpms[0]="ftp://ftp.openmamba.org/pub/openmamba/base/SRPMS.base"
|
||||
ftp_rw_server[0]="ftp://ftp.openmamba.org"
|
||||
ftp_rw_port[0]=
|
||||
ftp_rw_passive_mode[0]=on
|
||||
@ -30,7 +30,7 @@ ftp_rw_user[0]=
|
||||
ftp_rw_passwd[0]=
|
||||
ftp_rw_rpms_dir[0]="/RPMS.@arch@"
|
||||
ftp_rw_srpms_dir[0]="/SRPMS.base"
|
||||
arch_list[0]="i586 ppc arm x86_64"
|
||||
arch_list[0]="i586 arm x86_64 aarch64"
|
||||
arch_noarch_upload[0]="${arch_list[0]}"
|
||||
ftpdir_rw_old[0]="/old"
|
||||
|
||||
|
@ -4,17 +4,15 @@ openmamba-sound-theme
|
||||
desktop-base-openmamba
|
||||
autodist
|
||||
kernel27
|
||||
rpm
|
||||
apt
|
||||
rootfiles
|
||||
soundfont-2rock9
|
||||
livecd-tools
|
||||
makedist
|
||||
makedist-openmamba
|
||||
postplug
|
||||
grub-theme-openmamba
|
||||
kdevelop
|
||||
lxde
|
||||
libqt
|
||||
distromatic
|
||||
u-boot
|
||||
openmamba-distro-compat
|
||||
xorg-apps
|
||||
|
@ -1,16 +1,49 @@
|
||||
# Global configuration file for autodist
|
||||
#
|
||||
REPS_BASE_URL=http://www.openmamba.org/pub/openmamba
|
||||
AUTODIST_ARCHS=(i586 x86_64 arm aarch64)
|
||||
SITE_BASE_URL=https:/openmamba.org
|
||||
REPS_BASE_URL=${SITE_BASE_URL}/pub/openmamba
|
||||
LOCAL_REPS_BASE_DIR=/var/ftp/pub/openmamba
|
||||
SEND_SERVER=devel-autodist
|
||||
GNOME_VER=2.32.0
|
||||
AUTOBUILD_MAXNUM=150
|
||||
#WEBBUILD_URL=http://localhost/cgi-bin/webbuild
|
||||
#WEBBUILD_USER=
|
||||
#WEBBUILD_EMAIL=
|
||||
#WEBBUILD_SECRET=
|
||||
WEBBUILD_STATEDIR=/var/webbuild
|
||||
WEBBUILD_DISTROQUERY_URL="http://www.openmamba.org/cgi-bin/distroquery"
|
||||
AUTOBUILD_MAXNUM=200
|
||||
AUTOBUILD_DATEFROM=20060601
|
||||
AUTOBUILD_SKIP_DAYS=7
|
||||
AUTOBUILD_SKIP_DAYS=28
|
||||
AUTOBUILD_SUCCESS_DAYS=3
|
||||
AUTODIST_REPOSITORY=devel-autodist
|
||||
AUTODIST_DELAYED_REPOSITORY=devel-future
|
||||
AUTODIST_REPOSITORIES=(devel devel-games devel-makedist devel-kernel devel-xorg devel-kde4 devel-autodist)
|
||||
AUTODIST_REPOSITORIES=(base devel-makedist devel-kernel devel-autodist devel-misc)
|
||||
AUTOPORT_UNSTAGE_ARCHS="i586"
|
||||
AUTOPORT_STAGEVARS="--define stage1=1"
|
||||
AUTOPORT_MAX_STEPS=15
|
||||
AUTOPORT_MAX_STEPS=10
|
||||
#RPMDIR=/usr/src/RPM
|
||||
AUTODIST_REBUILDOLD_MAX=20
|
||||
AUTODIST_REBUILDOLD_FROMDATE=20090101
|
||||
#
|
||||
# Set to disable autodist-repository and use local list
|
||||
#
|
||||
WEBBUILD_REPOSITORIES=(base devel-kernel devel-makedist devel-misc devel-autodist devel-future devel-past \
|
||||
milestone1 milestone1-updates milestone1-games milestone1-1.1 milestone1-makedist \
|
||||
milestone2 milestone2-games milestone2-updates milestone2-kernel milestone2-kde4 \
|
||||
milestone2-xorg milestone2-makedist milestone2-java \
|
||||
milestone1-java milestone1-contrib)
|
||||
#
|
||||
# Set to enable autodist-repository (you also need to disable WEBBUILD_REPOSITORIES above)
|
||||
#
|
||||
#AUTODIST_REPOSITORIES_LOCAL_REPS=(base devel-kernel devel-makedist devel-misc devel-autodist \
|
||||
# devel-future devel-past \
|
||||
# milestone3 milestone3-games milestone3-updates milestone3-makedist \
|
||||
# milestone2 milestone2-games milestone2-updates milestone2-kernel milestone2-kde4 \
|
||||
# milestone2-xorg milestone2-makedist milestone2-java milestone2-kernel-next \
|
||||
# milestone1 milestone1-updates milestone1-games milestone1-1.1 milestone1-makedist)
|
||||
#AUTODIST_REPOSITORIES_REMOTE_REPS=(devel-contrib \
|
||||
# milestone1-java milestone1-contrib)
|
||||
#AUTODIST_REPOSITORIES_TRANSITIONAL_REP=devel-makedist
|
||||
#AUTODIST_REPOSITORIES_REMOTE_FTPUSER=
|
||||
#AUTODIST_REPOSITORIES_REMOTE_FTPPASS=
|
||||
#AUTODIST_REPOSITORIES_REMOTE_FTP=
|
||||
|
@ -1,317 +0,0 @@
|
||||
# openmamba autodist build jobs database - architecture independent
|
||||
#
|
||||
# Copyright (c) 2006-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Released under the terms of the GNU GPL version 3 license
|
||||
#
|
||||
|
||||
kernel=(
|
||||
kernel
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
arm,mamba-arm
|
||||
x86_64,mamba-x86_64
|
||||
)
|
||||
|
||||
kernel_64GB=(
|
||||
kernel
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
kernel_x86_64=(
|
||||
kernel
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
)
|
||||
|
||||
kernel_hannspad=(
|
||||
kernel-hannspad
|
||||
target
|
||||
arm
|
||||
)
|
||||
|
||||
kernel_iconia=(
|
||||
kernel-iconia
|
||||
target
|
||||
arm
|
||||
)
|
||||
|
||||
#ppc,mamba
|
||||
#x86_64,mamba
|
||||
|
||||
kernel_extramodules=(
|
||||
kernel-extramodules
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
kernel_packages_old=(
|
||||
hsfmodem,slmodem,compat-wireless,alsa-driver,ati-driver,lirc,ndiswrapper,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,VirtualBox,\
|
||||
broadcom-sta,atheros-81,drbd,rtl8192se
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
i586,mamba,3.0
|
||||
i586,mamba-64GB,3.0
|
||||
)
|
||||
|
||||
kernel_packages=(
|
||||
hsfmodem,slmodem,compat-wireless,alsa-driver,ati-driver,lirc,ndiswrapper,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,VirtualBox,\
|
||||
broadcom-sta,stk11xx,cm2020,rtl8192se
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
i586,mamba,-
|
||||
i586,mamba-64GB,-
|
||||
)
|
||||
|
||||
kernel_packages_new=(
|
||||
hsfmodem,slmodem,compat-wireless,alsa-driver,ati-driver,lirc,ndiswrapper,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,VirtualBox,\
|
||||
broadcom-sta,stk11xx,cm2020
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
i586,mamba,3.2
|
||||
i586,mamba-64GB,3.2
|
||||
)
|
||||
#rtl8192se
|
||||
|
||||
#ppc,mamba
|
||||
#x86_64,mamba
|
||||
|
||||
NVIDIA_all=(
|
||||
NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
i586,mamba,-
|
||||
i586,mamba-64GB,-
|
||||
)
|
||||
|
||||
alsa_driver=(
|
||||
alsa-driver
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
ati_driver=(
|
||||
ati-driver
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
#x86_64,mamba-x86_64
|
||||
|
||||
broadcom_sta=(
|
||||
broadcom-sta
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
kernel_wireless_backport=(
|
||||
kernel-wireless-backport
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
lirc=(
|
||||
lirc
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
ndiswrapper=(
|
||||
ndiswrapper
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
NVIDIA=(
|
||||
NVIDIA
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
VirtualBox=(
|
||||
VirtualBox
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
compat_wireless=(
|
||||
compat-wireless
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
broadcom_sta=(
|
||||
broadcom-sta
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
atheros_81=(
|
||||
atheros-sta
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
drbd=(
|
||||
drbd
|
||||
target,KERNEL_TARGET
|
||||
i586,mamba
|
||||
i586,mamba-64GB
|
||||
)
|
||||
|
||||
xorg_drv_video=(
|
||||
xorg-drv-video,xorg-drv-video-apm,xorg-drv-video-ark,xorg-drv-video-ast,xorg-drv-video-ati,\
|
||||
xorg-drv-video-chips,xorg-drv-video-cirrus,xorg-drv-video-dummy,xorg-drv-video-fbdev,\
|
||||
xorg-drv-video-geode,xorg-drv-video-glint,xorg-drv-video-i128,xorg-drv-video-i740,\
|
||||
xorg-drv-video-intel,xorg-drv-video-mach64,xorg-drv-video-mga,xorg-drv-video-neomagic,\
|
||||
xorg-drv-video-newport,xorg-drv-video-nouveau,xorg-drv-video-nv,xorg-drv-video-openchrome,\
|
||||
xorg-drv-video-r128,xorg-drv-video-radeonhd,xorg-drv-video-rendition,xorg-drv-video-s3,\
|
||||
xorg-drv-video-s3virge,xorg-drv-video-savage,xorg-drv-video-siliconmotion,xorg-drv-video-sis,\
|
||||
xorg-drv-video-sisusb,xorg-drv-video-trident,xorg-drv-video-tseng,xorg-drv-video-v4l,\
|
||||
xorg-drv-video-vesa,xorg-drv-video-vmware,xorg-drv-video-voodoo,xorg-drv-video-xgixp
|
||||
)
|
||||
|
||||
xorg_drv_input=(
|
||||
xorg-drv-input,xorg-drv-input-acecad,xorg-drv-input-aiptek,xorg-drv-input-elographics,\
|
||||
xorg-drv-input-evdev,xorg-drv-input-fpit,xorg-drv-input-hyperpen,xorg-drv-input-joystick,\
|
||||
xorg-drv-input-keyboard,xorg-drv-input-mouse,xorg-drv-input-mutouch,xorg-drv-input-penmount,\
|
||||
xorg-drv-input-synaptics,xorg-drv-input-tslib,xorg-drv-input-vmmouse,xorg-drv-input-void
|
||||
)
|
||||
|
||||
abiword=(
|
||||
abiword,abiword-docs
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
compiz=(
|
||||
compiz,compiz-bcop,compiz-plugins-extra,compiz-plugins-main,libcompizconfig,compizconfig-backend-kconfig4,\
|
||||
compizconfig-simple-settings-manager,emerald
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
# compiz-bcop,compizconfig-backend-kconfig,compizconfig-settings-manager,compizconfig-backend-gconf
|
||||
|
||||
compiz09=(
|
||||
compiz-core,libcompizconfig,python-compizconfig,compizconfig-backend-kconfig4,compiz-fusion-plugins-main,compiz-fusion-plugins-extra
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
#curl=(
|
||||
#curl
|
||||
#%build_and_install
|
||||
#1
|
||||
#)
|
||||
|
||||
evolution=(
|
||||
libevolution-data-server,evolution
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
#,evolution-exchange
|
||||
|
||||
#ekiga=(
|
||||
#libpt,libopal,ekiga
|
||||
#%build_and_install
|
||||
#1
|
||||
#)
|
||||
|
||||
#gobby=(
|
||||
#obby,gobby
|
||||
#%build_and_install
|
||||
#1
|
||||
#)
|
||||
|
||||
kde3=(
|
||||
kdelibs,kdebase,kdeadmin,kdeutils,kdenetwork,kdeaccessibility,kdepim,kdegames,kdegraphics,kdemultimedia,kdeaddons,kdenetwork,\
|
||||
kdesdk,kdetoys,kdebindings,kdewebdev,kdeedu,kdeartwork,kde-i18n
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
kde4=(
|
||||
kdelibs,kdepimlibs,oxygen-icons,kde-runtime,kde-workspace,kde-wallpapers,kde-baseapps,kdepim4,\
|
||||
kdepim-runtime,kdeadmin,kdemultimedia,kdenetwork4,kdeartwork,kdegames,kdetoys,kdesdk,marble,\
|
||||
kdeplasma-addons,kde-l10n,blinken,cantor,gwenview,libkdeedu,libanalitza,kalgebra,kalzium,kamera,\
|
||||
kanagram,kate,kbruch,kcolorchooser,kdegraphics-strigi-analyzer,kgamma,kgeography,khangman,kig,kiten,\
|
||||
klettres,kmplot,kolourpaint,konsole,kruler,ksnapshot,kstars,libkdcraw,libkexiv2,libkipi,libksane,\
|
||||
okular,smokegen,smokeqt,smokekde,svgpart,rocs,kwordquiz,kturtle,ktouch,qtruby,korundum,\
|
||||
kross-interpreters,perl-Qt4,perl-KDE,kdegraphics-thumbnailers,ksaneplugin,parley,step,\
|
||||
ark,filelight,kcalc,kcharselect,kdf,kfloppy,kgpg,kremotecontrol,ktimer,kwallet,sweeper
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
#kdeaccessibility4,kdeutils
|
||||
|
||||
alsa=(
|
||||
libalsa,libalsa-plugins,alsa-utils,alsa-driver,alsa-tools
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
apache_tomcat=(
|
||||
apache-tomcat-dbcp,apache-tomcat
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
netbeans=(
|
||||
netbeans-platform,netbeans
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
firefox=(
|
||||
xulrunner,firefox
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
xfce=(
|
||||
libxfce4util,xfconf,libxfcegui4,libxfce4ui,xfce-utils,xfce4-appfinder,xfce4-panel,xfce4-session,xfdesktop,xfwm4
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
#xfce4-mixer,xfprint,orage,xfwm4-themes,libxfce4menu
|
||||
|
||||
FlightGear=(
|
||||
libSimGear,FlightGear
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
valknut=(
|
||||
libdc,valknut
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
# use for major release update (e.g. 2.24 -> 2.26)
|
||||
gnome=(
|
||||
libgnome,libsoup,libgweather,librsvg,libwnck,libgdl,gnome-desktop,python-gnome-desktop,libeel,gnome-icon-theme,gnome-menus,\
|
||||
libgnome-panel,anjuta,zenity,metacity,nautilus,brasero,cheese,evince,gconf-editor,gedit,gedit-plugins
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
fwbuilder=(
|
||||
libfwbuilder,fwbuilder
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
|
||||
koffice=(
|
||||
koffice
|
||||
%build_and_install
|
||||
1
|
||||
)
|
||||
#,koffice-i18n
|
@ -1,73 +0,0 @@
|
||||
# openmamba autodist build jobs database
|
||||
#
|
||||
# Copyright (c) 2006-2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Released under the terms of the GNU GPL version 3 license
|
||||
#
|
||||
|
||||
#
|
||||
# XTC 1 (Cross Toolchain)
|
||||
#
|
||||
# build native binutils (gcc needed, so it's not a stage1 build)
|
||||
# and cross platform binutils
|
||||
#
|
||||
binutils=(
|
||||
binutils
|
||||
cross_target_cpu,_target_platform
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
avr,avr
|
||||
)
|
||||
|
||||
glibc=(
|
||||
glibc
|
||||
cross_target_cpu,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER,build_doc,build_profile,build_selinux
|
||||
arm,-,-,mamba-arm,-,0,0,0
|
||||
)
|
||||
|
||||
kernel=(
|
||||
kernel
|
||||
target,KERNEL_TARGET
|
||||
arm,mamba-arm
|
||||
)
|
||||
|
||||
linux_firmware=(
|
||||
linux-firmware
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
arm,mamba-arm,3.2
|
||||
)
|
||||
|
||||
pam=(
|
||||
pam
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
rpm=(
|
||||
rpm
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
klibc=(
|
||||
klibc
|
||||
KERNEL_VER
|
||||
2.6.33mamba-arm
|
||||
)
|
||||
|
||||
emacs=(
|
||||
emacs
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,disable_java,disable_gjdoc
|
||||
avr,avr,1,-
|
||||
arm,arm-openmamba-linux-gnueabi,1,1
|
||||
)
|
||||
|
||||
udev=(
|
||||
udev
|
||||
%build_and_install
|
||||
0
|
||||
)
|
@ -1,183 +0,0 @@
|
||||
# openmamba autodist build jobs database for i586 platform
|
||||
#
|
||||
# Copyright (c) 2006-2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Released under the terms of the GNU GPL version 3 license
|
||||
#
|
||||
|
||||
#
|
||||
# XTC 1 (Cross Toolchain)
|
||||
#
|
||||
# build native binutils (gcc needed, so it's not a stage1 build)
|
||||
# and cross platform binutils
|
||||
#
|
||||
binutils=(
|
||||
binutils
|
||||
cross_target_cpu,_target_platform
|
||||
i586,i586-openmamba-linux-gnu
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
avr,avr
|
||||
x86_64,x86_64-openmamba-linux-gnu
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 2
|
||||
#
|
||||
# glibc stage1: build headers only
|
||||
glibc_stage1=(
|
||||
glibc
|
||||
cross_target_cpu,stage1,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
i586,1,i586-openmamba-linux-gnu,mamba,-
|
||||
arm,1,arm-openmamba-linux-gnueabi,mamba-arm,2.6.33
|
||||
ppc,1,ppc-openmamba-linux-gnu,mamba-ppc,2.6.33
|
||||
x86_64,1,x86_64-openmamba-linux-gnu,mamba-x86_64,-
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 3
|
||||
#
|
||||
gcc_stage1=(
|
||||
gcc
|
||||
cross_target_cpu,stage1,_target_platform
|
||||
arm,1,arm-openmamba-linux-gnueabi
|
||||
i586,1,i586-openmamba-linux-gnu
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
x86_64,1,x86_64-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 4
|
||||
#
|
||||
glibc_stage2=(
|
||||
glibc
|
||||
cross_target_cpu,stage2,bigendian,softfloat,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
arm,1,-,-,arm-openmamba-linux-gnueabi,mamba-arm,2.6.33
|
||||
i586,1,-,-,i586-openmamba-linux-gnu,mamba,-
|
||||
ppc,1,-,-,ppc-openmamba-linux-gnu,mamba,-
|
||||
x86_64,1,-,-,x86_64-openmamba-linux-gnu,mamba-x86_64,-
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 5
|
||||
#
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,disable_java
|
||||
i586,i586-openmamba-linux-gnu,-
|
||||
arm,arm-openmamba-linux-gnueabi,1
|
||||
x86_64,x86_64-openmamba-linux-gnu,1
|
||||
ppc,ppc-openmamba-linux-gnu,1
|
||||
avr,avr,1
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 6
|
||||
#
|
||||
glibc=(
|
||||
glibc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
i586,i586-openmamba-linux-gnu,-,-,mamba,-
|
||||
x86_64,x86_64-openmamba-linux-gnu,-,-,mamba-x86_64,2.6.33
|
||||
arm,arm-openmamba-linux-gnueabi,-,-,mamba-arm,-
|
||||
ppc,ppc-openmamba-linux-gnu,-,-,mamba-ppc,2.6.33
|
||||
)
|
||||
|
||||
# XTC 7
|
||||
cross_environment=(
|
||||
cross-environment
|
||||
cross_target_cpu,autodist_crossonly,_target_platform
|
||||
avr,1,avr
|
||||
i586,1,i586-openmamba-linux-gnu
|
||||
arm,1,arm-openmamba-linux-gnueabi
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
x86_64,1,x86_64-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
gcc_cross=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,disable_java
|
||||
avr,avr,1
|
||||
)
|
||||
|
||||
pkg_config=(
|
||||
pkg-config
|
||||
cross_target_cpu,_target_platform
|
||||
i586,i586-openmamba-linux-gnu
|
||||
x86_64,x86_64-openmamba-linux-gnu
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
gcc_uclibc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
arm,arm-linux-uclibc,-,-,mamba-arm,2.6.33
|
||||
)
|
||||
|
||||
dietlibc=(
|
||||
dietlibc
|
||||
cross_target_cpu
|
||||
i586
|
||||
arm
|
||||
)
|
||||
|
||||
gcc34=(
|
||||
gcc34
|
||||
cross_target_cpu
|
||||
i586
|
||||
ppc
|
||||
)
|
||||
|
||||
klibc=(
|
||||
klibc
|
||||
cross_target_cpu,_target_platform,KERNEL_VER
|
||||
-,-,-
|
||||
ppc,ppc-openmamba-linux-gnu,2.6.33mamba-ppc
|
||||
x86_64,x86_64-openmamba-linux-gnu,2.6.33mamba-x86_64
|
||||
arm,arm-openmamba-linux-gnueabi,2.6.33mamba-arm
|
||||
)
|
||||
|
||||
glibc_arm=(
|
||||
glibc
|
||||
cross_target_cpu,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
arm,-,-,mamba-arm,-
|
||||
)
|
||||
|
||||
#
|
||||
# ppc cross toolchain
|
||||
#
|
||||
binutils_ppc=(
|
||||
binutils
|
||||
cross_target_cpu,_target_platform
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
glibc_ppc_stage1=(
|
||||
glibc
|
||||
cross_target_cpu,stage1,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,1,ppc-openmamba-linux-gnu,mamba,-
|
||||
)
|
||||
|
||||
gcc_ppc_stage1=(
|
||||
gcc
|
||||
cross_target_cpu,stage1,_target_platform
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
glibc_ppc_stage2=(
|
||||
glibc
|
||||
cross_target_cpu,stage2,bigendian,softfloat,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,1,-,-,ppc-openmamba-linux-gnu,mamba-ppc,2.6.33
|
||||
)
|
||||
|
||||
gcc_ppc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
glibc_ppc=(
|
||||
glibc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,ppc-openmamba-linux-gnu,-,-,mamba-ppc,2.6.33
|
||||
)
|
@ -1,267 +0,0 @@
|
||||
# openmamba autodist build jobs database
|
||||
#
|
||||
# Copyright (c) 2006-2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Released under the terms of the GNU GPL version 3 license
|
||||
#
|
||||
|
||||
# XTC 1 (Cross Toolchain)
|
||||
cross_environment=(
|
||||
cross-environment
|
||||
cross_target_cpu,autodist_crossonly,_target_platform
|
||||
x86_64,1,x86_64-openmamba-linux-gnu
|
||||
i586,1,i586-openmamba-linux-gnu
|
||||
arm,1,arm-openmamba-linux-gnueabi
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 2
|
||||
#
|
||||
# build native binutils (gcc needed, so it's not a stage1 build)
|
||||
# and cross platform binutils
|
||||
#
|
||||
binutils=(
|
||||
binutils
|
||||
cross_target_cpu,_target_platform
|
||||
x86_64,x86_64-openmamba-linux-gnu
|
||||
i586,i586-openmamba-linux-gnu
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 3
|
||||
#
|
||||
# glibc stage1: build headers only
|
||||
glibc_stage1=(
|
||||
glibc
|
||||
cross_target_cpu,stage1,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,1,x86_64-openmamba-linux-gnu,mamba-x86_64,-
|
||||
arm,1,arm-openmamba-linux-gnueabi,mamba-arm,2.6.33
|
||||
i586,1,i586-openmamba-linux-gnu,mamba,-
|
||||
ppc,1,ppc-openmamba-linux-gnu,mamba,-
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 4
|
||||
#
|
||||
gcc_stage1=(
|
||||
gcc
|
||||
cross_target_cpu,stage1,_target_platform
|
||||
x86_64,1,x86_64-openmamba-linux-gnu
|
||||
arm,1,arm-openmamba-linux-gnueabi
|
||||
i586,1,i586-openmamba-linux-gnu
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 5
|
||||
#
|
||||
glibc_stage2=(
|
||||
glibc
|
||||
cross_target_cpu,stage2,bigendian,softfloat,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,1,-,-,x86_64-openmamba-linux-gnu,mamba-x86_64,-
|
||||
arm,1,-,-,arm-openmamba-linux-gnueabi,mamba-arm,2.6.33
|
||||
i586,1,-,-,i586-openmamba-linux-gnu,mamba,-
|
||||
ppc,1,-,-,ppc-openmamba-linux-gnu,mamba,-
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 6
|
||||
#
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform
|
||||
x86_64,x86_64-openmamba-linux-gnu
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
i586,i586-openmamba-linux-gnu
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 7
|
||||
#
|
||||
glibc=(
|
||||
glibc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,ppc-openmamba-linux-gnu,-,-,mamba-ppc,2.6.33
|
||||
x86_64,x86_64-openmamba-linux-gnu,-,-,mamba-x86_64,-
|
||||
i586,i586-openmamba-linux-gnu,-,-,mamba,-
|
||||
arm,arm-openmamba-linux-gnueabi,-,-,mamba-arm,2.6.33
|
||||
)
|
||||
|
||||
gcc_uclibc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
arm,arm-linux-uclibc,-,-,mamba-arm,2.6.33
|
||||
)
|
||||
|
||||
dietlibc=(
|
||||
dietlibc
|
||||
cross_target_cpu
|
||||
ppc
|
||||
x86_64
|
||||
i586
|
||||
arm
|
||||
)
|
||||
|
||||
gcc34=(
|
||||
gcc34
|
||||
cross_target_cpu
|
||||
ppc
|
||||
x86_64
|
||||
i586
|
||||
ppc
|
||||
)
|
||||
|
||||
#klibc=(
|
||||
#klibc
|
||||
#cross_target_cpu,_target_platform,KERNEL_VER
|
||||
#-,-,-
|
||||
#ppc,ppc-openmamba-linux-gnueabi,2.6.33mamba-ppc
|
||||
#)
|
||||
|
||||
kernel=(
|
||||
kernel
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
kernel_new=(
|
||||
kernel
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,mamba-ppc,2.6.33
|
||||
)
|
||||
|
||||
kernel_extra=(
|
||||
kernel-extramodules
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
kernel_packages=(
|
||||
hsfmodem,compat-wireless,ati-driver,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,broadcom-sta
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,mamba-ppc,-
|
||||
)
|
||||
# slmodem, alsa-driver, lirc,VirtualBox, ndiswrapper, alsa-driver
|
||||
|
||||
kernel_packages_new=(
|
||||
hsfmodem,compat-wireless,ati-driver,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,broadcom-sta
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,mamba-ppc,2.6.33
|
||||
)
|
||||
|
||||
NVIDIA_all=(
|
||||
NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
alsa_driver=(
|
||||
alsa-driver
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
ati_driver=(
|
||||
ati-driver
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
broadcom_sta=(
|
||||
broadcom-sta
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
kernel_extramodules=(
|
||||
kernel-extramodules
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
kernel_nongpl=(
|
||||
kernel-nongpl
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
kernel_wireless_backport=(
|
||||
kernel-wireless-backport
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
lirc=(
|
||||
lirc
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
ndiswrapper=(
|
||||
ndiswrapper
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
NVIDIA=(
|
||||
NVIDIA
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
VirtualBox=(
|
||||
VirtualBox
|
||||
target,KERNEL_TARGET
|
||||
ppc,mamba-ppc
|
||||
)
|
||||
|
||||
glibc=(
|
||||
glibc
|
||||
cross_target_cpu,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
ppc,-,-,mamba-ppc,2.6.33
|
||||
)
|
||||
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu
|
||||
ppc
|
||||
)
|
||||
|
||||
binutils=(
|
||||
binutils
|
||||
cross_target_cpu
|
||||
ppc
|
||||
)
|
||||
|
||||
pam=(
|
||||
pam
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
rpm=(
|
||||
rpm
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
klibc=(
|
||||
klibc
|
||||
KERNEL_VER
|
||||
2.6.33mamba-ppc
|
||||
)
|
||||
|
||||
emacs=(
|
||||
emacs
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
gcc=(
|
||||
gcc
|
||||
disable_jack,disable_java,disable_gjdoc
|
||||
1,1,1
|
||||
)
|
@ -1,271 +0,0 @@
|
||||
# openmamba autodist build jobs database
|
||||
#
|
||||
# Copyright (c) 2006-2010 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Released under the terms of the GNU GPL version 3 license
|
||||
#
|
||||
|
||||
# XTC 1 (Cross Toolchain)
|
||||
cross_environment=(
|
||||
cross-environment
|
||||
cross_target_cpu,autodist_crossonly,_target_platform
|
||||
x86_64,1,x86_64-openmamba-linux-gnu
|
||||
i586,1,i586-openmamba-linux-gnu
|
||||
arm,1,arm-openmamba-linux-gnueabi
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 2
|
||||
#
|
||||
# build native binutils (gcc needed, so it's not a stage1 build)
|
||||
# and cross platform binutils
|
||||
#
|
||||
binutils=(
|
||||
binutils
|
||||
cross_target_cpu,_target_platform
|
||||
x86_64,x86_64-openmamba-linux-gnu
|
||||
i586,i586-openmamba-linux-gnu
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 3
|
||||
#
|
||||
# glibc stage1: build headers only
|
||||
glibc_stage1=(
|
||||
glibc
|
||||
cross_target_cpu,stage1,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,1,x86_64-openmamba-linux-gnu,mamba-x86_64,-
|
||||
arm,1,arm-openmamba-linux-gnueabi,mamba-arm,2.6.33
|
||||
i586,1,i586-openmamba-linux-gnu,mamba,-
|
||||
ppc,1,ppc-openmamba-linux-gnu,mamba,-
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 4
|
||||
#
|
||||
gcc_stage1=(
|
||||
gcc
|
||||
cross_target_cpu,stage1,_target_platform
|
||||
x86_64,1,x86_64-openmamba-linux-gnu
|
||||
arm,1,arm-openmamba-linux-gnueabi
|
||||
i586,1,i586-openmamba-linux-gnu
|
||||
ppc,1,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 5
|
||||
#
|
||||
glibc_stage2=(
|
||||
glibc
|
||||
cross_target_cpu,stage2,bigendian,softfloat,_target_platform,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,1,-,-,x86_64-openmamba-linux-gnu,mamba-x86_64,-
|
||||
arm,1,-,-,arm-openmamba-linux-gnueabi,mamba-arm,2.6.33
|
||||
i586,1,-,-,i586-openmamba-linux-gnu,mamba,-
|
||||
ppc,1,-,-,ppc-openmamba-linux-gnu,mamba,-
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 6
|
||||
#
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform
|
||||
x86_64,x86_64-openmamba-linux-gnu
|
||||
arm,arm-openmamba-linux-gnueabi
|
||||
i586,i586-openmamba-linux-gnu
|
||||
ppc,ppc-openmamba-linux-gnu
|
||||
)
|
||||
|
||||
#
|
||||
# XTC 7
|
||||
#
|
||||
glibc=(
|
||||
glibc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,x86_64-openmamba-linux-gnu,-,-,mamba-x86_64,-
|
||||
i586,i586-openmamba-linux-gnu,-,-,mamba,-
|
||||
arm,arm-openmamba-linux-gnueabi,-,-,mamba-arm,2.6.33
|
||||
)
|
||||
|
||||
gcc_uclibc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
arm,arm-linux-uclibc,-,-,mamba-arm,2.6.33
|
||||
)
|
||||
|
||||
dietlibc=(
|
||||
dietlibc
|
||||
cross_target_cpu
|
||||
x86_64
|
||||
i586
|
||||
arm
|
||||
)
|
||||
|
||||
gcc34=(
|
||||
gcc34
|
||||
cross_target_cpu
|
||||
x86_64
|
||||
i586
|
||||
ppc
|
||||
)
|
||||
|
||||
kernel=(
|
||||
kernel
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
)
|
||||
#x86_64,mamba-xen
|
||||
|
||||
kernel_extra=(
|
||||
kernel-extramodules
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
)
|
||||
#x86_64,mamba-xen
|
||||
|
||||
kernel_packages=(
|
||||
hsfmodem,compat-wireless,ati-driver,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,broadcom-sta
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,mamba-x86_64,-
|
||||
)
|
||||
# slmodem, alsa-driver, lirc,VirtualBox, ndiswrapper, alsa-driver
|
||||
|
||||
kernel_packages_new=(
|
||||
hsfmodem,compat-wireless,ati-driver,NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx,broadcom-sta
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,mamba-x86_64,2.6.33
|
||||
)
|
||||
|
||||
kernelxen_packages=(
|
||||
alsa-driver,hsfmodem,compat-wireless,ati-driver,ndiswrapper,broadcom-sta
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,mamba-xen,-
|
||||
)
|
||||
|
||||
NVIDIA_all=(
|
||||
NVIDIA,NVIDIA_71xx,NVIDIA_96xx,NVIDIA_173xx
|
||||
target,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,mamba-x86_64
|
||||
)
|
||||
#x86_64,mamba-xen
|
||||
|
||||
alsa_driver=(
|
||||
alsa-driver
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
ati_driver=(
|
||||
ati-driver
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
broadcom_sta=(
|
||||
broadcom-sta
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
kernel_extramodules=(
|
||||
kernel-extramodules
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
kernel_nongpl=(
|
||||
kernel-nongpl
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
kernel_wireless_backport=(
|
||||
kernel-wireless-backport
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
broadcom_sta=(
|
||||
broadcom-sta
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
lirc=(
|
||||
lirc
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
ndiswrapper=(
|
||||
ndiswrapper
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
NVIDIA=(
|
||||
NVIDIA
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
)
|
||||
#x86_64,mamba-xen
|
||||
|
||||
VirtualBox=(
|
||||
VirtualBox
|
||||
target,KERNEL_TARGET
|
||||
x86_64,mamba-x86_64
|
||||
x86_64,mamba-xen
|
||||
)
|
||||
|
||||
glibc=(
|
||||
glibc
|
||||
cross_target_cpu,bigendian,softfloat,KERNEL_TARGET,KERNEL_VER
|
||||
x86_64,-,-,mamba-x86_64,-
|
||||
)
|
||||
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu
|
||||
x86_64
|
||||
)
|
||||
|
||||
binutils=(
|
||||
binutils
|
||||
cross_target_cpu
|
||||
x86_64
|
||||
)
|
||||
|
||||
pam=(
|
||||
pam
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
rpm=(
|
||||
rpm
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
emacs=(
|
||||
emacs
|
||||
bootstrap
|
||||
1
|
||||
)
|
||||
|
||||
gcc=(
|
||||
gcc
|
||||
cross_target_cpu,_target_platform,disable_jack,disable_gjdoc,disable_java
|
||||
x86_64,x86_64-openmamba-linux-gnu,1,1,0
|
||||
)
|
@ -1,83 +0,0 @@
|
||||
kdebase
|
||||
kdewebdev
|
||||
grub
|
||||
libsqlite2
|
||||
libglade1
|
||||
openssl097
|
||||
gnupg
|
||||
kannel
|
||||
ftp
|
||||
nrg2iso
|
||||
ddrescue
|
||||
db42
|
||||
gcc34
|
||||
ftpsync
|
||||
libglib1
|
||||
gcc33
|
||||
libxml
|
||||
libtool1
|
||||
openldap22
|
||||
python24
|
||||
postgresql7
|
||||
PyQt
|
||||
libcares1
|
||||
libraw13941
|
||||
net-snmp5
|
||||
libmtp7
|
||||
gambas
|
||||
libgda2
|
||||
libmusicbrainz2
|
||||
libpng2
|
||||
libXaw8
|
||||
icu38
|
||||
mysql5
|
||||
libreadline5
|
||||
libxcb-xlib
|
||||
autoconf2.13
|
||||
python
|
||||
libflac11
|
||||
libdc1394_control
|
||||
automake1.10
|
||||
libusb0
|
||||
xorg-drv-input
|
||||
libeigen
|
||||
libgtk1
|
||||
java-junit3
|
||||
lm_sensors2
|
||||
kernel-extramodules
|
||||
kernel-nongpl-nvidia
|
||||
kernel-nongpl-fglrx
|
||||
kernel-nongpl
|
||||
automake1.6
|
||||
libjpeg6b
|
||||
kernel-nongpl-fglrx
|
||||
kernel-nongpl-nvidia
|
||||
db47
|
||||
arts
|
||||
kdegraphics
|
||||
synaptic
|
||||
libjpeg7
|
||||
kdevelop
|
||||
libgda
|
||||
objectweb-asm1
|
||||
objectweb-asm2
|
||||
apache-tomcat5
|
||||
java-junit381
|
||||
jakarta-commons-lang24
|
||||
openssl098
|
||||
libpng12
|
||||
java-servletapi4
|
||||
tcltk84
|
||||
make381
|
||||
lilo
|
||||
rpm516
|
||||
ffmpeg052
|
||||
rpm5
|
||||
libpoppler6
|
||||
x264-84
|
||||
db51
|
||||
kde-i18n
|
||||
libwpg01
|
||||
libwps01
|
||||
libwpd08
|
||||
db52
|
@ -1,28 +1,95 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Autodist script for updating specfiles
|
||||
#
|
||||
# Copyright (c) 2007-2009 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Copyright (c) 2007-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# Released with the same license as autodist
|
||||
#
|
||||
|
||||
[ "$1" ] || {
|
||||
echo "Error: update-specfile: specfile not given; aborting."
|
||||
SPECFILE=
|
||||
BUILDREQNUM=0
|
||||
|
||||
for ((i=1; i<=$#; i++)); do
|
||||
case ${!i} in
|
||||
--buildreq) let i+=1
|
||||
if [ ! "${!i}" ]; then
|
||||
echo "ERROR: --buildreq requires at least an argument; aborting."
|
||||
exit 1
|
||||
fi
|
||||
let BUILDREQNUM+=1
|
||||
BUILDREQ[$BUILDREQNUM]=${!i}
|
||||
if [ "${!i+1}" -a "${!i+1:0:1}" != "-" ]; then
|
||||
let i+=1
|
||||
BUILDREQREL[$BUILDREQNUM]=${!i}
|
||||
if [ ! "${!i+1}" -o "${!i+1:0:1}" = "-" ]; then
|
||||
echo "ERROR: update-specfile: --buildreq requires one or three arguments; aborting."
|
||||
exit 1
|
||||
fi
|
||||
let i+=1
|
||||
BUILDREQVER[$BUILDREQNUM]=${!i}
|
||||
fi
|
||||
;;
|
||||
*) if [ ! "$SPECFILE" ]; then
|
||||
SPECFILE=${!i}
|
||||
else
|
||||
echo "ERROR: update-specfile: unrecognized script option: '${!i}'; aborting."
|
||||
exit 1
|
||||
fi
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$SPECFILE" ] || {
|
||||
echo "ERROR: update-specfile: specfile not given; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -e $1 ] || {
|
||||
[ -e $SPECFILE ] || {
|
||||
echo "Error: update-specfile: file $1 does not exist; aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
sed -i "s|^Vendor:.*|Vendor: openmamba|" $1
|
||||
sed -i "s|^Distribution:.*|Distribution: openmamba|" $1
|
||||
sed -i "s|silvan\.calarco@qilinux\.it|silvan.calarco@mambasoft.it|" $1
|
||||
sed -i "/BuildRequires:[[:space:]]*libffmpeg-devel/d" $1
|
||||
sed -i "s|\(BuildRequires:[[:space:]]*\)libmysql-devel|\1libmysql5-devel|" $1
|
||||
sed -i "s|\(BuildRequires:[[:space:]]*\)libdb42-devel|\1libdb47-devel|" $1
|
||||
sed -i "s|\(BuildRequires:[[:space:]]*\)firefox-devel|\1xulrunner-devel|" $1
|
||||
sed -i "s|^PreReq:[[:space:]]*/sbin/install-info|Requires(post):%{__install_info}|" $1
|
||||
sed -i "s|^PreReq:[[:space:]]*%{__install_info}|Requires(post):%{__install_info}|" $1
|
||||
sed -i "s|^PreReq:[[:space:]]*|Requires(pre): |" $1
|
||||
#sed -i "s|^\(Source.*:[[:space:]]*ftp://ftp.kde.org/pub/kde/stable/.*.tar.\)bz2|\1xz|" $1
|
||||
# Distribution global changes
|
||||
sed -i "s|^Vendor:.*|Vendor: openmamba|;
|
||||
s|^Distribution:.*|Distribution: openmamba|;
|
||||
/BuildRequires:[[:space:]]*libffmpeg-devel/d;
|
||||
/^BuildRequires:[[:space:]]*libkdegames-devel/d;
|
||||
/^BuildRequires:[[:space:]]*libkdegames5-devel/d;
|
||||
/^BuildRequires:[[:space:]]*python3.7dist/d;
|
||||
/^BuildRoot:[[:space:]]*.*/d;
|
||||
s|\(BuildRequires:[[:space:]]*\)libmysql-devel|\1libmysql5-devel|;
|
||||
s|\(BuildRequires:[[:space:]]*\)libdb42-devel|\1libdb47-devel|;
|
||||
s|\(BuildRequires:[[:space:]]*\)libdb51-devel|\1libdb53-devel|;
|
||||
s|\(BuildRequires:[[:space:]]*\)firefox-devel|\1xulrunner-devel|;
|
||||
s|^PreReq:[[:space:]]*/sbin/install-info|Requires(post):%{__install_info}|;
|
||||
s|^PreReq:[[:space:]]*%{__install_info}|Requires(post):%{__install_info}|;
|
||||
s|^PreReq:[[:space:]]*|Requires(pre): |;
|
||||
s|^\(Requires:[[:space:]]*kde-workspace\)$|#\1|;
|
||||
s|^%patch\([0-9][0-9]*\)|%patch \1|;
|
||||
s|http://.*.dl\.sourceforge\.net/|https://downloads.sourceforge.net/|;
|
||||
s|http://ftp.kde.org/stable/|https://download.kde.org/stable/|;
|
||||
s|ftp://ftp.kde.org/pub/kde/|https://download.kde.org/|;
|
||||
s|update-mime-database %{|update-mime-database -n %{|;
|
||||
s|http://download.kde.org/stable/%{version}|https://download.kde.org/stable/applications/%{version}|;
|
||||
s|http[s]*://pypi.python.org/packages/source/[^/]*/|https://pypi.debian.net/|;
|
||||
s|http://ftp.gnome.org/pub/GNOME/sources/|https://download.gnome.org/sources/|;
|
||||
s|ftp://ftp.gnome.org/pub/gnome/sources/|https://download.gnome.org/sources/|" $SPECFILE
|
||||
# s|;s,.*/man/.*,&.gz,g||;
|
||||
# s|http.*.cpan.org/.*/\([^/-]*\)\(-.*\)|https://cpan.metacpan.org/modules/by-module/\1/\1\2|;
|
||||
#sed -i "s|^\(Source.*:[[:space:]]*ftp://ftp.kde.org/pub/kde/stable/.*.tar.\)bz2|\1xz|" $SPECFILE
|
||||
|
||||
if [ $BUILDREQNUM -gt 0 ]; then
|
||||
grep "^## AUTOBUILDREQ-END" $SPECFILE > /dev/null || {
|
||||
echo "ERROR: update-specfile: missing AUTOBUILDREQ block; aborting."
|
||||
exit 1
|
||||
}
|
||||
for b in `seq 1 $BUILDREQNUM`; do
|
||||
line=${BUILDREQ[$b]}
|
||||
if [ "${BUILDREQREL[$b]}" ]; then
|
||||
line="$line ${BUILDREQREL[$b]} ${BUILDREQVER[$b]}"
|
||||
fi
|
||||
sed -i "/^## AUTOBUILDREQ-END/,9999{/BuildRequires:[[:space:]]*${BUILDREQ[$b]}$/d}" $SPECFILE
|
||||
sed -i "/^## AUTOBUILDREQ-END/,9999{/BuildRequires:[[:space:]]*${BUILDREQ[$b]}[[:space:]]/d}" $SPECFILE
|
||||
sed -i "/^## AUTOBUILDREQ-END/a BuildRequires: $line" $SPECFILE
|
||||
done
|
||||
fi
|
||||
exit 0
|
||||
|
@ -1 +0,0 @@
|
||||
gcc
|
@ -1,17 +0,0 @@
|
||||
libatk
|
||||
libgtk
|
||||
libpango
|
||||
tcltk
|
||||
dbus
|
||||
libgsf
|
||||
python
|
||||
glib
|
||||
libnfsidmap
|
||||
ghostscript
|
||||
liblcms
|
||||
ImageMagick4
|
||||
ImageMagick
|
||||
gcc
|
||||
libtiff
|
||||
libtiff3
|
||||
libcairo
|
@ -1,4 +0,0 @@
|
||||
tcltk
|
||||
libxml2
|
||||
libpango
|
||||
libatk
|
64
etc/cron.daily/40-autodist-cleanold
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
[ -e /etc/autodist/config ] && . /etc/autodist/config
|
||||
[ -e /etc/sysconfig/autoport ] && . /etc/sysconfig/autoport
|
||||
|
||||
RPMS_CTIME_OLD="+3"
|
||||
BUILD_CTIME_OLD="+3"
|
||||
SOURCES_CTIME_OLD="+7"
|
||||
SOURCES_ARCHIVES_CTIME_OLD="+7"
|
||||
SOURCES_PATCH_CTIME_OLD="+365"
|
||||
SRPMS_CTIME_OLD="+3"
|
||||
TMP_CTIME_OLD="+2"
|
||||
|
||||
function clean() {
|
||||
dir=$1
|
||||
[ "$VERBOSE" ] && echo "Cleaning from base directory $dir..."
|
||||
[ -e $dir/ ] && find $dir/ -mindepth 1 -maxdepth 1 -name "pipe\:\[*" -exec rm -f {} \;
|
||||
[ -e $dir/RPM/SPECS/ ] && find $dir/RPM/SPECS/ -mindepth 1 -maxdepth 1 -type f -not -name "*.spec*" -exec rm -f {} \;
|
||||
for arch in ${AUTODIST_ARCHS[*]}; do
|
||||
[ -e $dir/RPM/RPMS/$arch/ ] && find $dir/RPM/RPMS/$arch/ -mindepth 1 -maxdepth 1 -type f -mtime ${RPMS_CTIME_OLD} -exec rm -f {} \;
|
||||
done
|
||||
[ -e $dir/RPM/RPMS/noarch/ ] && find $dir/RPM/RPMS/noarch/ -mindepth 1 -maxdepth 1 -type f -mtime ${RPMS_CTIME_OLD} -exec rm -f {} \;
|
||||
if [ -e $dir/RPM/BUILD/ ]; then
|
||||
find $dir/RPM/BUILD/ -mindepth 1 -maxdepth 1 -type d -ctime ${BUILD_CTIME_OLD} -exec rm -rf {} \;
|
||||
# delete older package duplicates
|
||||
find $dir/RPM/BUILD/ -maxdepth 1 | sort -V | \
|
||||
while read curr; do
|
||||
if [ "${curr/-[0-9._]*}" = "${last/-[0-9._]*}" -a "${last}" ]; then
|
||||
rm -rf $last
|
||||
fi
|
||||
last=$curr;
|
||||
done
|
||||
fi
|
||||
[ -e $dir/RPM/SOURCES/ ] && {
|
||||
find $dir/RPM/SOURCES/ -mindepth 1 -maxdepth 1 -type f -ctime ${SOURCES_CTIME_OLD} -a ! -name "*.patch" -exec rm -rf {} \;
|
||||
find $dir/RPM/SOURCES/ -mindepth 1 -maxdepth 1 -type f -ctime ${SOURCES_ARCHIVES_CTIME_OLD} -a -name "*.tar.xz" -exec rm -rf {} \;
|
||||
find $dir/RPM/SOURCES/ -mindepth 1 -maxdepth 1 -type f -ctime ${SOURCES_ARCHIVES_CTIME_OLD} -a -name "*.tar.bz2" -exec rm -rf {} \;
|
||||
find $dir/RPM/SOURCES/ -mindepth 1 -maxdepth 1 -type f -ctime ${SOURCES_ARCHIVES_CTIME_OLD} -a -name "*.tar.gz" -exec rm -rf {} \;
|
||||
find $dir/RPM/SOURCES/ -mindepth 1 -maxdepth 1 -type f -ctime ${SOURCES_PATCH_CTIME_OLD} -a -name "*.patch" -exec rm -rf {} \;
|
||||
}
|
||||
[ -e $dir/RPM/SRPMS/ ] && find $dir/RPM/SRPMS/ -mindepth 1 -maxdepth 1 -type f -mtime ${SRPMS_CTIME_OLD} -exec rm -f {} \;
|
||||
}
|
||||
|
||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
a=${AUTOPORT_CHROOT[$i]}
|
||||
clean /var/autoport/$a/usr/src
|
||||
[ -e /var/autoport/$a/var/autodist/RPM/RPMS/ ] && \
|
||||
clean /var/autoport/$a/var/autodist
|
||||
[ -e /var/autoport/$a/var/tmp/autodist ] && \
|
||||
find /var/autoport/$a/var/tmp/autodist/ -mindepth 1 -maxdepth 1 -type f -ctime ${TMP_CTIME_OLD} -exec rm -rf {} \;
|
||||
find /var/autoport/$a/tmp/ -mindepth 1 -maxdepth 1 -type f -ctime ${TMP_CTIME_OLD} -exec rm -rf {} \;
|
||||
autoport-chroot $a ccache -C
|
||||
elif [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
clean /var/autodist
|
||||
find /var/autodist-tmp/ -mindepth 1 -maxdepth 1 -ctime ${TMP_CTIME_OLD} -exec rm -rf {} \;
|
||||
sudo -u autodist ccache -C
|
||||
elif [ "${AUTOPORT_NATIVE[$i]}" -a "${AUTOPORT_CHROOT_USER[$i]}" ]; then
|
||||
WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$i]} | cut -d: -f6`
|
||||
if [ -e $WORKINGHOME ]; then
|
||||
clean $WORKINGHOME
|
||||
fi
|
||||
find /var/autodist-tmp/ -mindepth 1 -maxdepth 1 -ctime ${TMP_CTIME_OLD} -exec rm -rf {} \;
|
||||
fi
|
||||
done
|
20
etc/cron.daily/40-autodist-upstream-updates
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist-upstream-updates daily cron script
|
||||
# (c) 2008-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/autodist/config
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
if [ ! "$AUTOPORT_UPDATE_NO_DISTROMATIC" ]; then
|
||||
REPOSITORY=devel
|
||||
/usr/sbin/autodist-upstream-updates -q -h -u -r $REPOSITORY > $LOCAL_REPS_BASE_DIR/distromatic/$REPOSITORY/_popular.html
|
||||
|
||||
REPOSITORY=milestone1-1.1
|
||||
/usr/sbin/autodist-upstream-updates -q -h -u -r $REPOSITORY > $LOCAL_REPS_BASE_DIR/distromatic/$REPOSITORY/_popular.html
|
||||
|
||||
REPOSITORY=milestone2
|
||||
/usr/sbin/autodist-upstream-updates -q -h -u -r $REPOSITORY > $LOCAL_REPS_BASE_DIR/distromatic/$REPOSITORY/_popular.html
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
find /var/autodist/RPM/RPMS/i586/ -maxdepth 1 -ctime +25 -exec rm -rf {} \;
|
||||
find /var/autodist/RPM/RPMS/noarch/ -maxdepth 1 -ctime +25 -exec rm -rf {} \;
|
||||
find /var/autodist/RPM/BUILD/ -maxdepth 1 -ctime +25 -exec rm -rf {} \;
|
||||
find /var/autodist/RPM/SOURCES/ -maxdepth 1 -ctime +120 -exec rm -rf {} \;
|
||||
find /var/autodist/RPM/SRPMS/ -maxdepth 1 -ctime +90 -exec rm -rf {} \;
|
||||
find /var/tmp/autodist/ -maxdepth 1 -ctime +25 -exec rm -rf {} \;
|
17
etc/cron.hourly/60-autodist-update
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist autoupdate hourly cron script
|
||||
# (c) 2008-2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/autodist/config
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
# FIXME: parametrize automaint call
|
||||
if [ ! "$AUTOPORT_UPDATE_NO_AUTOMAINT" ]; then
|
||||
automaint -s devel-autodist -d base -p devel-makedist
|
||||
fi
|
||||
|
||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
echo "Running autodist-launcher ${i}"
|
||||
systemd-run -u autodist-launcher-${i} /usr/bin/autodist-launcher ${i}
|
||||
done
|
14
etc/cron.hourly/65-autoport
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# openmamba-autobuild-autoport daily cron script
|
||||
# (c) 2008-2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
#. /etc/sysconfig/openmamba-central
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0
|
||||
|
||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
echo "Running autoport-launcher ${i}"
|
||||
systemd-run -u autoport-launcher-${i} /usr/bin/autoport-launcher ${i}
|
||||
done
|
@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# openmamba-autobuild-autoport daily cron script
|
||||
# (c) 2008-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
#. /etc/sysconfig/openmamba-central
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
[ "$AUTOPORT_ENABLE" = "1" -o "$AUTOPORT_ENABLE" = "true" ] || exit 0
|
||||
|
||||
ME=`basename $0`
|
||||
[ "$$" == "`pidof -x $ME`" ] || {
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Warning: $ME script already running; exiting."
|
||||
exit 0
|
||||
}
|
||||
|
||||
PIDFILE=/var/run/autodist/autodist.pid
|
||||
HOUR=`date +%H`
|
||||
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
|
||||
|
||||
function pid_check() {
|
||||
|
||||
[ -e $PIDFILE ] && PIDCHECK=`cat $PIDFILE`
|
||||
|
||||
[ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && {
|
||||
echo "Error: an autodist process is already running; exiting for safety."
|
||||
exit 0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pid_check
|
||||
|
||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||
[ "${AUTOPORT_ARCH[$i]}" ] || continue
|
||||
[ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
|
||||
|
||||
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then
|
||||
CMD_PREFIX=linux32
|
||||
else
|
||||
CMD_PREFIX=
|
||||
fi
|
||||
|
||||
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
LOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-chroot-${AUTOPORT_CHROOT[$i]}-last.log"
|
||||
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
LOGFILE="/var/autodist/log/autoport-native-${AUTOPORT_ARCH[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-native-${AUTOPORT_ARCH[$i]}-last.log"
|
||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
LOGFILE="/var/autodist/log/autoport-cross-${AUTOPORT_CROSS[$i]}.log"
|
||||
LASTLOGFILE="/var/autodist/log/autoport-cross-${AUTOPORT_CROSS[$i]}-last.log"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
[ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE
|
||||
|
||||
# for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
echo "Autoport start at `date`" > $LOGFILE
|
||||
echo "========================" >> $LOGFILE
|
||||
# done
|
||||
|
||||
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||
a=${AUTOPORT_CHROOT[$i]}
|
||||
# sudo mount -o bind /proc /var/autoport/$a/proc
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in $a chroot environment"
|
||||
echo "Updating packages in $a chroot environment..." >> $LOGFILE
|
||||
LANG=C /usr/sbin/chroot /var/autoport/$a smart update --quiet > /dev/null
|
||||
LANG=C /usr/sbin/chroot /var/autoport/$a smart upgrade -y >> $LOGFILE
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
echo "Working on $r($a) in chroot mode..." >> $LOGFILE
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r($a) in chroot mode" >> $LOGFILE
|
||||
# disable service restarts
|
||||
mv /var/autoport/$a/sbin/service /var/autoport/$a/sbin/service.autoport
|
||||
ln -s /bin/true /var/autoport/$a/sbin/service
|
||||
$CMD_PREFIX /usr/sbin/chroot /var/autoport/$a su -l ${AUTOPORT_CHROOT_USER[$i]} -c "autoport -b -r $r" >> $LOGFILE
|
||||
mv /var/autoport/$a/sbin/service.autoport /var/autoport/$a/sbin/service
|
||||
cat /var/autoport/$a/home/${AUTOPORT_CHROOT_USER[$i]}/.autoport/${AUTOPORT_ARCH[$i]}/log >> $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
done
|
||||
#$local_ftp/$r/autoport-$a.log
|
||||
fi
|
||||
|
||||
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||
a=${AUTOPORT_ARCH[$i]}
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Updating packages in $a native environment"
|
||||
echo "Updating packages in $a native environment..." >> $LOGFILE
|
||||
LANG=C smart update > /dev/null
|
||||
LANG=C smart upgrade -y >> $LOGFILE
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
echo "Working on $r($a) in native mode" >> $LOGFILE
|
||||
su -l autodist -c "autoport -b -r $r" >> $LOGFILE
|
||||
cat /var/autodist/.autoport/$a/log >> $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||
a=${AUTOPORT_CROSS[$i]}
|
||||
for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
[[ "`/usr/bin/tty`" != "not a tty" ]] && echo "Working on $r($a) in cross-platform mode"
|
||||
echo "Working on $r($a) in cross-platform mode" >> $LOGFILE
|
||||
su -l autodist -c "autoport -b -x $a -r $r" >> $LOGFILE
|
||||
cat /var/autodist/.autoport/$a/log >> $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
# $local_ftp/$r/autoport-$a.log
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Autoport end at `date`" >> $LOGFILE
|
||||
echo "========================" >> $LOGFILE
|
||||
|
||||
# for r in ${AUTOPORT_REPOSITORIES[$i]}; do
|
||||
# [ -e /var/autodist/log/autoport-$r.log ] && \
|
||||
# cp /var/autodist/log/autoport-$r.log /var/autodist/log/autoport-$r-last.log
|
||||
# done
|
||||
|
||||
done
|
8
etc/logrotate.d/webbuild
Normal file
@ -0,0 +1,8 @@
|
||||
/var/webbuild/access_log {
|
||||
monthly
|
||||
rotate 12
|
||||
copytruncate
|
||||
compress
|
||||
notifempty
|
||||
missingok
|
||||
}
|
@ -2,20 +2,43 @@
|
||||
# autoport global configuration
|
||||
#
|
||||
local_ftp=/var/ftp/pub/openmamba/
|
||||
|
||||
#AUTOBUILDS_STATUS_URL="http://www.openmamba.org/distribution/autobuilds.html"
|
||||
#AUTOPORT_ENABLE=1
|
||||
# Disabled by default because they would require local repository
|
||||
AUTOPORT_UPDATE_NO_AUTOMAINT=1
|
||||
AUTOPORT_UPDATE_NO_DISTROMATIC=1
|
||||
#AUTOPORT_CGI_HOST=(http://localhost/cgi-bin/autodist)
|
||||
#AUTOPORT_WEBBUILD_HOST=http://localhost/webbuild.html
|
||||
#ICECREAM_MONITOR_HOST=localhost
|
||||
|
||||
AUTOPORT_DEVEL_IMPORT_REPOSITORIES="devel-makedist base devel-autodist \
|
||||
devel-kernel devel-misc devel-future devel-past"
|
||||
|
||||
AUTOPORT_DEVEL_RELEASE_REPOSITORIES="milestone2-makedist milestone2-kernel milestone2-kernel-next"
|
||||
|
||||
AUTOPORT_MILESTONE2_IMPORT_REPOSITORIES="milestone2-makedist milestone2-updates milestone2-kernel \
|
||||
milestone2-kde4 milestone2-xorg milestone2-kernel-next milestone2"
|
||||
|
||||
#AUTOPORT_ARCH[0]=x86_64
|
||||
#AUTOPORT_DISABLE[0]=
|
||||
#AUTOPORT_CHROOT[0]=devel-x86_64
|
||||
#AUTOPORT_CHROOT_USER[0]=sdk
|
||||
#AUTOPORT_CHROOT_ICECREAM[0]=1
|
||||
#AUTOPORT_CROSS[0]=
|
||||
#AUTOPORT_NATIVE[0]=
|
||||
#AUTOPORT_REPOSITORIES[0]="devel-makedist"
|
||||
#AUTOPORT_BASE_REPOSITORY[0]="devel-makedist"
|
||||
#AUTOPORT_IMPORT_REPOSITORIES[0]="$AUTOPORT_DEVEL_IMPORT_REPOSITORIES"
|
||||
|
||||
#AUTOPORT_ARCH[1]=i586
|
||||
#AUTOPORT_DISABLE[1]=
|
||||
#AUTOPORT_CHROOT[1]=milestone2-i586
|
||||
#AUTOPORT_CHROOT_USER[1]=sdk
|
||||
#AUTOPORT_CHROOT_ICECREAM[1]=1
|
||||
#AUTOPORT_CROSS[1]=
|
||||
#AUTOPORT_NATIVE[1]=
|
||||
#AUTOPORT_BASE_REPOSITORY[0]="devel-autodist"
|
||||
#AUTOPORT_REPOSITORIES[1]="milestone2-makedist"
|
||||
#AUTOPORT_BASE_REPOSITORY[0]="milestone2-makedist"
|
||||
#AUTOPORT_IMPORT_REPOSITORIES[0]="$AUTOPORT_DEVEL_IMPORT_REPOSITORIES"
|
||||
|
70
repology-openmamba.py
Executable file
@ -0,0 +1,70 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# repology-openmamba.py - find upstream packages updates from repology.org
|
||||
# Copyright (c) 2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
|
||||
import json, urllib.request, time, sys
|
||||
|
||||
|
||||
with open("/var/ftp/pub/openmamba/devel/legacy") as f:
|
||||
legacy_packages = f.read().splitlines()
|
||||
|
||||
with open("/var/ftp/pub/openmamba/devel/ignore") as f:
|
||||
data = json.loads(f.read())
|
||||
ignored_packages = data["repology"]
|
||||
|
||||
from_package = ""
|
||||
last_from_package = "NONE"
|
||||
results = []
|
||||
|
||||
while True:
|
||||
if from_package == last_from_package:
|
||||
break
|
||||
requrl = "https://repology.org/api/v1/projects/"
|
||||
if from_package != "":
|
||||
requrl += from_package +"/"
|
||||
requrl += "?inrepo=openmamba&outdated=1"
|
||||
sys.stderr.write("Requesting: " + requrl + "\n")
|
||||
url = urllib.request.urlopen(requrl)
|
||||
#print(requrl)
|
||||
data = json.loads(url.read().decode())
|
||||
|
||||
if from_package != "" and len(data.keys()) <= 1:
|
||||
break
|
||||
for k in data.keys():
|
||||
if k == from_package:
|
||||
continue
|
||||
package = k
|
||||
openmamba_srcname = None
|
||||
openmamba_version = None
|
||||
openmamba_altnames = []
|
||||
newest_version = None
|
||||
newest_repos = []
|
||||
for p in data[k]:
|
||||
if p["repo"] == "openmamba":
|
||||
if not p["srcname"] in ignored_packages and \
|
||||
not p["srcname"] in legacy_packages:
|
||||
if openmamba_srcname is None:
|
||||
openmamba_version = p["version"]
|
||||
openmamba_srcname = p["srcname"]
|
||||
else:
|
||||
openmamba_altnames.append(p["srcname"])
|
||||
elif p["status"] == "newest":
|
||||
# kaos_build provides unreleased kde package versions
|
||||
if p["repo"] != "kaos_build":
|
||||
newest_version = p["version"]
|
||||
newest_repos.append(p["repo"])
|
||||
newest_repos = list(dict.fromkeys(newest_repos))
|
||||
if openmamba_srcname and newest_version is not None and len(newest_repos) > 0:
|
||||
results.append(openmamba_srcname + " " + newest_version)
|
||||
for altname in openmamba_altnames:
|
||||
results.append(altname + " " + newest_version)
|
||||
last_from_package = from_package
|
||||
from_package = package
|
||||
time.sleep(1)
|
||||
|
||||
results_sorted = sorted(set(results), key=str.casefold)
|
||||
#results_unique = set(results_sorted)
|
||||
for result in results_sorted:
|
||||
print(result)
|
205
telegram/openmamba_bot.py
Executable file
@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# openmamba bot for Telegram
|
||||
#
|
||||
# Copyright (C) 2016-2023 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
# GPL v3 license
|
||||
|
||||
from telegram import (ParseMode, Update)
|
||||
|
||||
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, RegexHandler,
|
||||
ConversationHandler, Job, CallbackContext)
|
||||
|
||||
import logging
|
||||
import subprocess
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
# Enable logging
|
||||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
level=logging.INFO)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
timers = dict()
|
||||
social_log_last_ids = dict()
|
||||
|
||||
reps = [ 'base', 'devel-makedist', 'devel-autodist', 'devel-kernel', 'devel-misc', 'devel-future', 'devel-past' ]
|
||||
|
||||
def start(update: Update, context: CallbackContext):
|
||||
|
||||
user = update.message.from_user
|
||||
logger.info("User %s started the conversation." % user.first_name)
|
||||
|
||||
update.message.reply_text(
|
||||
'Hi! This is the openmamba GNU/Linux Bot.\n'
|
||||
'Send any text to search for packages.\n'
|
||||
'Send /details [name] to see details of specified source package.\n'
|
||||
'Send /set [seconds] to enable notifications.\n'
|
||||
'Send /unset to disable notifications.\n\n')
|
||||
|
||||
return
|
||||
|
||||
|
||||
def help(update: Update, context: CallbackContext):
|
||||
|
||||
update.message.reply_text(
|
||||
'Send any text to search for packages.\n'
|
||||
'Send /details [name] to see details of specified source package.\n'
|
||||
'Send /set [seconds] to enable notifications.\n'
|
||||
'Send /unset to disable notifications.\n\n')
|
||||
|
||||
return
|
||||
|
||||
|
||||
def query(update: Update, context: CallbackContext):
|
||||
user = update.message.from_user
|
||||
logger.info("Query of %s: %s" % (user.first_name, update.message.text))
|
||||
|
||||
response = ""
|
||||
for rep in reps:
|
||||
conn = sqlite3.connect('/var/webbuild/db/%s-sources.db' % rep, check_same_thread=False)
|
||||
cursor = conn.cursor()
|
||||
print(rep)
|
||||
cursor.execute(
|
||||
'SELECT id,name,version,release,summary,url FROM sources where name like "%%%s%%" or summary like "%%%s%%" '
|
||||
'ORDER BY name="%s" DESC, name like "%s%%" DESC, name like "%%%s%%" DESC limit 10'
|
||||
% (update.message.text, update.message.text, update.message.text, update.message.text, update.message.text))
|
||||
for row in cursor:
|
||||
response += "<b>%s</b> %s-%s (%s)\n%s\n%s\n\n" % (row[1], row[2], row[3], rep, row[4], row[5])
|
||||
|
||||
if response != "":
|
||||
update.message.reply_text(response, parse_mode=ParseMode.HTML)
|
||||
else:
|
||||
update.message.reply_text('No results found.')
|
||||
return
|
||||
|
||||
|
||||
def details(update: Update, context: CallbackContext):
|
||||
user = update.message.from_user
|
||||
logger.info("Details of %s: %s" % (user.first_name, update.message.text))
|
||||
|
||||
response = ""
|
||||
for rep in reps:
|
||||
conn = sqlite3.connect('/var/webbuild/db/%s-sources.db' % rep, check_same_thread=False)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
'SELECT id,name,version,release,summary,url,description FROM sources where name="%s"' % (context.args[0]))
|
||||
for row in cursor:
|
||||
response += "<b>%s</b> %s-%s (devel)\n%s\n%s\n\n<i>%s</i>\n\n" % (row[1], row[2], row[3], row[4], row[5], row[6])
|
||||
for arch in [ 'x86_64', 'aarch64', 'i586', 'arm' ]:
|
||||
conn1 = sqlite3.connect('/var/webbuild/db/' + rep + '-' + arch + '.db', check_same_thread=False)
|
||||
cursor1 = conn1.cursor()
|
||||
cursor1.execute('SELECT id,name FROM packages where id_source=%s' % (row[0]))
|
||||
for row1 in cursor1:
|
||||
response += "<b>%s</b>(%s) " % (row1[1], arch)
|
||||
response += "\n\n\n"
|
||||
|
||||
if response != "":
|
||||
update.message.reply_text(response[0:4096], parse_mode=ParseMode.HTML)
|
||||
else:
|
||||
update.message.reply_text('No results found.')
|
||||
return
|
||||
|
||||
|
||||
def alarm(context):
|
||||
social_log_conn = sqlite3.connect('/var/webbuild/webbuild.db')
|
||||
social_log_cursor = social_log_conn.cursor()
|
||||
social_log_cursor.execute('SELECT id,user,text,datetime(time,\'localtime\'),type FROM social_log where id>%s' % social_log_last_ids[context.job])
|
||||
response = ""
|
||||
for row in social_log_cursor:
|
||||
if row[4] == "job":
|
||||
response += "Job run by <i>%s</i> %s (%s)\n" % (row[1], row[2], row[3])
|
||||
else:
|
||||
response += "<i>%s</i> %s (%s)\n" % (row[1], row[2], row[3])
|
||||
if response != "":
|
||||
bot.sendMessage(context.job, response, parse_mode=ParseMode.HTML)
|
||||
social_log_last_ids[context.job] = row[0]
|
||||
|
||||
|
||||
def set(update: Update, context: CallbackContext):
|
||||
chat_id = update.message.chat_id
|
||||
try:
|
||||
due = int(context.args[0])
|
||||
if due < 0:
|
||||
update.message.reply_text('Sorry we can not go back to future!')
|
||||
return
|
||||
#job = Job(alarm, context, next_t=due, repeat=True, context=chat_id)
|
||||
#timers[chat_id] = job
|
||||
context.job_queue.run_repeating(alarm, due)
|
||||
#context.jobqueue.put(job)
|
||||
|
||||
social_log_conn = sqlite3.connect('/var/webbuild/webbuild.db')
|
||||
social_log_cursor = social_log_conn.cursor()
|
||||
social_log_cursor.execute('''SELECT MAX(id) FROM social_log''')
|
||||
social_log_last_ids[chat_id] = social_log_cursor.fetchone()[0] - 5
|
||||
|
||||
update.message.reply_text('Notifications enabled!')
|
||||
|
||||
except (IndexError, ValueError):
|
||||
update.message.reply_text('Usage: /set <seconds>')
|
||||
|
||||
|
||||
def unset(update: Update, context: CallbackContext):
|
||||
chat_id = update.message.chat_id
|
||||
|
||||
if chat_id not in timers:
|
||||
update.message.reply_text('Notification were not enabled')
|
||||
return
|
||||
|
||||
job = timers[chat_id]
|
||||
job.schedule_removal()
|
||||
del timers[chat_id]
|
||||
update.message.reply_text('Notifications disabled')
|
||||
|
||||
|
||||
def cancel(update: Update, context: CallbackContext):
|
||||
user = update.message.from_user
|
||||
logger.info("User %s canceled the conversation." % user.first_name)
|
||||
update.message.reply_text('Bye!')
|
||||
|
||||
return ConversationHandler.END
|
||||
|
||||
|
||||
def error(update: Update, context: CallbackContext):
|
||||
logger.warning('Update "%s" caused error "%s"' % (update, context.error))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# Load bot token from external configuration file
|
||||
bot_token = ""
|
||||
with open("/etc/autodist/secrets") as myfile:
|
||||
for line in myfile:
|
||||
name, var = line.rstrip().split("=")
|
||||
if name == "TELEGRAM_BOT_TOKEN":
|
||||
bot_token = var
|
||||
|
||||
# Create the EventHandler and pass it your bot's token.
|
||||
updater = Updater(bot_token)
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dp = updater.dispatcher
|
||||
|
||||
dp.add_handler(CommandHandler('start', start))
|
||||
dp.add_handler(CommandHandler('help', help))
|
||||
dp.add_handler(CommandHandler('details', details, pass_args=True))
|
||||
dp.add_handler(CommandHandler('set', set, pass_args=True, pass_job_queue=True))
|
||||
dp.add_handler(CommandHandler('unset', unset))
|
||||
dp.add_handler(MessageHandler(Filters.text, query))
|
||||
|
||||
# log all errors
|
||||
dp.add_error_handler(error)
|
||||
|
||||
# Start the Bot
|
||||
updater.start_polling()
|
||||
|
||||
# Run the bot until the you presses Ctrl-C or the process receives SIGINT,
|
||||
# SIGTERM or SIGABRT. This should be used most of the time, since
|
||||
# start_polling() is non-blocking and will stop the bot gracefully.
|
||||
updater.idle()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
10
telegram/openmambabot.service
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=openmamba bot for Telegram
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/var/autodist/env/bin/python3 /usr/share/autodist/openmamba_bot.py
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
1
telegram/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
python-telegram-bot~=13.14
|
70
webbuild/html/autobuilds.html
Normal file
@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html><head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type">
|
||||
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/images/webbuild.ico" />
|
||||
<!-- styles needed by jScrollPane -->
|
||||
<link type="text/css" href="/scripts/jquery.jscrollpane.css" rel="stylesheet" media="all" >
|
||||
<!-- latest jQuery direct from google's CDN -->
|
||||
<script type="text/javascript" src="/scripts/jquery.js"></script>
|
||||
<!-- the mousewheel plugin - optional to provide mousewheel support -->
|
||||
<script type="text/javascript" src="/scripts/jquery.mousewheel.js"></script>
|
||||
<!-- the jScrollPane script -->
|
||||
<script type="text/javascript" src="/scripts/jquery.jscrollpane.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/styles/webbuild.css">
|
||||
<script type="text/javascript" src="/scripts/socialbox.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
var lastupdate = 0;
|
||||
var reloadtime = 0;
|
||||
|
||||
function ajax_getvalues() {
|
||||
var url = window.location.protocol+"//"+window.location.hostname+"/cgi-bin/autodist?FORMAT=xml&"+window.location.href.replace(/.*\?/,"");
|
||||
var xmlhttp;
|
||||
if (window.XMLHttpRequest)
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
else
|
||||
return;
|
||||
document.getElementById("noajax_msg").innerHTML = "";
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState != 4)
|
||||
return;
|
||||
var xmldoc = xmlhttp.responseXML.documentElement;
|
||||
document.getElementById("output").innerHTML = xmldoc.getElementsByTagName("output")[0].childNodes[0].nodeValue;
|
||||
reloadtime = xmldoc.getElementsByTagName("reloadtime")[0].childNodes[0].nodeValue;
|
||||
lastupdate = (+new Date());
|
||||
setTimeout("ajax_getvalues()", reloadtime);
|
||||
}
|
||||
xmlhttp.open("GET", url, true);
|
||||
xmlhttp.send(null);
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
</head><body>
|
||||
<div id=container style="position:relative;width:894px;height:auto;top:0;left:0;margin-left:auto;margin-right:auto;">
|
||||
<table width="100%"><tr><td>
|
||||
<tr><td valign="middle">
|
||||
<table align="center"><tr>
|
||||
<td colspan=2><img src="/images/webbuild.png" alt="build automatici">
|
||||
<b>- Autodist - Build automatici</b>
|
||||
</td>
|
||||
</tr></table>
|
||||
</td></tr>
|
||||
<tr><td>
|
||||
<div id="noajax_msg"><p>Il supporto per AJAX non è abilitato nel tuo browser. L'aggiornamento live non sarà disponibile, premi Ricarica per aggiornare la pagina.</p></div>
|
||||
<span id="output">Caricamento in corso, attendere...</span>
|
||||
<script>
|
||||
ajax_getvalues("");
|
||||
$("#output").mousemove(function(event) {
|
||||
lastupdatetime = (+new Date()) - lastupdate; // milliseconds since last update
|
||||
// var msg = "called " + lastupdatetime + "ms ago";
|
||||
if (lastupdatetime > reloadtime) { lastupdate = lastupdatetime; ajax_getvalues(); }
|
||||
});
|
||||
</script>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</body></html>
|
BIN
webbuild/html/images/fail.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
webbuild/html/images/inprogress.gif
Normal file
After Width: | Height: | Size: 537 B |
BIN
webbuild/html/images/ok.png
Normal file
After Width: | Height: | Size: 927 B |
BIN
webbuild/html/images/refresh.png
Normal file
After Width: | Height: | Size: 335 B |
BIN
webbuild/html/images/wait.gif
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
webbuild/html/images/webbuild.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
webbuild/html/images/webbuild.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
2
webbuild/html/scripts/codemirror/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/node_modules
|
||||
/npm-debug.log
|
6
webbuild/html/scripts/codemirror/.travis.yml
Normal file
@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
before_script:
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
23
webbuild/html/scripts/codemirror/LICENSE
Normal file
@ -0,0 +1,23 @@
|
||||
Copyright (C) 2012 by Marijn Haverbeke <marijnh@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Please note that some subdirectories of the CodeMirror distribution
|
||||
include their own LICENSE files, and are released under different
|
||||
licences.
|
29
webbuild/html/scripts/codemirror/keymap/emacs.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// TODO number prefixes
|
||||
(function() {
|
||||
// Really primitive kill-ring implementation.
|
||||
var killRing = [];
|
||||
function addToRing(str) {
|
||||
killRing.push(str);
|
||||
if (killRing.length > 50) killRing.shift();
|
||||
}
|
||||
function getFromRing() { return killRing[killRing.length - 1] || ""; }
|
||||
function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }
|
||||
|
||||
CodeMirror.keyMap.emacs = {
|
||||
"Ctrl-X": function(cm) {cm.setOption("keyMap", "emacs-Ctrl-X");},
|
||||
"Ctrl-W": function(cm) {addToRing(cm.getSelection()); cm.replaceSelection("");},
|
||||
"Ctrl-Alt-W": function(cm) {addToRing(cm.getSelection()); cm.replaceSelection("");},
|
||||
"Alt-W": function(cm) {addToRing(cm.getSelection());},
|
||||
"Ctrl-Y": function(cm) {cm.replaceSelection(getFromRing());},
|
||||
"Alt-Y": function(cm) {cm.replaceSelection(popFromRing());},
|
||||
"Ctrl-/": "undo", "Shift-Ctrl--": "undo", "Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
|
||||
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": "clearSearch", "Shift-Alt-5": "replace",
|
||||
"Ctrl-Z": "undo", "Cmd-Z": "undo", "Alt-/": "autocomplete",
|
||||
fallthrough: ["basic", "emacsy"]
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["emacs-Ctrl-X"] = {
|
||||
"Ctrl-S": "save", "Ctrl-W": "save", "S": "saveAll", "F": "open", "U": "undo", "K": "close",
|
||||
auto: "emacs", nofallthrough: true
|
||||
};
|
||||
})();
|
786
webbuild/html/scripts/codemirror/keymap/vim.js
vendored
Normal file
@ -0,0 +1,786 @@
|
||||
// Supported keybindings:
|
||||
//
|
||||
// Cursor movement:
|
||||
// h, j, k, l
|
||||
// e, E, w, W, b, B
|
||||
// Ctrl-f, Ctrl-b
|
||||
// Ctrl-n, Ctrl-p
|
||||
// $, ^, 0
|
||||
// G
|
||||
// ge, gE
|
||||
// gg
|
||||
// f<char>, F<char>, t<char>, T<char>
|
||||
// Ctrl-o, Ctrl-i TODO (FIXME - Ctrl-O wont work in Chrome)
|
||||
// /, ?, n, N TODO (does not work)
|
||||
// #, * TODO
|
||||
//
|
||||
// Entering insert mode:
|
||||
// i, I, a, A, o, O
|
||||
// s
|
||||
// ce, cb (without support for number of actions like c3e - TODO)
|
||||
// cc
|
||||
// S, C TODO
|
||||
// cf<char>, cF<char>, ct<char>, cT<char>
|
||||
//
|
||||
// Deleting text:
|
||||
// x, X
|
||||
// J
|
||||
// dd, D
|
||||
// de, db (without support for number of actions like d3e - TODO)
|
||||
// df<char>, dF<char>, dt<char>, dT<char>
|
||||
//
|
||||
// Yanking and pasting:
|
||||
// yy, Y
|
||||
// p, P
|
||||
// p'<char> TODO - test
|
||||
// y'<char> TODO - test
|
||||
// m<char> TODO - test
|
||||
//
|
||||
// Changing text in place:
|
||||
// ~
|
||||
// r<char>
|
||||
//
|
||||
// Visual mode:
|
||||
// v, V TODO
|
||||
//
|
||||
// Misc:
|
||||
// . TODO
|
||||
//
|
||||
|
||||
(function() {
|
||||
var count = "";
|
||||
var sdir = "f";
|
||||
var buf = "";
|
||||
var yank = 0;
|
||||
var mark = [];
|
||||
var reptTimes = 0;
|
||||
function emptyBuffer() { buf = ""; }
|
||||
function pushInBuffer(str) { buf += str; }
|
||||
function pushCountDigit(digit) { return function(cm) {count += digit;}; }
|
||||
function popCount() { var i = parseInt(count, 10); count = ""; return i || 1; }
|
||||
function iterTimes(func) {
|
||||
for (var i = 0, c = popCount(); i < c; ++i) func(i, i == c - 1);
|
||||
}
|
||||
function countTimes(func) {
|
||||
if (typeof func == "string") func = CodeMirror.commands[func];
|
||||
return function(cm) { iterTimes(function () { func(cm); }); };
|
||||
}
|
||||
|
||||
function iterObj(o, f) {
|
||||
for (var prop in o) if (o.hasOwnProperty(prop)) f(prop, o[prop]);
|
||||
}
|
||||
function iterList(l, f) {
|
||||
for (var i = 0; i < l.length; ++i) f(l[i]);
|
||||
}
|
||||
function toLetter(ch) {
|
||||
// T -> t, Shift-T -> T, '*' -> *, "Space" -> " "
|
||||
if (ch.slice(0, 6) == "Shift-") {
|
||||
return ch.slice(0, 1);
|
||||
} else {
|
||||
if (ch == "Space") return " ";
|
||||
if (ch.length == 3 && ch[0] == "'" && ch[2] == "'") return ch[1];
|
||||
return ch.toLowerCase();
|
||||
}
|
||||
}
|
||||
var SPECIAL_SYMBOLS = "~`!@#$%^&*()_-+=[{}]\\|/?.,<>:;\"\'1234567890";
|
||||
function toCombo(ch) {
|
||||
// t -> T, T -> Shift-T, * -> '*', " " -> "Space"
|
||||
if (ch == " ") return "Space";
|
||||
var specialIdx = SPECIAL_SYMBOLS.indexOf(ch);
|
||||
if (specialIdx != -1) return "'" + ch + "'";
|
||||
if (ch.toLowerCase() == ch) return ch.toUpperCase();
|
||||
return "Shift-" + ch.toUpperCase();
|
||||
}
|
||||
|
||||
var word = [/\w/, /[^\w\s]/], bigWord = [/\S/];
|
||||
function findWord(line, pos, dir, regexps) {
|
||||
var stop = 0, next = -1;
|
||||
if (dir > 0) { stop = line.length; next = 0; }
|
||||
var start = stop, end = stop;
|
||||
// Find bounds of next one.
|
||||
outer: for (; pos != stop; pos += dir) {
|
||||
for (var i = 0; i < regexps.length; ++i) {
|
||||
if (regexps[i].test(line.charAt(pos + next))) {
|
||||
start = pos;
|
||||
for (; pos != stop; pos += dir) {
|
||||
if (!regexps[i].test(line.charAt(pos + next))) break;
|
||||
}
|
||||
end = pos;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {from: Math.min(start, end), to: Math.max(start, end)};
|
||||
}
|
||||
function moveToWord(cm, regexps, dir, times, where) {
|
||||
var cur = cm.getCursor();
|
||||
|
||||
for (var i = 0; i < times; i++) {
|
||||
var line = cm.getLine(cur.line), startCh = cur.ch, word;
|
||||
while (true) {
|
||||
// If we're at start/end of line, start on prev/next respectivly
|
||||
if (cur.ch == line.length && dir > 0) {
|
||||
cur.line++;
|
||||
cur.ch = 0;
|
||||
line = cm.getLine(cur.line);
|
||||
} else if (cur.ch == 0 && dir < 0) {
|
||||
cur.line--;
|
||||
cur.ch = line.length;
|
||||
line = cm.getLine(cur.line);
|
||||
}
|
||||
if (!line) break;
|
||||
|
||||
// On to the actual searching
|
||||
word = findWord(line, cur.ch, dir, regexps);
|
||||
cur.ch = word[where == "end" ? "to" : "from"];
|
||||
if (startCh == cur.ch && word.from != word.to) cur.ch = word[dir < 0 ? "from" : "to"];
|
||||
else break;
|
||||
}
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
function joinLineNext(cm) {
|
||||
var cur = cm.getCursor(), ch = cur.ch, line = cm.getLine(cur.line);
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
if (cur.line != cm.lineCount()) {
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
cm.replaceSelection(" ", "end");
|
||||
CodeMirror.commands.delCharRight(cm);
|
||||
}
|
||||
}
|
||||
function delTillMark(cm, cHar) {
|
||||
var i = mark[cHar];
|
||||
if (i === undefined) {
|
||||
// console.log("Mark not set"); // TODO - show in status bar
|
||||
return;
|
||||
}
|
||||
var l = cm.getCursor().line, start = i > l ? l : i, end = i > l ? i : l;
|
||||
cm.setCursor(start);
|
||||
for (var c = start; c <= end; c++) {
|
||||
pushInBuffer("\n"+cm.getLine(start));
|
||||
cm.removeLine(start);
|
||||
}
|
||||
}
|
||||
function yankTillMark(cm, cHar) {
|
||||
var i = mark[cHar];
|
||||
if (i === undefined) {
|
||||
// console.log("Mark not set"); // TODO - show in status bar
|
||||
return;
|
||||
}
|
||||
var l = cm.getCursor().line, start = i > l ? l : i, end = i > l ? i : l;
|
||||
for (var c = start; c <= end; c++) {
|
||||
pushInBuffer("\n"+cm.getLine(c));
|
||||
}
|
||||
cm.setCursor(start);
|
||||
}
|
||||
function goLineStartText(cm) {
|
||||
// Go to the start of the line where the text begins, or the end for whitespace-only lines
|
||||
var cur = cm.getCursor(), firstNonWS = cm.getLine(cur.line).search(/\S/);
|
||||
cm.setCursor(cur.line, firstNonWS == -1 ? line.length : firstNonWS, true);
|
||||
}
|
||||
|
||||
function charIdxInLine(cm, cHar, motion_options) {
|
||||
// Search for cHar in line.
|
||||
// motion_options: {forward, inclusive}
|
||||
// If inclusive = true, include it too.
|
||||
// If forward = true, search forward, else search backwards.
|
||||
// If char is not found on this line, do nothing
|
||||
var cur = cm.getCursor(), line = cm.getLine(cur.line), idx;
|
||||
var ch = toLetter(cHar), mo = motion_options;
|
||||
if (mo.forward) {
|
||||
idx = line.indexOf(ch, cur.ch + 1);
|
||||
if (idx != -1 && mo.inclusive) idx += 1;
|
||||
} else {
|
||||
idx = line.lastIndexOf(ch, cur.ch);
|
||||
if (idx != -1 && !mo.inclusive) idx += 1;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
function moveTillChar(cm, cHar, motion_options) {
|
||||
// Move to cHar in line, as found by charIdxInLine.
|
||||
var idx = charIdxInLine(cm, cHar, motion_options), cur = cm.getCursor();
|
||||
if (idx != -1) cm.setCursor({line: cur.line, ch: idx});
|
||||
}
|
||||
|
||||
function delTillChar(cm, cHar, motion_options) {
|
||||
// delete text in this line, untill cHar is met,
|
||||
// as found by charIdxInLine.
|
||||
// If char is not found on this line, do nothing
|
||||
var idx = charIdxInLine(cm, cHar, motion_options);
|
||||
var cur = cm.getCursor();
|
||||
if (idx !== -1) {
|
||||
if (motion_options.forward) {
|
||||
cm.replaceRange("", {line: cur.line, ch: cur.ch}, {line: cur.line, ch: idx});
|
||||
} else {
|
||||
cm.replaceRange("", {line: cur.line, ch: idx}, {line: cur.line, ch: cur.ch});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enterInsertMode(cm) {
|
||||
// enter insert mode: switch mode and cursor
|
||||
popCount();
|
||||
cm.setOption("keyMap", "vim-insert");
|
||||
}
|
||||
|
||||
function dialog(cm, text, shortText, f) {
|
||||
if (cm.openDialog) cm.openDialog(text, f);
|
||||
else f(prompt(shortText, ""));
|
||||
}
|
||||
function showAlert(cm, text) {
|
||||
var esc = text.replace(/[<&]/, function(ch) { return ch == "<" ? "<" : "&"; });
|
||||
if (cm.openDialog) cm.openDialog(esc + " <button type=button>OK</button>");
|
||||
else alert(text);
|
||||
}
|
||||
|
||||
// main keymap
|
||||
var map = CodeMirror.keyMap.vim = {
|
||||
// Pipe (|); TODO: should be *screen* chars, so need a util function to turn tabs into spaces?
|
||||
"'|'": function(cm) {
|
||||
cm.setCursor(cm.getCursor().line, popCount() - 1, true);
|
||||
},
|
||||
"A": function(cm) {
|
||||
cm.setCursor(cm.getCursor().line, cm.getCursor().ch+1, true);
|
||||
enterInsertMode(cm);
|
||||
},
|
||||
"Shift-A": function(cm) { CodeMirror.commands.goLineEnd(cm); enterInsertMode(cm);},
|
||||
"I": function(cm) { enterInsertMode(cm);},
|
||||
"Shift-I": function(cm) { goLineStartText(cm); enterInsertMode(cm);},
|
||||
"O": function(cm) {
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
CodeMirror.commands.newlineAndIndent(cm);
|
||||
enterInsertMode(cm);
|
||||
},
|
||||
"Shift-O": function(cm) {
|
||||
CodeMirror.commands.goLineStart(cm);
|
||||
cm.replaceSelection("\n", "start");
|
||||
cm.indentLine(cm.getCursor().line);
|
||||
enterInsertMode(cm);
|
||||
},
|
||||
"G": function(cm) { cm.setOption("keyMap", "vim-prefix-g");},
|
||||
"Shift-D": function(cm) {
|
||||
// commented out verions works, but I left original, cause maybe
|
||||
// I don't know vim enouth to see what it does
|
||||
/* var cur = cm.getCursor();
|
||||
var f = {line: cur.line, ch: cur.ch}, t = {line: cur.line};
|
||||
pushInBuffer(cm.getRange(f, t));
|
||||
*/
|
||||
emptyBuffer();
|
||||
mark["Shift-D"] = cm.getCursor(false).line;
|
||||
cm.setCursor(cm.getCursor(true).line);
|
||||
delTillMark(cm,"Shift-D"); mark = [];
|
||||
},
|
||||
|
||||
"S": function (cm) {
|
||||
countTimes(function (_cm) {
|
||||
CodeMirror.commands.delCharRight(_cm);
|
||||
})(cm);
|
||||
enterInsertMode(cm);
|
||||
},
|
||||
"M": function(cm) {cm.setOption("keyMap", "vim-prefix-m"); mark = [];},
|
||||
"Y": function(cm) {cm.setOption("keyMap", "vim-prefix-y"); emptyBuffer(); yank = 0;},
|
||||
"Shift-Y": function(cm) {
|
||||
emptyBuffer();
|
||||
mark["Shift-D"] = cm.getCursor(false).line;
|
||||
cm.setCursor(cm.getCursor(true).line);
|
||||
yankTillMark(cm,"Shift-D"); mark = [];
|
||||
},
|
||||
"/": function(cm) {var f = CodeMirror.commands.find; f && f(cm); sdir = "f";},
|
||||
"'?'": function(cm) {
|
||||
var f = CodeMirror.commands.find;
|
||||
if (f) { f(cm); CodeMirror.commands.findPrev(cm); sdir = "r"; }
|
||||
},
|
||||
"N": function(cm) {
|
||||
var fn = CodeMirror.commands.findNext;
|
||||
if (fn) sdir != "r" ? fn(cm) : CodeMirror.commands.findPrev(cm);
|
||||
},
|
||||
"Shift-N": function(cm) {
|
||||
var fn = CodeMirror.commands.findNext;
|
||||
if (fn) sdir != "r" ? CodeMirror.commands.findPrev(cm) : fn.findNext(cm);
|
||||
},
|
||||
"Shift-G": function(cm) {
|
||||
count == "" ? cm.setCursor(cm.lineCount()) : cm.setCursor(parseInt(count, 10)-1);
|
||||
popCount();
|
||||
CodeMirror.commands.goLineStart(cm);
|
||||
},
|
||||
"':'": function(cm) {
|
||||
var exModeDialog = ': <input type="text" style="width: 90%"/>';
|
||||
dialog(cm, exModeDialog, ':', function(command) {
|
||||
if (command.match(/^\d+$/)) {
|
||||
cm.setCursor(command - 1, cm.getCursor().ch);
|
||||
} else {
|
||||
showAlert(cm, "Bad command: " + command);
|
||||
}
|
||||
});
|
||||
},
|
||||
nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
|
||||
// standard mode switching
|
||||
iterList(["d", "t", "T", "f", "F", "c", "r"],
|
||||
function (ch) {
|
||||
CodeMirror.keyMap.vim[toCombo(ch)] = function (cm) {
|
||||
cm.setOption("keyMap", "vim-prefix-" + ch);
|
||||
emptyBuffer();
|
||||
};
|
||||
});
|
||||
|
||||
function addCountBindings(keyMap) {
|
||||
// Add bindings for number keys
|
||||
keyMap["0"] = function(cm) {
|
||||
count.length > 0 ? pushCountDigit("0")(cm) : CodeMirror.commands.goLineStart(cm);
|
||||
};
|
||||
for (var i = 1; i < 10; ++i) keyMap[i] = pushCountDigit(i);
|
||||
}
|
||||
addCountBindings(CodeMirror.keyMap.vim);
|
||||
|
||||
// main num keymap
|
||||
// Add bindings that are influenced by number keys
|
||||
iterObj({
|
||||
"Left": "goColumnLeft", "Right": "goColumnRight",
|
||||
"Down": "goLineDown", "Up": "goLineUp", "Backspace": "goCharLeft",
|
||||
"Space": "goCharRight",
|
||||
"X": function(cm) {CodeMirror.commands.delCharRight(cm);},
|
||||
"P": function(cm) {
|
||||
var cur = cm.getCursor().line;
|
||||
if (buf!= "") {
|
||||
if (buf[0] == "\n") CodeMirror.commands.goLineEnd(cm);
|
||||
cm.replaceRange(buf, cm.getCursor());
|
||||
}
|
||||
},
|
||||
"Shift-X": function(cm) {CodeMirror.commands.delCharLeft(cm);},
|
||||
"Shift-J": function(cm) {joinLineNext(cm);},
|
||||
"Shift-P": function(cm) {
|
||||
var cur = cm.getCursor().line;
|
||||
if (buf!= "") {
|
||||
CodeMirror.commands.goLineUp(cm);
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
cm.replaceSelection(buf, "end");
|
||||
}
|
||||
cm.setCursor(cur+1);
|
||||
},
|
||||
"'~'": function(cm) {
|
||||
var cur = cm.getCursor(), cHar = cm.getRange({line: cur.line, ch: cur.ch}, {line: cur.line, ch: cur.ch+1});
|
||||
cHar = cHar != cHar.toLowerCase() ? cHar.toLowerCase() : cHar.toUpperCase();
|
||||
cm.replaceRange(cHar, {line: cur.line, ch: cur.ch}, {line: cur.line, ch: cur.ch+1});
|
||||
cm.setCursor(cur.line, cur.ch+1);
|
||||
},
|
||||
"Ctrl-B": function(cm) {CodeMirror.commands.goPageUp(cm);},
|
||||
"Ctrl-F": function(cm) {CodeMirror.commands.goPageDown(cm);},
|
||||
"Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
|
||||
"U": "undo", "Ctrl-R": "redo"
|
||||
}, function(key, cmd) { map[key] = countTimes(cmd); });
|
||||
|
||||
// empty key maps
|
||||
iterList([
|
||||
"vim-prefix-d'",
|
||||
"vim-prefix-y'",
|
||||
"vim-prefix-df",
|
||||
"vim-prefix-dF",
|
||||
"vim-prefix-dt",
|
||||
"vim-prefix-dT",
|
||||
"vim-prefix-c",
|
||||
"vim-prefix-cf",
|
||||
"vim-prefix-cF",
|
||||
"vim-prefix-ct",
|
||||
"vim-prefix-cT",
|
||||
"vim-prefix-",
|
||||
"vim-prefix-f",
|
||||
"vim-prefix-F",
|
||||
"vim-prefix-t",
|
||||
"vim-prefix-T",
|
||||
"vim-prefix-r",
|
||||
"vim-prefix-m"
|
||||
],
|
||||
function (prefix) {
|
||||
CodeMirror.keyMap[prefix] = {
|
||||
auto: "vim",
|
||||
nofallthrough: true,
|
||||
style: "fat-cursor"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-g"] = {
|
||||
"E": countTimes(function(cm) { cm.setCursor(moveToWord(cm, word, -1, 1, "start"));}),
|
||||
"Shift-E": countTimes(function(cm) { cm.setCursor(moveToWord(cm, bigWord, -1, 1, "start"));}),
|
||||
"G": function (cm) { cm.setCursor({line: 0, ch: cm.getCursor().ch});},
|
||||
auto: "vim", nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-d"] = {
|
||||
"D": countTimes(function(cm) {
|
||||
pushInBuffer("\n"+cm.getLine(cm.getCursor().line));
|
||||
cm.removeLine(cm.getCursor().line);
|
||||
cm.setOption("keyMap", "vim");
|
||||
}),
|
||||
"'": function(cm) {
|
||||
cm.setOption("keyMap", "vim-prefix-d'");
|
||||
emptyBuffer();
|
||||
},
|
||||
"B": function(cm) {
|
||||
var cur = cm.getCursor();
|
||||
var line = cm.getLine(cur.line);
|
||||
var index = line.lastIndexOf(" ", cur.ch);
|
||||
|
||||
pushInBuffer(line.substring(index, cur.ch));
|
||||
cm.replaceRange("", {line: cur.line, ch: index}, cur);
|
||||
cm.setOption("keyMap", "vim");
|
||||
},
|
||||
nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
// FIXME - does not work for bindings like "d3e"
|
||||
addCountBindings(CodeMirror.keyMap["vim-prefix-d"]);
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-c"] = {
|
||||
"B": function (cm) {
|
||||
countTimes("delWordLeft")(cm);
|
||||
enterInsertMode(cm);
|
||||
},
|
||||
"C": function (cm) {
|
||||
iterTimes(function (i, last) {
|
||||
CodeMirror.commands.deleteLine(cm);
|
||||
if (i) {
|
||||
CodeMirror.commands.delCharRight(cm);
|
||||
if (last) CodeMirror.commands.deleteLine(cm);
|
||||
}
|
||||
});
|
||||
enterInsertMode(cm);
|
||||
},
|
||||
nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
|
||||
iterList(["vim-prefix-d", "vim-prefix-c", "vim-prefix-"], function (prefix) {
|
||||
iterList(["f", "F", "T", "t"],
|
||||
function (ch) {
|
||||
CodeMirror.keyMap[prefix][toCombo(ch)] = function (cm) {
|
||||
cm.setOption("keyMap", prefix + ch);
|
||||
emptyBuffer();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
var MOTION_OPTIONS = {
|
||||
"t": {inclusive: false, forward: true},
|
||||
"f": {inclusive: true, forward: true},
|
||||
"T": {inclusive: false, forward: false},
|
||||
"F": {inclusive: true, forward: false}
|
||||
};
|
||||
|
||||
function setupPrefixBindingForKey(m) {
|
||||
CodeMirror.keyMap["vim-prefix-m"][m] = function(cm) {
|
||||
mark[m] = cm.getCursor().line;
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-d'"][m] = function(cm) {
|
||||
delTillMark(cm,m);
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-y'"][m] = function(cm) {
|
||||
yankTillMark(cm,m);
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-r"][m] = function (cm) {
|
||||
var cur = cm.getCursor();
|
||||
cm.replaceRange(toLetter(m),
|
||||
{line: cur.line, ch: cur.ch},
|
||||
{line: cur.line, ch: cur.ch + 1});
|
||||
CodeMirror.commands.goColumnLeft(cm);
|
||||
};
|
||||
// all commands, related to motions till char in line
|
||||
iterObj(MOTION_OPTIONS, function (ch, options) {
|
||||
CodeMirror.keyMap["vim-prefix-" + ch][m] = function(cm) {
|
||||
moveTillChar(cm, m, options);
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-d" + ch][m] = function(cm) {
|
||||
delTillChar(cm, m, options);
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-c" + ch][m] = function(cm) {
|
||||
delTillChar(cm, m, options);
|
||||
enterInsertMode(cm);
|
||||
};
|
||||
});
|
||||
}
|
||||
for (var i = 65; i < 65 + 26; i++) { // uppercase alphabet char codes
|
||||
var ch = String.fromCharCode(i);
|
||||
setupPrefixBindingForKey(toCombo(ch));
|
||||
setupPrefixBindingForKey(toCombo(ch.toLowerCase()));
|
||||
}
|
||||
for (var i = 0; i < SPECIAL_SYMBOLS.length; ++i) {
|
||||
setupPrefixBindingForKey(toCombo(SPECIAL_SYMBOLS.charAt(i)));
|
||||
}
|
||||
setupPrefixBindingForKey("Space");
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-y"] = {
|
||||
"Y": countTimes(function(cm) { pushInBuffer("\n"+cm.getLine(cm.getCursor().line+yank)); yank++; }),
|
||||
"'": function(cm) {cm.setOption("keyMap", "vim-prefix-y'"); emptyBuffer();},
|
||||
nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-insert"] = {
|
||||
// TODO: override navigation keys so that Esc will cancel automatic indentation from o, O, i_<CR>
|
||||
"Esc": function(cm) {
|
||||
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1, true);
|
||||
cm.setOption("keyMap", "vim");
|
||||
},
|
||||
"Ctrl-N": "autocomplete",
|
||||
"Ctrl-P": "autocomplete",
|
||||
fallthrough: ["default"]
|
||||
};
|
||||
|
||||
function findMatchedSymbol(cm, cur, symb) {
|
||||
var line = cur.line;
|
||||
var symb = symb ? symb : cm.getLine(line)[cur.ch];
|
||||
|
||||
// Are we at the opening or closing char
|
||||
var forwards = ['(', '[', '{'].indexOf(symb) != -1;
|
||||
|
||||
var reverseSymb = (function(sym) {
|
||||
switch (sym) {
|
||||
case '(' : return ')';
|
||||
case '[' : return ']';
|
||||
case '{' : return '}';
|
||||
case ')' : return '(';
|
||||
case ']' : return '[';
|
||||
case '}' : return '{';
|
||||
default : return null;
|
||||
}
|
||||
})(symb);
|
||||
|
||||
// Couldn't find a matching symbol, abort
|
||||
if (reverseSymb == null) return cur;
|
||||
|
||||
// Tracking our imbalance in open/closing symbols. An opening symbol wii be
|
||||
// the first thing we pick up if moving forward, this isn't true moving backwards
|
||||
var disBal = forwards ? 0 : 1;
|
||||
|
||||
while (true) {
|
||||
if (line == cur.line) {
|
||||
// First pass, do some special stuff
|
||||
var currLine = forwards ? cm.getLine(line).substr(cur.ch).split('') : cm.getLine(line).substr(0,cur.ch).split('').reverse();
|
||||
} else {
|
||||
var currLine = forwards ? cm.getLine(line).split('') : cm.getLine(line).split('').reverse();
|
||||
}
|
||||
|
||||
for (var index = 0; index < currLine.length; index++) {
|
||||
if (currLine[index] == symb) disBal++;
|
||||
else if (currLine[index] == reverseSymb) disBal--;
|
||||
|
||||
if (disBal == 0) {
|
||||
if (forwards && cur.line == line) return {line: line, ch: index + cur.ch};
|
||||
else if (forwards) return {line: line, ch: index};
|
||||
else return {line: line, ch: currLine.length - index - 1 };
|
||||
}
|
||||
}
|
||||
|
||||
if (forwards) line++;
|
||||
else line--;
|
||||
}
|
||||
}
|
||||
|
||||
function selectCompanionObject(cm, revSymb, inclusive) {
|
||||
var cur = cm.getCursor();
|
||||
|
||||
var end = findMatchedSymbol(cm, cur, revSymb);
|
||||
var start = findMatchedSymbol(cm, end);
|
||||
start.ch += inclusive ? 1 : 0;
|
||||
end.ch += inclusive ? 0 : 1;
|
||||
|
||||
return {start: start, end: end};
|
||||
}
|
||||
|
||||
// These are our motion commands to be used for navigation and selection with
|
||||
// certian other commands. All should return a cursor object.
|
||||
var motionList = ['B', 'E', 'J', 'K', 'H', 'L', 'W', 'Shift-W', "'^'", "'$'", "'%'", 'Esc'];
|
||||
|
||||
motions = {
|
||||
'B': function(cm, times) { return moveToWord(cm, word, -1, times); },
|
||||
'Shift-B': function(cm, times) { return moveToWord(cm, bigWord, -1, times); },
|
||||
'E': function(cm, times) { return moveToWord(cm, word, 1, times, 'end'); },
|
||||
'Shift-E': function(cm, times) { return moveToWord(cm, bigWord, 1, times, 'end'); },
|
||||
'J': function(cm, times) {
|
||||
var cur = cm.getCursor();
|
||||
return {line: cur.line+times, ch : cur.ch};
|
||||
},
|
||||
|
||||
'K': function(cm, times) {
|
||||
var cur = cm.getCursor();
|
||||
return {line: cur.line-times, ch: cur.ch};
|
||||
},
|
||||
|
||||
'H': function(cm, times) {
|
||||
var cur = cm.getCursor();
|
||||
return {line: cur.line, ch: cur.ch-times};
|
||||
},
|
||||
|
||||
'L': function(cm, times) {
|
||||
var cur = cm.getCursor();
|
||||
return {line: cur.line, ch: cur.ch+times};
|
||||
},
|
||||
'W': function(cm, times) { return moveToWord(cm, word, 1, times); },
|
||||
'Shift-W': function(cm, times) { return moveToWord(cm, bigWord, 1, times); },
|
||||
"'^'": function(cm, times) {
|
||||
var cur = cm.getCursor();
|
||||
var line = cm.getLine(cur.line).split('');
|
||||
|
||||
// Empty line :o
|
||||
if (line.length == 0) return cur;
|
||||
|
||||
for (var index = 0; index < line.length; index++) {
|
||||
if (line[index].match(/[^\s]/)) return {line: cur.line, ch: index};
|
||||
}
|
||||
},
|
||||
"'$'": function(cm) {
|
||||
var cur = cm.getCursor();
|
||||
var line = cm.getLine(cur.line);
|
||||
return {line: cur.line, ch: line.length};
|
||||
},
|
||||
"'%'": function(cm) { return findMatchedSymbol(cm, cm.getCursor()); },
|
||||
"Esc" : function(cm) {
|
||||
cm.setOption('vim');
|
||||
reptTimes = 0;
|
||||
|
||||
return cm.getCursor();
|
||||
}
|
||||
};
|
||||
|
||||
// Map our movement actions each operator and non-operational movement
|
||||
motionList.forEach(function(key, index, array) {
|
||||
CodeMirror.keyMap['vim-prefix-d'][key] = function(cm) {
|
||||
// Get our selected range
|
||||
var start = cm.getCursor();
|
||||
var end = motions[key](cm, reptTimes ? reptTimes : 1);
|
||||
|
||||
// Set swap var if range is of negative length
|
||||
if ((start.line > end.line) || (start.line == end.line && start.ch > end.ch)) var swap = true;
|
||||
|
||||
// Take action, switching start and end if swap var is set
|
||||
pushInBuffer(cm.getRange(swap ? end : start, swap ? start : end));
|
||||
cm.replaceRange("", swap ? end : start, swap ? start : end);
|
||||
|
||||
// And clean up
|
||||
reptTimes = 0;
|
||||
cm.setOption("keyMap", "vim");
|
||||
};
|
||||
|
||||
CodeMirror.keyMap['vim-prefix-c'][key] = function(cm) {
|
||||
var start = cm.getCursor();
|
||||
var end = motions[key](cm, reptTimes ? reptTimes : 1);
|
||||
|
||||
if ((start.line > end.line) || (start.line == end.line && start.ch > end.ch)) var swap = true;
|
||||
pushInBuffer(cm.getRange(swap ? end : start, swap ? start : end));
|
||||
cm.replaceRange("", swap ? end : start, swap ? start : end);
|
||||
|
||||
reptTimes = 0;
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
};
|
||||
|
||||
CodeMirror.keyMap['vim-prefix-y'][key] = function(cm) {
|
||||
var start = cm.getCursor();
|
||||
var end = motions[key](cm, reptTimes ? reptTimes : 1);
|
||||
|
||||
if ((start.line > end.line) || (start.line == end.line && start.ch > end.ch)) var swap = true;
|
||||
pushInBuffer(cm.getRange(swap ? end : start, swap ? start : end));
|
||||
|
||||
reptTimes = 0;
|
||||
cm.setOption("keyMap", "vim");
|
||||
};
|
||||
|
||||
CodeMirror.keyMap['vim'][key] = function(cm) {
|
||||
var cur = motions[key](cm, reptTimes ? reptTimes : 1);
|
||||
cm.setCursor(cur.line, cur.ch);
|
||||
|
||||
reptTimes = 0;
|
||||
};
|
||||
});
|
||||
|
||||
var nums = [1,2,3,4,5,6,7,8,9];
|
||||
nums.forEach(function(key, index, array) {
|
||||
CodeMirror.keyMap['vim'][key] = function (cm) {
|
||||
reptTimes = (reptTimes * 10) + key;
|
||||
};
|
||||
CodeMirror.keyMap['vim-prefix-d'][key] = function (cm) {
|
||||
reptTimes = (reptTimes * 10) + key;
|
||||
};
|
||||
CodeMirror.keyMap['vim-prefix-y'][key] = function (cm) {
|
||||
reptTimes = (reptTimes * 10) + key;
|
||||
};
|
||||
CodeMirror.keyMap['vim-prefix-c'][key] = function (cm) {
|
||||
reptTimes = (reptTimes * 10) + key;
|
||||
};
|
||||
});
|
||||
|
||||
// Create our keymaps for each operator and make xa and xi where x is an operator
|
||||
// change to the corrosponding keymap
|
||||
var operators = ['d', 'y', 'c'];
|
||||
operators.forEach(function(key, index, array) {
|
||||
CodeMirror.keyMap['vim-prefix-'+key+'a'] = {
|
||||
auto: 'vim', nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
CodeMirror.keyMap['vim-prefix-'+key+'i'] = {
|
||||
auto: 'vim', nofallthrough: true, style: "fat-cursor"
|
||||
};
|
||||
|
||||
CodeMirror.keyMap['vim-prefix-'+key]['A'] = function(cm) {
|
||||
reptTimes = 0;
|
||||
cm.setOption('keyMap', 'vim-prefix-' + key + 'a');
|
||||
};
|
||||
|
||||
CodeMirror.keyMap['vim-prefix-'+key]['I'] = function(cm) {
|
||||
reptTimes = 0;
|
||||
cm.setOption('keyMap', 'vim-prefix-' + key + 'i');
|
||||
};
|
||||
});
|
||||
|
||||
function regexLastIndexOf(string, pattern, startIndex) {
|
||||
for (var i = startIndex == null ? string.length : startIndex; i >= 0; --i)
|
||||
if (pattern.test(string.charAt(i))) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create our text object functions. They work similar to motions but they
|
||||
// return a start cursor as well
|
||||
var textObjectList = ['W', 'Shift-[', 'Shift-9', '['];
|
||||
var textObjects = {
|
||||
'W': function(cm, inclusive) {
|
||||
var cur = cm.getCursor();
|
||||
var line = cm.getLine(cur.line);
|
||||
|
||||
var line_to_char = new String(line.substring(0, cur.ch));
|
||||
var start = regexLastIndexOf(line_to_char, /[^a-zA-Z0-9]/) + 1;
|
||||
var end = motions["E"](cm, 1) ;
|
||||
|
||||
end.ch += inclusive ? 1 : 0 ;
|
||||
return {start: {line: cur.line, ch: start}, end: end };
|
||||
},
|
||||
'Shift-[': function(cm, inclusive) { return selectCompanionObject(cm, '}', inclusive); },
|
||||
'Shift-9': function(cm, inclusive) { return selectCompanionObject(cm, ')', inclusive); },
|
||||
'[': function(cm, inclusive) { return selectCompanionObject(cm, ']', inclusive); }
|
||||
};
|
||||
|
||||
// One function to handle all operation upon text objects. Kinda funky but it works
|
||||
// better than rewriting this code six times
|
||||
function textObjectManipulation(cm, object, remove, insert, inclusive) {
|
||||
// Object is the text object, delete object if remove is true, enter insert
|
||||
// mode if insert is true, inclusive is the difference between a and i
|
||||
var tmp = textObjects[object](cm, inclusive);
|
||||
var start = tmp.start;
|
||||
var end = tmp.end;
|
||||
|
||||
if ((start.line > end.line) || (start.line == end.line && start.ch > end.ch)) var swap = true ;
|
||||
|
||||
pushInBuffer(cm.getRange(swap ? end : start, swap ? start : end));
|
||||
if (remove) cm.replaceRange("", swap ? end : start, swap ? start : end);
|
||||
if (insert) cm.setOption('keyMap', 'vim-insert');
|
||||
}
|
||||
|
||||
// And finally build the keymaps up from the text objects
|
||||
for (var i = 0; i < textObjectList.length; ++i) {
|
||||
var object = textObjectList[i];
|
||||
(function(object) {
|
||||
CodeMirror.keyMap['vim-prefix-di'][object] = function(cm) { textObjectManipulation(cm, object, true, false, false); };
|
||||
CodeMirror.keyMap['vim-prefix-da'][object] = function(cm) { textObjectManipulation(cm, object, true, false, true); };
|
||||
CodeMirror.keyMap['vim-prefix-yi'][object] = function(cm) { textObjectManipulation(cm, object, false, false, false); };
|
||||
CodeMirror.keyMap['vim-prefix-ya'][object] = function(cm) { textObjectManipulation(cm, object, false, false, true); };
|
||||
CodeMirror.keyMap['vim-prefix-ci'][object] = function(cm) { textObjectManipulation(cm, object, true, true, false); };
|
||||
CodeMirror.keyMap['vim-prefix-ca'][object] = function(cm) { textObjectManipulation(cm, object, true, true, true); };
|
||||
})(object)
|
||||
}
|
||||
})();
|
173
webbuild/html/scripts/codemirror/lib/codemirror.css
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
.CodeMirror {
|
||||
line-height: 1em;
|
||||
font-family: monospace;
|
||||
|
||||
/* Necessary so the scrollbar can be absolutely positioned within the wrapper on Lion. */
|
||||
position: relative;
|
||||
/* This prevents unwanted scrollbars from showing up on the body and wrapper in IE. */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
overflow: auto;
|
||||
height: 300px;
|
||||
/* This is needed to prevent an IE[67] bug where the scrolled content
|
||||
is visible outside of the scrolling box. */
|
||||
position: relative;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Vertical scrollbar */
|
||||
.CodeMirror-scrollbar {
|
||||
position: absolute;
|
||||
right: 0; top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
z-index: 0;
|
||||
}
|
||||
.CodeMirror-scrollbar-inner {
|
||||
/* This needs to have a nonzero width in order for the scrollbar to appear
|
||||
in Firefox and IE9. */
|
||||
width: 1px;
|
||||
}
|
||||
.CodeMirror-scrollbar.cm-sb-overlap {
|
||||
/* Ensure that the scrollbar appears in Lion, and that it overlaps the content
|
||||
rather than sitting to the right of it. */
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
float: none;
|
||||
right: 0;
|
||||
min-width: 12px;
|
||||
}
|
||||
.CodeMirror-scrollbar.cm-sb-nonoverlap {
|
||||
min-width: 12px;
|
||||
}
|
||||
.CodeMirror-scrollbar.cm-sb-ie7 {
|
||||
min-width: 18px;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter {
|
||||
position: absolute; left: 0; top: 0;
|
||||
z-index: 10;
|
||||
background-color: #f7f7f7;
|
||||
border-right: 1px solid #eee;
|
||||
min-width: 2em;
|
||||
height: 100%;
|
||||
}
|
||||
.CodeMirror-gutter-text {
|
||||
color: #aaa;
|
||||
text-align: right;
|
||||
padding: .4em .2em .4em .4em;
|
||||
white-space: pre !important;
|
||||
cursor: default;
|
||||
}
|
||||
.CodeMirror-lines {
|
||||
padding: .4em;
|
||||
white-space: pre;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.CodeMirror pre {
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
-o-border-radius: 0;
|
||||
border-radius: 0;
|
||||
border-width: 0; margin: 0; padding: 0; background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
padding: 0; margin: 0;
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror textarea {
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.CodeMirror pre.CodeMirror-cursor {
|
||||
z-index: 10;
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-left: 1px solid black;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
.cm-keymap-fat-cursor pre.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
background: rgba(0, 200, 0, .4);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
|
||||
}
|
||||
/* Kludge to turn off filter in ie9+, which also accepts rgba */
|
||||
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
|
||||
.CodeMirror-focused pre.CodeMirror-cursor {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
div.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
|
||||
|
||||
.CodeMirror-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* Default theme */
|
||||
|
||||
.cm-s-default span.cm-keyword {color: #708;}
|
||||
.cm-s-default span.cm-atom {color: #219;}
|
||||
.cm-s-default span.cm-number {color: #164;}
|
||||
.cm-s-default span.cm-def {color: #00f;}
|
||||
.cm-s-default span.cm-variable {color: black;}
|
||||
.cm-s-default span.cm-variable-2 {color: #05a;}
|
||||
.cm-s-default span.cm-variable-3 {color: #085;}
|
||||
.cm-s-default span.cm-property {color: black;}
|
||||
.cm-s-default span.cm-operator {color: black;}
|
||||
.cm-s-default span.cm-comment {color: #a50;}
|
||||
.cm-s-default span.cm-string {color: #a11;}
|
||||
.cm-s-default span.cm-string-2 {color: #f50;}
|
||||
.cm-s-default span.cm-meta {color: #555;}
|
||||
.cm-s-default span.cm-error {color: #f00;}
|
||||
.cm-s-default span.cm-qualifier {color: #555;}
|
||||
.cm-s-default span.cm-builtin {color: #30a;}
|
||||
.cm-s-default span.cm-bracket {color: #cc7;}
|
||||
.cm-s-default span.cm-tag {color: #170;}
|
||||
.cm-s-default span.cm-attribute {color: #00c;}
|
||||
.cm-s-default span.cm-header {color: blue;}
|
||||
.cm-s-default span.cm-quote {color: #090;}
|
||||
.cm-s-default span.cm-hr {color: #999;}
|
||||
.cm-s-default span.cm-link {color: #00c;}
|
||||
|
||||
span.cm-header, span.cm-strong {font-weight: bold;}
|
||||
span.cm-em {font-style: italic;}
|
||||
span.cm-emstrong {font-style: italic; font-weight: bold;}
|
||||
span.cm-link {text-decoration: underline;}
|
||||
|
||||
span.cm-invalidchar {color: #f00;}
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
|
||||
@media print {
|
||||
|
||||
/* Hide the cursor when printing */
|
||||
.CodeMirror pre.CodeMirror-cursor {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
}
|
3237
webbuild/html/scripts/codemirror/lib/codemirror.js
vendored
Normal file
164
webbuild/html/scripts/codemirror/lib/util/closetag.js
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* Tag-closer extension for CodeMirror.
|
||||
*
|
||||
* This extension adds a "closeTag" utility function that can be used with key bindings to
|
||||
* insert a matching end tag after the ">" character of a start tag has been typed. It can
|
||||
* also complete "</" if a matching start tag is found. It will correctly ignore signal
|
||||
* characters for empty tags, comments, CDATA, etc.
|
||||
*
|
||||
* The function depends on internal parser state to identify tags. It is compatible with the
|
||||
* following CodeMirror modes and will ignore all others:
|
||||
* - htmlmixed
|
||||
* - xml
|
||||
*
|
||||
* See demos/closetag.html for a usage example.
|
||||
*
|
||||
* @author Nathan Williams <nathan@nlwillia.net>
|
||||
* Contributed under the same license terms as CodeMirror.
|
||||
*/
|
||||
(function() {
|
||||
/** Option that allows tag closing behavior to be toggled. Default is true. */
|
||||
CodeMirror.defaults['closeTagEnabled'] = true;
|
||||
|
||||
/** Array of tag names to add indentation after the start tag for. Default is the list of block-level html tags. */
|
||||
CodeMirror.defaults['closeTagIndent'] = ['applet', 'blockquote', 'body', 'button', 'div', 'dl', 'fieldset', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'html', 'iframe', 'layer', 'legend', 'object', 'ol', 'p', 'select', 'table', 'ul'];
|
||||
|
||||
/** Array of tag names where an end tag is forbidden. */
|
||||
CodeMirror.defaults['closeTagVoid'] = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
||||
|
||||
/**
|
||||
* Call during key processing to close tags. Handles the key event if the tag is closed, otherwise throws CodeMirror.Pass.
|
||||
* - cm: The editor instance.
|
||||
* - ch: The character being processed.
|
||||
* - indent: Optional. An array of tag names to indent when closing. Omit or pass true to use the default indentation tag list defined in the 'closeTagIndent' option.
|
||||
* Pass false to disable indentation. Pass an array to override the default list of tag names.
|
||||
* - vd: Optional. An array of tag names that should not be closed. Omit to use the default void (end tag forbidden) tag list defined in the 'closeTagVoid' option. Ignored in xml mode.
|
||||
*/
|
||||
CodeMirror.defineExtension("closeTag", function(cm, ch, indent, vd) {
|
||||
if (!cm.getOption('closeTagEnabled')) {
|
||||
throw CodeMirror.Pass;
|
||||
}
|
||||
|
||||
var mode = cm.getOption('mode');
|
||||
|
||||
if (mode == 'text/html' || mode == 'xml') {
|
||||
|
||||
/*
|
||||
* Relevant structure of token:
|
||||
*
|
||||
* htmlmixed
|
||||
* className
|
||||
* state
|
||||
* htmlState
|
||||
* type
|
||||
* tagName
|
||||
* context
|
||||
* tagName
|
||||
* mode
|
||||
*
|
||||
* xml
|
||||
* className
|
||||
* state
|
||||
* tagName
|
||||
* type
|
||||
*/
|
||||
|
||||
var pos = cm.getCursor();
|
||||
var tok = cm.getTokenAt(pos);
|
||||
var state = tok.state;
|
||||
|
||||
if (state.mode && state.mode != 'html') {
|
||||
throw CodeMirror.Pass; // With htmlmixed, we only care about the html sub-mode.
|
||||
}
|
||||
|
||||
if (ch == '>') {
|
||||
var type = state.htmlState ? state.htmlState.type : state.type; // htmlmixed : xml
|
||||
|
||||
if (tok.className == 'tag' && type == 'closeTag') {
|
||||
throw CodeMirror.Pass; // Don't process the '>' at the end of an end-tag.
|
||||
}
|
||||
|
||||
cm.replaceSelection('>'); // Mode state won't update until we finish the tag.
|
||||
pos = {line: pos.line, ch: pos.ch + 1};
|
||||
cm.setCursor(pos);
|
||||
|
||||
tok = cm.getTokenAt(cm.getCursor());
|
||||
state = tok.state;
|
||||
type = state.htmlState ? state.htmlState.type : state.type; // htmlmixed : xml
|
||||
|
||||
if (tok.className == 'tag' && type != 'selfcloseTag') {
|
||||
var tagName = state.htmlState ? state.htmlState.tagName : state.tagName; // htmlmixed : xml
|
||||
if (tagName.length > 0 && shouldClose(cm, vd, tagName)) {
|
||||
insertEndTag(cm, indent, pos, tagName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Undo the '>' insert and allow cm to handle the key instead.
|
||||
cm.setSelection({line: pos.line, ch: pos.ch - 1}, pos);
|
||||
cm.replaceSelection("");
|
||||
|
||||
} else if (ch == '/') {
|
||||
if (tok.className == 'tag' && tok.string == '<') {
|
||||
var tagName = state.htmlState ? (state.htmlState.context ? state.htmlState.context.tagName : '') : (state.context ? state.context.tagName : ''); // htmlmixed : xml
|
||||
if (tagName.length > 0) {
|
||||
completeEndTag(cm, pos, tagName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
throw CodeMirror.Pass; // Bubble if not handled
|
||||
});
|
||||
|
||||
function insertEndTag(cm, indent, pos, tagName) {
|
||||
if (shouldIndent(cm, indent, tagName)) {
|
||||
cm.replaceSelection('\n\n</' + tagName + '>', 'end');
|
||||
cm.indentLine(pos.line + 1);
|
||||
cm.indentLine(pos.line + 2);
|
||||
cm.setCursor({line: pos.line + 1, ch: cm.getLine(pos.line + 1).length});
|
||||
} else {
|
||||
cm.replaceSelection('</' + tagName + '>');
|
||||
cm.setCursor(pos);
|
||||
}
|
||||
}
|
||||
|
||||
function shouldIndent(cm, indent, tagName) {
|
||||
if (typeof indent == 'undefined' || indent == null || indent == true) {
|
||||
indent = cm.getOption('closeTagIndent');
|
||||
}
|
||||
if (!indent) {
|
||||
indent = [];
|
||||
}
|
||||
return indexOf(indent, tagName.toLowerCase()) != -1;
|
||||
}
|
||||
|
||||
function shouldClose(cm, vd, tagName) {
|
||||
if (cm.getOption('mode') == 'xml') {
|
||||
return true; // always close xml tags
|
||||
}
|
||||
if (typeof vd == 'undefined' || vd == null) {
|
||||
vd = cm.getOption('closeTagVoid');
|
||||
}
|
||||
if (!vd) {
|
||||
vd = [];
|
||||
}
|
||||
return indexOf(vd, tagName.toLowerCase()) == -1;
|
||||
}
|
||||
|
||||
// C&P from codemirror.js...would be nice if this were visible to utilities.
|
||||
function indexOf(collection, elt) {
|
||||
if (collection.indexOf) return collection.indexOf(elt);
|
||||
for (var i = 0, e = collection.length; i < e; ++i)
|
||||
if (collection[i] == elt) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
function completeEndTag(cm, pos, tagName) {
|
||||
cm.replaceSelection('/' + tagName + '>');
|
||||
cm.setCursor({line: pos.line, ch: pos.ch + tagName.length + 2 });
|
||||
}
|
||||
|
||||
})();
|
27
webbuild/html/scripts/codemirror/lib/util/dialog.css
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
.CodeMirror-dialog {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.CodeMirror-dialog > div {
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0;
|
||||
background: white;
|
||||
border-bottom: 1px solid #eee;
|
||||
z-index: 15;
|
||||
padding: .1em .8em;
|
||||
overflow: hidden;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.CodeMirror-dialog input {
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
width: 20em;
|
||||
color: inherit;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.CodeMirror-dialog button {
|
||||
font-size: 70%;
|
||||
}
|
70
webbuild/html/scripts/codemirror/lib/util/dialog.js
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// Open simple dialogs on top of an editor. Relies on dialog.css.
|
||||
|
||||
(function() {
|
||||
function dialogDiv(cm, template) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
var dialog = wrap.insertBefore(document.createElement("div"), wrap.firstChild);
|
||||
dialog.className = "CodeMirror-dialog";
|
||||
dialog.innerHTML = '<div>' + template + '</div>';
|
||||
return dialog;
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("openDialog", function(template, callback) {
|
||||
var dialog = dialogDiv(this, template);
|
||||
var closed = false, me = this;
|
||||
function close() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
}
|
||||
var inp = dialog.getElementsByTagName("input")[0], button;
|
||||
if (inp) {
|
||||
CodeMirror.connect(inp, "keydown", function(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 27) {
|
||||
CodeMirror.e_stop(e);
|
||||
close();
|
||||
me.focus();
|
||||
if (e.keyCode == 13) callback(inp.value);
|
||||
}
|
||||
});
|
||||
inp.focus();
|
||||
CodeMirror.connect(inp, "blur", close);
|
||||
} else if (button = dialog.getElementsByTagName("button")[0]) {
|
||||
CodeMirror.connect(button, "click", function() {
|
||||
close();
|
||||
me.focus();
|
||||
});
|
||||
button.focus();
|
||||
CodeMirror.connect(button, "blur", close);
|
||||
}
|
||||
return close;
|
||||
});
|
||||
|
||||
CodeMirror.defineExtension("openConfirm", function(template, callbacks) {
|
||||
var dialog = dialogDiv(this, template);
|
||||
var buttons = dialog.getElementsByTagName("button");
|
||||
var closed = false, me = this, blurring = 1;
|
||||
function close() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
me.focus();
|
||||
}
|
||||
buttons[0].focus();
|
||||
for (var i = 0; i < buttons.length; ++i) {
|
||||
var b = buttons[i];
|
||||
(function(callback) {
|
||||
CodeMirror.connect(b, "click", function(e) {
|
||||
CodeMirror.e_preventDefault(e);
|
||||
close();
|
||||
if (callback) callback(me);
|
||||
});
|
||||
})(callbacks[i]);
|
||||
CodeMirror.connect(b, "blur", function() {
|
||||
--blurring;
|
||||
setTimeout(function() { if (blurring <= 0) close(); }, 200);
|
||||
});
|
||||
CodeMirror.connect(b, "focus", function() { ++blurring; });
|
||||
}
|
||||
});
|
||||
})();
|
196
webbuild/html/scripts/codemirror/lib/util/foldcode.js
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
// the tagRangeFinder function is
|
||||
// Copyright (C) 2011 by Daniel Glazman <daniel@glazman.org>
|
||||
// released under the MIT license (../../LICENSE) like the rest of CodeMirror
|
||||
CodeMirror.tagRangeFinder = function(cm, line, hideEnd) {
|
||||
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
||||
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
||||
var xmlNAMERegExp = new RegExp("^[" + nameStartChar + "][" + nameChar + "]*");
|
||||
|
||||
var lineText = cm.getLine(line);
|
||||
var found = false;
|
||||
var tag = null;
|
||||
var pos = 0;
|
||||
while (!found) {
|
||||
pos = lineText.indexOf("<", pos);
|
||||
if (-1 == pos) // no tag on line
|
||||
return;
|
||||
if (pos + 1 < lineText.length && lineText[pos + 1] == "/") { // closing tag
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
// ok we weem to have a start tag
|
||||
if (!lineText.substr(pos + 1).match(xmlNAMERegExp)) { // not a tag name...
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
var gtPos = lineText.indexOf(">", pos + 1);
|
||||
if (-1 == gtPos) { // end of start tag not in line
|
||||
var l = line + 1;
|
||||
var foundGt = false;
|
||||
var lastLine = cm.lineCount();
|
||||
while (l < lastLine && !foundGt) {
|
||||
var lt = cm.getLine(l);
|
||||
var gt = lt.indexOf(">");
|
||||
if (-1 != gt) { // found a >
|
||||
foundGt = true;
|
||||
var slash = lt.lastIndexOf("/", gt);
|
||||
if (-1 != slash && slash < gt) {
|
||||
var str = lineText.substr(slash, gt - slash + 1);
|
||||
if (!str.match( /\/\s*\>/ )) { // yep, that's the end of empty tag
|
||||
if (hideEnd === true) l++;
|
||||
return l;
|
||||
}
|
||||
}
|
||||
}
|
||||
l++;
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
else {
|
||||
var slashPos = lineText.lastIndexOf("/", gtPos);
|
||||
if (-1 == slashPos) { // cannot be empty tag
|
||||
found = true;
|
||||
// don't continue
|
||||
}
|
||||
else { // empty tag?
|
||||
// check if really empty tag
|
||||
var str = lineText.substr(slashPos, gtPos - slashPos + 1);
|
||||
if (!str.match( /\/\s*\>/ )) { // finally not empty
|
||||
found = true;
|
||||
// don't continue
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
var subLine = lineText.substr(pos + 1);
|
||||
tag = subLine.match(xmlNAMERegExp);
|
||||
if (tag) {
|
||||
// we have an element name, wooohooo !
|
||||
tag = tag[0];
|
||||
// do we have the close tag on same line ???
|
||||
if (-1 != lineText.indexOf("</" + tag + ">", pos)) // yep
|
||||
{
|
||||
found = false;
|
||||
}
|
||||
// we don't, so we have a candidate...
|
||||
}
|
||||
else
|
||||
found = false;
|
||||
}
|
||||
if (!found)
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
var startTag = "(\\<\\/" + tag + "\\>)|(\\<" + tag + "\\>)|(\\<" + tag + "\\s)|(\\<" + tag + "$)";
|
||||
var startTagRegExp = new RegExp(startTag, "g");
|
||||
var endTag = "</" + tag + ">";
|
||||
var depth = 1;
|
||||
var l = line + 1;
|
||||
var lastLine = cm.lineCount();
|
||||
while (l < lastLine) {
|
||||
lineText = cm.getLine(l);
|
||||
var match = lineText.match(startTagRegExp);
|
||||
if (match) {
|
||||
for (var i = 0; i < match.length; i++) {
|
||||
if (match[i] == endTag)
|
||||
depth--;
|
||||
else
|
||||
depth++;
|
||||
if (!depth) {
|
||||
if (hideEnd === true) l++;
|
||||
return l;
|
||||
}
|
||||
}
|
||||
}
|
||||
l++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.braceRangeFinder = function(cm, line, hideEnd) {
|
||||
var lineText = cm.getLine(line), at = lineText.length, startChar, tokenType;
|
||||
for (;;) {
|
||||
var found = lineText.lastIndexOf("{", at);
|
||||
if (found < 0) break;
|
||||
tokenType = cm.getTokenAt({line: line, ch: found}).className;
|
||||
if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; }
|
||||
at = found - 1;
|
||||
}
|
||||
if (startChar == null || lineText.lastIndexOf("}") > startChar) return;
|
||||
var count = 1, lastLine = cm.lineCount(), end;
|
||||
outer: for (var i = line + 1; i < lastLine; ++i) {
|
||||
var text = cm.getLine(i), pos = 0;
|
||||
for (;;) {
|
||||
var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos);
|
||||
if (nextOpen < 0) nextOpen = text.length;
|
||||
if (nextClose < 0) nextClose = text.length;
|
||||
pos = Math.min(nextOpen, nextClose);
|
||||
if (pos == text.length) break;
|
||||
if (cm.getTokenAt({line: i, ch: pos + 1}).className == tokenType) {
|
||||
if (pos == nextOpen) ++count;
|
||||
else if (!--count) { end = i; break outer; }
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
if (end == null || end == line + 1) return;
|
||||
if (hideEnd === true) end++;
|
||||
return end;
|
||||
};
|
||||
|
||||
CodeMirror.indentRangeFinder = function(cm, line) {
|
||||
var tabSize = cm.getOption("tabSize");
|
||||
var myIndent = cm.getLineHandle(line).indentation(tabSize), last;
|
||||
for (var i = line + 1, end = cm.lineCount(); i < end; ++i) {
|
||||
var handle = cm.getLineHandle(i);
|
||||
if (!/^\s*$/.test(handle.text)) {
|
||||
if (handle.indentation(tabSize) <= myIndent) break;
|
||||
last = i;
|
||||
}
|
||||
}
|
||||
if (!last) return null;
|
||||
return last + 1;
|
||||
};
|
||||
|
||||
CodeMirror.newFoldFunction = function(rangeFinder, markText, hideEnd) {
|
||||
var folded = [];
|
||||
if (markText == null) markText = '<div style="position: absolute; left: 2px; color:#600">▼</div>%N%';
|
||||
|
||||
function isFolded(cm, n) {
|
||||
for (var i = 0; i < folded.length; ++i) {
|
||||
var start = cm.lineInfo(folded[i].start);
|
||||
if (!start) folded.splice(i--, 1);
|
||||
else if (start.line == n) return {pos: i, region: folded[i]};
|
||||
}
|
||||
}
|
||||
|
||||
function expand(cm, region) {
|
||||
cm.clearMarker(region.start);
|
||||
for (var i = 0; i < region.hidden.length; ++i)
|
||||
cm.showLine(region.hidden[i]);
|
||||
}
|
||||
|
||||
return function(cm, line) {
|
||||
cm.operation(function() {
|
||||
var known = isFolded(cm, line);
|
||||
if (known) {
|
||||
folded.splice(known.pos, 1);
|
||||
expand(cm, known.region);
|
||||
} else {
|
||||
var end = rangeFinder(cm, line, hideEnd);
|
||||
if (end == null) return;
|
||||
var hidden = [];
|
||||
for (var i = line + 1; i < end; ++i) {
|
||||
var handle = cm.hideLine(i);
|
||||
if (handle) hidden.push(handle);
|
||||
}
|
||||
var first = cm.setMarker(line, markText);
|
||||
var region = {start: first, hidden: hidden};
|
||||
cm.onDeleteLine(first, function() { expand(cm, region); });
|
||||
folded.push(region);
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
299
webbuild/html/scripts/codemirror/lib/util/formatting.js
vendored
Normal file
@ -0,0 +1,299 @@
|
||||
// ============== Formatting extensions ============================
|
||||
// A common storage for all mode-specific formatting features
|
||||
if (!CodeMirror.modeExtensions) CodeMirror.modeExtensions = {};
|
||||
|
||||
// Returns the extension of the editor's current mode
|
||||
CodeMirror.defineExtension("getModeExt", function () {
|
||||
var mname = CodeMirror.resolveMode(this.getOption("mode")).name;
|
||||
var ext = CodeMirror.modeExtensions[mname];
|
||||
if (!ext) throw new Error("No extensions found for mode " + mname);
|
||||
return ext;
|
||||
});
|
||||
|
||||
// If the current mode is 'htmlmixed', returns the extension of a mode located at
|
||||
// the specified position (can be htmlmixed, css or javascript). Otherwise, simply
|
||||
// returns the extension of the editor's current mode.
|
||||
CodeMirror.defineExtension("getModeExtAtPos", function (pos) {
|
||||
var token = this.getTokenAt(pos);
|
||||
if (token && token.state && token.state.mode)
|
||||
return CodeMirror.modeExtensions[token.state.mode == "html" ? "htmlmixed" : token.state.mode];
|
||||
else
|
||||
return this.getModeExt();
|
||||
});
|
||||
|
||||
// Comment/uncomment the specified range
|
||||
CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
|
||||
var curMode = this.getModeExtAtPos(this.getCursor());
|
||||
if (isComment) { // Comment range
|
||||
var commentedText = this.getRange(from, to);
|
||||
this.replaceRange(curMode.commentStart + this.getRange(from, to) + curMode.commentEnd
|
||||
, from, to);
|
||||
if (from.line == to.line && from.ch == to.ch) { // An empty comment inserted - put cursor inside
|
||||
this.setCursor(from.line, from.ch + curMode.commentStart.length);
|
||||
}
|
||||
}
|
||||
else { // Uncomment range
|
||||
var selText = this.getRange(from, to);
|
||||
var startIndex = selText.indexOf(curMode.commentStart);
|
||||
var endIndex = selText.lastIndexOf(curMode.commentEnd);
|
||||
if (startIndex > -1 && endIndex > -1 && endIndex > startIndex) {
|
||||
// Take string till comment start
|
||||
selText = selText.substr(0, startIndex)
|
||||
// From comment start till comment end
|
||||
+ selText.substring(startIndex + curMode.commentStart.length, endIndex)
|
||||
// From comment end till string end
|
||||
+ selText.substr(endIndex + curMode.commentEnd.length);
|
||||
}
|
||||
this.replaceRange(selText, from, to);
|
||||
}
|
||||
});
|
||||
|
||||
// Applies automatic mode-aware indentation to the specified range
|
||||
CodeMirror.defineExtension("autoIndentRange", function (from, to) {
|
||||
var cmInstance = this;
|
||||
this.operation(function () {
|
||||
for (var i = from.line; i <= to.line; i++) {
|
||||
cmInstance.indentLine(i, "smart");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Applies automatic formatting to the specified range
|
||||
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
|
||||
var absStart = this.indexFromPos(from);
|
||||
var absEnd = this.indexFromPos(to);
|
||||
// Insert additional line breaks where necessary according to the
|
||||
// mode's syntax
|
||||
var res = this.getModeExt().autoFormatLineBreaks(this.getValue(), absStart, absEnd);
|
||||
var cmInstance = this;
|
||||
|
||||
// Replace and auto-indent the range
|
||||
this.operation(function () {
|
||||
cmInstance.replaceRange(res, from, to);
|
||||
var startLine = cmInstance.posFromIndex(absStart).line;
|
||||
var endLine = cmInstance.posFromIndex(absStart + res.length).line;
|
||||
for (var i = startLine; i <= endLine; i++) {
|
||||
cmInstance.indentLine(i, "smart");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Define extensions for a few modes
|
||||
|
||||
CodeMirror.modeExtensions["css"] = {
|
||||
commentStart: "/*",
|
||||
commentEnd: "*/",
|
||||
wordWrapChars: [";", "\\{", "\\}"],
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
text = text.substring(startPos, endPos);
|
||||
return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2");
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["javascript"] = {
|
||||
commentStart: "/*",
|
||||
commentEnd: "*/",
|
||||
wordWrapChars: [";", "\\{", "\\}"],
|
||||
|
||||
getNonBreakableBlocks: function (text) {
|
||||
var nonBreakableRegexes = [
|
||||
new RegExp("for\\s*?\\(([\\s\\S]*?)\\)"),
|
||||
new RegExp("\\\\\"([\\s\\S]*?)(\\\\\"|$)"),
|
||||
new RegExp("\\\\\'([\\s\\S]*?)(\\\\\'|$)"),
|
||||
new RegExp("'([\\s\\S]*?)('|$)"),
|
||||
new RegExp("\"([\\s\\S]*?)(\"|$)"),
|
||||
new RegExp("//.*([\r\n]|$)")
|
||||
];
|
||||
var nonBreakableBlocks = new Array();
|
||||
for (var i = 0; i < nonBreakableRegexes.length; i++) {
|
||||
var curPos = 0;
|
||||
while (curPos < text.length) {
|
||||
var m = text.substr(curPos).match(nonBreakableRegexes[i]);
|
||||
if (m != null) {
|
||||
nonBreakableBlocks.push({
|
||||
start: curPos + m.index,
|
||||
end: curPos + m.index + m[0].length
|
||||
});
|
||||
curPos += m.index + Math.max(1, m[0].length);
|
||||
}
|
||||
else { // No more matches
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nonBreakableBlocks.sort(function (a, b) {
|
||||
return a.start - b.start;
|
||||
});
|
||||
|
||||
return nonBreakableBlocks;
|
||||
},
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
text = text.substring(startPos, endPos);
|
||||
var curPos = 0;
|
||||
var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n;])", "g");
|
||||
var nonBreakableBlocks = this.getNonBreakableBlocks(text);
|
||||
if (nonBreakableBlocks != null) {
|
||||
var res = "";
|
||||
for (var i = 0; i < nonBreakableBlocks.length; i++) {
|
||||
if (nonBreakableBlocks[i].start > curPos) { // Break lines till the block
|
||||
res += text.substring(curPos, nonBreakableBlocks[i].start).replace(reLinesSplitter, "$1\n$2");
|
||||
curPos = nonBreakableBlocks[i].start;
|
||||
}
|
||||
if (nonBreakableBlocks[i].start <= curPos
|
||||
&& nonBreakableBlocks[i].end >= curPos) { // Skip non-breakable block
|
||||
res += text.substring(curPos, nonBreakableBlocks[i].end);
|
||||
curPos = nonBreakableBlocks[i].end;
|
||||
}
|
||||
}
|
||||
if (curPos < text.length - 1) {
|
||||
res += text.substr(curPos).replace(reLinesSplitter, "$1\n$2");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
return text.replace(reLinesSplitter, "$1\n$2");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["xml"] = {
|
||||
commentStart: "<!--",
|
||||
commentEnd: "-->",
|
||||
wordWrapChars: [">"],
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
text = text.substring(startPos, endPos);
|
||||
var lines = text.split("\n");
|
||||
var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)");
|
||||
var reOpenBrackets = new RegExp("<", "g");
|
||||
var reCloseBrackets = new RegExp("(>)([^\r\n])", "g");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var mToProcess = lines[i].match(reProcessedPortion);
|
||||
if (mToProcess != null && mToProcess.length > 3) { // The line starts with whitespaces and ends with whitespaces
|
||||
lines[i] = mToProcess[1]
|
||||
+ mToProcess[2].replace(reOpenBrackets, "\n$&").replace(reCloseBrackets, "$1\n$2")
|
||||
+ mToProcess[3];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["htmlmixed"] = {
|
||||
commentStart: "<!--",
|
||||
commentEnd: "-->",
|
||||
wordWrapChars: [">", ";", "\\{", "\\}"],
|
||||
|
||||
getModeInfos: function (text, absPos) {
|
||||
var modeInfos = new Array();
|
||||
modeInfos[0] =
|
||||
{
|
||||
pos: 0,
|
||||
modeExt: CodeMirror.modeExtensions["xml"],
|
||||
modeName: "xml"
|
||||
};
|
||||
|
||||
var modeMatchers = new Array();
|
||||
modeMatchers[0] =
|
||||
{
|
||||
regex: new RegExp("<style[^>]*>([\\s\\S]*?)(</style[^>]*>|$)", "i"),
|
||||
modeExt: CodeMirror.modeExtensions["css"],
|
||||
modeName: "css"
|
||||
};
|
||||
modeMatchers[1] =
|
||||
{
|
||||
regex: new RegExp("<script[^>]*>([\\s\\S]*?)(</script[^>]*>|$)", "i"),
|
||||
modeExt: CodeMirror.modeExtensions["javascript"],
|
||||
modeName: "javascript"
|
||||
};
|
||||
|
||||
var lastCharPos = (typeof (absPos) !== "undefined" ? absPos : text.length - 1);
|
||||
// Detect modes for the entire text
|
||||
for (var i = 0; i < modeMatchers.length; i++) {
|
||||
var curPos = 0;
|
||||
while (curPos <= lastCharPos) {
|
||||
var m = text.substr(curPos).match(modeMatchers[i].regex);
|
||||
if (m != null) {
|
||||
if (m.length > 1 && m[1].length > 0) {
|
||||
// Push block begin pos
|
||||
var blockBegin = curPos + m.index + m[0].indexOf(m[1]);
|
||||
modeInfos.push(
|
||||
{
|
||||
pos: blockBegin,
|
||||
modeExt: modeMatchers[i].modeExt,
|
||||
modeName: modeMatchers[i].modeName
|
||||
});
|
||||
// Push block end pos
|
||||
modeInfos.push(
|
||||
{
|
||||
pos: blockBegin + m[1].length,
|
||||
modeExt: modeInfos[0].modeExt,
|
||||
modeName: modeInfos[0].modeName
|
||||
});
|
||||
curPos += m.index + m[0].length;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
curPos += m.index + Math.max(m[0].length, 1);
|
||||
}
|
||||
}
|
||||
else { // No more matches
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sort mode infos
|
||||
modeInfos.sort(function sortModeInfo(a, b) {
|
||||
return a.pos - b.pos;
|
||||
});
|
||||
|
||||
return modeInfos;
|
||||
},
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
var modeInfos = this.getModeInfos(text);
|
||||
var reBlockStartsWithNewline = new RegExp("^\\s*?\n");
|
||||
var reBlockEndsWithNewline = new RegExp("\n\\s*?$");
|
||||
var res = "";
|
||||
// Use modes info to break lines correspondingly
|
||||
if (modeInfos.length > 1) { // Deal with multi-mode text
|
||||
for (var i = 1; i <= modeInfos.length; i++) {
|
||||
var selStart = modeInfos[i - 1].pos;
|
||||
var selEnd = (i < modeInfos.length ? modeInfos[i].pos : endPos);
|
||||
|
||||
if (selStart >= endPos) { // The block starts later than the needed fragment
|
||||
break;
|
||||
}
|
||||
if (selStart < startPos) {
|
||||
if (selEnd <= startPos) { // The block starts earlier than the needed fragment
|
||||
continue;
|
||||
}
|
||||
selStart = startPos;
|
||||
}
|
||||
if (selEnd > endPos) {
|
||||
selEnd = endPos;
|
||||
}
|
||||
var textPortion = text.substring(selStart, selEnd);
|
||||
if (modeInfos[i - 1].modeName != "xml") { // Starting a CSS or JavaScript block
|
||||
if (!reBlockStartsWithNewline.test(textPortion)
|
||||
&& selStart > 0) { // The block does not start with a line break
|
||||
textPortion = "\n" + textPortion;
|
||||
}
|
||||
if (!reBlockEndsWithNewline.test(textPortion)
|
||||
&& selEnd < text.length - 1) { // The block does not end with a line break
|
||||
textPortion += "\n";
|
||||
}
|
||||
}
|
||||
res += modeInfos[i - 1].modeExt.autoFormatLineBreaks(textPortion);
|
||||
}
|
||||
}
|
||||
else { // Single-mode text
|
||||
res = modeInfos[0].modeExt.autoFormatLineBreaks(text.substring(startPos, endPos));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
134
webbuild/html/scripts/codemirror/lib/util/javascript-hint.js
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
(function () {
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, keywords, getToken) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
className: token.string == "." ? "property" : null};
|
||||
}
|
||||
// If it is a property, find out what it is a property of.
|
||||
while (tprop.className == "property") {
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
if (tprop.string != ".") return;
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
if (tprop.string == ')') {
|
||||
var level = 1;
|
||||
do {
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
switch (tprop.string) {
|
||||
case ')': level++; break;
|
||||
case '(': level--; break;
|
||||
default: break;
|
||||
}
|
||||
} while (level > 0);
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
if (tprop.className == 'variable')
|
||||
tprop.className = 'function';
|
||||
else return; // no clue
|
||||
}
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
}
|
||||
return {list: getCompletions(token, context, keywords),
|
||||
from: {line: cur.line, ch: token.start},
|
||||
to: {line: cur.line, ch: token.end}};
|
||||
}
|
||||
|
||||
CodeMirror.javascriptHint = function(editor) {
|
||||
return scriptHint(editor, javascriptKeywords,
|
||||
function (e, cur) {return e.getTokenAt(cur);});
|
||||
};
|
||||
|
||||
function getCoffeeScriptToken(editor, cur) {
|
||||
// This getToken, it is for coffeescript, imitates the behavior of
|
||||
// getTokenAt method in javascript.js, that is, returning "property"
|
||||
// type and treat "." as indepenent token.
|
||||
var token = editor.getTokenAt(cur);
|
||||
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
||||
token.end = token.start;
|
||||
token.string = '.';
|
||||
token.className = "property";
|
||||
}
|
||||
else if (/^\.[\w$_]*$/.test(token.string)) {
|
||||
token.className = "property";
|
||||
token.start++;
|
||||
token.string = token.string.replace(/\./, '');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
CodeMirror.coffeescriptHint = function(editor) {
|
||||
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken);
|
||||
};
|
||||
|
||||
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
||||
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
||||
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
||||
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
||||
var funcProps = "prototype apply call bind".split(" ");
|
||||
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
|
||||
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
|
||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||
|
||||
function getCompletions(token, context, keywords) {
|
||||
var found = [], start = token.string;
|
||||
function maybeAdd(str) {
|
||||
if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
function gatherCompletions(obj) {
|
||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||
for (var name in obj) maybeAdd(name);
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
if (obj.className == "variable")
|
||||
base = window[obj.string];
|
||||
else if (obj.className == "string")
|
||||
base = "";
|
||||
else if (obj.className == "atom")
|
||||
base = 1;
|
||||
else if (obj.className == "function") {
|
||||
if (window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||
(typeof window.jQuery == 'function'))
|
||||
base = window.jQuery();
|
||||
else if (window._ != null && (obj.string == '_') && (typeof window._ == 'function'))
|
||||
base = window._();
|
||||
}
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
}
|
||||
else {
|
||||
// If not, just look in the window object and any local scope
|
||||
// (reading into JS mode internals to get at the local variables)
|
||||
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
||||
gatherCompletions(window);
|
||||
forEach(keywords, maybeAdd);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
})();
|
51
webbuild/html/scripts/codemirror/lib/util/loadmode.js
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
(function() {
|
||||
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
|
||||
|
||||
var loading = {};
|
||||
function splitCallback(cont, n) {
|
||||
var countDown = n;
|
||||
return function() { if (--countDown == 0) cont(); };
|
||||
}
|
||||
function ensureDeps(mode, cont) {
|
||||
var deps = CodeMirror.modes[mode].dependencies;
|
||||
if (!deps) return cont();
|
||||
var missing = [];
|
||||
for (var i = 0; i < deps.length; ++i) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(deps[i]))
|
||||
missing.push(deps[i]);
|
||||
}
|
||||
if (!missing.length) return cont();
|
||||
var split = splitCallback(cont, missing.length);
|
||||
for (var i = 0; i < missing.length; ++i)
|
||||
CodeMirror.requireMode(missing[i], split);
|
||||
}
|
||||
|
||||
CodeMirror.requireMode = function(mode, cont) {
|
||||
if (typeof mode != "string") mode = mode.name;
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
|
||||
if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = CodeMirror.modeURL.replace(/%N/g, mode);
|
||||
var others = document.getElementsByTagName("script")[0];
|
||||
others.parentNode.insertBefore(script, others);
|
||||
var list = loading[mode] = [cont];
|
||||
var count = 0, poll = setInterval(function() {
|
||||
if (++count > 100) return clearInterval(poll);
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) {
|
||||
clearInterval(poll);
|
||||
loading[mode] = null;
|
||||
ensureDeps(mode, function() {
|
||||
for (var i = 0; i < list.length; ++i) list[i]();
|
||||
});
|
||||
}
|
||||
}, 200);
|
||||
};
|
||||
|
||||
CodeMirror.autoLoadMode = function(instance, mode) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(mode))
|
||||
CodeMirror.requireMode(mode, function() {
|
||||
instance.setOption("mode", instance.getOption("mode"));
|
||||
});
|
||||
};
|
||||
}());
|
44
webbuild/html/scripts/codemirror/lib/util/match-highlighter.js
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
// Define match-highlighter commands. Depends on searchcursor.js
|
||||
// Use by attaching the following function call to the onCursorActivity event:
|
||||
//myCodeMirror.matchHighlight(minChars);
|
||||
// And including a special span.CodeMirror-matchhighlight css class (also optionally a separate one for .CodeMirror-focused -- see demo matchhighlighter.html)
|
||||
|
||||
(function() {
|
||||
var DEFAULT_MIN_CHARS = 2;
|
||||
|
||||
function MatchHighlightState() {
|
||||
this.marked = [];
|
||||
}
|
||||
function getMatchHighlightState(cm) {
|
||||
return cm._matchHighlightState || (cm._matchHighlightState = new MatchHighlightState());
|
||||
}
|
||||
|
||||
function clearMarks(cm) {
|
||||
var state = getMatchHighlightState(cm);
|
||||
for (var i = 0; i < state.marked.length; ++i)
|
||||
state.marked[i].clear();
|
||||
state.marked = [];
|
||||
}
|
||||
|
||||
function markDocument(cm, className, minChars) {
|
||||
clearMarks(cm);
|
||||
minChars = (typeof minChars !== 'undefined' ? minChars : DEFAULT_MIN_CHARS);
|
||||
if (cm.somethingSelected() && cm.getSelection().replace(/^\s+|\s+$/g, "").length >= minChars) {
|
||||
var state = getMatchHighlightState(cm);
|
||||
var query = cm.getSelection();
|
||||
cm.operation(function() {
|
||||
if (cm.lineCount() < 2000) { // This is too expensive on big documents.
|
||||
for (var cursor = cm.getSearchCursor(query); cursor.findNext();) {
|
||||
//Only apply matchhighlight to the matches other than the one actually selected
|
||||
if (!(cursor.from().line === cm.getCursor(true).line && cursor.from().ch === cm.getCursor(true).ch))
|
||||
state.marked.push(cm.markText(cursor.from(), cursor.to(), className));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("matchHighlight", function(className, minChars) {
|
||||
markDocument(this, className, minChars);
|
||||
});
|
||||
})();
|
81
webbuild/html/scripts/codemirror/lib/util/multiplex.js
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
CodeMirror.multiplexingMode = function(outer /*, others */) {
|
||||
// Others should be {open, close, mode [, delimStyle]} objects
|
||||
var others = Array.prototype.slice.call(arguments, 1);
|
||||
var n_others = others.length;
|
||||
|
||||
function indexOf(string, pattern, from) {
|
||||
if (typeof pattern == "string") return string.indexOf(pattern, from);
|
||||
var m = pattern.exec(from ? string.slice(from) : string);
|
||||
return m ? m.index + from : -1;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
outer: CodeMirror.startState(outer),
|
||||
innerActive: null,
|
||||
inner: null
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
return {
|
||||
outer: CodeMirror.copyState(outer, state.outer),
|
||||
innerActive: state.innerActive,
|
||||
inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner)
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.innerActive) {
|
||||
var cutOff = Infinity, oldContent = stream.string;
|
||||
for (var i = 0; i < n_others; ++i) {
|
||||
var other = others[i];
|
||||
var found = indexOf(oldContent, other.open, stream.pos);
|
||||
if (found == stream.pos) {
|
||||
stream.match(other.open);
|
||||
state.innerActive = other;
|
||||
state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0);
|
||||
return other.delimStyle;
|
||||
} else if (found != -1 && found < cutOff) {
|
||||
cutOff = found;
|
||||
}
|
||||
}
|
||||
if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff);
|
||||
var outerToken = outer.token(stream, state.outer);
|
||||
if (cutOff != Infinity) stream.string = oldContent;
|
||||
return outerToken;
|
||||
} else {
|
||||
var curInner = state.innerActive, oldContent = stream.string;
|
||||
var found = indexOf(oldContent, curInner.close, stream.pos);
|
||||
if (found == stream.pos) {
|
||||
stream.match(curInner.close);
|
||||
state.innerActive = state.inner = null;
|
||||
return curInner.delimStyle;
|
||||
}
|
||||
if (found > -1) stream.string = oldContent.slice(0, found);
|
||||
var innerToken = curInner.mode.token(stream, state.inner);
|
||||
if (found > -1) stream.string = oldContent;
|
||||
var cur = stream.current(), found = cur.indexOf(curInner.close);
|
||||
if (found > -1) stream.backUp(cur.length - found);
|
||||
return innerToken;
|
||||
}
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var mode = state.innerActive ? state.innerActive.mode : outer;
|
||||
if (!mode.indent) return CodeMirror.Pass;
|
||||
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
|
||||
},
|
||||
|
||||
compareStates: function(a, b) {
|
||||
if (a.innerActive != b.innerActive) return false;
|
||||
var mode = a.innerActive || outer;
|
||||
if (!mode.compareStates) return CodeMirror.Pass;
|
||||
return mode.compareStates(a.innerActive ? a.inner : a.outer,
|
||||
b.innerActive ? b.inner : b.outer);
|
||||
},
|
||||
|
||||
electricChars: outer.electricChars
|
||||
};
|
||||
};
|
52
webbuild/html/scripts/codemirror/lib/util/overlay.js
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
// Utility function that allows modes to be combined. The mode given
|
||||
// as the base argument takes care of most of the normal mode
|
||||
// functionality, but a second (typically simple) mode is used, which
|
||||
// can override the style of text. Both modes get to parse all of the
|
||||
// text, but when both assign a non-null style to a piece of code, the
|
||||
// overlay wins, unless the combine argument was true, in which case
|
||||
// the styles are combined.
|
||||
|
||||
// overlayParser is the old, deprecated name
|
||||
CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, combine) {
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
base: CodeMirror.startState(base),
|
||||
overlay: CodeMirror.startState(overlay),
|
||||
basePos: 0, baseCur: null,
|
||||
overlayPos: 0, overlayCur: null
|
||||
};
|
||||
},
|
||||
copyState: function(state) {
|
||||
return {
|
||||
base: CodeMirror.copyState(base, state.base),
|
||||
overlay: CodeMirror.copyState(overlay, state.overlay),
|
||||
basePos: state.basePos, baseCur: null,
|
||||
overlayPos: state.overlayPos, overlayCur: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.start == state.basePos) {
|
||||
state.baseCur = base.token(stream, state.base);
|
||||
state.basePos = stream.pos;
|
||||
}
|
||||
if (stream.start == state.overlayPos) {
|
||||
stream.pos = stream.start;
|
||||
state.overlayCur = overlay.token(stream, state.overlay);
|
||||
state.overlayPos = stream.pos;
|
||||
}
|
||||
stream.pos = Math.min(state.basePos, state.overlayPos);
|
||||
if (stream.eol()) state.basePos = state.overlayPos = 0;
|
||||
|
||||
if (state.overlayCur == null) return state.baseCur;
|
||||
if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur;
|
||||
else return state.overlayCur;
|
||||
},
|
||||
|
||||
indent: base.indent && function(state, textAfter) {
|
||||
return base.indent(state.base, textAfter);
|
||||
},
|
||||
electricChars: base.electricChars
|
||||
};
|
||||
};
|
123
webbuild/html/scripts/codemirror/lib/util/pig-hint.js
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
(function () {
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, keywords, getToken) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
className: token.string == ":" ? "pig-type" : null};
|
||||
}
|
||||
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
|
||||
var completionList = getCompletions(token, context);
|
||||
completionList = completionList.sort();
|
||||
//prevent autocomplete for last word, instead show dropdown with one word
|
||||
if(completionList.length == 1) {
|
||||
completionList.push(" ");
|
||||
}
|
||||
|
||||
return {list: completionList,
|
||||
from: {line: cur.line, ch: token.start},
|
||||
to: {line: cur.line, ch: token.end}};
|
||||
}
|
||||
|
||||
CodeMirror.pigHint = function(editor) {
|
||||
return scriptHint(editor, pigKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
|
||||
};
|
||||
|
||||
function toTitleCase(str) {
|
||||
return str.replace(/(?:^|\s)\w/g, function(match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
var pigKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
|
||||
+ "JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL "
|
||||
+ "PARTITION GROUP AND OR NOT GENERATE FLATTEN ASC DESC IS STREAM THROUGH STORE MAPREDUCE "
|
||||
+ "SHIP CACHE INPUT OUTPUT STDERROR STDIN STDOUT LIMIT SAMPLE LEFT RIGHT FULL EQ GT LT GTE LTE "
|
||||
+ "NEQ MATCHES TRUE FALSE";
|
||||
var pigKeywordsU = pigKeywords.split(" ");
|
||||
var pigKeywordsL = pigKeywords.toLowerCase().split(" ");
|
||||
|
||||
var pigTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP";
|
||||
var pigTypesU = pigTypes.split(" ");
|
||||
var pigTypesL = pigTypes.toLowerCase().split(" ");
|
||||
|
||||
var pigBuiltins = "ABS ACOS ARITY ASIN ATAN AVG BAGSIZE BINSTORAGE BLOOM BUILDBLOOM CBRT CEIL "
|
||||
+ "CONCAT COR COS COSH COUNT COUNT_STAR COV CONSTANTSIZE CUBEDIMENSIONS DIFF DISTINCT DOUBLEABS "
|
||||
+ "DOUBLEAVG DOUBLEBASE DOUBLEMAX DOUBLEMIN DOUBLEROUND DOUBLESUM EXP FLOOR FLOATABS FLOATAVG "
|
||||
+ "FLOATMAX FLOATMIN FLOATROUND FLOATSUM GENERICINVOKER INDEXOF INTABS INTAVG INTMAX INTMIN "
|
||||
+ "INTSUM INVOKEFORDOUBLE INVOKEFORFLOAT INVOKEFORINT INVOKEFORLONG INVOKEFORSTRING INVOKER "
|
||||
+ "ISEMPTY JSONLOADER JSONMETADATA JSONSTORAGE LAST_INDEX_OF LCFIRST LOG LOG10 LOWER LONGABS "
|
||||
+ "LONGAVG LONGMAX LONGMIN LONGSUM MAX MIN MAPSIZE MONITOREDUDF NONDETERMINISTIC OUTPUTSCHEMA "
|
||||
+ "PIGSTORAGE PIGSTREAMING RANDOM REGEX_EXTRACT REGEX_EXTRACT_ALL REPLACE ROUND SIN SINH SIZE "
|
||||
+ "SQRT STRSPLIT SUBSTRING SUM STRINGCONCAT STRINGMAX STRINGMIN STRINGSIZE TAN TANH TOBAG "
|
||||
+ "TOKENIZE TOMAP TOP TOTUPLE TRIM TEXTLOADER TUPLESIZE UCFIRST UPPER UTF8STORAGECONVERTER";
|
||||
var pigBuiltinsU = pigBuiltins.split(" ").join("() ").split(" ");
|
||||
var pigBuiltinsL = pigBuiltins.toLowerCase().split(" ").join("() ").split(" ");
|
||||
var pigBuiltinsC = ("BagSize BinStorage Bloom BuildBloom ConstantSize CubeDimensions DoubleAbs "
|
||||
+ "DoubleAvg DoubleBase DoubleMax DoubleMin DoubleRound DoubleSum FloatAbs FloatAvg FloatMax "
|
||||
+ "FloatMin FloatRound FloatSum GenericInvoker IntAbs IntAvg IntMax IntMin IntSum "
|
||||
+ "InvokeForDouble InvokeForFloat InvokeForInt InvokeForLong InvokeForString Invoker "
|
||||
+ "IsEmpty JsonLoader JsonMetadata JsonStorage LongAbs LongAvg LongMax LongMin LongSum MapSize "
|
||||
+ "MonitoredUDF Nondeterministic OutputSchema PigStorage PigStreaming StringConcat StringMax "
|
||||
+ "StringMin StringSize TextLoader TupleSize Utf8StorageConverter").split(" ").join("() ").split(" ");
|
||||
|
||||
function getCompletions(token, context) {
|
||||
var found = [], start = token.string;
|
||||
function maybeAdd(str) {
|
||||
if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
|
||||
function gatherCompletions(obj) {
|
||||
if(obj == ":") {
|
||||
forEach(pigTypesL, maybeAdd);
|
||||
}
|
||||
else {
|
||||
forEach(pigBuiltinsU, maybeAdd);
|
||||
forEach(pigBuiltinsL, maybeAdd);
|
||||
forEach(pigBuiltinsC, maybeAdd);
|
||||
forEach(pigTypesU, maybeAdd);
|
||||
forEach(pigTypesL, maybeAdd);
|
||||
forEach(pigKeywordsU, maybeAdd);
|
||||
forEach(pigKeywordsL, maybeAdd);
|
||||
}
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
|
||||
if (obj.className == "pig-word")
|
||||
base = obj.string;
|
||||
else if(obj.className == "pig-type")
|
||||
base = ":" + obj.string;
|
||||
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
})();
|
53
webbuild/html/scripts/codemirror/lib/util/runmode.js
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
CodeMirror.runMode = function(string, modespec, callback, options) {
|
||||
function esc(str) {
|
||||
return str.replace(/[<&]/, function(ch) { return ch == "<" ? "<" : "&"; });
|
||||
}
|
||||
|
||||
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
|
||||
var isNode = callback.nodeType == 1;
|
||||
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
|
||||
if (isNode) {
|
||||
var node = callback, accum = [], col = 0;
|
||||
callback = function(text, style) {
|
||||
if (text == "\n") {
|
||||
accum.push("<br>");
|
||||
col = 0;
|
||||
return;
|
||||
}
|
||||
var escaped = "";
|
||||
// HTML-escape and replace tabs
|
||||
for (var pos = 0;;) {
|
||||
var idx = text.indexOf("\t", pos);
|
||||
if (idx == -1) {
|
||||
escaped += esc(text.slice(pos));
|
||||
col += text.length - pos;
|
||||
break;
|
||||
} else {
|
||||
col += idx - pos;
|
||||
escaped += esc(text.slice(pos, idx));
|
||||
var size = tabSize - col % tabSize;
|
||||
col += size;
|
||||
for (var i = 0; i < size; ++i) escaped += " ";
|
||||
pos = idx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (style)
|
||||
accum.push("<span class=\"cm-" + esc(style) + "\">" + escaped + "</span>");
|
||||
else
|
||||
accum.push(escaped);
|
||||
};
|
||||
}
|
||||
var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
if (i) callback("\n");
|
||||
var stream = new CodeMirror.StringStream(lines[i]);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
callback(stream.current(), style, i, stream.start);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
if (isNode)
|
||||
node.innerHTML = accum.join("");
|
||||
};
|
118
webbuild/html/scripts/codemirror/lib/util/search.js
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
// Define search commands. Depends on dialog.js or another
|
||||
// implementation of the openDialog method.
|
||||
|
||||
// Replace works a little oddly -- it will do the replace on the next
|
||||
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
|
||||
// replace by making sure the match is no longer selected when hitting
|
||||
// Ctrl-G.
|
||||
|
||||
(function() {
|
||||
function SearchState() {
|
||||
this.posFrom = this.posTo = this.query = null;
|
||||
this.marked = [];
|
||||
}
|
||||
function getSearchState(cm) {
|
||||
return cm._searchState || (cm._searchState = new SearchState());
|
||||
}
|
||||
function getSearchCursor(cm, query, pos) {
|
||||
// Heuristic: if the query string is all lowercase, do a case insensitive search.
|
||||
return cm.getSearchCursor(query, pos, typeof query == "string" && query == query.toLowerCase());
|
||||
}
|
||||
function dialog(cm, text, shortText, f) {
|
||||
if (cm.openDialog) cm.openDialog(text, f);
|
||||
else f(prompt(shortText, ""));
|
||||
}
|
||||
function confirmDialog(cm, text, shortText, fs) {
|
||||
if (cm.openConfirm) cm.openConfirm(text, fs);
|
||||
else if (confirm(shortText)) fs[0]();
|
||||
}
|
||||
function parseQuery(query) {
|
||||
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
|
||||
return isRE ? new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i") : query;
|
||||
}
|
||||
var queryDialog =
|
||||
'Search: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
|
||||
function doSearch(cm, rev) {
|
||||
var state = getSearchState(cm);
|
||||
if (state.query) return findNext(cm, rev);
|
||||
dialog(cm, queryDialog, "Search for:", function(query) {
|
||||
cm.operation(function() {
|
||||
if (!query || state.query) return;
|
||||
state.query = parseQuery(query);
|
||||
if (cm.lineCount() < 2000) { // This is too expensive on big documents.
|
||||
for (var cursor = getSearchCursor(cm, state.query); cursor.findNext();)
|
||||
state.marked.push(cm.markText(cursor.from(), cursor.to(), "CodeMirror-searching"));
|
||||
}
|
||||
state.posFrom = state.posTo = cm.getCursor();
|
||||
findNext(cm, rev);
|
||||
});
|
||||
});
|
||||
}
|
||||
function findNext(cm, rev) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
|
||||
if (!cursor.find(rev)) {
|
||||
cursor = getSearchCursor(cm, state.query, rev ? {line: cm.lineCount() - 1} : {line: 0, ch: 0});
|
||||
if (!cursor.find(rev)) return;
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
||||
});}
|
||||
function clearSearch(cm) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
if (!state.query) return;
|
||||
state.query = null;
|
||||
for (var i = 0; i < state.marked.length; ++i) state.marked[i].clear();
|
||||
state.marked.length = 0;
|
||||
});}
|
||||
|
||||
var replaceQueryDialog =
|
||||
'Replace: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
|
||||
var replacementQueryDialog = 'With: <input type="text" style="width: 10em"/>';
|
||||
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
|
||||
function replace(cm, all) {
|
||||
dialog(cm, replaceQueryDialog, "Replace:", function(query) {
|
||||
if (!query) return;
|
||||
query = parseQuery(query);
|
||||
dialog(cm, replacementQueryDialog, "Replace with:", function(text) {
|
||||
if (all) {
|
||||
cm.compoundChange(function() { cm.operation(function() {
|
||||
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
|
||||
if (typeof query != "string") {
|
||||
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
||||
cursor.replace(text.replace(/\$(\d)/, function(w, i) {return match[i];}));
|
||||
} else cursor.replace(text);
|
||||
}
|
||||
});});
|
||||
} else {
|
||||
clearSearch(cm);
|
||||
var cursor = getSearchCursor(cm, query, cm.getCursor());
|
||||
function advance() {
|
||||
var start = cursor.from(), match;
|
||||
if (!(match = cursor.findNext())) {
|
||||
cursor = getSearchCursor(cm, query);
|
||||
if (!(match = cursor.findNext()) ||
|
||||
(start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
||||
[function() {doReplace(match);}, advance]);
|
||||
}
|
||||
function doReplace(match) {
|
||||
cursor.replace(typeof query == "string" ? text :
|
||||
text.replace(/\$(\d)/, function(w, i) {return match[i];}));
|
||||
advance();
|
||||
}
|
||||
advance();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
||||
CodeMirror.commands.findNext = doSearch;
|
||||
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
||||
CodeMirror.commands.clearSearch = clearSearch;
|
||||
CodeMirror.commands.replace = replace;
|
||||
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
|
||||
})();
|
119
webbuild/html/scripts/codemirror/lib/util/searchcursor.js
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
(function(){
|
||||
function SearchCursor(cm, query, pos, caseFold) {
|
||||
this.atOccurrence = false; this.cm = cm;
|
||||
if (caseFold == null && typeof query == "string") caseFold = false;
|
||||
|
||||
pos = pos ? cm.clipPos(pos) : {line: 0, ch: 0};
|
||||
this.pos = {from: pos, to: pos};
|
||||
|
||||
// The matches method is filled in based on the type of query.
|
||||
// It takes a position and a direction, and returns an object
|
||||
// describing the next occurrence of the query, or null if no
|
||||
// more matches were found.
|
||||
if (typeof query != "string") { // Regexp match
|
||||
if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g");
|
||||
this.matches = function(reverse, pos) {
|
||||
if (reverse) {
|
||||
query.lastIndex = 0;
|
||||
var line = cm.getLine(pos.line).slice(0, pos.ch), match = query.exec(line), start = 0;
|
||||
while (match) {
|
||||
start += match.index;
|
||||
line = line.slice(match.index);
|
||||
query.lastIndex = 0;
|
||||
var newmatch = query.exec(line);
|
||||
if (newmatch) match = newmatch;
|
||||
else break;
|
||||
start++;
|
||||
}
|
||||
} else {
|
||||
query.lastIndex = pos.ch;
|
||||
var line = cm.getLine(pos.line), match = query.exec(line),
|
||||
start = match && match.index;
|
||||
}
|
||||
if (match)
|
||||
return {from: {line: pos.line, ch: start},
|
||||
to: {line: pos.line, ch: start + match[0].length},
|
||||
match: match};
|
||||
};
|
||||
} else { // String query
|
||||
if (caseFold) query = query.toLowerCase();
|
||||
var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
|
||||
var target = query.split("\n");
|
||||
// Different methods for single-line and multi-line queries
|
||||
if (target.length == 1)
|
||||
this.matches = function(reverse, pos) {
|
||||
var line = fold(cm.getLine(pos.line)), len = query.length, match;
|
||||
if (reverse ? (pos.ch >= len && (match = line.lastIndexOf(query, pos.ch - len)) != -1)
|
||||
: (match = line.indexOf(query, pos.ch)) != -1)
|
||||
return {from: {line: pos.line, ch: match},
|
||||
to: {line: pos.line, ch: match + len}};
|
||||
};
|
||||
else
|
||||
this.matches = function(reverse, pos) {
|
||||
var ln = pos.line, idx = (reverse ? target.length - 1 : 0), match = target[idx], line = fold(cm.getLine(ln));
|
||||
var offsetA = (reverse ? line.indexOf(match) + match.length : line.lastIndexOf(match));
|
||||
if (reverse ? offsetA >= pos.ch || offsetA != match.length
|
||||
: offsetA <= pos.ch || offsetA != line.length - match.length)
|
||||
return;
|
||||
for (;;) {
|
||||
if (reverse ? !ln : ln == cm.lineCount() - 1) return;
|
||||
line = fold(cm.getLine(ln += reverse ? -1 : 1));
|
||||
match = target[reverse ? --idx : ++idx];
|
||||
if (idx > 0 && idx < target.length - 1) {
|
||||
if (line != match) return;
|
||||
else continue;
|
||||
}
|
||||
var offsetB = (reverse ? line.lastIndexOf(match) : line.indexOf(match) + match.length);
|
||||
if (reverse ? offsetB != line.length - match.length : offsetB != match.length)
|
||||
return;
|
||||
var start = {line: pos.line, ch: offsetA}, end = {line: ln, ch: offsetB};
|
||||
return {from: reverse ? end : start, to: reverse ? start : end};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
SearchCursor.prototype = {
|
||||
findNext: function() {return this.find(false);},
|
||||
findPrevious: function() {return this.find(true);},
|
||||
|
||||
find: function(reverse) {
|
||||
var self = this, pos = this.cm.clipPos(reverse ? this.pos.from : this.pos.to);
|
||||
function savePosAndFail(line) {
|
||||
var pos = {line: line, ch: 0};
|
||||
self.pos = {from: pos, to: pos};
|
||||
self.atOccurrence = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (this.pos = this.matches(reverse, pos)) {
|
||||
this.atOccurrence = true;
|
||||
return this.pos.match || true;
|
||||
}
|
||||
if (reverse) {
|
||||
if (!pos.line) return savePosAndFail(0);
|
||||
pos = {line: pos.line-1, ch: this.cm.getLine(pos.line-1).length};
|
||||
}
|
||||
else {
|
||||
var maxLine = this.cm.lineCount();
|
||||
if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
|
||||
pos = {line: pos.line+1, ch: 0};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
from: function() {if (this.atOccurrence) return this.pos.from;},
|
||||
to: function() {if (this.atOccurrence) return this.pos.to;},
|
||||
|
||||
replace: function(newText) {
|
||||
var self = this;
|
||||
if (this.atOccurrence)
|
||||
self.pos.to = this.cm.replaceRange(newText, self.pos.from, self.pos.to);
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
|
||||
return new SearchCursor(this, query, pos, caseFold);
|
||||
});
|
||||
})();
|
16
webbuild/html/scripts/codemirror/lib/util/simple-hint.css
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
.CodeMirror-completions {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
overflow: hidden;
|
||||
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
}
|
||||
.CodeMirror-completions select {
|
||||
background: #fafafa;
|
||||
outline: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: monospace;
|
||||
}
|
97
webbuild/html/scripts/codemirror/lib/util/simple-hint.js
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
(function() {
|
||||
CodeMirror.simpleHint = function(editor, getHints, givenOptions) {
|
||||
// Determine effective options based on given values and defaults.
|
||||
var options = {}, defaults = CodeMirror.simpleHint.defaults;
|
||||
for (var opt in defaults)
|
||||
if (defaults.hasOwnProperty(opt))
|
||||
options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
|
||||
|
||||
function collectHints(previousToken) {
|
||||
// We want a single cursor position.
|
||||
if (editor.somethingSelected()) return;
|
||||
|
||||
var tempToken = editor.getTokenAt(editor.getCursor());
|
||||
|
||||
// Don't show completions if token has changed and the option is set.
|
||||
if (options.closeOnTokenChange && previousToken != null &&
|
||||
(tempToken.start != previousToken.start || tempToken.className != previousToken.className)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var result = getHints(editor);
|
||||
if (!result || !result.list.length) return;
|
||||
var completions = result.list;
|
||||
function insert(str) {
|
||||
editor.replaceRange(str, result.from, result.to);
|
||||
}
|
||||
// When there is only one completion, use it directly.
|
||||
if (completions.length == 1) {insert(completions[0]); return true;}
|
||||
|
||||
// Build the select widget
|
||||
var complete = document.createElement("div");
|
||||
complete.className = "CodeMirror-completions";
|
||||
var sel = complete.appendChild(document.createElement("select"));
|
||||
// Opera doesn't move the selection when pressing up/down in a
|
||||
// multi-select, but it does properly support the size property on
|
||||
// single-selects, so no multi-select is necessary.
|
||||
if (!window.opera) sel.multiple = true;
|
||||
for (var i = 0; i < completions.length; ++i) {
|
||||
var opt = sel.appendChild(document.createElement("option"));
|
||||
opt.appendChild(document.createTextNode(completions[i]));
|
||||
}
|
||||
sel.firstChild.selected = true;
|
||||
sel.size = Math.min(10, completions.length);
|
||||
var pos = editor.cursorCoords();
|
||||
complete.style.left = pos.x + "px";
|
||||
complete.style.top = pos.yBot + "px";
|
||||
document.body.appendChild(complete);
|
||||
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
||||
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
||||
if(winW - pos.x < sel.clientWidth)
|
||||
complete.style.left = (pos.x - sel.clientWidth) + "px";
|
||||
// Hack to hide the scrollbar.
|
||||
if (completions.length <= 10)
|
||||
complete.style.width = (sel.clientWidth - 1) + "px";
|
||||
|
||||
var done = false;
|
||||
function close() {
|
||||
if (done) return;
|
||||
done = true;
|
||||
complete.parentNode.removeChild(complete);
|
||||
}
|
||||
function pick() {
|
||||
insert(completions[sel.selectedIndex]);
|
||||
close();
|
||||
setTimeout(function(){editor.focus();}, 50);
|
||||
}
|
||||
CodeMirror.connect(sel, "blur", close);
|
||||
CodeMirror.connect(sel, "keydown", function(event) {
|
||||
var code = event.keyCode;
|
||||
// Enter
|
||||
if (code == 13) {CodeMirror.e_stop(event); pick();}
|
||||
// Escape
|
||||
else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
|
||||
else if (code != 38 && code != 40) {
|
||||
close(); editor.focus();
|
||||
// Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
|
||||
editor.triggerOnKeyDown(event);
|
||||
// Don't show completions if the code is backspace and the option is set.
|
||||
if (!options.closeOnBackspace || code != 8) {
|
||||
setTimeout(function(){collectHints(tempToken);}, 50);
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.connect(sel, "dblclick", pick);
|
||||
|
||||
sel.focus();
|
||||
// Opera sometimes ignores focusing a freshly created node
|
||||
if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
|
||||
return true;
|
||||
}
|
||||
return collectHints();
|
||||
};
|
||||
CodeMirror.simpleHint.defaults = {
|
||||
closeOnBackspace: true,
|
||||
closeOnTokenChange: false
|
||||
};
|
||||
})();
|
137
webbuild/html/scripts/codemirror/lib/util/xml-hint.js
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
|
||||
(function() {
|
||||
|
||||
CodeMirror.xmlHints = [];
|
||||
|
||||
CodeMirror.xmlHint = function(cm, simbol) {
|
||||
|
||||
if(simbol.length > 0) {
|
||||
var cursor = cm.getCursor();
|
||||
cm.replaceSelection(simbol);
|
||||
cursor = {line: cursor.line, ch: cursor.ch + 1};
|
||||
cm.setCursor(cursor);
|
||||
}
|
||||
|
||||
// dirty hack for simple-hint to receive getHint event on space
|
||||
var getTokenAt = editor.getTokenAt;
|
||||
|
||||
editor.getTokenAt = function() { return 'disabled'; };
|
||||
CodeMirror.simpleHint(cm, getHint);
|
||||
|
||||
editor.getTokenAt = getTokenAt;
|
||||
};
|
||||
|
||||
var getHint = function(cm) {
|
||||
|
||||
var cursor = cm.getCursor();
|
||||
|
||||
if (cursor.ch > 0) {
|
||||
|
||||
var text = cm.getRange({line: 0, ch: 0}, cursor);
|
||||
var typed = '';
|
||||
var simbol = '';
|
||||
for(var i = text.length - 1; i >= 0; i--) {
|
||||
if(text[i] == ' ' || text[i] == '<') {
|
||||
simbol = text[i];
|
||||
break;
|
||||
}
|
||||
else {
|
||||
typed = text[i] + typed;
|
||||
}
|
||||
}
|
||||
|
||||
text = text.slice(0, text.length - typed.length);
|
||||
|
||||
var path = getActiveElement(cm, text) + simbol;
|
||||
var hints = CodeMirror.xmlHints[path];
|
||||
|
||||
if(typeof hints === 'undefined')
|
||||
hints = [''];
|
||||
else {
|
||||
hints = hints.slice(0);
|
||||
for (var i = hints.length - 1; i >= 0; i--) {
|
||||
if(hints[i].indexOf(typed) != 0)
|
||||
hints.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
list: hints,
|
||||
from: { line: cursor.line, ch: cursor.ch - typed.length },
|
||||
to: cursor
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
var getActiveElement = function(codeMirror, text) {
|
||||
|
||||
var element = '';
|
||||
|
||||
if(text.length >= 0) {
|
||||
|
||||
var regex = new RegExp('<([^!?][^\\s/>]*).*?>', 'g');
|
||||
|
||||
var matches = [];
|
||||
var match;
|
||||
while ((match = regex.exec(text)) != null) {
|
||||
matches.push({
|
||||
tag: match[1],
|
||||
selfclose: (match[0].slice(match[0].length - 2) === '/>')
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = matches.length - 1, skip = 0; i >= 0; i--) {
|
||||
|
||||
var item = matches[i];
|
||||
|
||||
if (item.tag[0] == '/')
|
||||
{
|
||||
skip++;
|
||||
}
|
||||
else if (item.selfclose == false)
|
||||
{
|
||||
if (skip > 0)
|
||||
{
|
||||
skip--;
|
||||
}
|
||||
else
|
||||
{
|
||||
element = '<' + item.tag + '>' + element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
element += getOpenTag(text);
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
var getOpenTag = function(text) {
|
||||
|
||||
var open = text.lastIndexOf('<');
|
||||
var close = text.lastIndexOf('>');
|
||||
|
||||
if (close < open)
|
||||
{
|
||||
text = text.slice(open);
|
||||
|
||||
if(text != '<') {
|
||||
|
||||
var space = text.indexOf(' ');
|
||||
if(space < 0)
|
||||
space = text.indexOf('\t');
|
||||
if(space < 0)
|
||||
space = text.indexOf('\n');
|
||||
|
||||
if (space < 0)
|
||||
space = text.length;
|
||||
|
||||
return text.slice(0, space);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
})();
|
284
webbuild/html/scripts/codemirror/mode/clike/clike.js
vendored
Normal file
@ -0,0 +1,284 @@
|
||||
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
keywords = parserConfig.keywords || {},
|
||||
builtin = parserConfig.builtin || {},
|
||||
blockKeywords = parserConfig.blockKeywords || {},
|
||||
atoms = parserConfig.atoms || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
if (builtin.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = null;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
(function() {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
||||
"double static else struct entry switch extern typedef float union for unsigned " +
|
||||
"goto while enum void const signed volatile";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
stream.skipToEnd();
|
||||
return "meta";
|
||||
}
|
||||
|
||||
// C#-style strings where "" escapes a quote.
|
||||
function tokenAtString(stream, state) {
|
||||
var next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == '"' && !stream.eat('"')) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
function mimes(ms, mode) {
|
||||
for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
|
||||
}
|
||||
|
||||
mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
mimes(["text/x-c++src", "text/x-c++hdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"wchar_t"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-java", {
|
||||
name: "clike",
|
||||
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
||||
"do double else enum extends final finally float for goto if implements import " +
|
||||
"instanceof int interface long native new package private protected public " +
|
||||
"return short static strictfp super switch synchronized this throw throws transient " +
|
||||
"try void volatile while"),
|
||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-csharp", {
|
||||
name: "clike",
|
||||
keywords: words("abstract as base break case catch checked class const continue" +
|
||||
" default delegate do else enum event explicit extern finally fixed for" +
|
||||
" foreach goto if implicit in interface internal is lock namespace new" +
|
||||
" operator out override params private protected public readonly ref return sealed" +
|
||||
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
||||
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
||||
" global group into join let orderby partial remove select set value var yield"),
|
||||
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
||||
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
||||
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
||||
" UInt64 bool byte char decimal double short int long object" +
|
||||
" sbyte float string ushort uint ulong"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
if (stream.eat('"')) {
|
||||
state.tokenize = tokenAtString;
|
||||
return tokenAtString(stream, state);
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-scala", {
|
||||
name: "clike",
|
||||
keywords: words(
|
||||
|
||||
/* scala */
|
||||
"abstract case catch class def do else extends false final finally for forSome if " +
|
||||
"implicit import lazy match new null object override package private protected return " +
|
||||
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
||||
"<% >: # @ " +
|
||||
|
||||
/* package scala */
|
||||
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
||||
"readChar readInt readLong readFloat readDouble " +
|
||||
|
||||
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
||||
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
||||
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
||||
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
||||
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
||||
|
||||
/* package java.lang */
|
||||
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
||||
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
||||
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
||||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
||||
|
||||
|
||||
),
|
||||
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
}());
|
102
webbuild/html/scripts/codemirror/mode/clike/index.html
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: C-like mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: C-like mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
/* C demo code */
|
||||
|
||||
#include <zmq.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
|
||||
typedef struct {
|
||||
void* arg_socket;
|
||||
zmq_msg_t* arg_msg;
|
||||
char* arg_string;
|
||||
unsigned long arg_len;
|
||||
int arg_int, arg_command;
|
||||
|
||||
int signal_fd;
|
||||
int pad;
|
||||
void* context;
|
||||
sem_t sem;
|
||||
} acl_zmq_context;
|
||||
|
||||
#define p(X) (context->arg_##X)
|
||||
|
||||
void* zmq_thread(void* context_pointer) {
|
||||
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
||||
char ok = 'K', err = 'X';
|
||||
int res;
|
||||
|
||||
while (1) {
|
||||
while ((res = sem_wait(&context->sem)) == EINTR);
|
||||
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
||||
switch(p(command)) {
|
||||
case 0: goto cleanup;
|
||||
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
||||
case 2: p(int) = zmq_close(p(socket)); break;
|
||||
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
||||
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
||||
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
||||
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
||||
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
||||
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
||||
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
||||
}
|
||||
p(command) = errno;
|
||||
write(context->signal_fd, &ok, 1);
|
||||
}
|
||||
cleanup:
|
||||
close(context->signal_fd);
|
||||
free(context_pointer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
||||
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
||||
pthread_t thread;
|
||||
|
||||
context->context = zmq_context;
|
||||
context->signal_fd = signal_fd;
|
||||
sem_init(&context->sem, 1, 0);
|
||||
pthread_create(&thread, 0, &zmq_thread, context);
|
||||
pthread_detach(thread);
|
||||
return context;
|
||||
}
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-csrc"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle C-like languages as well as it
|
||||
can. Takes two configuration parameters: <code>keywords</code>, an
|
||||
object whose property names are the keywords in the language,
|
||||
and <code>useCPP</code>, which determines whether C preprocessor
|
||||
directives are recognized.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
||||
(C code), <code>text/x-c++src</code> (C++
|
||||
code), <code>text/x-java</code> (Java
|
||||
code), <code>text/x-csharp</code> (C#).</p>
|
||||
</body>
|
||||
</html>
|
766
webbuild/html/scripts/codemirror/mode/clike/scala.html
vendored
Normal file
@ -0,0 +1,766 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: C-like mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/ambiance.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style>
|
||||
body
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-width:inherit;
|
||||
height: 100%;
|
||||
}
|
||||
html, form, .CodeMirror, .CodeMirror-scroll
|
||||
{
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
<textarea id="code" name="code">
|
||||
|
||||
/* __ *\
|
||||
** ________ ___ / / ___ Scala API **
|
||||
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||
** /____/\___/_/ |_/____/_/ | | **
|
||||
** |/ **
|
||||
\* */
|
||||
|
||||
package scala.collection
|
||||
|
||||
import generic._
|
||||
import mutable.{ Builder, ListBuffer }
|
||||
import annotation.{tailrec, migration, bridge}
|
||||
import annotation.unchecked.{ uncheckedVariance => uV }
|
||||
import parallel.ParIterable
|
||||
|
||||
/** A template trait for traversable collections of type `Traversable[A]`.
|
||||
*
|
||||
* $traversableInfo
|
||||
* @define mutability
|
||||
* @define traversableInfo
|
||||
* This is a base trait of all kinds of $mutability Scala collections. It
|
||||
* implements the behavior common to all collections, in terms of a method
|
||||
* `foreach` with signature:
|
||||
* {{{
|
||||
* def foreach[U](f: Elem => U): Unit
|
||||
* }}}
|
||||
* Collection classes mixing in this trait provide a concrete
|
||||
* `foreach` method which traverses all the
|
||||
* elements contained in the collection, applying a given function to each.
|
||||
* They also need to provide a method `newBuilder`
|
||||
* which creates a builder for collections of the same kind.
|
||||
*
|
||||
* A traversable class might or might not have two properties: strictness
|
||||
* and orderedness. Neither is represented as a type.
|
||||
*
|
||||
* The instances of a strict collection class have all their elements
|
||||
* computed before they can be used as values. By contrast, instances of
|
||||
* a non-strict collection class may defer computation of some of their
|
||||
* elements until after the instance is available as a value.
|
||||
* A typical example of a non-strict collection class is a
|
||||
* <a href="../immutable/Stream.html" target="ContentFrame">
|
||||
* `scala.collection.immutable.Stream`</a>.
|
||||
* A more general class of examples are `TraversableViews`.
|
||||
*
|
||||
* If a collection is an instance of an ordered collection class, traversing
|
||||
* its elements with `foreach` will always visit elements in the
|
||||
* same order, even for different runs of the program. If the class is not
|
||||
* ordered, `foreach` can visit elements in different orders for
|
||||
* different runs (but it will keep the same order in the same run).'
|
||||
*
|
||||
* A typical example of a collection class which is not ordered is a
|
||||
* `HashMap` of objects. The traversal order for hash maps will
|
||||
* depend on the hash codes of its elements, and these hash codes might
|
||||
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
||||
* is ordered because it's `foreach` method visits elements in the
|
||||
* order they were inserted into the `HashMap`.
|
||||
*
|
||||
* @author Martin Odersky
|
||||
* @version 2.8
|
||||
* @since 2.8
|
||||
* @tparam A the element type of the collection
|
||||
* @tparam Repr the type of the actual collection containing the elements.
|
||||
*
|
||||
* @define Coll Traversable
|
||||
* @define coll traversable collection
|
||||
*/
|
||||
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
||||
with FilterMonadic[A, Repr]
|
||||
with TraversableOnce[A]
|
||||
with GenTraversableLike[A, Repr]
|
||||
with Parallelizable[A, ParIterable[A]]
|
||||
{
|
||||
self =>
|
||||
|
||||
import Traversable.breaks._
|
||||
|
||||
/** The type implementing this traversable */
|
||||
protected type Self = Repr
|
||||
|
||||
/** The collection of type $coll underlying this `TraversableLike` object.
|
||||
* By default this is implemented as the `TraversableLike` object itself,
|
||||
* but this can be overridden.
|
||||
*/
|
||||
def repr: Repr = this.asInstanceOf[Repr]
|
||||
|
||||
/** The underlying collection seen as an instance of `$Coll`.
|
||||
* By default this is implemented as the current collection object itself,
|
||||
* but this can be overridden.
|
||||
*/
|
||||
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
||||
|
||||
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
||||
* By default this is implemented as just a cast, but this can be overridden.
|
||||
*/
|
||||
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
||||
|
||||
/** Creates a new builder for this collection type.
|
||||
*/
|
||||
protected[this] def newBuilder: Builder[A, Repr]
|
||||
|
||||
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
||||
|
||||
/** Applies a function `f` to all elements of this $coll.
|
||||
*
|
||||
* Note: this method underlies the implementation of most other bulk operations.
|
||||
* It's important to implement this method in an efficient way.
|
||||
*
|
||||
*
|
||||
* @param f the function that is applied for its side-effect to every element.
|
||||
* The result of function `f` is discarded.
|
||||
*
|
||||
* @tparam U the type parameter describing the result of function `f`.
|
||||
* This result will always be ignored. Typically `U` is `Unit`,
|
||||
* but this is not necessary.
|
||||
*
|
||||
* @usecase def foreach(f: A => Unit): Unit
|
||||
*/
|
||||
def foreach[U](f: A => U): Unit
|
||||
|
||||
/** Tests whether this $coll is empty.
|
||||
*
|
||||
* @return `true` if the $coll contain no elements, `false` otherwise.
|
||||
*/
|
||||
def isEmpty: Boolean = {
|
||||
var result = true
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
result = false
|
||||
break
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/** Tests whether this $coll is known to have a finite size.
|
||||
* All strict collections are known to have finite size. For a non-strict collection
|
||||
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
||||
* It returns `false` if the stream is not yet evaluated to the end.
|
||||
*
|
||||
* Note: many collection methods will not work on collections of infinite sizes.
|
||||
*
|
||||
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
||||
*/
|
||||
def hasDefiniteSize = true
|
||||
|
||||
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
||||
b ++= thisCollection
|
||||
b ++= that.seq
|
||||
b.result
|
||||
}
|
||||
|
||||
@bridge
|
||||
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
||||
++(that: GenTraversableOnce[B])(bf)
|
||||
|
||||
/** Concatenates this $coll with the elements of a traversable collection.
|
||||
* It differs from ++ in that the right operand determines the type of the
|
||||
* resulting collection rather than the left one.
|
||||
*
|
||||
* @param that the traversable to append.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` which contains all elements
|
||||
* of this $coll followed by all elements of `that`.
|
||||
*
|
||||
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
||||
*
|
||||
* @return a new $coll which contains all elements of this $coll
|
||||
* followed by all elements of `that`.
|
||||
*/
|
||||
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
||||
b ++= that
|
||||
b ++= thisCollection
|
||||
b.result
|
||||
}
|
||||
|
||||
/** This overload exists because: for the implementation of ++: we should reuse
|
||||
* that of ++ because many collections override it with more efficient versions.
|
||||
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
||||
* but Traversable and down can use the overload.
|
||||
*/
|
||||
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
||||
(that ++ seq)(breakOut)
|
||||
|
||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
b.sizeHint(this)
|
||||
for (x <- this) b += f(x)
|
||||
b.result
|
||||
}
|
||||
|
||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- this) b ++= f(x).seq
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Selects all elements of this $coll which satisfy a predicate.
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
||||
* predicate `p`. The order of the elements is preserved.
|
||||
*/
|
||||
def filter(p: A => Boolean): Repr = {
|
||||
val b = newBuilder
|
||||
for (x <- this)
|
||||
if (p(x)) b += x
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Selects all elements of this $coll which do not satisfy a predicate.
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
||||
* predicate `p`. The order of the elements is preserved.
|
||||
*/
|
||||
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
||||
|
||||
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Builds a new collection by applying an option-valued function to all
|
||||
* elements of this $coll on which the function is defined.
|
||||
*
|
||||
* @param f the option-valued function which filters and maps the $coll.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` resulting from applying the option-valued function
|
||||
* `f` to each element and collecting all defined results.
|
||||
* The order of the elements is preserved.
|
||||
*
|
||||
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
||||
*
|
||||
* @param pf the partial function which filters and maps the $coll.
|
||||
* @return a new $coll resulting from applying the given option-valued function
|
||||
* `f` to each element and collecting all defined results.
|
||||
* The order of the elements is preserved.
|
||||
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- this)
|
||||
f(x) match {
|
||||
case Some(y) => b += y
|
||||
case _ =>
|
||||
}
|
||||
b.result
|
||||
}
|
||||
*/
|
||||
|
||||
/** Partitions this $coll in two ${coll}s according to a predicate.
|
||||
*
|
||||
* @param p the predicate on which to partition.
|
||||
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
||||
* satisfy the predicate `p` and the second $coll consists of all elements
|
||||
* that don't. The relative order of the elements in the resulting ${coll}s
|
||||
* is the same as in the original $coll.
|
||||
*/
|
||||
def partition(p: A => Boolean): (Repr, Repr) = {
|
||||
val l, r = newBuilder
|
||||
for (x <- this) (if (p(x)) l else r) += x
|
||||
(l.result, r.result)
|
||||
}
|
||||
|
||||
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
||||
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
||||
for (elem <- this) {
|
||||
val key = f(elem)
|
||||
val bldr = m.getOrElseUpdate(key, newBuilder)
|
||||
bldr += elem
|
||||
}
|
||||
val b = immutable.Map.newBuilder[K, Repr]
|
||||
for ((k, v) <- m)
|
||||
b += ((k, v.result))
|
||||
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Tests whether a predicate holds for all elements of this $coll.
|
||||
*
|
||||
* $mayNotTerminateInf
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return `true` if the given predicate `p` holds for all elements
|
||||
* of this $coll, otherwise `false`.
|
||||
*/
|
||||
def forall(p: A => Boolean): Boolean = {
|
||||
var result = true
|
||||
breakable {
|
||||
for (x <- this)
|
||||
if (!p(x)) { result = false; break }
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/** Tests whether a predicate holds for some of the elements of this $coll.
|
||||
*
|
||||
* $mayNotTerminateInf
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return `true` if the given predicate `p` holds for some of the
|
||||
* elements of this $coll, otherwise `false`.
|
||||
*/
|
||||
def exists(p: A => Boolean): Boolean = {
|
||||
var result = false
|
||||
breakable {
|
||||
for (x <- this)
|
||||
if (p(x)) { result = true; break }
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/** Finds the first element of the $coll satisfying a predicate, if any.
|
||||
*
|
||||
* $mayNotTerminateInf
|
||||
* $orderDependent
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return an option value containing the first element in the $coll
|
||||
* that satisfies `p`, or `None` if none exists.
|
||||
*/
|
||||
def find(p: A => Boolean): Option[A] = {
|
||||
var result: Option[A] = None
|
||||
breakable {
|
||||
for (x <- this)
|
||||
if (p(x)) { result = Some(x); break }
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
||||
|
||||
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
b.sizeHint(this, 1)
|
||||
var acc = z
|
||||
b += acc
|
||||
for (x <- this) { acc = op(acc, x); b += acc }
|
||||
b.result
|
||||
}
|
||||
|
||||
@migration(2, 9,
|
||||
"This scanRight definition has changed in 2.9.\n" +
|
||||
"The previous behavior can be reproduced with scanRight.reverse."
|
||||
)
|
||||
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
var scanned = List(z)
|
||||
var acc = z
|
||||
for (x <- reversed) {
|
||||
acc = op(x, acc)
|
||||
scanned ::= acc
|
||||
}
|
||||
val b = bf(repr)
|
||||
for (elem <- scanned) b += elem
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Selects the first element of this $coll.
|
||||
* $orderDependent
|
||||
* @return the first element of this $coll.
|
||||
* @throws `NoSuchElementException` if the $coll is empty.
|
||||
*/
|
||||
def head: A = {
|
||||
var result: () => A = () => throw new NoSuchElementException
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
result = () => x
|
||||
break
|
||||
}
|
||||
}
|
||||
result()
|
||||
}
|
||||
|
||||
/** Optionally selects the first element.
|
||||
* $orderDependent
|
||||
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
||||
*/
|
||||
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
||||
|
||||
/** Selects all elements except the first.
|
||||
* $orderDependent
|
||||
* @return a $coll consisting of all elements of this $coll
|
||||
* except the first one.
|
||||
* @throws `UnsupportedOperationException` if the $coll is empty.
|
||||
*/
|
||||
override def tail: Repr = {
|
||||
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
||||
drop(1)
|
||||
}
|
||||
|
||||
/** Selects the last element.
|
||||
* $orderDependent
|
||||
* @return The last element of this $coll.
|
||||
* @throws NoSuchElementException If the $coll is empty.
|
||||
*/
|
||||
def last: A = {
|
||||
var lst = head
|
||||
for (x <- this)
|
||||
lst = x
|
||||
lst
|
||||
}
|
||||
|
||||
/** Optionally selects the last element.
|
||||
* $orderDependent
|
||||
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
||||
*/
|
||||
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
||||
|
||||
/** Selects all elements except the last.
|
||||
* $orderDependent
|
||||
* @return a $coll consisting of all elements of this $coll
|
||||
* except the last one.
|
||||
* @throws `UnsupportedOperationException` if the $coll is empty.
|
||||
*/
|
||||
def init: Repr = {
|
||||
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
||||
var lst = head
|
||||
var follow = false
|
||||
val b = newBuilder
|
||||
b.sizeHint(this, -1)
|
||||
for (x <- this.seq) {
|
||||
if (follow) b += lst
|
||||
else follow = true
|
||||
lst = x
|
||||
}
|
||||
b.result
|
||||
}
|
||||
|
||||
def take(n: Int): Repr = slice(0, n)
|
||||
|
||||
def drop(n: Int): Repr =
|
||||
if (n <= 0) {
|
||||
val b = newBuilder
|
||||
b.sizeHint(this)
|
||||
b ++= thisCollection result
|
||||
}
|
||||
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
||||
|
||||
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
||||
|
||||
// Precondition: from >= 0, until > 0, builder already configured for building.
|
||||
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
||||
var i = 0
|
||||
breakable {
|
||||
for (x <- this.seq) {
|
||||
if (i >= from) b += x
|
||||
i += 1
|
||||
if (i >= until) break
|
||||
}
|
||||
}
|
||||
b.result
|
||||
}
|
||||
// Precondition: from >= 0
|
||||
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
||||
val b = newBuilder
|
||||
if (until <= from) b.result
|
||||
else {
|
||||
b.sizeHint(this, delta)
|
||||
sliceInternal(from, until, b)
|
||||
}
|
||||
}
|
||||
// Precondition: from >= 0
|
||||
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
||||
val b = newBuilder
|
||||
if (until <= from) b.result
|
||||
else {
|
||||
b.sizeHintBounded(until - from, this)
|
||||
sliceInternal(from, until, b)
|
||||
}
|
||||
}
|
||||
|
||||
def takeWhile(p: A => Boolean): Repr = {
|
||||
val b = newBuilder
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
if (!p(x)) break
|
||||
b += x
|
||||
}
|
||||
}
|
||||
b.result
|
||||
}
|
||||
|
||||
def dropWhile(p: A => Boolean): Repr = {
|
||||
val b = newBuilder
|
||||
var go = false
|
||||
for (x <- this) {
|
||||
if (!p(x)) go = true
|
||||
if (go) b += x
|
||||
}
|
||||
b.result
|
||||
}
|
||||
|
||||
def span(p: A => Boolean): (Repr, Repr) = {
|
||||
val l, r = newBuilder
|
||||
var toLeft = true
|
||||
for (x <- this) {
|
||||
toLeft = toLeft && p(x)
|
||||
(if (toLeft) l else r) += x
|
||||
}
|
||||
(l.result, r.result)
|
||||
}
|
||||
|
||||
def splitAt(n: Int): (Repr, Repr) = {
|
||||
val l, r = newBuilder
|
||||
l.sizeHintBounded(n, this)
|
||||
if (n >= 0) r.sizeHint(this, -n)
|
||||
var i = 0
|
||||
for (x <- this) {
|
||||
(if (i < n) l else r) += x
|
||||
i += 1
|
||||
}
|
||||
(l.result, r.result)
|
||||
}
|
||||
|
||||
/** Iterates over the tails of this $coll. The first value will be this
|
||||
* $coll and the final one will be an empty $coll, with the intervening
|
||||
* values the results of successive applications of `tail`.
|
||||
*
|
||||
* @return an iterator over all the tails of this $coll
|
||||
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
||||
*/
|
||||
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
||||
|
||||
/** Iterates over the inits of this $coll. The first value will be this
|
||||
* $coll and the final one will be an empty $coll, with the intervening
|
||||
* values the results of successive applications of `init`.
|
||||
*
|
||||
* @return an iterator over all the inits of this $coll
|
||||
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
||||
*/
|
||||
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
||||
|
||||
/** Copies elements of this $coll to an array.
|
||||
* Fills the given array `xs` with at most `len` elements of
|
||||
* this $coll, starting at position `start`.
|
||||
* Copying will stop once either the end of the current $coll is reached,
|
||||
* or the end of the array is reached, or `len` elements have been copied.
|
||||
*
|
||||
* $willNotTerminateInf
|
||||
*
|
||||
* @param xs the array to fill.
|
||||
* @param start the starting index.
|
||||
* @param len the maximal number of elements to copy.
|
||||
* @tparam B the type of the elements of the array.
|
||||
*
|
||||
*
|
||||
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
||||
*/
|
||||
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
||||
var i = start
|
||||
val end = (start + len) min xs.length
|
||||
breakable {
|
||||
for (x <- this) {
|
||||
if (i >= end) break
|
||||
xs(i) = x
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def toTraversable: Traversable[A] = thisCollection
|
||||
def toIterator: Iterator[A] = toStream.iterator
|
||||
def toStream: Stream[A] = toBuffer.toStream
|
||||
|
||||
/** Converts this $coll to a string.
|
||||
*
|
||||
* @return a string representation of this collection. By default this
|
||||
* string consists of the `stringPrefix` of this $coll,
|
||||
* followed by all elements separated by commas and enclosed in parentheses.
|
||||
*/
|
||||
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
||||
|
||||
/** Defines the prefix of this object's `toString` representation.
|
||||
*
|
||||
* @return a string representation which starts the result of `toString`
|
||||
* applied to this $coll. By default the string prefix is the
|
||||
* simple name of the collection class $coll.
|
||||
*/
|
||||
def stringPrefix : String = {
|
||||
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
||||
val idx1 = string.lastIndexOf('.' : Int)
|
||||
if (idx1 != -1) string = string.substring(idx1 + 1)
|
||||
val idx2 = string.indexOf('$')
|
||||
if (idx2 != -1) string = string.substring(0, idx2)
|
||||
string
|
||||
}
|
||||
|
||||
/** Creates a non-strict view of this $coll.
|
||||
*
|
||||
* @return a non-strict view of this $coll.
|
||||
*/
|
||||
def view = new TraversableView[A, Repr] {
|
||||
protected lazy val underlying = self.repr
|
||||
override def foreach[U](f: A => U) = self foreach f
|
||||
}
|
||||
|
||||
/** Creates a non-strict view of a slice of this $coll.
|
||||
*
|
||||
* Note: the difference between `view` and `slice` is that `view` produces
|
||||
* a view of the current $coll, whereas `slice` produces a new $coll.
|
||||
*
|
||||
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
||||
* $orderDependent
|
||||
*
|
||||
* @param from the index of the first element of the view
|
||||
* @param until the index of the element following the view
|
||||
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
||||
* and extending up to (but not including) index `until`.
|
||||
*/
|
||||
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
||||
|
||||
/** Creates a non-strict filter of this $coll.
|
||||
*
|
||||
* Note: the difference between `c filter p` and `c withFilter p` is that
|
||||
* the former creates a new collection, whereas the latter only
|
||||
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
||||
* and `withFilter` operations.
|
||||
* $orderDependent
|
||||
*
|
||||
* @param p the predicate used to test elements.
|
||||
* @return an object of class `WithFilter`, which supports
|
||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
||||
* All these operations apply to those elements of this $coll which
|
||||
* satisfy the predicate `p`.
|
||||
*/
|
||||
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
||||
|
||||
/** A class supporting filtered operations. Instances of this class are
|
||||
* returned by method `withFilter`.
|
||||
*/
|
||||
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
||||
|
||||
/** Builds a new collection by applying a function to all elements of the
|
||||
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
||||
*
|
||||
* @param f the function to apply to each element.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` resulting from applying
|
||||
* the given function `f` to each element of the outer $coll
|
||||
* that satisfies predicate `p` and collecting the results.
|
||||
*
|
||||
* @usecase def map[B](f: A => B): $Coll[B]
|
||||
*
|
||||
* @return a new $coll resulting from applying the given function
|
||||
* `f` to each element of the outer $coll that satisfies
|
||||
* predicate `p` and collecting the results.
|
||||
*/
|
||||
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- self)
|
||||
if (p(x)) b += f(x)
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Builds a new collection by applying a function to all elements of the
|
||||
* outer $coll containing this `WithFilter` instance that satisfy
|
||||
* predicate `p` and concatenating the results.
|
||||
*
|
||||
* @param f the function to apply to each element.
|
||||
* @tparam B the element type of the returned collection.
|
||||
* @tparam That $thatinfo
|
||||
* @param bf $bfinfo
|
||||
* @return a new collection of type `That` resulting from applying
|
||||
* the given collection-valued function `f` to each element
|
||||
* of the outer $coll that satisfies predicate `p` and
|
||||
* concatenating the results.
|
||||
*
|
||||
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
||||
*
|
||||
* @return a new $coll resulting from applying the given collection-valued function
|
||||
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
||||
*/
|
||||
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
||||
val b = bf(repr)
|
||||
for (x <- self)
|
||||
if (p(x)) b ++= f(x).seq
|
||||
b.result
|
||||
}
|
||||
|
||||
/** Applies a function `f` to all elements of the outer $coll containing
|
||||
* this `WithFilter` instance that satisfy predicate `p`.
|
||||
*
|
||||
* @param f the function that is applied for its side-effect to every element.
|
||||
* The result of function `f` is discarded.
|
||||
*
|
||||
* @tparam U the type parameter describing the result of function `f`.
|
||||
* This result will always be ignored. Typically `U` is `Unit`,
|
||||
* but this is not necessary.
|
||||
*
|
||||
* @usecase def foreach(f: A => Unit): Unit
|
||||
*/
|
||||
def foreach[U](f: A => U): Unit =
|
||||
for (x <- self)
|
||||
if (p(x)) f(x)
|
||||
|
||||
/** Further refines the filter for this $coll.
|
||||
*
|
||||
* @param q the predicate used to test elements.
|
||||
* @return an object of class `WithFilter`, which supports
|
||||
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
||||
* All these operations apply to those elements of this $coll which
|
||||
* satisfy the predicate `q` in addition to the predicate `p`.
|
||||
*/
|
||||
def withFilter(q: A => Boolean): WithFilter =
|
||||
new WithFilter(x => p(x) && q(x))
|
||||
}
|
||||
|
||||
// A helper for tails and inits.
|
||||
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
||||
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
||||
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</textarea>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
theme: "ambiance",
|
||||
mode: "text/x-scala"
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
207
webbuild/html/scripts/codemirror/mode/clojure/clojure.js
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
/**
|
||||
* Author: Hans Engel
|
||||
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
|
||||
*/
|
||||
CodeMirror.defineMode("clojure", function (config, mode) {
|
||||
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", TAG = "tag",
|
||||
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
|
||||
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
||||
|
||||
function makeKeywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
var atoms = makeKeywords("true false nil");
|
||||
|
||||
var keywords = makeKeywords(
|
||||
"defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
|
||||
|
||||
var builtins = makeKeywords(
|
||||
"* *1 *2 *3 *agent* *allow-unresolved-vars* *assert *clojure-version* *command-line-args* *compile-files* *compile-path* *e *err* *file* *flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* *source-path* *use-context-classloader* *warn-on-reflection* + - / < <= = == > >= accessor aclone agent agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* butlast byte byte-array bytes case cast char char-array char-escape-string char-name-string char? chars chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement concat cond condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec decimal? declare definline defmacro defmethod defmulti defn defn- defonce defstruct delay delay? deliver deref derive descendants destructure disj disj! dissoc dissoc! distinct distinct? doall doc dorun doseq dosync dotimes doto double double-array doubles drop drop-last drop-while empty empty? ensure enumeration-seq eval even? every? extend extend-protocol extend-type extends? extenders false? ffirst file-seq filter find find-doc find-ns find-var first float float-array float? floats flush fn fn? fnext for force format future future-call future-cancel future-cancelled? future-done? future? gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator hash hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc init-proxy instance? int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array make-hierarchy map map? mapcat max max-key memfn memoize merge merge-with meta method-sig methods min min-key mod name namespace neg? newline next nfirst nil? nnext not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? or parents partial partition pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers primitives-classnames print print-ctor print-doc print-dup print-method print-namespace-doc print-simple print-special-doc print-str printf println println-str prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot rand rand-int range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string reify reduce ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure release-pending-sends rem remove remove-method remove-ns repeat repeatedly replace replicate require reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? seque sequence sequential? set set-validator! set? short short-array shorts shutdown-agents slurp some sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-form-anchor special-symbol? split-at split-with str stream? string? struct struct-map subs subseq subvec supers swap! symbol symbol? sync syntax-symbol-anchor take take-last take-nth take-while test the-ns time to-array to-array-2d trampoline transient tree-seq true? type unchecked-add unchecked-dec unchecked-divide unchecked-inc unchecked-multiply unchecked-negate unchecked-remainder unchecked-subtract underive unquote unquote-splicing update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector? when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision xml-seq");
|
||||
|
||||
var indentKeys = makeKeywords(
|
||||
// Built-ins
|
||||
"ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type try catch " +
|
||||
|
||||
// Binding forms
|
||||
"let letfn binding loop for doseq dotimes when-let if-let " +
|
||||
|
||||
// Data structures
|
||||
"defstruct struct-map assoc " +
|
||||
|
||||
// clojure.test
|
||||
"testing deftest " +
|
||||
|
||||
// contrib
|
||||
"handler-case handle dotrace deftrace");
|
||||
|
||||
var tests = {
|
||||
digit: /\d/,
|
||||
digit_or_colon: /[\d:]/,
|
||||
hex: /[0-9a-fA-F]/,
|
||||
sign: /[+-]/,
|
||||
exponent: /[eE]/,
|
||||
keyword_char: /[^\s\(\[\;\)\]]/,
|
||||
basic: /[\w\$_\-]/,
|
||||
lang_keyword: /[\w*+!\-_?:\/]/
|
||||
};
|
||||
|
||||
function stateStack(indent, type, prev) { // represents a state stack object
|
||||
this.indent = indent;
|
||||
this.type = type;
|
||||
this.prev = prev;
|
||||
}
|
||||
|
||||
function pushStack(state, indent, type) {
|
||||
state.indentStack = new stateStack(indent, type, state.indentStack);
|
||||
}
|
||||
|
||||
function popStack(state) {
|
||||
state.indentStack = state.indentStack.prev;
|
||||
}
|
||||
|
||||
function isNumber(ch, stream){
|
||||
// hex
|
||||
if ( ch === '0' && 'x' == stream.peek().toLowerCase() ) {
|
||||
stream.eat('x');
|
||||
stream.eatWhile(tests.hex);
|
||||
return true;
|
||||
}
|
||||
|
||||
// leading sign
|
||||
if ( ch == '+' || ch == '-' ) {
|
||||
stream.eat(tests.sign);
|
||||
ch = stream.next();
|
||||
}
|
||||
|
||||
if ( tests.digit.test(ch) ) {
|
||||
stream.eat(ch);
|
||||
stream.eatWhile(tests.digit);
|
||||
|
||||
if ( '.' == stream.peek() ) {
|
||||
stream.eat('.');
|
||||
stream.eatWhile(tests.digit);
|
||||
}
|
||||
|
||||
if ( 'e' == stream.peek().toLowerCase() ) {
|
||||
stream.eat(tests.exponent);
|
||||
stream.eat(tests.sign);
|
||||
stream.eatWhile(tests.digit);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function () {
|
||||
return {
|
||||
indentStack: null,
|
||||
indentation: 0,
|
||||
mode: false
|
||||
};
|
||||
},
|
||||
|
||||
token: function (stream, state) {
|
||||
if (state.indentStack == null && stream.sol()) {
|
||||
// update indentation, but only if indentStack is empty
|
||||
state.indentation = stream.indentation();
|
||||
}
|
||||
|
||||
// skip spaces
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
var returnType = null;
|
||||
|
||||
switch(state.mode){
|
||||
case "string": // multi-line string parsing mode
|
||||
var next, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == "\"" && !escaped) {
|
||||
|
||||
state.mode = false;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
returnType = STRING; // continue on in string mode
|
||||
break;
|
||||
default: // default parsing mode
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch == "\"") {
|
||||
state.mode = "string";
|
||||
returnType = STRING;
|
||||
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
|
||||
returnType = ATOM;
|
||||
} else if (ch == ";") { // comment
|
||||
stream.skipToEnd(); // rest of the line is a comment
|
||||
returnType = COMMENT;
|
||||
} else if (isNumber(ch,stream)){
|
||||
returnType = NUMBER;
|
||||
} else if (ch == "(" || ch == "[") {
|
||||
var keyWord = '', indentTemp = stream.column(), letter;
|
||||
/**
|
||||
Either
|
||||
(indent-word ..
|
||||
(non-indent-word ..
|
||||
(;something else, bracket, etc.
|
||||
*/
|
||||
|
||||
if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
|
||||
keyWord += letter;
|
||||
}
|
||||
|
||||
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
||||
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
||||
} else { // non-indent word
|
||||
// we continue eating the spaces
|
||||
stream.eatSpace();
|
||||
if (stream.eol() || stream.peek() == ";") {
|
||||
// nothing significant after
|
||||
// we restart indentation 1 space after
|
||||
pushStack(state, indentTemp + 1, ch);
|
||||
} else {
|
||||
pushStack(state, indentTemp + stream.current().length, ch); // else we match
|
||||
}
|
||||
}
|
||||
stream.backUp(stream.current().length - 1); // undo all the eating
|
||||
|
||||
returnType = BRACKET;
|
||||
} else if (ch == ")" || ch == "]") {
|
||||
returnType = BRACKET;
|
||||
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
||||
popStack(state);
|
||||
}
|
||||
} else if ( ch == ":" ) {
|
||||
stream.eatWhile(tests.lang_keyword);
|
||||
return ATOM;
|
||||
} else {
|
||||
stream.eatWhile(tests.basic);
|
||||
|
||||
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
||||
returnType = KEYWORD;
|
||||
} else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
|
||||
returnType = BUILTIN;
|
||||
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
|
||||
returnType = ATOM;
|
||||
} else returnType = null;
|
||||
}
|
||||
}
|
||||
|
||||
return returnType;
|
||||
},
|
||||
|
||||
indent: function (state, textAfter) {
|
||||
if (state.indentStack == null) return state.indentation;
|
||||
return state.indentStack.indent;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-clojure", "clojure");
|
67
webbuild/html/scripts/codemirror/mode/clojure/index.html
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: Clojure mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="clojure.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Clojure mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
; Conway's Game of Life, based on the work of:
|
||||
;; Laurent Petit https://gist.github.com/1200343
|
||||
;; Christophe Grand http://clj-me.cgrand.net/2011/08/19/conways-game-of-life
|
||||
|
||||
(ns ^{:doc "Conway's Game of Life."}
|
||||
game-of-life)
|
||||
|
||||
;; Core game of life's algorithm functions
|
||||
|
||||
(defn neighbours
|
||||
"Given a cell's coordinates, returns the coordinates of its neighbours."
|
||||
[[x y]]
|
||||
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])]
|
||||
[(+ dx x) (+ dy y)]))
|
||||
|
||||
(defn step
|
||||
"Given a set of living cells, computes the new set of living cells."
|
||||
[cells]
|
||||
(set (for [[cell n] (frequencies (mapcat neighbours cells))
|
||||
:when (or (= n 3) (and (= n 2) (cells cell)))]
|
||||
cell)))
|
||||
|
||||
;; Utility methods for displaying game on a text terminal
|
||||
|
||||
(defn print-board
|
||||
"Prints a board on *out*, representing a step in the game."
|
||||
[board w h]
|
||||
(doseq [x (range (inc w)) y (range (inc h))]
|
||||
(if (= y 0) (print "\n"))
|
||||
(print (if (board [x y]) "[X]" " . "))))
|
||||
|
||||
(defn display-grids
|
||||
"Prints a squence of boards on *out*, representing several steps."
|
||||
[grids w h]
|
||||
(doseq [board grids]
|
||||
(print-board board w h)
|
||||
(print "\n")))
|
||||
|
||||
;; Launches an example board
|
||||
|
||||
(def
|
||||
^{:doc "board represents the initial set of living cells"}
|
||||
board #{[2 1] [2 2] [2 3]})
|
||||
|
||||
(display-grids (take 3 (iterate step board)) 5 5) </textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-clojure</code>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
22
webbuild/html/scripts/codemirror/mode/coffeescript/LICENSE
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2011 Jeff Pickhardt
|
||||
Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
346
webbuild/html/scripts/codemirror/mode/coffeescript/coffeescript.js
vendored
Normal file
@ -0,0 +1,346 @@
|
||||
/**
|
||||
* Link to the project's GitHub page:
|
||||
* https://github.com/pickhardt/coffeescript-codemirror-mode
|
||||
*/
|
||||
CodeMirror.defineMode('coffeescript', function(conf) {
|
||||
var ERRORCLASS = 'error';
|
||||
|
||||
function wordRegexp(words) {
|
||||
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
||||
}
|
||||
|
||||
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\?]");
|
||||
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\},:`=;\\.]');
|
||||
var doubleOperators = new RegExp("^((\->)|(\=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))");
|
||||
var doubleDelimiters = new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
||||
var tripleDelimiters = new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))");
|
||||
var identifiers = new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*");
|
||||
var properties = new RegExp("^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*");
|
||||
|
||||
var wordOperators = wordRegexp(['and', 'or', 'not',
|
||||
'is', 'isnt', 'in',
|
||||
'instanceof', 'typeof']);
|
||||
var indentKeywords = ['for', 'while', 'loop', 'if', 'unless', 'else',
|
||||
'switch', 'try', 'catch', 'finally', 'class'];
|
||||
var commonKeywords = ['break', 'by', 'continue', 'debugger', 'delete',
|
||||
'do', 'in', 'of', 'new', 'return', 'then',
|
||||
'this', 'throw', 'when', 'until'];
|
||||
|
||||
var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
|
||||
|
||||
indentKeywords = wordRegexp(indentKeywords);
|
||||
|
||||
|
||||
var stringPrefixes = new RegExp("^('{3}|\"{3}|['\"])");
|
||||
var regexPrefixes = new RegExp("^(/{3}|/)");
|
||||
var commonConstants = ['Infinity', 'NaN', 'undefined', 'null', 'true', 'false', 'on', 'off', 'yes', 'no'];
|
||||
var constants = wordRegexp(commonConstants);
|
||||
|
||||
// Tokenizers
|
||||
function tokenBase(stream, state) {
|
||||
// Handle scope changes
|
||||
if (stream.sol()) {
|
||||
var scopeOffset = state.scopes[0].offset;
|
||||
if (stream.eatSpace()) {
|
||||
var lineOffset = stream.indentation();
|
||||
if (lineOffset > scopeOffset) {
|
||||
return 'indent';
|
||||
} else if (lineOffset < scopeOffset) {
|
||||
return 'dedent';
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if (scopeOffset > 0) {
|
||||
dedent(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ch = stream.peek();
|
||||
|
||||
// Handle docco title comment (single line)
|
||||
if (stream.match("####")) {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
// Handle multi line comments
|
||||
if (stream.match("###")) {
|
||||
state.tokenize = longComment;
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
// Single line comment
|
||||
if (ch === '#') {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
// Handle number literals
|
||||
if (stream.match(/^-?[0-9\.]/, false)) {
|
||||
var floatLiteral = false;
|
||||
// Floats
|
||||
if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) {
|
||||
floatLiteral = true;
|
||||
}
|
||||
if (stream.match(/^-?\d+\.\d*/)) {
|
||||
floatLiteral = true;
|
||||
}
|
||||
if (stream.match(/^-?\.\d+/)) {
|
||||
floatLiteral = true;
|
||||
}
|
||||
|
||||
if (floatLiteral) {
|
||||
// prevent from getting extra . on 1..
|
||||
if (stream.peek() == "."){
|
||||
stream.backUp(1);
|
||||
}
|
||||
return 'number';
|
||||
}
|
||||
// Integers
|
||||
var intLiteral = false;
|
||||
// Hex
|
||||
if (stream.match(/^-?0x[0-9a-f]+/i)) {
|
||||
intLiteral = true;
|
||||
}
|
||||
// Decimal
|
||||
if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) {
|
||||
intLiteral = true;
|
||||
}
|
||||
// Zero by itself with no other piece of number.
|
||||
if (stream.match(/^-?0(?![\dx])/i)) {
|
||||
intLiteral = true;
|
||||
}
|
||||
if (intLiteral) {
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle strings
|
||||
if (stream.match(stringPrefixes)) {
|
||||
state.tokenize = tokenFactory(stream.current(), 'string');
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
// Handle regex literals
|
||||
if (stream.match(regexPrefixes)) {
|
||||
if (stream.current() != '/' || stream.match(/^.*\//, false)) { // prevent highlight of division
|
||||
state.tokenize = tokenFactory(stream.current(), 'string-2');
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
stream.backUp(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle operators and delimiters
|
||||
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
|
||||
return 'punctuation';
|
||||
}
|
||||
if (stream.match(doubleOperators)
|
||||
|| stream.match(singleOperators)
|
||||
|| stream.match(wordOperators)) {
|
||||
return 'operator';
|
||||
}
|
||||
if (stream.match(singleDelimiters)) {
|
||||
return 'punctuation';
|
||||
}
|
||||
|
||||
if (stream.match(constants)) {
|
||||
return 'atom';
|
||||
}
|
||||
|
||||
if (stream.match(keywords)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
return 'variable';
|
||||
}
|
||||
|
||||
if (stream.match(properties)) {
|
||||
return 'property';
|
||||
}
|
||||
|
||||
// Handle non-detected items
|
||||
stream.next();
|
||||
return ERRORCLASS;
|
||||
}
|
||||
|
||||
function tokenFactory(delimiter, outclass) {
|
||||
var singleline = delimiter.length == 1;
|
||||
return function tokenString(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^'"\/\\]/);
|
||||
if (stream.eat('\\')) {
|
||||
stream.next();
|
||||
if (singleline && stream.eol()) {
|
||||
return outclass;
|
||||
}
|
||||
} else if (stream.match(delimiter)) {
|
||||
state.tokenize = tokenBase;
|
||||
return outclass;
|
||||
} else {
|
||||
stream.eat(/['"\/]/);
|
||||
}
|
||||
}
|
||||
if (singleline) {
|
||||
if (conf.mode.singleLineStringErrors) {
|
||||
outclass = ERRORCLASS;
|
||||
} else {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
}
|
||||
return outclass;
|
||||
};
|
||||
}
|
||||
|
||||
function longComment(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^#]/);
|
||||
if (stream.match("###")) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
stream.eatWhile("#");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function indent(stream, state, type) {
|
||||
type = type || 'coffee';
|
||||
var indentUnit = 0;
|
||||
if (type === 'coffee') {
|
||||
for (var i = 0; i < state.scopes.length; i++) {
|
||||
if (state.scopes[i].type === 'coffee') {
|
||||
indentUnit = state.scopes[i].offset + conf.indentUnit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
indentUnit = stream.column() + stream.current().length;
|
||||
}
|
||||
state.scopes.unshift({
|
||||
offset: indentUnit,
|
||||
type: type
|
||||
});
|
||||
}
|
||||
|
||||
function dedent(stream, state) {
|
||||
if (state.scopes.length == 1) return;
|
||||
if (state.scopes[0].type === 'coffee') {
|
||||
var _indent = stream.indentation();
|
||||
var _indent_index = -1;
|
||||
for (var i = 0; i < state.scopes.length; ++i) {
|
||||
if (_indent === state.scopes[i].offset) {
|
||||
_indent_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_indent_index === -1) {
|
||||
return true;
|
||||
}
|
||||
while (state.scopes[0].offset !== _indent) {
|
||||
state.scopes.shift();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
state.scopes.shift();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
// Handle '.' connected identifiers
|
||||
if (current === '.') {
|
||||
style = state.tokenize(stream, state);
|
||||
current = stream.current();
|
||||
if (style === 'variable') {
|
||||
return 'variable';
|
||||
} else {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle scope changes.
|
||||
if (current === 'return') {
|
||||
state.dedent += 1;
|
||||
}
|
||||
if (((current === '->' || current === '=>') &&
|
||||
!state.lambda &&
|
||||
state.scopes[0].type == 'coffee' &&
|
||||
stream.peek() === '')
|
||||
|| style === 'indent') {
|
||||
indent(stream, state);
|
||||
}
|
||||
var delimiter_index = '[({'.indexOf(current);
|
||||
if (delimiter_index !== -1) {
|
||||
indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1));
|
||||
}
|
||||
if (indentKeywords.exec(current)){
|
||||
indent(stream, state);
|
||||
}
|
||||
if (current == 'then'){
|
||||
dedent(stream, state);
|
||||
}
|
||||
|
||||
|
||||
if (style === 'dedent') {
|
||||
if (dedent(stream, state)) {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
delimiter_index = '])}'.indexOf(current);
|
||||
if (delimiter_index !== -1) {
|
||||
if (dedent(stream, state)) {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'coffee') {
|
||||
if (state.scopes.length > 1) state.scopes.shift();
|
||||
state.dedent -= 1;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
var external = {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
scopes: [{offset:basecolumn || 0, type:'coffee'}],
|
||||
lastToken: null,
|
||||
lambda: false,
|
||||
dedent: 0
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var style = tokenLexer(stream, state);
|
||||
|
||||
state.lastToken = {style:style, content: stream.current()};
|
||||
|
||||
if (stream.eol() && stream.lambda) {
|
||||
state.lambda = false;
|
||||
}
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return state.scopes[0].offset;
|
||||
}
|
||||
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript');
|
728
webbuild/html/scripts/codemirror/mode/coffeescript/index.html
vendored
Normal file
@ -0,0 +1,728 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: CoffeeScript mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="coffeescript.js"></script>
|
||||
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: CoffeeScript mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
# CoffeeScript mode for CodeMirror
|
||||
# Copyright (c) 2011 Jeff Pickhardt, released under
|
||||
# the MIT License.
|
||||
#
|
||||
# Modified from the Python CodeMirror mode, which also is
|
||||
# under the MIT License Copyright (c) 2010 Timothy Farrell.
|
||||
#
|
||||
# The following script, Underscore.coffee, is used to
|
||||
# demonstrate CoffeeScript mode for CodeMirror.
|
||||
#
|
||||
# To download CoffeeScript mode for CodeMirror, go to:
|
||||
# https://github.com/pickhardt/coffeescript-codemirror-mode
|
||||
|
||||
# **Underscore.coffee
|
||||
# (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
|
||||
# Underscore is freely distributable under the terms of the
|
||||
# [MIT license](http://en.wikipedia.org/wiki/MIT_License).
|
||||
# Portions of Underscore are inspired by or borrowed from
|
||||
# [Prototype.js](http://prototypejs.org/api), Oliver Steele's
|
||||
# [Functional](http://osteele.com), and John Resig's
|
||||
# [Micro-Templating](http://ejohn.org).
|
||||
# For all details and documentation:
|
||||
# http://documentcloud.github.com/underscore/
|
||||
|
||||
|
||||
# Baseline setup
|
||||
# --------------
|
||||
|
||||
# Establish the root object, `window` in the browser, or `global` on the server.
|
||||
root = this
|
||||
|
||||
|
||||
# Save the previous value of the `_` variable.
|
||||
previousUnderscore = root._
|
||||
|
||||
### Multiline
|
||||
comment
|
||||
###
|
||||
|
||||
# Establish the object that gets thrown to break out of a loop iteration.
|
||||
# `StopIteration` is SOP on Mozilla.
|
||||
breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
|
||||
|
||||
|
||||
#### Docco style single line comment (title)
|
||||
|
||||
|
||||
# Helper function to escape **RegExp** contents, because JS doesn't have one.
|
||||
escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
|
||||
|
||||
|
||||
# Save bytes in the minified (but not gzipped) version:
|
||||
ArrayProto = Array.prototype
|
||||
ObjProto = Object.prototype
|
||||
|
||||
|
||||
# Create quick reference variables for speed access to core prototypes.
|
||||
slice = ArrayProto.slice
|
||||
unshift = ArrayProto.unshift
|
||||
toString = ObjProto.toString
|
||||
hasOwnProperty = ObjProto.hasOwnProperty
|
||||
propertyIsEnumerable = ObjProto.propertyIsEnumerable
|
||||
|
||||
|
||||
# All **ECMA5** native implementations we hope to use are declared here.
|
||||
nativeForEach = ArrayProto.forEach
|
||||
nativeMap = ArrayProto.map
|
||||
nativeReduce = ArrayProto.reduce
|
||||
nativeReduceRight = ArrayProto.reduceRight
|
||||
nativeFilter = ArrayProto.filter
|
||||
nativeEvery = ArrayProto.every
|
||||
nativeSome = ArrayProto.some
|
||||
nativeIndexOf = ArrayProto.indexOf
|
||||
nativeLastIndexOf = ArrayProto.lastIndexOf
|
||||
nativeIsArray = Array.isArray
|
||||
nativeKeys = Object.keys
|
||||
|
||||
|
||||
# Create a safe reference to the Underscore object for use below.
|
||||
_ = (obj) -> new wrapper(obj)
|
||||
|
||||
|
||||
# Export the Underscore object for **CommonJS**.
|
||||
if typeof(exports) != 'undefined' then exports._ = _
|
||||
|
||||
|
||||
# Export Underscore to global scope.
|
||||
root._ = _
|
||||
|
||||
|
||||
# Current version.
|
||||
_.VERSION = '1.1.0'
|
||||
|
||||
|
||||
# Collection Functions
|
||||
# --------------------
|
||||
|
||||
# The cornerstone, an **each** implementation.
|
||||
# Handles objects implementing **forEach**, arrays, and raw objects.
|
||||
_.each = (obj, iterator, context) ->
|
||||
try
|
||||
if nativeForEach and obj.forEach is nativeForEach
|
||||
obj.forEach iterator, context
|
||||
else if _.isNumber obj.length
|
||||
iterator.call context, obj[i], i, obj for i in [0...obj.length]
|
||||
else
|
||||
iterator.call context, val, key, obj for own key, val of obj
|
||||
catch e
|
||||
throw e if e isnt breaker
|
||||
obj
|
||||
|
||||
|
||||
# Return the results of applying the iterator to each element. Use JavaScript
|
||||
# 1.6's version of **map**, if possible.
|
||||
_.map = (obj, iterator, context) ->
|
||||
return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
|
||||
results = []
|
||||
_.each obj, (value, index, list) ->
|
||||
results.push iterator.call context, value, index, list
|
||||
results
|
||||
|
||||
|
||||
# **Reduce** builds up a single result from a list of values. Also known as
|
||||
# **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
|
||||
_.reduce = (obj, iterator, memo, context) ->
|
||||
if nativeReduce and obj.reduce is nativeReduce
|
||||
iterator = _.bind iterator, context if context
|
||||
return obj.reduce iterator, memo
|
||||
_.each obj, (value, index, list) ->
|
||||
memo = iterator.call context, memo, value, index, list
|
||||
memo
|
||||
|
||||
|
||||
# The right-associative version of **reduce**, also known as **foldr**. Uses
|
||||
# JavaScript 1.8's version of **reduceRight**, if available.
|
||||
_.reduceRight = (obj, iterator, memo, context) ->
|
||||
if nativeReduceRight and obj.reduceRight is nativeReduceRight
|
||||
iterator = _.bind iterator, context if context
|
||||
return obj.reduceRight iterator, memo
|
||||
reversed = _.clone(_.toArray(obj)).reverse()
|
||||
_.reduce reversed, iterator, memo, context
|
||||
|
||||
|
||||
# Return the first value which passes a truth test.
|
||||
_.detect = (obj, iterator, context) ->
|
||||
result = null
|
||||
_.each obj, (value, index, list) ->
|
||||
if iterator.call context, value, index, list
|
||||
result = value
|
||||
_.breakLoop()
|
||||
result
|
||||
|
||||
|
||||
# Return all the elements that pass a truth test. Use JavaScript 1.6's
|
||||
# **filter**, if it exists.
|
||||
_.filter = (obj, iterator, context) ->
|
||||
return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
|
||||
results = []
|
||||
_.each obj, (value, index, list) ->
|
||||
results.push value if iterator.call context, value, index, list
|
||||
results
|
||||
|
||||
|
||||
# Return all the elements for which a truth test fails.
|
||||
_.reject = (obj, iterator, context) ->
|
||||
results = []
|
||||
_.each obj, (value, index, list) ->
|
||||
results.push value if not iterator.call context, value, index, list
|
||||
results
|
||||
|
||||
|
||||
# Determine whether all of the elements match a truth test. Delegate to
|
||||
# JavaScript 1.6's **every**, if it is present.
|
||||
_.every = (obj, iterator, context) ->
|
||||
iterator ||= _.identity
|
||||
return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
|
||||
result = true
|
||||
_.each obj, (value, index, list) ->
|
||||
_.breakLoop() unless (result = result and iterator.call(context, value, index, list))
|
||||
result
|
||||
|
||||
|
||||
# Determine if at least one element in the object matches a truth test. Use
|
||||
# JavaScript 1.6's **some**, if it exists.
|
||||
_.some = (obj, iterator, context) ->
|
||||
iterator ||= _.identity
|
||||
return obj.some iterator, context if nativeSome and obj.some is nativeSome
|
||||
result = false
|
||||
_.each obj, (value, index, list) ->
|
||||
_.breakLoop() if (result = iterator.call(context, value, index, list))
|
||||
result
|
||||
|
||||
|
||||
# Determine if a given value is included in the array or object,
|
||||
# based on `===`.
|
||||
_.include = (obj, target) ->
|
||||
return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
|
||||
return true for own key, val of obj when val is target
|
||||
false
|
||||
|
||||
|
||||
# Invoke a method with arguments on every item in a collection.
|
||||
_.invoke = (obj, method) ->
|
||||
args = _.rest arguments, 2
|
||||
(if method then val[method] else val).apply(val, args) for val in obj
|
||||
|
||||
|
||||
# Convenience version of a common use case of **map**: fetching a property.
|
||||
_.pluck = (obj, key) ->
|
||||
_.map(obj, (val) -> val[key])
|
||||
|
||||
|
||||
# Return the maximum item or (item-based computation).
|
||||
_.max = (obj, iterator, context) ->
|
||||
return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
|
||||
result = computed: -Infinity
|
||||
_.each obj, (value, index, list) ->
|
||||
computed = if iterator then iterator.call(context, value, index, list) else value
|
||||
computed >= result.computed and (result = {value: value, computed: computed})
|
||||
result.value
|
||||
|
||||
|
||||
# Return the minimum element (or element-based computation).
|
||||
_.min = (obj, iterator, context) ->
|
||||
return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
|
||||
result = computed: Infinity
|
||||
_.each obj, (value, index, list) ->
|
||||
computed = if iterator then iterator.call(context, value, index, list) else value
|
||||
computed < result.computed and (result = {value: value, computed: computed})
|
||||
result.value
|
||||
|
||||
|
||||
# Sort the object's values by a criterion produced by an iterator.
|
||||
_.sortBy = (obj, iterator, context) ->
|
||||
_.pluck(((_.map obj, (value, index, list) ->
|
||||
{value: value, criteria: iterator.call(context, value, index, list)}
|
||||
).sort((left, right) ->
|
||||
a = left.criteria; b = right.criteria
|
||||
if a < b then -1 else if a > b then 1 else 0
|
||||
)), 'value')
|
||||
|
||||
|
||||
# Use a comparator function to figure out at what index an object should
|
||||
# be inserted so as to maintain order. Uses binary search.
|
||||
_.sortedIndex = (array, obj, iterator) ->
|
||||
iterator ||= _.identity
|
||||
low = 0
|
||||
high = array.length
|
||||
while low < high
|
||||
mid = (low + high) >> 1
|
||||
if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
|
||||
low
|
||||
|
||||
|
||||
# Convert anything iterable into a real, live array.
|
||||
_.toArray = (iterable) ->
|
||||
return [] if (!iterable)
|
||||
return iterable.toArray() if (iterable.toArray)
|
||||
return iterable if (_.isArray(iterable))
|
||||
return slice.call(iterable) if (_.isArguments(iterable))
|
||||
_.values(iterable)
|
||||
|
||||
|
||||
# Return the number of elements in an object.
|
||||
_.size = (obj) -> _.toArray(obj).length
|
||||
|
||||
|
||||
# Array Functions
|
||||
# ---------------
|
||||
|
||||
# Get the first element of an array. Passing `n` will return the first N
|
||||
# values in the array. Aliased as **head**. The `guard` check allows it to work
|
||||
# with **map**.
|
||||
_.first = (array, n, guard) ->
|
||||
if n and not guard then slice.call(array, 0, n) else array[0]
|
||||
|
||||
|
||||
# Returns everything but the first entry of the array. Aliased as **tail**.
|
||||
# Especially useful on the arguments object. Passing an `index` will return
|
||||
# the rest of the values in the array from that index onward. The `guard`
|
||||
# check allows it to work with **map**.
|
||||
_.rest = (array, index, guard) ->
|
||||
slice.call(array, if _.isUndefined(index) or guard then 1 else index)
|
||||
|
||||
|
||||
# Get the last element of an array.
|
||||
_.last = (array) -> array[array.length - 1]
|
||||
|
||||
|
||||
# Trim out all falsy values from an array.
|
||||
_.compact = (array) -> item for item in array when item
|
||||
|
||||
|
||||
# Return a completely flattened version of an array.
|
||||
_.flatten = (array) ->
|
||||
_.reduce array, (memo, value) ->
|
||||
return memo.concat(_.flatten(value)) if _.isArray value
|
||||
memo.push value
|
||||
memo
|
||||
, []
|
||||
|
||||
|
||||
# Return a version of the array that does not contain the specified value(s).
|
||||
_.without = (array) ->
|
||||
values = _.rest arguments
|
||||
val for val in _.toArray(array) when not _.include values, val
|
||||
|
||||
|
||||
# Produce a duplicate-free version of the array. If the array has already
|
||||
# been sorted, you have the option of using a faster algorithm.
|
||||
_.uniq = (array, isSorted) ->
|
||||
memo = []
|
||||
for el, i in _.toArray array
|
||||
memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
|
||||
memo
|
||||
|
||||
|
||||
# Produce an array that contains every item shared between all the
|
||||
# passed-in arrays.
|
||||
_.intersect = (array) ->
|
||||
rest = _.rest arguments
|
||||
_.select _.uniq(array), (item) ->
|
||||
_.all rest, (other) ->
|
||||
_.indexOf(other, item) >= 0
|
||||
|
||||
|
||||
# Zip together multiple lists into a single array -- elements that share
|
||||
# an index go together.
|
||||
_.zip = ->
|
||||
length = _.max _.pluck arguments, 'length'
|
||||
results = new Array length
|
||||
for i in [0...length]
|
||||
results[i] = _.pluck arguments, String i
|
||||
results
|
||||
|
||||
|
||||
# If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
|
||||
# we need this function. Return the position of the first occurrence of an
|
||||
# item in an array, or -1 if the item is not included in the array.
|
||||
_.indexOf = (array, item) ->
|
||||
return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
|
||||
i = 0; l = array.length
|
||||
while l - i
|
||||
if array[i] is item then return i else i++
|
||||
-1
|
||||
|
||||
|
||||
# Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
|
||||
# if possible.
|
||||
_.lastIndexOf = (array, item) ->
|
||||
return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
|
||||
i = array.length
|
||||
while i
|
||||
if array[i] is item then return i else i--
|
||||
-1
|
||||
|
||||
|
||||
# Generate an integer Array containing an arithmetic progression. A port of
|
||||
# [the native Python **range** function](http://docs.python.org/library/functions.html#range).
|
||||
_.range = (start, stop, step) ->
|
||||
a = arguments
|
||||
solo = a.length <= 1
|
||||
i = start = if solo then 0 else a[0]
|
||||
stop = if solo then a[0] else a[1]
|
||||
step = a[2] or 1
|
||||
len = Math.ceil((stop - start) / step)
|
||||
return [] if len <= 0
|
||||
range = new Array len
|
||||
idx = 0
|
||||
loop
|
||||
return range if (if step > 0 then i - stop else stop - i) >= 0
|
||||
range[idx] = i
|
||||
idx++
|
||||
i+= step
|
||||
|
||||
|
||||
# Function Functions
|
||||
# ------------------
|
||||
|
||||
# Create a function bound to a given object (assigning `this`, and arguments,
|
||||
# optionally). Binding with arguments is also known as **curry**.
|
||||
_.bind = (func, obj) ->
|
||||
args = _.rest arguments, 2
|
||||
-> func.apply obj or root, args.concat arguments
|
||||
|
||||
|
||||
# Bind all of an object's methods to that object. Useful for ensuring that
|
||||
# all callbacks defined on an object belong to it.
|
||||
_.bindAll = (obj) ->
|
||||
funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
|
||||
_.each funcs, (f) -> obj[f] = _.bind obj[f], obj
|
||||
obj
|
||||
|
||||
|
||||
# Delays a function for the given number of milliseconds, and then calls
|
||||
# it with the arguments supplied.
|
||||
_.delay = (func, wait) ->
|
||||
args = _.rest arguments, 2
|
||||
setTimeout((-> func.apply(func, args)), wait)
|
||||
|
||||
|
||||
# Memoize an expensive function by storing its results.
|
||||
_.memoize = (func, hasher) ->
|
||||
memo = {}
|
||||
hasher or= _.identity
|
||||
->
|
||||
key = hasher.apply this, arguments
|
||||
return memo[key] if key of memo
|
||||
memo[key] = func.apply this, arguments
|
||||
|
||||
|
||||
# Defers a function, scheduling it to run after the current call stack has
|
||||
# cleared.
|
||||
_.defer = (func) ->
|
||||
_.delay.apply _, [func, 1].concat _.rest arguments
|
||||
|
||||
|
||||
# Returns the first function passed as an argument to the second,
|
||||
# allowing you to adjust arguments, run code before and after, and
|
||||
# conditionally execute the original function.
|
||||
_.wrap = (func, wrapper) ->
|
||||
-> wrapper.apply wrapper, [func].concat arguments
|
||||
|
||||
|
||||
# Returns a function that is the composition of a list of functions, each
|
||||
# consuming the return value of the function that follows.
|
||||
_.compose = ->
|
||||
funcs = arguments
|
||||
->
|
||||
args = arguments
|
||||
for i in [funcs.length - 1..0] by -1
|
||||
args = [funcs[i].apply(this, args)]
|
||||
args[0]
|
||||
|
||||
|
||||
# Object Functions
|
||||
# ----------------
|
||||
|
||||
# Retrieve the names of an object's properties.
|
||||
_.keys = nativeKeys or (obj) ->
|
||||
return _.range 0, obj.length if _.isArray(obj)
|
||||
key for key, val of obj
|
||||
|
||||
|
||||
# Retrieve the values of an object's properties.
|
||||
_.values = (obj) ->
|
||||
_.map obj, _.identity
|
||||
|
||||
|
||||
# Return a sorted list of the function names available in Underscore.
|
||||
_.functions = (obj) ->
|
||||
_.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
|
||||
|
||||
|
||||
# Extend a given object with all of the properties in a source object.
|
||||
_.extend = (obj) ->
|
||||
for source in _.rest(arguments)
|
||||
obj[key] = val for key, val of source
|
||||
obj
|
||||
|
||||
|
||||
# Create a (shallow-cloned) duplicate of an object.
|
||||
_.clone = (obj) ->
|
||||
return obj.slice 0 if _.isArray obj
|
||||
_.extend {}, obj
|
||||
|
||||
|
||||
# Invokes interceptor with the obj, and then returns obj.
|
||||
# The primary purpose of this method is to "tap into" a method chain,
|
||||
# in order to perform operations on intermediate results within
|
||||
the chain.
|
||||
_.tap = (obj, interceptor) ->
|
||||
interceptor obj
|
||||
obj
|
||||
|
||||
|
||||
# Perform a deep comparison to check if two objects are equal.
|
||||
_.isEqual = (a, b) ->
|
||||
# Check object identity.
|
||||
return true if a is b
|
||||
# Different types?
|
||||
atype = typeof(a); btype = typeof(b)
|
||||
return false if atype isnt btype
|
||||
# Basic equality test (watch out for coercions).
|
||||
return true if `a == b`
|
||||
# One is falsy and the other truthy.
|
||||
return false if (!a and b) or (a and !b)
|
||||
# One of them implements an `isEqual()`?
|
||||
return a.isEqual(b) if a.isEqual
|
||||
# Check dates' integer values.
|
||||
return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
|
||||
# Both are NaN?
|
||||
return false if _.isNaN(a) and _.isNaN(b)
|
||||
# Compare regular expressions.
|
||||
if _.isRegExp(a) and _.isRegExp(b)
|
||||
return a.source is b.source and
|
||||
a.global is b.global and
|
||||
a.ignoreCase is b.ignoreCase and
|
||||
a.multiline is b.multiline
|
||||
# If a is not an object by this point, we can't handle it.
|
||||
return false if atype isnt 'object'
|
||||
# Check for different array lengths before comparing contents.
|
||||
return false if a.length and (a.length isnt b.length)
|
||||
# Nothing else worked, deep compare the contents.
|
||||
aKeys = _.keys(a); bKeys = _.keys(b)
|
||||
# Different object sizes?
|
||||
return false if aKeys.length isnt bKeys.length
|
||||
# Recursive comparison of contents.
|
||||
return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
|
||||
true
|
||||
|
||||
|
||||
# Is a given array or object empty?
|
||||
_.isEmpty = (obj) ->
|
||||
return obj.length is 0 if _.isArray(obj) or _.isString(obj)
|
||||
return false for own key of obj
|
||||
true
|
||||
|
||||
|
||||
# Is a given value a DOM element?
|
||||
_.isElement = (obj) -> obj and obj.nodeType is 1
|
||||
|
||||
|
||||
# Is a given value an array?
|
||||
_.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
|
||||
|
||||
|
||||
# Is a given variable an arguments object?
|
||||
_.isArguments = (obj) -> obj and obj.callee
|
||||
|
||||
|
||||
# Is the given value a function?
|
||||
_.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
|
||||
|
||||
|
||||
# Is the given value a string?
|
||||
_.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
|
||||
|
||||
|
||||
# Is a given value a number?
|
||||
_.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
|
||||
|
||||
|
||||
# Is a given value a boolean?
|
||||
_.isBoolean = (obj) -> obj is true or obj is false
|
||||
|
||||
|
||||
# Is a given value a Date?
|
||||
_.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
|
||||
|
||||
|
||||
# Is the given value a regular expression?
|
||||
_.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
|
||||
|
||||
|
||||
# Is the given value NaN -- this one is interesting. `NaN != NaN`, and
|
||||
# `isNaN(undefined) == true`, so we make sure it's a number first.
|
||||
_.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
|
||||
|
||||
|
||||
# Is a given value equal to null?
|
||||
_.isNull = (obj) -> obj is null
|
||||
|
||||
|
||||
# Is a given variable undefined?
|
||||
_.isUndefined = (obj) -> typeof obj is 'undefined'
|
||||
|
||||
|
||||
# Utility Functions
|
||||
# -----------------
|
||||
|
||||
# Run Underscore.js in noConflict mode, returning the `_` variable to its
|
||||
# previous owner. Returns a reference to the Underscore object.
|
||||
_.noConflict = ->
|
||||
root._ = previousUnderscore
|
||||
this
|
||||
|
||||
|
||||
# Keep the identity function around for default iterators.
|
||||
_.identity = (value) -> value
|
||||
|
||||
|
||||
# Run a function `n` times.
|
||||
_.times = (n, iterator, context) ->
|
||||
iterator.call context, i for i in [0...n]
|
||||
|
||||
|
||||
# Break out of the middle of an iteration.
|
||||
_.breakLoop = -> throw breaker
|
||||
|
||||
|
||||
# Add your own custom functions to the Underscore object, ensuring that
|
||||
# they're correctly added to the OOP wrapper as well.
|
||||
_.mixin = (obj) ->
|
||||
for name in _.functions(obj)
|
||||
addToWrapper name, _[name] = obj[name]
|
||||
|
||||
|
||||
# Generate a unique integer id (unique within the entire client session).
|
||||
# Useful for temporary DOM ids.
|
||||
idCounter = 0
|
||||
_.uniqueId = (prefix) ->
|
||||
(prefix or '') + idCounter++
|
||||
|
||||
|
||||
# By default, Underscore uses **ERB**-style template delimiters, change the
|
||||
# following template settings to use alternative delimiters.
|
||||
_.templateSettings = {
|
||||
start: '<%'
|
||||
end: '%>'
|
||||
interpolate: /<%=(.+?)%>/g
|
||||
}
|
||||
|
||||
|
||||
# JavaScript templating a-la **ERB**, pilfered from John Resig's
|
||||
# *Secrets of the JavaScript Ninja*, page 83.
|
||||
# Single-quote fix from Rick Strahl.
|
||||
# With alterations for arbitrary delimiters, and to preserve whitespace.
|
||||
_.template = (str, data) ->
|
||||
c = _.templateSettings
|
||||
endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
|
||||
fn = new Function 'obj',
|
||||
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
||||
'with(obj||{}){p.push(\'' +
|
||||
str.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(endMatch,"<22><><EFBFBD>")
|
||||
.split("'").join("\\'")
|
||||
.split("<22><><EFBFBD>").join("'")
|
||||
.replace(c.interpolate, "',$1,'")
|
||||
.split(c.start).join("');")
|
||||
.split(c.end).join("p.push('") +
|
||||
"');}return p.join('');"
|
||||
if data then fn(data) else fn
|
||||
|
||||
|
||||
# Aliases
|
||||
# -------
|
||||
|
||||
_.forEach = _.each
|
||||
_.foldl = _.inject = _.reduce
|
||||
_.foldr = _.reduceRight
|
||||
_.select = _.filter
|
||||
_.all = _.every
|
||||
_.any = _.some
|
||||
_.contains = _.include
|
||||
_.head = _.first
|
||||
_.tail = _.rest
|
||||
_.methods = _.functions
|
||||
|
||||
|
||||
# Setup the OOP Wrapper
|
||||
# ---------------------
|
||||
|
||||
# If Underscore is called as a function, it returns a wrapped object that
|
||||
# can be used OO-style. This wrapper holds altered versions of all the
|
||||
# underscore functions. Wrapped objects may be chained.
|
||||
wrapper = (obj) ->
|
||||
this._wrapped = obj
|
||||
this
|
||||
|
||||
|
||||
# Helper function to continue chaining intermediate results.
|
||||
result = (obj, chain) ->
|
||||
if chain then _(obj).chain() else obj
|
||||
|
||||
|
||||
# A method to easily add functions to the OOP wrapper.
|
||||
addToWrapper = (name, func) ->
|
||||
wrapper.prototype[name] = ->
|
||||
args = _.toArray arguments
|
||||
unshift.call args, this._wrapped
|
||||
result func.apply(_, args), this._chain
|
||||
|
||||
|
||||
# Add all ofthe Underscore functions to the wrapper object.
|
||||
_.mixin _
|
||||
|
||||
|
||||
# Add all mutator Array functions to the wrapper.
|
||||
_.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
|
||||
method = Array.prototype[name]
|
||||
wrapper.prototype[name] = ->
|
||||
method.apply(this._wrapped, arguments)
|
||||
result(this._wrapped, this._chain)
|
||||
|
||||
|
||||
# Add all accessor Array functions to the wrapper.
|
||||
_.each ['concat', 'join', 'slice'], (name) ->
|
||||
method = Array.prototype[name]
|
||||
wrapper.prototype[name] = ->
|
||||
result(method.apply(this._wrapped, arguments), this._chain)
|
||||
|
||||
|
||||
# Start chaining a wrapped Underscore object.
|
||||
wrapper::chain = ->
|
||||
this._chain = true
|
||||
this
|
||||
|
||||
|
||||
# Extracts the result from a wrapped and chained object.
|
||||
wrapper::value = -> this._wrapped
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
|
||||
|
||||
<p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
|
||||
|
||||
</body>
|
||||
</html>
|
174
webbuild/html/scripts/codemirror/mode/css/css.js
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
CodeMirror.defineMode("css", function(config) {
|
||||
var indentUnit = config.indentUnit, type;
|
||||
|
||||
var keywords = keySet(["above", "absolute", "activeborder", "activecaption", "afar", "after-white-space", "ahead", "alias", "all", "all-scroll",
|
||||
"alternate", "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", "arabic-indic", "armenian", "asterisks",
|
||||
"auto", "avoid", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "blink",
|
||||
"block", "block-axis", "bold", "bolder", "border", "border-box", "both", "bottom", "break-all", "break-word", "button",
|
||||
"button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian", "capitalize", "caps-lock-indicator",
|
||||
"caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic",
|
||||
"clear", "clip", "close-quote", "col-resize", "collapse", "compact", "condensed", "contain", "content", "content-box", "context-menu",
|
||||
"continuous", "copy", "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal", "decimal-leading-zero", "default",
|
||||
"default-button", "destination-atop", "destination-in", "destination-out", "destination-over", "devanagari", "disc", "discard", "document",
|
||||
"dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", "element",
|
||||
"ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", "ethiopic-abegede-am-et", "ethiopic-abegede-gez",
|
||||
"ethiopic-abegede-ti-er", "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", "ethiopic-halehame-aa-et",
|
||||
"ethiopic-halehame-am-et", "ethiopic-halehame-gez", "ethiopic-halehame-om-et", "ethiopic-halehame-sid-et",
|
||||
"ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ew-resize", "expanded",
|
||||
"extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes", "forwards", "from", "geometricPrecision",
|
||||
"georgian", "graytext", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew", "help",
|
||||
"hidden", "hide", "higher", "highlight", "highlighttext", "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
|
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", "inherit", "initial", "inline",
|
||||
"inline-axis", "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "kannada", "katakana",
|
||||
"katakana-iroha", "khmer", "landscape", "lao", "large", "larger", "left", "level", "lighter", "line-through", "linear", "lines",
|
||||
"list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", "lower-greek",
|
||||
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lower-roman", "lowercase", "ltr", "malayalam", "match", "media-controls-background",
|
||||
"media-current-time-display", "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button",
|
||||
"media-rewind-button", "media-seek-back-button", "media-seek-forward-button", "media-slider", "media-sliderthumb", "media-time-remaining-display",
|
||||
"media-volume-slider", "media-volume-slider-container", "media-volume-sliderthumb", "medium", "menu", "menulist", "menulist-button",
|
||||
"menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", "mix", "mongolian", "monospace", "move", "multiple",
|
||||
"myanmar", "n-resize", "narrower", "navy", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
|
||||
"normal", "not-allowed", "nowrap", "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote", "optimizeLegibility",
|
||||
"optimizeSpeed", "oriya", "oromo", "outset", "outside", "overlay", "overline", "padding", "padding-box", "painted", "paused",
|
||||
"persian", "plus-darker", "plus-lighter", "pointer", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress",
|
||||
"push-button", "radio", "read-only", "read-write", "read-write-plaintext-only", "relative", "repeat", "repeat-x",
|
||||
"repeat-y", "reset", "reverse", "rgb", "rgba", "ridge", "right", "round", "row-resize", "rtl", "run-in", "running", "s-resize", "sans-serif",
|
||||
"scroll", "scrollbar", "se-resize", "searchfield", "searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
|
||||
"searchfield-results-decoration", "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama", "single",
|
||||
"skip-white-space", "slide", "slider-horizontal", "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
||||
"small", "small-caps", "small-caption", "smaller", "solid", "somali", "source-atop", "source-in", "source-out", "source-over",
|
||||
"space", "square", "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", "subpixel-antialiased", "super",
|
||||
"sw-resize", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group",
|
||||
"table-row", "table-row-group", "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", "thick", "thin",
|
||||
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", "tigrinya-er-abegede",
|
||||
"tigrinya-et", "tigrinya-et-abegede", "to", "top", "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", "upper-alpha", "upper-armenian",
|
||||
"upper-greek", "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", "vertical", "vertical-text", "visible",
|
||||
"visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "white", "wider", "window", "windowframe", "windowtext",
|
||||
"x-large", "x-small", "xor", "xx-large", "xx-small", "yellow", "-wap-marquee", "-webkit-activelink", "-webkit-auto", "-webkit-baseline-middle",
|
||||
"-webkit-body", "-webkit-box", "-webkit-center", "-webkit-control", "-webkit-focus-ring-color", "-webkit-grab", "-webkit-grabbing",
|
||||
"-webkit-gradient", "-webkit-inline-box", "-webkit-left", "-webkit-link", "-webkit-marquee", "-webkit-mini-control", "-webkit-nowrap", "-webkit-pictograph",
|
||||
"-webkit-right", "-webkit-small-control", "-webkit-text", "-webkit-xxx-large", "-webkit-zoom-in", "-webkit-zoom-out"]);
|
||||
|
||||
function keySet(array) { var keys = {}; for (var i = 0; i < array.length; ++i) keys[array[i]] = true; return keys; }
|
||||
function ret(style, tp) {type = tp; return style;}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
|
||||
else if (ch == "/" && stream.eat("*")) {
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
}
|
||||
else if (ch == "<" && stream.eat("!")) {
|
||||
state.tokenize = tokenSGMLComment;
|
||||
return tokenSGMLComment(stream, state);
|
||||
}
|
||||
else if (ch == "=") ret(null, "compare");
|
||||
else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
|
||||
else if (ch == "\"" || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
else if (ch == "#") {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("atom", "hash");
|
||||
}
|
||||
else if (ch == "!") {
|
||||
stream.match(/^\s*\w*/);
|
||||
return ret("keyword", "important");
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w.%]/);
|
||||
return ret("number", "unit");
|
||||
}
|
||||
else if (/[,.+>*\/]/.test(ch)) {
|
||||
return ret(null, "select-op");
|
||||
}
|
||||
else if (/[;{}:\[\]\(\)]/.test(ch)) {
|
||||
return ret(null, ch);
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("variable", "variable");
|
||||
}
|
||||
}
|
||||
|
||||
function tokenCComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (maybeEnd && ch == "/") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenSGMLComment(stream, state) {
|
||||
var dashes = 0, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (dashes >= 2 && ch == ">") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
dashes = (ch == "-") ? dashes + 1 : 0;
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped)
|
||||
break;
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
if (!escaped) state.tokenize = tokenBase;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function(base) {
|
||||
return {tokenize: tokenBase,
|
||||
baseIndent: base || 0,
|
||||
stack: []};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
|
||||
var context = state.stack[state.stack.length-1];
|
||||
if (type == "hash" && context != "rule") style = "string-2";
|
||||
else if (style == "variable") {
|
||||
if (context == "rule") style = keywords[stream.current()] ? "keyword" : "number";
|
||||
else if (!context || context == "@media{") style = "tag";
|
||||
}
|
||||
|
||||
if (context == "rule" && /^[\{\};]$/.test(type))
|
||||
state.stack.pop();
|
||||
if (type == "{") {
|
||||
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
|
||||
else state.stack.push("{");
|
||||
}
|
||||
else if (type == "}") state.stack.pop();
|
||||
else if (type == "@media") state.stack.push("@media");
|
||||
else if (context == "{" && type != "comment") state.stack.push("rule");
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var n = state.stack.length;
|
||||
if (/^\}/.test(textAfter))
|
||||
n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
|
||||
return state.baseIndent + n * indentUnit;
|
||||
},
|
||||
|
||||
electricChars: "}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/css", "css");
|
56
webbuild/html/scripts/codemirror/mode/css/index.html
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: CSS mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: CSS mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example CSS */
|
||||
|
||||
@import url("something.css");
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
h1:before, h2:before {
|
||||
content: "::";
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: courier, monospace;
|
||||
font-size: 80%;
|
||||
color: #418A8A;
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/css</code>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
32
webbuild/html/scripts/codemirror/mode/diff/diff.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
CodeMirror.defineMode("diff", function() {
|
||||
|
||||
var TOKEN_NAMES = {
|
||||
'+': 'tag',
|
||||
'-': 'string',
|
||||
'@': 'meta'
|
||||
};
|
||||
|
||||
return {
|
||||
token: function(stream) {
|
||||
var tw_pos = stream.string.search(/[\t ]+?$/);
|
||||
|
||||
if (!stream.sol() || tw_pos === 0) {
|
||||
stream.skipToEnd();
|
||||
return ("error " + (
|
||||
TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
|
||||
}
|
||||
|
||||
var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
|
||||
|
||||
if (tw_pos === -1) {
|
||||
stream.skipToEnd();
|
||||
} else {
|
||||
stream.pos = tw_pos;
|
||||
}
|
||||
|
||||
return token_name;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-diff", "diff");
|
105
webbuild/html/scripts/codemirror/mode/diff/index.html
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: Diff mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="diff.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
|
||||
span.cm-meta {color: #a0b !important;}
|
||||
span.cm-error { background-color: black; opacity: 0.4;}
|
||||
span.cm-error.cm-string { background-color: red; }
|
||||
span.cm-error.cm-tag { background-color: #2b2; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Diff mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
diff --git a/index.html b/index.html
|
||||
index c1d9156..7764744 100644
|
||||
--- a/index.html
|
||||
+++ b/index.html
|
||||
@@ -95,7 +95,8 @@ StringStream.prototype = {
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
- autoMatchBrackets: true
|
||||
+ autoMatchBrackets: true,
|
||||
+ onGutterClick: function(x){console.log(x);}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
diff --git a/lib/codemirror.js b/lib/codemirror.js
|
||||
index 04646a9..9a39cc7 100644
|
||||
--- a/lib/codemirror.js
|
||||
+++ b/lib/codemirror.js
|
||||
@@ -399,10 +399,16 @@ var CodeMirror = (function() {
|
||||
}
|
||||
|
||||
function onMouseDown(e) {
|
||||
- var start = posFromMouse(e), last = start;
|
||||
+ var start = posFromMouse(e), last = start, target = e.target();
|
||||
if (!start) return;
|
||||
setCursor(start.line, start.ch, false);
|
||||
if (e.button() != 1) return;
|
||||
+ if (target.parentNode == gutter) {
|
||||
+ if (options.onGutterClick)
|
||||
+ options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (!focused) onFocus();
|
||||
|
||||
e.stop();
|
||||
@@ -808,7 +814,7 @@ var CodeMirror = (function() {
|
||||
for (var i = showingFrom; i < showingTo; ++i) {
|
||||
var marker = lines[i].gutterMarker;
|
||||
if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
|
||||
- else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
|
||||
+ else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
|
||||
}
|
||||
gutter.style.display = "none"; // TODO test whether this actually helps
|
||||
gutter.innerHTML = html.join("");
|
||||
@@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
|
||||
if (option == "parser") setParser(value);
|
||||
else if (option === "lineNumbers") setLineNumbers(value);
|
||||
else if (option === "gutter") setGutter(value);
|
||||
- else if (option === "readOnly") options.readOnly = value;
|
||||
- else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
|
||||
- else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
|
||||
- else throw new Error("Can't set option " + option);
|
||||
+ else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
|
||||
+ else options[option] = value;
|
||||
},
|
||||
cursorCoords: cursorCoords,
|
||||
undo: operation(undo),
|
||||
@@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
|
||||
replaceRange: operation(replaceRange),
|
||||
|
||||
operation: function(f){return operation(f)();},
|
||||
- refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
|
||||
+ refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
|
||||
+ getInputField: function(){return input;}
|
||||
};
|
||||
return instance;
|
||||
}
|
||||
@@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
|
||||
readOnly: false,
|
||||
onChange: null,
|
||||
onCursorActivity: null,
|
||||
+ onGutterClick: null,
|
||||
autoMatchBrackets: false,
|
||||
workTime: 200,
|
||||
workDelay: 300,
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
203
webbuild/html/scripts/codemirror/mode/ecl/ecl.js
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
CodeMirror.defineMode("ecl", function(config) {
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function metaHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
stream.skipToEnd();
|
||||
return "meta";
|
||||
}
|
||||
|
||||
function tokenAtString(stream, state) {
|
||||
var next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == '"' && !stream.eat('"')) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
var indentUnit = config.indentUnit;
|
||||
var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
|
||||
var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
|
||||
var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
|
||||
var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
|
||||
var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
|
||||
var blockKeywords = words("catch class do else finally for if switch try while");
|
||||
var atoms = words("true false null");
|
||||
var hooks = {"#": metaHook};
|
||||
var multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current().toLowerCase();
|
||||
if (keyword.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
} else if (variable.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "variable";
|
||||
} else if (variable_2.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "variable-2";
|
||||
} else if (variable_3.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "variable-3";
|
||||
} else if (builtin.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
} else { //Data types are of from KEYWORD##
|
||||
var i = cur.length - 1;
|
||||
while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
|
||||
--i;
|
||||
|
||||
if (i > 0) {
|
||||
var cur2 = cur.substr(0, i + 1);
|
||||
if (variable_3.propertyIsEnumerable(cur2)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
|
||||
return "variable-3";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return null;
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-ecl", "ecl");
|
42
webbuild/html/scripts/codemirror/mode/ecl/index.html
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: ECL mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="ecl.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style>.CodeMirror {border: 1px solid black;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: ECL mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
/*
|
||||
sample useless code to demonstrate ecl syntax highlighting
|
||||
this is a multiline comment!
|
||||
*/
|
||||
|
||||
// this is a singleline comment!
|
||||
|
||||
import ut;
|
||||
r :=
|
||||
record
|
||||
string22 s1 := '123';
|
||||
integer4 i1 := 123;
|
||||
end;
|
||||
#option('tmp', true);
|
||||
d := dataset('tmp::qb', r, thor);
|
||||
output(d);
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
tabMode: "indent",
|
||||
matchBrackets: true,
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
463
webbuild/html/scripts/codemirror/mode/erlang/erlang.js
vendored
Normal file
@ -0,0 +1,463 @@
|
||||
// block; "begin", "case", "fun", "if", "receive", "try": closed by "end"
|
||||
// block internal; "after", "catch", "of"
|
||||
// guard; "when", closed by "->"
|
||||
// "->" opens a clause, closed by ";" or "."
|
||||
// "<<" opens a binary, closed by ">>"
|
||||
// "," appears in arglists, lists, tuples and terminates lines of code
|
||||
// "." resets indentation to 0
|
||||
// obsolete; "cond", "let", "query"
|
||||
|
||||
CodeMirror.defineMIME("text/x-erlang", "erlang");
|
||||
|
||||
CodeMirror.defineMode("erlang", function(cmCfg, modeCfg) {
|
||||
|
||||
function rval(state,stream,type) {
|
||||
// distinguish between "." as terminator and record field operator
|
||||
if (type == "record") {
|
||||
state.context = "record";
|
||||
}else{
|
||||
state.context = false;
|
||||
}
|
||||
|
||||
// remember last significant bit on last line for indenting
|
||||
if (type != "whitespace" && type != "comment") {
|
||||
state.lastToken = stream.current();
|
||||
}
|
||||
// erlang -> CodeMirror tag
|
||||
switch (type) {
|
||||
case "atom": return "atom";
|
||||
case "attribute": return "attribute";
|
||||
case "builtin": return "builtin";
|
||||
case "comment": return "comment";
|
||||
case "fun": return "meta";
|
||||
case "function": return "tag";
|
||||
case "guard": return "property";
|
||||
case "keyword": return "keyword";
|
||||
case "macro": return "variable-2";
|
||||
case "number": return "number";
|
||||
case "operator": return "operator";
|
||||
case "record": return "bracket";
|
||||
case "string": return "string";
|
||||
case "type": return "def";
|
||||
case "variable": return "variable";
|
||||
case "error": return "error";
|
||||
case "separator": return null;
|
||||
case "open_paren": return null;
|
||||
case "close_paren": return null;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
var typeWords = [
|
||||
"-type", "-spec", "-export_type", "-opaque"];
|
||||
|
||||
var keywordWords = [
|
||||
"after","begin","catch","case","cond","end","fun","if",
|
||||
"let","of","query","receive","try","when"];
|
||||
|
||||
var separatorWords = [
|
||||
"->",";",":",".",","];
|
||||
|
||||
var operatorWords = [
|
||||
"and","andalso","band","bnot","bor","bsl","bsr","bxor",
|
||||
"div","not","or","orelse","rem","xor"];
|
||||
|
||||
var symbolWords = [
|
||||
"+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-"];
|
||||
|
||||
var openParenWords = [
|
||||
"<<","(","[","{"];
|
||||
|
||||
var closeParenWords = [
|
||||
"}","]",")",">>"];
|
||||
|
||||
var guardWords = [
|
||||
"is_atom","is_binary","is_bitstring","is_boolean","is_float",
|
||||
"is_function","is_integer","is_list","is_number","is_pid",
|
||||
"is_port","is_record","is_reference","is_tuple",
|
||||
"atom","binary","bitstring","boolean","function","integer","list",
|
||||
"number","pid","port","record","reference","tuple"];
|
||||
|
||||
var bifWords = [
|
||||
"abs","adler32","adler32_combine","alive","apply","atom_to_binary",
|
||||
"atom_to_list","binary_to_atom","binary_to_existing_atom",
|
||||
"binary_to_list","binary_to_term","bit_size","bitstring_to_list",
|
||||
"byte_size","check_process_code","contact_binary","crc32",
|
||||
"crc32_combine","date","decode_packet","delete_module",
|
||||
"disconnect_node","element","erase","exit","float","float_to_list",
|
||||
"garbage_collect","get","get_keys","group_leader","halt","hd",
|
||||
"integer_to_list","internal_bif","iolist_size","iolist_to_binary",
|
||||
"is_alive","is_atom","is_binary","is_bitstring","is_boolean",
|
||||
"is_float","is_function","is_integer","is_list","is_number","is_pid",
|
||||
"is_port","is_process_alive","is_record","is_reference","is_tuple",
|
||||
"length","link","list_to_atom","list_to_binary","list_to_bitstring",
|
||||
"list_to_existing_atom","list_to_float","list_to_integer",
|
||||
"list_to_pid","list_to_tuple","load_module","make_ref","module_loaded",
|
||||
"monitor_node","node","node_link","node_unlink","nodes","notalive",
|
||||
"now","open_port","pid_to_list","port_close","port_command",
|
||||
"port_connect","port_control","pre_loaded","process_flag",
|
||||
"process_info","processes","purge_module","put","register",
|
||||
"registered","round","self","setelement","size","spawn","spawn_link",
|
||||
"spawn_monitor","spawn_opt","split_binary","statistics",
|
||||
"term_to_binary","time","throw","tl","trunc","tuple_size",
|
||||
"tuple_to_list","unlink","unregister","whereis"];
|
||||
|
||||
// ignored for indenting purposes
|
||||
var ignoreWords = [
|
||||
",", ":", "catch", "after", "of", "cond", "let", "query"];
|
||||
|
||||
|
||||
var smallRE = /[a-z_]/;
|
||||
var largeRE = /[A-Z_]/;
|
||||
var digitRE = /[0-9]/;
|
||||
var octitRE = /[0-7]/;
|
||||
var anumRE = /[a-z_A-Z0-9]/;
|
||||
var symbolRE = /[\+\-\*\/<>=\|:]/;
|
||||
var openParenRE = /[<\(\[\{]/;
|
||||
var closeParenRE = /[>\)\]\}]/;
|
||||
var sepRE = /[\->\.,:;]/;
|
||||
|
||||
function isMember(element,list) {
|
||||
return (-1 < list.indexOf(element));
|
||||
}
|
||||
|
||||
function isPrev(stream,string) {
|
||||
var start = stream.start;
|
||||
var len = string.length;
|
||||
if (len <= start) {
|
||||
var word = stream.string.slice(start-len,start);
|
||||
return word == string;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function tokenize(stream, state) {
|
||||
if (stream.eatSpace()) {
|
||||
return rval(state,stream,"whitespace");
|
||||
}
|
||||
|
||||
// attributes and type specs
|
||||
if ((peekToken(state).token == "" || peekToken(state).token == ".") &&
|
||||
stream.peek() == '-') {
|
||||
stream.next();
|
||||
if (stream.eat(smallRE) && stream.eatWhile(anumRE)) {
|
||||
if (isMember(stream.current(),typeWords)) {
|
||||
return rval(state,stream,"type");
|
||||
}else{
|
||||
return rval(state,stream,"attribute");
|
||||
}
|
||||
}
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
|
||||
// comment
|
||||
if (ch == '%') {
|
||||
stream.skipToEnd();
|
||||
return rval(state,stream,"comment");
|
||||
}
|
||||
|
||||
// macro
|
||||
if (ch == '?') {
|
||||
stream.eatWhile(anumRE);
|
||||
return rval(state,stream,"macro");
|
||||
}
|
||||
|
||||
// record
|
||||
if ( ch == "#") {
|
||||
stream.eatWhile(anumRE);
|
||||
return rval(state,stream,"record");
|
||||
}
|
||||
|
||||
// char
|
||||
if ( ch == "$") {
|
||||
if (stream.next() == "\\") {
|
||||
if (!stream.eatWhile(octitRE)) {
|
||||
stream.next();
|
||||
}
|
||||
}
|
||||
return rval(state,stream,"string");
|
||||
}
|
||||
|
||||
// quoted atom
|
||||
if (ch == '\'') {
|
||||
if (singleQuote(stream)) {
|
||||
return rval(state,stream,"atom");
|
||||
}else{
|
||||
return rval(state,stream,"error");
|
||||
}
|
||||
}
|
||||
|
||||
// string
|
||||
if (ch == '"') {
|
||||
if (doubleQuote(stream)) {
|
||||
return rval(state,stream,"string");
|
||||
}else{
|
||||
return rval(state,stream,"error");
|
||||
}
|
||||
}
|
||||
|
||||
// variable
|
||||
if (largeRE.test(ch)) {
|
||||
stream.eatWhile(anumRE);
|
||||
return rval(state,stream,"variable");
|
||||
}
|
||||
|
||||
// atom/keyword/BIF/function
|
||||
if (smallRE.test(ch)) {
|
||||
stream.eatWhile(anumRE);
|
||||
|
||||
if (stream.peek() == "/") {
|
||||
stream.next();
|
||||
if (stream.eatWhile(digitRE)) {
|
||||
return rval(state,stream,"fun"); // f/0 style fun
|
||||
}else{
|
||||
stream.backUp(1);
|
||||
return rval(state,stream,"atom");
|
||||
}
|
||||
}
|
||||
|
||||
var w = stream.current();
|
||||
|
||||
if (isMember(w,keywordWords)) {
|
||||
pushToken(state,stream);
|
||||
return rval(state,stream,"keyword");
|
||||
}
|
||||
if (stream.peek() == "(") {
|
||||
// 'put' and 'erlang:put' are bifs, 'foo:put' is not
|
||||
if (isMember(w,bifWords) &&
|
||||
(!isPrev(stream,":") || isPrev(stream,"erlang:"))) {
|
||||
return rval(state,stream,"builtin");
|
||||
}else{
|
||||
return rval(state,stream,"function");
|
||||
}
|
||||
}
|
||||
if (isMember(w,guardWords)) {
|
||||
return rval(state,stream,"guard");
|
||||
}
|
||||
if (isMember(w,operatorWords)) {
|
||||
return rval(state,stream,"operator");
|
||||
}
|
||||
if (stream.peek() == ":") {
|
||||
if (w == "erlang") {
|
||||
return rval(state,stream,"builtin");
|
||||
} else {
|
||||
return rval(state,stream,"function");
|
||||
}
|
||||
}
|
||||
return rval(state,stream,"atom");
|
||||
}
|
||||
|
||||
// number
|
||||
if (digitRE.test(ch)) {
|
||||
stream.eatWhile(digitRE);
|
||||
if (stream.eat('#')) {
|
||||
stream.eatWhile(digitRE); // 16#10 style integer
|
||||
} else {
|
||||
if (stream.eat('.')) { // float
|
||||
stream.eatWhile(digitRE);
|
||||
}
|
||||
if (stream.eat(/[eE]/)) {
|
||||
stream.eat(/[-+]/); // float with exponent
|
||||
stream.eatWhile(digitRE);
|
||||
}
|
||||
}
|
||||
return rval(state,stream,"number"); // normal integer
|
||||
}
|
||||
|
||||
// open parens
|
||||
if (nongreedy(stream,openParenRE,openParenWords)) {
|
||||
pushToken(state,stream);
|
||||
return rval(state,stream,"open_paren");
|
||||
}
|
||||
|
||||
// close parens
|
||||
if (nongreedy(stream,closeParenRE,closeParenWords)) {
|
||||
pushToken(state,stream);
|
||||
return rval(state,stream,"close_paren");
|
||||
}
|
||||
|
||||
// separators
|
||||
if (greedy(stream,sepRE,separatorWords)) {
|
||||
// distinguish between "." as terminator and record field operator
|
||||
if (state.context == false) {
|
||||
pushToken(state,stream);
|
||||
}
|
||||
return rval(state,stream,"separator");
|
||||
}
|
||||
|
||||
// operators
|
||||
if (greedy(stream,symbolRE,symbolWords)) {
|
||||
return rval(state,stream,"operator");
|
||||
}
|
||||
|
||||
return rval(state,stream,null);
|
||||
}
|
||||
|
||||
function nongreedy(stream,re,words) {
|
||||
if (stream.current().length == 1 && re.test(stream.current())) {
|
||||
stream.backUp(1);
|
||||
while (re.test(stream.peek())) {
|
||||
stream.next();
|
||||
if (isMember(stream.current(),words)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
stream.backUp(stream.current().length-1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function greedy(stream,re,words) {
|
||||
if (stream.current().length == 1 && re.test(stream.current())) {
|
||||
while (re.test(stream.peek())) {
|
||||
stream.next();
|
||||
}
|
||||
while (0 < stream.current().length) {
|
||||
if (isMember(stream.current(),words)) {
|
||||
return true;
|
||||
}else{
|
||||
stream.backUp(1);
|
||||
}
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function doubleQuote(stream) {
|
||||
return quote(stream, '"', '\\');
|
||||
}
|
||||
|
||||
function singleQuote(stream) {
|
||||
return quote(stream,'\'','\\');
|
||||
}
|
||||
|
||||
function quote(stream,quoteChar,escapeChar) {
|
||||
while (!stream.eol()) {
|
||||
var ch = stream.next();
|
||||
if (ch == quoteChar) {
|
||||
return true;
|
||||
}else if (ch == escapeChar) {
|
||||
stream.next();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function Token(stream) {
|
||||
this.token = stream ? stream.current() : "";
|
||||
this.column = stream ? stream.column() : 0;
|
||||
this.indent = stream ? stream.indentation() : 0;
|
||||
}
|
||||
|
||||
function myIndent(state,textAfter) {
|
||||
var indent = cmCfg.indentUnit;
|
||||
var outdentWords = ["after","catch"];
|
||||
var token = (peekToken(state)).token;
|
||||
var wordAfter = takewhile(textAfter,/[^a-z]/);
|
||||
|
||||
if (isMember(token,openParenWords)) {
|
||||
return (peekToken(state)).column+token.length;
|
||||
}else if (token == "." || token == ""){
|
||||
return 0;
|
||||
}else if (token == "->") {
|
||||
if (wordAfter == "end") {
|
||||
return peekToken(state,2).column;
|
||||
}else if (peekToken(state,2).token == "fun") {
|
||||
return peekToken(state,2).column+indent;
|
||||
}else{
|
||||
return (peekToken(state)).indent+indent;
|
||||
}
|
||||
}else if (isMember(wordAfter,outdentWords)) {
|
||||
return (peekToken(state)).indent;
|
||||
}else{
|
||||
return (peekToken(state)).column+indent;
|
||||
}
|
||||
}
|
||||
|
||||
function takewhile(str,re) {
|
||||
var m = str.match(re);
|
||||
return m ? str.slice(0,m.index) : str;
|
||||
}
|
||||
|
||||
function popToken(state) {
|
||||
return state.tokenStack.pop();
|
||||
}
|
||||
|
||||
function peekToken(state,depth) {
|
||||
var len = state.tokenStack.length;
|
||||
var dep = (depth ? depth : 1);
|
||||
if (len < dep) {
|
||||
return new Token;
|
||||
}else{
|
||||
return state.tokenStack[len-dep];
|
||||
}
|
||||
}
|
||||
|
||||
function pushToken(state,stream) {
|
||||
var token = stream.current();
|
||||
var prev_token = peekToken(state).token;
|
||||
if (isMember(token,ignoreWords)) {
|
||||
return false;
|
||||
}else if (drop_both(prev_token,token)) {
|
||||
popToken(state);
|
||||
return false;
|
||||
}else if (drop_first(prev_token,token)) {
|
||||
popToken(state);
|
||||
return pushToken(state,stream);
|
||||
}else{
|
||||
state.tokenStack.push(new Token(stream));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function drop_first(open, close) {
|
||||
switch (open+" "+close) {
|
||||
case "when ->": return true;
|
||||
case "-> end": return true;
|
||||
case "-> .": return true;
|
||||
case ". .": return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
function drop_both(open, close) {
|
||||
switch (open+" "+close) {
|
||||
case "( )": return true;
|
||||
case "[ ]": return true;
|
||||
case "{ }": return true;
|
||||
case "<< >>": return true;
|
||||
case "begin end": return true;
|
||||
case "case end": return true;
|
||||
case "fun end": return true;
|
||||
case "if end": return true;
|
||||
case "receive end": return true;
|
||||
case "try end": return true;
|
||||
case "-> ;": return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState:
|
||||
function() {
|
||||
return {tokenStack: [],
|
||||
context: false,
|
||||
lastToken: null};
|
||||
},
|
||||
|
||||
token:
|
||||
function(stream, state) {
|
||||
return tokenize(stream, state);
|
||||
},
|
||||
|
||||
indent:
|
||||
function(state, textAfter) {
|
||||
// console.log(state.tokenStack);
|
||||
return myIndent(state,textAfter);
|
||||
}
|
||||
};
|
||||
});
|
63
webbuild/html/scripts/codemirror/mode/erlang/index.html
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: Erlang mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="erlang.js"></script>
|
||||
<link rel="stylesheet" href="../../theme/erlang-dark.css">
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Erlang mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
%% -*- mode: erlang; erlang-indent-level: 2 -*-
|
||||
%%% Created : 7 May 2012 by mats cronqvist <masse@klarna.com>
|
||||
|
||||
%% @doc
|
||||
%% Demonstrates how to print a record.
|
||||
%% @end
|
||||
|
||||
-module('ex').
|
||||
-author('mats cronqvist').
|
||||
-export([demo/0,
|
||||
rec_info/1]).
|
||||
|
||||
-record(demo,{a="One",b="Two",c="Three",d="Four"}).
|
||||
|
||||
rec_info(demo) -> record_info(fields,demo).
|
||||
|
||||
demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
|
||||
|
||||
expand_recs(M,List) when is_list(List) ->
|
||||
[expand_recs(M,L)||L<-List];
|
||||
expand_recs(M,Tup) when is_tuple(Tup) ->
|
||||
case tuple_size(Tup) of
|
||||
L when L < 1 -> Tup;
|
||||
L ->
|
||||
try Fields = M:rec_info(element(1,Tup)),
|
||||
L = length(Fields)+1,
|
||||
lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
|
||||
catch _:_ ->
|
||||
list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
|
||||
end
|
||||
end;
|
||||
expand_recs(_,Term) ->
|
||||
Term.
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
extraKeys: {"Tab": "indentAuto"},
|
||||
theme: "erlang-dark"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
|
||||
</body>
|
||||
</html>
|
145
webbuild/html/scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
CodeMirror.defineMode("gfm", function(config, parserConfig) {
|
||||
var mdMode = CodeMirror.getMode(config, "markdown");
|
||||
var aliases = {
|
||||
html: "htmlmixed",
|
||||
js: "javascript",
|
||||
json: "application/json",
|
||||
c: "text/x-csrc",
|
||||
"c++": "text/x-c++src",
|
||||
java: "text/x-java",
|
||||
csharp: "text/x-csharp",
|
||||
"c#": "text/x-csharp"
|
||||
};
|
||||
|
||||
// make this lazy so that we don't need to load GFM last
|
||||
var getMode = (function () {
|
||||
var i, modes = {}, mimes = {}, mime;
|
||||
|
||||
var list = CodeMirror.listModes();
|
||||
for (i = 0; i < list.length; i++) {
|
||||
modes[list[i]] = list[i];
|
||||
}
|
||||
var mimesList = CodeMirror.listMIMEs();
|
||||
for (i = 0; i < mimesList.length; i++) {
|
||||
mime = mimesList[i].mime;
|
||||
mimes[mime] = mimesList[i].mime;
|
||||
}
|
||||
|
||||
for (var a in aliases) {
|
||||
if (aliases[a] in modes || aliases[a] in mimes)
|
||||
modes[a] = aliases[a];
|
||||
}
|
||||
|
||||
return function (lang) {
|
||||
return modes[lang] ? CodeMirror.getMode(config, modes[lang]) : null;
|
||||
};
|
||||
}());
|
||||
|
||||
function markdown(stream, state) {
|
||||
// intercept fenced code blocks
|
||||
if (stream.sol() && stream.match(/^```([\w+#]*)/)) {
|
||||
// try switching mode
|
||||
state.localMode = getMode(RegExp.$1);
|
||||
if (state.localMode)
|
||||
state.localState = state.localMode.startState();
|
||||
|
||||
state.token = local;
|
||||
return 'code';
|
||||
}
|
||||
|
||||
return mdMode.token(stream, state.mdState);
|
||||
}
|
||||
|
||||
function local(stream, state) {
|
||||
if (stream.sol() && stream.match(/^```/)) {
|
||||
state.localMode = state.localState = null;
|
||||
state.token = markdown;
|
||||
return 'code';
|
||||
}
|
||||
else if (state.localMode) {
|
||||
return state.localMode.token(stream, state.localState);
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
return 'code';
|
||||
}
|
||||
}
|
||||
|
||||
// custom handleText to prevent emphasis in the middle of a word
|
||||
// and add autolinking
|
||||
function handleText(stream, mdState) {
|
||||
var match;
|
||||
if (stream.match(/^\w+:\/\/\S+/)) {
|
||||
return 'link';
|
||||
}
|
||||
if (stream.match(/^[^\[*\\<>` _][^\[*\\<>` ]*[^\[*\\<>` _]/)) {
|
||||
return mdMode.getType(mdState);
|
||||
}
|
||||
if (match = stream.match(/^[^\[*\\<>` ]+/)) {
|
||||
var word = match[0];
|
||||
if (word[0] === '_' && word[word.length-1] === '_') {
|
||||
stream.backUp(word.length);
|
||||
return undefined;
|
||||
}
|
||||
return mdMode.getType(mdState);
|
||||
}
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
var mdState = mdMode.startState();
|
||||
mdState.text = handleText;
|
||||
return {token: markdown, mode: "markdown", mdState: mdState,
|
||||
localMode: null, localState: null};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
return {token: state.token, mode: state.mode, mdState: CodeMirror.copyState(mdMode, state.mdState),
|
||||
localMode: state.localMode,
|
||||
localState: state.localMode ? CodeMirror.copyState(state.localMode, state.localState) : null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
/* Parse GFM double bracket links */
|
||||
var ch;
|
||||
if ((ch = stream.peek()) != undefined && ch == '[') {
|
||||
stream.next(); // Advance the stream
|
||||
|
||||
/* Only handle double bracket links */
|
||||
if ((ch = stream.peek()) == undefined || ch != '[') {
|
||||
stream.backUp(1);
|
||||
return state.token(stream, state);
|
||||
}
|
||||
|
||||
while ((ch = stream.next()) != undefined && ch != ']') {}
|
||||
|
||||
if (ch == ']' && (ch = stream.next()) != undefined && ch == ']')
|
||||
return 'link';
|
||||
|
||||
/* If we did not find the second ']' */
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
/* Match GFM latex formulas, as well as latex formulas within '$' */
|
||||
if (stream.match(/^\$[^\$]+\$/)) {
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (stream.match(/^\\\((.*?)\\\)/)) {
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (stream.match(/^\$\$[^\$]+\$\$/)) {
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (stream.match(/^\\\[(.*?)\\\]/)) {
|
||||
return "string";
|
||||
}
|
||||
|
||||
return state.token(stream, state);
|
||||
}
|
||||
};
|
||||
}, "markdown");
|
48
webbuild/html/scripts/codemirror/mode/gfm/index.html
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: GFM mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../markdown/markdown.js"></script>
|
||||
<script src="gfm.js"></script>
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<link rel="stylesheet" href="../markdown/markdown.css">
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: GFM mode</h1>
|
||||
|
||||
<!-- source: http://daringfireball.net/projects/markdown/basics.text -->
|
||||
<form><textarea id="code" name="code">
|
||||
Github Flavored Markdown
|
||||
========================
|
||||
|
||||
Everything from markdown plus GFM features:
|
||||
|
||||
## Fenced code blocks
|
||||
|
||||
```javascript
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
console.log(items[i], i); // log them
|
||||
}
|
||||
```
|
||||
|
||||
See http://github.github.com/github-flavored-markdown/
|
||||
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: 'gfm',
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
theme: "default"
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
170
webbuild/html/scripts/codemirror/mode/go/go.js
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
CodeMirror.defineMode("go", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
|
||||
var keywords = {
|
||||
"break":true, "case":true, "chan":true, "const":true, "continue":true,
|
||||
"default":true, "defer":true, "else":true, "fallthrough":true, "for":true,
|
||||
"func":true, "go":true, "goto":true, "if":true, "import":true,
|
||||
"interface":true, "map":true, "package":true, "range":true, "return":true,
|
||||
"select":true, "struct":true, "switch":true, "type":true, "var":true,
|
||||
"bool":true, "byte":true, "complex64":true, "complex128":true,
|
||||
"float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
|
||||
"int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
|
||||
"uint64":true, "int":true, "uint":true, "uintptr":true
|
||||
};
|
||||
|
||||
var atoms = {
|
||||
"true":true, "false":true, "iota":true, "nil":true, "append":true,
|
||||
"cap":true, "close":true, "complex":true, "copy":true, "imag":true,
|
||||
"len":true, "make":true, "new":true, "panic":true, "print":true,
|
||||
"println":true, "real":true, "recover":true
|
||||
};
|
||||
|
||||
var blockKeywords = {
|
||||
"else":true, "for":true, "func":true, "if":true, "interface":true,
|
||||
"select":true, "struct":true, "switch":true
|
||||
};
|
||||
|
||||
var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'" || ch == "`") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\d\.]/.test(ch)) {
|
||||
if (ch == ".") {
|
||||
stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
|
||||
} else if (ch == "0") {
|
||||
stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
|
||||
} else {
|
||||
stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
|
||||
}
|
||||
return "number";
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (cur == "case" || cur == "default") curPunc = "case";
|
||||
return "keyword";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || quote == "`"))
|
||||
state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
if (ctx.type == "case") ctx.type = "}";
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "case") ctx.type = "case";
|
||||
else if (curPunc == "}" && ctx.type == "}") ctx = popContext(state);
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
|
||||
state.context.type = "}";
|
||||
return ctx.indented;
|
||||
}
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}:"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-go", "go");
|
73
webbuild/html/scripts/codemirror/mode/go/index.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: Go mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/elegant.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="go.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Go mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
// Prime Sieve in Go.
|
||||
// Taken from the Go specification.
|
||||
// Copyright © The Go Authors.
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Send the sequence 2, 3, 4, ... to channel 'ch'.
|
||||
func generate(ch chan<- int) {
|
||||
for i := 2; ; i++ {
|
||||
ch <- i // Send 'i' to channel 'ch'
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the values from channel 'src' to channel 'dst',
|
||||
// removing those divisible by 'prime'.
|
||||
func filter(src <-chan int, dst chan<- int, prime int) {
|
||||
for i := range src { // Loop over values received from 'src'.
|
||||
if i%prime != 0 {
|
||||
dst <- i // Send 'i' to channel 'dst'.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The prime sieve: Daisy-chain filter processes together.
|
||||
func sieve() {
|
||||
ch := make(chan int) // Create a new channel.
|
||||
go generate(ch) // Start generate() as a subprocess.
|
||||
for {
|
||||
prime := <-ch
|
||||
fmt.Print(prime, "\n")
|
||||
ch1 := make(chan int)
|
||||
go filter(ch, ch1, prime)
|
||||
ch = ch1
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
sieve()
|
||||
}
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
theme: "elegant",
|
||||
matchBrackets: true,
|
||||
indentUnit: 8,
|
||||
tabSize: 8,
|
||||
indentWithTabs: true,
|
||||
mode: "text/x-go"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME type:</strong> <code>text/x-go</code></p>
|
||||
</body>
|
||||
</html>
|
210
webbuild/html/scripts/codemirror/mode/groovy/groovy.js
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
CodeMirror.defineMode("groovy", function(config, parserConfig) {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var keywords = words(
|
||||
"abstract as assert boolean break byte case catch char class const continue def default " +
|
||||
"do double else enum extends final finally float for goto if implements import in " +
|
||||
"instanceof int interface long native new package private protected public return " +
|
||||
"short static strictfp super switch synchronized threadsafe throw throws transient " +
|
||||
"try void volatile while");
|
||||
var blockKeywords = words("catch class do else finally for if switch try while enum interface def");
|
||||
var atoms = words("null true false this");
|
||||
|
||||
var curPunc;
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'") {
|
||||
return startString(ch, stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
if (stream.eat(/eE/)) { stream.eat(/\+\-/); stream.eatWhile(/\d/); }
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize.push(tokenComment);
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
if (expectExpression(state.lastToken)) {
|
||||
return startString(ch, stream, state);
|
||||
}
|
||||
}
|
||||
if (ch == "-" && stream.eat(">")) {
|
||||
curPunc = "->";
|
||||
return null;
|
||||
}
|
||||
if (/[+\-*&%=<>!?|\/~]/.test(ch)) {
|
||||
stream.eatWhile(/[+\-*&%=<>|~]/);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
if (ch == "@") { stream.eatWhile(/[\w\$_\.]/); return "meta"; }
|
||||
if (state.lastToken == ".") return "property";
|
||||
if (stream.eat(":")) { curPunc = "proplabel"; return "property"; }
|
||||
var cur = stream.current();
|
||||
if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
return "variable";
|
||||
}
|
||||
tokenBase.isBase = true;
|
||||
|
||||
function startString(quote, stream, state) {
|
||||
var tripleQuoted = false;
|
||||
if (quote != "/" && stream.eat(quote)) {
|
||||
if (stream.eat(quote)) tripleQuoted = true;
|
||||
else return "string";
|
||||
}
|
||||
function t(stream, state) {
|
||||
var escaped = false, next, end = !tripleQuoted;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {
|
||||
if (!tripleQuoted) { break; }
|
||||
if (stream.match(quote + quote)) { end = true; break; }
|
||||
}
|
||||
if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
|
||||
state.tokenize.push(tokenBaseUntilBrace());
|
||||
return "string";
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end) state.tokenize.pop();
|
||||
return "string";
|
||||
}
|
||||
state.tokenize.push(t);
|
||||
return t(stream, state);
|
||||
}
|
||||
|
||||
function tokenBaseUntilBrace() {
|
||||
var depth = 1;
|
||||
function t(stream, state) {
|
||||
if (stream.peek() == "}") {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
state.tokenize.pop();
|
||||
return state.tokenize[state.tokenize.length-1](stream, state);
|
||||
}
|
||||
} else if (stream.peek() == "{") {
|
||||
depth++;
|
||||
}
|
||||
return tokenBase(stream, state);
|
||||
}
|
||||
t.isBase = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize.pop();
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function expectExpression(last) {
|
||||
return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
|
||||
last == "newstatement" || last == "keyword" || last == "proplabel";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: [tokenBase],
|
||||
context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true,
|
||||
lastToken: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
// Automatic semicolon insertion
|
||||
if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
|
||||
popContext(state); ctx = state.context;
|
||||
}
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = state.tokenize[state.tokenize.length-1](stream, state);
|
||||
if (style == "comment") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
// Handle indentation for {x -> \n ... }
|
||||
else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
|
||||
popContext(state);
|
||||
state.context.align = false;
|
||||
}
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
state.lastToken = curPunc || style;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (!state.tokenize[state.tokenize.length-1].isBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
|
||||
if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : config.indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-groovy", "groovy");
|
72
webbuild/html/scripts/codemirror/mode/groovy/index.html
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: Groovy mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="groovy.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Groovy mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
//Pattern for groovy script
|
||||
def p = ~/.*\.groovy/
|
||||
new File( 'd:\\scripts' ).eachFileMatch(p) {f ->
|
||||
// imports list
|
||||
def imports = []
|
||||
f.eachLine {
|
||||
// condition to detect an import instruction
|
||||
ln -> if ( ln =~ '^import .*' ) {
|
||||
imports << "${ln - 'import '}"
|
||||
}
|
||||
}
|
||||
// print thmen
|
||||
if ( ! imports.empty ) {
|
||||
println f
|
||||
imports.each{ println " $it" }
|
||||
}
|
||||
}
|
||||
|
||||
/* Coin changer demo code from http://groovy.codehaus.org */
|
||||
|
||||
enum UsCoin {
|
||||
quarter(25), dime(10), nickel(5), penny(1)
|
||||
UsCoin(v) { value = v }
|
||||
final value
|
||||
}
|
||||
|
||||
enum OzzieCoin {
|
||||
fifty(50), twenty(20), ten(10), five(5)
|
||||
OzzieCoin(v) { value = v }
|
||||
final value
|
||||
}
|
||||
|
||||
def plural(word, count) {
|
||||
if (count == 1) return word
|
||||
word[-1] == 'y' ? word[0..-2] + "ies" : word + "s"
|
||||
}
|
||||
|
||||
def change(currency, amount) {
|
||||
currency.values().inject([]){ list, coin ->
|
||||
int count = amount / coin.value
|
||||
amount = amount % coin.value
|
||||
list += "$count ${plural(coin.toString(), count)}"
|
||||
}
|
||||
}
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-groovy"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-groovy</code></p>
|
||||
</body>
|
||||
</html>
|
242
webbuild/html/scripts/codemirror/mode/haskell/haskell.js
vendored
Normal file
@ -0,0 +1,242 @@
|
||||
CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
||||
|
||||
function switchState(source, setState, f) {
|
||||
setState(f);
|
||||
return f(source, setState);
|
||||
}
|
||||
|
||||
// These should all be Unicode extended, as per the Haskell 2010 report
|
||||
var smallRE = /[a-z_]/;
|
||||
var largeRE = /[A-Z]/;
|
||||
var digitRE = /[0-9]/;
|
||||
var hexitRE = /[0-9A-Fa-f]/;
|
||||
var octitRE = /[0-7]/;
|
||||
var idRE = /[a-z_A-Z0-9']/;
|
||||
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
|
||||
var specialRE = /[(),;[\]`{}]/;
|
||||
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
|
||||
|
||||
function normal(source, setState) {
|
||||
if (source.eatWhile(whiteCharRE)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ch = source.next();
|
||||
if (specialRE.test(ch)) {
|
||||
if (ch == '{' && source.eat('-')) {
|
||||
var t = "comment";
|
||||
if (source.eat('#')) {
|
||||
t = "meta";
|
||||
}
|
||||
return switchState(source, setState, ncomment(t, 1));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ch == '\'') {
|
||||
if (source.eat('\\')) {
|
||||
source.next(); // should handle other escapes here
|
||||
}
|
||||
else {
|
||||
source.next();
|
||||
}
|
||||
if (source.eat('\'')) {
|
||||
return "string";
|
||||
}
|
||||
return "error";
|
||||
}
|
||||
|
||||
if (ch == '"') {
|
||||
return switchState(source, setState, stringLiteral);
|
||||
}
|
||||
|
||||
if (largeRE.test(ch)) {
|
||||
source.eatWhile(idRE);
|
||||
if (source.eat('.')) {
|
||||
return "qualifier";
|
||||
}
|
||||
return "variable-2";
|
||||
}
|
||||
|
||||
if (smallRE.test(ch)) {
|
||||
source.eatWhile(idRE);
|
||||
return "variable";
|
||||
}
|
||||
|
||||
if (digitRE.test(ch)) {
|
||||
if (ch == '0') {
|
||||
if (source.eat(/[xX]/)) {
|
||||
source.eatWhile(hexitRE); // should require at least 1
|
||||
return "integer";
|
||||
}
|
||||
if (source.eat(/[oO]/)) {
|
||||
source.eatWhile(octitRE); // should require at least 1
|
||||
return "number";
|
||||
}
|
||||
}
|
||||
source.eatWhile(digitRE);
|
||||
var t = "number";
|
||||
if (source.eat('.')) {
|
||||
t = "number";
|
||||
source.eatWhile(digitRE); // should require at least 1
|
||||
}
|
||||
if (source.eat(/[eE]/)) {
|
||||
t = "number";
|
||||
source.eat(/[-+]/);
|
||||
source.eatWhile(digitRE); // should require at least 1
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
if (symbolRE.test(ch)) {
|
||||
if (ch == '-' && source.eat(/-/)) {
|
||||
source.eatWhile(/-/);
|
||||
if (!source.eat(symbolRE)) {
|
||||
source.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
var t = "variable";
|
||||
if (ch == ':') {
|
||||
t = "variable-2";
|
||||
}
|
||||
source.eatWhile(symbolRE);
|
||||
return t;
|
||||
}
|
||||
|
||||
return "error";
|
||||
}
|
||||
|
||||
function ncomment(type, nest) {
|
||||
if (nest == 0) {
|
||||
return normal;
|
||||
}
|
||||
return function(source, setState) {
|
||||
var currNest = nest;
|
||||
while (!source.eol()) {
|
||||
var ch = source.next();
|
||||
if (ch == '{' && source.eat('-')) {
|
||||
++currNest;
|
||||
}
|
||||
else if (ch == '-' && source.eat('}')) {
|
||||
--currNest;
|
||||
if (currNest == 0) {
|
||||
setState(normal);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(ncomment(type, currNest));
|
||||
return type;
|
||||
};
|
||||
}
|
||||
|
||||
function stringLiteral(source, setState) {
|
||||
while (!source.eol()) {
|
||||
var ch = source.next();
|
||||
if (ch == '"') {
|
||||
setState(normal);
|
||||
return "string";
|
||||
}
|
||||
if (ch == '\\') {
|
||||
if (source.eol() || source.eat(whiteCharRE)) {
|
||||
setState(stringGap);
|
||||
return "string";
|
||||
}
|
||||
if (source.eat('&')) {
|
||||
}
|
||||
else {
|
||||
source.next(); // should handle other escapes here
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(normal);
|
||||
return "error";
|
||||
}
|
||||
|
||||
function stringGap(source, setState) {
|
||||
if (source.eat('\\')) {
|
||||
return switchState(source, setState, stringLiteral);
|
||||
}
|
||||
source.next();
|
||||
setState(normal);
|
||||
return "error";
|
||||
}
|
||||
|
||||
|
||||
var wellKnownWords = (function() {
|
||||
var wkw = {};
|
||||
function setType(t) {
|
||||
return function () {
|
||||
for (var i = 0; i < arguments.length; i++)
|
||||
wkw[arguments[i]] = t;
|
||||
};
|
||||
}
|
||||
|
||||
setType("keyword")(
|
||||
"case", "class", "data", "default", "deriving", "do", "else", "foreign",
|
||||
"if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
|
||||
"module", "newtype", "of", "then", "type", "where", "_");
|
||||
|
||||
setType("keyword")(
|
||||
"\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
|
||||
|
||||
setType("builtin")(
|
||||
"!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
|
||||
"==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
|
||||
|
||||
setType("builtin")(
|
||||
"Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
|
||||
"False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
|
||||
"IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left",
|
||||
"Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
|
||||
"ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
|
||||
"String", "True");
|
||||
|
||||
setType("builtin")(
|
||||
"abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
|
||||
"asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
|
||||
"compare", "concat", "concatMap", "const", "cos", "cosh", "curry",
|
||||
"cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either",
|
||||
"elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo",
|
||||
"enumFromTo", "error", "even", "exp", "exponent", "fail", "filter",
|
||||
"flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap",
|
||||
"foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger",
|
||||
"fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents",
|
||||
"getLine", "head", "id", "init", "interact", "ioError", "isDenormalized",
|
||||
"isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last",
|
||||
"lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map",
|
||||
"mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound",
|
||||
"minimum", "mod", "negate", "not", "notElem", "null", "odd", "or",
|
||||
"otherwise", "pi", "pred", "print", "product", "properFraction",
|
||||
"putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile",
|
||||
"readIO", "readList", "readLn", "readParen", "reads", "readsPrec",
|
||||
"realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse",
|
||||
"round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq",
|
||||
"sequence", "sequence_", "show", "showChar", "showList", "showParen",
|
||||
"showString", "shows", "showsPrec", "significand", "signum", "sin",
|
||||
"sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum",
|
||||
"tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger",
|
||||
"toRational", "truncate", "uncurry", "undefined", "unlines", "until",
|
||||
"unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
|
||||
"zip3", "zipWith", "zipWith3");
|
||||
|
||||
return wkw;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
return {
|
||||
startState: function () { return { f: normal }; },
|
||||
copyState: function (s) { return { f: s.f }; },
|
||||
|
||||
token: function(stream, state) {
|
||||
var t = state.f(stream, function(s) { state.f = s; });
|
||||
var w = stream.current();
|
||||
return (w in wellKnownWords) ? wellKnownWords[w] : t;
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-haskell", "haskell");
|
61
webbuild/html/scripts/codemirror/mode/haskell/index.html
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CodeMirror: Haskell mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="haskell.js"></script>
|
||||
<link rel="stylesheet" href="../../theme/elegant.css">
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Haskell mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
module UniquePerms (
|
||||
uniquePerms
|
||||
)
|
||||
where
|
||||
|
||||
-- | Find all unique permutations of a list where there might be duplicates.
|
||||
uniquePerms :: (Eq a) => [a] -> [[a]]
|
||||
uniquePerms = permBag . makeBag
|
||||
|
||||
-- | An unordered collection where duplicate values are allowed,
|
||||
-- but represented with a single value and a count.
|
||||
type Bag a = [(a, Int)]
|
||||
|
||||
makeBag :: (Eq a) => [a] -> Bag a
|
||||
makeBag [] = []
|
||||
makeBag (a:as) = mix a $ makeBag as
|
||||
where
|
||||
mix a [] = [(a,1)]
|
||||
mix a (bn@(b,n):bs) | a == b = (b,n+1):bs
|
||||
| otherwise = bn : mix a bs
|
||||
|
||||
permBag :: Bag a -> [[a]]
|
||||
permBag [] = [[]]
|
||||
permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs
|
||||
where
|
||||
oneOfEach [] = []
|
||||
oneOfEach (an@(a,n):bs) =
|
||||
let bs' = if n == 1 then bs else (a,n-1):bs
|
||||
in (a,bs') : mapSnd (an:) (oneOfEach bs)
|
||||
|
||||
apSnd f (a,b) = (a, f b)
|
||||
mapSnd = map . apSnd
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
theme: "elegant"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p>
|
||||
</body>
|
||||
</html>
|