* [PATCH 1/3] base-files: profile: Whitespace clean up
@ 2017-04-03 12:48 Peter Kjellerstedt
2017-04-03 12:48 ` [PATCH 2/3] base-files: profile: Do not assume that the tty command exists Peter Kjellerstedt
2017-04-03 12:48 ` [PATCH 3/3] base-files: profile: Simplify setting variables conditionally Peter Kjellerstedt
0 siblings, 2 replies; 5+ messages in thread
From: Peter Kjellerstedt @ 2017-04-03 12:48 UTC (permalink / raw)
To: openembedded-core
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
meta/recipes-core/base-files/base-files/profile | 29 +++++++++++++------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
index c616616cee..22dfb4f219 100644
--- a/meta/recipes-core/base-files/base-files/profile
+++ b/meta/recipes-core/base-files/base-files/profile
@@ -6,28 +6,29 @@ EDITOR="vi" # needed for packages like cron, git-commit
test -z "$TERM" && TERM="vt100" # Basic terminal capab. For screen etc.
if [ "$HOME" = "ROOTHOME" ]; then
- PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
+ PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
fi
if [ "$PS1" ]; then
-# works for bash and ash (no other shells known to be in use here)
- PS1='\u@\h:\w\$ '
+ # works for bash and ash (no other shells known to be in use here)
+ PS1='\u@\h:\w\$ '
fi
if [ -d /etc/profile.d ]; then
- for i in /etc/profile.d/*.sh ; do
- if [ -f $i -a -r $i ]; then
- . $i
- fi
- done
- unset i
+ for i in /etc/profile.d/*.sh; do
+ if [ -f $i -a -r $i ]; then
+ . $i
+ fi
+ done
+ unset i
fi
if [ -x /usr/bin/resize ] && termpath="`tty`"; then
- # Make sure we are on a serial console (i.e. the device used starts with /dev/tty),
- # otherwise we confuse e.g. the eclipse launcher which tries do use ssh
- case "$termpath" in
- /dev/tty[A-z]*) resize >/dev/null
- esac
+ # Make sure we are on a serial console (i.e. the device used starts with
+ # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
+ # tries do use ssh
+ case "$termpath" in
+ /dev/tty[A-z]*) resize >/dev/null
+ esac
fi
export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
--
2.12.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] base-files: profile: Do not assume that the tty command exists
2017-04-03 12:48 [PATCH 1/3] base-files: profile: Whitespace clean up Peter Kjellerstedt
@ 2017-04-03 12:48 ` Peter Kjellerstedt
2017-04-03 12:48 ` [PATCH 3/3] base-files: profile: Simplify setting variables conditionally Peter Kjellerstedt
1 sibling, 0 replies; 5+ messages in thread
From: Peter Kjellerstedt @ 2017-04-03 12:48 UTC (permalink / raw)
To: openembedded-core
This avoids the following error when logging in to a host that does
not have the tty command:
-sh: tty: not found
Reported-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
meta/recipes-core/base-files/base-files/profile | 6 +++---
meta/recipes-core/base-files/base-files_3.0.14.bb | 4 ----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
index 22dfb4f219..ceaf15f799 100644
--- a/meta/recipes-core/base-files/base-files/profile
+++ b/meta/recipes-core/base-files/base-files/profile
@@ -22,12 +22,12 @@ if [ -d /etc/profile.d ]; then
unset i
fi
-if [ -x /usr/bin/resize ] && termpath="`tty`"; then
+if command -v resize >/dev/null && command -v tty >/dev/null; then
# Make sure we are on a serial console (i.e. the device used starts with
# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
# tries do use ssh
- case "$termpath" in
- /dev/tty[A-z]*) resize >/dev/null
+ case $(tty) in
+ /dev/tty[A-z]*) resize >/dev/null;;
esac
fi
diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb b/meta/recipes-core/base-files/base-files_3.0.14.bb
index f56969c52e..ca7bf06353 100644
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -128,10 +128,6 @@ do_install () {
install -m 0644 ${WORKDIR}/host.conf ${D}${sysconfdir}/host.conf
install -m 0644 ${WORKDIR}/motd ${D}${sysconfdir}/motd
- if [ "/usr/bin" != "${bindir}" ]; then
- sed -i "s,/usr/bin/resize,${bindir}/resize," ${D}${sysconfdir}/profile
- fi
-
ln -sf /proc/mounts ${D}${sysconfdir}/mtab
}
--
2.12.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] base-files: profile: Simplify setting variables conditionally
2017-04-03 12:48 [PATCH 1/3] base-files: profile: Whitespace clean up Peter Kjellerstedt
2017-04-03 12:48 ` [PATCH 2/3] base-files: profile: Do not assume that the tty command exists Peter Kjellerstedt
@ 2017-04-03 12:48 ` Peter Kjellerstedt
2017-04-03 15:45 ` Leonardo Sandoval
1 sibling, 1 reply; 5+ messages in thread
From: Peter Kjellerstedt @ 2017-04-03 12:48 UTC (permalink / raw)
To: openembedded-core
It is preferred to use `[ "$FOO" ] || ...` instead of
`[ -z "$FOO" ] && ...` as the latter leaves $? set to 1.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
index ceaf15f799..a062028226 100644
--- a/meta/recipes-core/base-files/base-files/profile
+++ b/meta/recipes-core/base-files/base-files/profile
@@ -3,15 +3,13 @@
PATH="/usr/local/bin:/usr/bin:/bin"
EDITOR="vi" # needed for packages like cron, git-commit
-test -z "$TERM" && TERM="vt100" # Basic terminal capab. For screen etc.
+[ "$TERM" ] || TERM="vt100" # Basic terminal capab. For screen etc.
-if [ "$HOME" = "ROOTHOME" ]; then
- PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
-fi
-if [ "$PS1" ]; then
- # works for bash and ash (no other shells known to be in use here)
- PS1='\u@\h:\w\$ '
-fi
+# Add /sbin & co to $PATH for the root user
+[ "$HOME" != "ROOTHOME" ] || PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
+
+# Set the prompt for bash and ash (no other shells known to be in use here)
+[ -z "$PS1" ] || PS1='\u@\h:\w\$ '
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
--
2.12.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] base-files: profile: Simplify setting variables conditionally
2017-04-03 12:48 ` [PATCH 3/3] base-files: profile: Simplify setting variables conditionally Peter Kjellerstedt
@ 2017-04-03 15:45 ` Leonardo Sandoval
2017-04-04 7:50 ` Peter Kjellerstedt
0 siblings, 1 reply; 5+ messages in thread
From: Leonardo Sandoval @ 2017-04-03 15:45 UTC (permalink / raw)
To: Peter Kjellerstedt; +Cc: openembedded-core
On Mon, 2017-04-03 at 14:48 +0200, Peter Kjellerstedt wrote:
> It is preferred to use `[ "$FOO" ] || ...` instead of
> `[ -z "$FOO" ] && ...` as the latter leaves $? set to 1.
>
> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
> meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
> index ceaf15f799..a062028226 100644
> --- a/meta/recipes-core/base-files/base-files/profile
> +++ b/meta/recipes-core/base-files/base-files/profile
> @@ -3,15 +3,13 @@
>
> PATH="/usr/local/bin:/usr/bin:/bin"
> EDITOR="vi" # needed for packages like cron, git-commit
> -test -z "$TERM" && TERM="vt100" # Basic terminal capab. For screen etc.
> +[ "$TERM" ] || TERM="vt100" # Basic terminal capab. For screen etc.
>
> -if [ "$HOME" = "ROOTHOME" ]; then
> - PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
> -fi
> -if [ "$PS1" ]; then
> - # works for bash and ash (no other shells known to be in use here)
> - PS1='\u@\h:\w\$ '
> -fi
> +# Add /sbin & co to $PATH for the root user
> +[ "$HOME" != "ROOTHOME" ] || PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
> +
> +# Set the prompt for bash and ash (no other shells known to be in use here)
> +[ -z "$PS1" ] || PS1='\u@\h:\w\$ '
Here you are using [ -z ] instead of [ ], is this intended? I do not
think so based on your commit message.
>
> if [ -d /etc/profile.d ]; then
> for i in /etc/profile.d/*.sh; do
> --
> 2.12.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] base-files: profile: Simplify setting variables conditionally
2017-04-03 15:45 ` Leonardo Sandoval
@ 2017-04-04 7:50 ` Peter Kjellerstedt
0 siblings, 0 replies; 5+ messages in thread
From: Peter Kjellerstedt @ 2017-04-04 7:50 UTC (permalink / raw)
To: Leonardo Sandoval; +Cc: openembedded-core@lists.openembedded.org
> -----Original Message-----
> From: Leonardo Sandoval
> [mailto:leonardo.sandoval.gonzalez@linux.intel.com]
> Sent: den 3 april 2017 17:45
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH 3/3] base-files: profile: Simplify
> setting variables conditionally
>
> On Mon, 2017-04-03 at 14:48 +0200, Peter Kjellerstedt wrote:
> > It is preferred to use `[ "$FOO" ] || ...` instead of
> > `[ -z "$FOO" ] && ...` as the latter leaves $? set to 1.
> >
> > Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> > ---
> > meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
> > 1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
> > index ceaf15f799..a062028226 100644
> > --- a/meta/recipes-core/base-files/base-files/profile
> > +++ b/meta/recipes-core/base-files/base-files/profile
> > @@ -3,15 +3,13 @@
> >
> > PATH="/usr/local/bin:/usr/bin:/bin"
> > EDITOR="vi" # needed for packages like cron, git-commit
> > -test -z "$TERM" && TERM="vt100" # Basic terminal capab. For screen etc.
> > +[ "$TERM" ] || TERM="vt100" # Basic terminal capab. For screen etc.
> >
> > -if [ "$HOME" = "ROOTHOME" ]; then
> > - PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
> > -fi
> > -if [ "$PS1" ]; then
> > - # works for bash and ash (no other shells known to be in use here)
> > - PS1='\u@\h:\w\$ '
> > -fi
> > +# Add /sbin & co to $PATH for the root user
> > +[ "$HOME" != "ROOTHOME" ] || PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
> > +
> > +# Set the prompt for bash and ash (no other shells known to be in use here)
> > +[ -z "$PS1" ] || PS1='\u@\h:\w\$ '
>
> Here you are using [ -z ] instead of [ ], is this intended? I do not
> think so based on your commit message.
Yes, it is intentional to maintain the original functionality.
However, I may have to update the commit message a bit. It was
written when I had only done the change for the $TERM variable.
> >
> > if [ -d /etc/profile.d ]; then
> > for i in /etc/profile.d/*.sh; do
> > --
> > 2.12.0
//Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-04 7:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-03 12:48 [PATCH 1/3] base-files: profile: Whitespace clean up Peter Kjellerstedt
2017-04-03 12:48 ` [PATCH 2/3] base-files: profile: Do not assume that the tty command exists Peter Kjellerstedt
2017-04-03 12:48 ` [PATCH 3/3] base-files: profile: Simplify setting variables conditionally Peter Kjellerstedt
2017-04-03 15:45 ` Leonardo Sandoval
2017-04-04 7:50 ` Peter Kjellerstedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox