Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the build system to work without bash. #209

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# vim: set softtabstop=2 shiftwidth=2:
SHELL = bash
SHELL = sh

PUBLISHTAG = $(shell node scripts/publish-tag.js)
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
Expand Down Expand Up @@ -182,7 +182,7 @@ publish: gitclean ls-ok link doc-clean doc

release: gitclean ls-ok markedclean marked-manclean doc-clean doc
node bin/npm-cli.js prune --production --no-save
@bash scripts/release.sh
@${SHELL} scripts/release.sh

sandwich:
@[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13)
Expand Down
21 changes: 10 additions & 11 deletions configure
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
#!/bin/bash
#!/bin/sh

# set configurations that will be "sticky" on this system,
# surviving npm self-updates.

CONFIGS=()
i=0

# get the location of this file.
unset CDPATH
CDPATH=
CONFFILE=$(cd $(dirname "$0"); pwd -P)/npmrc

CONFIGS=
NL="
"

while [ $# -gt 0 ]; do
conf="$1"
case $conf in
case "$conf" in
--help)
echo "./configure --param=value ..."
exit 0
;;
--*)
CONFIGS[$i]="${conf:2}"
CONFIGS="$CONFIGS${conf#--*}$NL"
;;
*)
CONFIGS[$i]="$conf"
CONFIGS="$CONFIGS$conf$NL"
;;
esac
let i++
shift
done

for c in "${CONFIGS[@]}"; do
echo "$c" >> "$CONFFILE"
done
printf %s "$CONFIGS" > "$CONFFILE"
39 changes: 16 additions & 23 deletions scripts/clean-old.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/bin/bash
#!/bin/sh
NL="
"

# look for old 0.x cruft, and get rid of it.
# Should already be sitting in the npm folder.

# This doesn't have to be quite as cross-platform as install.sh.
# There are some bash-isms, because maintaining *two*
# fully-portable posix/bourne sh scripts is too much for
# one project with a sane maintainer.

# If readlink isn't available, then this is just too tricky.
# However, greadlink is fine, so Solaris can join the party, too.
readlink="readlink"
Expand Down Expand Up @@ -57,8 +54,7 @@ done

packages=`echo $packages`

filelist=()
fid=0
filelist=

for prefix in $PREFIXES; do
# remove any links into the .npm dir, or links to
Expand All @@ -68,8 +64,7 @@ for prefix in $PREFIXES; do
target=`$readlink $file | grep '/\.npm/'`
if [ "x$target" != "x" ]; then
# found one!
filelist[$fid]="$file"
let 'fid++'
filelist="$filelist$file$NL"
# also remove any symlinks to this file.
base=`basename "$file"`
base=`echo "$base" | awk -F@ '{print $1}'`
Expand All @@ -78,8 +73,7 @@ for prefix in $PREFIXES; do
| while read l; do
target=`$readlink "$l" | grep "$base"`
if [ "x$target" != "x" ]; then
filelist[$fid]="$1"
let 'fid++'
filelist="$filelist$file$NL"
fi
done
fi
Expand All @@ -91,33 +85,29 @@ for prefix in $PREFIXES; do
find $prefix/$folder -type f \
| xargs grep -sl '// generated by npm' \
| while read file; do
filelist[$fid]="$file"
let 'fid++'
filelist="$filelist$file$NL"
done
done

# now remove the package modules, and the .npm folder itself.
if [ "x$packages" != "x" ]; then
for pkg in $packages; do
filelist[$fid]="$prefix/lib/node/$pkg"
let 'fid++'
filelist="$filelist$prefix/lib/node/$pkg$NL"
for i in $prefix/lib/node/$pkg\@*; do
filelist[$fid]="$i"
let 'fid++'
filelist="$filelist$i$NL"
done
done
fi

for folder in lib/node/.npm lib/npm share/npm; do
if [ -d $prefix/$folder ]; then
filelist[$fid]="$prefix/$folder"
let 'fid++'
filelist="$filelist$prefix/$folder/$NL"
fi
done
done

# now actually clean, but only if there's anything TO clean
if [ "${#filelist[@]}" -gt 0 ]; then
if [ "x$filelist" != "x" ]; then
echo ""
echo "This script will find and eliminate any shims, symbolic"
echo "links, and other cruft that was installed by npm 0.x."
Expand All @@ -139,13 +129,16 @@ if [ "${#filelist[@]}" -gt 0 ]; then
OK="yes"
fi

set -o noglob
IFS="
"
while [ "$OK" != "y" ] && [ "$OK" != "yes" ] && [ "$OK" != "no" ]; do
echo "Is this OK?"
echo " enter 'yes' or 'no'"
echo " or 'show' to see a list of files "
read OK
if [ "x$OK" = "xshow" ] || [ "x$OK" = "xs" ]; then
for i in "${filelist[@]}"; do
for i in $filelist; do
echo "$i"
done
fi
Expand All @@ -154,7 +147,7 @@ if [ "${#filelist[@]}" -gt 0 ]; then
echo "Aborting"
exit 1
fi
for i in "${filelist[@]}"; do
for i in $filelist; do
rm -rf "$i"
done
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/dep-update
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
node . install --save $1@$2 &&\
node scripts/gen-dev-ignores.js &&\
git add node_modules package.json package-lock.json &&\
Expand Down
2 changes: 1 addition & 1 deletion scripts/dev-dep-update
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
node . install --save --save-dev $1@$2 &&\
node scripts/gen-dev-ignores.js &&\
git add package.json package-lock.json &&\
Expand Down
13 changes: 6 additions & 7 deletions scripts/doc-build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
#!/bin/sh

if [[ $DEBUG != "" ]]; then
if [ -n "$DEBUG" ]; then
set -x
fi
set -o errexit
set -o pipefail
set -e

src=$1
dest=$2
Expand All @@ -15,7 +14,7 @@ version=$(node bin/npm-cli.js -v)
mkdir -p $(dirname $dest)

html_replace_tokens () {
local url=$1
url=$1
sed "s|@NAME@|$name|g" \
| sed "s|@DATE@|$date|g" \
| sed "s|@URL@|$url|g" \
Expand All @@ -29,7 +28,7 @@ html_replace_tokens () {
| perl -p -e 's/([^"-])([^\(> ]+)(\(5\))/\1<a href="..\/files\/\2.html">\2\3<\/a>/g' \
| perl -p -e 's/([^"-])([^\(> ]+)(\(7\))/\1<a href="..\/misc\/\2.html">\2\3<\/a>/g' \
| perl -p -e 's/\([1357]\)<\/a><\/h1>/<\/a><\/h1>/g' \
| (if [ $(basename $(dirname $dest)) == "doc" ]; then
| (if [ $(basename $(dirname $dest)) = "doc" ]; then
perl -p -e 's/ href="\.\.\// href="/g'
else
cat
Expand All @@ -52,7 +51,7 @@ case $dest in
exit $?
;;
*.html)
url=${dest/html\//}
url=$(echo $dest | sed -e 's/html\///g')
(cat html/dochead.html && \
cat $src | ./node_modules/.bin/marked &&
cat html/docfoot.html)\
Expand Down
7 changes: 0 additions & 7 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ else
make=NOMAKE
fi

# If there's no bash, then don't even try to clean
if [ -x "/bin/bash" ]; then
(exit 0)
else
clean="no"
fi

node_version=`"$node" --version 2>&1`
ret=$?
if [ $ret -ne 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#!/bin/sh

# script for creating a zip and tarball for inclusion in node

unset CDPATH
CDPATH=

set -e

Expand Down
4 changes: 2 additions & 2 deletions scripts/relocate.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/bin/sh

# Change the cli shebang to point at the specified node
# Useful for when the program is moved around after install.
# Also used by the default 'make install' in node to point
# npm at the newly installed node, rather than the first one
# in the PATH, which would be the default otherwise.

# bash /path/to/npm/scripts/relocate.sh $nodepath
# sh /path/to/npm/scripts/relocate.sh $nodepath
# If $nodepath is blank, then it'll use /usr/bin/env

dir="$(dirname "$(dirname "$0")")"
Expand Down