Skip to content

Commit

Permalink
Added libyui-terminal (boo#937026).
Browse files Browse the repository at this point in the history
Run a command in a "screen" terminal. Useful for tests running on
headless machines.

`screen` is needed but not added as a dependency here; you need to add
it yourself if you use this.
  • Loading branch information
mvidner committed Jul 21, 2015
1 parent 24511f9 commit 8a3096d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions libyui-ncurses.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ rm -rf "$RPM_BUILD_ROOT"

%files -n @PROJECTNAME@@SONAME_MAJOR@
%defattr(-,root,root)
%{_bindir}/libyui-terminal
%dir %{_libdir}/@BASELIB@
%{_libdir}/@BASELIB@/lib*.so.*
%doc %dir %{_docdir}/@PROJECTNAME@@SONAME_MAJOR@
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
PROCESS_SOURCES()

INSTALL(PROGRAMS libyui-terminal DESTINATION "${YPREFIX}/bin")
44 changes: 44 additions & 0 deletions src/libyui-terminal
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
##
# Copyright (C) 2015 SUSE, LLC.
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) version 3.0 of the License. This library
# is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details. You should have received a copy of the GNU
# Lesser General Public License along with this library; if not, write
# to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
# Floor, Boston, MA 02110-1301 USA
##
# libyui-terminal
#
if [ $# = 0 -o "$1" = "-h" -o "$1" = "--help" ]; then
echo "Usage: $0 COMMAND [arguments...]"
echo " Runs COMMAND within a new terminal"
echo " which is useful for running tests on headless machines."
exit 0
fi

# We need the exit code and the output of "$@". Screen eats the exit
# code and hides the output. So let's use temporary files.
EXIT=`mktemp`
OUT=`mktemp`

echo "Using `basename $0` to run \"$@\""
# escape for embedding to "sh -c"
quoted=$(printf "%q " "$@")
# -D -m This also starts screen in "detached" mode, but doesn't fork
# a new process. The command exits if the session
# terminates.
screen -D -m sh -c "$quoted > $OUT 2>&1; echo \$? > $EXIT"

RET=`cat $EXIT`
rm -f $EXIT
cat $OUT
rm -f $OUT

echo "`basename $0` finished"
exit $RET

0 comments on commit 8a3096d

Please sign in to comment.