Skip to content

Commit

Permalink
Merge pull request #1 from watbulb/casked-version
Browse files Browse the repository at this point in the history
Casked version (0.1b)
  • Loading branch information
watbulb authored Apr 9, 2019
2 parents e83037a + 6fa6a99 commit 359eb53
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 121 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
.DS_Store

## Output files
*.tar.gz
*.o
*.pkg

## IDE/Workspace/Editor files
*.swp
Expand Down
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright © 2019 Dayton Pidhirney (watbulb) <[email protected]>

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.
141 changes: 94 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,116 @@
#

PROJECT := ansiterm2
IDENTIFIER := sh.potato.ansiterm2
CHECKSUM := $(shell cat VERSION | cut -d: -f1 | xargs)
VERSION := $(shell cat VERSION | cut -d: -f2 | xargs)
SIGNID := 52AMYRYD66

LOCAL_FORMULA := ansiterm2.rb
LOCAL_ARCHIVE := "http://localhost:8000/ansiterm2.tar.gz"
GIT_FORMULA := "https://raw.githubusercontent.com/watbulb/ANSiTerm2/$(VERSION)/ansiterm2.rb"
GIT_ARCHIVE := "https://github.com/watbulb/ANSiTerm2/releases/download/$(VERSION)/ansiterm2.tar.gz"
GIT_CASK := https://raw.githubusercontent.com/watbulb/ANSiTerm2/$(VERSION)/ansiterm2.rb
GIT_PKG := https://github.com/watbulb/ANSiTerm2/releases/download/\#{version}/ansiterm2.pkg
LOCAL_CASK := ansiterm2.rb
LOCAL_PKG := http://localhost:8000/ansiterm2.pkg

FONTDIR := ~/Library/Fonts
PROFILEDIR := ~/Library/Application\ Support/iTerm2/DynamicProfiles/
CONFDIR := .config/ansiterm2
FONTDIR := Library/Fonts
PROFILEDIR := Library/Application\ Support/iTerm2/DynamicProfiles

PKG_SCRIPTS := pkg/scripts
PKG_PROPS := pkg/requirements.plist
PKG_DIST := pkg/distribution.xml
PROFILE_PLIST := profile/$(IDENTIFIER)
SRC := docs font profile trigger
OBJ := ansiterm2.tar.gz
PKG_OBJ := ansiterm2.pkg
OBJLIST := sh.potato.ansiterm2.pkg $(PKG_OBJ)
OBJ : $(OBJLIST)


# build the staging directory for .pkg creation
$(IDENTIFIER).pkg:
@mkdir -p $@; rm -rf $@/*
@mkdir -p $@/$(FONTDIR) $@/$(PROFILEDIR) $@/$(CONFDIR)


# build the archive (pkg) used for brew cask
$(PKG_OBJ): $(IDENTIFIER).pkg
cp -r $(SRC) $^/$(CONFDIR)
touch $^/$(PROFILEDIR)/$(IDENTIFIER).plist
cp $^/$(CONFDIR)/font/* $^/$(FONTDIR)
# build stage one of the package distro (core files)
pkgbuild \
--version $(VERSION) \
--identifier $^ \
--ownership preserve \
--scripts $(PKG_SCRIPTS) \
--root $^ \
stage1_$@
# build a final package distribution (linked stages)
productbuild \
--product $(PKG_PROPS) \
--distribution $(PKG_DIST) \
$@
@rm stage1_$@


# when installing locally we need to update the cask to point to local URL
update_url:
sed -i '' -e 's_url.*\".*_url "$(LOCAL_PKG)"_g' $(LOCAL_CASK)


# when installing locally we need to update the local archive checksum in the cask
update_checksum:
sed -i '' -e "s/sha256.*'/sha256 '$(shell sha256sum $(PKG_OBJ) | cut -d' ' -f1)'/g" $(LOCAL_CASK)


# builds the archive used for brew formula
ansiterm2.tar.gz:
tar -cjf $@ $(SRC)
all: ## (default) clean and build brew cask
all: clean OBJ


# when installing locally we need to update the formula to point to local URL
update_localurl:
sed -i '' -e 's_url.*\".*_url $(LOCAL_ARCHIVE)_g' $(LOCAL_FORMULA)
test: ## test client functionality (execute from inside ANSiTerm2)
@echo "[-] ERROR: Currently not implemented!"
@exit 1


# when installing locally we need to update the local archive checksum in the formula
update_checksum:
sed -i '' -e 's/sha256.*\".*/sha256 "$(shell sha256sum $(OBJ) | cut -d" " -f1)"/g' $(LOCAL_FORMULA)
audit: ## audit the brew cask
brew cask audit $(LOCAL_CASK)


all: ## (default) clean and build brew formula
all: clean $(OBJ)
release: ## create signed release of ansiterm2.pkg
release: $(PKG_OBJ) | update_checksum
productsign --sign $(SIGNID) $^ $^.signed
mv $^.signed $^
sed -i '' -e 's_url.*\".*_url "$(GIT_PKG)"_g' $(LOCAL_CASK)
sha256sum $^


test: ## test client functionality (execute from inside ANSiTerm2)
@echo "[-] ERROR: Currently not implemented!"
bumpver: ## bump versions to the version you've specified (NEWVER)
bumpver: VERSION README.md $(LOCAL_CASK) $(PKG_DIST)
ifeq ($(NEWVER),)
@echo "[-] ERROR: NEWVER has not been supplied to make!"
@exit 1
else
$(foreach file,$^,sed -i '' -e 's/$(VERSION)/$(NEWVER)/g' $(file) ;)
sed -i '' -e "s/$(CHECKSUM)/$(shell sha256sum $(PKG_OBJ) | cut -d' ' -f1)/g" VERSION
endif


brewtest: ## test brew formula creation/installation
brew audit $(LOCAL_FORMULA)

install: ## install ANSiTerm2 (using git)
HOMEBREW_INSTALL_BADGE="📟" \
HOMEBREW_NO_AUTO_UPDATE=1 \
brew cask install $(GIT_CASK)

install: ## install ANSiTerm2 regularly (using git)
@HOMEBREW_INSTALL_BADGE="📟" \
HOMEBREW_NO_AUTO_UPDATE=1 \
brew install -s $(GIT_FORMULA)

install_local: ## install ANSiTerm2 (using local changes)
install_local: all | update_url update_checksum
$(shell killall -9 python || :)
python -m SimpleHTTPServer >/dev/null 2>&1 &
HOMEBREW_INSTALL_BADGE="📟" \
HOMEBREW_NO_AUTO_UPDATE=1 \
brew cask install --verbose $(LOCAL_CASK)

install_local: ## install ANSiTerm2 using local changes
install_local: update_localurl | all update_checksum
@python -m SimpleHTTPServer >/dev/null 2>&1 &
@HOMEBREW_INSTALL_BADGE="📟" \
HOMEBREW_NO_AUTO_UPDATE=1 \
brew install -s $(LOCAL_FORMULA)
@killall -KILL python


# @TODO: once ANSiTerm2 is casked this should all be handled by `brew remove`
uninstall: ## uninstall ANSiTerm2 brew formula
@$(foreach font,$(shell ls -p font/.), rm -f $(FONTDIR)/$(font) || : ;)
@echo "removed font files successfully"
@$(foreach profile,$(shell ls -p profile/.), rm -f $(PROFILEDIR)/$(profile) || : ;)
@echo "removed profile successfully"
brew remove ansiterm2
uninstall: ## uninstall ANSiTerm2 brew cask
brew cask uninstall --verbose $(PROJECT)


help: ## show this help dialog
Expand All @@ -78,12 +123,14 @@ help: ## show this help dialog


clean: ## clean this project
rm -f $(OBJ)
rm -rf $(OBJLIST)


.PHONY: $(OBJ) \
update_localurl update_checksum \
test brewtest install uninstall clean help
update_url update_checksum \
test audit release install uninstall clean help
.NOTPARALLEL: $(OBJ) \
update_localurl update_checksum \
test brewtest install uninstall clean help
update_url update_checksum \
test audit release install uninstall clean help
.DEFAULT_TARGET: all

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 📟 ANSiTerm2 (0.1a-rc2)
# 📟 ANSiTerm2 (0.1b)

_ANSiTerm2_ is a set of profiles, triggers and meticulous tweaks that turn [_iTerm2_](https://www.iterm2.com) into
a fully fledged modern BBS client; modem support included! If you want to learn more, head over to the [wiki](https://github.com/watbulb/ANSiTerm2/wiki).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
77c03c5f1a3720e009ffb9dfe0884c954efbe46905742ddd8d6286fafbefa80f:0.1a-rc2
37c8d10fec7943a993b388843dbd1a132976bf5cc6d92a5d8df70822222e2184:0.1b
101 changes: 35 additions & 66 deletions ansiterm2.rb
Original file line number Diff line number Diff line change
@@ -1,68 +1,37 @@
class Ansiterm2 < Formula
desc "
ANSiTerm2 is a set of configurations, triggers and patches
that turn iTerm2 into a fully fledged modern BBS client, modem support included!
The last hope for a working and maintainable modern BBS client for macOS.
Author: Dayton Pidhirney (watbulb)
"
homepage "https://www.phenomprod.com/"
version "0.1a-rc2"
url "https://github.com/watbulb/ANSiTerm2/releases/download/0.1a-rc2/ansiterm2.tar.gz"
sha256 "77c03c5f1a3720e009ffb9dfe0884c954efbe46905742ddd8d6286fafbefa80f"
bottle :unneeded

# lrzsz is required for zmodem transfers
depends_on "lrzsz"

# telnet is required for connecting to remote terminals
depends_on "telnet"

def install
# @XXX: rather poor way to check for Cask dependency
# since brew doesn't support formulas which depend
# on Casks, sadly...
system "/usr/local/bin/brew", "cask", "install", "iterm2"

# install Amiga fonts:
# @XXX: a Cask is required to write to ~/Library/Fonts
# so for now we just prompt the user to install topaz
# if it doesn't yet exist
username = ENV["USER"]
fontprompt = false
if not(File.exist?("/Users/#{username}/Library/Fonts/TopazPlus_a1200_v1.0.ttf"))
system "open", "font/TopazPlus_a1200_v1.0.ttf"
fontprompt = true
end

# replace the dynamic_profile username in the ANSiTerm2 profile
profile = "profile/sh.potato.ansiterm2.plist"
IO.write(profile, File.open(profile) do |f|
f.read.gsub("replacement_user", username)
end)

# install ANSiTerm2 to formula share
share.mkpath
share.install "docs"
share.install "font"
share.install "trigger"
share.install "profile"

# prompt for font installation and iTerm2 configuration documentation
if(fontprompt)
puts
puts "A FontBook window should have appeared!"
puts "Please install the required Amiga font onto your system!"
puts '(simply click "Install Font" within the FontBook window)'
end

puts
puts "Please run the following command to 'activate' or 'update' ANSiTerm2:"
puts "cp #{share}/profile/* ~/Library/Application\\ Support/iTerm2/DynamicProfiles/"
puts
puts "ANSiTerm2 can be activated once iTerm2 is opened by pressing CTRL+CMD+0"
puts
cask 'ansiterm2' do
version '0.1b'
sha256 'deede8f364fa94119ee6bbd2953198bac90e3153c402e39a446f23baf620c425'

url "https://github.com/watbulb/ANSiTerm2/releases/download/#{version}/ansiterm2.pkg"
appcast 'https://github.com/watbulb/ANSiTerm2/releases.atom'
name 'ANSiTerm2'
homepage 'https://github.com/watbulb/ANSiTerm2'

# mavericks or above is required for iTerm2
depends_on macos: '>= :mavericks'

# ANSiTerm2 depends on the following for client modem functionality
depends_on formula: 'telnet'
depends_on formula: 'lrzsz'

# Some users install iTerm2 from it's website, so it won't show in installed Casks
if not(Dir.exist?("/Applications/iTerm.app"))
depends_on cask: 'iterm2'
end
end

# install secure signed (Apple Developer) package installer
# note: this doesn't even need root, which makes it even more secure :)
installer script: {
executable: '/usr/sbin/installer',
args: ['-pkg', 'ansiterm2.pkg', '-target', 'CurrentUserHomeDirectory']
}

# remove pacakge by product-ids
# note: unfortunately since brew doesn't support uninstalling HOME based
# packages, we have to rely on removing them manually, this is why brew is shit.
uninstall delete: [
'~/Library/Application Support/iTerm2/DynamicProfiles/sh.potato.ansiterm2.plist',
'~/.config/ansiterm2'
]

# vim: ts=4 sw=4 et
end
19 changes: 19 additions & 0 deletions pkg/distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<pkg-ref id="sh.potato.ansiterm2.pkg">
<bundle-version/>
</pkg-ref>
<options customize="never" require-scripts="false"/>
<domains enable_localSystem="false" enable_anywhere="false" enable_currentUserHome="true"/>
<choices-outline>
<line choice="default">
<line choice="sh.potato.ansiterm2.pkg"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="sh.potato.ansiterm2.pkg" visible="true">
<pkg-ref id="sh.potato.ansiterm2.pkg"/>
</choice>
<pkg-ref id="sh.potato.ansiterm2.pkg" auth="none" version="0.1b" onConclusion="none" installKBytes="381">#stage1_ansiterm2.pkg</pkg-ref>
<title>ANSiTerm2</title>
</installer-gui-script>
8 changes: 8 additions & 0 deletions pkg/requirements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>home</key>
<true/>
</dict>
</plist>
14 changes: 14 additions & 0 deletions pkg/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# implode on error
set -e

# symlink the dynamic profile to the user config folder
rm ~/Library/Application\ Support/iTerm2/DynamicProfiles/sh.potato.ansiterm2.plist
ln -s ~/.config/ansiterm2/profile/sh.potato.ansiterm2.plist ~/Library/Application\ Support/iTerm2/DynamicProfiles/sh.potato.ansiterm2.plist

# replace the dummy usernames in the profile with the real one
sed -i '' -e "s/replacement_user/${USER}/g" ~/.config/ansiterm2/profile/sh.potato.ansiterm2.plist

exit 0 # all went well :)

4 changes: 2 additions & 2 deletions profile/sh.potato.ansiterm2.plist
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@
"Triggers" : [
{
"action" : "MuteCoprocessTrigger",
"parameter" : "\/usr\/local\/Cellar\/ansiterm2\/0.1a-rc2\/share\/trigger\/modem\/iterm2-recv-zmodem.sh",
"parameter" : "\/Users\/replacement_user\/.config\/ansiterm2\/trigger\/modem\/iterm2-recv-zmodem.sh",
"regex" : "\\\\*\\\\*B00000000000000",
"partial" : true
},
{
"partial" : true,
"parameter" : "\/usr\/local\/Cellar\/ansiterm2\/0.1a-rc2\/share\/trigger\/modem\/iterm2-send-zmodem.sh",
"parameter" : "\/Users\/replacement_user\/.config\/ansiterm2\/trigger\/modem\/iterm2-send-zmodem.sh",
"regex" : "\\\\*\\\\*B0100",
"action" : "MuteCoprocessTrigger"
},
Expand Down
2 changes: 1 addition & 1 deletion trigger/modem/iterm2-recv-zmodem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ elif [ ! "${FILE}" ]; then
echo; echo; echo
else
cd "${FILE}" || :
/usr/local/bin/rz -E -e -b && sleep 1
/usr/local/bin/rz -q -E -e -b && sleep 1
echo; echo; echo
fi
2 changes: 1 addition & 1 deletion trigger/modem/iterm2-send-zmodem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ elif [ ! "${FILE}" ]; then
print \\x18\\x18\\x18\\x18\\x18 && sleep 1
echo; echo; echo
else
/usr/local/bin/sz -E -e -b -8 "${FILE}" && sleep 1
/usr/local/bin/sz -q -E -e -b -8 "${FILE}" && sleep 1
echo; echo; echo
fi

0 comments on commit 359eb53

Please sign in to comment.