74 |
|
|
75 |
build_postinstall() |
build_postinstall() |
76 |
{ |
{ |
77 |
|
local m_mtime |
78 |
|
local m_md5sum |
79 |
|
local filelist |
80 |
|
local item |
81 |
|
local check_srcdir |
82 |
|
local filetype |
83 |
|
local fileposix |
84 |
|
local fileowner |
85 |
|
local filegroup |
86 |
|
local lnkdest |
87 |
|
local filedir |
88 |
|
local char_major |
89 |
|
local char_minor |
90 |
|
|
91 |
echo -e "${COLBLUE}===${COLGREEN} fetching files for package '${PKGNAME}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} fetching files for package '${PKGNAME}' ...${COLDEFAULT}" |
92 |
|
|
93 |
# md5sums will only be generated for files: $M_MD5SUM |
# md5sums will only be generated for files: $m_md5sum |
94 |
|
|
95 |
# sets mtime to same value of the $BINDIR: $M_MTIME |
# sets mtime to same value of the $BINDIR: $m_mtime |
96 |
# only needed for files and symlinks |
# only needed for files and symlinks |
97 |
M_MTIME=$(stat -c %Y ${BINDIR}) |
m_mtime=$(stat -c %Y ${BINDIR}) |
98 |
|
|
99 |
# install mtime to package (needed for later checks) |
# install mtime to package (needed for later checks) |
100 |
echo "${M_MTIME}" > ${BUILDDIR}/${PKGNAME}/.mtime |
echo "${m_mtime}" > ${BUILDDIR}/${PKGNAME}/.mtime |
101 |
|
|
102 |
# !! we use § as field seperator !! |
# !! we use § as field seperator !! |
103 |
# doing so prevent us to get errors by filenames with spaces |
# doing so prevent us to get errors by filenames with spaces |
104 |
BUILD_TODELFILES=$(find ${SEARCHDIRS} -printf %p§) |
filelist=$(find ${SEARCHDIRS} -printf %p§) |
105 |
|
|
106 |
# sets fieldseperator to "§" instead of " " |
# sets fieldseperator to "§" instead of " " |
107 |
IFS=§ |
IFS=§ |
108 |
|
|
109 |
for I in $BUILD_TODELFILES |
for item in ${filelist} |
110 |
do |
do |
111 |
CHECK_SRCDIR="$(echo ${I#${SEARCHDIRS}*}|grep $BUILDDIR)" |
check_srcdir="$(echo ${item#${SEARCHDIRS}*}|grep ${BUILDDIR})" |
112 |
|
|
113 |
if [ -z "$CHECK_SRCDIR" ] |
if [[ -z ${check_srcdir} ]] |
114 |
then |
then |
115 |
FILETYPE="$(stat -c %F $I)" |
filetype="$(stat -c %F ${item})" |
116 |
FILEPOSIX="$(stat -c %a $I)" |
fileposix="$(stat -c %a ${item})" |
117 |
FILEOWNER="$(stat -c %U $I)" |
fileowner="$(stat -c %U ${item})" |
118 |
FILEGROUP="$(stat -c %G $I)" |
filegroup="$(stat -c %G ${item})" |
119 |
|
|
120 |
[[ ${FILEOWNER} = UNKNOWN ]] && FILEOWNER="root" |
[[ ${fileowner} = UNKNOWN ]] && fileowner="root" |
121 |
[[ ${FILEGROUP} = UNKNOWN ]] && FILEGROUP="root" |
[[ ${filegroup} = UNKNOWN ]] && filegroup="root" |
122 |
|
|
123 |
case "${FILETYPE}" in |
case "${filetype}" in |
124 |
"directory") |
"directory") |
125 |
if [[ $I != ${SEARCHDIRS} ]] |
if [[ ${item} != ${SEARCHDIRS} ]] |
126 |
then |
then |
127 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.dirs |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.dirs |
128 |
fi |
fi |
129 |
;; |
;; |
130 |
|
|
131 |
"symbolic link") |
"symbolic link") |
132 |
LNKDEST="$(readlink $I)" |
lnkdest="$(readlink ${item})" |
133 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${LNKDEST#${SEARCHDIRS}*}§${M_MTIME}" >> ${BUILDDIR}/${PKGNAME}/.symlinks |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${lnkdest#${SEARCHDIRS}*}§${m_mtime}" >> ${BUILDDIR}/${PKGNAME}/.symlinks |
134 |
;; |
;; |
|
|
|
135 |
|
|
136 |
"regular empty file") |
"regular empty file") |
137 |
FILEDIR="$(dirname $I)" |
filedir="$(dirname ${item})" |
138 |
FILEDIR="${FILEDIR#${SEARCHDIRS}*}" |
filedir="${filedir#${SEARCHDIRS}*}" |
139 |
M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)" |
m_md5sum="$(md5sum ${item}|cut -d' ' -f1)" |
140 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}§${m_mtime}§${m_md5sum}" >> ${BUILDDIR}/${PKGNAME}/.files |
141 |
install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
install -d ${BUILDDIR}/${PKGNAME}/binfiles/${filedir} |
142 |
cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
cp ${item} ${BUILDDIR}/${PKGNAME}/binfiles/${filedir} |
143 |
;; |
;; |
144 |
|
|
145 |
"regular file" ) |
"regular file" ) |
146 |
FILEDIR="$(dirname $I)" |
filedir="$(dirname ${item})" |
147 |
FILEDIR="${FILEDIR#${SEARCHDIRS}*}" |
filedir="${filedir#${SEARCHDIRS}*}" |
148 |
M_MD5SUM="$(md5sum ${I}|cut -d' ' -f1)" |
m_md5sum="$(md5sum ${item}|cut -d' ' -f1)" |
149 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}§${M_MTIME}§${M_MD5SUM}" >> ${BUILDDIR}/${PKGNAME}/.files |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}§${m_time}§${m_md5sum}" >> ${BUILDDIR}/${PKGNAME}/.files |
150 |
install -d ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
install -d ${BUILDDIR}/${PKGNAME}/binfiles/${filedir} |
151 |
cp ${I} ${BUILDDIR}/${PKGNAME}/binfiles/${FILEDIR} |
cp ${item} ${BUILDDIR}/${PKGNAME}/binfiles/${filedir} |
152 |
;; |
;; |
153 |
|
|
154 |
"block special file") |
"block special file") |
155 |
# convert hex2dec |
# convert hex2dec |
156 |
# printf '%d' 0x12 -> 18 |
# printf '%d' 0x12 -> 18 |
157 |
local CHAR_MAJOR="$(printf 0x$(stat -c %t $I))" |
char_major="$(printf 0x$(stat -c %t ${item}))" |
158 |
local CHAR_MINOR="$(printf 0x$(stat -c %T $I))" |
char_minor="$(printf 0x$(stat -c %T ${item}))" |
159 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEPOSIX}§${CHAR_MAJOR}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.pipes |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${char_major}§${char_minor}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.pipes |
160 |
;; |
;; |
161 |
|
|
162 |
"character special file") |
"character special file") |
163 |
# convert hex2dec |
# convert hex2dec |
164 |
# printf '%d' 0x12 -> 18 |
# printf '%d' 0x12 -> 18 |
165 |
local CHAR_MAJOR="$(printf 0x$(stat -c %t $I))" |
char_major="$(printf 0x$(stat -c %t ${item}))" |
166 |
local CHAR_MINOR="$(printf 0x$(stat -c %T $I))" |
char_minor="$(printf 0x$(stat -c %T ${item}))" |
167 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${CHAR_MAJOR}§${CHAR_MINOR}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.char |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${char_major}§${char_minor}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.char |
168 |
;; |
;; |
169 |
|
|
170 |
"fifo") |
"fifo") |
171 |
echo "${I#${SEARCHDIRS}*}§${FILEPOSIX}§${FILEOWNER}§${FILEGROUP}" >> ${BUILDDIR}/${PKGNAME}/.fifo |
echo "${item#${SEARCHDIRS}*}§${fileposix}§${fileowner}§${filegroup}" >> ${BUILDDIR}/${PKGNAME}/.fifo |
172 |
;; |
;; |
173 |
|
|
174 |
*) |
*) |