https://wiki.ubuntu.org.cn/api.php?action=feedcontributions&user=96.47.232.233&feedformat=atomUbuntu中文 - 用户贡献 [zh-hans]2024-03-29T08:56:11Z用户贡献MediaWiki 1.26.3https://wiki.ubuntu.org.cn/index.php?title=%E8%B7%9F%E6%88%91%E4%B8%80%E8%B5%B7%E5%86%99Makefile:%E9%9A%90%E5%90%AB%E8%A7%84%E5%88%99&diff=154512跟我一起写Makefile:隐含规则2016-06-28T00:49:32Z<p>96.47.232.233:/* 定义模式规则 */</p>
<hr />
<div>{{TOCright}}<br />
{{跟我一起写Makefile}}<br />
<br />
=隐含规则=<br />
<br />
在我们使用Makefile时,有一些我们会经常使用,而且使用频率非常高的东西,比如,我们编译C/C++的源程序为中间目标文件(Unix下是[.o]文件,Windows下是[.obj]文件)。本章讲述的就是一些在Makefile中的“隐含的”,早先约定了的,不需要我们再写出来的规则。<br />
<br />
“隐含规则”也就是一种惯例,make会按照这种“惯例”心照不喧地来运行,那怕我们的Makefile中没有书写这样的规则。例如,把[.c]文件编译成[.o]文件这一规则,你根本就不用写出来,make会自动推导出这种规则,并生成我们需要的[.o]文件。<br />
<br />
“隐含规则”会使用一些我们系统变量,我们可以改变这些系统变量的值来定制隐含规则的运行时的参数。如系统变量“CFLAGS”可以控制编译时的编译器参数。<br />
<br />
我们还可以通过“模式规则”的方式写下自己的隐含规则。用“后缀规则”来定义隐含规则会有许多的限制。使用“模式规则”会更回得智能和清楚,但“后缀规则”可以用来保证我们Makefile的兼容性。<br />
我们了解了“隐含规则”,可以让其为我们更好的服务,也会让我们知道一些“约定俗成”了的东西,而不至于使得我们在运行Makefile时出现一些我们觉得莫名其妙的东西。当然,任何事物都是矛盾的,水能载舟,亦可覆舟,所以,有时候“隐含规则”也会给我们造成不小的麻烦。只有了解了它,我们才能更好地使用它。<br />
<br />
<br />
==使用隐含规则==<br />
<br />
如果要使用隐含规则生成你需要的目标,你所需要做的就是不要写出这个目标的规则。那么,make会试图去自动推导产生这个目标的规则和命令,如果 make可以自动推导生成这个目标的规则和命令,那么这个行为就是隐含规则的自动推导。当然,隐含规则是make事先约定好的一些东西。例如,我们有下面的一个Makefile:<br />
<br />
foo : foo.o bar.o<br />
cc –o foo foo.o bar.o $(CFLAGS) $(LDFLAGS)<br />
<br />
我们可以注意到,这个Makefile中并没有写下如何生成foo.o和bar.o这两目标的规则和命令。因为make的“隐含规则”功能会自动为我们自动去推导这两个目标的依赖目标和生成命令。<br />
<br />
make会在自己的“隐含规则”库中寻找可以用的规则,如果找到,那么就会使用。如果找不到,那么就会报错。在上面的那个例子中,make调用的隐含规则是,把[.o]的目标的依赖文件置成[.c],并使用C的编译命令“cc –c $(CFLAGS) [.c]”来生成[.o]的目标。也就是说,我们完全没有必要写下下面的两条规则:<br />
<br />
foo.o : foo.c<br />
cc –c foo.c $(CFLAGS)<br />
bar.o : bar.c<br />
cc –c bar.c $(CFLAGS)<br />
<br />
因为,这已经是“约定”好了的事了,make和我们约定好了用C编译器“cc”生成[.o]文件的规则,这就是隐含规则。<br />
<br />
当然,如果我们为[.o]文件书写了自己的规则,那么make就不会自动推导并调用隐含规则,它会按照我们写好的规则忠实地执行。<br />
<br />
还有,在make的“隐含规则库”中,每一条隐含规则都在库中有其顺序,越靠前的则是越被经常使用的,所以,这会导致我们有些时候即使我们显示地指定了目标依赖,make也不会管。如下面这条规则(没有命令):<br />
<br />
foo.o : foo.p<br />
<br />
依赖文件“foo.p”(Pascal程序的源文件)有可能变得没有意义。如果目录下存在了“foo.c”文件,那么我们的隐含规则一样会生效,并会通过“foo.c”调用C的编译器生成foo.o文件。因为,在隐含规则中,Pascal的规则出现在C的规则之后,所以,make找到可以生成 foo.o的C的规则就不再寻找下一条规则了。如果你确实不希望任何隐含规则推导,那么,你就不要只写出“依赖规则”,而不写命令。<br />
<br />
<br />
==隐含规则一览==<br />
<br />
这里我们将讲述所有预先设置(也就是make内建)的隐含规则,如果我们不明确地写下规则,那么,make就会在这些规则中寻找所需要规则和命令。当然,我们也可以使用make的参数“-r”或“--no-builtin-rules”选项来取消所有的预设置的隐含规则。<br />
<br />
当然,即使是我们指定了“-r”参数,某些隐含规则还是会生效,因为有许多的隐含规则都是使用了“后缀规则”来定义的,所以,只要隐含规则中有 “后缀列表”(也就一系统定义在目标.SUFFIXES的依赖目标),那么隐含规则就会生效。默认的后缀列表是:.out, .a, .ln, .o, .c, .cc, .C, .p, .f, .F, .r, .y, .l, .s, .S, .mod, .sym, .def, .h, .info, .dvi, .tex, .texinfo, .texi, .txinfo, .w, .ch .web, .sh, .elc, .el。具体的细节,我们会在后面讲述。<br />
<br />
还是先来看一看常用的隐含规则吧。<br />
<br />
1、编译C程序的隐含规则。<br />
<br />
“<n>;.o”的目标的依赖目标会自动推导为“<n>;.c”,并且其生成命令是“$(CC) –c $(CPPFLAGS) $(CFLAGS)”<br />
<br />
2、编译C++程序的隐含规则。<br />
<br />
“<n>;.o”的目标的依赖目标会自动推导为“<n>;.cc”或是“<n>;.C”,并且其生成命令是 “$(CXX) –c $(CPPFLAGS) $(CFLAGS)”。(建议使用“.cc”作为C++源文件的后缀,而不是“.C”)<br />
<br />
3、编译Pascal程序的隐含规则。<br />
<br />
“<n>;.o”的目标的依赖目标会自动推导为“<n>;.p”,并且其生成命令是“$(PC) –c $(PFLAGS)”。<br />
<br />
4、编译Fortran/Ratfor程序的隐含规则。<br />
<br />
“<n>;.o”的目标的依赖目标会自动推导为“<n>;.r”或“<n>;.F”或“<n>;.f”,并且其生成命令是:<br />
“.f” “$(FC) –c $(FFLAGS)”<br />
“.F” “$(FC) –c $(FFLAGS) $(CPPFLAGS)”<br />
“.f” “$(FC) –c $(FFLAGS) $(RFLAGS)”<br />
<br />
5、预处理Fortran/Ratfor程序的隐含规则。<br />
<br />
“<n>;.f”的目标的依赖目标会自动推导为“<n>;.r”或“<n>;.F”。这个规则只是转换Ratfor或有预处理的Fortran程序到一个标准的Fortran程序。其使用的命令是:<br />
“.F” “$(FC) –F $(CPPFLAGS) $(FFLAGS)”<br />
“.r” “$(FC) –F $(FFLAGS) $(RFLAGS)”<br />
<br />
6、编译Modula-2程序的隐含规则。<br />
<br />
“<n>;.sym”的目标的依赖目标会自动推导为“<n>;.def”,并且其生成命令是:“$(M2C) $ (M2FLAGS) $(DEFFLAGS)”。“<n.o>;” 的目标的依赖目标会自动推导为“<n>;.mod”,并且其生成命令是:“$(M2C) $(M2FLAGS) $(MODFLAGS)”。<br />
<br />
7、汇编和汇编预处理的隐含规则。<br />
<br />
“<n>;.o” 的目标的依赖目标会自动推导为“<n>;.s”,默认使用编译品“as”,并且其生成命令是:“$ (AS) $(ASFLAGS)”。“<n>;.s” 的目标的依赖目标会自动推导为“<n>;.S”,默认使用C预编译器 “cpp”,并且其生成命令是:“$(AS) $(ASFLAGS)”。<br />
<br />
8、链接Object文件的隐含规则。<br />
<br />
“<n>;”目标依赖于“<n>;.o”,通过运行C的编译器来运行链接程序生成(一般是“ld”),其生成命令是: “$(CC) $(LDFLAGS) <n>;.o $(LOADLIBES) $(LDLIBS)”。这个规则对于只有一个源文件的工程有效,同时也对多个Object文件(由不同的源文件生成)的也有效。例如如下规则:<br />
<br />
x : y.o z.o<br />
<br />
并且“x.c”、“y.c”和“z.c”都存在时,隐含规则将执行如下命令:<br />
<br />
cc -c x.c -o x.o<br />
cc -c y.c -o y.o<br />
cc -c z.c -o z.o<br />
cc x.o y.o z.o -o x<br />
rm -f x.o<br />
rm -f y.o<br />
rm -f z.o<br />
<br />
如果没有一个源文件(如上例中的x.c)和你的目标名字(如上例中的x)相关联,那么,你最好写出自己的生成规则,不然,隐含规则会报错的。<br />
<br />
9、Yacc C程序时的隐含规则。<br />
<br />
“<n>;.c”的依赖文件被自动推导为“n.y”(Yacc生成的文件),其生成命令是:“$(YACC) $(YFALGS)”。(“Yacc”是一个语法分析器,关于其细节请查看相关资料)<br />
<br />
10、Lex C程序时的隐含规则。<br />
<br />
“<n>;.c”的依赖文件被自动推导为“n.l”(Lex生成的文件),其生成命令是:“$(LEX) $(LFALGS)”。(关于“Lex”的细节请查看相关资料)<br />
<br />
11、Lex Ratfor程序时的隐含规则。<br />
<br />
“<n>;.r”的依赖文件被自动推导为“n.l”(Lex生成的文件),其生成命令是:“$(LEX) $(LFALGS)”。<br />
<br />
12、从C程序、Yacc文件或Lex文件创建Lint库的隐含规则。<br />
<br />
“<n>;.ln” (lint生成的文件)的依赖文件被自动推导为“n.c”,其生成命令是:“$(LINT) $(LINTFALGS) $(CPPFLAGS) -i”。对于“<n>;.y”和“<n>;.l”也是同样的规则。<br />
<br />
<br />
==隐含规则使用的变量==<br />
<br />
在隐含规则中的命令中,基本上都是使用了一些预先设置的变量。你可以在你的makefile中改变这些变量的值,或是在make的命令行中传入这些值,或是在你的环境变量中设置这些值,无论怎么样,只要设置了这些特定的变量,那么其就会对隐含规则起作用。当然,你也可以利用make的“-R”或 “--no–builtin-variables”参数来取消你所定义的变量对隐含规则的作用。<br />
<br />
例如,第一条隐含规则——编译C程序的隐含规则的命令是“$(CC) –c $(CFLAGS) $(CPPFLAGS)”。Make默认的编译命令是“cc”,如果你把变量“$(CC)”重定义成“gcc”,把变量“$(CFLAGS)”重定义成“-g”,那么,隐含规则中的命令全部会以 “gcc –c -g $(CPPFLAGS)”的样子来执行了。<br />
<br />
我们可以把隐含规则中使用的变量分成两种:一种是命令相关的,如“CC”;一种是参数相的关,如“CFLAGS”。下面是所有隐含规则中会用到的变量:<br />
<br />
1、关于命令的变量。<br />
<br />
;AR:函数库打包程序。默认命令是“ar”。 <br />
;AS:汇编语言编译程序。默认命令是“as”。<br />
;CC:C语言编译程序。默认命令是“cc”。<br />
;CXX:C++语言编译程序。默认命令是“g++”。<br />
;CO:从 RCS文件中扩展文件程序。默认命令是“co”。<br />
;CPP:C程序的预处理器(输出是标准输出设备)。默认命令是“$(CC) –E”。<br />
;FC:Fortran 和 Ratfor 的编译器和预处理程序。默认命令是“f77”。<br />
;GET:从SCCS文件中扩展文件的程序。默认命令是“get”。 <br />
;LEX:Lex方法分析器程序(针对于C或Ratfor)。默认命令是“lex”。<br />
;PC:Pascal语言编译程序。默认命令是“pc”。<br />
;YACC:Yacc文法分析器(针对于C程序)。默认命令是“yacc”。<br />
;YACCR:Yacc文法分析器(针对于Ratfor程序)。默认命令是“yacc –r”。<br />
;MAKEINFO:转换Texinfo源文件(.texi)到Info文件程序。默认命令是“makeinfo”。<br />
;TEX:从TeX源文件创建TeX DVI文件的程序。默认命令是“tex”。<br />
;TEXI2DVI:从Texinfo源文件创建军TeX DVI 文件的程序。默认命令是“texi2dvi”。<br />
;WEAVE:转换Web到TeX的程序。默认命令是“weave”。<br />
;CWEAVE:转换C Web 到 TeX的程序。默认命令是“cweave”。<br />
;TANGLE:转换Web到Pascal语言的程序。默认命令是“tangle”。<br />
;CTANGLE:转换C Web 到 C。默认命令是“ctangle”。<br />
;RM:删除文件命令。默认命令是“rm –f”。<br />
<br />
2、关于命令参数的变量<br />
<br />
下面的这些变量都是相关上面的命令的参数。如果没有指明其默认值,那么其默认值都是空。<br />
<br />
;ARFLAGS:函数库打包程序AR命令的参数。默认值是“rv”。<br />
;ASFLAGS:汇编语言编译器参数。(当明显地调用“.s”或“.S”文件时)。 <br />
;CFLAGS:C语言编译器参数。<br />
;CXXFLAGS:C++语言编译器参数。<br />
;COFLAGS:RCS命令参数。 <br />
;CPPFLAGS:C预处理器参数。( C 和 Fortran 编译器也会用到)。<br />
;FFLAGS:Fortran语言编译器参数。<br />
;GFLAGS:SCCS “get”程序参数。<br />
;LDFLAGS:链接器参数。(如:“ld”)<br />
;LFLAGS:Lex文法分析器参数。<br />
;PFLAGS:Pascal语言编译器参数。<br />
;RFLAGS:Ratfor 程序的Fortran 编译器参数。<br />
;YFLAGS:Yacc文法分析器参数。 <br />
<br />
==隐含规则链==<br />
<br />
有些时候,一个目标可能被一系列的隐含规则所作用。例如,一个[.o]的文件生成,可能会是先被Yacc的[.y]文件先成[.c],然后再被C的编译器生成。我们把这一系列的隐含规则叫做“隐含规则链”。<br />
<br />
在上面的例子中,如果文件[.c]存在,那么就直接调用C的编译器的隐含规则,如果没有[.c]文件,但有一个[.y]文件,那么Yacc的隐含规则会被调用,生成[.c]文件,然后,再调用C编译的隐含规则最终由[.c]生成[.o]文件,达到目标。<br />
<br />
我们把这种[.c]的文件(或是目标),叫做中间目标。不管怎么样,make会努力自动推导生成目标的一切方法,不管中间目标有多少,其都会执着地把所有的隐含规则和你书写的规则全部合起来分析,努力达到目标,所以,有些时候,可能会让你觉得奇怪,怎么我的目标会这样生成?怎么我的 makefile发疯了?<br />
<br />
在默认情况下,对于中间目标,它和一般的目标有两个地方所不同:第一个不同是除非中间的目标不存在,才会引发中间规则。第二个不同的是,只要目标成功产生,那么,产生最终目标过程中,所产生的中间目标文件会被以“rm -f”删除。<br />
<br />
通常,一个被makefile指定成目标或是依赖目标的文件不能被当作中介。然而,你可以明显地说明一个文件或是目标是中介目标,你可以使用伪目标“.INTERMEDIATE”来强制声明。(如:.INTERMEDIATE : mid )<br />
<br />
你也可以阻止make自动删除中间目标,要做到这一点,你可以使用伪目标“.SECONDARY”来强制声明(如:.SECONDARY : sec)。你还可以把你的目标,以模式的方式来指定(如:%.o)成伪目标“.PRECIOUS”的依赖目标,以保存被隐含规则所生成的中间文件。<br />
<br />
在“隐含规则链”中,禁止同一个目标出现两次或两次以上,这样一来,就可防止在make自动推导时出现无限递归的情况。<br />
<br />
Make会优化一些特殊的隐含规则,而不生成中间文件。如,从文件“foo.c”生成目标程序“foo”,按道理,make会编译生成中间文件 “foo.o”,然后链接成“foo”,但在实际情况下,这一动作可以被一条“cc”的命令完成(cc –o foo foo.c),于是优化过的规则就不会生成中间文件。<br />
<br />
<br />
==定义模式规则==<br />
<br />
你可以使用模式规则来定义一个隐含规则。一个模式规则就好像一个一般的规则,只是在规则中,目标的定义需要有"%"字符。"%"的意思是表示一个或多个任意字符。在依赖目标中同样可以使用"%",只是依赖目标中的"%"的取值,取决于其目标。<br />
<br />
有一点需要注意的是,"%"的展开发生在变量和函数的展开之后,变量和函数的展开发生在make载入Makefile时,而模式规则中的"%"则发生在运行时。<br />
<br />
<br />
1、模式规则介绍<br />
<br />
模式规则中,至少在规则的目标定义中要包含"%",否则,就是一般的规则。目标中的"%"定义表示对文件名的匹配,"%"表示长度任意的非空字符串。例如:"%.c"表示以".c"结尾的文件名(文件名的长度至少为3),而"s.%.c"则表示以"s."开头,".c"结尾的文件名(文件名的长度至少为5)。<br />
<br />
如果"%"定义在目标中,那么,目标中的"%"的值决定了依赖目标中的"%"的值,也就是说,目标中的模式的"%"决定了依赖目标中"%"的样子。例如有一个模式规则如下:<br />
<br />
%.o : %.c ; <command ......>;<br />
<br />
其含义是,指出了怎么从所有的[.c]文件生成相应的[.o]文件的规则。如果要生成的目标是"a.o b.o",那么"%c"就是"a.c b.c"。<br />
<br />
一旦依赖目标中的"%"模式被确定,那么,make会被要求去匹配当前目录下所有的文件名,一旦找到,make就会规则下的命令,所以,在模式规则中,目标可能会是多个的,如果有模式匹配出多个目标,make就会产生所有的模式目标,此时,make关心的是依赖的文件名和生成目标的命令这两件事。<br />
<br />
<br />
2、模式规则示例<br />
<br />
下面这个例子表示了,把所有的[.c]文件都编译成[.o]文件.<br />
<br />
%.o : %.c<br />
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@<br />
<br />
其中,"$@"表示所有的目标的挨个值,"$<"表示了所有依赖目标的挨个值。这些奇怪的变量我们叫"自动化变量",后面会详细讲述。<br />
<br />
下面的这个例子中有两个目标是模式的:<br />
<br />
%.tab.c %.tab.h: %.y<br />
bison -d $<<br />
<br />
这条规则告诉make把所有的[.y]文件都以"bison -d <n>;.y"执行,然后生成"<n>;. tab.c"和"<n>;.tab.h"文件。(其中,"<n>;"表示一个任意字符串)。如果我们的执行程序"foo"依赖于文件"parse.tab.o"和"scan.o",并且文件"scan.o"依赖于文件"parse.tab.h",如果"parse.y"文件被更新了,那么根据上述的规则,"bison -d parse.y"就会被执行一次,于是,"parse.tab.o"和"scan.o"的依赖文件就齐了。(假设,"parse.tab.o"由"parse.tab.c"生成,和"scan.o"由"scan.c"生成,而"foo"由 "parse.tab.o"和"scan.o"链接生成,而且foo和其[.o]文件的依赖关系也写好,那么,所有的目标都会得到满足)<br />
<br />
<br />
3、自动化变量<br />
<br />
在上述的模式规则中,目标和依赖文件都是一系例的文件,那么我们如何书写一个命令来完成从不同的依赖文件生成相应的目标?因为在每一次的对模式规则的解析时,都会是不同的目标和依赖文件。<br />
<br />
自动化变量就是完成这个功能的。在前面,我们已经对自动化变量有所提涉,相信你看到这里已对它有一个感性认识了。所谓自动化变量,就是这种变量会把模式中所定义的一系列的文件自动地挨个取出,直至所有的符合模式的文件都取完了。这种自动化变量只应出现在规则的命令中。<br />
<br />
下面是所有的自动化变量及其说明:<br />
<br />
;$@: 表示规则中的目标文件集。在模式规则中,如果有多个目标,那么,"$@"就是匹配于目标中模式定义的集合。<br />
<br />
;$%: 仅当目标是函数库文件中,表示规则中的目标成员名。例如,如果一个目标是"foo.a(bar.o)",那么,"$%"就是 "bar.o","$@"就是"foo.a"。如果目标不是函数库文件(Unix下是[.a],Windows下是[.lib]),那么,其值为空。<br />
<br />
;$< :依赖目标中的第一个目标名字。如果依赖目标是以模式(即"%")定义的,那么"$<"将是符合模式的一系列的文件集。注意,其是一个一个取出来的。 <br />
;$?: 所有比目标新的依赖目标的集合。以空格分隔。<br />
<br />
;$^:所有的依赖目标的集合。以空格分隔。如果在依赖目标中有多个重复的,那个这个变量会去除重复的依赖目标,只保留一份。<br />
<br />
;$+:这个变量很像"$^",也是所有依赖目标的集合。只是它不去除重复的依赖目标。<br />
<br />
;$*: 这个变量表示目标模式中"%"及其之前的部分。如果目标是"dir/a.foo.b",并且目标的模式是"a.%.b",那么,"$*"的值就是"dir/a.foo"。这个变量对于构造有关联的文件名是比较有用。如果目标中没有模式的定义,那么"$*"也就不能被推导出,但是,如果目标文件的后缀是make所识别的,那么"$*"就是除了后缀的那一部分。例如:如果目标是"foo.c",因为".c"是make所能识别的后缀名,所以," $*"的值就是"foo"。这个特性是GNU make的,很有可能不兼容于其它版本的make,所以,你应该尽量避免使用"$*",除非是在隐含规则或是静态模式中。如果目标中的后缀是make所不能识别的,那么"$*"就是空值。<br />
<br />
当你希望只对更新过的依赖文件进行操作时,"$?"在显式规则中很有用,例如,假设有一个函数库文件叫"lib",其由其它几个object文件更新。那么把object文件打包的比较有效率的Makefile规则是:<br />
<br />
lib : foo.o bar.o lose.o win.o<br />
ar r lib $?<br />
<br />
在上述所列出来的自动量变量中。四个变量($@、$<、$%、$*)在扩展时只会有一个文件,而另三个的值是一个文件列表。这七个自动化变量还可以取得文件的目录名或是在当前目录下的符合模式的文件名,只需要搭配上"D"或"F"字样。这是GNU make中老版本的特性,在新版本中,我们使用函数"dir"或"notdir"就可以做到了。"D"的含义就是Directory,就是目录,"F"的含义就是File,就是文件。<br />
<br />
下面是对于上面的七个变量分别加上"D"或是"F"的含义:<br />
<br />
$(@D)<br />
表示"$@"的目录部分(不以斜杠作为结尾),如果"$@"值是"dir/foo.o",那么"$(@D)"就是"dir",而如果"$@"中没有包含斜杠的话,其值就是"."(当前目录)。<br />
<br />
$(@F)<br />
表示"$@"的文件部分,如果"$@"值是"dir/foo.o",那么"$(@F)"就是"foo.o","$(@F)"相当于函数"$(notdir $@)"。<br />
<br />
"$(*D)"<br />
"$(*F)"<br />
和上面所述的同理,也是取文件的目录部分和文件部分。对于上面的那个例子,"$(*D)"返回"dir",而"$(*F)"返回"foo"<br />
<br />
"$(%D)"<br />
"$(%F)"<br />
分别表示了函数包文件成员的目录部分和文件部分。这对于形同"archive(member)"形式的目标中的"member"中包含了不同的目录很有用。<br />
<br />
"$(<D)"<br />
"$(<F)"<br />
分别表示依赖文件的目录部分和文件部分。<br />
<br />
"$(^D)"<br />
"$(^F)"<br />
分别表示所有依赖文件的目录部分和文件部分。(无相同的)<br />
<br />
"$(+D)"<br />
"$(+F)"<br />
分别表示所有依赖文件的目录部分和文件部分。(可以有相同的)<br />
<br />
"$(?D)"<br />
"$(?F)"<br />
分别表示被更新的依赖文件的目录部分和文件部分。<br />
<br />
最后想提醒一下的是,对于"$<",为了避免产生不必要的麻烦,我们最好给$后面的那个特定字符都加上圆括号,比如,"$(<)"就要比"$<"要好一些。<br />
<br />
还得要注意的是,这些变量只使用在规则的命令中,而且一般都是"显式规则"和"静态模式规则"(参见前面"书写规则"一章)。其在隐含规则中并没有意义。<br />
<br />
4、模式的匹配<br />
<br />
一般来说,一个目标的模式有一个有前缀或是后缀的"%",或是没有前后缀,直接就是一个"%"。因为"%"代表一个或多个字符,所以在定义好了的模式中,我们把"%"所匹配的内容叫做"茎",例如"%.c"所匹配的文件"test.c"中"test"就是"茎"。因为在目标和依赖目标中同时有"% "时,依赖目标的"茎"会传给目标,当做目标中的"茎"。<br />
<br />
当一个模式匹配包含有斜杠(实际也不经常包含)的文件时,那么在进行模式匹配时,目录部分会首先被移开,然后进行匹配,成功后,再把目录加回去。在进行"茎"的传递时,我们需要知道这个步骤。例如有一个模式"e%t",文件"src/eat"匹配于该模式,于是"src/a"就是其"茎",如果这个模式定义在依赖目标中,而被依赖于这个模式的目标中又有个模式"c%r",那么,目标就是"src/car"。("茎"被传递)<br />
<br />
<br />
5、重载内建隐含规则<br />
<br />
你可以重载内建的隐含规则(或是定义一个全新的),例如你可以重新构造和内建隐含规则不同的命令,如:<br />
<br />
%.o : %.c<br />
$(CC) -c $(CPPFLAGS) $(CFLAGS) -D$(date)<br />
<br />
你可以取消内建的隐含规则,只要不在后面写命令就行。如:<br />
<br />
%.o : %.s<br />
<br />
同样,你也可以重新定义一个全新的隐含规则,其在隐含规则中的位置取决于你在哪里写下这个规则。朝前的位置就靠前。<br />
<br />
==老式风格的"后缀规则"==<br />
<br />
后缀规则是一个比较老式的定义隐含规则的方法。后缀规则会被模式规则逐步地取代。因为模式规则更强更清晰。为了和老版本的Makefile兼容,GNU make同样兼容于这些东西。后缀规则有两种方式:"双后缀"和"单后缀"。<br />
<br />
双后缀规则定义了一对后缀:目标文件的后缀和依赖目标(源文件)的后缀。如".c.o"相当于"%o : %c"。单后缀规则只定义一个后缀,也就是源文件的后缀。如".c"相当于"% : %.c"。<br />
<br />
后缀规则中所定义的后缀应该是make所认识的,如果一个后缀是make所认识的,那么这个规则就是单后缀规则,而如果两个连在一起的后缀都被 make所认识,那就是双后缀规则。例如:".c"和".o"都是make所知道。因而,如果你定义了一个规则是".c.o"那么其就是双后缀规则,意义就是".c"是源文件的后缀,".o"是目标文件的后缀。如下示例:<br />
<br />
.c.o:<br />
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<<br />
<br />
后缀规则不允许任何的依赖文件,如果有依赖文件的话,那就不是后缀规则,那些后缀统统被认为是文件名,如:<br />
<br />
.c.o: foo.h<br />
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<<br />
<br />
这个例子,就是说,文件".c.o"依赖于文件"foo.h",而不是我们想要的这样:<br />
<br />
%.o: %.c foo.h<br />
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<<br />
<br />
后缀规则中,如果没有命令,那是毫无意义的。因为他也不会移去内建的隐含规则。<br />
<br />
而要让make知道一些特定的后缀,我们可以使用伪目标".SUFFIXES"来定义或是删除,如:<br />
<br />
.SUFFIXES: .hack .win<br />
<br />
把后缀.hack和.win加入后缀列表中的末尾。<br />
<br />
.SUFFIXES: # 删除默认的后缀<br />
.SUFFIXES: .c .o .h # 定义自己的后缀<br />
<br />
先清除默认后缀,后定义自己的后缀列表。<br />
<br />
make的参数"-r"或"-no-builtin-rules"也会使用得默认的后缀列表为空。而变量"SUFFIXE"被用来定义默认的后缀列表,你可以用".SUFFIXES"来改变后缀列表,但请不要改变变量"SUFFIXE"的值。<br />
<br />
==隐含规则搜索算法==<br />
<br />
比如我们有一个目标叫 T。下面是搜索目标T的规则的算法。请注意,在下面,我们没有提到后缀规则,原因是,所有的后缀规则在Makefile被载入内存时,会被转换成模式规则。如果目标是"archive(member)"的函数库文件模式,那么这个算法会被运行两次,第一次是找目标T,如果没有找到的话,那么进入第二次,第二次会把"member"当作T来搜索。<br />
<br />
1、把T的目录部分分离出来。叫D,而剩余部分叫N。(如:如果T是"src/foo.o",那么,D就是"src/",N就是"foo.o")<br />
<br />
2、创建所有匹配于T或是N的模式规则列表。<br />
<br />
3、如果在模式规则列表中有匹配所有文件的模式,如"%",那么从列表中移除其它的模式。<br />
<br />
4、移除列表中没有命令的规则。<br />
<br />
5、对于第一个在列表中的模式规则:<br />
<br />
1)推导其"茎"S,S应该是T或是N匹配于模式中"%"非空的部分。<br />
<br />
2)计算依赖文件。把依赖文件中的"%"都替换成"茎"S。如果目标模式中没有包含斜框字符,而把D加在第一个依赖文件的开头。<br />
<br />
3)测试是否所有的依赖文件都存在或是理当存在。(如果有一个文件被定义成另外一个规则的目标文件,或者是一个显式规则的依赖文件,那么这个文件就叫"理当存在")<br />
<br />
4)如果所有的依赖文件存在或是理当存在,或是就没有依赖文件。那么这条规则将被采用,退出该算法。<br />
<br />
6、如果经过第5步,没有模式规则被找到,那么就做更进一步的搜索。对于存在于列表中的第一个模式规则:<br />
<br />
1)如果规则是终止规则,那就忽略它,继续下一条模式规则。<br />
<br />
2)计算依赖文件。(同第5步)<br />
<br />
3)测试所有的依赖文件是否存在或是理当存在。<br />
<br />
4)对于不存在的依赖文件,递归调用这个算法查找他是否可以被隐含规则找到。<br />
<br />
5)如果所有的依赖文件存在或是理当存在,或是就根本没有依赖文件。那么这条规则被采用,退出该算法。<br />
<br />
<br />
7、如果没有隐含规则可以使用,查看".DEFAULT"规则,如果有,采用,把".DEFAULT"的命令给T使用。<br />
<br />
一旦规则被找到,就会执行其相当的命令,而此时,我们的自动化变量的值才会生成。</div>96.47.232.233https://wiki.ubuntu.org.cn/index.php?title=Corey/vimrc&diff=153845Corey/vimrc2016-06-15T03:05:41Z<p>96.47.232.233:/* vimrc的一个简单例子 */</p>
<hr />
<div>=== vimrc的一个简单例子 ===<br />
<br />
是一个我自己的简单例子,经过简单的修改就可以变成你自己的,enjoy it. 我也是修改别人的,呵呵<br />
<br />
另外,https://github.com/kepbod/vim-config 里的配置也很不错,可以去看看<br />
<br />
注意看下面的文本里面的注释。 拷贝,修改里面注释的地方,粘在vim的安装目录_vimrc里面。<br />
<br />
然后就可以打开gvim试一下了。<br />
<br />
第一个个是在windows上vim7.0测试通过的, 第二个是用于ubuntu上。<br />
<br />
注意有可能拷贝到ubuntu时,行尾会带有WINDOWS的换行回车,<br />
<br />
可以直接在vim里面从新打开.vimrc这个文件,删掉行尾怪怪的符号就行了。和修改set guifont为你的ubuntu可用的字体和编码格式。<br />
<br />
我这里是作为我windows上实际使用的文件,同时也是说明怎么使用字体名称带空格的方法。<br />
<br />
最近写的一个插件,截图和下载地址<br><br />
<br />
http://www.vim.org/scripts/script.php?script_id=2194<br><br />
<br />
[[Image:Vim_marks.PNG]]<br><br />
<br />
==== _vimrc windows版 ====<br />
<pre>" ######## windows vim 7.1 ########<br />
" ######## 注意这个部分是用在windows上面的 适用于vim7.1,只需拷贝覆盖你的vim安装目录下_vimrc文件。 "下面几行保证你使用的时候类似windows其它的编辑器,Ctrl+v Ctrl+c 也可以用了<br />
set nocompatible<br />
source $VIMRUNTIME/vimrc_example.vim<br />
source $VIMRUNTIME/mswin.vim<br />
behave mswin &nbsp; &nbsp; <br />
colo corey "//这里需要修改成你喜欢的,要不然就把我底下的文件拷贝下来,粘在vim的colors目录下起名corey.vim里面。<br />
"不换行显示<br />
<br />
set nowrap "把tab键转化为空格<br />
set expandtab "不忽略大小写<br />
set noignorecase<br />
"显示下面的横向滚动条<br />
set guioptions+=b <br />
"高亮显示当前光标行<br />
set cul<br />
"下面两句是,当你是插入模式时候,取消行高亮<br />
au InsertEnter * set nocul<br />
au InsertLeave * set cul<br />
"放开下面的注释,为开始的时候自动窗口最大化<br />
"au GUIEnter * simalt ~x "maximum the initial window<br />
<br />
<br />
"在状态行显示一些编码信息<br />
if has("statusline")<br />
set statusline=%&lt;%f\ %h%m%r%=%{\"[\".(&amp;fenc==\"\"?&amp;enc:&amp;fenc).\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P<br />
endif<br />
"默认设置ctag寻找tags文件的路径,<br />
set tags=tags,./tags<br />
<br />
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1<br />
set guifont=NSimSun:h14:cGB2312<br />
<br />
<br />
set diffexpr=MyDiff()<br />
<br />
function MyDiff()<br />
let opt = '-a --binary '<br />
if &amp;diffopt =~ 'icase' | let opt = opt . '-i ' | endif<br />
if &amp;diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif<br />
let arg1 = v:fname_in<br />
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif<br />
let arg2 = v:fname_new<br />
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif<br />
let arg3 = v:fname_out<br />
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif<br />
let eq = ''<br />
if $VIMRUNTIME =~ ' '<br />
if &amp;sh =~ '\&lt;cmd'<br />
let cmd = '""' . $VIMRUNTIME . '\diff"'<br />
let eq = '"'<br />
else<br />
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'<br />
endif<br />
else<br />
let cmd = $VIMRUNTIME . '\diff'<br />
endif<br />
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' &gt; ' . arg3 . eq<br />
endfunction<br />
<br />
<br />
<br />
<br />
</pre> <br />
==== vimrc Ubuntu版 ====<br />
<pre>" ######## Ubuntu vim 7.0 ########<br />
" ######## 注意这个部分是用在Ubuntu上面的 适用于vim7.0,只需拷贝添加到你的vim安装目录下(/etc/vim/vimrc)文件中任意位置。<br />
colo corey<br />
set number<br />
set shiftwidth=4<br />
set softtabstop=4<br />
set tabstop=4<br />
set fileencodings=ucs-bom,utf-8<br />
set guifont=Monospace\ 16<br />
set nobk<br />
<br />
</pre> <br />
==== 配色方案(corey.vim) ====<br />
" Vim color file<br />
" Maintainer: corey<br />
" Last Change: 2005 November 21<br />
" This color scheme uses a dark grey background.<br />
" First remove all existing highlighting.<br />
set background=dark<br />
hi clear<br />
if exists("syntax_on")<br />
syntax reset<br />
endif<br />
let colors_name = "corey"<br />
hi Normal ctermbg=DarkGrey ctermfg=White guifg=White guibg=grey20<br />
" Groups used in the 'highlight' and 'guicursor' options default value.<br />
hi ErrorMsg term=standout ctermbg=DarkRed ctermfg=White guibg=Red guifg=White<br />
hi IncSearch term=reverse cterm=reverse gui=reverse<br />
hi ModeMsg term=bold cterm=bold gui=bold<br />
"hi StatusLine term=reverse,bold cterm=reverse,bold gui=reverse,bold<br />
"hi StatusLineNC term=reverse cterm=reverse gui=reverse<br />
hi StatusLine term=reverse cterm=reverse,bold guibg=black guifg=White<br />
hi StatusLineNC term=reverse cterm=reverse guibg=White guifg=darkgray<br />
"hi StatusLine term=reverse,bold cterm=reverse gui=NONE guifg=White guibg=darkblue<br />
"hi StatusLineNC term=reverse cterm=reverse gui=NONE guifg=white guibg=#333333<br />
hi VertSplit term=reverse cterm=reverse gui=reverse<br />
hi Visual term=reverse cterm=reverse gui=reverse guifg=Grey guibg=fg<br />
hi VisualNOS term=underline,bold cterm=underline,bold gui=underline,bold<br />
hi DiffText term=reverse cterm=bold ctermbg=Red gui=bold guibg=Red<br />
hi Cursor guibg=Green guifg=Black<br />
hi lCursor guibg=Cyan guifg=Black<br />
hi Directory term=bold ctermfg=LightCyan guifg=Cyan<br />
hi LineNr term=underline ctermfg=LightCyan guifg=LightCyan<br />
hi MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen<br />
hi NonText term=bold ctermfg=LightBlue gui=bold guifg=LightBlue guibg=grey30<br />
hi Question term=standout ctermfg=LightGreen gui=bold guifg=Green<br />
hi Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black<br />
hi SpecialKey term=bold ctermfg=LightBlue guifg=Cyan<br />
hi Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta<br />
hi WarningMsg term=standout ctermfg=LightRed guifg=Red<br />
hi WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black<br />
hi Folded term=standout ctermbg=LightGrey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue<br />
hi FoldColumn term=standout ctermbg=LightGrey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue<br />
hi DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue<br />
hi DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta<br />
hi DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan<br />
" Groups for syntax highlighting<br />
hi Constant term=underline ctermfg=Magenta guifg=#ffa0a0 guibg=grey5<br />
hi Special term=bold ctermfg=LightRed guifg=Orange guibg=grey5<br />
<br />
hi CursorLine term=underline cterm=underline gui=underline ctermbg=NONE guibg=NONE<br />
if &amp;t_Co &gt; 8<br />
hi Statement term=bold cterm=bold ctermfg=Yellow guifg=#ffff60 gui=bold<br />
endif<br />
hi Ignore ctermfg=DarkGrey guifg=grey20<br />
" vim: sw=2<br />
<br />
<br />
<br />
----<br />
<br />
* [[支持所有版本类]]</div>96.47.232.233https://wiki.ubuntu.org.cn/index.php?title=Shell%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80&diff=153842Shell编程基础2016-06-14T08:49:13Z<p>96.47.232.233:/* 变量算术 */</p>
<hr />
<div>原作者 Leal;请参阅页面底部的编者列表。<br />
<br />
授权许可:<br />
* [http://creativecommons.org/licenses/by-sa/2.0/ 创作共享署名协议]<br />
* [http://www.gnu.org/copyleft/fdl.html GNU 自由文档许可证]<br />
<br />
注意:本文仍然在持续的修订之中,且错漏之处可能较多。如果能够阅读英语的话,可以考虑试试较为完善的 [http://mywiki.wooledge.org/BashGuide/ Wooledge BashGuide]。这个站点除了教程之外,还有一些类似“bash 百科”的内容。[https://gnu.org/s/bash/manual Bash 官方手册]也是你的好朋友。<br />
<br />
== 从第一行开始 ==<br />
我们可以使用任意一种文字编辑器,比如gedit、kedit、emacs、vi等来编写shell脚本,它必须以如下行开始(必须放在文件的第一行): <br />
<br />
<source lang=bash>#!/bin/bash</source><br />
<br />
此行称为 [https://en.wikipedia.org/wiki/shebang shebang](就是 sharp (#) + bang (!) 的意思),会指引操作系统使用接下来指定的程序运行此文件。此处 <tt>/bin/bash</tt> 执行我们的文件。<br />
<br />
一些人使用 <tt>#!/bin/sh</tt> 来让 <tt>sh</tt> 执行文件,按照习惯这表示任何支持 [http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html POSIX shell 命令语言]的 <tt>sh</tt>程序。为了用上我们所喜欢的 <tt>bash</tt> 拓展语法功能,我们就不这么用了。如果你使用别的脚本,例如 <tt>/bin/tcsh</tt>,照着样子加个 <tt>#!</tt> 就行。<br />
<br />
编辑结束并保存后,如果直接要执行该脚本,必须先使其具有可执行属性: <br />
<br />
<source lang=bash>chmod +x filename</source><br />
<br />
此后在该脚本所在目录下,输入 <tt>./filename<tt> 即可执行该脚本。 <br />
<br />
== 变量 ==<br />
<br />
Shell 变量默认全都是字符串。<br />
<br />
=== 变量赋值和引用 ===<br />
<br />
Shell 编程中,使用变量无需事先声明。变量名的命名遵守正则表达式 <tt>[a-zA-Z_][a-zA-Z0-9_]+</tt>,也就是由大小写字母数字和下划线组成,且不能以数字开头。请注意 shell 环境中的确有以数字和特殊符号开头的变量名,但是那些东西不可以用接下来的方式赋值。<br />
<br />
需要给变量赋值时,可以这么写: <br />
<br />
<source lang=bash>varname=值 [var2=val2 ....]</source><br />
<br />
请注意这边等号左右不能有空格。<br />
要取用一个变量的值,只需在变量名前面加一个 <tt>$</tt>:<br />
<br />
<source lang=bash># assign<br />
a="hello world" # 等号两边均不能有空格存在<br />
# print<br />
printf '%s\n' "A is: $a"</source><br />
<br />
挑个自己喜欢的编辑器,输入上述内容,并保存为文件 first,然后执行 chmod +x first 使其可执行,最后输入 ./first 执行该脚本。其输出结果如下:<br />
<br />
<source lang="bash"><br />
A is: hello world<br />
</source><br />
<br />
有时候变量名可能会和其它文字(匹配最长的符合变量名或特殊变量名要求的内容)混淆,比如: <br />
<br />
<source lang=bash>num=2<br />
echo "this is the $numnd" # 输出 this is the — shell 尝试寻找 $numnd 的值<br />
echo "this is the ${num}nd" # 输出 this is the 2nd — 修好了!<br />
# 花括号可以隔开变量名,但是放歪了的话…<br />
echo "this is the {$num}nd" # 输出 this is the {2}nd — 切是切开了,但是…</source><br />
<br />
=== 变量算术 ===<br />
<br />
Shell 变量默认都是字符串。这也就是说,你尝试这么做,肯定没用:<br />
<br />
<source lang=bash>var=1<br />
var=$var+1<br />
echo $var # 输出 1+1</source><br />
<br />
我们可以用很多方法达成我们的目标。首先是好孩子的方法——C 风格表达式。<br />
<br />
<source lang=bash>var=0<br />
# bash 里面可以用 (( )) 执行 C 风格的算术表达式。<br />
# 如果你接下来还会读 if 那一段的话,你还会知道这玩意的返回和 C 的非零真假判断一致。<br />
(( var += 1 )) # 这是一种,现在 var 是 1<br />
(( var++ )) # 这也是一种自增,2<br />
(( var = var * var )) # 怎么来乘法了!var 现在是 4。<br />
let 'var = var / 3' # 还是只有 bash 才能用的拓展。除法是整数除法,向 0 舍入,1。<br />
# 来一点不一定要 bash 的方法吧,毕竟 sh 还有很多种,总不能全报错了吧。<br />
# $(( )) 会展开成为这个 C 表达式求值的结果。以前 bash 有个 $[ ] 一样,但是别去用。<br />
echo $((var += 2)) # echo 出 3,var 现在是 3。<br />
var=$((var-1)) # 展开成 var=2,var 现在是……还用说吗,2。</source><br />
<br />
以前还有人用 expr 之类的外部程序来,不过这属于杀鸡用牛刀。并且调用外部程序浪费时间性能差。<br />
<br />
<source lang=bash>var=1<br />
var=$(expr "$var" + 1) # expr 收到三个参数 '1' '+' '1',<br />
<br />
# 按照 expr --help 里面写的方法运行<br />
# 然后输出替换掉 $() 这里变成 var=2。<br />
<br />
var=`expr "$var" + 1` # 前面一行的老写法,千万千万不要学。</source><br />
<br />
== Shell里的流程控制 ==<br />
<br />
=== if 语句 ===<br />
<br />
if 表达式如果条件命令组为真,则执行 then 后的部分。标准形式:<br />
<br />
<source lang=bash>if <br />
判断命令,可以有很多个,真假取最后的返回值<br />
then<br />
如果前述为真做什么<br />
[ # 方括号代表可选,别真打进去了!<br />
elif<br />
可以再来个判断,如果签名为假继续尝试这里<br />
then<br />
如果前述为真做什么 ]<br />
else<br />
如果全都不行做什么<br />
fi # 结束,就是倒写的 if 啦。</source><br />
<br />
现实生活中一般判断只有一个命令,所以你看到的一般是:<br />
<br />
<source lang=bash>if ....; then # 你也可以写成 if 之后换行,这样就不用分号了。<br />
....<br />
fi</source><br />
<br />
大多数情况下,可以使用测试命令来对条件进行测试,比如可以比较字符串、判断文件是否存在及是否可读等等……在 bash 中一般采用更好用的 <tt>[[ ... ]]</tt> 语法进行条件测试,而通用方法是 <tt>[ ... ]<tt>(相当于 <tt>test ...</tt>)。两者都接纳的常用测试语句有:<br />
<br />
;<tt>-f "filename"</tt>:判断是否是一个文件<br />
;<tt>-x "/bin/ls"</tt>:判断/bin/ls是否存在并有可执行权限<br />
;<tt>-n "$var"</tt>:判断 $var 变量是否有值<br />
;<tt>"$a" == "$b"</tt>:判断$a和$b是否相等<br />
<br />
前者可以使用 <tt>help [[</tt> 查询用法,后者使用 <tt>help [</tt> (bash) 或 <tt>man test</tt> 查询。下面的语句用到了这个内容:<br />
<br />
<source lang=bash>if [ "${SHELL}" == "/bin/bash" ]; then<br />
echo "your login shell is the bash (bourne again shell)"<br />
else<br />
echo "your login shell is not bash but ${SHELL}"<br />
fi</source><br />
<br />
变量 <tt>$SHELL</tt> 包含有登录shell的名称,我们拿它和 <tt>/bin/bash</tt> 进行比较以判断当前使用的shell是否为bash。你可能会问了,要是 bash 路径不是这个呢?<br />
<br />
=== && 和 || 操作符 ===<br />
<br />
熟悉C语言的朋友可能会喜欢下面的表达式:<br />
<br />
<source lang=bash>[ -f "/etc/shadow" ] && echo "This computer uses shadow passwords"</source><br />
<br />
这里的 && 就是一个快捷操作符,如果左边的表达式为真(返回 0——“成功”)则执行右边的语句,你也可以把它看作逻辑运算里的与操作。上述脚本表示如果/etc/shadow文件存在,则打印“This computer uses shadow passwords”。<br />
<br />
同样shell编程中还可以用或操作 (||),例如:<br />
<br />
<source lang=bash>#!/bin/bash<br />
<br />
mailfolder=/var/spool/mail/james<br />
[ -r "$mailfolder" ] || { echo "Can not read $mailfolder"; exit 1; }<br />
echo "$mailfolder has mail from:"<br />
grep "^From " $mailfolder</source><br />
<br />
该脚本首先判断mailfolder是否可读,如果可读则打印该文件中以"From"开头的行。如果不可读则或操作生效,打印错误信息后脚本退出。需要注意的是,这里我们必须使用如下两个命令:<br />
<br />
<source lang=bash>{<br />
echo "Can not read $mailfolder"; # 打印错误信息<br />
exit 1; # 退出程序<br />
}</source><br />
<br />
我们使用花括号以组合命令的形式将两个命令放到一起作为一个命令使用。即使不用与和或操作符,我们也可以用if表达式完成任何事情,但是使用与或操作符会更便利很多。<br />
<br />
要注意 Shell 中的 && || 程序流操作符不表现任何优先级区别,完全是先看到谁就先处理谁的关系。<br />
<br />
=== case 语句 ===<br />
<br />
case表达式可以用来匹配一个给定的字符串,而不是数字(可别和C语言里的switch...case混淆)。<br />
<br />
<source lang="bash"><br />
case ... in<br />
...) do something here <br />
;;<br />
esac<br />
</source><br />
file命令可以辨别出一个给定文件的文件类型,如:file lf.gz,其输出结果为:<br />
<br />
<source lang="bash"><br />
lf.gz: gzip compressed data, deflated, original filename,<br />
last modified: Mon Aug 27 23:09:18 2001, os: Unix<br />
</source><br />
<br />
我们利用这点写了一个名为smartzip的脚本,该脚本可以自动解压bzip2, gzip和zip 类型的压缩文件:<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
ftype="$(file "$1")"<br />
case "$ftype" in<br />
"$1: Zip archive"*)<br />
unzip "$1" ;;<br />
"$1: gzip compressed"*)<br />
gunzip "$1" ;;<br />
"$1: bzip2 compressed"*)<br />
bunzip2 "$1" ;;<br />
*)<br />
echo "File $1 can not be uncompressed with smartzip";;<br />
esac<br />
</source><br />
<br />
你可能注意到上面使用了一个特殊变量 {{code|$1}},该变量包含有传递给该脚本的第一个参数值。也就是说,当我们运行:<br />
<br />
<source lang="bash"><br />
smartzip articles.zip<br />
</source><br />
<br />
{{code|$1}} 就是字符串 articles.zip。<br />
<br />
=== select 循环语句 ===<br />
<br />
select 循环语句是bash的一种扩展应用,擅长于交互式场合。<br />
<br />
用户可以从一组不同的值中进行选择: <br />
<br />
<source lang="bash"><br />
pocket=()<br />
select var in 跳跳糖 糖 很多糖 企鹅糖; do<br />
echo "除了 $var 还要什么吗?"<br />
if ((RANDOM%4 == 0)); then<br />
echo "呀!时间不够了,快上车!"<br />
break # break 还是那个 break<br />
fi<br />
pocket+=("$var")<br />
done<br />
echo "你最后说的那个 $var 弄丢了……"<br />
IFS='、'<br />
echo "现在口袋里只有:${pocket[*]}。"<br />
IFS=$' \t\n'<br />
</source><br />
<br />
下面是一个简单的示例: <br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
echo "What is your favourite OS?"<br />
select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do<br />
break;<br />
done<br />
echo "You have selected $var"<br />
</source><br />
<br />
该脚本的运行结果如下: <br />
<br />
<source lang="bash"><br />
What is your favourite OS?<br />
1) Linux<br />
2) Gnu Hurd<br />
3) Free BSD<br />
4) Other<br />
#? 1<br />
You have selected Linux<br />
</source><br />
<br />
=== while/for 循环===<br />
<br />
在shell中,可以使用如下循环:<br />
<br />
<source lang="bash"><br />
while ...; do<br />
....<br />
done<br />
</source><br />
<br />
只要测试表达式条件为真,则while循环将一直运行。关键字"break"用来跳出循环,而关键字”continue”则可以跳过一个循环的余下部分,直接跳到下一次循环中。<br />
<br />
for循环会查看一个字符串列表(字符串用空格分隔),并将其赋给一个变量:<br />
<br />
<source lang="bash"><br />
for var in ....; do<br />
....<br />
done<br />
</source><br />
<br />
下面的示例会把A B C分别打印到屏幕上:<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
for var in A B C ; do<br />
echo "var is $var"<br />
done<br />
</source><br />
<br />
下面是一个实用的脚本showrpm,其功能是打印一些RPM包的统计信息:<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
# list a content summary of a number of RPM packages<br />
# USAGE: showrpm rpmfile1 rpmfile2 ...<br />
# EXAMPLE: showrpm /cdrom/RedHat/RPMS/*.rpm<br />
for rpmpackage in "$@"; do<br />
if [ -r "$rpmpackage" ];then<br />
echo "=============== $rpmpackage =============="<br />
rpm -qi -p $rpmpackage<br />
else<br />
echo "ERROR: cannot read file $rpmpackage"<br />
fi<br />
done<br />
</source><br />
<br />
这里出现了第二个特殊变量$@,该变量包含有输入的所有命令行参数值。如果你运行showrpm openssh.rpm w3m.rpm webgrep.rpm,那么 "$@"(有引号) 就包含有 3 个字符串,即openssh.rpm, w3m.rpm和 webgrep.rpm。$*的意思是差不多的。但是只有一个字串。如果不加引号,带空格的参数会被截断。<br />
<br />
== Shell里的一些特殊符号==<br />
<br />
=== 引号 ===<br />
<br />
在向程序传递任何参数之前,程序会扩展通配符和变量。这里所谓的扩展是指程序会把通配符(比如*)替换成适当的文件名,把变量替换成变量值。我们可以使用引号来防止这种扩展,先来看一个例子,假设在当前目录下有两个jpg文件:mail.jpg和tux.jpg。<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
echo *.jpg # => mail.jpg tux.jpg<br />
</source><br />
<br />
引号(单引号和双引号)可以防止通配符*的扩展:<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
echo "*.jpg" # => *.jpg<br />
echo '*.jpg' # => *.jpg<br />
</source><br />
<br />
其中单引号更严格一些,它可以防止任何变量扩展;而双引号可以防止通配符扩展但允许变量扩展:<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
echo $SHELL # => /bin/bash<br />
echo "$SHELL" # => /bin/bash<br />
echo '$SHELL' # => $SHELL<br />
</source><br />
<br />
此外还有一种防止这种扩展的方法,即使用转义字符——反斜杠{{code|\}}:<br />
<br />
<source lang="bash"><br />
echo \*.jpg # => *.jpg<br />
echo \$SHELL # => $SHELL<br />
</source><br />
<br />
== Here Document ==<br />
<br />
当要将几行文字传递给一个命令时,用here document是一种不错的方法。对每个脚本写一段帮助性的文字是很有用的,此时如果使用here document就不必用echo函数一行行输出。Here document以 &lt;&lt; 开头,后面接上一个字符串,这个字符串还必须出现在here document的末尾。下面是一个例子,在该例子中,我们对多个文件进行重命名,并且使用here document打印帮助: <br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
# we have less than 3 arguments. Print the help text:<br />
if [ $# -lt 3 ] ;; then<br />
cat << HELP<br />
<br />
ren -- renames a number of files using sed regular expressions USAGE: ren 'regexp' 'replacement' files...<br />
<br />
EXAMPLE: rename all *.HTM files in *.html:<br />
ren 'HTM$' 'html' *.HTM<br />
<br />
HELP #这里HELP要顶格写,前面不能有空格或者TAB制表符。如果cat一行写成cat &lt;&lt; -HELP,前边可以带TAB.<br />
exit 0<br />
fi<br />
OLD="$1"<br />
NEW="$2"<br />
# The shift command removes one argument from the list of<br />
# command line arguments.<br />
shift<br />
shift<br />
# $@ contains now all the files:<br />
for file in "$@"; do<br />
if [ -f "$file" ]&nbsp;; then<br />
newfile=`echo "$file" | sed "s/${OLD}/${NEW}/g"`<br />
if [ -f "$newfile" ]; then<br />
echo "ERROR: $newfile exists already"<br />
else<br />
echo "renaming $file to $newfile ..."<br />
mv "$file" "$newfile"<br />
fi<br />
fi<br />
done<br />
</source><br />
示例有点复杂,我们需要多花点时间来说明一番。第一个if表达式判断输入命令行参数是否小于3个 (特殊变量$# 表示包含参数的个数) 。如果输入参数小于3个,则将帮助文字传递给cat命令,然后由cat命令将其打印在屏幕上。打印帮助文字后程序退出。如果输入参数等于或大于3个,我们就将第一个参数赋值给变量OLD,第二个参数赋值给变量NEW。下一步,我们使用shift命令将第一个和第二个参数从参数列表中删除,这样原来的第三个参数就成为参数列表$*的第一个参数。然后我们开始循环,命令行参数列表被一个接一个地被赋值给变量$file。接着我们判断该文件是否存在,如果存在则通过sed命令搜索和替换来产生新的文件名。然后将反短斜线内命令结果赋值给newfile。这样我们就达到了目的:得到了旧文件名和新文件名。然后使用 mv命令进行重命名<br />
<br />
== Shell里的函数 ==<br />
<br />
如果你写过比较复杂的脚本,就会发现可能在几个地方使用了相同的代码,这时如果用上函数,会方便很多。函数的大致样子如下: <br />
<br />
<source lang="bash"><br />
# 别笑,bash 里面函数名的确可以这样……<br />
# (POSIX sh 函数名倒是和变量名要求差不多)<br />
我是一个函数() {<br />
# 函数里面 $1 $2 对应函数所接受到的第一、第二……个参数。<br />
这里有很多命令<br />
}<br />
</source><br />
<br />
函数没有必要声明。只要在执行之前出现定义就行<br />
<br />
下面是一个名为xtitlebar的脚本,它可以改变终端窗口的名称。这里使用了一个名为help的函数,该函数在脚本中使用了两次: <br />
<br />
<source lang=bash>#!/bin/bash<br />
<br />
help()<br />
{<br />
cat << HELP<br />
xtitlebar -- change the name of an xterm, gnome-terminal or kde konsole<br />
USAGE: xtitlebar [-h] "string_for_titelbar"<br />
OPTIONS: -h help text<br />
EXAMPLE: xtitlebar "cvs"<br />
HELP<br />
exit 0<br />
}<br />
# in case of error or if -h is given we call the function help:<br />
if [[ $1 == '' || $1 == '-h' ]]; then<br />
help<br />
fi<br />
# send the escape sequence to change the xterm titelbar:<br />
echo -e "\033]0;$1\007"<br />
#</source> <br />
在脚本中提供帮助是一种很好的编程习惯,可以方便其他用户(和自己)使用和理解脚本。<br />
<br />
== 命令行参数 == <br />
<br />
我们已经见过 {{code|$*}} 和 {{code|$1}}, $2 ... $9 等特殊变量,这些特殊变量包含了用户从命令行输入的参数。迄今为止,我们仅仅了解了一些简单的命令行语法(比如一些强制性的参数和查看帮助的-h选项)。但是在编写更复杂的程序时,您可能会发现您需要更多的自定义的选项。通常的惯例是在所有可选的参数之前加一个减号,后面再加上参数值 (比如文件名)。 <br />
<br />
有好多方法可以实现对输入参数的分析,但是下面的使用case表达式的例子无疑是一个不错的方法。 <br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
<br />
help()<br />
{<br />
cat &lt;&lt; HELP<br />
This is a generic command line parser demo.<br />
USAGE EXAMPLE: cmdparser -l hello -f -- -somefile1 somefile2<br />
HELP<br />
exit 0<br />
}<br />
<br />
while [ -n "$1" ]; do<br />
case "$1" in<br />
-h) help;shift 1;; # function help is called<br />
-f) opt_f=1;shift 1;; # variable opt_f is set<br />
-l) opt_l=$2;shift 2;; # -l takes an argument -&gt; shift by 2<br />
--) shift;break;; # end of options<br />
-*) echo "error: no such option $1. -h for help";exit 1;;<br />
*) break;;<br />
esac<br />
done<br />
<br />
echo "opt_f is $opt_f"<br />
echo "opt_l is $opt_l"<br />
echo "first arg is $1"<br />
echo "2nd arg is $2"<br />
<br />
</source><br />
<br />
你可以这样运行该脚本: <br />
<br />
<source lang="bash"><br />
cmdparser -l hello -f -- -somefile1 somefile2<br />
</source><br />
<br />
返回结果如下: <br />
<br />
<source lang="bash"><br />
opt_f is 1<br />
opt_l is hello<br />
first arg is -somefile1<br />
2nd arg is somefile2<br />
</source><br />
<br />
这个脚本是如何工作的呢?脚本首先在所有输入命令行参数中进行循环,将输入参数与case表达式进行比较,如果匹配则设置一个变量并且移除该参数。根据unix系统的惯例,首先输入的应该是包含减号的参数。<br />
<br />
== Shell脚本示例==<br />
<br />
=== 一般编程步骤=== <br />
<br />
现在我们来讨论编写一个脚本的一般步骤。任何优秀的脚本都应该具有帮助和输入参数。写一个框架脚本(framework.sh),该脚本包含了大多数脚本需要的框架结构,是一个非常不错的主意。这样一来,当我们开始编写新脚本时,可以先执行如下命令:<br />
<br />
<source lang="bash"><br />
cp framework.sh myscript<br />
</source><br />
<br />
然后再插入自己的函数。<br />
<br />
让我们来看看如下两个示例。<br />
<br />
=== 二进制到十进制的转换 ===<br />
<br />
脚本 b2d 将二进制数 (比如 1101) 转换为相应的十进制数。这也是一个用expr命令进行数学运算的例子: <br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
# vim: set sw=4 ts=4 et:<br />
help()<br />
{<br />
cat << HELP<br />
<br />
b2d -- convert binary to decimal<br />
<br />
USAGE: b2d [-h] binarynum<br />
<br />
OPTIONS: -h help text<br />
<br />
EXAMPLE: b2d 111010<br />
will return 58<br />
HELP<br />
exit 0<br />
}<br />
<br />
error()<br />
{<br />
# print an error and exit<br />
echo "$1"<br />
exit 1<br />
}<br />
<br />
lastchar()<br />
{<br />
# return the last character of a string in $rval<br />
if [ -z "$1" ]; then<br />
# empty string<br />
rval=""<br />
return<br />
fi<br />
# wc puts some space behind the output this is why we need sed:<br />
numofchar=`echo -n "$1" | sed 's/ //g' | wc -c ` <br />
#sed 's/ //g' 所有空白去掉 sed 's/ /\t/g' 所有空白用t代替<br />
# now cut out the last char 抓取第numofchar个字节<br />
rval=`echo -n "$1" | cut -b $numofchar`<br />
}<br />
<br />
chop()<br />
{<br />
# remove the last character in string and return it in $rval<br />
if [ -z "$1" ]; then<br />
# empty string<br />
rval=""<br />
return<br />
fi<br />
# wc puts some space behind the output this is why we need sed:<br />
numofchar=`echo -n "$1" | wc -c | sed 's/ //g' `<br />
if [ "$numofchar" = "1" ]; then<br />
# only one char in string<br />
rval=""<br />
return<br />
fi<br />
numofcharminus1=`expr $numofchar "-" 1`<br />
# now cut all but the last char:<br />
rval=`echo -n "$1" | cut -b -$numofcharminus1` <br />
#原来的 rval=`echo -n "$1" | cut -b 0-${numofcharminus1}`运行时出错.<br />
#原因是cut从1开始计数,应该是cut -b 1-${numofcharminus1}<br />
}<br />
<br />
while [ -n "$1" ]; do<br />
case $1 in<br />
-h) help;shift 1;; # function help is called<br />
--) shift;break;; # end of options<br />
-*) error "error: no such option $1. -h for help";;<br />
*) break;;<br />
esac<br />
done<br />
<br />
# The main program<br />
sum=0<br />
weight=1<br />
# one arg must be given:<br />
[ -z "$1" ] &amp;&amp; help<br />
binnum="$1"<br />
binnumorig="$1"<br />
<br />
while [ -n "$binnum" ]; do<br />
lastchar "$binnum"<br />
if [ "$rval" = "1" ]; then<br />
sum=`expr "$weight" "+" "$sum"` <br />
# $expr 10 + 10 20 expr提示是计算操作<br />
fi<br />
# remove the last position in $binnum<br />
chop "$binnum"<br />
binnum="$rval"<br />
weight=`expr "$weight" "*" 2`<br />
done<br />
<br />
echo "binary $binnumorig is decimal $sum"<br />
#<br />
</source><br />
<br />
该脚本使用的算法是利用十进制和二进制数权值 (1,2,4,8,16,..),比如二进制"10"可以这样转换成十进制: <br />
<br />
<source lang="bash"><br />
0 * 1 + 1 * 2 = 2<br />
</source><br />
<br />
为了得到单个的二进制数我们是用了lastchar 函数。该函数使用wc –c计算字符个数,然后使用cut命令取出末尾一个字符。Chop函数的功能则是移除最后一个字符。<br />
<br />
但是还记得前面怎么说的吗?进制转换哪需要这么麻烦:<br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
while read -p 'input a binary...' num; do<br />
if [[ $num == *[!01]* ]]; then<br />
echo "含有 0 1 之外的字符"<br />
fi<br />
echo "$((0x$num))" # 在 num 头上糊一个 0x 然后跑数学计算——就完事了!<br />
printf "%d\n" "0x$num" # printf 也可以凑热闹啊<br />
done<br />
</source><br />
<br />
如果你喜欢自己算的话,其实也可以从左到右来(反正数学计算不要有事没事玩 expr 啦):<br />
<br />
<source lang="bash">#!/bin/bash<br />
# 人人皆知的 Horner 规则<br />
value=0<br />
echo "写一堆 1 0 完了回车"<br />
while read -n 1 char; do<br />
case $char in<br />
(0|1) ;; # 好<br />
('') break;; # 没了<br />
(*) echo "你说啥?"; break;;<br />
esac<br />
((value *= 2))<br />
((value += char))<br />
done<br />
echo "$value"</source><br />
<br />
=== 文件循环移动 ===<br />
<br />
你可能有这样的需求并一直都这么做:将所有发出邮件保存到一个文件中。但是过了几个月之后,这个文件可能会变得很大以至于该文件的访问速度变慢;下面的脚本 rotatefile 可以解决这个问题。这个脚本可以重命名邮件保存文件(假设为outmail)为outmail.1,而原来的outmail.1就变成了 outmail.2 等等... <br />
<br />
<source lang="bash"><br />
#!/bin/bash<br />
# vim: set sw=4 ts=4 et:<br />
<br />
ver="0.1"<br />
help()<br />
{<br />
cat << HELP<br />
rotatefile -- rotate the file name<br />
USAGE: rotatefile [-h] filename<br />
OPTIONS: -h help text<br />
EXAMPLE: rotatefile out<br />
<br />
This will e.g rename out.2 to out.3, out.1 to out.2, out to out.1<br />
and create an empty out-file<br />
<br />
<br />
version $ver<br />
<br />
HELP<br />
<br />
exit 0<br />
}<br />
<br />
if [[ $1 == '-h' || $1 == '' ]]; then<br />
help<br />
fi<br />
<br />
filename=$1<br />
<br />
# 我们先找到最大的数字再说。<br />
max=0<br />
while [ -f "$filename.$((++max))" ]; do<br />
: # 什么都不用做,我们已经顺手用 ++max 自增了 max 了。<br />
done<br />
<br />
# 然后从最大的一路重命名下来。<br />
for ((i=max; i>0; i--)); do<br />
# 数字加个 1,好给前一个让位子。<br />
mv "$filename.$i" "$filename.$((i+1))"<br />
done<br />
<br />
# 最后我们点名要重命名的:<br />
if [ -f "$filename" ]; then<br />
mv "$filename" "$filename.1"<br />
fi<br />
<br />
# 重新创建一下。<br />
: > "$filename"<br />
<br />
</source>。<br />
<br />
== 脚本调试==<br />
<br />
最简单的调试方法当然是使用echo命令。你可以在任何怀疑出错的地方用echo打印变量值,这也是大部分shell程序员花费80%的时间用于调试的原因。Shell脚本的好处在于无需重新编译,而插入一个echo命令也不需要多少时间。<br />
<br />
shell也有一个真正的调试模式,如果脚本"strangescript"出错,可以使用如下命令进行调试:<br />
<br />
<source lang="bash"><br />
sh -x strangescript<br />
</source><br />
<br />
上述命令会执行该脚本,同时显示所有变量的值。<br />
<br />
shell还有一个不执行脚本只检查语法的模式,命令如下:<br />
<br />
<source lang="bash"><br />
sh -n your_script<br />
</source><br />
<br />
这个命令会返回所有语法错误。<br />
<br />
我们希望你现在已经可以开始编写自己的shell脚本了,尽情享受这份乐趣吧! :)<br />
<br />
<br />
[[Category:程序开发]]</div>96.47.232.233https://wiki.ubuntu.org.cn/index.php?title=%E8%AE%A8%E8%AE%BA:%E9%A6%96%E9%A1%B5/%E7%BB%8F%E5%85%B8%E7%89%88&diff=153793讨论:首页/经典版2016-06-11T23:52:26Z<p>96.47.232.233:以“''不要改动此页面。''''' == 粗体文字 == == == 大标题文字 == == == 大标题文字 == == 大标题文字 == == == '''File:<math>Example.jpg</math><now...”替换内容</p>
<hr />
<div>''不要改动此页面。'''''<br />
== 粗体文字 ==<br />
<br />
== <br />
== 大标题文字 ==<br />
<br />
== <br />
== 大标题文字 ==<br />
<br />
== 大标题文字 ==<br />
==<br />
==<br />
'''[[File:<math>Example.jpg</math><nowiki>--~~~~在此插入非格式文本</nowiki>]]</div>96.47.232.233https://wiki.ubuntu.org.cn/index.php?title=UbuntuWiki:UbuntuWeeklyNewsletter/Issue151&diff=153603UbuntuWiki:UbuntuWeeklyNewsletter/Issue1512016-06-03T02:56:13Z<p>96.47.232.233:dcscx</p>
<hr />
<div>{{From|https://wiki.ubuntu.com/UbuntuWeeklyNewsletter/Issue151}}<br />
{{Languages|UbuntuWiki:UbuntuWeeklyNewsletter/Issue151}}<br />
https://wiki.ubuntu.com/UbuntuWeeklyNewsletter/Issue151?action=AttachFile&do=get&target=newspaper-icon3.jpg<br />
Welcome to the Ubuntu Weekly Newsletter, Issue #151 for the week July 12th - July 18th, 2009. In this issue we cover: Ubuntu 8.04.3 released, Kubuntu Council, Kubuntu Wiki, Technical Board: Nominations, Karmic Translations are now Open, New Ubuntu Members, Ubuntu Zimbabwe, Empathy is now in Karmic, App``Armor now available in Karmic: Testing Needed, Ubuntu IRC Council News, OpenJDK 6 Certification for Ubuntu 9.04, Ubuntu Podcast Quickie #9, Ubuntu-based distro touted for power management, and much, much more!<br />
=== UWN Translations ===<br />
* Note to translators and our readers: We are trying a new way of linking to our translations pages. Please follow the link below for the information you need.<br />
https://wiki.ubuntu.com/UbuntuWeeklyNewsletter/Translations<br />
=== In This Issue ===<br />
* Ubuntu 8.04.3 released<br />
* Kubuntu Council<br />
* Kubuntu Wiki<br />
* Technical Board Nominations<br />
* Karmic Translations Now Open<br />
* New Ubuntu Members<br />
* Ubuntu Stats<br />
* Ubuntu Zimbabwe<br />
* Empathy is now in Karmic<br />
* App``Armor now available in Karmic: Testing needed<br />
* Ubuntu IRC Council News<br />
* OpenJDK 6 Certification for Ubuntu 9.04<br />
* In the Press & Blogosphere<br />
* Ubuntu Podcast Quickie #9<br />
* Ubuntu-based distro touted for power management<br />
* Upcoming Meetings & Events<br />
* Updates & Security<br />
=== General Community News ===<br />
==== Ubuntu 8.04.3 LTS Released ====<br />
Ubuntu 8.04.3 LTS has been released for the server, desktop, and alternate installation CDs for the i386 and amd64 architectures. Eighty updates have been integrated including security updates and corrections for other high-impact bugs, with a focus on maintaining stability and compatibility with Ubuntu 8.04 LTS. Downloads or CDs are available[1], as are the release notes[2]. A complete list of post-release updates is also available[3].<br />
<ol><li>http://www.ubuntu.com/getubuntu/download<br />
</li><li>http://www.ubuntu.com/getubuntu/releasenotes/804<br />
</li><li>https://wiki.ubuntu.com/HardyReleaseNotes/ChangeSummary/8.04.3</li></ol><br />
<br />
https://lists.ubuntu.com/archives/ubuntu-announce/2009-July/000124.html<br />
==== Kubuntu Council ====<br />
Following a vote of Kubuntu Members we have three new Kubuntu Council members. Harald Sitter (hsitter, apachelogger), Roderick Greening (rgreening) and Jonathan Thomas (Jon``The``Echidna) will join the team, Celeste and Lydia in being able to vote on new members and occasional other decisions.<br />
Thanks to Steve Stalcup for putting himself forward and making it a hard choice to vote on.<br />
https://lists.ubuntu.com/archives/kubuntu-devel/2009-July/002999.html<br />
==== Kubuntu Wiki ====<br />
wiki.kubuntu.org is the Ubuntu wiki themed for Kubuntu users. This week it received a shiny new theme thanks to Ryan Kavanagh, bringing it up to date with the latest website artwork.<br />
https://wiki.kubuntu.org/Kubuntu<br />
<a href=http://acheterviagrageneriquefrance.com/>achat viagra</a> acheter viagra <br />
<a href=http://viagraachetergenerique.net/>viagra pas cher</a> viagra <br />
<a href=http://comprarviagragenericoes.net/>comprar viagra</a> venta viagra espana<br />
<br />
==== Karmic Translations Are Now Open ====<br />
We are pleased to announce that Karmic is now open for translation.<br />
You can now go to:<br />
https://translations.launchpad.net/ubuntu/karmic/+translations<br />
to start translating Ubuntu Karmic into your language.<br />
This will be the first Ubuntu release to feature message sharing functionality, which will initially allow Jaunty and Karmic translations to be shared on a template and message basis. This will mean that you no longer need to translate the same strings in Jaunty and Karmic. Translate it in one, and your translation will automatically -read instantly- appear in the other.<br />
This feature will progressively be enabled for all Ubuntu releases. Stay tuned for the announcement and more information from the Launchpad Translations team.<br />
During the development cycle language pack updates will be released regularly twice per week (except for soft freezes for alpha or beta milestones). The generation of the first language pack has already started and it will be released in a few days - until then, the PPA language pack updates for Jaunty will be put on hold in order not to interfere with this process.<br />
You are encouraged to test those translations in Karmic and report any problems you might find, either in the ubuntu-translators list or against the ubuntu-translations project in Launchpad.<br />
* Ubuntu Translators List: https://lists.ubuntu.com/mailman/listinfo/ubuntu-translators<br />
* Ubuntu Translators Project: https://launchpad.net/ubuntu-translations<br />
Happy translating!<br />
https://lists.ubuntu.com/archives/ubuntu-translators/2009-July/002617.html<br />
==== New Ubuntu Members ====<br />
The approval results from the July 15th Americas Membership meeting are as follows:<br />
Steve Conklin: Steve works for Canonical as a Kernel engineer. Currently he is working on new hardware enablement and bringing netbooks running Ubuntu to market. He is also involved with the ubuntu-NGO team helping it get off the ground. His experience working with the Red Cross will come in handy with that work. Wiki: https://wiki.ubuntu.com/sconklin Launchpad: https://launchpad.net/~sconklin<br />
Amber Granger: Amber has had one of the most memorable first impressions with the Ubuntu community when you started with a bang with her blog, Just Me, Amber. The blog was a way for her to share her experiences with joining, and becoming a very important part of, the Ubuntu community. She is currently helping plan the Atlanta Linux Fest and also an Ubuntu User Conference in 2010. Wiki: https://wiki.ubuntu.com/AmberGraner Launchpad: https://launchpad.net/~akgraner<br />
Martin-Éric Racine: Martin-Éric has been involved with Free Software for a number of years now. He spends much of his time working to maintain a number of packages for Debian which are included in the Main repository of Ubuntu. Due to this, he also spends a large amount of time ensuring that patches in Ubuntu are correctly forwarded upstream. Wiki: https://wiki.ubuntu.com/MartinEricRacine Launchpad: https://launchpad.net/~q-funk<br />
Jimmy Harris: Jimmy is a very active member of the Ubuntu-Florida Local Community team where he not only plans and runs Bug Jams and Packaging Jams but he also DJs at the conferences using Ubuntu Studio and Mixx. He is also a mentor for the Ubuntu US Local Community team project for the state of Alaska, the largest state in the Union. Wiki: https://wiki.ubuntu.com/pak33m Launchpad: https://launchpad.net/~pak33m<br />
Please join me in welcoming these great new Ubuntu Members!<br />
=== Ubuntu Stats ===<br />
==== Bug Stats ====<br />
* Open (59023) +47 over last week<br />
* Critical (29) +3 over last week<br />
* Unconfirmed (27273) -271 over last week<br />
* Unassigned (50839) -1 over last week<br />
* All bugs ever reported (295943) +1673 over last week<br />
As always, the Bug Squad needs more help. If you want to get started, please see https://wiki.ubuntu.com/BugSquad<br />
==== Translation Stats Jaunty ====<br />
* Spanish (12797) -52 # over last week<br />
* French (39785) -366 # over last week<br />
* Brazilian Portuguese (49473) -612 # over last week<br />
* Swedish (54357) -2649 # over last week<br />
* English (United Kingdom) (55729) -84 # over last week<br />
Remaining strings to translate in Ubuntu 9.04 "Jaunty Jackalope," see more at: https://translations.launchpad.net/ubuntu/jaunty/<br />
==== Ubuntu Brainstorm Top 5 this week ====<br />
* Squeeze the maximum of a laptop battery - http://brainstorm.ubuntu.com/idea/20670/<br />
* Update Manager is not optimized for low speed Internet - http://brainstorm.ubuntu.com/idea/20696/<br />
* All gnome applications have completely different UIs - http://brainstorm.ubuntu.com/idea/20651/<br />
* ubuntu-restricted-extras is essential for many users - http://brainstorm.ubuntu.com/idea/20671/<br />
* Empathy logs should be in an "empathy" folder (like pidgin) in karmic - http://brainstorm.ubuntu.com/idea/20703/<br />
Ubuntu Brainstorm is a community site geared toward letting you add your ideas for Ubuntu. You can submit your own idea, or vote for or against another idea. http://brainstorm.ubuntu.com/<br />
=== LoCo News ===<br />
==== Ubuntu Zimbabwe ====<br />
The Ubuntu Zimbabwe Lo``Co Team is pleased to announce that it has been admitted as an Honorary Institutional Member of the Computer Society of Zimbabwe. (Membership No: 090025) It is our hope to work with the Computer Society of Zimbabwe in assisting with the technological development of the country (which has suffered a great deal as a result of the economic melt down) while promoting and using Ubuntu and open source solutions for the benefit of the country as a whole.<br />
https://lists.ubuntu.com/archives/ubuntu-news-team/2009-July/000642.html<br />
=== New in Karmic Koala ===<br />
==== Empathy is now in Karmic ====<br />
As of today, the seeds have been switched, and Empathy, the awesome Telepathy IM client with support for both audio and video chat, geo-location, Adium themes, and collaboration via Tubes, is now included in the Ubuntu 9.10 Karmic Koala daily LiveCDs. Let's get testing!<br />
http://blog.thesilentnumber.me/2009/07/empathy-is-now-in-karmic.html<br />
==== AppArmor now available in Karmic: Testing Needed ====<br />
After a lot of hard work by John Johansen and the Ubuntu kernel team, bug #375422 is well on its way to be fixed. More than just forward ported for Ubuntu, App``Armor has been reworked to use the updated kernel infrastructure for LSMs. As seen in #apparmor on Freenode a couple of days ago:<br />
* 11:24 < jjohansen> I am working to a point where I can try upstreaming again, base off of the security_path_XXX patches instead of the vfs patches<br />
* 11:24 < jjohansen> so the module is mostly self contained again<br />
These patches are in the latest 9.10 kernel, and help testing App``Armor in Karmic is needed. To get started, verify you have at least 2.6.31-3.19-generic:<br />
* $ cat /proc/version_signature<br />
* Ubuntu 2.6.31-3.19-generic<br />
App``Armor will be enabled by default for Karmic just like in previous Ubuntu releases, but it is off for now until a few kinks are worked out. To test it right away, you’ll need to reboot, adding ’security=apparmor’ to the kernel command line. Then fire up ‘aa-status’ to see if it is enabled. A fresh install of 9.10 as of today should look something like:<br />
* $ sudo aa-status<br />
* apparmor module is loaded.<br />
* 8 profiles are loaded.<br />
* 8 profiles are in enforce mode.<br />
* /usr/lib/connman/scripts/dhclient-script<br />
* /usr/share/gdm/guest-session/Xsession<br />
* /usr/sbin/tcpdump<br />
* /usr/lib/cups/backend/cups-pdf<br />
* /sbin/dhclient3<br />
* /usr/sbin/cupsd<br />
* /sbin/dhclient-script<br />
* /usr/lib/NetworkManager/nm-dhcp-client.action<br />
* 0 profiles are in complain mode.<br />
* 2 processes have profiles defined.<br />
* 2 processes are in enforce mode :<br />
* /sbin/dhclient3 (3271)<br />
* /usr/sbin/cupsd (2645)<br />
* 0 processes are in complain mode.<br />
* 0 processes are unconfined but have a profile defined.<br />
Please throw all your crazy profiles at it as well as testing the packages with existing profiles, then file bugs:<br />
* For the kernel, add your comments (positive and negative) to bug #375422<br />
* App``Armor tools bugs should be filed with ‘ubuntu-bug apparmor’<br />
* Profile bugs should be filed against the individual source package with ‘ubuntu-bug <source package name>’. See [[UbuntuWiki:DebuggingApparmor|DebuggingApparmor]] for details. https://wiki.ubuntu.com/DebuggingApparmor<br />
Thank you Ubuntu Kernel team and especially John for all the hard work.<br />
http://penguindroppings.wordpress.com/2009/07/15/apparmor-now-available-in-karmic-testing-needed/<br />
=== The Planet ===<br />
==== Jussi Schultink: Ubuntu IRC Council News ====<br />
Sometime ago Jussi was elected to the Ubuntu IRC council. This has been a big step for him, up from regular ubuntu operator and contributor, to a governance role. So now he feels it's time to start writing about what the IRC council is doing, and where and when things are happening.<br />
First up he’d like to mention the next IRCC meeting, coming up on 2 August, at 07:00 UTC, in #ubuntu-meeting. You can find the agenda for the meeting at https://wiki.ubuntu.com/IrcTeam/IrcCouncil/MeetingAgenda - if you have an agenda item, please feel free to add it there.<br />
Second, he'd like to mention the blueprint for a new bantracker and IRC operator helper features that Benjamin (Pici) has kindly popped up on launchpad- you can find it here: https://blueprints.edge.launchpad.net/bantrackertwo<br />
The IRCC would welcome as much community input for that as possible, so please, feel free to add suggestions and ideas to the mix.<br />
For those of you who done know us, the IRCC consists of the following people: jussi01 , Pici, Pricey, elky and nalioth.<br />
They look forward to seeing you all on Freenode/Ubuntu channels soon!<br />
http://jussi01.com/?p=63<br />
==== Nick Barcet: OpenJDK 6 Certification for Ubuntu 9.04 ====<br />
The Ubuntu Java development team is pleased to announce completed certification of OpenJDK 6 for Ubuntu 9.04, continuing Ubuntu's tradition of integrating the latest and greatest open source technologies into a high-quality, easy-to-use Linux distribution.<br />
After signing the Sun TCK agreement earlier this year, Java developers went to work with the certification process and received final certification from Sun in late May.<br />
This certification means that the OpenJDK 6 package included with Ubuntu 9.04 now passes the rigorous testing of the Java SE Test Compatibility Kit (TCK) and is compatible with the Java(TM) SE 6 platform on the amd64 (x86_64) and i386 (ix86) architectures.<br />
OpenJDK is a free and open source implementation of Sun's Java(TM) SE 6 platform. The Java TCK is a toolkit providing tools, tests, and documentation to help determine whether or not Java implementations meet compliance.<br />
https://lists.ubuntu.com/archives/ubuntu-devel-announce/2009-July/000587.html<br />
=== In The Press ===<br />
==== Canonical seeking desktop backgrounds for Ubuntu 9.10 ====<br />
The H-Online tells us that Kenneth Wimer of the Canonical Design Team has announced that the team is seeking high quality desktop backgrounds from "anyone and everyone" for the upcoming Ubuntu 9.10 "Karmic Koala" release. The team have created a Flickr photo group pool where users can submit or simply browse the proposed backgrounds. "Ubuntu would like to include a beautiful set of images for our users to choose from in our next release," said Wimer. More details about submission requirements can be found on the Background Guidelines Wiki and all images must be freely licensed under the Creative Commons CC-BY-SA license. The final version of Karmic Koala is scheduled to be released on the 29th of October. http://www.h-online.com/open/Canonical-seeking-desktop-backgrounds-for-Ubuntu-9-10--/news/113773<br />
==== Do We Need a New Distro for Everything? ====<br />
The Linux Loop says that they're not saying we shouldn’t have hundreds of distros competing for our hard drive; in fact they think that sort of competition is quite healthy, but do we really need a new distro for everything? Apparently Watt``OS thinks so. Now in its third beta, Watt``OS is an Ubuntu-based distro aimed at having low power consumption. "I’ve already got a distro for saving power, though. It’s called the off button." In the Linux Loop's opinion it just doesn’t make sense to offer a new distribution for a small improvement on an existing distribution. "I’m sure the power-saving work Watt``OS is doing is great and it is certainly needed, since Linux is rather lacking in power management, but it would be far better as an application, not its own distribution." http://www.linuxloop.com/2009/07/15/do-we-need-a-new-distro-for-everything/<br />
==== How Does Ubuntu 9.04 Measure Up to Mac OS X? ====<br />
Linux Magazine's Nathan Willis says that bucking the historical trend of comparing desktop Linux with Windows, Ubuntu founder Mark Shuttleworth recently told journalist Bruce Byfield that he was looking to Mac OS X as the operating system to beat for future Ubuntu releases — particularly in the areas of usability and user experience. Over all, Ubuntu 9.04 averages a B+ in this comparison against Mac OS X usability. The areas in which Ubuntu comes up short OS X in this review are considerably smaller in scope — an unpredictable “suspend” here, a not-very-helpful help system there, some missing or difficult to use applications. But that does not mean that filling in all of the small gaps is easy work; in fact it may get more difficult. As Shuttleworth admits, it is not going to be an overnight story. A part of that challenge, he adds, is figuring out how Canonical can inspire both consistency and innovation in the broader open source community. Ubuntu has also recently launched a project to fix niggling usability issues, called One Hundred Paper Cuts. The project aims to improve the user experience by identifying one hundred issues which negatively impact the user’s experience, but which can be fixed relatively easily. It’s certainly a move in the right direction! http://www.linux-mag.com/cache/7419/1.html<br />
==== Netbook Performance: Ubuntu vs. OpenSolaris ====<br />
Phoronix's Michael Larabel notes that in the past when Phoronix has published Open``Solaris vs. Linux Kernel benchmarks and similar articles looking at the performance of Sun's Open``Solaris up against popular Linux distributions, they have looked at the performance on high-end AMD workstations, but they have never compared the Open``Solaris and Linux performance on netbooks. In this article Phoronix has compiled results comparing Open``Solaris 2009.06 and Ubuntu 9.04 on the Dell Inspiron Mini 9 netbook. While Open``Solaris 2009.06 started out performing much better than Ubuntu 9.04, due to the GPU tests being run, this was due to the bugged Intel graphics stack found in the Jaunty Jackalope. Once both Ubuntu and Open``Solaris were running with similar packages after the fallout from the invasive Intel Linux graphics work, we should see nearly identical results. Beyond these graphics tests, however, as a whole Ubuntu 9.04 performed much better than Open``Solaris 2009.06 on this Atom-based Dell Inspiron Mini 9 netbook. http://www.phoronix.com/scan.php?page=article&item=intel_atom_os&num=1<br />
==== OpenSuSE, Ubuntu, Fedora, Mandriva Benchmarks ====<br />
Michael Larabel of Phoronix says with it being a while since he last compared many Linux distributions when it comes to their measurable desktop performance, he decided to run a new round of tests atop four of the most popular Linux distributions: OpenSuSE, Ubuntu, Fedora, and Mandriva. To see where these Linux distributions are at, Larabel used their latest development releases and then performed all package updates as of 2009-07-15. Well, nothing too conclusive can be derived from just the fifteen benchmarks they have shared today, especially with a few of the tests not containing results for all four distributions. However, for the trends that can be gathered, OpenSuSE and Ubuntu were generally the fastest. http://www.phoronix.com/scan.php?page=article&item=distro_four_way&num=1<br />
==== Ubuntu 8.04.3 LTS Released ====<br />
Phoronix's Michael Larabel says that for those of you still running Ubuntu 8.04 due to its Long-Term Support status rather than upgrading to Ubuntu 8.10 or Ubuntu 9.04, fire up your update manager as Ubuntu 8.04.3 LTS is now available. Ubuntu 8.04.3 LTS is the third maintenance update targeting the Hardy Heron and it includes security updates and fixes for high impact bugs. Approximately 80 updates have been incorporated into Ubuntu 8.04.3 LTS that address issues within the installer, desktop, server, and general areas. Details on this update are available via the Canonical release announcement. Ubuntu 8.04 LTS is supported on the desktop until April of 2011 while it will be supported on servers until April of 2013. The next Ubuntu release with an extended support status will be next year with Ubuntu 10.4 LTS. http://www.phoronix.com/scan.php?page=news_item&px=NzM4NQ<br />
==== Shuttleworth about GNOME 3.0 - What's good, what's missing, what needs work ====<br />
Andreas Proschofsky of der``Standard had a chance to conduct an interview with Mark Shuttleworth, and they had an opportunity to discuss many things about Ubuntu including the new GNOME 3.0. When asked if GNOME 3.0 would make it into the Ubuntu 10.04 LTS, Shuttleworth said, "The heart of this question is: How do you deal with the situation where a distro makes a long term release and upstreams are on a different schedule. I think it's worth asking the question: Is it valuable for upstreams to have a long term release made? And no-one disagrees that this would be valuable, but when are you going to do that? Until now there's been no overarching force to say you do it now or then. I think, what we are about to see is the emergence of sort of a greater structure in the cadence of releases in the open source ecosystem." http://derstandard.at/fs/1246541995003/Interview-Shuttleworth-about-GNOME-30---Whats-good-whats-missing-what-needs-work<br />
==== Ubuntu 9.04 Receives OpenJDK 6 Certification ====<br />
Marius Nestor of Softpedia reports that Canonical, through Matthias Klose, announced on July 11th, 2009 that the Ubuntu Java development team had completed the certification of the Open``JDK 6 platform for Ubuntu 9.04 (Jaunty Jackalope). This means that the Open``JDK 6 package included in Ubuntu 9.04 has passed the meticulous tests of the Java Standard Edition Test Compatibility Kit and that it is now fully compatible with the Java Standard Edition 6 platform, on both i386 and amd64 architectures. "The Ubuntu Java development team is pleased to announce completed certification of Open``JDK 6 for Ubuntu 9.04, continuing Ubuntu's tradition of integrating the latest and greatest open source technologies into a high-quality, easy-to-use Linux distribution. After signing the Sun TCK agreement earlier this year, Java developers went to work with the certification process and received final certification from Sun in late May," Matthias Klose said in the official announcement. http://news.softpedia.com/news/Ubuntu-9-04-Receives-OpenJDK-6-Certification-116630.shtml<br />
==== Ubuntu’s Karmic Koala Needs You! ====<br />
Rami Taibah of The Linuxologist tells us that the Canonical Design team is currently running a contest for beautiful desktop wallpapers for its upcoming Ubuntu Karmic Koala 9.10 scheduled to be released in October 2009. They have created a photo pool on Flickr where you can submit or just browse proposed backgrounds. "In our next release, the Karmic Koala (Ubuntu 9.10), we would like to include a set of high quality desktop backgrounds. In order to accomplish this we call on anyone and everyone to submit images which are freely licensed CC-BY-SA and follow the guidelines for inclusion." So what are you waiting for? Grab your SLR and launch your GIMP! http://linuxologist.com/eye-candy/ubuntus-karmic-koala-needs-you/<br />
=== In The Blogosphere ===<br />
==== Embracing the “Meta Release Cycle” ====<br />
In an interview with derstandard.at, Shuttleworth discussed ongoing efforts to coordinate Ubuntu releases more tightly with Debian’s development cycle, hoping that other distributions and upstream projects will follow suit. With the adoption of a “Meta Release Cycle,” he argued, the efforts of all free-software developers could be made more effective by allowing the latest versions of applications to travel downstream at the same speed. Some may see this move as an attempt by Ubuntu–which has long faced hostility from geeks who resent its success or focus on bringing normal people into the Linux fold–to domineer the Linux world. To a certain extent, this may be true. But a little benevolent domineering is exactly what the Linux community needs in order to move beyond the organizational mayhem that currently impedes its progress.<br />
http://www.workswithu.com/2009/07/14/embracing-the-meta-release-cycle/<br />
==== Mythbuntu and Mint Developers Pan Ubuntu for Strict Time-Release Policy ====<br />
In an article on Techradar which looked at the upcoming Karmic Koala release of Ubuntu, Clement Lefebvre, the developer of Linux Mint, a popular Ubuntu derivative, and Mario Limonciello, the maintainer of the Ubuntu-sanctioned Mythbuntu media center distribution both took aim at what they saw as the chief weakness of Ubuntu.<br />
"Of course," complained Lefebvre, "[focusing on consolidation instead of cutting-edge features] wouldn't make sense for Ubuntu unless we became an upstream component of their distribution. I'm really happy with what Ubuntu is doing, and if I were to change anything… it would be the commitment to a release schedule and the return of a 'release when ready' policy to guarantee a stronger level of quality against regressions."<br />
"I would prefer that the release cycles were not strictly six months," said Limonciello. "Over the last few releases there have been a variety of bugs that weren't deemed to 'hold up' the release and could just be fixed in a Stable Release Update. I'm of the opinion if you have a fix for the bug that you know works, you shouldn't put off the fix just to meet a deadline for releasing a CD. It's better to include the fix sooner and give a better experience to the user out of the box."<br />
* Techradar article: http://www.techradar.com/news/software/operating-systems/what-to-expect-from-the-next-version-of-ubuntu-614458<br />
http://blog.ibeentoubuntu.com/2009/07/mythbuntu-and-mint-developers-pans.html<br />
==== Ubuntu 9.10 Preview: Kernel Mode Setting ====<br />
Kernel mode setting will be enabled by default for Intel-based video cards on Ubuntu 9.10, set to be released in October. Christopher Tozzi recently played around with this new feature on a Karmic Koala live CD, and shares his results. Fast-user switching and access to the virtual console were quite zippy on his i810 video card running in the live environment. Kernel mode setting means the Linux kernel, instead of an X11 video driver, handles the task of configuring the graphics mode of the console. There’s no official word on when kernel mode setting will be enabled for video chipsets other than Intel, but Ubuntu developers are working on it for some nvidia and ATI devices. Don’t expect it in Karmic, though. Video available at the link.<br />
http://www.workswithu.com/2009/07/15/ubuntu-910-preview-kernel-mode-setting/<br />
=== In Other News ===<br />
==== Ubuntu Podcast Quickie #9 ====<br />
In this episode:<br />
* 8.04.03 coming 16 July<br />
* Ubuntu 6.06 desktop support ending<br />
* Ubuntu Free Culture Showcase deadline approaching<br />
* updates on Spread Ubuntu<br />
* Ubu``Con Central America<br />
* 100 Paper Cuts Round 2<br />
http://ubuntupodcast.net/2009/07/15/ubuntu-podcast-quickie-9/<br />
==== Ubuntu-based distro touted for power management ====<br />
Desktop Linux's Eric Brown reports that a group called Planet``Watt has released a Beta 3 version of a new lightweight, power-sipping distro based on Ubuntu. The low-power Watt``OS is built from scratch using the Ubuntu Minimal``CD and Ubuntu 9.04, and uses the lightweight LXDE environment and Open``Box. Watt``OS is not intended to be the "smallest or fastest," says the project FAQ. Instead, the group is looking to create a balance between speed and power consumption on the one hand and features on the other. Designed to run on both low-power and older systems, the distro should run "quite pleasant and quick" on any computer with at least 600MHz and 256MB of RAM. Eventually, the group plans to offer a set of "Watt``Panel" tools for users that will let them "tweak the power consumption and processor performance of their system in an easy point and click fashion." Watt``OS Beta 3 is available now, including a Live CD version. http://www.desktoplinux.com/news/NS3390383145.html<br />
=== Upcoming Meetings and Events ===<br />
==== Sunday, July 19, 2009 ====<br />
* None listed as of publication<br />
==== Monday, July 20, 2009 ====<br />
* None listed as of publication<br />
==== Tuesday, July 21, 2009 ====<br />
===== Ubuntu Learning Team Meeting =====<br />
* Start: 01:00 UTC<br />
* End: 02:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: Agenda: https://wiki.ubuntu.com/Learning/Agenda<br />
===== Community Council Meeting =====<br />
* Start: 10:00 UTC<br />
* End: 12:00 UTC<br />
* Location: #ubuntu-meeting<br />
* Agenda: https://wiki.ubuntu.com/CommunityCouncilAgenda<br />
===== Server Team Meeting =====<br />
* Start: 15:00 UTC<br />
* End: 16:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: https://wiki.ubuntu.com/ServerTeam/Meeting<br />
===== Desktop Team Meeting =====<br />
* Start: 16:30 UTC<br />
* End: 17:30 UTC<br />
* Location: IRC channel #ubuntu-desktop<br />
* Agenda: https://wiki.ubuntu.com/DesktopTeam/Meeting<br />
===== Kernel Team Meeting =====<br />
* Start: 17:00 UTC<br />
* End: 18:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: Not listed as of publication<br />
===== LoCo Council Meeting =====<br />
* Start: 19:00 UTC<br />
* End: 20:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: https://wiki.ubuntu.com/LoCoCouncilAgenda<br />
==== Wednesday, July 22, 2009 ====<br />
===== Foundation Team Meeting =====<br />
* Start: 16:00 UTC<br />
* End: 17:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: None listed as of publication<br />
===== QA Team Meeting =====<br />
* Start: 17:00 UTC<br />
* End: 18:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: https://wiki.ubuntu.com/QATeam/Meetings/<br />
==== Thursday, July 23, 2009 ====<br />
===== Karmic Alpha 3 =====<br />
===== Packaging Training: Packaging Perl Modules (gwolf and jawnsy) =====<br />
* Start: 12:00 UTC<br />
* End: 13:00 UTC<br />
* IRC channel #ubuntu-classroom<br />
* Agenda: https://wiki.ubuntu.com/Packaging/Training<br />
===== Ubuntu Java Meeting =====<br />
* Start: 14:00 UTC<br />
* End: 15:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: None listed as of publication<br />
===== MC Meeting =====<br />
* Start: 16:00 UTC<br />
* End: 17:00 UTC<br />
* Location: Not listed as of publication<br />
* Agenda: Not listed as of publication<br />
===== Ubuntu Mobile Team Meeting =====<br />
* Start: 21:00 UTC<br />
* End: 22:00 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: None listed as of publication<br />
==== Friday, July 24, 2009 ====<br />
===== Karmic Weekly Release Meeting =====<br />
* Start: 15:00 UTC<br />
* End: 16:30 UTC<br />
* Location: IRC channel #ubuntu-meeting<br />
* Agenda: http://wiki.ubuntu.com/ReleaseTeam/Meeting/2009-07-24<br />
==== Saturday, July 25, 2009 ====<br />
* None listed as of publication<br />
=== Updates and Security for 6.06, 8.04, 8.10 and 9.04 ===<br />
==== Security Updates ====<br />
* USN-800-1: irssi vulnerability - http://www.ubuntu.com/usn/USN-800-1<br />
* USN-799-1: D-Bus vulnerability - http://www.ubuntu.com/usn/USN-799-1<br />
* USN-801-1: tiff vulnerability - http://www.ubuntu.com/usn/USN-801-1<br />
* USN-802-1: Apache vulnerabilities - http://www.ubuntu.com/usn/USN-802-1<br />
* USN-803-1: dhcp vulnerability - http://www.ubuntu.com/usn/USN-803-1<br />
* USN-804-1: Pulse``Audio vulnerability - http://www.ubuntu.com/usn/USN-804-1<br />
==== Ubuntu 6.06 Updates ====<br />
* None Reported<br />
==== Ubuntu 8.04 Updates ====<br />
* xfce4-weather-plugin 0.6.2-1ubuntu1.2 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012263.html<br />
* sun-java5 1.5.0-19-0ubuntu0.8.04 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012264.html<br />
* symphony 1.3-1hardy2 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012265.html<br />
* nautilus 1:2.22.5.1-0ubuntu3 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012266.html<br />
* gvfs 0.2.5-0ubuntu8 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012267.html<br />
* freeradius 1.1.7-1ubuntu0.1 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012268.html<br />
* libxcb 1.1-1ubuntu1.1 - https://lists.ubuntu.com/archives/hardy-changes/2009-July/012269.html<br />
==== Ubuntu 8.10 Updates ====<br />
* sun-java5 1.5.0-19-0ubuntu0.8.10 - https://lists.ubuntu.com/archives/intrepid-changes/2009-July/009752.html<br />
* xfce4-weather-plugin 0.6.2-1ubuntu2.8.10.1 - https://lists.ubuntu.com/archives/intrepid-changes/2009-July/009753.html<br />
* symphony 1.3-1intrepid1 - https://lists.ubuntu.com/archives/intrepid-changes/2009-July/009754.html<br />
==== Ubuntu 9.04 Updates ====<br />
* linux-meta 2.6.28.14.18 - https://lists.ubuntu.com/archives/jaunty-changes/2009-July/009858.html<br />
* sun-java5 1.5.0-19-0ubuntu0.9.04 - https://lists.ubuntu.com/archives/jaunty-changes/2009-July/009859.html<br />
* xfce4-weather-plugin 0.6.2-1ubuntu2.9.04.1 - https://lists.ubuntu.com/archives/jaunty-changes/2009-July/009860.html<br />
* symphony 1.3-1jaunty1 - https://lists.ubuntu.com/archives/jaunty-changes/2009-July/009861.html<br />
* libvirt 0.6.1-0ubuntu5.1 - https://lists.ubuntu.com/archives/jaunty-changes/2009-July/009862.html<br />
=== Archives and RSS Feed ===<br />
You can always find older Ubuntu Weekly Newsletter issues at: https://wiki.ubuntu.com/UbuntuWeeklyNewsletter<br />
You can subscribe to the Ubuntu Weekly News via RSS at:<br />
http://fridge.ubuntu.com/uwn/feed<br />
=== Additional Ubuntu News ===<br />
As always you can find more news and announcements at:<br />
http://www.ubuntu.com/news<br />
and<br />
http://fridge.ubuntu.com/<br />
=== Conclusion ===<br />
Thank you for reading the Ubuntu Weekly Newsletter.<br />
See you next week!<br />
=== Credits ===<br />
The Ubuntu Weekly Newsletter is brought to you by:<br />
* John Crawford<br />
* Craig A. Eddy<br />
* Dave Bush<br />
* Sayak Banerjee<br />
* Your Name Here<br />
* Liraz Siri<br />
* And many others<br />
=== Glossary of Terms ===<br />
<ol><li>GPU - Graphics Processing Unit.<br />
</li><li>IRC - Internet Relay Chat.<br />
</li><li>LTS - Long Term Support. - Said of a release that will receive support for 3-years/5-years rather than the typical 18 months.<br />
</li><li>UTC - Coordinated Universal Time: UTC replaced GMT as the basis for the main reference time scale or civil time in various regions on January 1, 1972.<br />
</li><li>TCK - Technology Compatibility Kit.</li></ol><br />
<br />
Other acronyms can be found at https://wiki.ubuntu.com/UbuntuWeeklyNewsletter/glossary<br />
=== Ubuntu - Get Involved ===<br />
The Ubuntu community consists of individuals and teams, working on different aspects of the distribution, giving advice and technical support, and helping to promote Ubuntu to a wider audience. No contribution is too small, and anyone can help. It's your chance to get in on all the community fun associated with developing and promoting Ubuntu. http://www.ubuntu.com/community/participate<br />
=== Feedback ===<br />
This document is maintained by the Ubuntu Weekly News Team. If you have a story idea or suggestions for the Weekly Newsletter, join the Ubuntu News Team mailing list at https://lists.ubuntu.com/mailman/listinfo/Ubuntu-news-team and submit it. Ideas can also be added to the wiki at https://wiki.ubuntu.com/UbuntuWeeklyNewsletter/Ideas. If you'd like to contribute to a future issue of the Ubuntu Weekly Newsletter, please feel free to edit the appropriate wiki page. If you have any technical support questions, please send them to ubuntu-users@lists.ubuntu.com.<br />
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License<br />
https://wiki.ubuntu.com/UbuntuWeeklyNewsletter/Issue151?action=AttachFile&do=get&target=CCL.png<br />
[http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons License 3.0 BY SA]<br />
<br />
[[category:UbuntuWiki]]</div>96.47.232.233