aboutsummaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorKevin Bowling <kbowling@FreeBSD.org>2021-04-08 19:53:53 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2021-04-08 19:55:20 +0000
commit298fdc2dd2e3d79321fbd5ac18c725e8c07b2224 (patch)
treefb90a76b95f8e2df95d711046fe5b485addd1b70 /sysutils
parent80a2e3a37fcf5c33a48a019e33f146afa92cb019 (diff)
downloadports-298fdc2dd2e3d79321fbd5ac18c725e8c07b2224.tar.gz
ports-298fdc2dd2e3d79321fbd5ac18c725e8c07b2224.zip
sysutils/byobu: Improve FreeBSD compatibility
PR: 254565 Approved by: Justin Coffman <jcoffman@xsecure.io> (maintainer)
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/byobu/Makefile5
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_cpu__count13
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_cpu__freq30
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_disk23
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_load__average11
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_memory77
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_time__binary8
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_trash9
-rw-r--r--sysutils/byobu/files/patch-usr_lib_byobu_uptime12
-rw-r--r--sysutils/byobu/pkg-message16
10 files changed, 168 insertions, 36 deletions
diff --git a/sysutils/byobu/Makefile b/sysutils/byobu/Makefile
index 5955362be5d8..4a17708893a2 100644
--- a/sysutils/byobu/Makefile
+++ b/sysutils/byobu/Makefile
@@ -2,6 +2,7 @@
PORTNAME= byobu
PORTVERSION= 5.133
+PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= http://launchpad.net/${PORTNAME}/trunk/${PORTVERSION}/+download/
DISTNAME= ${PORTNAME}_${PORTVERSION}.orig
@@ -15,7 +16,7 @@ LICENSE_FILE= ${WRKSRC}/COPYING
RUN_DEPENDS= bash:shells/bash \
gsed:textproc/gsed
-USES= autoreconf python shebangfix
+USES= autoreconf python shebangfix ncurses:port
SHEBANG_FILES= usr/lib/byobu/include/notify_osd \
usr/lib/byobu/include/config.py.in \
@@ -49,7 +50,5 @@ post-patch:
-e "s@/usr/bin/python@${PYTHON_CMD}@"
${REINPLACE_CMD} -e 's,@sysconfdir@/profile.d,$$(datadir)/@PACKAGE@,' \
${WRKSRC}/etc/profile.d/Makefile.am
- ${FIND} ${WRKSRC}/usr/lib/byobu -type f -maxdepth 1 | ${XARGS} \
- ${REINPLACE_CMD} -e 's:/proc:/compat/linux/proc:g'
.include <bsd.port.mk>
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_cpu__count b/sysutils/byobu/files/patch-usr_lib_byobu_cpu__count
new file mode 100644
index 000000000000..488987644088
--- /dev/null
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_cpu__count
@@ -0,0 +1,13 @@
+--- usr/lib/byobu/cpu_count.orig 2016-04-07 22:05:52 UTC
++++ usr/lib/byobu/cpu_count
+@@ -25,7 +25,9 @@ __cpu_count_detail() {
+
+ __cpu_count() {
+ local c
+- c=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
++ c=$(getconf _NPROCESSORS_ONLN 2>/dev/null || \
++ grep -ci "^processor" /proc/cpuinfo || \
++ sysctl -n hw.ncpu)
+ [ "$c" = "1" ] || printf "%sx" "$c"
+ }
+
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_cpu__freq b/sysutils/byobu/files/patch-usr_lib_byobu_cpu__freq
new file mode 100644
index 000000000000..094594b3d855
--- /dev/null
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_cpu__freq
@@ -0,0 +1,30 @@
+--- usr/lib/byobu/cpu_freq.orig 2016-04-07 22:05:52 UTC
++++ usr/lib/byobu/cpu_freq
+@@ -25,6 +25,7 @@ __cpu_freq_detail() {
+
+ __cpu_freq() {
+ local hz freq count
++
+ if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then
+ read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
+ fpdiv $hz "1000000" 1 # 1Ghz
+@@ -33,7 +34,6 @@ __cpu_freq() {
+ if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then
+ freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%01.1f", $2 / 1000 }')
+ else
+- # Must scale frequency by number of processors, if counting bogomips
+ count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo)
+ freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }')
+ freq=$(printf "%s %s" "$freq" "$count" | awk '{printf "%01.1f\n", $1/$2/1000}')
+@@ -41,7 +41,11 @@ __cpu_freq() {
+ elif hz=$(sysctl -n hw.cpufrequency 2>/dev/null); then
+ fpdiv $hz "1000000000" 1 # 1Ghz
+ freq="$_RET"
++ elif hz=$(sysctl -n machdep.tsc_freq 2>/dev/null); then
++ fpdiv $hz "1000000000" 1
++ freq="$_RET"
+ fi
++
+ [ -n "$freq" ] || return
+ color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --
+ }
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_disk b/sysutils/byobu/files/patch-usr_lib_byobu_disk
index 5198a1d25cc6..7d8e86a147b5 100644
--- a/sysutils/byobu/files/patch-usr_lib_byobu_disk
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_disk
@@ -1,25 +1,28 @@
---- usr/lib/byobu/disk.orig 2016-04-07 22:05:52 UTC
+--- usr/lib/byobu/disk.orig 2020-02-09 16:40:29 UTC
+++ usr/lib/byobu/disk
-@@ -20,7 +20,7 @@
+@@ -20,7 +20,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__disk_detail() {
- df -h -P
-+ df -h
++ if [ $(uname) = "FreeBSD" ]; then
++ df -h
++ else
++ df -h -P
++ fi
}
__disk() {
-@@ -28,11 +28,11 @@ __disk() {
- # Default to /, but let users override
- [ -z "$MONITORED_DISK" ] && MP="/" || MP="$MONITORED_DISK"
- case $MP in
-- /dev/*) MP=$(awk '$1 == m { print $2; exit(0); }' "m=$MP" /proc/mounts);;
-+ /dev/*) MP=$(awk '$1 == m { print $2; exit(0); }' "m=$MP" /compat/linux/proc/mounts);;
+@@ -32,7 +36,11 @@ __disk() {
esac
# this could be done faster with 'stat --file-system --format'
# but then we'd have to do blocks -> human units ourselves
- out=$({ df -h -P "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
-+ out=$({ df -h "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
++ if [ $(uname) = "FreeBSD" ]; then
++ out=$({ df -h "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
++ else
++ out=$({ df -h -P "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }')
++ fi
set -- ${out}
size=${1}; pct=${2};
unit=${size#${size%?}} # get the unit (last char)
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_load__average b/sysutils/byobu/files/patch-usr_lib_byobu_load__average
new file mode 100644
index 000000000000..c060aa5d5505
--- /dev/null
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_load__average
@@ -0,0 +1,11 @@
+--- usr/lib/byobu/load_average.orig 2016-04-07 22:05:52 UTC
++++ usr/lib/byobu/load_average
+@@ -26,6 +26,8 @@ __load_average_detail() {
+ __load_average() {
+ if [ -r "/proc/loadavg" ]; then
+ read one five fifteen other < /proc/loadavg
++ elif [ $(uname) = "FreeBSD" ]; then
++ one=$(uptime | sed -En 's:.*averages\: ([[:digit:]]+\.[[:digit:]]+),.*:\1:p')
+ else
+ one=$(uptime | sed -e "s/.*://" | awk '{print $1}')
+ fi
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_memory b/sysutils/byobu/files/patch-usr_lib_byobu_memory
index b4952a8fbfae..bf08bbfac38b 100644
--- a/sysutils/byobu/files/patch-usr_lib_byobu_memory
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_memory
@@ -1,11 +1,74 @@
---- usr/lib/byobu/memory.orig 2019-08-23 17:23:09 UTC
+--- usr/lib/byobu/memory.orig 2016-09-15 19:22:48 UTC
+++ usr/lib/byobu/memory
-@@ -52,7 +52,7 @@ __memory() {
- buffers_plus_cached=$(($buffers+$cached))
- # "free output" buffers and cache (output from 'free')
- fo_buffers=$(($kb_main_used - $buffers_plus_cached))
+@@ -26,16 +26,35 @@ __memory_detail() {
+ __memory() {
+ local free="" total="" buffers="" cached=""
+ local kb_main_used=0 buffers_plus_cached=0 fo_buffers=0 fo_cached=0
+- if [ -r /proc/meminfo ]; then
+- while read tok val unit; do
+- case "$tok" in
+- MemTotal:) total=${val};;
+- MemFree:) free=${val};;
+- Buffers:) buffers=${val};;
+- Cached:) cached=${val};;
+- esac
+- [ -n "${free}" -a -n "${total}" -a -n "${buffers}" -a -n "${cached}" ] && break;
+- done < /proc/meminfo
++
++ if [ $(uname) = "Linux" ]; then
++ if [ -r /proc/meminfo ]; then
++ while read tok val unit; do
++ case "$tok" in
++ MemTotal:) total=${val};;
++ MemFree:) free=${val};;
++ Buffers:) buffers=${val};;
++ Cached:) cached=${val};;
++ esac
++ [ -n "${free}" -a -n "${total}" -a -n "${buffers}" -a -n "${cached}" ] && break;
++ done < /proc/meminfo
++ fi
++ elif [ $(uname) = "FreeBSD" ]; then
++ # FreeBSD support
++ mem_phys=$(sysctl -n hw.physmem)
++ page_size=$(sysctl -n hw.pagesize)
++ mem_inactive=$(($(sysctl -n vm.stats.vm.v_inactive_count)*$page_size))
++ mem_cache=$(($(sysctl -n vm.stats.vm.v_cache_count)*$page_size))
++ mem_free=$(($(sysctl -n vm.stats.vm.v_free_count)*$page_size))
++
++ mem_avail=$(($mem_inactive+$mem_cache+$mem_free))
++ mem_used=$(($mem_phys-$mem_avail))
++
++ total=$(($mem_phys/1024))
++ free=$(($mem_avail/1024))
++
++ buffers=0
++ cached=0
+ elif eval $BYOBU_TEST vm_stat >/dev/null 2>&1; then
+ # MacOS support
+ # calculation borrowed from http://apple.stackexchange.com/a/48195/18857
+@@ -44,16 +63,18 @@ __memory() {
+ speculative_blocks=$(vm_stat | grep speculative | awk '{ print $3 }' | sed -e 's/\.//')
+ free=$((($free_blocks+speculative_blocks)*4))
+ inactive=$(($inactive_blocks*4))
+- total=$((($free+$inactive)))
++ total=$(($free+$inactive))
+ buffers=0
+ cached=0
+ fi
+- kb_main_used=$(($total-$free))
+- buffers_plus_cached=$(($buffers+$cached))
+- # "free output" buffers and cache (output from 'free')
+- fo_buffers=$(($kb_main_used - $buffers_plus_cached))
- fpdiv $((100*${fo_buffers})) "${total}" 0;
-+ fpdiv $((100*${kb_main_used})) "${total}" 0;
- usage=${_RET}
+- usage=${_RET}
++
++ kb_main_used=$(($total-$free))
++ buffers_plus_cached=$(($buffers+$cached))
++ # "free output" buffers and cache (output from 'free')
++ fo_buffers=$(($kb_main_used - $buffers_plus_cached))
++ fpdiv $((100*${fo_buffers})) "${total}" 0;
++ usage=${_RET}
++
if [ $total -ge 1048576 ]; then
fpdiv "$total" 1048567 1
+ total=${_RET}
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_time__binary b/sysutils/byobu/files/patch-usr_lib_byobu_time__binary
new file mode 100644
index 000000000000..ac5fcb4524d8
--- /dev/null
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_time__binary
@@ -0,0 +1,8 @@
+--- usr/lib/byobu/time_binary.orig 2013-08-28 03:50:01 UTC
++++ usr/lib/byobu/time_binary
+@@ -172,3 +172,5 @@ fi
+ color k w
+ printf "%s" "$display_time"
+ color --
++
++# vi: syntax=sh ts=4 noexpandtab
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_trash b/sysutils/byobu/files/patch-usr_lib_byobu_trash
new file mode 100644
index 000000000000..dca0d6909af2
--- /dev/null
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_trash
@@ -0,0 +1,9 @@
+--- usr/lib/byobu/trash.orig 2016-04-07 22:05:52 UTC
++++ usr/lib/byobu/trash
+@@ -34,4 +34,4 @@ __trash() {
+ printf "%s[%s]" "$ICON_TRASH" "$count"
+ }
+
+-# vi: syntax=sh ts=4 noexpandtab
++# vi: syntax=sh ts=4 noexpandtab
+\ No newline at end of file
diff --git a/sysutils/byobu/files/patch-usr_lib_byobu_uptime b/sysutils/byobu/files/patch-usr_lib_byobu_uptime
new file mode 100644
index 000000000000..25efa2075fb4
--- /dev/null
+++ b/sysutils/byobu/files/patch-usr_lib_byobu_uptime
@@ -0,0 +1,12 @@
+--- usr/lib/byobu/uptime.orig 2016-05-31 14:48:13 UTC
++++ usr/lib/byobu/uptime
+@@ -30,6 +30,9 @@ __uptime() {
+ if [ -r /proc/uptime ]; then
+ read u idle < /proc/uptime
+ u=${u%.*}
++ elif [ $(uname) = "FreeBSD" ]; then
++ u=$(sysctl -n kern.boottime | sed -En 's:.*sec = ([[:digit:]]+),.*:\1:p')
++ u=$(($(date +%s) - $u))
+ elif [ -x /usr/sbin/sysctl ]; then
+ # MacOS support
+ u=$(/usr/sbin/sysctl -n kern.boottime | cut -f4 -d' ' | cut -d',' -f1)
diff --git a/sysutils/byobu/pkg-message b/sysutils/byobu/pkg-message
deleted file mode 100644
index 9b5cb832d96f..000000000000
--- a/sysutils/byobu/pkg-message
+++ /dev/null
@@ -1,16 +0,0 @@
-[
-{ type: install
- message: <<EOM
-byobu requires linprocfs(5) mounted on /compat/linux/proc
-
-If you have not done it yet, please do the following:
-
- mkdir -p /compat/linux/proc
- mount -t linprocfs linproc /compat/linux/proc
-
-To make it permanent, you need the following line in /etc/fstab:
-
- linproc /compat/linux/proc linprocfs rw,late 0 0
-EOM
-}
-]