PKG_NAME=latex2html
# 设置好编译环境
MY_SLACK_HOME=/home/slackware/source/myslackware
cd $MY_SLACK_HOME
SRC=${MY_SLACK_HOME}/source
PKG_OUT=${MY_SLACK_HOME}/packages
#取SRC
mkdir ${SRC}/$PKG_NAME
cd ${SRC}/$PKG_NAME
wget ~latex2ht/current/latex2html-2002-2-1.tar.gz # 05.02.2005
#创建需要的文件
touch latex2html.SlackBuild
touch slack-desc
#解压文件
tar -xzf latex2html-2002-2-1.tar.gz || exit 1
#建立 slack-desc
echo "# HOW TO EDIT THIS FILE:
echo "# The "handy ruler" below makes it easier to edit a package description. Line ">> slack-desc
echo "# up the first '|' above the ':' following the base package name, and the '|' on ">> slack-desc
echo "# the right side marks the last column you can put a character in. You must make">> slack-desc
echo "# exactly 11 lines for the formatting to be correct. It's also customary to ">> slack-desc
echo "# leave one space after the ':'. ">> slack-desc
echo " ">> slack-desc
echo " |-----handy-ruler------------------------------------------------------| ">> slack-desc
echo "$PKG_NAME: Summary of application name and function (one line only) ">> slack-desc
echo "$PKG_NAME: ">> slack-desc
echo "$PKG_NAME: Description of application - this description should be fairly ">> slack-desc
echo "$PKG_NAME: in-depth; in other words, make it clear what the package does (and ">> slack-desc
echo "$PKG_NAME: maybe include relevant links and/or instructions if there's room), ">> slack-desc
echo "$PKG_NAME: but don't get too verbose. ">> slack-desc
echo "$PKG_NAME: This file can have a maximum of eleven (11) lines of text preceded by ">> slack-desc
echo "$PKG_NAME: the "appname: " designation. ">> slack-desc
echo "$PKG_NAME: ">> slack-desc
echo "$PKG_NAME: It's a good idea to include a link to the application's homepage too. ">> slack-desc
echo "$PKG_NAME: ">> slack-desc
#下面开始时SlackBuild 文件内容
#!/bin/sh
#作者 revision date yyyy/mm/dd
#设置初始化变量
CWD=`pwd`
if [ "$TMP" = "" ]; then
TMP=/tmp
fi
#有些人喜欢在 /tmp 下建立一个目录来开始编译
# The version which appears in the application's filename
VERSION=2002-2-1
# 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 which you want to build your package
# First digit is the build number, which specifies how many times it has been built.
# Second string is the short form of the authors name, typical three initials:w
#第一个数字是表示编译了多少次,第二个号码是发行者名字缩写,第三个字母一般为w?
BUILD=${BUILD:-1_rlw}
# The application's name
# 应用程序名字
APP=latex2html
# The installation directory of the package (where its actual directory
# structure will be created)
# 包的正确安装目录结构放哪里
PKG=$TMP/package-$APP
#SLKCFLAGS (一般用于 CFLAGS 和 CXXFLAGS)编译的参数设置,如果是gc 3.4.x的话,用-mcpu 代替 -mtune
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIR=/usr/lib64
fi
#解压源码
# Delete the leftover directories if they exist (due to a previous build)
# and (re)create the packaging directory
rm -rf $PKG
mkdir -p $TMP $PKG
rm -rf $TMP/$APP-$VERSION
# Change to the TMP directory
cd $TMP || exit 1
# Extract the application source in TMP
# Note: if your application comes as a tar.bz2, you need tar -jxvf
tar -zxvf $CWD/$APP-$VERSION.tar.gz || exit 1
# Change to the application source directory
cd $APP-$VERSION || exit 1
# Change ownership and permissions if necessary
# This may not be needed in some source tarballs, but it never hurts
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
#config and make
# Set configure options
# If your app is written in C++, you'll also need to add a line for CXXFLAGS
CFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--with-perl=/usr/bin/perl \
--enable-eps \
--enable-gif \
--enable-png \
--build=$ARCH-slackware-linux \
--host=$ARCH-slackware-linux
# grep DESTDIR Makefile* 看看是否支持 DESTDIR 参数 如果不支持则
# make install的时候使用 make prefix=$PKG/usr install
#一般测试时使用普通用户运行下列命令,防止不可挽回的错误
# compile the source, but exit if anything goes wrong
make || exit
# Install everything into the package directory, but exit if anything goes wrong
make install DESTDIR=$PKG || exit
#或者
# grep -i '^prefix \?=' Makefile{,.in} 查看是否支持 make的时候增加 prefix参数,如果是
# make prefix=$PKG/usr install
#制作文档目录
# Create a directory for documentation
mkdir -p $PKG/usr/doc/$APP-$VERSION
# Copy documentation to the docs directory and fix permissions
cp -a BUGS Changes FAQ INSTALL LICENSE MANIFEST README TODO docs/ $PKG/usr/doc/$APP-$VERSION
find $PKG/usr/doc/$APP-$VERSION -type f -exec chmod 644 {} \;
#拷贝一份我们的SlackBuild到此目录
cat $CWD/$APP.SlackBuild > $PKG/usr/doc/$APP-$VERSION/$APP.SlackBuild
#收尾工作
# Create the ./install directory and copy the slack-desc into it
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
#如果 doinst.sh存在,则添加到包内
# Add doinst.sh to package (if it exists)
if [ -e $CWD/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
#制作pkg安装包
# Build the package
cd $PKG
/sbin/makepkg -l y -c n $TMP/$APP-$PKG_VERSION-$ARCH-$BUILD.tgz
阅读(2041) | 评论(0) | 转发(0) |