文档章节

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

没有更多内容

加载失败,请刷新页面

加载更多

区块链10年了,还未落地,它失败了吗?

导读 几乎每个人,甚至是对通证持怀疑态度的人,都对区块链的技术有积极的看法,因为它有可能改变世界。然而,区块链技术问世已经10年了,我们仍然没有真正的用上区块链技术。 几乎每个人,甚...

问题终结者
19分钟前
0
0
20180921 su与sudo命令、限制root用户通过ssh远程登录

su 命令 用户切换。 su # 切换到root用户su username # 切换到username用户# su 后面加-时,会初始化当前用户的各种环境su - username # 指定用户执行某些命令 su - -c "touch /tm...

野雪球
33分钟前
1
0
Windows 下双 Python 开发环境配置

Windows 下双 Python 开发环境配置作者:老农民(刘启华)QQ: 46715422Email: 46715422@qq.com微信: 46715422 本人曾经在 Windows 下被两个版本环境折腾够呛,现在总结两个 Python...

新疆老农民
昨天
2
0
CentOS7全局安装composer

1. 下载composer-setup.php到当前目录 php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" 2. 安装 php composer-setup.php 3. 将composer设置成全局 mv c......

月夜中徘徊
昨天
3
0
20180920上课截图

小丑鱼00
昨天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部