<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>luhux Blog</title>
		<description>shell fan</description>
		<link></link>
		<atom:link href="/feed.xml" rel="self" type="application/rss+xml" />
		
			<item>
				<title>在Linux上使用pkgsrc</title>
				<description>&lt;hr /&gt;

&lt;p&gt;环境: Linux&lt;/p&gt;

&lt;hr /&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;下载解压pkgsrc&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;更新pkgsrc为最新&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;在系统安装编译器和工具&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;bootstrap 安装 pkgtools 和 bmake&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;使用&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;在pkgsrc安装的服务找不到管理脚本&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;管理服务&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;下载解压pkgsrc&quot;&gt;下载解压pkgsrc&lt;/h1&gt;

&lt;blockquote&gt;
  &lt;p&gt;如果已经下载解压 可跳过这一步&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
# tar zxf pkgsrc.tar.gz -C /usr
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;更新pkgsrc为最新&quot;&gt;更新pkgsrc为最新&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc &amp;amp;&amp;amp; env CVS_RSH=ssh cvs up -dP
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;在系统安装编译器和工具&quot;&gt;在系统安装编译器和工具&lt;/h1&gt;

&lt;p&gt;pkgsrc的bootstrap需要一个C编译器和一些工具&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;gcc&lt;/li&gt;
  &lt;li&gt;gmake&lt;/li&gt;
  &lt;li&gt;automake (可能非必须)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;请确保拥有这些编译器和工具&lt;/p&gt;

&lt;p&gt;CentOS安装:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# yum install make automake gcc gcc-c++ 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;bootstrap-安装-pkgtools-和-bmake&quot;&gt;bootstrap 安装 pkgtools 和 bmake&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc/bootstrap/
# ./bootstrap 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;添加目标bin和sbin到path环境变量&quot;&gt;添加目标bin和sbin到PATH环境变量&lt;/h1&gt;

&lt;p&gt;将下面文件加入你的全局环境变量文件&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;export PATH=${PATH}:/usr/pkg/bin:/usr/pkg/sbin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;比如加入/etc/profile&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;echo 'export PATH=${PATH}:/usr/pkg/bin:/usr/pkg/sbin' &amp;gt;&amp;gt; /etc/profile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后重新登陆用户&lt;/p&gt;

&lt;p&gt;执行bmake&lt;/p&gt;

&lt;p&gt;如果命令找到则添加成功&lt;/p&gt;

&lt;h1 id=&quot;使用&quot;&gt;使用&lt;/h1&gt;

&lt;p&gt;NetBSD 上的pkgsrc的决大多数用法在其他平台同样通用&lt;/p&gt;

&lt;p&gt;Linux没有pkgsrc源的二进制支持的，所以要自己编译.&lt;/p&gt;

&lt;h1 id=&quot;在pkgsrc安装的服务找不到启动脚本&quot;&gt;在pkgsrc安装的服务找不到启动脚本&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/pkg/share/examples/rc.d/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;找到需要的服务并复置到 /etc/rc.d/&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp /usr/pkg/shar/examples/rc.d/服务脚本名 /etc/pkgsrc-rc.d/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我通过pkgsrc安装了apache24&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/pkg/share/examples/rc.d/
apache mysqld
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;复制&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp /usr/pkg/share/examples/rc.d/apache /etc/pkgsrc-rc.d/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;管理服务&quot;&gt;管理服务&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# /路径/服务脚本 操作
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;一般服务操作有&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;操作&lt;/th&gt;
      &lt;th&gt;描述&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;start&lt;/td&gt;
      &lt;td&gt;开启服务(当服务在rc.conf中启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;stop&lt;/td&gt;
      &lt;td&gt;关闭服务(当服务在rc.conf中启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;restart&lt;/td&gt;
      &lt;td&gt;重启服务(当服务在rc.conf中启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;onestart&lt;/td&gt;
      &lt;td&gt;开启服务(当服务在rc.conf中未启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;onestop&lt;/td&gt;
      &lt;td&gt;关闭服务(当服务在rc.conf中未启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;onerestart&lt;/td&gt;
      &lt;td&gt;重启服务(当服务在rc.conf中未启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;status&lt;/td&gt;
      &lt;td&gt;查看服务运形状态&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;开启apache&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# /etc/pkgsrc-rc.d/apache start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;关闭apache&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# /etc/pkgsrc-rc.d/apache stop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;重启apache&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# /etc/pkgsrc-rc.d/apache restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;http://www.netbsd.org/docs/pkgsrc/getting.html#getting-via-tar&lt;/p&gt;

&lt;p&gt;http://www.netbsd.org/docs/pkgsrc/getting.html#uptodate-cvs&lt;/p&gt;

&lt;p&gt;https://www.netbsd.org/docs/guide/en/chap-rc.html&lt;/p&gt;

</description>
				<pubDate>Wed, 13 Feb 2019 11:07:00 +0000</pubDate>
				<link>/2019/02/linux-use-pkgsrc</link>
				<guid isPermaLink="true">/2019/02/linux-use-pkgsrc</guid>
			</item>
		
			<item>
				<title>pkgsrc 设置源加速</title>
				<description>&lt;hr /&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;外国人估计也没专门考虑过需要一个自定义distfile源这个问题，毕竟人家没有wall.&lt;br /&gt;
pkgsrc文档也没写&lt;/p&gt;

&lt;p&gt;自己读了读pkgsrc的源码，找到一个方法:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;编辑mk.conf&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;编辑mkconf&quot;&gt;编辑mk.conf&lt;/h1&gt;

&lt;p&gt;加入&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MASTER_SITE_BACKUP= 源地址 源地址 ...    # 覆盖原来的地址列表变量
MASTER_SORT=   域名后缀 域名后缀 ...    # 根据域名后缀排序
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;例如:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MASTER_SITE_BACKUP= https://mirrors.nju.edu.cn/pkgsrc/distfiles/ https://mirrors.tuna.tsinghua.edu.cn/pkgsrc/distfiles/
MASTER_SORT=    .edu.cn .cn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;我添加了珠江大学开源镜像站和清华大学开源镜像站&lt;/li&gt;
  &lt;li&gt;排序方式是.edu.cn后缀优先级别最高,依次.cn后缀,最后的是国外的源码镜像站&lt;/li&gt;
&lt;/ul&gt;
</description>
				<pubDate>Wed, 13 Feb 2019 11:07:00 +0000</pubDate>
				<link>/2019/02/netbsd-pkgsrc-use-mirrors</link>
				<guid isPermaLink="true">/2019/02/netbsd-pkgsrc-use-mirrors</guid>
			</item>
		
			<item>
				<title>已知可以编译大多数pkgsrc包的Linux</title>
				<description>&lt;h1 id=&quot;2018q4&quot;&gt;2018Q4&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;CentOS 7  gcc-4.8&lt;/li&gt;
&lt;/ul&gt;

</description>
				<pubDate>Sat, 02 Feb 2019 11:07:00 +0000</pubDate>
				<link>/2019/02/current-linux-use-pkgsrc</link>
				<guid isPermaLink="true">/2019/02/current-linux-use-pkgsrc</guid>
			</item>
		
			<item>
				<title>pkgsrc 软件包选项</title>
				<description>&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/luhux/images/master/netbsd-pkgsrc-compile-options.png&quot; alt=&quot;picture&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;ol&gt;
  &lt;li&gt;确认自己要用到的选项&lt;/li&gt;
  &lt;li&gt;写入配置文件&lt;/li&gt;
  &lt;li&gt;编译&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;确认自己要用到的选项&quot;&gt;确认自己要用到的选项&lt;/h1&gt;

&lt;p&gt;进入要编译的软件包文件夹&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc/分类/软件
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;查看支持的选项&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake show-options
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我要编译 emacs26.1 :&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc/editors/emacs26/
# bmake show-options
Any of the following general options may be selected:
	dbus	 Enable dbus (desktop bus) support.
	gconf	 Use GConf to store preferences.
	gnutls	 Enable GNU TLS support.
	imagemagick	 Use ImageMagick as imaging library.
	svg	 Enable SVG support.
	xaw3d	 Enable Xaw3D support.
	xft2	 Enable Xft support.
	xml	 Enable XML support.
At most one of the following window-system options may be selected:
	nextstep	 Enable Cocoa or GNUstep support.
	x11	 Enable X11 support.
At most one of the following toolkit options may be selected:
	gtk	 Enable support for GTK.
	gtk2	 Enable support for GTK2.
	gtk3	 Enable support for GTK3.
	lucid	
	motif	 Enable motif support.
	xaw	 Enable Xaw support.

These options are enabled by default:
	dbus gconf gnutls gtk3 svg x11 xaw3d xft2
	xml

These options are currently enabled:
	dbus gconf gnutls imagemagick svg x11 xaw
	xaw3d xft2 xml

You can select which build options to use by setting PKG_DEFAULT_OPTIONS
or PKG_OPTIONS.emacs.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我要用到&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gtk gtk2 gtk3 xaw lucid motif 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;写入配置文件&quot;&gt;写入配置文件&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# echo 'PKG_OPTIONS.包名+= 选项' &amp;gt;&amp;gt; /usr/pkg/etc/mk.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的emacs:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# echo 'PKG_OPTIONS.emacs+=     gtk gtk2 gtk3 xaw lucid motif' &amp;gt;&amp;gt; /usr/pkg/etc/mk.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;编译&quot;&gt;编译&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;参考:&lt;/p&gt;

&lt;p&gt;http://www.netbsd.org/docs/pkgsrc/configuring.html&lt;/p&gt;
</description>
				<pubDate>Thu, 29 Nov 2018 11:07:00 +0000</pubDate>
				<link>/2018/11/pkgsrc-compile-options</link>
				<guid isPermaLink="true">/2018/11/pkgsrc-compile-options</guid>
			</item>
		
			<item>
				<title>netbsd pkgsrc 创建手动获取源码包脚本</title>
				<description>&lt;hr /&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;由于地区防火墙的限制&lt;/p&gt;

&lt;p&gt;很多在国外的服务器上的源码包下载很慢&lt;/p&gt;

&lt;p&gt;pkgsrc提供创建手动下载脚本&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;进入要编译的软件包目录&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;创建脚本&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;进入要编译的软件包目录&quot;&gt;进入要编译的软件包目录&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc/分类/软件名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;创建脚本&quot;&gt;创建脚本&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake fetch-list &amp;gt; 脚本名.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;例如&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake fetch-list &amp;gt; fetch-source.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;在创建后在网络好的情况下执行&quot;&gt;在创建后在网络好的情况下执行&lt;/h2&gt;
</description>
				<pubDate>Sat, 13 Oct 2018 12:09:00 +0000</pubDate>
				<link>/2018/10/netbsd-pkgsrc-fetch-script</link>
				<guid isPermaLink="true">/2018/10/netbsd-pkgsrc-fetch-script</guid>
			</item>
		
			<item>
				<title>netbsd上的pkgsrc的mk.conf不生效的解决</title>
				<description>&lt;hr /&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;设置了/usr/pkg/etc/mk.conf 但是不生效&lt;/p&gt;

&lt;h2 id=&quot;尝试链接到-etc-生效&quot;&gt;尝试链接到 /etc 生效:&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ln -s /usr/pkg/etc/mk.conf /etc/mk.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
				<pubDate>Fri, 12 Oct 2018 14:07:00 +0000</pubDate>
				<link>/2018/10/netbsd-mk.conf</link>
				<guid isPermaLink="true">/2018/10/netbsd-mk.conf</guid>
			</item>
		
			<item>
				<title>netbsd pkgsrc 使用源码构建一个二进制包</title>
				<description>&lt;h2&gt;&lt;img src=&quot;https://raw.githubusercontent.com/luhux/images/master/netbsd-create-binary-packge.png&quot; alt=&quot;netbsd-pkgsrc-create-binary&quot; /&gt;&lt;/h2&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;进入需要编译的软件的目录&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;编译&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;打包&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;进入需要编译的软件的目录&quot;&gt;进入需要编译的软件的目录&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc/分类/软件名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我要编译游戏中的2048-cli&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/pkgsrc/games/2048-cli
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;编译&quot;&gt;编译&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;打包&quot;&gt;打包&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake package
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的2048-cli打包输出&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# bmake package
=&amp;gt; Bootstrap dependency digest&amp;gt;=20010302: found digest-20160304
===&amp;gt; Checking for vulnerabilities in 2048-cli-0.9.1
===&amp;gt; Installing for 2048-cli-0.9.1
=&amp;gt; Generating pre-install file lists
=&amp;gt; Creating installation directories
/usr/bin/install -c -s -o root -g wheel -m 755 /usr/pkgsrc/games/2048-cli/work/2048-cli-0.9.1/2048 /usr/pkgsrc/games/2048-cli/work/.destdir/usr/pkg/bin
/usr/bin/install -c -o root -g wheel -m 644 /usr/pkgsrc/games/2048-cli/work/2048-cli-0.9.1/man/2048.1 /usr/pkgsrc/games/2048-cli/work/.destdir/usr/pkg/man/man1
=&amp;gt; Automatic manual page handling
=&amp;gt; Generating post-install file lists
=&amp;gt; Checking file-check results for 2048-cli-0.9.1
=&amp;gt; Creating binary package /usr/pkgsrc/games/2048-cli/work/.packages/2048-cli-0.9.1.tgz
===&amp;gt; Building binary package for 2048-cli-0.9.1
=&amp;gt; Creating binary package /usr/pkgsrc/packages/All/2048-cli-0.9.1.tgz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;可以看出软件包被创建在 /usr/pkgsrc/packages/All/的目录下&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;http://www.netbsd.org/docs/pkgsrc/binary.html&lt;/p&gt;
</description>
				<pubDate>Fri, 12 Oct 2018 11:07:00 +0000</pubDate>
				<link>/2018/10/netbsd-pkgsrc-make-a-package</link>
				<guid isPermaLink="true">/2018/10/netbsd-pkgsrc-make-a-package</guid>
			</item>
		
			<item>
				<title>NetBSD编译内核</title>
				<description>&lt;h2&gt;&lt;img src=&quot;https://raw.githubusercontent.com/luhux/images/master/netbsd-kernel.png&quot; alt=&quot;netbsd-kernel&quot; /&gt;&lt;/h2&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;ol&gt;
  &lt;li&gt;确认内核源码是否安装&lt;/li&gt;
  &lt;li&gt;复制创建编缉内核配置文件&lt;/li&gt;
  &lt;li&gt;配置,生成依赖并编译内核&lt;/li&gt;
  &lt;li&gt;备份原内核并安装内核&lt;/li&gt;
  &lt;li&gt;内核失败的挽救&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;确认内核源码是否安装&quot;&gt;确认内核源码是否安装&lt;/h1&gt;

&lt;p&gt;在安装NetBSD时内核源码是可选选项&lt;/p&gt;

&lt;p&gt;检查源码是否安装&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/src/sys/arch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;已安装:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/src/sys/arch
/usr/src/sys/arch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;未安装:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/src/sys/arch
ls: /usr/src/sys/arch: No such file or directory
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;安装源码&quot;&gt;安装源码:&lt;/h2&gt;

&lt;p&gt;下载源码&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# wget http://cdn.netbsd.org/pub/NetBSD/NetBSD-release-$(uname -r | head -c 1)/tar_files/src/sys.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;解压安装&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# tar zxvf sys.tar.gz -C /usr
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;复制并编缉配置&quot;&gt;复制并编缉配置&lt;/h1&gt;

&lt;p&gt;进入源码目录&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd /usr/src/sys/arch/($uname -m)/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;进入配置文件目录&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;复制标准配置&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp GENERIC 你的配置文件名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的配置文件为 MY_SERVER&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp GENERIC MY_SERVER
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;编缉配置&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# vim 你的配置文件名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;编缉请参考man的 config 手册和 options 手册&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;config(1)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;options(4)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;编缉后保存退出&lt;/p&gt;

&lt;h1 id=&quot;配置生成依赖并编译内核&quot;&gt;配置,生成依赖并编译内核&lt;/h1&gt;

&lt;h2 id=&quot;依靠配置生成编译工作文件夹&quot;&gt;依靠配置生成编译工作文件夹&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# config 你的配置文件名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的配置文件名为MY_SERVER&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# config MY_SERVER
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;它会检查你的配置文件&lt;/p&gt;

&lt;p&gt;如果配置出错它会停止并报错 请根据提示更改配置文件&lt;/p&gt;

&lt;p&gt;如果配置文件通过检测则生成 ../compile/你的配置文件名/ 的文件夹&lt;/p&gt;

&lt;h2 id=&quot;生成依赖&quot;&gt;生成依赖&lt;/h2&gt;

&lt;p&gt;进入已生成的文件夹&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd ../compile/你的配置文件名/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的文件夹为MY_SERVER&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd ../compile/MY_SERVER/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;生成依赖&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# make depend
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;它会再一步检查配置文件并检查依赖&lt;/p&gt;

&lt;p&gt;如果检查通过它会生成所需文件&lt;/p&gt;

&lt;p&gt;如果检查不通过它会报错并停止,请根据报错修改配置文件并重新生成文件夹:&lt;/p&gt;

&lt;p&gt;删除旧文件夹&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd ..
# rm -rf 你的配置文件名/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的文件夹为 MY_SERVER&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cd ..
# rm -rf MY_SERVER/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重新进入conf文件夹&lt;/p&gt;

&lt;p&gt;根据报错修改配置文件&lt;/p&gt;

&lt;p&gt;并再次&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# config 你的配置文件名
# cd ../compile/你的配置文件名/
# make depend
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;直到成功为止&lt;/p&gt;

&lt;h2 id=&quot;编译内核&quot;&gt;编译内核&lt;/h2&gt;

&lt;p&gt;在工作文件夹&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# make
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;等待编译完成&lt;/p&gt;

&lt;p&gt;如果编译失败请:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;重新生成工作目录再编译&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;检查内核配置文件的不合理处,并修改,重新生成工作目录编译&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;备份原内核并安装内核&quot;&gt;备份原内核并安装内核&lt;/h1&gt;

&lt;p&gt;编译完成后工作文件夹会有一个netbsd文件.&lt;/p&gt;

&lt;p&gt;看起来是这样:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls -lh netbsd
-rwxr-xr-x  1 root  wheel   21M Sep 27 11:06 netbsd
# file netbsd 
netbsd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for NetBSD 8.0, not stripped
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;备份原内核&quot;&gt;备份原内核&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp /netbsd /netbsd.old
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;安装编译好的内核&quot;&gt;安装编译好的内核&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp ./netbsd /netbsd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重启应用内核&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;安装失败的挽救&quot;&gt;安装失败的挽救&lt;/h1&gt;

&lt;p&gt;由于各种原因可能会造成新内核启动失败&lt;/p&gt;

&lt;p&gt;挽救的方法:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;使用原来的内核启动,并尝试解决错误&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;使用原来的内核启动,并尝试解决错误无果,恢复原来内核&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;使用原来的内核启动的方法&quot;&gt;使用原来的内核启动的方法&lt;/h2&gt;

&lt;p&gt;由于启动管理器有很多,这里我只说默认启动器的方法.&lt;/p&gt;

&lt;p&gt;重启进入启动选择器&lt;/p&gt;

&lt;p&gt;按下空格键进入boot prompt(启动提示符)  boot:&lt;/p&gt;

&lt;p&gt;输入 boot netbsd.old -s 回车 (使用原来内核启动并进入单用户模式)&lt;/p&gt;

&lt;p&gt;接下来修复问题 或直接&amp;gt;恢复原来内核&lt;/p&gt;

&lt;h2 id=&quot;恢复原来内核&quot;&gt;恢复原来内核&lt;/h2&gt;

&lt;p&gt;在(使用原来内核启动并进入单用户模式)中执行:&lt;/p&gt;

&lt;p&gt;恢复原内核&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# fsck /
# mount /
# mv netbsd.old netbsd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重启&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;其它引导器&quot;&gt;其它引导器&lt;/h2&gt;

&lt;p&gt;理解后自行操作&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;https://www.netbsd.org/docs/guide/en/chap-kernel.html&lt;/p&gt;

</description>
				<pubDate>Wed, 26 Sep 2018 11:07:00 +0000</pubDate>
				<link>/2018/09/netbsd-compile-kernel</link>
				<guid isPermaLink="true">/2018/09/netbsd-compile-kernel</guid>
			</item>
		
			<item>
				<title>NetBSD rc.d服务管理</title>
				<description>&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/luhux/images/master/netbsd-rc.d.png&quot; alt=&quot;netbsdrc.d&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;etcrcd&quot;&gt;/etc/rc.d/&lt;/h1&gt;

&lt;p&gt;这个目录下存放服务的管理脚本&lt;/p&gt;

&lt;h1 id=&quot;etcrcconf&quot;&gt;/etc/rc.conf&lt;/h1&gt;

&lt;p&gt;控制开机启动的服务&lt;/p&gt;

&lt;h1 id=&quot;etcrclocal&quot;&gt;/etc/rc.local&lt;/h1&gt;

&lt;p&gt;系统自定义开机脚本&lt;/p&gt;

&lt;h1 id=&quot;控制开机自启&quot;&gt;控制开机自启&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# vi /etc/rc.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我的rc.conf&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#       $NetBSD: rc.conf,v 1.97 2014/07/14 12:29:48 mbalmer Exp $
#
# See rc.conf(5) for more information.
#
# Use program=YES to enable program, NO to disable it. program_flags are
# passed to the program on the command line.
#

# Load the defaults in from /etc/defaults/rc.conf (if it's readable).
# These can be overridden below.
#
if [ -r /etc/defaults/rc.conf ]; then
        . /etc/defaults/rc.conf
fi

# If this is not set to YES, the system will drop into single-user mode.
#
rc_configured=YES

# Add local overrides below.
#

dhcpcd=YES
dhcpcd_flags=&quot;-qM re0&quot;
sshd=YES
wscons=YES
cron=YES
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;服务脚本名=YES    # 这里填YES或NO YES表示开机自启,NO表示开机不自启
服务脚本名_标志=&quot;&quot;  # 这里填服务的副加参数 具体看目标服务
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;服务脚本名必需为 /etc/rc.d/ 下的文件名&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;在pkgsrc安装的服务找不到启动脚本&quot;&gt;在pkgsrc安装的服务找不到启动脚本&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/pkg/share/examples/rc.d/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;找到需要的服务并复置到 /etc/rc.d/&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp /usr/pkg/shar/examples/rc.d/服务脚本名 /etc/rc.d/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我通过pkgsrc安装了apache24&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# ls /usr/pkg/share/examples/rc.d/
apache mysqld
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;复制&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# cp /usr/pkg/share/examples/rc.d/apache /etc/rc.d/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;设置开机自启&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# echo 'apache=YES' &amp;gt;&amp;gt; /etc/rc.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;手动管理服务&quot;&gt;手动管理服务&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# service 服务脚本名 操作
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;一般服务操作有&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;操作&lt;/th&gt;
      &lt;th&gt;描述&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;start&lt;/td&gt;
      &lt;td&gt;开启服务(当服务在rc.conf中启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;stop&lt;/td&gt;
      &lt;td&gt;关闭服务(当服务在rc.conf中启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;restart&lt;/td&gt;
      &lt;td&gt;重启服务(当服务在rc.conf中启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;onestart&lt;/td&gt;
      &lt;td&gt;开启服务(当服务在rc.conf中未启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;onestop&lt;/td&gt;
      &lt;td&gt;关闭服务(当服务在rc.conf中未启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;onerestart&lt;/td&gt;
      &lt;td&gt;重启服务(当服务在rc.conf中未启用)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;status&lt;/td&gt;
      &lt;td&gt;查看服务运形状态&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;具体服务操作查看&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# /etc/rc.d/服务名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;查看ssh&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;localhost# /etc/rc.d/sshd
Usage: /etc/rc.d/sshd [fast|force|one](start stop restart rcvar keygen reload status poll)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;开启apache&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# service apache start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;关闭apache&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# service apache stop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;重启apache&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# service apache restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;https://www.netbsd.org/docs/guide/en/chap-rc.html&lt;/p&gt;
</description>
				<pubDate>Tue, 25 Sep 2018 11:07:00 +0000</pubDate>
				<link>/2018/09/netbsd-rc.d</link>
				<guid isPermaLink="true">/2018/09/netbsd-rc.d</guid>
			</item>
		
			<item>
				<title>NetBSD使用pkgin管理二进制包</title>
				<description>&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/luhux/images/master/netbsd-pkgin.png&quot; alt=&quot;pkgin&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;环境: NetBSD 8 amd64&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;pkgin 是一个像apt/yum一样的包管理工具,来管理pkgsrc的包&lt;/p&gt;

&lt;h1 id=&quot;安装pkgin&quot;&gt;安装pkgin&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# PKG_PATH=&quot;http://cdn.NetBSD.org/pub/pkgsrc/packages/$(uname -s)/$(uname -m)/$(uname -r|cut -f '1 2' -d.)/All/&quot;
# export PKG_PATH
# pkg_add pkgin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;使用pkgin安装一个包&quot;&gt;使用pkgin安装一个包&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# pkgin install 包名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;使用pkgin卸载一个包&quot;&gt;使用pkgin卸载一个包&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# pkgin remove 包名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;使用pkgin搜索一个包&quot;&gt;使用pkgin搜索一个包&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# pkgin search 包名
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;使用pkgin显示系统已安装包&quot;&gt;使用pkgin显示系统已安装包&lt;/h1&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ pkgin list
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
				<pubDate>Mon, 24 Sep 2018 11:07:00 +0000</pubDate>
				<link>/2018/09/netbsd-use-pkgin</link>
				<guid isPermaLink="true">/2018/09/netbsd-use-pkgin</guid>
			</item>
		
	</channel>
</rss>
