#!/bin/sh # ===================================================================== # Projet : DARKMAKE # Fichier : autoupdate # Auteur : Nicolas "DarkHack" Chapuis (c) 2026 # ================== DARKHACK ================== # [ darkweb.fr - system online ] # Powered by Perplexity, your AI assistant # [https://www.perplexity.ai](https://www.perplexity.ai) # ============================================== # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ===================================================================== rootDarkMake="${rootDarkMake:-/etc/darkmake}" if ! type "shInclude" > /dev/null; then . /etc/darksh/lib/shTools shLog="${shLog:-autoupdate-init}" shDebugEnable="${shDebugEnable:-1}" shDebug "$*" fi $(shInclude ${rootDarkMake}/pkg/lib-sh/pkg-config) cmdAutoupdate="${cmdAutoupdate:-$(which autoupdate)}" cmdAutoscan="${cmdAutoscan:-$(which autoscan)}" shErrorOnMissing "pkgSrc pkgDirLog" shErrorOnMissing "cmdAutoupdate cmdAutoscan" #shDebug 1 "M4:$M4 M4DIR:$M4DIR" # / END INCLUDE M4 # TOOL CHAIN PARAM AUTOUPDATE_PARAM="${AUTOUPDATE_PARAM:-$M4DIR --verbose}" AUTOSCAN_CONF="${AUTOSCAN_CONF:-$M4DIR --verbose}" # shDebug 1 "AUTOUPDATE INIT ========================" #for amINFile in $(find $pkgSrc | grep Makefile$);do # amINFolder="$(echo $amINFile | rev | cut -f 2- -d/ | rev | tr -d '[:space:]' )" # amINFileName="$(echo ${amINFile} | rev | cut -f 1 -d/ | rev | tr -d '[:space:]')" # if [ ! -f "${amINFolder}/${amINFileName}.in" ];then # if [ -f "${amINFolder}/${amINFileName}.am" ];then # echo cp "${amINFolder}/${amINFileName}.am" "${amINFolder}/${amINFileName}.in"; # cp "${amINFolder}/${amINFileName}.am" "${amINFolder}/${amINFileName}.in"; # else # echo cp $amINFile "${amINFolder}/${amINFileName}.in"; # cp $amINFile "${amINFolder}/${amINFileName}.in"; # fi # fi #done #for amINFile in $( find $pkgSrc | grep "configure$" );do # amINFolder="$(echo $amINFile | rev | cut -f 2- -d/ | rev | tr -d '[:space:]' )" # amINFileName="$(echo ${amINFile} | rev | cut -f 1 -d/ | rev | tr -d '[:space:]')" # if [ ! -f "${amINFolder}/${amINFileName}.in" ] && [ ! -f "${amINFolder}/${amINFileName}.ac" ];then # echo mv $amINFile "${amINFolder}/${amINFileName}.in"; # mv $amINFile "${amINFolder}/${amINFileName}.in"; # else # mv $amINFile "${amINFolder}/${amINFileName}.oldautoupdate"; # fi #done for amINFile in $( find $pkgSrc | egrep "configure.(ac|in)$" );do amINFolder="$(echo $amINFile | rev | cut -f 2- -d/ | rev | tr -d '[:space:]' )" amINFileName="$(echo ${amINFile} | rev | cut -f 1 -d/ | rev | tr -d '[:space:]')" alignFile="${amINFolder}/${amINFileName}" if [ -f "$alignFile" ];then if [ ! -f "${alignFile}-origine" ];then cp "$amINFile" "${alignFile}-origine" fi # Correctifs spécifiques Autoconf / Libtool. shDebug 0 "sed -i.sedorigin 's|AC_REQUIRE(AC_CANONICAL_HOST)_LT_SET_OPTION(\[LT_INIT\],\[win32-dll\])|AC_LIBTOOL_WIN32_DLL|g' "${alignFile}"" sed -i.sedorigin 's|AC_REQUIRE(AC_CANONICAL_HOST)_LT_SET_OPTION(\[LT_INIT\],\[win32-dll\])|AC_LIBTOOL_WIN32_DLL|g' "${alignFile}" # shDebug 0 "sed -i 's|LT_INIT|AC_PROG_LIBTOOL|g' "${file}"" # sed -i "s|LT_INIT|AC_PROG_LIBTOOL|g" "${file}" awk ' /^[[:space:]]*#[[:space:]]/ && /AC_PROG_CC_(STDC|C89|C99)|AC_LIBTOOL_WIN32_DLL/ { sub(/#[[:space:]]*/, "dnl ") sub(/_/, "-") print next } /^[[:space:]]*AC_PROG_CC_(STDC|C89|C99)[[:space:]]*$/ { print "dnl DarkMake: obsolete compiler-mode check; AC_PROG_CC handles it." next } /^[[:space:]]*AC_HEADER_STDC[[:space:]]*$/ { print "dnl DarkMake: preserve checks from the former standard-header macro." print "dnl AC_CHECK_INCLUDES_DEFAULT" print "AC_PROG_EGREP" next } { print } ' "$alignFile" > "$alignFile.awk-tmp" && mv "$alignFile.awk-tmp" "$alignFile" #awk ' #/^[[:space:]]*AC_CONFIG_HEADER.*$/ { # print "AC_CONFIG_HEADER([config.h])" # print "AC_CONFIG_MACRO_DIRS([m4])" # next #} #/^[[:space:]]*AC_PROG_RANLIB[[:space:]]*$/ { # print "LT_INIT" # next #} #/^[[:space:]]*AC_HEADER_TIME[[:space:]]*$/ { # print "dnl DarkMake: AC_HEADER_TIME." # print "AC_CHECK_HEADERS_ONCE([sys/time.h])" # next #} # #{ print } #' "$alignFile" > "$alignFile.awk-tmp" && #mv "$alignFile.awk-tmp" "$alignFile" fi done folder="$pkgSrc" if [ ! -d "$folder" ];then shDebug 0 "AUTOCONF INIT = NOT AN FOLDER:$folder !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; else if [ -f "$folder/touchDW_autoupdate" ] && [ -z "$autoupdateForce" ];then shDebug 1 "autoupdate ever done." else touch "$folder/touchDW_autoupdate" cpt=0 cptAutoUpdate=0 autoconflog="${pkgDirLog}/0_autoupdate" cpt=$((cpt + 1 )); shDebug 1 "autoupdate:$folder" if [ ! -d "$autoconflog" ];then mkdir "$autoconflog";fi if [ -n "$acLocalList" ];then # acLocalList="${acLocalList:-}" acLocalDests="${acLocalDests:-${pkgSrc}}" fileLog="${autoconflog}/${cpt}-m4.log" echo "$(date) ========= M4" >> "${fileLog}" 2>&1 shDebug 1 "autoconf/autoupdate acLocalList:${acLocalList}" >> "${fileLog}" 2>&1 acLocalAllDest="" for acLocalDest in ${acLocalDests} ;do if [ -z "${acLocalDest}" ];then continue;fi if [ -n "${acLocalAllDest}" ];then acLocalAllDest="${acLocalAllDest} ${acLocalDest}/m4"; else acLocalAllDest="${acLocalDest}/m4";fi done for acLocalDest in ${acLocalFullDests} ;do if [ -z "${acLocalDest}" ];then continue;fi if [ -n "${acLocalAllDest}" ];then acLocalAllDest="${acLocalAllDest} ${acLocalDest}"; else acLocalAllDest="${acLocalDest}";fi done for acLocalDest in ${acLocalAllDest} ;do if [ -z "${acLocalDest}" ];then continue;fi [ ! -d "${acLocalDest}" ] && mkdir "${acLocalDest}" for acLocalFile in ${acLocalList};do # if [ -f "${acLocalDest}/$acLocalFile" ];then # shDebug 1 "autoconf libtool aclocal m4 replace ${acLocalFile} ${acLocalDest} !" # rm ${acLocalDest}/$acLocalFile # else # shDebug 1 "autoconf libtool aclocal m4 missing ${acLocalFile} ${acLocalDest} !" # fi for acLocalSrc in /usr/share/aclocal /usr/share/gnulib/autotools/m4;do if [ -f "${acLocalSrc}/${acLocalFile}" ] && [ ! -f "${acLocalDest}/${acLocalFile}" ];then shDebug 1 "autoconf/autoupdate for libtool m4 cp missing ${acLocalSrc}/${acLocalFile} ${acLocalDest}" cp "${acLocalSrc}/${acLocalFile}" "${acLocalDest}/${acLocalFile}" \ && shDebug 1 cp "${acLocalSrc}/${acLocalFile}" "${acLocalDest}/${acLocalFile}" >> "${fileLog}" 2>&1 fi done done done fi cd $folder for file in $(find "$folder" | grep "^.*\.in$" | tr '\n' ' ') $(find "$folder" | grep "^.*\.ac$" | tr '\n' ' ') \ $(find "$folder" | grep "^.*\.am$" | tr '\n' ' ');do # $(find "$folder" | grep "^.*\.m4$" | tr '\n' ' ');do if [ -f "$file" ];then $(which echo) -e "$file\r\c" cptAutoUpdate=$((cptAutoUpdate + 1 )); fileLog="$autoconflog/${cptAutoUpdate}-$(echo $file | rev | cut -d/ -f 1 | rev | tr -d '[:space:]').log" printEnv > $fileLog echo $cmdAutoupdate $AUTOUPDATE_PARAM "$file" >> $fileLog $cmdAutoupdate $AUTOUPDATE_PARAM "$file" >> $fileLog 2>&1 fi done if [ -n "${autoupdateResetConfigure}" ];then if [ -f "${folder}/configure" ];then shDebug 1 "mv "${folder}/configure" "${folder}/configure.autoupdate-origine"" mv "${folder}/configure" "${folder}/configure.autoupdate-origine" fi fi fi fi autoconflog="$pkgDirLog/1_autoscan" cptFolder=0 for file in $filesToInit;do if [ -f "${file}" ];then continue;fi if [ ! -d "$autoconflog" ];then mkdir "$autoconflog";fi cptFolder=$(( cptFolder + 1 )) folder=$( echo "$file" | rev | cut -f2- -d'/' | rev ) subFolder="$(shDirGetSubFolder $pkgSrc $folder)" strSubId="$(shDirGenerateSubId $pkgSrc $folder)" # [ ! -d "${folder}/build-aux" ] && mkdir "${folder}/build-aux" # fileLog="${autoconflog}/XX0_libtool_buildaux.log" # echo "$(date) ======= LIBTOOL BUILD-AUX" > $fileLog 2>&1 # shDebug 1 "autoupdate libtool init BUILD-AUX ${subFolder}/build-aux" ## for buildAuxFile in "install-sh" "install.sh" "shtool";do # for buildAuxFile in $( ls /usr/share/libtool/build-aux );do # srcBuildAuxFile="/usr/share/libtool/build-aux/${buildAuxFile}" # pkgBuildAuxFile="${folder}/build-aux/${buildAuxFile}" # if [ ! -f "${pkgBuildAuxFile}" ] && [ ! -d "${pkgBuildAuxFile}" ];then # cp "${srcBuildAuxFile}" "${pkgBuildAuxFile}" \ # && echo cp "${srcBuildAuxFile}" "${pkgBuildAuxFile}" >> $fileLog 2>&1 # fi # done # # fileLog="${autoconflog}/XX1_gnulib_buildaux.log" # echo "$(date) ======= GNULIB BUILD-AUX" > $fileLog 2>&1 # shDebug 1 "autoupdate gnulib init BUILD-AUX ${subFolder}/build-aux" ## for buildAuxFile in "install-sh" "install.sh" "shtool";do # for buildAuxFile in $( ls /usr/share/gnulib/build-aux );do # srcBuildAuxFile="/usr/share/gnulib/build-aux/${buildAuxFile}" # pkgBuildAuxFile="${folder}/build-aux/${buildAuxFile}" # if [ ! -f "${pkgBuildAuxFile}" ] && [ ! -d "${pkgBuildAuxFile}" ];then # cp "${srcBuildAuxFile}" "${pkgBuildAuxFile}" \ # && echo cp "${srcBuildAuxFile}" "${pkgBuildAuxFile}" >> $fileLog 2>&1 # fi # done if [ -f "$folder/autoscan.ac" ];then continue;fi cd "$folder" reflog="autoscan[ $cptFolder $subFolder ]" # shDebug 1 "${reflog} ${cptAutoUpdate}-autoscan.log ( $AUTOSCAN_CONF )" fileLog="$autoconflog/${strSubId}-0-autoscan.log" printEnv > $fileLog echo $cmdAutoscan $AUTOSCAN_CONF >> $fileLog LIBTOOLIZE="${cmdLibtoolize}" LIBTOOL="${LIBTOOL}" \ AUTOM4TE="${cmdAutom4te}" AUTOCONF="${cmdAutoconf}" AUTOHEADER="${cmdAutoheader}" AUTOMAKE="${cmdAutomake}" ACLOCAL="${cmdAclocal}" \ AUTOPOINT="${cmdAutopoint}" AUTOUPDATE="${cmdAutoupdate}" AUTOSCAN="${cmdAutoscan}" \ $cmdAutoscan $AUTOSCAN_CONF >> $fileLog 2>&1 if [ ! -f "$folder/configure.scan" ];then #shDebug 1 "${reflog} [${cptFolder}]:echec!!!" echo "NO $folder/CONFIGURE.SCAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> $fileLog else mv "$folder/configure.scan" "$folder/autoscan.ac" if [ ! -f "$folder/configure.ac" ] && [ ! -f "$folder/configure.in" ] ;then shDebug 0 "${reflog} [${cptFolder}]:no configure.[ac|in] !" # shDebug 0 "${reflog} [${cptFolder}]:put configure.scan to configure.ac !" # echo "mv $folder/configure.scan $folder/configure.ac !!!!!!!!!!!!!!!!!" >> $fileLog # mv "$folder/configure.scan" "$folder/configure.ac" file="$folder/autoscan.ac" # sed -i "s/AC_CONFIG_HEADERS.*/AC_CONFIG_HEADERS([config.h])\nAC_CONFIG_MACRO_DIRS([m4])/g" "${file}" else shDebug 0 "${reflog} [${cptFolder}]:no replace configure.ac !" #shDebug 0 "file configure.ac ever exist we destroy it!!" #echo "file configure.ac ever exist we destroy it." >> $fileLog file="$folder/autoscan.ac" fi fi if [ -f "$file" ];then $(which echo) -e "$file\r\c" fileLog="$autoconflog/${strSubId}-1-autoupdate.log" printEnv > $fileLog echo $cmdAutoupdate $AUTOUPDATE_PARAM "$file" >> $fileLog LIBTOOLIZE="${cmdLibtoolize}" LIBTOOL="${LIBTOOL}" \ AUTOM4TE="${cmdAutom4te}" AUTOCONF="${cmdAutoconf}" AUTOHEADER="${cmdAutoheader}" AUTOMAKE="${cmdAutomake}" ACLOCAL="${cmdAclocal}" \ AUTOPOINT="${cmdAutopoint}" AUTOUPDATE="${cmdAutoupdate}" AUTOSCAN="${cmdAutoscan}" \ $cmdAutoupdate $AUTOUPDATE_PARAM "$file" >> $fileLog 2>&1 fi done #echo "===== END AUTOUPDATE" # YACC="$YACC" INTLBISON="$INTLBISON" CC="$CC" CXX="$CXX" m4="$M4"\ # GNULIB_SRCDIR="$GNULIB_SRCDIR" GNULIB_TOOL="$GNULIB_TOOL" \ # LIBGNU_LIBS="$LIBGNU_LIBS" LIBGNU_CFLAGS="$LIBGNU_CFLAGS" LIBGNU_PATH="$LIBGNU_PATH" \ # LIBTOOL_LIBS="$LIBTOOL_LIBS" LIBTOOL_CFLAGS="$LIBTOOL_CFLAGS" LIBTOOL_PATH="$LIBTOOL_PATH" LIBTOOL="$LIBTOOL" LIBTOOLIZE="$LIBTOOLIZE" \ # PATH="$PATH" LIBRARY_PATH="$LIBRARY_PATH" LD_RUN_PATH="$LD_RUN_PATH" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" M4DIR="$M4DIR" \ # LIBS="$LIBS" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" \