文档章节

Writing a SlackBuild script

张俊伟0809
 张俊伟0809
发布于 2014/08/09 06:40
字数 719
阅读 18
收藏 0

Setting up build environment

   /home/slackware: The Slackware home directory which is owned by the "packger" group( which root and

user account are the members on the local system.

    /home/slackware/source: which places the whole slackware-source.

    /home/slackware/source/myslackware: This is where puts all packages.

   /home/slackware/source/myslackware/<package> In this directory we build our package

    /home/slackware/packages: where puts all built packages.


Getting started

    Beginning the process of building package with SlackBuild script.

    For this example, we will create a package of latex2html which made website home page.

    creating the directory named <build_environment>/latex2html, getting the most

recent source code release of latex2html and placing it in this directory.

    mkdir <build-environment>/latex2html

    cd <build-environment>/latex2html

 wget http://www.latex2html.org/~latex2ht/current/latex2html-2002-2-1.tar.gz

    touch latex2html.SlackBuild

    touch slack-desc

    Extracting the source code, because we need to look at configure script and late to determine what options we need to pass to it.

    Writing the SlackBuild script

        Initial Setup

            First specifying the interpreter

            #!/bin/sh -e  ('e' option tells shell exit on any error.

            # <you name> revision date yyyy/mm/dd

            # Set initial variables :

             CWD=$(pwd)

            if [ "$TMP" == " " ]; then

               TMP = /tmp

            fi

            # The version which appears in the application's filename

            VERSION = 2012-1-2

        # If the version conflicts with the Slackware package standard
        # The dash character ("-") is not allowed in the VERSION string
        # You can set the PKG_VERSION to something else than VERSION
        PKG_VERSION=2002.2.1 # the version which appears in the package name.

        ARCH=${ARCH:-i486} #The architecture on where your package will biuld
        
        #First digit is the build number. which specifies how many times it has been built,
        #Second string is the short form of authors name, typically three initilas: w
        BUILD=${BUILD: - 1_dvp}
        #The Application's name
        APP=latex2html
        #The installation directory of the package
        PKG=$TMP/package-$APP
        
        #Set SLKCFLAGS, if use old version gcc less than 3.4.x, needing "-mcpu" instead of "mtune"

          if [ "$ARCH" = "i486" ]; then

                SLKCFLAGS = "-02 -match=i486 -mtune=i686"

          elif [ "$ARCH = "x86_64" ]; then

                SLCKFLAGS = "-02 -fPIC"

           fi

        #Exract the source file

        #Deleting the leftover directories id there exists

        rm -fr  $PKG

        mkdir -p $TMP $PKG

        rm -fr $TMP/$APP-$VERSION

        #Change to the $TMP directory

        cd $TMP || exit 1

        #Extract the application source file in TMP

        tar -xzvf $CWD/$APP-$VERSION.tar.gz

        # Change to the Application directory

        cd $APP-$VERSION || exit 1

        chown -R root:root  .

        chmod u+x, go+r-w, a-s .

        #Set configure options

        #If your app  is writen in C++, you will also add line about CXXFLAGS

        CFLAGS="$SLCKFLAGS" \

        ./configure \

        --prefix=/usr \

        --sysconfdir=/etc \

        --localstatedir=/var \

        --with-perl=/usr/bin/perl \

        --enable-eps \

        --enable-gif \

        --enable-png \

        --build=$ARCH-slackware-linux \

        --host=$BUILD-slackware-linux \

        #Compile the source and exit when go wrong

        make || exit

        #Installing everything into the package directory, but exit if go wrong

        make install $PKG || exit

        

        # Install software documentation

        #Create the directory to stored the documentation

        mkdir -p $PKG/usr/doc/$APP-$VERSION

        #Copy documentation to docs directory and change the permission

        cp -a BUGS Changes FAQ INSTALL LICENSE MAINFEST README TODO docs/ $PKG/usr/doc/$APP-$VERSION

        find $PKG/usr/doc/$APP-$VERSION -type  f -exec chmod 644  {} \;

        #We can also place the *.SlackBuild script to the directory

        cat $CWD/$APP.SlackBuild > $PKG/usr/doc/$APP.SlackBuild

        #Create the ./install directory and place the slack-desc in this directory

        mkdir -p $PKG/install

        cp $CWD/slack-desc $PKG/install/slack-desc

        #And doinst.sh to the directory if it exits

        if [ -e doinst.sh.gz ]; then

            zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh

        fi

# Strip some libraries and binaries
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)

# Compress man pages if they exist
if [ -d $PKG/usr/man ]; then
 ( cd $PKG/usr/man
 find . -type f -exec gzip -9 {} \;
 for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
 )
fi

# Compress info pages if they exist (and remove the dir file)
if [ -d $PKG/usr/info ]; then
 gzip -9 $PKG/usr/info/*.info
 rm -f $PKG/usr/info/dir
fi

Build the Package

# Build the package
cd $PKG
/sbin/makepkg -l y -c n $TMP/$APP-$PKG_VERSION-$ARCH-$BUILD.tgz


© 著作权归作者所有

共有 人打赏支持
张俊伟0809
粉丝 0
博文 35
码字总数 6255
作品 0
深圳
程序员
私信 提问
JBoss Portlet Bridge 3.3.0.CR1 发布

JBoss Portlet Bridge 3.3.0.CR1 发布了,值得关注的改进有: Upgrade to RichFaces 4.3.4.Final for example portlets. Modify how we remove double encoded ampersand in script urls to......

红薯
2013/11/03
377
0
BASH SHELL SCRIPTING UTILITIES

A collection of handy utilities and functions to make bash scripting easier and more fun. I do a lot of bash shell scripting. Okay, not a lot, but from time to time I find it ha......

易野
2018/08/11
0
0
在浏览器里查看Nginx和PHP-FPM的运行状态

查看Nginx状态 location = /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } curl http://127.0.0.1/nginx_status http://nginx.org/en/docs/http/ngxhttpst......

eechen
2014/12/27
0
1
#!/bin/sh and #!/bin/bash

On Linux and other Unix-like systems you have a choice of multiple shells. The shell is responsible not only for drawing your little prompt, but interpreting your commands, espe......

Oscarfff
2016/03/20
18
0
cacti监控不到nginx的状态&cacti升级后监控不到硬盘及内存信息。

/www/netadmin.abc.com/www/htdocs/cacti/scripts/get_nginx_clients_status.pl http://abc.com/NginxStatus/ nginx_active:-1 nginx_reading:-1 nginx_writing:-1 nginx_waiting:-1 /www/ne......

披着狼皮的羊
2011/03/17
1K
3

没有更多内容

加载失败,请刷新页面

加载更多

开始看《Java学习笔记》

虽然书买了很久,但一直没看。这其中也写过一些Java程序,但都是基于IDE的帮助和对C#的理解来写的,感觉不踏实。 林信良的书写得蛮好的,能够帮助打好基础,看得出作者是比较用心的。 第1章概...

max佩恩
昨天
0
0
Redux 三大原则

1.单一数据源 在传统的MVC架构中,我们可以根据需要创建无数个Model,而Model之间可以互相监听、触发事件甚至循环或嵌套触发事件,这些在Redux中都是不被允许的。 因为在Redux的思想里,一个...

wenxingjun
昨天
0
0
跟我学Spring Cloud(Finchley版)-12-微服务容错三板斧

至此,我们已实现服务发现、负载均衡,同时,使用Feign也实现了良好的远程调用——我们的代码是可读、可维护的。理论上,我们现在已经能构建一个不错的分布式应用了,但微服务之间是通过网络...

周立_ITMuch
昨天
0
0
XML

学习目标  能够说出XML的作用  能够编写XML文档声明  能够编写符合语法的XML  能够通过DTD约束编写XML文档  能够通过Schema约束编写XML文档  能够通过Dom4j解析XML文档 第1章 xm...

stars永恒
昨天
0
0
RabbitMQ学习(2)

1. 生产者客户端 void basicPublish(String exchange, String routingKey, boolean mandatory, boolean immediate, BasicProperties props, byte[] body) 1. 在生产者客户端发送消息时,首先......

江左煤郎
昨天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部