文档章节

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
342
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......

易野
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
Xcode Server + Slack = Rockstar Combo for iOS CI/CD

Xcode Server is a Continuous Integration service provided by Apple to analyze, build, test, and archive iOS apps. Xcode Server has been recently inbuilt with Xcode 9, which made......

Shashikant Jagtap
2017/12/12
0
0

没有更多内容

加载失败,请刷新页面

加载更多

如何处理JavaScript 中的货币值?

 金钱无处不在。   无论在银行应用程序、电子商务网站还是证券交易所平台,我们每天都在与金钱互动。我们也越来越依赖技术来处理问题。   然而,关于如何以编程处理货币价值尚无共识。虽...

数据星河
24分钟前
3
0
并发中的volatile

1. 概述 由于线程有本地内存的存在, 一个线程修改的共享变量不会及时的刷新到主内存中, 使得另一个线程读取共享变量时读取到的仍旧是旧值, 就导致了内存可见性问题. 现在volatile就可以解决这...

Ala6
25分钟前
7
0
三大特性之---封装

封装从字面上来理解就是包装的意思,专业点就是信息隐藏,是指利用抽象数据类型将数据和基于数据的操作封装在一起,使其构成一个不可分割的独立实体,数据被保护在抽象数据类型的内部,尽可能...

architect刘源源
28分钟前
2
0
设计模式 之 策略模式

设计模式 之 策略模式 定义 提供几个算法策略,选择其中一个策略去执行。 优点 由于将算法封装成单独的策略,策略可以灵活切换。 扩展性好,符合开闭原则。 缺点 策略多,类也会变多 策略类需...

GMarshal
29分钟前
3
0
HBase集群监控的那些事儿

为什么需要监控? 为了保证系统的稳定性,可靠性,可运维性。 掌控集群的核心性能指标,了解集群的性能表现; 集群出现问题时及时报警,便于运维同学及时修复问题; 集群重要指标值异常时进行...

微笑向暖wx
29分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部