1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-12-24 19:37:49 +03:00

maketgz: tidy-up [ci skip] (#901)

- fix shellcheck warnings:
  - use quotes
  - use `$()`
- use `printf` (instead of calling perl).
- indent.
- copy/adapt header comment from curl to `maketgz`.
This commit is contained in:
Viktor Szakats
2023-03-30 20:59:47 +02:00
committed by GitHub
parent d23133b5a3
commit 5012442850
7 changed files with 90 additions and 89 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/usr/bin/env perl
# git log --pretty=fuller --no-color --date=short --decorate=full

59
maketgz
View File

@@ -1,26 +1,27 @@
#! /bin/sh
# Script to build release-archives with
#!/bin/sh
# Script to build release-archives with. Note that this requires a checkout
# from git and you should first run 'autoreconf -fi' and './configure'.
#
version=$1
version="$1"
if [ -z "$version" ]; then
echo "Specify a version number!"
exit
fi
if [ "xonly" = "x$2" ]; then
if [ "only" = "$2" ]; then
echo "Setup version number only!"
only=1
fi
libversion="$version"
major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"`
minor=`echo $libversion |cut -d. -f2 | sed -e "s/[^0-9]//g"`
patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
major="$(echo "$libversion" | cut -d. -f1 | sed -e "s/[^0-9]//g")"
minor="$(echo "$libversion" | cut -d. -f2 | sed -e "s/[^0-9]//g")"
patch="$(echo "$libversion" | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g")"
numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
numeric="$(printf "%02x%02x%02x\n" "$major" "$minor" "$patch")"
HEADER=include/libssh2.h
@@ -28,23 +29,23 @@ if test -z "$only"; then
ext=".dist"
# when not setting up version numbers locally
for a in $HEADER; do
cp $a "$a$ext"
cp "$a" "$a$ext"
done
HEADER="$HEADER$ext"
fi
# requires a date command that knows -u for UTC time zone
datestamp=`LC_TIME=C date -u`
datestamp="$(LC_TIME=C date -u)"
# Replace in-place version number in header file:
sed -i.bak \
-e 's/^#define LIBSSH2_VERSION .*/#define LIBSSH2_VERSION "'$libversion'"/g' \
-e 's/^#define LIBSSH2_VERSION_NUM .*/#define LIBSSH2_VERSION_NUM 0x'$numeric'/g' \
-e 's/^#define LIBSSH2_VERSION_MAJOR .*/#define LIBSSH2_VERSION_MAJOR '$major'/g' \
-e 's/^#define LIBSSH2_VERSION_MINOR .*/#define LIBSSH2_VERSION_MINOR '$minor'/g' \
-e 's/^#define LIBSSH2_VERSION_PATCH .*/#define LIBSSH2_VERSION_PATCH '$patch'/g' \
-e "s/^#define LIBSSH2_VERSION .*/#define LIBSSH2_VERSION \"$libversion\"/g" \
-e "s/^#define LIBSSH2_VERSION_NUM .*/#define LIBSSH2_VERSION_NUM 0x$numeric/g" \
-e "s/^#define LIBSSH2_VERSION_MAJOR .*/#define LIBSSH2_VERSION_MAJOR $major/g" \
-e "s/^#define LIBSSH2_VERSION_MINOR .*/#define LIBSSH2_VERSION_MINOR $minor/g" \
-e "s/^#define LIBSSH2_VERSION_PATCH .*/#define LIBSSH2_VERSION_PATCH $patch/g" \
-e "s/^#define LIBSSH2_TIMESTAMP .*/#define LIBSSH2_TIMESTAMP \"$datestamp\"/g" \
$HEADER
"$HEADER"
rm -f "$HEADER.bak"
@@ -59,7 +60,7 @@ fi
findprog() {
file="$1"
for part in `echo $PATH| tr ':' ' '`; do
for part in $(echo "$PATH" | tr ':' ' '); do
path="$part/$file"
if [ -x "$path" ]; then
# there it is!
@@ -98,7 +99,7 @@ git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./git2ne
echo "make dist"
targz="libssh2-$version.tar.gz"
make -s dist VERSION=$version
make -s dist "VERSION=$version"
res=$?
if test "$res" != 0; then
@@ -113,7 +114,7 @@ fi
bzip2="libssh2-$version.tar.bz2"
echo "Generating $bzip2"
gzip -dc $targz | bzip2 --best > $bzip2
gzip -dc "$targz" | bzip2 --best > "$bzip2"
############################################################################
#
@@ -122,21 +123,21 @@ gzip -dc $targz | bzip2 --best > $bzip2
xz="libssh2-$version.tar.xz"
echo "Generating $xz"
gzip -dc $targz | xz -6e - > $xz
gzip -dc "$targz" | xz -6e - > "$xz"
############################################################################
#
# Now make a zip archive from the tar.gz original
#
makezip() {
rm -rf $tempdir
mkdir $tempdir
cd $tempdir
gzip -dc ../$targz | tar -xf -
find . | zip $zip -@ >/dev/null
mv $zip ../
cd ..
rm -rf $tempdir
rm -rf "$tempdir"
mkdir "$tempdir"
cd "$tempdir" || exit 1
gzip -dc "../$targz" | tar -xf -
find . | zip "$zip" -@ >/dev/null
mv "$zip" ../
cd .. || exit 1
rm -rf "$tempdir"
}
zip="libssh2-$version.zip"
@@ -147,4 +148,4 @@ makezip
echo "------------------"
echo "maketgz report:"
echo ""
ls -l $targz $bzip2 $zip $xz
ls -l "$targz" "$bzip2" "$zip" "$xz"

View File

@@ -6,9 +6,9 @@ set -e
# Run syntax checks for all manpages in the documentation tree.
#
srcdir=${srcdir:-$PWD}
dstdir=${builddir:-$PWD}
mandir=${srcdir}/../docs
srcdir="${srcdir:-$PWD}"
dstdir="${builddir:-$PWD}"
mandir="${srcdir}/../docs"
#
# Only test if suitable man is available
@@ -20,11 +20,11 @@ fi
ec=0
trap "rm -f $dstdir/man3" EXIT
trap 'rm -f "$dstdir/man3"' EXIT
ln -sf "$mandir" "$dstdir/man3"
for manpage in $mandir/libssh2_*.*; do
for manpage in "$mandir"/libssh2_*.*; do
echo "$manpage"
warnings=$(LANG=en_US.UTF-8 MANWIDTH=80 man -M "$dstdir" --warnings \
-E UTF-8 -l "$manpage" 2>&1 >/dev/null)
@@ -34,4 +34,4 @@ for manpage in $mandir/libssh2_*.*; do
fi
done
exit $ec
exit "$ec"

View File

@@ -1,10 +1,12 @@
#!/bin/bash -eu
#!/usr/bin/env bash
set -eu
# This script is called by the oss-fuzz main project when compiling the fuzz
# targets. This script is regression tested by ci/ossfuzz.sh.
# Save off the current folder as the build root.
export BUILD_ROOT=$PWD
export BUILD_ROOT="$PWD"
echo "CC: $CC"
echo "CXX: $CXX"
@@ -13,7 +15,8 @@ echo "CFLAGS: $CFLAGS"
echo "CXXFLAGS: $CXXFLAGS"
echo "OUT: $OUT"
export MAKEFLAGS+="-j$(nproc)"
MAKEFLAGS+="-j$(nproc)"
export MAKEFLAGS
# Install dependencies
apt-get -y install automake libtool libssl-dev zlib1g-dev
@@ -27,4 +30,4 @@ apt-get -y install automake libtool libssl-dev zlib1g-dev
make V=1
# Copy the fuzzer to the output directory.
cp -v tests/ossfuzz/ssh2_client_fuzzer $OUT/
cp -v tests/ossfuzz/ssh2_client_fuzzer "$OUT/"

View File

@@ -5,44 +5,43 @@
# Start sshd, invoke parameters, saving exit code, kill sshd, and
# return exit code.
srcdir=${srcdir:-$PWD}
SSHD=${SSHD:-/usr/sbin/sshd}
srcdir="${srcdir:-$PWD}"
SSHD="${SSHD:-/usr/sbin/sshd}"
cmd="./ssh2${EXEEXT}"
srcdir=`cd "$srcdir"; pwd`
srcdir="$(cd "$srcdir" || exit; pwd)"
PRIVKEY=$srcdir/etc/user
export PRIVKEY
PUBKEY=$srcdir/etc/user.pub
export PUBKEY
export PRIVKEY="$srcdir/etc/user"
export PUBKEY="$srcdir/etc/user.pub"
if test -n "$DEBUG"; then
libssh2_sshd_params="-d -d"
libssh2_sshd_params="-d -d"
fi
chmod go-rwx "$srcdir"/etc/host*
$SSHD -f /dev/null -h "$srcdir"/etc/host \
-o 'Port 4711' \
-o 'Protocol 2' \
-o "AuthorizedKeysFile $srcdir/etc/user.pub" \
-o 'UsePrivilegeSeparation no' \
-o 'StrictModes no' \
-D \
$libssh2_sshd_params &
# shellcheck disable=SC2086
"$SSHD" -f /dev/null -h "$srcdir/etc/host" \
-o 'Port 4711' \
-o 'Protocol 2' \
-o "AuthorizedKeysFile \"$srcdir/etc/user.pub\"" \
-o 'UsePrivilegeSeparation no' \
-o 'StrictModes no' \
-D \
$libssh2_sshd_params &
sshdpid=$!
trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT
trap 'kill "${sshdpid}"; echo signal killing sshd; exit 1;' EXIT
: "started sshd (${sshdpid})"
sleep 3
: Invoking $cmd...
eval $cmd
: "Invoking $cmd..."
eval "$cmd"
ec=$?
: Self-test exit code $ec
: "Self-test exit code $ec"
: "killing sshd (${sshdpid})"
kill "${sshdpid}" > /dev/null 2>&1
trap "" EXIT
exit $ec
exit "$ec"

View File

@@ -10,44 +10,42 @@ SSHD="@SSHD_EXECUTABLE@"
cmd="\"$1\""
PRIVKEY=$srcdir/etc/user
export PRIVKEY
PUBKEY=$srcdir/etc/user.pub
export PUBKEY
export PRIVKEY="$srcdir/etc/user"
export PUBKEY="$srcdir/etc/user.pub"
if test -n "$DEBUG"; then
libssh2_sshd_params="-d -d"
libssh2_sshd_params="-d -d"
fi
chmod go-rwx "$srcdir"/etc/host*
# shellcheck disable=SC2086
"$SSHD" -f /dev/null -h "$srcdir/etc/host" \
-o 'Port 4711' \
-o 'Protocol 2' \
-o "AuthorizedKeysFile \"$srcdir/etc/user.pub\"" \
-o 'UsePrivilegeSeparation no' \
-o 'StrictModes no' \
-D \
$libssh2_sshd_params &
-o 'Port 4711' \
-o 'Protocol 2' \
-o "AuthorizedKeysFile \"$srcdir/etc/user.pub\"" \
-o 'UsePrivilegeSeparation no' \
-o 'StrictModes no' \
-D \
$libssh2_sshd_params &
sshdpid=$!
trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT
trap 'kill "${sshdpid}"; echo signal killing sshd; exit 1;' EXIT
: "started sshd (${sshdpid})"
sleep 3
if ! kill -0 ${sshdpid}
then
echo "SSHD exited before test started"
exit 1
if ! kill -0 "${sshdpid}"; then
echo "SSHD exited before test started"
exit 1
fi
: Invoking $cmd...
: "Invoking $cmd..."
eval "$cmd"
ec=$?
: Self-test exit code $ec
: "Self-test exit code $ec"
: "killing sshd (${sshdpid})"
kill "${sshdpid}" > /dev/null 2>&1
trap "" EXIT
exit $ec
exit "$ec"

View File

@@ -5,24 +5,24 @@
# Start sshd, invoke parameters, saving exit code, kill sshd, and
# return exit code.
cmd="$@"
SSHD=${SSHD:-/usr/sbin/sshd}
cmd="$*"
SSHD="${SSHD:-/usr/sbin/sshd}"
$SSHD -f etc/sshd_config -h $PWD/etc/host -D &
"$SSHD" -f etc/sshd_config -h "$PWD/etc/host" -D &
sshdpid=$!
trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT
trap 'kill "${sshdpid}"; echo signal killing sshd; exit 1;' EXIT
: "started sshd (${sshdpid})"
sleep 1
: Invoking $cmd...
eval $cmd
: "Invoking $cmd..."
eval "$cmd"
ec=$?
: Self-test exit code $ec
: "Self-test exit code $ec"
: "killing sshd (${sshdpid})"
kill "${sshdpid}" > /dev/null 2>&1
trap "" EXIT
exit $ec
exit "$ec"