Commit f43499ee authored by mara's avatar mara

added support for building packages from the "extra" section

parent d441039a
#!/bin/bash
_CWD=$(pwd)
BCWD=$(pwd)
THREADS=$(grep -c 'processor' /proc/cpuinfo)
_BUILD="${_CWD}/slarm64-current/source"
_TXZ="${_CWD}/slarm64-current/slarm64"
_SOURCE="${_CWD}/slackware64-current/source"
_TMP="/tmp"
_WORK_DIR="work"
DISTR="slarm64"
SLACKWARE_PATH="${BCWD}/slackware64-current"
SLARM64_PATH="${BCWD}/slarm64-current"
PREFIX_SOURCE=${PREFIX_SOURCE:-"source"}
BTMP="/tmp"
WORK_DIR="work"
environment() {
[[ -z "$1" ]] && return 1
local TYPE="$1"
local PACKAGE="$2"
export LANG=C
export CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CPPFLAGS="-D_FORTIFYSLACKWARE_SOURCE_PATH2"
export CFLAGS="-O2 -pipe -fstack-protector-strong -fno-plt"
export CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-plt"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
if [[ ${TYPE} == "extra" ]]; then
export SLACKWARE_SOURCE_PATH="${SLACKWARE_PATH}/${TYPE}/${PREFIX_SOURCE}"
# export PACKAGES_PATH="${SLARM64_PATH}/${TYPE}/${PACKAGE}"
export PACKAGES_PATH="${SLARM64_PATH}"
export SLARM64_SOURCE_PATH="${SLARM64_PATH}/${TYPE}/${PREFIX_SOURCE}"
else
export SLACKWARE_SOURCE_PATH="${SLACKWARE_PATH}/${PREFIX_SOURCE}"
export PACKAGES_PATH="${SLARM64_PATH}/${DISTR}"
export SLARM64_SOURCE_PATH="${SLARM64_PATH}/${PREFIX_SOURCE}"
fi
}
remove_work_dir() {
[[ ! -z "$1" ]] && rm -rf "${_BUILD}/$1/${_WORK_DIR}"
[[ ! -z "$1" ]] && rm -rf "${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}"
}
prepare_work_dir() {
[[ -z "$1" ]] && return 1
[[ ! -d "${_BUILD}/$1/${_WORK_DIR}" ]] && mkdir "${_BUILD}/$1/${_WORK_DIR}"
[[ ! -d "${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}" ]] && mkdir "${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}"
# if new packages copy all
if [[ -e ${_BUILD}/$1/.new ]]; then
pushd ${_BUILD}/$1/ 2>&1>/dev/null
cp -a $(ls | grep -vP '^work$') ${_BUILD}/$1/${_WORK_DIR}/
if [[ -e ${SLARM64_SOURCE_PATH}/$1/.new ]]; then
pushd ${SLARM64_SOURCE_PATH}/$1/ 2>&1>/dev/null
cp -a $(ls | grep -vP '^work$') ${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}/
popd 2>&1>/dev/null
return 1
fi
for f in $(ls "${_SOURCE}/$1/");do
for f in $(ls "${SLACKWARE_SOURCE_PATH}/$1/");do
if [[ ! -L $f ]];then
cp -a "${_SOURCE}/$1/$f" ${_BUILD}/$1/${_WORK_DIR}/$(basename $f)
cp -a "${SLACKWARE_SOURCE_PATH}/$1/$f" ${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}/$(basename $f)
else
ln -s "${_SOURCE}/$1/$f" "${_BUILD}/$1/${_WORK_DIR}/$(basename $f)"
ln -s "${SLACKWARE_SOURCE_PATH}/$1/$f" "${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}/$(basename $f)"
fi
done
[[ $(ls ${_BUILD}/$1/ | grep .xz) ]] && cp -a ${_BUILD}/$1/*.xz \
${_BUILD}/$1/${_WORK_DIR}/
[[ $(ls ${SLARM64_SOURCE_PATH}/$1/ | grep .xz) ]] && cp -a ${SLARM64_SOURCE_PATH}/$1/*.xz \
${SLARM64_SOURCE_PATH}/$1/${WORK_DIR}/
}
fix_default() {
for pf in $(find ${_WORK_DIR}/ -maxdepth 1 -type f | grep .SlackBuild);do
for pf in $(find ${WORK_DIR}/ -maxdepth 1 -type f | grep .SlackBuild);do
pf=$(basename "$pf")
echo "$pf"
sed -n '/^if \[ \"$ARCH\" = \"\(i.86\)\" \]/{:a;N;/fi$/!ba;N;s/.*\n/case \"\$ARCH\" in\
......@@ -62,7 +78,7 @@ fix_default() {
\*\) SLKCFLAGS=\"-O2\"\
LIBDIRSUFFIX=\"\"\
;;\
esac\n/};p' -i "${_WORK_DIR}/${pf}"
esac\n/};p' -i "${WORK_DIR}/${pf}"
done
}
......@@ -80,7 +96,7 @@ patching_files() {
for pf in ${PATCH_FILES};do
pf=$(basename "$pf")
[[ -z "$pf" ]] && continue
pushd ${_WORK_DIR} 2>&1>/dev/null
pushd ${WORK_DIR} 2>&1>/dev/null
[[ ! $(patch -p1 --batch --dry-run -N -i ../${pf}.patch | grep previously) ]] && ( patch -p1 --verbose -i "../${pf}.patch" || return 1 )
popd 2>&1>/dev/null
count=$(($count+1))
......@@ -90,15 +106,15 @@ patching_files() {
move_pkg() {
[[ -z "$1" ]] && exit 1
[[ ! -d "${_TXZ}/$1" ]] && ( mkdir -p "${_TXZ}/$1" || return 1 )
if [[ -e "${_TXZ}/$1" ]]; then
for pkg in $(ls ${_TMP}/$2-*.t?z); do
[[ ! -d "${PACKAGES_PATH}/$1" ]] && ( mkdir -p "${PACKAGES_PATH}/$1" || return 1 )
if [[ -e "${PACKAGES_PATH}/$1" ]]; then
for pkg in $(ls ${BTMP}/$2-*.t?z); do
if [[ ${pkg} =~ "-solibs-" ]];then
local SERIES="a"
#[[ ${pkg} =~ "seamonkey-solibs-" ]] && SERIES="l"
mv ${pkg} "${_TXZ}/${SERIES}/"
mv ${pkg} "${PACKAGES_PATH}/${SERIES}/"
else
mv ${pkg} "${_TXZ}/$1/"
mv ${pkg} "${PACKAGES_PATH}/$1/"
fi
done
fi
......@@ -109,7 +125,7 @@ move_pkg() {
#----------------------------
read_packages() {
local PKG
PKG=( $(cat $_CWD/build_packages.conf | grep -v "^#") )
PKG=( $(cat $BCWD/build_packages.conf | grep -v "^#") )
eval "$1=\${PKG[*]}"
}
......@@ -120,59 +136,66 @@ build() {
for _PKG in ${PACKAGES};do
if [[ ! $(echo "${_PKG}" | grep "^#") ]];then
ERROR=0
# set global environment
environment
# echo "${_PKG}"
t=$(echo ${_PKG} | cut -d '/' -f1)
p=$(echo ${_PKG} | cut -d '/' -f2)
# set global environment
environment "$t" "$p"
# build extra series
[[ ${t} == "extra" ]] && _PKG=${_PKG/$t\///}
# build kde series
if [[ $t == kde && -e ${_BUILD}/$t/.rules ]]; then
source ${_BUILD}/$t/.rules
if [[ $t == kde && -e ${SLARM64_SOURCE_PATH}/$t/.rules ]]; then
source ${SLARM64_SOURCE_PATH}/$t/.rules
continue
fi
# build x11 series
if [[ $t == x ]]; then
X11_PKG_PATH=$(find ${_BUILD}/$t/ -type f -name "${p}-*.?z")
X11_PKG_PATH=$(find ${SLARM64_SOURCE_PATH}/$t/ -type f -name "${p}-*.?z")
X11_MODULE=$(echo ${X11_PKG_PATH} | rev | cut -d '/' -f2 | rev)
if [[ ! -z $X11_MODULE && ${X11_PKG_PATH} =~ '/x11/' ]]; then
x11_root="x11"
source ${_BUILD}/$t/$x11_root/.rules
source ${SLARM64_SOURCE_PATH}/$t/$x11_root/.rules
unset X11_PKG_PATH X11_MODULE
continue
fi
fi
[[ ! -d ${_BUILD}/${_PKG} ]] && ( mkdir -p ${_BUILD}/${_PKG} || return 1 )
[[ -e ${_BUILD}/${_PKG}/.ignore ]] && continue
[[ ! -d ${SLARM64_SOURCE_PATH}/${_PKG} ]] && ( mkdir -p ${SLARM64_SOURCE_PATH}/${_PKG} || return 1 )
[[ -e ${SLARM64_SOURCE_PATH}/${_PKG}/.ignore ]] && continue
remove_work_dir "${_PKG}"
prepare_work_dir "${_PKG}"
pushd ${_BUILD}/${_PKG} 2>&1>/dev/null
pushd ${SLARM64_SOURCE_PATH}/${_PKG} 2>&1>/dev/null
PKG_SOURCE=$(echo ${_WORK_DIR}/${p}-*.tar.?z)
PKG_SOURCE=$(echo ${WORK_DIR}/${p}-*.tar.?z)
PKG_VERSION=$(echo $PKG_SOURCE | rev | cut -f 3- -d . | cut -f 1 -d - | rev)
[[ -e ${_BUILD}/${_PKG}/.rules ]] && source ${_BUILD}/${_PKG}/.rules
#echo $PKG_SOURCE >> ${_CWD}/log
#echo ${PKG_VERSION} >> ${_CWD}/log
[[ -e ${SLARM64_SOURCE_PATH}/${_PKG}/.rules ]] && source ${SLARM64_SOURCE_PATH}/${_PKG}/.rules
#echo $PKG_SOURCE >> ${BCWD}/log
#echo ${PKG_VERSION} >> ${BCWD}/log
#exit
#continue
patching_files STATUS
[[ $STATUS == 1 ]] && fix_default
pushd ${_WORK_DIR} 2>&1>/dev/null
pushd ${WORK_DIR} 2>&1>/dev/null
./${p}.SlackBuild 2>&1 | tee ${p}.build.log
[[ ${PIPESTATUS[0]} == 1 ]] && ERROR=1
[[ ${ERROR} == 1 ]] && mv ${p}.build.log ${p}.build.log.1
[[ ${ERROR} == 1 ]] && fix_global ${p}
[[ ${ERROR} == 1 ]] && ./${p}.SlackBuild 2>&1 | tee ${p}.build.log
if [[ ${PIPESTATUS[0]} == 1 && ${ERROR} == 1 ]]; then
echo "${_PKG}" 2>&1 >> ${_CWD}/build_error.log
[[ ${t} == "extra" ]] && _PKG="${t}${_PKG}"
echo "${_PKG}" 2>&1 >> ${BCWD}/build_error.log
continue
fi
popd 2>&1>/dev/null
[[ ${t} == "extra" ]] && t="${t}/${p}"
move_pkg ${t} ${p}
upgradepkg --install-new --reinstall ${_TXZ}/${t}/${p}-*.txz
upgradepkg --install-new --reinstall ${PACKAGES_PATH}/${t}/${p}-*.txz
popd 2>&1>/dev/null
fi
done
......
#----------------------------------
# sample list of package packages
#
# extra/tigervnc
# extra/fltk
#
# d/python3
# ap/vim
# xap/vim-gvim
#
#---------------------------------
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment