Commit 7fa78fda authored by Oskar Skog's avatar Oskar Skog

Removed perkele/

parent 5bc00838
2016-02-17 Oskar Skog <[email protected]>
0.1.17
* README: Various changes.
* ., Makefile.static: Removed perkele/.
0.1.16
* Makefile.static (clean): Added $(DESKTOP_STAGE) and corrected
$(OSX_INFO_PLIST) to $(INFO_PLIST).
......
......@@ -268,16 +268,14 @@ PKG := "$(builddir)$(PKG_INDIR)"
# .txt in zips.
PKG_TEXTFILES := BUGS ChangeLog FAQ FILES INSTALL NEWS README desktop/FILES \
desktop/README
# Old crap
PERKELE := perkele/Windows.ps1 perkele/desktop/anonymine.lnk.py
# Already CRLF + old crap.
PKG_NOCONV := Windows.txt Windows-admin.bat Windows-user.bat \
configure desktop/$(NAME).ico desktop/desktop.sh \
desktop/$(NAME)-*.png desktop/$(NAME)*.xcf $(PERKELE)
desktop/$(NAME)-*.png desktop/$(NAME)*.xcf
PKG_FILES := $(NAME).py $(NAME)_engine.py $(NAME)_fields.py $(NAME)_solver.py \
configure.py Makefile.static install-cfg check.sh enginecfg cursescfg \
test.py desktop/Info.plist.py desktop/icon.icns.py
PKG_SUBDIRS := desktop perkele perkele/desktop
PKG_SUBDIRS := desktop
check: FORCE
@$(srcdir)check.sh "$(srcdir)" "$(builddir)"
......
# NOTICE: This has not been tested!!
# Ugh PowerShell.
# NOTICE: Keep python_pkg up to date!
$cygwin_dir = "C:\Cygwin"
$cygwin_setup = "$cygwin_dir\setup.exe"
$python_pkg = "python-2.7.10-1"
$src64 = "https://cygwin.com/setup-x86_64.exe"
$src32 = "https://cygwin.com/setup-x86.exe"
# Procedures:
# 1. Install Cygwin if needed.
# 2. Install the dependencies of the game.
# 3. Start a Cygwin environment.
# 4. Install the game.
# Information:
# https://cygwin.com/cgi-bin2/package-grep.cgi
# http://ss64.com/ps/bits.txt
# http://ss64.com/ps/
# https://cygwin.com/faq/faq.html#faq.setup.cli
#Set-ExecutionPolicy -ExecutionPolicy bypass
$ErrorActionPreference = "Stop"
Import-Module BitsTransfer
if (Test-Path -Path $cygwin_dir)
Write-Host "Cygwin appears to be pre-installed."
else
{
# 64/32
if ( Test-Path -Path "C:\Windows\SysWOW64" )
$src = $src64
else
$src = $src32
Write-Host "Downloading $src"
Start-BitsTransfer "$src" cygwin.exe
Write-Host "Installing Cygwin"
.\cygwin.exe -R "$cygwin_dir"
Move-Item -path cygwin.exe -destination "$cygwin_setup"
}
Write-Host "Installing $python_pkg and the game"
$cygwin_setup -R "$cygwin_dir" -P $python_pkg
"$cygwin_dir\bin\bash" -c "./configure -v; make; make install"
#!/usr/bin/python2
'''
http://fileanalysis.net/lnk/
http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux
https://github.com/libyal/liblnk/blob/master/documentation/Windows%20Shortcut%20File%20%28LNK%29%20format.asciidoc
http://packages.altlinux.org/en/Sisyphus/srpms/liblnk/sources/Windows_Shortcut_File_%28LNK%29_format.pdf/download
HasName 0x00000004 The StringData section contains the NAME_STRING field
HasRelativePath 0x00000008 The StringData section contains the RELATIVE_PATH field
HasArguments 0x00000020 The StringData section contains the COMMAND_LINE_ARGUMENTS field
HasIconLocation 0x00000040 The LNK file contains a custom icon location
0x00: Length=76 4C 00 00 00
0x04: Magic 01 14 02 00 00 00 00 00 c0 00 00 00 00 00 00 46
0x14 Flags=0x2c 2c 00 00 00
0x18 Flags=0x80 80 00 00 00
0x1c 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x24 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x2c 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x34 target size=42 2a 00 00 00
0x38 icon index=42 2a 00 00 00
0x3c show=normal=1 01 00 00 00
0x40 hotkey=2 0x00 00 00
0x42 10 0x00 00 00
00 00 00 00
00 00 00 00
stringdata Name/description
stringdata rel path
stringdata args
stringdata icon path
'''
import time
import sys
def mklnk(outfile, bash_path, icon_path):
#f = open('anonymine.lnk', 'w')
f = open(outfile, 'w')
f.write('\x4c\x00\x00\x00') # Header length 76
f.write('\x01\x14\x02\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x46')
f.write('\x6c\x00\x00\x00') # HasName|HasRelativePath|HasArguments|HasIconLocation
f.write('\x80\x00\x00\x00') # Normal file attributes
# Unix time to 64 bit LE x*100ns since 1601-01-01
def addtime(unix_time):
value = int((unix_time + 11644477200) * 10**7)
# 11644473600 doesn't seem to work.
for i in range(8):
f.write(chr(value%256))
value//=256
addtime(time.time()) # Creation: 64bit LE 100ns since 1601-01-01
addtime(time.time()) # Access: 64bit LE 100ns since 1601-01-01
addtime(time.time()) # Write: 64bit LE 100ns since 1601-01-01
f.write('\0\0\0\0') # Target size = meaningless for Anonymine.
f.write('\0\0\0\0') # Icon index = ?
f.write('\x01\x00\x00\x00') # Show window in normal way.
f.write('\0\0') # No hotkey
f.write(10*'\0') # Reserved
def stringdata(s):
f.write(chr(len(s)%256))
f.write(chr(len(s)//256))
f.write(s)
stringdata('Anonymine - minesweeper without guessing')
#stringdata('C:\\Cygwin\\bin\\bash.exe')
stringdata(bash_path)
stringdata('-lc anonymine')
#stringdata('C:\\Cygwin\\usr\\share\\pixmaps\\anonymine.ico')
stringdata(icon_path)
f.close()
if __name__ == '__main__':
if len(sys.argv) != 4:
sys.stderr.write('Usage: ./anonymine.lnk.py link bash icon\n')
else:
mklnk(sys.argv[1], sys.argv[2], sys.argv[3])
http://fileanalysis.net/lnk/
HasName 0x00000004 The StringData section contains the NAME_STRING field
HasRelativePath 0x00000008 The StringData section contains the RELATIVE_PATH field
HasArguments 0x00000020 The StringData section contains the COMMAND_LINE_ARGUMENTS field
0x00: Length=76 4C 00 00 00
0x04: Magic 00 01 14 01 00 00 00 00 c0 00 00 00 00 00 00 46
0x14 Flags=0x2c 2c 00 00 00
0x18 Flags=0x80 80 00 00 00
0x1c 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x24 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x2c 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x34 target size=42 2a 00 00 00
0x38 icon index=42 2a 00 00 00
0x3c show=normal=1 01 00 00 00
0x40 hotkey=2 0x00 00 00
0x42 10 0x00 00 00
00 00 00 00
00 00 00 00
-------------------------------------------
:::: len=33 21 00
:::: 'Anonymine - guessless minesweeper'
-------------------------------------------
:::: len=22 16 00
:::: 'C:\Cygwin\bin\bash.exe'
-------------------------------------------
:::: len=13 0d 00
:::: '-lc anonymine'
#!/usr/bin/python
# -*- encoding: utf-8 -*-
# In a nutshell: PERKELE
# desktop/anonymine.lnk.py link description bash command icon
'''
http://fileanalysis.net/lnk/
http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux
https://github.com/libyal/liblnk/blob/master/documentation/Windows%20Shortcut%20File%20%28LNK%29%20format.asciidoc
http://packages.altlinux.org/en/Sisyphus/srpms/liblnk/sources/Windows_Shortcut_File_%28LNK%29_format.pdf/download
HasLinkInfo 0x00000002 The LNK file contains location information
HasName 0x00000004 The StringData section contains the NAME_STRING field
HasRelativePath 0x00000008 The StringData section contains the RELATIVE_PATH field
HasArguments 0x00000020 The StringData section contains the COMMAND_LINE_ARGUMENTS field
HasIconLocation 0x00000040 The LNK file contains a custom icon location
IsUnicode 0x00000080 UTF-16 LE instead of ASCII in data strings
0x00: Length=76 4C 00 00 00
0x04: Magic 01 14 02 00 00 00 00 00 c0 00 00 00 00 00 00 46
0x14 Flags=0x2c 2c 00 00 00
0x18 Flags=0x80 80 00 00 00
0x1c 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x24 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x2c 1601-01-01 00:00 00 00 00 00 00 00 00 00
0x34 target size=42 2a 00 00 00
0x38 icon index=42 2a 00 00 00
0x3c show=normal=1 01 00 00 00
0x40 hotkey=2 0x00 00 00
0x42 10 0x00 00 00
00 00 00 00
00 00 00 00
stringdata Name/description
stringdata rel path
stringdata args
stringdata icon path
'''
import time
import sys
import os
def mklnk(outfile, description, bash_path, command, icon_path):
if sys.version_info[0] == 2:
import locale
encoding = locale.getdefaultlocale()[1]
use_unicode = False
for arg in (description, bash_path, command, icon_path):
try:
if sys.version_info[0] == 2:
arg.decode('us-ascii')
else:
arg.encode('us-ascii')
except:
use_unicode = True
break
f = open(outfile, 'wb')
def write(s):
if sys.version_info[0] == 3:
f.write(s.encode('iso-8859-1'))
else:
f.write(s)
def le32(x):
for i in range(4):
write(chr(x%256))
x//=256
le32(76) # Header length
write('\x01\x14\x02\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00\x46')
le32(0x66 | 0x80*use_unicode) # Flags
#write('\xe6\x00\x00\x00') # HasLinkInfo|HasName|HasArguments|HasIconLocation|IsUnicode
le32(0x80) # Normal file attribute
# Unix time to 64 bit LE x*100ns since 1601-01-01
def addtime(unix_time):
value = int((unix_time + 11644473600) * 10**7)
# 11644473600 doesn't seem to work.
for i in range(8):
write(chr(value%256))
value//=256
addtime(time.time()) # Creation: 64bit LE 100ns since 1601-01-01
addtime(time.time()) # Access: 64bit LE 100ns since 1601-01-01
addtime(time.time()) # Write: 64bit LE 100ns since 1601-01-01
le32(0) # Target size = meaningless for Anonymine.
le32(0) # Icon index = ?
le32(1) # Show window in normal way.
write('\0\0') # No hotkey
write(10*'\0') # Reserved
# Location information
diskname = 'The drive on which Cygwin is installed'
if sys.version_info[0] == 2:
bash_path = bash_path.decode(encoding)
bash_path += unichr(0)
else:
bash_path += chr(0)
if use_unicode:
bash_path = bash_path.encode('utf-16-le')
head_length = 49 + len(diskname)
else:
bash_path = bash_path.encode('us-ascii')
head_length = 45 + len(diskname)
le32(head_length + len(bash_path)) # Total size
le32(32) # Header length
le32(1) # Flags: local
#le32(28) # Offset to volume information
if use_unicode:
le32(32) # Offset to volume information
#le32(head_length - 1) # Use the terminating NUL of diskname as ASCII path.
le32(0)
else:
le32(28) # Offset to volume information
le32(head_length) # Offset to ASCII local path
le32(0) # Not used: Network share information
le32(0) # Not used: Common path ASCII
if use_unicode:
le32(head_length) # Offset to UTF-16-LE path
# Volume information
le32(16 + len(diskname) + 1) # size of volume information
le32(0) # Unknown, probably fixed
write('ABCD') # Bogus drive serial number
le32(16) # Offset to ASCII label relative to volume information.
write(diskname)
write('\0')
# Local path
f.write(bash_path)
def stringdata(s):
write(chr(len(s)%256))
write(chr(len(s)//256))
if use_unicode:
f.write(s.encode('utf-16-le'))
else:
f.write(s.encode('us-ascii'))
if sys.version_info[0] == 3:
stringdata(description)
#stringdata(bash_path)
stringdata('-lc ' + command)
stringdata(icon_path)
else:
stringdata(description.decode(encoding))
#stringdata(bash_path.decode(encoding))
stringdata('-lc ' + command)
stringdata(icon_path.decode(encoding))
# Just because I can.
msg = '\nJåo nåo e ja jåo YOLO ja nåo!\n'
if sys.version_info[0] == 3:
msg = msg.encode('utf-8')
le32(len(msg) + 8) # length
write('\n42\n') # magic
f.write(msg)
write('\0\0\0\0')
# write('\0\0\0\0') # Extra data terminal block
# Needed ?
f.close()
if __name__ == '__main__':
if len(sys.argv) != 6:
sys.stderr.write(
'Usage: '
'desktop/anonymine.lnk.py link description bash command icon\n'
)
else:
mklnk(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
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