milis/bin/mpsd

1424 lines
34 KiB
Plaintext
Raw Normal View History

2016-02-24 01:27:23 +01:00
#!/bin/bash
# error codes
E_GENERAL=1
2016-03-07 00:39:49 +01:00
E_TALIMAT=2 # hatalı talimat
2016-02-24 01:27:23 +01:00
E_DIR_PERM=3 # (source/build) directory missing or missing read/write permission
E_DOWNLOAD=4 # error during download
E_UNPACK=5 # error during unpacking of source file(s)
E_MD5=6 # md5sum verification failed
E_FOOTPRINT=7 # footprint check failure
2017-10-27 23:59:41 +02:00
E_BUILD=8 # error while running 'derle()'
2017-10-27 17:18:27 +02:00
E_INSTALL=9 # paket kurulum hatası (mps -k)
2016-02-24 01:27:23 +01:00
info() {
echo "=======> $1"
}
warning() {
2016-03-07 00:39:49 +01:00
info "UYARI: $1" >&2
2016-02-24 01:27:23 +01:00
}
error() {
2016-03-07 00:39:49 +01:00
info "HATA: $1" >&2
2016-02-24 01:27:23 +01:00
}
abort_on_build() {
error $1
exit $E_BUILD
}
get_filename() {
2017-07-26 01:53:37 +02:00
if [[ "$1" =~ "::"(.+) ]] ;then
2017-07-22 01:54:42 +02:00
echo "$DERLEME_KAYNAKDIZIN/${BASH_REMATCH[1]}"
elif [[ $1 =~ ^(http|https|ftp|file)://.*/(.+) ]]; then
2016-03-07 00:39:49 +01:00
echo "$DERLEME_KAYNAKDIZIN/${BASH_REMATCH[2]}"
2016-02-24 01:27:23 +01:00
else
echo $1
fi
}
get_basename() {
local FILE="`echo $1 | sed 's|^.*://.*/||g'`"
echo $FILE
}
check_pkgfile() {
2017-10-28 15:21:27 +02:00
local ISIM_TEST
if [ "${isim}" == "" ]; then
error "$PKGMK_PKGFILE dosyası içinde 'isim' değişkeni bulunamadı."
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2017-10-27 23:59:41 +02:00
elif [ "`type -t derle`" != "function" ]; then
error "$PKGMK_PKGFILE dosyası içinde 'derle' fonksiyonu bulunamadı."
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2016-02-24 01:27:23 +01:00
fi
2017-10-28 15:21:27 +02:00
ISIM_TEST=`echo "${isim}" | sed 's@[[a-z0-9]*[-_+]*]*@@g'`
if [ "$ISIM_TEST" != "" ]; then
error " 'isim' tanımlı değil veya değişkeni geçersiz karakter barındırıyor: $ISIM_TEST"
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2016-02-24 01:27:23 +01:00
fi
2017-10-28 15:21:27 +02:00
if [ ${#isim} -gt 30 ];then
error " 'isim' değişkeni 30 karakterden büyük olamaz."
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2016-02-24 01:27:23 +01:00
fi
2017-10-28 15:21:27 +02:00
if [ "${surum}" == "" ]; then
2016-03-09 01:57:13 +01:00
error "'versiyon' degeri $PKGMK_PKGFILE dosyası içinde yok veya tanımlı degil."
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2016-02-24 01:27:23 +01:00
fi
2017-10-28 01:04:15 +02:00
if [ "$DEVIR_YOKSAY" = "yok" ]; then
2017-10-28 15:21:27 +02:00
if [ "${devir}" == "" ]; then
error " 'devir' degeri $PKGMK_PKGFILE dosyası içinde yok veya tanımlı degil."
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2016-02-24 01:27:23 +01:00
fi
fi
}
get_package_name() {
local NAME EXT
2016-03-07 00:39:49 +01:00
if [ "${1:$((${#1} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
EXT=$PKT_UZANTISI
2016-02-24 01:27:23 +01:00
else
2016-03-07 00:39:49 +01:00
EXT=$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU
2016-02-24 01:27:23 +01:00
fi
2017-10-28 15:21:27 +02:00
2016-02-24 01:27:23 +01:00
NAME=`echo "$1" | cut -d'#' -f1`
echo "$NAME"
}
get_package_builddate() {
local NAME BUILD_DATE EXT
2016-03-07 00:39:49 +01:00
if [ "${1:$((${#1} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
EXT=$PKT_UZANTISI
2016-02-24 01:27:23 +01:00
else
2016-03-07 00:39:49 +01:00
EXT=$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU
2016-02-24 01:27:23 +01:00
fi
NAME="`get_package_name $1`"
BUILD_DATE=`echo $1|sed "s/i686.$EXT//"|sed "s/x86_64.$EXT//"|sed "s/any.$EXT//"`
echo "${BUILD_DATE:$((${#NAME}))}"
}
get_package_extension() {
local EXTENSION
2016-03-07 00:39:49 +01:00
if [ "${1:$((${#1} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
EXTENSION=".$PKT_UZANTISI"
2016-02-24 01:27:23 +01:00
else
2016-03-07 00:39:49 +01:00
EXTENSION=".$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU"
2016-02-24 01:27:23 +01:00
fi
echo $EXTENSION
}
get_package_arch() {
local NAME BUILD_DATE EXTENSION
NAME=`get_package_name $1`
BUILD_DATE=`get_package_builddate $1`
EXTENSION=`get_package_extension $1`
echo $1|sed "s/$NAME$BUILD_DATE//"|sed "s/$EXTENSION//"
}
check_directory() {
if [ ! -d $1 ]; then
error "Directory '$1' does not exist."
exit $E_DIR_PERM
elif [ ! -w $1 ]; then
error "Directory '$1' not writable."
exit $E_DIR_PERM
elif [ ! -x $1 ] || [ ! -r $1 ]; then
error "Directory '$1' not readable."
exit $E_DIR_PERM
fi
}
check_file() {
if [ -e $1 ] && [ ! -w $1 ]; then
error "File '$1' is not writable."
exit $E_GENERAL
fi
}
downloads_file_with_curl() {
if [ ! "`type -p curl`" ]; then
error "Command 'curl' not found."
exit $E_GENERAL
fi
DOWNLOAD_OPTS="--ftp-pasv --retry 3 --retry-delay 3 \
-R -o $1 --fail -#"
error=1
curl $DOWNLOAD_OPTS $2
error=$?
if [ $error != 0 ]; then
2016-03-07 00:39:49 +01:00
error "İndiriliyor '$2' başarısız."
2016-02-24 01:27:23 +01:00
exit $E_DOWNLOAD
fi
}
download_file() {
2017-07-22 01:54:42 +02:00
2017-07-26 01:53:37 +02:00
if [[ "$1" =~ (.+)"::" ]] ;then
2017-07-22 01:54:42 +02:00
adres="${BASH_REMATCH[0]}"
adres=`echo $adres | sed s'/..$//' `
else
adres="$1"
fi
info "İndiriliyor $adres"
2016-02-24 01:27:23 +01:00
LOCAL_FILENAME=`get_filename $1`
2017-07-22 01:54:42 +02:00
info "kayıt:$LOCAL_FILENAME"
2016-02-24 01:27:23 +01:00
if [ ! "`type -p wget`" ]; then
warning "Command 'wget' not found."
info "You should install 'wget' as soon as possible, trying with curl ..."
downloads_file_with_curl $LOCAL_FILENAME $1
else
LOCAL_FILENAME_PARTIAL="$LOCAL_FILENAME.partial"
DOWNLOAD_OPTS="--passive-ftp --no-directories --tries=3 --waitretry=3 \
2017-07-22 01:54:42 +02:00
-O $LOCAL_FILENAME \
2016-02-24 01:27:23 +01:00
--output-document=$LOCAL_FILENAME_PARTIAL --no-check-certificate"
if [ -f "$LOCAL_FILENAME_PARTIAL" ]; then
2016-03-07 00:39:49 +01:00
info "Kısmi indirme var,tamamlanmaya çalışılacak"
2016-02-24 01:27:23 +01:00
RESUME_CMD="-c"
fi
error=1
2017-07-22 01:54:42 +02:00
BASENAME=`get_basename $adres`
2016-02-24 01:27:23 +01:00
for REPO in ${PKGMK_SOURCE_MIRRORS[@]}; do
REPO="`echo $REPO | sed 's|/$||'`"
wget $RESUME_CMD $DOWNLOAD_OPTS $PKGMK_WGET_OPTS $REPO/$BASENAME
error=$?
if [ $error == 0 ]; then
break
fi
done
if [ $error != 0 ]; then
while true; do
2017-07-22 01:54:42 +02:00
wget $RESUME_CMD $DOWNLOAD_OPTS $PKGMK_WGET_OPTS $adres
2016-02-24 01:27:23 +01:00
error=$?
if [ $error != 0 ] && [ "$RESUME_CMD" ]; then
info "Partial download failed, restarting"
rm -f "$LOCAL_FILENAME_PARTIAL"
RESUME_CMD=""
else
break
fi
done
fi
if [ $error != 0 ]; then
2017-07-22 01:54:42 +02:00
error "İndiriliyor '$adres' başarısız."
2016-02-24 01:27:23 +01:00
exit $E_DOWNLOAD
fi
mv -f "$LOCAL_FILENAME_PARTIAL" "$LOCAL_FILENAME"
fi
}
2017-10-28 15:21:27 +02:00
kaynak_indir() {
2016-02-24 01:27:23 +01:00
local FILE LOCAL_FILENAME
2017-10-28 15:21:27 +02:00
for FILE in ${kaynak[@]}; do
2016-02-24 01:27:23 +01:00
LOCAL_FILENAME=`get_filename $FILE`
if [ ! -e $LOCAL_FILENAME ]; then
if [ "$LOCAL_FILENAME" = "$FILE" ]; then
2017-10-28 15:21:27 +02:00
error " '$LOCAL_FILENAME' dosyası içinde 'kaynak' değişkeni tanımsız veya yok."
2016-02-24 01:27:23 +01:00
exit $E_DOWNLOAD
else
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_DOWNLOAD" = "evet" ]; then
2016-02-24 01:27:23 +01:00
download_file $FILE
else
2017-10-28 15:21:27 +02:00
error " '$LOCAL_FILENAME' kaynak dosyası bulunamadı."
2016-02-24 01:27:23 +01:00
exit $E_DOWNLOAD
fi
fi
fi
done
}
remove_source() {
local FILE LOCAL_FILENAME
2017-10-28 15:21:27 +02:00
for FILE in ${kaynak[@]}; do
2016-02-24 01:27:23 +01:00
LOCAL_FILENAME=`get_filename $FILE`
if [ -e $LOCAL_FILENAME ] && [ "$LOCAL_FILENAME" != "$FILE" ]; then
info "Removing $LOCAL_FILENAME"
rm -f $LOCAL_FILENAME
fi
done
}
unpack_source() {
local FILE LOCAL_FILENAME COMMAND
2017-10-28 15:21:27 +02:00
for FILE in ${kaynak[@]}; do
2016-02-24 01:27:23 +01:00
LOCAL_FILENAME=`get_filename $FILE`
case $LOCAL_FILENAME in
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_IGNORE_UNPACK" != "evet" ];then
2016-02-24 01:27:23 +01:00
COMMAND="bsdtar -p -o -C $SRC -xf $LOCAL_FILENAME"
else
COMMAND="cp $LOCAL_FILENAME $SRC"
fi ;;
*)
COMMAND="cp $LOCAL_FILENAME $SRC" ;;
esac
echo "$COMMAND"
$COMMAND
if [ $? != 0 ]; then
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
fi
2016-03-07 00:39:49 +01:00
error "'$TARGET' derlenmesi basarisiz."
2016-02-24 01:27:23 +01:00
exit $E_UNPACK
fi
done
}
get_package_list() {
2017-04-25 21:52:52 +02:00
local ARCH FILE i
2016-02-24 01:27:23 +01:00
i=0
for ARCH in x86_64 i686 any; do
2017-10-28 15:21:27 +02:00
for FILE in `find $PAKETLEME_DIZIN -name "${isim}*$ARCH.$PKT_UZANTISI*"`; do
2016-02-24 01:27:23 +01:00
TARGETS[i]=`basename $FILE`
i=$((i+1))
done
done
}
make_md5sum() {
local FILE LOCAL_FILENAMES
2017-10-28 15:21:27 +02:00
if [ "$kaynak" ]; then
for FILE in ${kaynak[@]}; do
2016-02-24 01:27:23 +01:00
LOCAL_FILENAMES="$LOCAL_FILENAMES `get_filename $FILE`"
done
md5sum $LOCAL_FILENAMES | sed -e 's| .*/| |' | sort -k 2
fi
}
make_footprint() {
if ! (echo $TARGET| grep "kernel" >/dev/null); then
pkginfo --footprint $TARGET | \
sed "s|\tlib/modules/`uname -r`/|\tlib/modules/<kernel-version>/|g" | \
sort -k 3
else
pkginfo --footprint $TARGET | sort -k 3
fi
}
check_md5sum() {
2016-03-07 00:39:49 +01:00
local FILE="$DERLEME_SANTIYE/.tmp"
2016-02-24 01:27:23 +01:00
cd $PKGMK_ROOT
if [ -f $PKGMK_MD5SUM ]; then
make_md5sum > $FILE.md5sum
sort -k 2 $PKGMK_MD5SUM > $FILE.md5sum.orig
diff -w -t -U 0 $FILE.md5sum.orig $FILE.md5sum | \
sed '/^@@/d' | \
sed '/^+++/d' | \
sed '/^---/d' | \
sed 's/^+/NEW /g' | \
sed 's/^-/MISSING /g' > $FILE.md5sum.diff
if [ -s $FILE.md5sum.diff ]; then
error "Md5sum mismatch found:"
cat $FILE.md5sum.diff >&2
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_CHECK_MD5SUM" = "evet" ]; then
2016-02-24 01:27:23 +01:00
error "Md5sum not ok."
exit $E_MD5
fi
2016-03-07 00:39:49 +01:00
error "'$TARGET' derleme basarisiz."
2016-02-24 01:27:23 +01:00
exit $E_MD5
fi
else
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_CHECK_MD5SUM" = "evet" ]; then
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
fi
info "Md5sum not found."
exit $E_MD5
fi
warning "Md5sum not found, creating new."
make_md5sum > $PKGMK_MD5SUM
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_CHECK_MD5SUM" = "evet" ]; then
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
fi
info "Md5sum ok."
exit 0
fi
}
2017-11-01 19:18:48 +01:00
hash_kontrol() {
_hata_deger="FAILED"
if [ $LC_ALL = "tr_TR.UTF-8" ];then
_hata_deger="BAŞARISIZ"
fi
cd $DERLEME_KAYNAKDIZIN
cp $PKGMK_ROOT/$isim.hash $DERLEME_KAYNAKDIZIN/
sha256sum -c $DERLEME_KAYNAKDIZIN/$isim.hash > /tmp/$isim.hash.kontrol 2> /dev/null
sha512sum -c $DERLEME_KAYNAKDIZIN/$isim.hash >> /tmp/$isim.hash.kontrol 2> /dev/null
if [[ $(cat /tmp/$isim.hash.kontrol | grep $_hata_deger) ]];then
echo "shasum uyuşmayan kaynak kod var"
exit 1
fi
[ -f $DERLEME_KAYNAKDIZIN/$isim.hash ] && rm $DERLEME_KAYNAKDIZIN/$isim.hash
#[ -f /tmp/$isim.hash.kontrol ] && rm /tmp/$isim.hash.kontrol
2017-11-28 01:28:21 +01:00
cd -
2017-11-01 19:18:48 +01:00
}
2016-02-24 01:27:23 +01:00
strip_files() {
local FILE FILTER
cd $PKG
if [ -f $PKGMK_ROOT/$PKGMK_NOSTRIP ]; then
FILTER="grep -v -f $PKGMK_ROOT/$PKGMK_NOSTRIP"
else
FILTER="cat"
fi
find . -type f -printf "%P\n" | $FILTER | while read FILE; do
case $(file -b "$FILE") in
*ELF*executable*not\ stripped)
strip --strip-all "$FILE"
;;
*ELF*shared\ object*not\ stripped)
strip --strip-unneeded "$FILE"
;;
current\ ar\ archive)
strip --strip-debug "$FILE"
esac
done
}
compress_manpages() {
local FILE DIR TARGET
cd $PKG
find . -type f -path "*/share/man*/*" | while read FILE; do
if [ "$FILE" = "${FILE%%.gz}" ]; then
gzip -9 "$FILE"
fi
done
find . -type l -path "*/share/man*/*" | while read FILE; do
TARGET=`readlink -n "$FILE"`
TARGET="${TARGET##*/}"
TARGET="${TARGET%%.gz}.gz"
rm -f "$FILE"
FILE="${FILE%%.gz}.gz"
DIR=`dirname "$FILE"`
if [ -e "$DIR/$TARGET" ]; then
ln -sf "$TARGET" "$FILE"
fi
done
find . -type f -path "*/share/info/*" | while read FILE; do
if [ "$FILE" = "${FILE%%.gz}" ]; then
gzip -9 "$FILE"
fi
done
find . -type l -path "*/share/info/*" | while read FILE; do
TARGET=`readlink -n "$FILE"`
TARGET="${TARGET##*/}"
TARGET="${TARGET%%.gz}.gz"
rm -f "$FILE"
FILE="${FILE%%.gz}.gz"
DIR=`dirname "$FILE"`
if [ -e "$DIR/$TARGET" ]; then
ln -sf "$TARGET" "$FILE"
fi
done
}
check_footprint() {
2016-03-07 00:39:49 +01:00
local TARGET FILE="$DERLEME_SANTIYE/.tmp"
2016-02-24 01:27:23 +01:00
2017-04-25 21:52:52 +02:00
cd $PAKETLEME_DIZIN
2016-02-24 01:27:23 +01:00
if [ -z $TARGETS ]; then
get_package_list
if [ -z $TARGETS ]; then
error "Unable to update footprint"
fi
fi
for TARGET in ${TARGETS[@]}; do
if [ -f $TARGET ]; then
PKGMK_FOOTPRINT="`get_package_name $TARGET`".footprint
make_footprint > $FILE.footprint
if [ -f $PKGMK_FOOTPRINT ]; then
sort -k 3 $PKGMK_FOOTPRINT > $FILE.footprint.orig
diff -w -t -U 0 $FILE.footprint.orig $FILE.footprint | \
sed '/^@@/d' | \
sed '/^+++/d' | \
sed '/^---/d' | \
sed 's/^+/NEW /g' | \
sed 's/^-/MISSING /g' > $FILE.footprint.diff
if [ -s $FILE.footprint.diff ]; then
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_IGNORE_NEW" = "evet" ]; then
2016-02-24 01:27:23 +01:00
mv $FILE.footprint $PKGMK_FOOTPRINT
warning "Footprint mismatch found:"
else
error "Footprint mismatch found:"
2016-03-07 00:39:49 +01:00
BUILD_SUCCESSFUL="yok"
2016-02-24 01:27:23 +01:00
fi
cat $FILE.footprint.diff >&2
fi
else
warning "Footprint not found, creating new."
mv $FILE.footprint $PKGMK_FOOTPRINT
fi
else
error "Package '$TARGET' was not found."
2016-03-07 00:39:49 +01:00
BUILD_SUCCESSFUL="yok"
2016-02-24 01:27:23 +01:00
fi
done
}
make_work_dir() {
2016-03-07 00:39:49 +01:00
export PKG="$DERLEME_SANTIYE/pkg"
export SRC="$DERLEME_SANTIYE/src"
2016-02-24 01:27:23 +01:00
umask 022
cd $PKGMK_ROOT
remove_work_dir
mkdir -p $SRC $PKG
2017-11-01 19:18:48 +01:00
if [ -f $PKGMK_ROOT/$HASH_KONTROL_DOSYA ]; then
echo "hash kontrol dosyası var"
if [ "$SHASUM_KONTROL_YAP" = "evet" ]; then
echo "hash kontrolü yapılacak"
hash_kontrol
else
echo "hash kontrolü yapılmayacak."
fi
else
echo "hash kontrol dosyası yok-hash kontrolü yapılmayacak."
fi
2016-02-24 01:27:23 +01:00
}
remove_work_dir() {
2016-03-07 00:39:49 +01:00
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
}
2017-10-27 16:22:18 +02:00
2016-02-24 01:27:23 +01:00
pack_devel() {
local DIR SUBDIR
for DIR in usr opt/*; do
for SUBDIR in include lib/pkgconfig; do
if [ -d $DIR/$SUBDIR ]; then
bsdtar -r -f \
2017-10-28 15:21:27 +02:00
$PAKETLEME_DIZIN/${isim}.${group}#$surum-any.${PKT_UZANTISI} \
2016-03-07 00:39:49 +01:00
$DIR/$SUBDIR || BUILD_SUCCESSFUL="yok"
2016-02-24 01:27:23 +01:00
rm -r $DIR/$SUBDIR
j=1
fi
done
done
}
remove_devel() {
local DIR SUBDIR
for DIR in usr opt/*; do
for SUBDIR in include lib/pkgconfig; do
if [ -d $DIR/$SUBDIR ]; then
rm -r $DIR/$SUBDIR
fi
done
done
}
2017-10-27 16:22:18 +02:00
2016-02-24 01:27:23 +01:00
add_meta_files() {
local NAME
NAME="`get_package_name $1`"
cd $PKG
2016-02-26 02:41:51 +01:00
if [ -f $PKGMK_ROOT/${NAME}.okubeni ]; then
cp $PKGMK_ROOT/${NAME}.okubeni .README
2016-02-24 01:27:23 +01:00
fi
2016-02-26 02:41:51 +01:00
if [ -f $PKGMK_ROOT/${NAME}.kos-kur ]; then
cp $PKGMK_ROOT/${NAME}.kos-kur .PRE
2016-02-24 01:27:23 +01:00
fi
2016-02-26 02:41:51 +01:00
if [ -f $PKGMK_ROOT/${NAME}.kur-kos ]; then
cp $PKGMK_ROOT/${NAME}.kur-kos .POST
2016-02-24 01:27:23 +01:00
fi
2017-06-28 14:18:39 +02:00
for file in .README .PRE .POST; do
2016-02-24 01:27:23 +01:00
if [ -f $file ]; then
2017-04-25 21:52:52 +02:00
bsdtar -r -f $PAKETLEME_DIZIN/$1 \
2016-02-24 01:27:23 +01:00
$file
rm $file
fi
done
}
add_meta_to_archive() {
2017-10-27 16:59:51 +02:00
local NAME TAR SIZE_I DESC URL PACK MAINT ARCH GRUP
2016-02-24 01:27:23 +01:00
NAME="`get_package_name $1`"
ARCH="`get_package_arch $1`"
info "$NAME arşivine üstbilgiler ekleniyor."
2016-03-07 00:39:49 +01:00
TAR="$DERLEME_SANTIYE/tar"
2016-02-24 01:27:23 +01:00
mkdir -p $TAR
cd $TAR
2017-04-25 21:52:52 +02:00
bsdtar xf $PAKETLEME_DIZIN/$1
2017-06-10 07:00:51 +02:00
# üstbaşlık bilgilerinin türkçe harf desteği için
LC_ALL="tr_TR.UTF-8"
2017-10-27 20:46:27 +02:00
if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tanım|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
DESC="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tanım|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
2016-02-24 01:27:23 +01:00
else
2017-10-27 16:59:51 +02:00
DESC="belirsiz"
2016-02-24 01:27:23 +01:00
fi
2017-10-27 20:46:27 +02:00
if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Paketçi|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
PACK="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Paketçi|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
2016-02-24 01:27:23 +01:00
else
2017-10-27 16:59:51 +02:00
PACK="belirsiz"
2016-02-24 01:27:23 +01:00
fi
2017-10-27 20:46:27 +02:00
if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tamirci|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
MAINT="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Tamirci|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
2016-02-24 01:27:23 +01:00
else
2017-10-27 16:59:51 +02:00
MAINT="belirsiz"
2016-02-24 01:27:23 +01:00
fi
if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^url|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
URL="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^url|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
else
2017-10-27 16:59:51 +02:00
URL="belirsiz"
fi
if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Grup|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
GRUP="`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^Grup|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"
else
GRUP="belirsiz"
2016-02-24 01:27:23 +01:00
fi
2017-04-25 21:52:52 +02:00
SIZE_I="`du -b $PAKETLEME_DIZIN/$1|sed "s/\t/ /"|cut -d " " -f1`"
2016-02-24 01:27:23 +01:00
echo "N$NAME" > .META
echo "D$DESC" >> .META
echo "U$URL" >> .META
echo "M$MAINT" >> .META
echo "P$PACK" >> .META
echo "S$SIZE_I" >> .META
2017-10-28 15:21:27 +02:00
echo "V$surum" >> .META
echo "r$devir" >> .META
2016-02-24 01:27:23 +01:00
echo "B$PKGMK_BUILDVER" >> .META
echo "a$ARCH" >> .META
2017-10-27 16:59:51 +02:00
echo "G$GRUP" >> .META
2017-10-27 17:18:27 +02:00
2017-04-25 21:52:52 +02:00
bsdtar -tf $PAKETLEME_DIZIN/$1 > .MTREE
2016-02-24 01:27:23 +01:00
2017-04-25 21:52:52 +02:00
rm $PAKETLEME_DIZIN/$1
2016-02-24 01:27:23 +01:00
2017-06-28 14:18:39 +02:00
for file in .META .MTREE .README .PRE .POST .INFO; do
2016-02-24 01:27:23 +01:00
if [ -f $file ]; then
2017-04-25 21:52:52 +02:00
bsdtar -r -f $PAKETLEME_DIZIN/$1 \
2016-02-24 01:27:23 +01:00
$file
fi
done
2017-04-25 21:52:52 +02:00
bsdtar -r -f $PAKETLEME_DIZIN/$1 *
2016-02-24 01:27:23 +01:00
cd ..
rm -rf $TAR
}
compress_archive() {
info "$1 sıkıştırılıyor."
2016-03-07 00:39:49 +01:00
case $PKT_SIKISTIRMA_MODU in
2016-02-24 01:27:23 +01:00
lz) lzip -9 $1;;
gz) gzip -9 $1;;
bz2) bzip2 -9 $1;;
xz) xz -z -9 $1;;
esac
}
2017-10-27 23:59:41 +02:00
derleme_yap() {
2016-02-24 01:27:23 +01:00
if [ "$PAKETSIZ_DERLEME" = "evet" ]; then
paketsiz_derle
else
build_package
fi
}
paketsiz_derle() {
2016-03-07 00:39:49 +01:00
local BUILD_SUCCESSFUL="yok"
2016-02-24 01:27:23 +01:00
export PKG="/"
2016-03-07 00:39:49 +01:00
export SRC="$DERLEME_SANTIYE/src"
2016-02-24 01:27:23 +01:00
umask 022
cd $PKGMK_ROOT
2016-03-07 00:39:49 +01:00
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
mkdir -p $SRC
2016-03-07 00:39:49 +01:00
info "derleniyor... '$TARGET'"
2016-02-24 01:27:23 +01:00
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_DOWNLOAD" = "evet" ]; then
2017-10-28 15:21:27 +02:00
kaynak_indir
2016-02-24 01:27:23 +01:00
fi
unpack_source
cd $SRC
2017-10-27 23:59:41 +02:00
(set -e -x ; derle)
2016-02-24 01:27:23 +01:00
# cd $PKG
if [ $? = 0 ]; then
2016-03-07 00:39:49 +01:00
BUILD_SUCCESSFUL="evet"
2016-02-24 01:27:23 +01:00
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
fi
2016-03-07 00:39:49 +01:00
if [ "$BUILD_SUCCESSFUL" = "evet" ]; then
2016-02-24 01:27:23 +01:00
info " '$TARGET' derleme basarili"
else
if [ -f $TARGET ]; then
touch -r $PKGMK_ROOT/$PKGMK_PKGFILE $TARGET &> /dev/null
fi
error " '$TARGET' derleme basarisiz"
exit 1
fi
}
build_package() {
# TODO find a better solution for the hardcoded folders
2016-03-07 00:39:49 +01:00
local BUILD_SUCCESSFUL="yok"
2016-02-24 01:27:23 +01:00
if [ "$1" != "$TARGET" ]; then
if [ ! -z $TARGETS ]; then
for TARGET in ${TARGETS[@]}; do
error "$TARGET should be remove"
done
error "Remove the binaries first..."
exit $E_BUILD
fi
fi
check_file "$TARGET"
make_work_dir
if [ "$UID" != "0" ]; then
2017-11-01 19:18:48 +01:00
warning "Paketler root olarak derlenmeli."
2016-02-24 01:27:23 +01:00
fi
2017-10-27 23:09:55 +02:00
info "Derleniyor '$TARGET'."
2016-02-24 01:27:23 +01:00
unpack_source
cd $SRC
2017-10-27 23:59:41 +02:00
(set -e -x ; derle)
2016-02-24 01:27:23 +01:00
if [ $? = 0 ]; then
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_NO_STRIP" = "yok" ]; then
2016-02-24 01:27:23 +01:00
strip_files
fi
compress_manpages
cd $PKG
i=0
j=0
2016-03-07 00:39:49 +01:00
for group in ${PAKET_GRUPLAR[@]}; do
BUILD_SUCCESSFUL="evet"
2016-02-24 01:27:23 +01:00
if [ "`type -t ${group}`" == "function" ]; then
(set -e -x ;${group})
j=1
if [ $? = 0 ]; then
2016-03-07 00:39:49 +01:00
BUILD_SUCCESSFUL="evet"
2016-02-24 01:27:23 +01:00
else
error "Building '$TARGET' failed."
exit $E_BUILD
fi
else
if [ "$1" != "$TARGET" ]; then
2017-10-28 15:21:27 +02:00
if [ -f $PAKETLEME_DIZIN/${isim}.${group}#$surum-* ]; then
rm $PAKETLEME_DIZIN/${isim}.${group}#$surum-}*
2016-02-24 01:27:23 +01:00
fi
pack_${group}
fi
remove_${group}
2016-03-07 00:39:49 +01:00
if [ "$BUILD_SUCCESSFUL" == "yok" ]; then
2016-02-24 01:27:23 +01:00
error "Building '$TARGET' failed."
exit $E_BUILD
fi
fi
# Add the meta in each package
if [ $j == 1 ]; then
2016-03-07 00:39:49 +01:00
if [ "$BUILD_SUCCESSFUL" == "yok" ]; then
2016-02-24 01:27:23 +01:00
error "Building '$TARGET' failed."
exit $E_BUILD
fi
j=0
fi
j=0
done
2016-03-19 01:55:02 +01:00
#dil desteginin eklenmesi-geri kalanın temizlenmesi
2016-03-21 18:23:43 +01:00
#if [ ! "$PAKET_LOKAL" == "hepsi" ];then
# local lokaldizin
# if [ -d usr/share/locale ];then
# lokaldizin="usr/share/locale"
# fi
# if [ -d opt/*/usr/share/locale ];then
# lokaldizin="opt/*/usr/share/locale"
# fi
# for DIR in `ls $lokaldizin` ; do
# if [[ "$PAKET_LOKAL" == *"$DIR"* ]]; then
# echo $DIR "dil paketi ekleniyor"
# else
# rm -rf $lokaldizin/$DIR
# fi
# done
#fi
2016-03-19 01:55:02 +01:00
2016-02-24 01:27:23 +01:00
if [ "`ls|wc -l`" != "0" ]; then
2017-10-28 15:21:27 +02:00
bsdtar -r -f $PAKETLEME_DIZIN/${isim}#$surum-${MIMARI}.${PKT_UZANTISI} *
2016-02-24 01:27:23 +01:00
else
error "No files found in $PKG..."
exit $E_BUILD
fi
if [ $? = 0 ]; then
2016-03-07 00:39:49 +01:00
BUILD_SUCCESSFUL="evet"
if [ "$DOSYAIZLEME_YOKSAY" == "evet" ]; then
warning "dosyaizleme pas gecildi."
2016-02-24 01:27:23 +01:00
else
check_footprint
fi
fi
fi
2016-03-07 00:39:49 +01:00
if [ "$BUILD_SUCCESSFUL" = "evet" ]; then
2016-02-24 01:27:23 +01:00
if [ "$1" != "$TARGET" ]; then
get_package_list
if [ -z $TARGETS ]; then
error "Paket(ler) bulunamadı..."
exit $E_BUILD
fi
for TARGET in ${TARGETS[@]}; do
add_meta_files $TARGET
add_meta_to_archive $TARGET
done
else
add_meta_files `basename $TARGET`
add_meta_to_archive `basename $TARGET`
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
2016-02-24 01:27:23 +01:00
remove_work_dir
fi
else
if [ -f $TARGET ]; then
touch -r $PKGMK_ROOT/$PKGMK_PKGFILE $TARGET &> /dev/null
fi
2016-03-07 00:39:49 +01:00
error "'$TARGET' derlenmesi başarısız."
2016-02-24 01:27:23 +01:00
exit $E_BUILD
fi
}
install_package() {
local COMMAND
get_package_list
if [ -z $TARGETS ]; then
error "kurulacak paket bulunamadı..."
exit $E_INSTALL
fi
for TARGET in ${TARGETS[@]}; do
2017-04-25 21:52:52 +02:00
if [ "`get_package_arch $TARGET`" = "$MIMARI" ] || [ "`get_package_arch $TARGET`" = "any" ]; then
2016-02-24 01:27:23 +01:00
info "kuruluyor '$TARGET'."
2017-10-27 17:18:27 +02:00
if [ "$DERLE_KUR" = "kur" ]; then
2017-04-25 21:52:52 +02:00
COMMAND="mps -k $PAKETLEME_DIZIN/$TARGET"
2016-02-24 01:27:23 +01:00
else
2017-04-25 21:52:52 +02:00
COMMAND="mps -k $PAKETLEME_DIZIN/$TARGET"
2016-02-24 01:27:23 +01:00
fi
cd $PKGMK_ROOT
echo "$COMMAND"
$COMMAND
if [ $? = 0 ]; then
info " '$TARGET' basarili sekilde kuruldu."
else
error " '$TARGET' kurulum basarisiz."
exit $E_INSTALL
fi
fi
done
}
paket_kur() {
local COMMAND
get_package_list
if [ -z $TARGETS ]; then
error "kurulacak paket bulunamadı..."
exit $E_INSTALL
fi
for TARGET in ${TARGETS[@]}; do
2017-04-25 21:52:52 +02:00
if [ "`get_package_arch $TARGET`" = "$MIMARI" ] || [ "`get_package_arch $TARGET`" = "any" ]; then
2016-02-24 01:27:23 +01:00
info "kuruluyor '$TARGET'."
#paket_kurulum
if [ "$PAKET_KURMA" = "evet" ]; then
2017-04-25 21:52:52 +02:00
COMMAND2="echo :::::::::::::::::::::::: $PAKETLEME_DIZIN/$TARGET"
2016-02-24 01:27:23 +01:00
fi
echo "$COMMAND2"
$COMMAND2
cd $PKGMK_ROOT
echo "$COMMAND"
$COMMAND
if [ $? = 0 ]; then
info " '$TARGET' basarili sekilde kuruldu."
else
error " '$TARGET' kurulum basarisiz."
exit $E_INSTALL
fi
fi
done
}
recursive() {
local ARGS FILE DIR
2016-03-07 00:39:49 +01:00
[ -f $REPO_DOSYASI ] && rm -v $REPO_DOSYASI
2016-02-24 01:27:23 +01:00
ARGS=`echo "$@" | sed -e "s/--recursive//g" -e "s/-r//g"`
for FILE in `find $PKGMK_ROOT -name $PKGMK_PKGFILE | sort`; do
DIR="`dirname $FILE`/"
if [ -d $DIR ]; then
info "Entering directory '$DIR'."
(cd $DIR && $PKGMK_COMMAND $ARGS)
info "Leaving directory '$DIR'."
fi
done
}
clean() {
unset TARGETS
get_package_list
if [ ! -z $TARGETS ]; then
for TARGET in ${TARGETS[@]}; do
2017-04-25 21:52:52 +02:00
if [ -f $PAKETLEME_DIZIN/$TARGET ]; then
2016-02-24 01:27:23 +01:00
info "Removing $TARGET"
2017-04-25 21:52:52 +02:00
rm -f $PAKETLEME_DIZIN/$TARGET
2016-02-24 01:27:23 +01:00
fi
done
else
2016-03-07 00:39:49 +01:00
warning "$TARGETS bulunamadı"
2016-02-24 01:27:23 +01:00
fi
find $PKGMK_ROOT -name "*.md5sum" -exec rm -v {} \; 2> /dev/null
find $PKGMK_ROOT -name "*.footprint" -exec rm -v {} \; 2> /dev/null
unset TARGETS
}
update_footprint() {
2017-04-25 21:52:52 +02:00
cd $PAKETLEME_DIZIN
2016-02-24 01:27:23 +01:00
if [ -z $TARGETS ]; then
get_package_list
if [ -z $TARGETS ]; then
error "Package(s) not found(s), unable to update footprint."
exit $E_FOOTPRINT
fi
fi
for TARGET in ${TARGETS[@]}; do
if [ ! -f $TARGET ]; then
error "Unable to update footprint. File '$TARGET' not found."
exit $E_FOOTPRINT
fi
PKGMK_FOOTPRINT="`get_package_name $TARGET`".footprint
check_file "$PKGMK_FOOTPRINT"
make_footprint > $PKGMK_FOOTPRINT
touch $TARGET
info "Footprint updated for $TARGET"
done
}
build_needed() {
local FILE RESULT
2016-03-07 00:39:49 +01:00
RESULT="evet"
2016-02-24 01:27:23 +01:00
if [ -f $TARGET ]; then
2016-03-07 00:39:49 +01:00
RESULT="yok"
2016-02-24 01:27:23 +01:00
FILE=`get_filename $PKGMK_PKGFILE`
if [ ! -e $FILE ] || [ ! $TARGET -nt $FILE ]; then
2016-03-07 00:39:49 +01:00
RESULT="evet"
2016-02-24 01:27:23 +01:00
break
fi
fi
echo $RESULT
}
update_repo()
{
local FILE MD5SUM EXT
cd $PKGMK_ROOT
get_package_list
if [ ! -z $TARGETS ]; then
EXT="`get_package_extension $TARGETS`"
2017-10-28 15:21:27 +02:00
echo -n "`get_package_builddate $TARGETS`#$EXT##$surum-#$devir" > $REPO_DOSYASI
2016-02-24 01:27:23 +01:00
for string in desc url maint pack; do
if [ ! -z "`cat $PKGMK_ROOT/$PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^$string|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`" ]; then
echo -n "#"`cat $PKGMK_PKGFILE |sed "s@^[ ,\t,#]*@@"|grep -i ^$string|cut -d : -f1 --complement|sed "s@^[ ,\t]*@@"`"" \
>> .PKGREPO
else
echo -n "#n.a" >> .PKGREPO
fi
done
printf "\n" >> .PKGREPO
for TARGET in ${TARGETS[@]}; do
FILE=`basename $TARGET`
MD5SUM=`md5sum $TARGET|cut -d " " -f1`
2016-03-07 00:39:49 +01:00
echo "$MD5SUM#`get_package_name $TARGET`#`get_package_arch $TARGET|sed "s/-//"`" >> $REPO_DOSYASI
2016-02-24 01:27:23 +01:00
done
2017-10-28 15:21:27 +02:00
for FILE in ${isim}*
2016-02-24 01:27:23 +01:00
do
[ ! -f "$FILE" ] && break
if [ "${FILE:$((${#FILE} - ${#EXT} ))}" != "$EXT" ]; then
2016-03-07 00:39:49 +01:00
echo "`md5sum $FILE|cut -d " " -f1`#$FILE" >> $REPO_DOSYASI
2016-02-24 01:27:23 +01:00
fi
done
else
2016-03-07 00:39:49 +01:00
rm -f $REPO_DOSYASI
2016-02-24 01:27:23 +01:00
fi
2016-03-07 00:39:49 +01:00
echo "`md5sum $PKGMK_PKGFILE|cut -d " " -f1`#$PKGMK_PKGFILE" >> $REPO_DOSYASI
2016-02-24 01:27:23 +01:00
}
clean_repo_files()
{
cd $PKGMK_ROOT
2016-03-07 00:39:49 +01:00
if [ -f $REPO_DOSYASI ]; then
rm $REPO_DOSYASI
info "siliniyor $REPO_DOSYASI"
2016-02-24 01:27:23 +01:00
fi
if [ -f MD5SUM ]; then
rm MD5SUM
2016-03-07 00:39:49 +01:00
info "siliniyor MD5SUM"
2016-02-24 01:27:23 +01:00
fi
}
interrupted() {
echo ""
error "Interrupted."
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_KEEP_WORK" = "yok" ]; then
rm -rf $DERLEME_SANTIYE
2016-02-24 01:27:23 +01:00
fi
exit $E_GENERAL
}
print_help() {
echo "usage: `basename $PKGMK_COMMAND` [options]"
echo "options:"
echo " -i, --install build and install packages"
echo " -u, --upgrade build and install packages (as upgrade)"
echo " -r, --recursive search for and build packages recursively"
echo " -d, --download download missing source file(s)"
echo " -cv, --show-version-only do not build, only show the version of the port and exit"
echo " -do, --download-only do not build, only download missing source file(s)"
echo " -eo, --extract-only do not build, only extract source file(s)"
echo " -utd, --up-to-date do not build, only check if package is up to date"
2016-03-07 00:39:49 +01:00
echo " -ur, --update-repo do not build, only update the $REPO_DOSYASI file"
2016-02-24 01:27:23 +01:00
echo " -uf, --update-footprint update footprint using result from last build"
2016-03-07 00:39:49 +01:00
echo " -ic, --ignore-collection build packages without update the $REPO_DOSYASI file of the collection means from the parent directory"
2016-02-24 01:27:23 +01:00
echo " -if, --ignore-footprint build packages without checking footprint"
echo " -in, --ignore-new build packages, ignore new files in a footprint missmatch"
echo " -um, --update-md5sum update md5sum"
echo " -im, --ignore-md5sum build packages without checking md5sum"
echo " -cm, --check-md5sum do not build, only check md5sum"
echo " -ns, --no-strip do not strip executable binaries or libraries"
echo " -f, --force build packages even if it appears to be up to date"
2016-03-07 00:39:49 +01:00
echo " -co, --clean-only do not build, only remove packages and downloaded files, update $REPO_DOSYASI file"
2016-02-24 01:27:23 +01:00
echo " -kw, --keep-work keep temporary working directory"
echo " -cf, --config-file <file> use alternative configuration file"
echo " -v, --version print version and exit "
echo " -h, --help print help and exit"
}
parse_options() {
while [ "$1" ]; do
case $1 in
-i|--install)
2017-10-27 17:18:27 +02:00
DERLE_KUR="kur" ;;
2016-02-24 01:27:23 +01:00
-pk|--pkur)
PAKET_KURMA="evet" ;;
-u|--upgrade)
2017-10-27 17:18:27 +02:00
DERLE_KUR="guncelle" ;;
2016-02-24 01:27:23 +01:00
-r|--recursive)
2016-03-07 00:39:49 +01:00
PKGMK_RECURSIVE="evet" ;;
2016-02-24 01:27:23 +01:00
-d|--download)
2016-03-07 00:39:49 +01:00
PKGMK_DOWNLOAD="evet" ;;
2016-02-24 01:27:23 +01:00
-do|--download-only)
2016-03-07 00:39:49 +01:00
PKGMK_DOWNLOAD="evet"
PKGMK_DOWNLOAD_ONLY="evet" ;;
2016-02-24 01:27:23 +01:00
-eo|--extract-only)
2016-03-07 00:39:49 +01:00
PKGMK_EXTRACT_ONLY="evet" ;;
2016-02-24 01:27:23 +01:00
-cv|--show-version-only)
2016-03-07 00:39:49 +01:00
PKGMK_SHOW_VERSION="evet";;
2016-02-24 01:27:23 +01:00
-utd|--up-to-date)
2016-03-07 00:39:49 +01:00
PKGMK_UP_TO_DATE="evet" ;;
-sk|--sd-kontrol)
SOZDIZIM_KONTROL="evet" ;;
2016-02-24 01:27:23 +01:00
-ur|--update-repo)
2016-03-07 00:39:49 +01:00
PKGMK_UPDATE_REPO="evet" ;;
2016-02-24 01:27:23 +01:00
-uf|--update-footprint)
2016-03-07 00:39:49 +01:00
PKGMK_UPDATE_FOOTPRINT="evet" ;;
2016-02-24 01:27:23 +01:00
-if|--ignore-footprint)
2016-03-07 00:39:49 +01:00
DOSYAIZLEME_YOKSAY="evet" ;;
2016-02-24 01:27:23 +01:00
-in|--ignore-new)
2016-03-07 00:39:49 +01:00
PKGMK_IGNORE_NEW="evet" ;;
2016-02-24 01:27:23 +01:00
-ic|--ignore-collection)
2016-03-07 00:39:49 +01:00
KOLEKSIYON_YOKSAY="evet" ;;
2016-02-24 01:27:23 +01:00
-ir|--ignore-repo)
2016-03-07 00:39:49 +01:00
REPO_YOKSAY="evet" ;;
2017-11-01 19:18:48 +01:00
-shk|--hash-kontrol)
SHASUM_KONTROL_YAP="evet" ;;
2016-02-24 01:27:23 +01:00
-ns|--no-strip)
2016-03-07 00:39:49 +01:00
PKGMK_NO_STRIP="evet" ;;
2016-02-24 01:27:23 +01:00
-f|--force)
2016-03-07 00:39:49 +01:00
PKGMK_FORCE="evet" ;;
2016-02-24 01:27:23 +01:00
-co|--clean-only)
2016-03-07 00:39:49 +01:00
PKGMK_CLEAN_ONLY="evet" ;;
2016-02-24 01:27:23 +01:00
-kw|--keep-work)
2016-03-07 00:39:49 +01:00
PKGMK_KEEP_WORK="evet" ;;
2016-02-24 01:27:23 +01:00
-cf|--config-file)
if [ ! "$2" ]; then
echo "`basename $PKGMK_COMMAND`: option $1 requires an argument"
exit 1
fi
2016-03-07 00:39:49 +01:00
DERLEME_AYARDOSYASI="$2"
2016-02-24 01:27:23 +01:00
shift ;;
-v|--version)
2017-10-28 01:04:15 +02:00
echo "`basename $PKGMK_COMMAND` $PKGMK_VERSION"
2016-02-24 01:27:23 +01:00
exit 0 ;;
-h|--help)
print_help
exit 0 ;;
*)
echo "`basename $PKGMK_COMMAND`: invalid option $1"
exit 1 ;;
esac
shift
done
}
main() {
if [ -f /etc/noprofile ]; then
source /etc/noprofile
fi
2017-11-01 14:46:54 +01:00
2017-11-01 19:18:48 +01:00
parse_options "$@"
2017-11-01 14:46:54 +01:00
if [ "$(md5sum $DERLEME_AYARDOSYASI | cut -d' ' -f1)" = "$(md5sum $ANADERLEME_AYARDOSYASI | cut -d' ' -f1)" ];then
2017-11-01 19:18:48 +01:00
shift
2017-11-01 14:46:54 +01:00
else
echo "mpsd.conf dosyası farklı!"
while true; do
echo "mpsd.conf güncel sürümü ile değiştirilsin mi?";read -p "e veya h-> " eh
case $eh in
[Ee]* ) cp -f $ANADERLEME_AYARDOSYASI $DERLEME_AYARDOSYASI; break;;
[Hh]* ) break;;
* ) echo "e veya h";;
esac
done
fi
2016-02-24 01:27:23 +01:00
2017-11-01 19:18:48 +01:00
if [ ! -f $DERLEME_AYARDOSYASI ]; then
error " '$DERLEME_AYARDOSYASI' dosyası bulunamadı."
exit $E_GENERAL
fi
2016-02-24 01:27:23 +01:00
2017-11-01 19:18:48 +01:00
. $DERLEME_AYARDOSYASI
2016-02-24 01:27:23 +01:00
2017-11-01 19:18:48 +01:00
MIMARI=`uname -m`
2017-11-01 14:46:54 +01:00
2016-03-07 00:39:49 +01:00
DOSYAIZLEME_YOKSAY="evet"
2017-11-01 14:46:54 +01:00
2016-02-24 01:27:23 +01:00
local FILE TARGET
2017-10-28 15:21:27 +02:00
isim=`basename $PKGMK_ROOT`
2016-02-24 01:27:23 +01:00
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_RECURSIVE" = "evet" ]; then
2016-02-24 01:27:23 +01:00
recursive "$@"
exit 0
fi
if [ ! -f $PKGMK_PKGFILE ]; then
2017-11-01 14:46:54 +01:00
error " '$PKGMK_PKGFILE' dosyası bulunamadı"
2016-03-07 00:39:49 +01:00
exit $E_TALIMAT
2016-02-24 01:27:23 +01:00
fi
. $PKGMK_PKGFILE
if [ -z $group ]; then
2017-10-28 15:21:27 +02:00
group="`echo $isim | cut -d "-" -f1`"
2016-02-24 01:27:23 +01:00
fi
2017-10-28 15:21:27 +02:00
if [ "$group" == "$isim" ]; then
2016-02-24 01:27:23 +01:00
unset group
fi
2017-10-28 15:21:27 +02:00
if [ -z "$surum" ]; then
2016-02-24 01:27:23 +01:00
if [ ! -z "$group" ];then
if [ -f ../$group/$PKGMK_PKGFILE ];then
. ../$group/$PKGMK_PKGFILE
unset run
. $PKGMK_PKGFILE
else
2017-10-28 15:21:27 +02:00
warning "$PKGMK_PKGFILE dosyası içinde 'surum' değişkeni ayarlı değil veya yer almıyor."
2016-02-24 01:27:23 +01:00
fi
else
2017-10-28 15:21:27 +02:00
warning "$PKGMK_PKGFILE dosyası içinde 'surum' değişkeni ayarlı değil veya yer almıyor."
2016-02-24 01:27:23 +01:00
fi
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_SHOW_VERSION" == "evet" ]; then
2017-10-28 15:21:27 +02:00
echo "$surum"
2016-02-24 01:27:23 +01:00
exit 0
fi
2017-10-27 17:18:27 +02:00
## bu bilgiler gösterilmeyecek<
#info "DERLE_KUR: $DERLE_KUR"
#info "PAKET_KURMA: $PAKET_KURMA"
#info "DERLEME_SANTIYE: $DERLEME_SANTIYE"
#info "DERLEME_KAYNAKDIZIN: $DERLEME_KAYNAKDIZIN"
#if [ "$DERLE_KUR" = "yok" ]; then
# PKGMK_CLEAN="yok"
# warning "TEMIZLIK PAS GECILDI."
#else
# info "PKGMK_KEEP_SOURCES: $PKGMK_KEEP_SOURCES"
# info "PKGMK_CLEAN: $PKGMK_CLEAN"
#fi
#if [ "$PKGMK_CLEAN" != "yok" ]; then
# DOSYAIZLEME_YOKSAY="evet"
# MD5SUM_YOKSAY="evet"
# warning "FOOTPRINT AND MD5SUM IGNORED"
#else
# if [ "$PKGMK_UPDATE_REPO" != "evet" ]; then
# info "REPO_YOKSAY: $REPO_YOKSAY"
# else
# info "PKGMK_UPDATE_REPO: $PKGMK_UPDATE_REPO"
# fi
# info "DOSYAIZLEME_YOKSAY: $DOSYAIZLEME_YOKSAY"
# info "MD5SUM_YOKSAY: $MD5SUM_YOKSAY"
#fi
#if [ "$REPO_YOKSAY" == "evet" ]; then
# info "$REPO_DOSYASI dosyası silenecek"
#fi
2016-02-24 01:27:23 +01:00
2017-10-27 17:18:27 +02:00
#info "PKT_SIKISTIRMA: $PKT_SIKISTIRMA"
#if [ "$PKT_SIKISTIRMA" != "yok" ]; then
# info "PKT_SIKISTIRMA_MODU: $PKT_SIKISTIRMA_MODU"
#fi
## >bu bilgiler gösterilmeyecek
2017-10-28 15:21:27 +02:00
info "isim: ${isim}"
if [ ! -z "$surum" ]; then
info "surum: $surum"
2016-02-24 01:27:23 +01:00
fi
2017-10-28 15:21:27 +02:00
if [ ! -z "$devir" ]; then
info "devir: $devir"
2016-02-24 01:27:23 +01:00
fi
if [ ! -z "$group" ]; then
2016-03-07 00:39:49 +01:00
info "grup: $group"
2016-02-24 01:27:23 +01:00
fi
2017-11-01 14:46:54 +01:00
HASH_KONTROL_DOSYA="$isim.hash"
2016-03-07 00:39:49 +01:00
check_directory "$DERLEME_KAYNAKDIZIN"
2017-04-25 21:52:52 +02:00
check_directory "$PAKETLEME_DIZIN"
2016-03-07 00:39:49 +01:00
check_directory "`dirname $DERLEME_SANTIYE`"
2016-02-24 01:27:23 +01:00
check_pkgfile
get_package_list
2016-03-07 00:39:49 +01:00
case $PKT_SIKISTIRMA_MODU in
2016-02-24 01:27:23 +01:00
lz|gz|bz2|xz)
if [ -z $TARGETS ]; then
2017-10-28 15:21:27 +02:00
TARGET="$PAKETLEME_DIZIN/${isim}#$surum-MIMARI.$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU"
2016-02-24 01:27:23 +01:00
fi;;
*)
2017-10-28 15:21:27 +02:00
error "Sıkıştırma modu '$PKT_SIKISTIRMA_MODU' desteklenmiyor"
2016-02-24 01:27:23 +01:00
exit $E_GENERAL
;;
esac
2016-03-07 00:39:49 +01:00
case $PKT_SIKISTIRMA_MODU in
2016-02-24 01:27:23 +01:00
gz) COMPRESSION="-z" ;;
bz2) export COMPRESSION="-j" ;;
xz) export COMPRESSION="-J" ;;
esac
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_CLEAN_ONLY" = "evet" ]; then
2016-02-24 01:27:23 +01:00
clean
remove_source
update_repo
exit 0
fi
2017-10-27 23:09:55 +02:00
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_UPDATE_REPO" = "evet" ]; then
2016-02-24 01:27:23 +01:00
update_repo
exit 0
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_UPDATE_FOOTPRINT" = "evet" ]; then
2016-02-24 01:27:23 +01:00
update_footprint
exit 0
fi
2016-03-07 00:39:49 +01:00
if [ "$SOZDIZIM_KONTROL" = "evet" ]; then
2017-11-01 19:18:48 +01:00
info "tanım: $description"
2016-03-07 00:39:49 +01:00
info "url: $url"
2017-11-01 19:18:48 +01:00
info "paketçi: $packager"
info "tamirci: $maintainer"
2016-02-24 01:27:23 +01:00
exit 0
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_DOWNLOAD_ONLY" = "evet" ]; then
2017-10-28 15:21:27 +02:00
kaynak_indir
2016-02-24 01:27:23 +01:00
exit 0
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_EXTRACT_ONLY" = "evet" ]; then
2017-10-28 15:21:27 +02:00
kaynak_indir
2016-02-24 01:27:23 +01:00
make_work_dir
2017-10-28 15:21:27 +02:00
info "Extracting sources of package '${isim}-$surum'."
2016-02-24 01:27:23 +01:00
unpack_source
exit 0
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_UP_TO_DATE" = "evet" ]; then
2016-02-24 01:27:23 +01:00
if [ ! -z $TARGETS ]; then
for TARGET in ${TARGETS[@]}; do
2016-03-07 00:39:49 +01:00
if [ "`build_needed`" = "evet" ]; then
2016-02-24 01:27:23 +01:00
info "Package '$TARGET' is not up to date."
else
info "Package '$TARGET' is up to date."
fi
done
else
2016-03-07 00:39:49 +01:00
if [ "`build_needed`" = "evet" ]; then
2016-02-24 01:27:23 +01:00
info "Package '$TARGET' is not up to date."
else
info "Package '$TARGET' is up to date."
fi
fi
exit 0
fi
# From here on it's need to check the base package not any group which means
if [ -z $TARGETS ]; then
2017-10-28 15:21:27 +02:00
TARGET=$PAKETLEME_DIZIN/${isim}#$surum-$MIMARI.$PKT_UZANTISI.$PKT_SIKISTIRMA_MODU
2017-11-01 19:18:48 +01:00
if [ "`build_needed`" = "yok" ] && [ "$PKGMK_FORCE" = "yok" ]; then
2016-02-24 01:27:23 +01:00
info "Package '$TARGET' is up to date."
else
2017-10-28 15:21:27 +02:00
kaynak_indir
2017-10-27 23:59:41 +02:00
derleme_yap
2016-02-24 01:27:23 +01:00
fi
else
FOUND=false
for TARGET in ${TARGETS[@]}; do
2017-11-01 19:18:48 +01:00
if [ "`build_needed`" = "yok" ] && [ "$PKGMK_FORCE" = "yok" ]; then
2017-04-25 21:52:52 +02:00
if [ "`get_package_arch $TARGET`" = "$MIMARI" ]; then
2016-02-24 01:27:23 +01:00
FOUND=true
fi
info "Package '$TARGET' is up to date."
else
2017-10-28 15:21:27 +02:00
kaynak_indir
2017-10-27 23:59:41 +02:00
derleme_yap
2016-02-24 01:27:23 +01:00
break
fi
done
fi
if [ ! -z $FOUND ] ; then
if [ $FOUND != true ]; then
2017-10-28 15:21:27 +02:00
kaynak_indir
2016-02-24 01:27:23 +01:00
PKGMK_BUILDVER="`get_package_builddate $TARGET`"
2017-10-28 15:21:27 +02:00
TARGET=$PAKETLEME_DIZIN/${isim}#$surum-$MIMARI.$PKT_UZANTISI
2017-10-27 23:59:41 +02:00
derleme_yap $TARGET
2016-02-24 01:27:23 +01:00
fi
fi
2016-03-07 00:39:49 +01:00
if [ "$DERLE_KUR" != "yok" ]; then
2016-02-24 01:27:23 +01:00
install_package
fi
2016-03-07 00:39:49 +01:00
if [ "$PKT_SIKISTIRMA" = "evet" ]; then
2017-04-25 21:52:52 +02:00
cd $PAKETLEME_DIZIN
2016-02-24 01:27:23 +01:00
get_package_list
for TARGET in ${TARGETS[@]}; do
2016-03-07 00:39:49 +01:00
if [ "${TARGET:$((${#TARGET} - ${#PKT_UZANTISI} ))}" == "$PKT_UZANTISI" ]; then
2016-02-24 01:27:23 +01:00
compress_archive $TARGET
fi
done
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_KEEP_SOURCES" != "evet" ]; then
2016-02-24 01:27:23 +01:00
remove_source
fi
2016-03-07 00:39:49 +01:00
if [ "$PKGMK_CLEAN" != "yok" ]; then
2016-02-24 01:27:23 +01:00
clean
unset TARGETS
2016-03-07 00:39:49 +01:00
if [ "$REPO_YOKSAY" == "evet" ];then
2016-02-24 01:27:23 +01:00
clean_repo_files
fi
fi
2016-03-07 00:39:49 +01:00
if [ "$REPO_YOKSAY" != "evet" ] && [ "$PKGMK_CLEAN" != "evet" ]; then
2016-02-24 01:27:23 +01:00
update_repo
fi
2017-10-27 23:09:55 +02:00
2016-02-24 01:27:23 +01:00
exit 0
}
trap "interrupted" SIGHUP SIGINT SIGQUIT SIGTERM
export LC_ALL=POSIX
2016-03-07 00:39:49 +01:00
DERLEME_AYARDOSYASI="/etc/mpsd.conf"
2017-11-01 14:46:54 +01:00
ANADERLEME_AYARDOSYASI="/sources/milis.git/ayarlar/mpsd.conf"
2016-02-24 01:27:23 +01:00
readonly PKGMK_VERSION="1.0"
readonly PKGMK_COMMAND="$0"
readonly PKGMK_ROOT="$PWD"
2017-04-25 21:52:52 +02:00
PAKETLEME_DIZIN="$PWD"
2016-02-24 01:27:23 +01:00
PKGMK_BUILDVER=`date +%s`
#PKGMK_BUILDVER="#"
2016-03-07 00:39:49 +01:00
PKT_UZANTISI="mps"
2016-02-24 01:27:23 +01:00
2016-03-07 00:39:49 +01:00
REPO_DOSYASI=".PKGREPO"
2016-02-24 01:27:23 +01:00
PKGMK_PKGFILE="talimat"
PKGMK_NOSTRIP=".nostrip"
2016-03-07 00:39:49 +01:00
PKGMK_KEEP_SOURCES="yok"
PKGMK_CLEAN="evet"
2016-02-24 01:27:23 +01:00
PAKET_KURMA="evet"
2016-03-07 00:39:49 +01:00
PAKET_GRUPLAR=()
2016-03-19 01:55:02 +01:00
PAKET_LOKAL="tr"
2016-02-24 01:27:23 +01:00
PKGMK_SOURCE_MIRRORS=()
2016-03-07 00:39:49 +01:00
DERLEME_KAYNAKDIZIN="$PWD"
DERLEME_SANTIYE="$PWD/work"
PKGMK_DOWNLOAD="yok"
DOSYAIZLEME_YOKSAY="evet"
PKGMK_IGNORE_NEW="evet"
2017-11-01 19:18:48 +01:00
SHASUM_KONTROL_YAP="evet"
2017-10-28 01:04:15 +02:00
DEVIR_YOKSAY="yok"
2016-03-07 00:39:49 +01:00
REPO_YOKSAY="evet"
PKGMK_NO_STRIP="yok"
PKT_SIKISTIRMA_MODU="lz"
PKT_SIKISTIRMA="yok"
DERLE_KUR="yok"
PKGMK_RECURSIVE="yok"
PKGMK_DOWNLOAD_ONLY="yok"
PKGMK_EXTRACT_ONLY="yok"
PKGMK_IGNORE_UNPACK="yok"
PKGMK_UP_TO_DATE="yok"
PKGMK_UPDATE_FOOTPRINT="yok"
PKGMK_FORCE="yok"
PKGMK_KEEP_WORK="yok"
2016-02-24 01:27:23 +01:00
main "$@"
# End of file