我有 3 个脚本来构建 OpenWrt,但我无法将其设置为最后有时间。这是脚本给出的内容和脚本。
openwrt-snapshot-r22256+29-14334c222e-ipq806x-generic-linksys_ea8500-sysupgrade.bin
但我想要那种随着时间的描述:
openwrt-snapshot-r22256+29-14334c222e-20230310-ipq806x-generic-linksys_ea8500-sysupgrade.bin
剧本:
#!/bin/bash
# createbuildinfo
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/shared
STATUSFILE="$BINDIR/$BUILTBASENAME.status"
DIFFFILE="$BINDIR/$BUILTBASENAME.patch"
DIFFCONFIGFILE="$BINDIR/$BUILTBASENAME.diffconfig"
DATE=$(date +%Y%m%d-%H%M)
cd $BUILDROOT
echo "Creating build info for"
echo " $BUILTBASENAME in"
echo " $BINDIR "
getGitInfo() {
#params: directory
echo "###########################################################################"
(cd $1
echo -n "Repo : "
git remote -v show | grep fetch
echo -n "Branch : "
git rev-parse --abbrev-ref HEAD
echo -n "Commit : "
git show --format="%cd %h %s" --abbrev=7 --date=short | head -n 1 | cut -b1-60
echo "Status : "
git status --porcelain
)
}
getGitDiff() {
(cd $1
git --no-pager diff HEAD
)
}
echo "Generating git statusfile $STATUSFILE"
echo "Status for $BUILTBASENAME created $DATE" >$STATUSFILE
echo " " >>$STATUSFILE
getGitInfo $BUILDROOT >>$STATUSFILE
for feed in `cat feeds.conf | grep -v "^#" | awk '{print $2}'`
do
getGitInfo $BUILDROOT/feeds/$feed >>${STATUSFILE}
done
echo "Generating diff file $DIFFFILE"
getGitDiff $BUILDROOT >$DIFFFILE
echo "Generating diffconfile $DIFFCONFIGFILE"
$BUILDROOT/scripts/diffconfig.sh > $DIFFCONFIGFILE
#共享
#!/bin/bash
BRANCH="snapshot"
BUILDROOT="/run/media/james/D/ipq806x_builds/NSS_test/"
BUILTDIR="$BUILDROOT/../builds"
VERSION_NUMBER=$($BUILDROOT/scripts/getver.sh)
VERSION_DIST=$(grep CONFIG_VERSION_DIST $BUILDROOT/.config | awk -F\" '{print $2}')
VERSION_DIST="${VERSION_DIST:=OpenWRT}"
TARGET_PROFILE=$(grep CONFIG_TARGET_PROFILE $BUILDROOT/.config | awk -F\" '{print $2}' | sed 's/DEVICE_//')
TARGET_SUBTARGET=$(grep CONFIG_TARGET_SUBTARGET $BUILDROOT/.config | awk -F\" '{print $2}')
TARGET_BOARD=$(grep CONFIG_TARGET_BOARD $BUILDROOT/.config | awk -F\" '{print $2}')
BUILTBASENAME="${VERSION_DIST}-${BRANCH}-${VERSION_NUMBER}-${TARGET_BOARD}-${TARGET_SUBTARGET}-${TARGET_PROFILE}"
BUILTBASENAME=$(echo $BUILTBASENAME | sed 's/ /-/g' | awk '{print tolower($0)}')
BINDIR="$BUILDROOT/bin/targets/${TARGET_BOARD}/${TARGET_SUBTARGET}"
#createbuild
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/shared
echo "#### `date`: Starting build of $VERSION_DIST $VERSION_NUMBER ####"
cd $BUILDROOT
time make -j4 V=s 2>&1 $1 | tee build.log | grep -i -E "^make.*(error|[12345]...Entering dir)"
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
echo -en "\007"
echo "#### `date`: Build failed, bailing out... "
exit 1
fi
echo -en "\007"
echo "#### `date`: Build of $VERSION_DIST $VERSION_NUMBER complete ###"
if [ -z $1 ]; then
${SCRIPT_DIR}/createbuildinfo
echo "#### `date`: Moving completed build to $BUILTDIR/$BUILTBASENAME ####"
mkdir -p $BUILTDIR/$BUILTBASENAME
#mv -v $BINDIR/$BUILTBASENAME* $BUILTDIR/$BUILTBASENAME
mv -v /run/media/james/D/ipq806x_builds/NSS_test/bin/targets/ipq806x/generic/*.bin /run/media/james/D/ipq806x_builds/builds/latest/
rm $BUILTDIR/latest
ln -s $BUILTDIR/$BUILTBASENAME $BUILTDIR/latest
echo "All done! Sysupgrade file can be found in"
echo $BUILTDIR/latest/$BUILTBASENAME-squashfs-sysupgrade.bin
fi