Skip to content

Commit d69aaf6

Browse files
committed
commiting to main
1 parent ea40aa5 commit d69aaf6

File tree

3 files changed

+140
-53
lines changed

3 files changed

+140
-53
lines changed

Makefile

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
#
44
PROJECT = datatools
55

6+
GIT_GROUP = caltechlibrary
7+
8+
RELEASE_DATE=$(shell date +'%Y-%m-%d')
9+
10+
RELEASE_HASH=$(shell git log --pretty=format:'%h' -n 1)
11+
12+
613
PROGRAMS = codemeta2cff csv2json csv2mdtable csv2tab csv2xlsx csvcleaner csvcols csvfind csvjoin csvrows finddir findfile json2toml json2yaml jsoncols jsonjoin jsonmunge jsonrange mergepath range reldate reltime sql2csv string tab2csv timefmt toml2json urlparse xlsx2csv xlsx2json yaml2json
714

815
MAN_PAGES = codemeta2cff.1 csv2json.1 csv2mdtable.1 csv2tab.1 csv2xlsx.1 csvcleaner.1 csvcols.1 csvfind.1 csvjoin.1 csvrows.1 finddir.1 findfile.1 json2toml.1 json2yaml.1 jsoncols.1 jsonjoin.1 jsonmunge.1 jsonrange.1 mergepath.1 range.1 reldate.1 reltime.1 sql2csv.1 string.1 tab2csv.1 timefmt.1 toml2json.1 urlparse.1 xlsx2csv.1 xlsx2json.1 yaml2json.1
@@ -54,10 +61,9 @@ CITATION.cff: codemeta.json .FORCE
5461
if [ -f $(PANDOC) ]; then echo "" | $(PANDOC) --metadata title="Cite $(PROJECT)" --metadata-file=_codemeta.json --template=codemeta-cff.tmpl >CITATION.cff; fi
5562

5663
installer.sh: .FORCE
57-
echo '' | pandoc --metadata title="$(PACKAGE)" --metadata-file codemeta.json --template codemeta-installer.tmpl >installer.sh
58-
chmod 775 installer.sh
59-
git add -f installer.sh
60-
64+
@echo '' | pandoc --metadata title="Installer" --metadata git_org_or_person="$(GIT_GROUP)" --metadata-file codemeta.json --template codemeta-installer.tmpl >installer.sh
65+
@chmod 775 installer.sh
66+
@git add -f installer.sh
6167

6268
$(PROGRAMS): $(PACKAGE)
6369
@mkdir -p bin
@@ -119,44 +125,57 @@ uninstall: .FORCE
119125

120126

121127

122-
dist/linux-amd64: $(PROGRAMS)
128+
dist/Linux-x86_64: $(PROGRAMS)
123129
@mkdir -p dist/bin
124130
@for FNAME in $(PROGRAMS); do env GOOS=linux GOARCH=amd64 go build -o dist/bin/$$FNAME cmd/$$FNAME/*.go; done
125-
@cd dist && zip -r $(PROJECT)-v$(VERSION)-linux-amd64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
131+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-Linux-x86_64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
126132
@rm -fR dist/bin
127133

128134

129-
dist/macos-amd64: $(PROGRAMS)
135+
dist/macOS-x86_64: $(PROGRAMS)
130136
@mkdir -p dist/bin
131137
@for FNAME in $(PROGRAMS); do env GOOS=darwin GOARCH=amd64 go build -o dist/bin/$$FNAME cmd/$$FNAME/*.go; done
132-
@cd dist && zip -r $(PROJECT)-v$(VERSION)-macos-amd64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
138+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-macOS-x86_64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
133139
@rm -fR dist/bin
134140

135141

136-
dist/macos-arm64: $(PROGRAMS)
142+
dist/macOS-arm64: $(PROGRAMS)
137143
@mkdir -p dist/bin
138144
@for FNAME in $(PROGRAMS); do env GOOS=darwin GOARCH=arm64 go build -o dist/bin/$$FNAME cmd/$$FNAME/*.go; done
139-
@cd dist && zip -r $(PROJECT)-v$(VERSION)-macos-arm64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
145+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-macOS-arm64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
140146
@rm -fR dist/bin
141147

142148

143-
dist/windows-amd64: $(PROGRAMS)
149+
dist/Windows-x86_64: $(PROGRAMS)
144150
@mkdir -p dist/bin
145151
@for FNAME in $(PROGRAMS); do env GOOS=windows GOARCH=amd64 go build -o dist/bin/$$FNAME.exe cmd/$$FNAME/*.go; done
146-
@cd dist && zip -r $(PROJECT)-v$(VERSION)-windows-amd64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
152+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-Windows-x86_64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
147153
@rm -fR dist/bin
148154

149-
dist/windows-arm64: $(PROGRAMS)
155+
dist/Windows-arm64: $(PROGRAMS)
150156
@mkdir -p dist/bin
151157
@for FNAME in $(PROGRAMS); do env GOOS=windows GOARCH=arm64 go build -o dist/bin/$$FNAME.exe cmd/$$FNAME/*.go; done
152-
@cd dist && zip -r $(PROJECT)-v$(VERSION)-windows-arm64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
158+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-Windows-arm64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
159+
@rm -fR dist/bin
160+
161+
# Raspberry Pi OS (32bit) as reported on Raspberry Pi 3B+
162+
dist/Linux-armv7l: $(PROGRAMS)
163+
@mkdir -p dist/bin
164+
@for FNAME in $(PROGRAMS); do env GOOS=linux GOARCH=arm GOARM=7 go build -o dist/bin/$$FNAME cmd/$$FNAME/*.go; done
165+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-RaspberryPiOS-arm7.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
153166
@rm -fR dist/bin
154167

168+
# Raspberry Pi running Ubuntu 64-bit, as reported on Raspberry Pi 4B
169+
dist/Linux-aarch64: $(PROGRAMS)
170+
@mkdir -p dist/bin
171+
@for FNAME in $(PROGRAMS); do env GOOS=linux GOARCH=arm GOARM=7 go build -o dist/bin/$$FNAME cmd/$$FNAME/*.go; done
172+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-Linux-aarch64.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
173+
@rm -fR dist/bin
155174

156-
dist/raspbian-arm7: $(PROGRAMS)
175+
dist/RaspberryPiOS-arm7: $(PROGRAMS)
157176
@mkdir -p dist/bin
158177
@for FNAME in $(PROGRAMS); do env GOOS=linux GOARCH=arm GOARM=7 go build -o dist/bin/$$FNAME cmd/$$FNAME/*.go; done
159-
@cd dist && zip -r $(PROJECT)-v$(VERSION)-raspberry_pi_os-arm7.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
178+
@cd dist && zip -r $(PROJECT)-v$(VERSION)-RaspberryPiOS-arm7.zip LICENSE codemeta.json CITATION.cff *.md bin/* docs/* how-to/* man/*
160179
@rm -fR dist/bin
161180

162181
#dist/datatools_$(VERSION)_amd64.snap:
@@ -199,7 +218,7 @@ gen_batfiles: .FORCE
199218

200219
snap: dist/datatools_$(VERSION)_amd64.snap
201220

202-
release: clean build man gen_batfiles distribute_docs dist/linux-amd64 dist/macos-amd64 dist/macos-arm64 dist/windows-amd64 dist/windows-arm64 dist/raspbian-arm7
221+
release: .FORCE installer.sh clean build man gen_batfiles distribute_docs dist/Linux-x86_64 dist/macOS-x86_64 dist/macOS-arm64 dist/Windows-x86_64 dist/Windows-arm64 dist/RaspberryPiOS-arm7 dist/Linux-armv7l dist/Linux-aarch64
203222

204223

205224
.FORCE:

codemeta-installer.tmpl

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#
66
PACKAGE="$name$"
77
VERSION="$version$"
8-
RELEASE="https://github.com/caltechlibrary/$$PACKAGE/releases/tag/$$VERSION"
8+
GIT_GROUP="$git_org_or_person$"
9+
RELEASE="https://github.com/$$GIT_GROUP/$$PACKAGE/releases/tag/v$$VERSION"
910

1011
#
1112
# Get the name of this script.
@@ -19,15 +20,19 @@ OS_NAME="$$(uname -o)"
1920
MACHINE="$$(uname -m)"
2021
case "$$OS_NAME" in
2122
Darwin)
22-
OS_NAME="macos"
23+
OS_NAME="macOS"
24+
;;
25+
GNU/Linux)
26+
OS_NAME="Linux"
2327
;;
2428
esac
29+
2530
ZIPFILE="$$PACKAGE-v$$VERSION-$$OS_NAME-$$MACHINE.zip"
2631

2732
#
2833
# Check to see if this zip file has been downloaded.
2934
#
30-
DOWNLOAD_URL="https://github.com/caltechlibrary/$$PACKAGE/releases/download/v$$VERSION/$$ZIPFILE"
35+
DOWNLOAD_URL="https://github.com/$$GIT_GROUP/$$PACKAGE/releases/download/v$$VERSION/$$ZIPFILE"
3136
if ! curl -L -o "$$HOME/Downloads/$$ZIPFILE" "$$DOWNLOAD_URL"; then
3237
echo "Curl failed to get $$DOWNLOAD_URL"
3338
fi
@@ -59,46 +64,44 @@ fi
5964
START="$$(pwd)"
6065
mkdir -p "$$HOME/.$$PACKAGE/installer"
6166
cd "$$HOME/.$$PACKAGE/installer" || exit 1
62-
unzip "$$HOME/Downloads/$$ZIPFILE" "bin/*"
67+
unzip "$$HOME/Downloads/$$ZIPFILE" "bin/*" "man/*"
6368

6469
#
6570
# Copy the application into place
6671
#
6772
mkdir -p "$$HOME/bin"
6873
EXPLAIN_OS_POLICY="yes"
69-
find bin -type f | while read -r APP; do
74+
find bin -type f >.binfiles.tmp
75+
while read -r APP; do
7076
V=$$("./$$APP" --version)
71-
if [ "$$V" = "" ]; then
77+
if [ "$$V" = "" ]; then
7278
EXPLAIN_OS_POLICY="yes"
7379
fi
7480
mv "$$APP" "$$HOME/bin/"
75-
done
81+
done <.binfiles.tmp
82+
rm .binfiles.tmp
7683

7784
#
7885
# Make sure $$HOME/bin is in the path
7986
#
80-
DIR_IN_PATH='no'
81-
for P in $$PATH; do
82-
if [ "$$P" = "$$HOME/bin" ]; then
83-
DIR_IN_PATH='yes'
84-
fi
85-
done
86-
if [ "$$DIR_IN_PATH" = "no" ]; then
87+
case :$$PATH: in
88+
*:$$HOME/bin:*)
89+
;;
90+
*)
8791
# shellcheck disable=SC2016
8892
echo 'export PATH="$$HOME/bin:$$PATH"' >>"$$HOME/.bashrc"
8993
# shellcheck disable=SC2016
9094
echo 'export PATH="$$HOME/bin:$$PATH"' >>"$$HOME/.zshrc"
91-
fi
92-
rm -fR "$$HOME/.$$PACKAGE/installer"
93-
cd "$$START" || exit 1
95+
;;
96+
esac
9497

9598
# shellcheck disable=SC2031
9699
if [ "$$EXPLAIN_OS_POLICY" = "no" ]; then
97100
cat <<EOT
98101
99102
You need to take additional steps to complete installation.
100103
101-
Your operating systems' security policied need to "allow"
104+
Your operating system security policied needs to "allow"
102105
running programs from $$PACKAGE.
103106
104107
Example: on macOS you can type open the programs in finder.
@@ -109,4 +112,35 @@ if [ "$$EXPLAIN_OS_POLICY" = "no" ]; then
109112
installed to enable them to run.
110113
111114
EOT
115+
116+
fi
117+
118+
#
119+
# Copy the manual pages into place
120+
#
121+
EXPLAIN_MAN_PATH="no"
122+
for SECTION in 1 2 3 4 5 6 7; do
123+
if [ -d "man/man$${SECTION}" ]; then
124+
EXPLAIN_MAN_PATH="yes"
125+
mkdir -p "$$HOME/man/man$${SECTION}"
126+
find "man/man$${SECTION}" -type f | while read -r MAN; do
127+
cp -v "$$MAN" "$$HOME/man/man$${SECTION}/"
128+
done
129+
fi
130+
done
131+
132+
if [ "$$EXPLAIN_MAN_PATH" = "yes" ]; then
133+
cat <<EOT
134+
The man pages have been installed at '$$HOME/man'. You
135+
need to have that location in your MANPATH for man to
136+
find the pages. E.g. For the Bash shell add the
137+
following to your following to your '$$HOME/.bashrc' file.
138+
139+
export MANPATH="$$HOME/man:$$MANPATH"
140+
141+
EOT
142+
112143
fi
144+
145+
rm -fR "$$HOME/.$$PACKAGE/installer"
146+
cd "$$START" || exit 1

installer.sh

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#
66
PACKAGE="datatools"
77
VERSION="1.2.2"
8-
RELEASE="https://github.com/caltechlibrary/$PACKAGE/releases/tag/$VERSION"
8+
GIT_GROUP="caltechlibrary"
9+
RELEASE="https://github.com/$GIT_GROUP/$PACKAGE/releases/tag/v$VERSION"
910

1011
#
1112
# Get the name of this script.
@@ -19,15 +20,19 @@ OS_NAME="$(uname -o)"
1920
MACHINE="$(uname -m)"
2021
case "$OS_NAME" in
2122
Darwin)
22-
OS_NAME="macos"
23+
OS_NAME="macOS"
24+
;;
25+
GNU/Linux)
26+
OS_NAME="Linux"
2327
;;
2428
esac
29+
2530
ZIPFILE="$PACKAGE-v$VERSION-$OS_NAME-$MACHINE.zip"
2631

2732
#
2833
# Check to see if this zip file has been downloaded.
2934
#
30-
DOWNLOAD_URL="https://github.com/caltechlibrary/$PACKAGE/releases/download/v$VERSION/$ZIPFILE"
35+
DOWNLOAD_URL="https://github.com/$GIT_GROUP/$PACKAGE/releases/download/v$VERSION/$ZIPFILE"
3136
if ! curl -L -o "$HOME/Downloads/$ZIPFILE" "$DOWNLOAD_URL"; then
3237
echo "Curl failed to get $DOWNLOAD_URL"
3338
fi
@@ -59,46 +64,44 @@ fi
5964
START="$(pwd)"
6065
mkdir -p "$HOME/.$PACKAGE/installer"
6166
cd "$HOME/.$PACKAGE/installer" || exit 1
62-
unzip "$HOME/Downloads/$ZIPFILE" "bin/*"
67+
unzip "$HOME/Downloads/$ZIPFILE" "bin/*" "man/*"
6368

6469
#
6570
# Copy the application into place
6671
#
6772
mkdir -p "$HOME/bin"
6873
EXPLAIN_OS_POLICY="yes"
69-
find bin -type f | while read -r APP; do
74+
find bin -type f >.binfiles.tmp
75+
while read -r APP; do
7076
V=$("./$APP" --version)
71-
if [ "$V" = "" ]; then
77+
if [ "$V" = "" ]; then
7278
EXPLAIN_OS_POLICY="yes"
7379
fi
7480
mv "$APP" "$HOME/bin/"
75-
done
81+
done <.binfiles.tmp
82+
rm .binfiles.tmp
7683

7784
#
7885
# Make sure $HOME/bin is in the path
7986
#
80-
DIR_IN_PATH='no'
81-
for P in $PATH; do
82-
if [ "$P" = "$HOME/bin" ]; then
83-
DIR_IN_PATH='yes'
84-
fi
85-
done
86-
if [ "$DIR_IN_PATH" = "no" ]; then
87+
case :$PATH: in
88+
*:$HOME/bin:*)
89+
;;
90+
*)
8791
# shellcheck disable=SC2016
8892
echo 'export PATH="$HOME/bin:$PATH"' >>"$HOME/.bashrc"
8993
# shellcheck disable=SC2016
9094
echo 'export PATH="$HOME/bin:$PATH"' >>"$HOME/.zshrc"
91-
fi
92-
rm -fR "$HOME/.$PACKAGE/installer"
93-
cd "$START" || exit 1
95+
;;
96+
esac
9497

9598
# shellcheck disable=SC2031
9699
if [ "$EXPLAIN_OS_POLICY" = "no" ]; then
97100
cat <<EOT
98101
99102
You need to take additional steps to complete installation.
100103
101-
Your operating systems' security policied need to "allow"
104+
Your operating system security policied needs to "allow"
102105
running programs from $PACKAGE.
103106
104107
Example: on macOS you can type open the programs in finder.
@@ -109,4 +112,35 @@ if [ "$EXPLAIN_OS_POLICY" = "no" ]; then
109112
installed to enable them to run.
110113
111114
EOT
115+
116+
fi
117+
118+
#
119+
# Copy the manual pages into place
120+
#
121+
EXPLAIN_MAN_PATH="no"
122+
for SECTION in 1 2 3 4 5 6 7; do
123+
if [ -d "man/man${SECTION}" ]; then
124+
EXPLAIN_MAN_PATH="yes"
125+
mkdir -p "$HOME/man/man${SECTION}"
126+
find "man/man${SECTION}" -type f | while read -r MAN; do
127+
cp -v "$MAN" "$HOME/man/man${SECTION}/"
128+
done
129+
fi
130+
done
131+
132+
if [ "$EXPLAIN_MAN_PATH" = "yes" ]; then
133+
cat <<EOT
134+
The man pages have been installed at '$HOME/man'. You
135+
need to have that location in your MANPATH for man to
136+
find the pages. E.g. For the Bash shell add the
137+
following to your following to your '$HOME/.bashrc' file.
138+
139+
export MANPATH="$HOME/man:$MANPATH"
140+
141+
EOT
142+
112143
fi
144+
145+
rm -fR "$HOME/.$PACKAGE/installer"
146+
cd "$START" || exit 1

0 commit comments

Comments
 (0)