hoe to do check patch before up-steaming in freebsd? - freebsd

I am new to freebsd, and i want to know what is the procedure to upstream a patch on freebsd, is there any script for freebsd to check the patch before up-streaming ( like linux has checkpatch.pl ) ? if not then how we are validating the patch. thanks

Related

how to have linux kernel export /proc/[pid]/io?

Im running linux on my board and have to read info in /proc/[pid]/io. But it is not found.
For ex:
$ dd if=/dev/zero of=/tmp/aa &
[1] 926
$ cat /proc/926/io
cat: /proc/926/io: No such file or directory
Which I need enable to have kernel export that?
Many thanks for your help!
I just discovered that another thing is necessary.
I just recompiled a 4.4 kernel (for an embedded system) and enabling the CONFIG_TASKSTATS was not enough. I have to enable
CONFIG_TASKSTATS=y
CONFIG_TASK_XACCT=y
CONFIG_TASK_IO_ACCOUNTING=y
in order for the /proc/<pid>/io to appear.
According to this, you need CONFIG_TASKSTATS enabled in your kernel.
You can check your current kernel's config in various ways depending on distribution, but looking at /boot/config-$(uname -r) works in Redhat flavors.
If you don't have that option configured, you'll need to recompile your kernel, or investigate why your distro doesn't enable it.

How to build libfetch in linux?

As is known for us all, source code for libfetch.so is not originally designed for redhat linux,and I have searched and tried many times, failed ,but I know someone has successfully made it previously.
Of course, commonly used ./confgure --parameter && make && make install will fail immediately, for the simple reason that it has no configure file(or something like that) at all!
source code download: http://www.filewatcher.com/m/libfetch-2.33.tar.gz.46611-0.html
so, can someone of you help me ?
I was able to build libfetch on Linux Mint using the Makefile which is available from the Alpine Linux aports repo. (It is very different from the BSD Makefile which comes with the libfetch source.) All the other source code was unchanged.

How to detect if my server is running centos or other from a perl script

I want to display some text in a script only if the Operating System is Centos .
How can i do that in a perl script ?
To answer your exact question, you can identify CentOS by reading the contents of /etc/redhat-release. E.g.
$ cat /etc/redhat-release
CentOS release 5.9 (Final)
As other commenters have made clear, it is better to depend on the exact OS features you want, or write code to be portable, rather than limiting it to a particular distribution of Linux.
Try $^O. It contains the OS that was used to build your version of Perl. Here's what perlvar has to say about it.
The name of the operating system under which this copy of Perl was
built, as determined during the configuration process. For examples
see PLATFORMS in perlport. The value is identical to $Config{'osname'}
. See also Config and the -V command-line switch documented in
perlrun. In Windows platforms, $^O is not very helpful: since it is
always MSWin32 , it doesn't tell the difference between
95/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() or
Win32::GetOSVersion() (see Win32 and perlport) to distinguish between
the variants. This variable was added in Perl 5.003.
Also see perlport.

Programmatically determining Ubuntu distribution and architecture?

What's the best way to programmatically determine if the current machine is running Ubuntu, what architecture it has, and what version of Ubuntu it is running?
One way would be to scan the output of uname -a to check for the right kernel version and architecture.
Another way would be to scan /etc/apt/sources.list for the Ubuntu distribution keyword (eq precise, quantal, etc)
Is there a better way?
Apart from uname -a, There are several way to get information about the current distribution.
The best way is to parse the release files. They usually ended with -release or _release and located in /etc. Following command will find them all.
ls /etc/*{-,_}release
Ubuntu uses lsb_release
Redhat/Fedora uses redhat-release
Slackware uses slackware-release
Gentoo uses gentoo-release
Debian's corresponding file is /etc/debian_version. This file will also (somewhat misleadingly, but for a good reason) be present on Ubuntu systems, though.
Another file is /etc/issue which is used for machine identification and pre-login prompt can be used to determine current distribution information.
System information can be found in /proc/version too.
cat /proc/version
One way would be to scan the output of uname -a to check for the right kernel version and architecture.
But one does not generally want to parse the output of such tools, because it's not elegant (it's considered a hack, so to say).
However, you can use the uname() function/syscall:
#include <sys/utsname.h>
struct utsname sysinfo;
if (uname(&sysinfo) < 0) {
printf("Cannot determine OS\n");
exit(-1);
}
printf("Operating system name: %s\n", sysinfo.sysname);
You can use a library as a neutral to the operating system. A solution is lsband your question became close to using lsb question.
Afaik most Linux distributions also use /etc/issue. The text in it can ofcourse have been changed by the admin to show a different login message.
Sample from fedora:
Fedora release 17 (Beefy Miracle)
Kernel \r on an \m (\l)
Sample from ubuntu:
Ubuntu 11.04 \n \l

Where in spec file do I add OS so resulting RPM contains OS and arch?

I'm building packages on a few different VMs (CentOS5 32 & 64, CentOS6 32 & 64, Fedora, etc). and the resulting RPM file contains the name.version.release.arch.rpm, as in:
foo-1.1-1.i386.rpm
But instead, I want it to output as:
foo-1.1-1.el5.i386.rpm
Where (in the spec file? .rpmmacros?) and how do I do that?
Thanks in advance.
In .spec file use this:
Release: 1%{?dist}
This is substituted to e.g. el6 RHEL6 etc. At least on Oracle Linux 6.5 with installed '#Development tools' and rpmdevtools.
In the Release tag:
Release: 1.el5
Often, people create a custom definition and then include that:
%define OSshort el5
Release: 1%{?OSshort}
Then, you could also use logic to define OSshort based upon what OS you're building on.
Updated: I modified the Release tag to only use OSshort if it's defined. Then, you can leave it undefined in the spec file and define it during the build command
$ rpmbuild -bb --define 'OSshort _el5'
Writing logic to test OS/distributions and automatically generate that involves parsing that's a bit more complex and I can't find an example right now.

Resources