一、什么是LXR

LXR是一个通用的源代码索引器和交叉引用器 它提供了一个基于 web 的可浏览任意定义以及任意标识的用法。 它支持很多种语言。

LXR 曾经被作为 “Linux 交叉引用器” 但是已经被证明它可以用来作为任意基于 Linux 内核的项目的交叉引用 它基于股票网站技术 (这意味着它的输出是标准的 HTML) 所以可以选择任意的可用 web 浏览器来作为他的客户端。 它被设计为不依赖 java 或者任何第三方客户端脚本,这样可以保证系统需求和依赖的最小化。

人们经常问起 LXR 与 LXRng (见于 http://lxr.linux.no) 之间的差别。 LXRng 是从 LXR 中 fork 出来带有实验性质的用来探索其他技术的分支。 它基于 ajax 并且依赖很多 CPAN 的包。 它使用了很多的客户端脚本,这意味着运算的负载被服务端和客户端一起分担了。 CAUTION!

It looks like lxr.linux.no has closed without notice some time during the first half of 2014. Whether there is a backup of LXRng is unknown.

在服务端, 任意的带有 cgi 能力的 web 服务器都能表现的很好。在开发过程中,LXR 是一个很有价值的项目合成观察角色。 对于从头开始学习源代码的人来说,它也是一个很有用的工具。 否则,学习曲线会很陡峭。

简单的说就是一个源码阅读工具,使用web浏览,源码中的各种信息储存在数据库里面,以标签的形式存在。window下有source insight,但有时候不是很方便使用SI阅读源码,因此,搭建打一个lxr服务器来阅读源码。

LXR 项目站点 : https://lxr.sourceforge.io/zh/1-0-InstallSteps/1-0-install.php

源码下载: https://sourceforge.net/projects/lxr/files/stable/

二、安装

博主使用的是Ubuntu20系统(固件名ROC-RK3588S-PC_Ubuntu20.04-Gnome-r240_v1.0.6f_230404.img),运行在rk3588上面,直接使用apt-get安装相关依赖即可。

需要的工具有:git、exuberant-ctags 、glimpse、swish-e、apache2、mysql-server、perl、libapache2-mod-perl2、libdbd-mysql-perl。

glimpse、swish-e安装一个就行,我这里都安装了,推荐安装glimpse,据实践,不安装swish-e貌似有点小问题,但安装了又要再配置文件里面去掉0.0。

sudo apt-get update

sudo apt-get install exuberant-ctags glimpse swish-e

sudo apt-get install perl libapache2-mod-perl2 libdbd-mysql-perl

sudo apt-get install libfile-mmagic-perl

sudo apt-get install apache2 mysql-server

安装完整之后,先去下载lxr源码,解压到/usr/local/share/lxr中,路径可以替换。

1、配置lxr

进入到/usr/local/share/lxr路径中,使用

./genxref --checkonly

其中,perl大于5.10版本,ctags大于5.0,glimpse和swish-e有一个就行。到这里之后,需要对lxr进行配置,生成配置文件lxr.conf、web服务器配置文件和数据库初始化文件。

./scripts/configure-lxr.pl -vv

具体的在附录,基本上全默认就行了,具体的可以参考https://lxr.sourceforge.io/zh/1-0-InstallSteps/1-0-install.php这个链接就行。比较重要的是源码存放路径、数据库存放路径和代码版本,博主的参数如下:

/usr/local/share/linux_kernel
/usr/local/share/glimpse_DB
/usr/local/share/swish_e_DB

2.4.18

对于lxr来说,代码root目录在/usr/local/share/linux_kernel,里面每一个版本代表一个工程,名字随意起,博主起名2.4.18,表示Linux2.4.18版本。

第一个参数表示代码树(就是工程数量)是一个还是多个,这里只能在./scripts/configure-lxr.pl -vv运行是配置,无法通过后面修改配置文件修改功能,我这里选择m,表示多个代码树。

 

其他的参数基本上可以说随意了。

2、初始化数据库

首先,在数据库中,生成对应的表:

sudo ./custom.d/initdb.sh

将lxr.conf移动到/usr/local/share/lxr目录下,生成检索信息时会用到。

sudo cp custom.d/lxr.conf .

在里面要将swish-e相关路径给屏蔽了。

之后,还需要将linux源码解压到/usr/local/share/linux_kernel/2.4.18目录下,

到这里以及准备好了lxr大部分东西了,现在需要对Linux源码生成检索信息,信息存放在数据库里面,路径为:/usr/local/share/glimpse_DB

sudo ./genxref --url=http://localhost/lxr --version=2.4.18

这个过程很慢很慢,rk3588来处理2.4.18内核大概需要2个小时,睡一觉起来再看它。

3、配置apache2服务器

好了之后,启动apache2服务器,需要先配置下服务器。

sudo cp custom.d/apache-lxrserver.conf /etc/apache2/conf-enabled/

在重启apache2之前,我们还需更改 /etc/apache2/conf-available/serve-cgi-bin.conf文件。

vim /etc/apache2/conf-available/serve-cgi-bin.conf

同时还要修改

vim /etc/apache2/sites-enabled/000-default.conf

<Directory /usr/local/share/lxr>
               AddHandler perl-script .pl .cgi
               PerlResponseHandler ModPerl::Registry
               Options +ExecCGI +FollowSymLinks +MultiViews
               PerlOptions +ParseHeaders
               AllowOverride All
               Order allow,deny
               Allow from all 
         </Directory>

这里一切顺利的化,可以启动apache2服务器了。

sudo a2enmod cgid

sudo a2dismod mpm*

sudo a2enmod mpm_worker

sudo systemctl restart apache2

启动之后,可以使用浏览器查看http://localhost/lxr/source网址中的信息。 博主rk3588的局域网ip是192.168.31.193,若是使用http://192.168.31.193/lxr/source查看,会得到错误,无法显示,,提示找不到源码树(我就掉这个坑里了,一直以为是我哪里配置错了,在局域网用ip访问就看不到信息,百度谷歌翻遍了都没找到),像这样的错误。

其实,这个问题是网络权限问题,只要在lxr.conf中将自己的ip添加到host_names里面就行了。

这样在局域网也能查看到了,这里附一张局域网下看到的linux源码图像。虽然没有source insight看起来舒服,但凑合用吧(博主一直用SI看代码,但SI有版权,某些时候不方便)。

恭喜你完成了lxr的安装与配置!

三、总结

我找到的 LXR相关资料,都是比较老了,基本上都是在ubuntu16以前安装的,整体还算可以,唯独在局域网ip访问这里被坑到了,rk3588没屏幕是看不到的,搞了一天才解决这个问题,记录下这个坑,希望能对各位小伙伴有所帮助。

附录

firefly@firefly:~/3rlib/lxr-2.3.6$ ./scripts/configure-lxr.pl -vv
*** LXR configurator (version: 2.4) ***LXR root directory is /home/firefly/3rlib/lxr-2.3.6
Configuration will be stored in custom.d/Configure for single/multiple trees? [S/m] > m*** LXR web server configuration ***Many different configurations are possible, they are related to the way
LXR service is accessed, i.e. to the structure of the URL.
Refer to the User's Manual for a description of the variants.LXR can be located at the server-root (so called dedicated)
or lower in the server hierarchy (shared because there are
usually other pages or sections).
Server type? [dedicated/SHARED] > Selecting which tree to display can be done in various ways:1. from the host name (all names are different),2. from a prefix to a common host name (similar to previous)3. from the site section name (all different)4. from interpretation of a section name part (similar to previous)5. from the head of script arguments
Method 5 is highly recommended because it has no impact on webserverconfiguration.
Method 3 is second choice but involves manually setting up manysymbolic links (one per source-tree).
Method 1 & 2 do not involve symbolic links but need populating webserverconfiguration with virtual hosts.Note that method 2 does not work well on //localhost.
Method 4 is deprecated because it has proved not easily portableunder alternate webservers (other than Apache).Tree designation?:ARGUMENTsection nameprefix in hosthostnameembedded in section> The computer hosting the server is described by an URL.
The form is !scheme://host_name:port
where:- ! is an optional flag (see below),- scheme is either http or https,- host_name can be given as an IPv4 address such as 123.45.67.89,an IPv6 address like [fe80::1234:90ab]or a domain name like localhost or lxr.url.example,- port is 1 to 65535.
Scheme: or :port must be specified if you want to restrict
access to the tree through the designated scheme or port.
This restriction is requested with the ! prefix flag.
--- Host name or IP? [//localhost] >
--- Alias name or IP? >
URL section name for LXR in your server? [/lxr] >
Will it be shared by all trees? [YES/no] > *** LXR database configuration ***The choice of the database engine can make a difference in indexing performance,
but resource consumption is also an important factor.* For a small personal project, try SQLite which do notneed a server and is free from configuration burden.* For medium to large projects, choice is between MySQL,PostgreSQL and Oracle.Oracle is not a free software, its interface has not beentested for a long time.* PostgreSQL databases are smaller than MySQL'sand performance is roughly equivalent.* MySQL is at its best with large-sized projects(such as kernel cross-referencing) where it is fastest at the costof bigger databases.* Take also in consideration the number of connected users.
Database engine? [MYSQL/oracle/postgres/sqlite] >
The safest option is to create one database per tree.
You can however create a single database for all your trees with a specific set of
tables for each tree (though this is not recommended).
How do you setup the databases? [PER TREE/global] >
All databases can be accessed with the same username and
can also be described under the same names.
Will you share database characteristics? [YES/no] >
Will you use the same username and password for all DBs? [YES/no] >
--- DB user name? [lxr] >
--- DB password ? [lxrpw] >
Will you give the same prefix to all tables? [YES/no] >
--- Common table prefix? [lxr_] >
--- Directory for glimpse databases? > /usr/local/share/glimpse_DB
--- Directory for swish-e databases? > /usr/local/share/swish_e_DB
REMINDER: after this configuration step, open lxr.conf
and comment out one of 'glimpsebin' or 'swishbin'.file .htaccess written into LXR root directory
file apache2-require.pl written into configuration directory
file apache-lxrserver.conf written into configuration directory
file lighttpd-lxrserver.conf written into configuration directory
file nginx-lxrserver.conf written into configuration directory
file thttpd-lxrserver.conf written into configuration directory
Mercurial support files written into configuration directory*** LXR master configuration file setup ***Global section part*** Configuring auxiliary tool paths
*** Host name previously defined as //localhost:
*** Configuring HTML parameters
*** 'Buttons-and-menus' interface is recommended for the kernel
*** to avoid screen cluttering.
--- Use 'buttons-and-menus' instead of 'link' interface? [YES/no] >
*** Configuring file subsection
*** Configuring "common factors"
*** Marking tree section*** LXR master configuration file setup ***Tree section partSQL script for database initialisation*** Configuring LXR server parameters
*** The virtual root is the fixed URL part after the hostname.
*** You previously defined the virtual root as /lxr
--- Caption in page header? (e.g. Project XYZZY displayed by LXR) > HTQ_LXR
Do you want a speed switch button for this tree ? [YES/no] >
--- Short title for button? (e.g. XYZZY) > HTQ_BTN
--- Tree identification in URL? (e.g. the-tree) > the-tree
Do you need a specific encoding for this tree ? [yes/NO] >
*** Describing tree location
How is your tree stored? [FILES/cvs/git/svn/hg/bk] >
*** A source directory contains one sub-directory for every version.
--- Source directory? (e.g. /home/myself/project-tree) > /usr/local/share/linux_kernel
Name to display for the path root? (e.g. Project or $v for version) [$v] >
*** Enumerating versions
Label for version selection menu?  [Version] >
*** Versions can be explicitly enumerated, be read from a file or computed
*** by a function. The latter case is recommended for VCS-stored trees.
Version enumeration method? [LIST/file/function] >
--- Version name?  > 2.4.18
--- Version name? (hit return to stop) >
*** By default, first version in list is displayed. You may also indicate
*** a prefered version.
--- Default displayed version is first in 'range'? [YES/no] >
*** Setting directory lists
*** Some directories may contain non-public project data (binaries,
*** compilers caches, SCM control data, ...). They can be hidden from LXR.
--- Directory to ignore, e.g. CVSROOT or CVS? (hit return to stop) >
*** If your source code uses "include" statements (#include, require, ...)
*** LXR needs hints to resolve the destination file.
--- Include directory, e.g. /include? (hit return to stop) >
*** Configuring data storage
--- Database name? > lxr_database
Do you want to override the global 'lxr' user name? [yes/NO] >
Do you want to override the global 'lxr_' table prefix? [yes/NO] > *** Configure another tree? [YES/no] > no
configuration saved in custom.d/lxr.conf
DB initialisation script is custom.d/initdb.sh

小白也能看懂的踩坑日记--ubuntu(rk3588)安装LXR(阅读源码工具)服务器相关推荐

  1. 2019-12-23《踩坑日记:虚拟机安装ESXI后无法访问/失联》

    一.问题描述:      今天探索了一下VMware ESXI的安装,在安装配置完成后遇到了无法访问服务端的问题.那么就这个问题的排查总结一下排错思路.      1.VMware-viclient无 ...

  2. armbian清理_小孩子才做选择,OMV、HomeAssistant我全都要,小白也能看懂的N1盒子纯净刷机指南...

    小孩子才做选择,OMV.HomeAssistant我全都要,小白也能看懂的N1盒子纯净刷机指南 2020-04-10 22:46:04 63点赞 609收藏 52评论 创作立场声明:今天我是一个可爱的 ...

  3. python进阶(小白也能看懂)——装饰器浅谈(一)

    python进阶(小白也能看懂)--装饰器(一) 第四篇 文章目录 python进阶(小白也能看懂)--装饰器(一) 1.函数基础知识 例子1.1 例子1.2 例子1.3 例子1.4 2.不带参数的装 ...

  4. python进阶(小白也能看懂)——Map、Filter、Reduce

    python进阶(小白也能看懂)--Map.Filter.Reduce 第三篇 Map.Filter.Reduce是python中常用的函数,使用这些函数能够给我们带来很多便捷. Map map(fu ...

  5. python进阶(小白也能看懂)——*args与**kwargs的使用

    python进阶(小白也能看懂)--*args与**kwargs的使用 第一篇 理解*args与**kwargs在定义函数时的作用 假设你写了一个函数multiply(函数定义在下面),专门用来处理两 ...

  6. 随机森林的特征 是放回抽样么_机器学习超详细实践攻略(10):随机森林算法详解及小白都能看懂的调参指南...

    一.什么是随机森林 前面我们已经介绍了决策树的基本原理和使用.但是决策树有一个很大的缺陷:因为决策树会非常细致地划分样本,如果决策树分得太多细致,会导致其在训练集上出现过拟合,而如果决策树粗略地划分样 ...

  7. 小白都能看懂的实战教程 手把手教你Python Web全栈开发(DAY 3)

    小白都能看懂的实战教程 手把手教你Python Web全栈开发 Flask(Python Web)实战系列之在线论坛系统 第三讲 这是小白都能看懂的实战教程 手把手教你Python Web全栈开发 的 ...

  8. c语言程序和plc程序的区别,一文告诉你PLC与计算机的本质区别在哪里!小白都能看懂!...

    原标题:一文告诉你PLC与计算机的本质区别在哪里!小白都能看懂! 你真的了解PLC吗?你知道PLC与计算机的本质区别吗?我来简单解释一下吧. 1.PLC可以工作在极其恶劣的电磁环境中 如果我们把计算机 ...

  9. 小白也能看懂的网络基础 | 01 什么是网络?

    公众号关注 「奇妙的 Linux 世界」 设为「星标」,每天带你玩转 Linux ! 引言 欢迎来到网络世界,<小白也能看懂的网络基础>系列文章会从零开始帮助你构建网络的基础知识.如果你完 ...

最新文章

  1. Redis、Kafka 和 Pulsar 消息队列对比,写得太好了!
  2. 二叉树的遍历(包括递归和非递归方法)
  3. 让面试官颤抖的 HTTP 2.0 协议面试题
  4. python to_excel保存成xls_pd.ExcelWriter(to_excel)保存结果到已存在的excel文件中
  5. 国家标准标点符号用法
  6. PoPo数据可视化第8期
  7. Win2008 R2 IIS FTP防火墙的配置
  8. php 标签页切换,vue.js实现标签页切换效果
  9. pythoncad标注教程,AotuCAD国标字体和标注设置技巧图文教程
  10. 学习AccessibilityService实现微信抢红包插件
  11. mathtype过期,不用每次都去回顾教程
  12. matlab矩阵逆时针旋转90度_matlab矩阵旋转任意角度的函数 imrotate
  13. 超级符号就是超级创意_超级食物
  14. 计算机cdef盘无法显示,win7计算机不显示硬盘分区盘符
  15. java毕业生设计中小型连锁超市配送中心配送管理计算机源码+系统+mysql+调试部署+lw
  16. mysql数据库怎么加入时间戳
  17. 第14章 数据仓库与数据挖掘
  18. Spring Security系列(11)- Security5.0版本Oauth2开放平台环境搭建
  19. 万用表测占空比怎么接_如何使用万用表测量频率和占空比?
  20. 关于Rtp封包方式之一的 FU-A分包方式

热门文章

  1. MySQL数据中有很多换行符和回车符!!该咋办?
  2. C++输入cin应用详解
  3. centos 7 安装音频视频解码器
  4. unity 简单AI巡逻
  5. 从B站转载车祸视频到微信群
  6. xmppframework
  7. python函数的作用是什么_Python函数
  8. 网络安全行业至少还有20家上市公司的空间
  9. 详解苹果Face ID,将让深度摄像头成主流
  10. android 上下左右滑动的表格,适用小程序的表格table,冻结行,冻结列,可左右,上下滑动...