221 lines
7 KiB
Bash
Executable file
221 lines
7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# PikeOS → UniversalISOS rebrand
|
|
set -euo pipefail
|
|
|
|
BASE="/home/fabiorafaelcoutada/portugalfuturista/universalisos"
|
|
SRC="$BASE/src"
|
|
DST="$BASE/pikeos-rebrand"
|
|
LOGDIR="$BASE/rebrand-logs"
|
|
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
|
|
|
mkdir -p "$DST" "$LOGDIR"
|
|
|
|
echo "============================================"
|
|
echo " PikeOS → UniversalISOS Rebrand"
|
|
echo " $(date)"
|
|
echo "============================================"
|
|
|
|
# ============================================
|
|
# PHASE 1: Copy source directories
|
|
# ============================================
|
|
echo ""
|
|
echo ">>> PHASE 1: Copying source directories..."
|
|
for dir in rpm scov share config cdk build; do
|
|
echo " Copying $dir..."
|
|
if [[ "$dir" == "build" ]]; then
|
|
# Exclude build logs (332 MB of historical CI output, not source)
|
|
rsync -a --exclude='log/BUILD-LOGS/' "$SRC/$dir/" "$DST/$dir/"
|
|
else
|
|
rsync -a "$SRC/$dir/" "$DST/$dir/"
|
|
fi
|
|
echo " ✓ $dir copied"
|
|
done
|
|
|
|
# Verify file counts
|
|
echo ""
|
|
echo " File count verification:"
|
|
for dir in rpm scov share config cdk build; do
|
|
SRC_COUNT=$(find "$SRC/$dir" -type f 2>/dev/null | wc -l)
|
|
DST_COUNT=$(find "$DST/$dir" -type f 2>/dev/null | wc -l)
|
|
if [[ "$dir" == "build" ]]; then
|
|
# build has excluded BUILD-LOGS, so counts will differ
|
|
echo " $dir: src=$SRC_COUNT dst=$DST_COUNT (BUILD-LOGS excluded)"
|
|
elif [[ "$SRC_COUNT" != "$DST_COUNT" ]]; then
|
|
echo " ⚠ MISMATCH: $dir src=$SRC_COUNT dst=$DST_COUNT"
|
|
else
|
|
echo " ✓ $dir: $DST_COUNT files"
|
|
fi
|
|
done
|
|
|
|
# ============================================
|
|
# PHASE 2: Rename files and directories containing 'pikeos'
|
|
# ============================================
|
|
echo ""
|
|
echo ">>> PHASE 2: Renaming files/directories with 'pikeos' in name..."
|
|
|
|
for dir in rpm scov share config cdk build; do
|
|
echo " Processing $dir..."
|
|
|
|
# Rename files (bottom-up via -depth)
|
|
find "$DST/$dir" -type f -iname '*pikeos*' -depth -print0 2>/dev/null | while IFS= read -r -d '' filepath; do
|
|
dirpath=$(dirname "$filepath")
|
|
base=$(basename "$filepath")
|
|
new=$(echo "$base" | sed \
|
|
-e 's/PIKEOS/UNIVERSALISOS/g' \
|
|
-e 's/PikeOS/UniversalISOS/g' \
|
|
-e 's/pikeos/universalisos/g')
|
|
if [[ "$base" != "$new" ]]; then
|
|
mv "$filepath" "$dirpath/$new"
|
|
fi
|
|
done
|
|
|
|
# Rename directories (deepest first via -depth)
|
|
find "$DST/$dir" -type d -iname '*pikeos*' -depth -print0 2>/dev/null | while IFS= read -r -d '' dirpath; do
|
|
parent=$(dirname "$dirpath")
|
|
base=$(basename "$dirpath")
|
|
new=$(echo "$base" | sed \
|
|
-e 's/PIKEOS/UNIVERSALISOS/g' \
|
|
-e 's/PikeOS/UniversalISOS/g' \
|
|
-e 's/pikeos/universalisos/g')
|
|
if [[ "$base" != "$new" ]]; then
|
|
mv "$dirpath" "$parent/$new"
|
|
fi
|
|
done
|
|
|
|
echo " ✓ $dir renames done"
|
|
done
|
|
|
|
# ============================================
|
|
# PHASE 3: Text content replacement (binary-safe)
|
|
# ============================================
|
|
echo ""
|
|
echo ">>> PHASE 3: Text content replacement..."
|
|
|
|
# Helper function: apply all PikeOS→UniversalISOS replacements to a file
|
|
apply_replacements() {
|
|
sed -i \
|
|
-e 's|/opt/pikeos-D5\.0|/opt/universalisos-D5.0|g' \
|
|
-e 's|/opt/sbe-D3\.1|/opt/universalisos-sbe-D3.1|g' \
|
|
-e 's/SYSGO AG/Portugal Futurista/g' \
|
|
-e 's/SYSGO/Portugal Futurista/g' \
|
|
-e 's/PIKEOS/UNIVERSALISOS/g' \
|
|
-e 's/PikeOS/UniversalISOS/g' \
|
|
-e 's/pikeos-/universalisos-/g' \
|
|
-e 's/pikeos/universalisos/g' \
|
|
-e 's/%_pikeos_/%_universalisos_/g' \
|
|
"$1"
|
|
}
|
|
|
|
# Process all text files, skip BUILD-LOGS
|
|
FILECOUNT=0
|
|
while IFS= read -r -d '' f; do
|
|
mime=$(file --mime-type -b "$f" 2>/dev/null)
|
|
case "$mime" in
|
|
text/*|application/json|application/xml|application/javascript|application/x-shellscript|application/x-perl|application/x-python*)
|
|
apply_replacements "$f"
|
|
FILECOUNT=$((FILECOUNT + 1))
|
|
;;
|
|
esac
|
|
done < <(find "$DST" -type f -not -path "*/log/BUILD-LOGS/*" -print0)
|
|
|
|
echo " Processed $FILECOUNT text files"
|
|
|
|
# Special: rename UOSX_ADT_ prefix in build/adt C source
|
|
if [[ -d "$DST/build/adt" ]]; then
|
|
echo " Renaming UOSX_ADT_ prefix in build/adt..."
|
|
find "$DST/build/adt" -type f \( -name '*.c' -o -name '*.h' \) -print0 2>/dev/null | \
|
|
xargs -0 sed -i 's/UOSX_ADT_/UOSX_UNIVERSALISOS_ADT_/g'
|
|
echo " ✓ ADT prefix renamed"
|
|
fi
|
|
|
|
# ============================================
|
|
# PHASE 4: Verification
|
|
# ============================================
|
|
echo ""
|
|
echo ">>> PHASE 4: Verification"
|
|
|
|
REPORT="$LOGDIR/verification-report-${TIMESTAMP}.txt"
|
|
|
|
{
|
|
echo "=== PikeOS → UniversalISOS Rebrand Verification ==="
|
|
echo "Date: $(date)"
|
|
echo ""
|
|
|
|
# Check remaining pikeos references
|
|
REMAINING_PIKEOS=$(grep -rIl 'PikeOS\|pikeos\|PIKEOS' "$DST" 2>/dev/null | wc -l)
|
|
echo "Files still containing pikeos/PikeOS/PIKEOS: $REMAINING_PIKEOS"
|
|
if (( REMAINING_PIKEOS > 0 )); then
|
|
echo " Details (first 20):"
|
|
grep -rIl 'PikeOS\|pikeos\|PIKEOS' "$DST" 2>/dev/null | head -20 | while read f; do
|
|
echo " $f"
|
|
done
|
|
fi
|
|
|
|
# Check remaining SYSGO references
|
|
REMAINING_SYSGO=$(grep -rIl 'SYSGO' "$DST" 2>/dev/null | wc -l)
|
|
echo ""
|
|
echo "Files still containing SYSGO: $REMAINING_SYSGO"
|
|
if (( REMAINING_SYSGO > 0 )); then
|
|
echo " Details (first 20):"
|
|
grep -rIl 'SYSGO' "$DST" 2>/dev/null | head -20 | while read f; do
|
|
echo " $f"
|
|
done
|
|
fi
|
|
|
|
# Check old paths
|
|
REMAINING_OLDPATH=$(grep -rIl '/opt/pikeos' "$DST" 2>/dev/null | wc -l)
|
|
echo ""
|
|
echo "Files still containing /opt/pikeos: $REMAINING_OLDPATH"
|
|
|
|
REMAINING_SBE=$(grep -rIl '/opt/sbe-D3' "$DST" 2>/dev/null | wc -l)
|
|
echo "Files still containing /opt/sbe-D3: $REMAINING_SBE"
|
|
|
|
# Critical file checks
|
|
echo ""
|
|
echo "=== Critical file checks ==="
|
|
if [[ -f "$DST/rpm/lib/rpm/macros" ]]; then
|
|
if grep -q '/opt/universalisos-D5.0' "$DST/rpm/lib/rpm/macros"; then
|
|
echo " ✓ RPM macros: paths updated"
|
|
else
|
|
echo " ✗ RPM macros: paths NOT updated"
|
|
fi
|
|
if grep -q 'PikeOS\|pikeos' "$DST/rpm/lib/rpm/macros"; then
|
|
echo " ✗ RPM macros: still contains pikeos"
|
|
else
|
|
echo " ✓ RPM macros: pikeos removed"
|
|
fi
|
|
fi
|
|
|
|
if [[ -f "$DST/config/rpm/common" ]]; then
|
|
if grep -q 'Portugal Futurista' "$DST/config/rpm/common"; then
|
|
echo " ✓ config/rpm/common: vendor updated to Portugal Futurista"
|
|
else
|
|
echo " ✗ config/rpm/common: vendor NOT updated"
|
|
fi
|
|
fi
|
|
|
|
# File count summary
|
|
echo ""
|
|
echo "=== File count summary ==="
|
|
for d in rpm scov share config cdk build; do
|
|
count=$(find "$DST/$d" -type f 2>/dev/null | wc -l)
|
|
size=$(du -sh "$DST/$d" 2>/dev/null | awk '{print $1}')
|
|
echo " $d: $count files, $size"
|
|
done
|
|
TOTAL=$(find "$DST" -type f | wc -l)
|
|
TOTAL_SIZE=$(du -sh "$DST" | awk '{print $1}')
|
|
echo " TOTAL: $TOTAL files, $TOTAL_SIZE"
|
|
|
|
# Symlink check
|
|
echo ""
|
|
echo "=== Symlink integrity ==="
|
|
BROKEN=$(find "$DST" -type l ! -exec test -e {} \; -print 2>/dev/null | wc -l)
|
|
echo "Broken symlinks: $BROKEN"
|
|
} 2>&1 | tee "$REPORT"
|
|
|
|
echo ""
|
|
echo "============================================"
|
|
echo " Rebrand complete!"
|
|
echo " Output: $DST"
|
|
echo " Report: $REPORT"
|
|
echo "============================================"
|