Commit ecb5e674 authored by Oskar Skog's avatar Oskar Skog

Pre 0.1.19: Tidying of Makefile

parent 5069ec27
......@@ -11,3 +11,6 @@ Info.plist
check.py
anonymine-wrapper
anonymine.desktop
enginecfg.out
mkenginecfg.py
2016-02-26 Oskar Skog <[email protected]>
0.1.19
*: Removed vm-README.md, update-anonymine, vmsetup and addplayer.
* calibrate-anonymine: Repurposed and renamed to mkenginecfg.
* Makefile.static:
- Use mkenginecfg
- Split up `all` and use Makefile properly.
- Move quotes from variable definitions to rules.
- mkenginecfg and check.sh should be in PKG_NOCONV.
- Added $(info) as a shutupable wrapper for verbose messages.
(Not the gmake function.)
* check.sh: Fixed to choose the appropriate enginecfg.
* INSTALL: updated
2016-02-21 Oskar Skog <[email protected]>
0.1.18
* anonymine.py: Code clean up.
......
......@@ -55,7 +55,7 @@ RUN IN CURRENT DIRECTORY
You can run Anonymine right here in this directory (the directory) of the
package.
python anonymine.py -c cursescfg -e enginecfg
python anonymine.py -c cursescfg -e enginecfg.default
ADVANCED INSTALLATION
......@@ -69,9 +69,8 @@ ADVANCED INSTALLATION
* The other version of python is expected to by "python3" or
"python2"; make sure you have that symlink as well if you want the
modules to be installed for both versions.
* You may want to make some changes to '/etc/anonymine/enginecfg'
after installation.
* enginecfg is auto-generated since 0.1.19, you can override the file
by creating `$(builddir)enginecfg.user` as your own enginecfg.
./configure; make; make install
......@@ -129,6 +128,9 @@ ADVANCED INSTALLATION
freedesktop Empty=false, non-empty=true; "Linux" desktop
macosx Empty=false, non-empty=true; Mac OS X
windows Empty=false, non-empty=true; Windows (Cygwin)
verbose If set to true (default), make will be verbose
prefix, bindir and libdir:
http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
......
This diff is collapsed.
......@@ -63,7 +63,7 @@ except:
GAME_NAME = 'Anonymine'
GAME_FILENAME = GAME_NAME.lower().replace(' ', '-')
GAME_VERSION = (0, 1, 18)
GAME_VERSION = (0, 1, 19)
# GAME_VERSION MAY lag behind the version of the package when no change has
# been made to this file.
GAME_CRAPTEXT = """{0} version {1}.{2}.{3}
......
#!/usr/bin/python
import subprocess
import time
import pprint
debug = False
if debug:
conf_file = '/dev/stdout'
else:
conf_file = '/etc/anonymine/enginecfg'
def main():
cpus = int(subprocess.check_output(
"lscpu -p | grep -v '#' | wc -l", shell=True
))
start = time.time()
i = 0
while i < 10**7:
i += 1
bogomips = 10/(time.time() - start)
# Magic:
procs = int(0.75 * cpus + 0.5)
maxtime = bogomips/27.39
cfg = {
'init-field': {
'procs': procs,
'maxtime': maxtime,
'filename': '/tmp/mines.{0}',
}
}
f = open(conf_file, 'w')
f.write('# Auto generated using calibrate-anonymine\n')
f.write(pprint.pformat(cfg))
f.write('\n')
f.close()
if __name__ == '__main__':
main()
#!/bin/sh
# check.sh $(srcdir) $(builddir)
srcdir=$1
builddir=$2
cat > $2check.py << __EOF__
cat > ${builddir}check.py << __EOF__
# check.py enginecfg
import anonymine_engine
import sys
for mode in ('moore', 'hex', 'neumann'):
engine = anonymine_engine.game_engine(
'enginecfg',
sys.argv[1],
width=10, height=10,
mines=20,
flagcount=True, guessless=True,
......@@ -19,13 +23,22 @@ __EOF__
cd $1
file1="${builddir}enginecfg.out"
file2="${builddir}enginecfg.user"
file3="${srcdir}enginecfg.default"
for enginecfg in $file1 $file2 $file3; do
if [ -f $enginecfg ]; then
break
fi
done
has_any=0
fail_any=0
assert_ver="import sys; assert sys.version_info[0] == 3 or sys.version_info[1] >= 6"
v_ck="import sys; assert sys.version_info[0] == 3 or sys.version_info[1] >= 6"
for interpreter in python2 python3 python; do
if $interpreter -c "$assert_ver" 2>/dev/null ; then
if $interpreter -c "$v_ck" 2>/dev/null ; then
has_any=1
if ! $interpreter $2check.py; then
if ! $interpreter ${builddir}check.py $enginecfg; then
fail_any=1
fi
fi
......
......@@ -11,7 +11,7 @@ if [ $# -eq 1 ]; then
done
for version_option in -V --version; do
if [ "$1" = $version_option ]; then
echo Anonymine 0.1.18
echo Anonymine 0.1.19
echo Handmade configure and configure.py
echo Version info from configure may lag behind.
exit
......
#!/bin/bash
# Automatically set up an Anonymine server on Windows.
# This requires Administrator privileges.
# Self-explanatory
crap ()
{
echo 'Crap: something went wrong' >&2
while [ $# -gt 0 ]; do
echo $1
shift
done
exit 1
}
test -d /cygdrive || crap "This is not Cygwin"
crap "This is experimental stuff"
# To uninstall SSH to reinstall it with this script:
# cygrunsrv --stop sshd
# cygrunsrv --remove sshd
# nano /etc/passwd
# net user sshd /delete
# net user cyg_server /delete
# /setup.exe -R `cygpath --windows /` -x openssh
# We probably don't want to mess something up.
if [ -n "`which sshd`" ]; then
echo "This script assumes that the SSH daemon has not been" >&2
echo "installed. Running this script could potentially mess" >&2
echo "up your configuration. If you wish to continue," >&2
echo "modify this script to do so. But don't touch unless" >&2
echo "you know what you're doing." >&2
exit 1
fi
echo 'WARNING: This script is sensitive to race-conditions.'
echo ' /etc/passwd will be appended to'
echo ' /etc/shells will be appended to'
echo ' /etc/sshd_config is assumed to be untouched'
echo ' /etc/sshd_config will be appended to'
echo ' ssh-host-config will be run'
read -p 'Continue (yes/*): ' continue_execution
if [ "$continue_execution" != "yes" ]; then
echo 'Execution stopped on demand from user'
exit 1
fi
# Configuration
echo 'The username MUST be a valid unix username and a valid Windows username'
echo 'Allowed: Alphanumerics + hyphens, periods and underscores in the middle'
read -p 'Enter username for Anonymine account: ' anonymine_username
read -p 'Enter (weak) password: ' anonymine_password
# Install the SSH daemon
/setup.exe --wait -q -R `cygpath --windows /` -P openssh cygrunsrv \
|| crap "setup.exe is not /setup.exe from within Cygwin"
ssh-host-config -c ntsec -N cygwin-sshd -y || crap "ssh-host-config failed"
# Configure sshd
echo "AllowUsers $anonymine_username" >> /etc/sshd_config
# Add the user and Anonymine as a shell
echo `which anonymine` >> /etc/shells
net user $anonymine_username "$anonymine_password" \
/activate yes /comment 'Anonymine over SSH account' \
|| crap "Failed to add user $anonymine_username"
line="`mkpasswd -l -u $anonymine_username | cut -f 6 -d :`"
echo "$line:`which anonymine`" >> /etc/passwd
# Launch SSH daemon
net start cygwin-sshd
#!/bin/sh
# ./mkenginecfg srcdir builddir
# TODO: measure time by the time it takes to solve some known fields.
srcdir=$1
builddir=$2
userfile="${builddir}enginecfg.user"
defaultfile="${srcdir}enginecfg.default"
outfile="${builddir}enginecfg.out"
pyfile="${builddir}mkenginecfg.py"
if [ -f "$userfile" ]; then
cp "$userfile" "$outfile"
exit 0
fi
cat > "$pyfile" << __EOF__
import pprint
import time
import sys
def main():
cpus = int(sys.argv[1])
start = time.time()
i = 0
while i < 10**8:
i += 1
bogomips = 100/(time.time() - start)
# Magic:
procs = int(0.83 * cpus + 0.5)
maxtime = bogomips/27.5
cfg = {
'init-field': {
'procs': procs,
'maxtime': maxtime,
'filename': '/tmp/mines.{0}',
}
}
sys.stdout.write('# Auto generated during "build".\n')
sys.stdout.write(pprint.pformat(cfg))
sys.stdout.write('\n')
sys.stdout.close()
if __name__ == '__main__':
main()
__EOF__
if [ -n "`which lscpu`" ]; then
ncpus="`lscpu -p | grep -v '#' | wc -l`"
fi
if [ -n "`which sysctl`" ]; then
ncpus="`sysctl -n hw.ncpus`"
fi
oldpwd=`pwd`
cd "$srcdir"
python "$pyfile" $ncpus > "$outfile" || cp "$defaultfile" "$outfile"
cd "$oldpwd"
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment