copy_output.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/usr/bin/env bash
  2. set -e
  3. [ "$GLUON_IMAGEDIR" -a "$GLUON_PACKAGEDIR" -a "$LEDE_TARGET" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" ] || exit 1
  4. default_factory_ext='.bin'
  5. default_factory_suffix='-squashfs-factory'
  6. default_sysupgrade_ext='.bin'
  7. default_sysupgrade_suffix='-squashfs-sysupgrade'
  8. output=
  9. profile=
  10. aliases=
  11. factory_ext=
  12. factory_suffix=
  13. sysupgrade_ext=
  14. sysupgrade_suffix=
  15. no_opkg=
  16. mkdir -p "${GLUON_IMAGEDIR}/factory" "${GLUON_IMAGEDIR}/sysupgrade"
  17. if [ "$(expr match "$LEDE_TARGET" '.*-.*')" -gt 0 ]; then
  18. LEDE_BINDIR="${LEDE_TARGET//-/\/}"
  19. else
  20. LEDE_BINDIR="${LEDE_TARGET}/generic"
  21. fi
  22. SITE_CODE="$(scripts/site.sh site_code)"
  23. PACKAGE_PREFIX="gluon-${SITE_CODE}-${GLUON_RELEASE}"
  24. copy() {
  25. [ "${output}" ] || return 0
  26. want_device "${output}" || return 0
  27. if [ "$factory_ext" ]; then
  28. rm -f "${GLUON_IMAGEDIR}/factory/gluon-"*"-${output}${factory_ext}"
  29. cp "lede/bin/targets/${LEDE_BINDIR}/lede-${LEDE_TARGET}${profile}${factory_suffix}${factory_ext}" \
  30. "${GLUON_IMAGEDIR}/factory/gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}${factory_ext}"
  31. for alias in $aliases; do
  32. rm -f "${GLUON_IMAGEDIR}/factory/gluon-"*"-${alias}${factory_ext}"
  33. ln -s "gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}${factory_ext}" \
  34. "${GLUON_IMAGEDIR}/factory/gluon-${SITE_CODE}-${GLUON_RELEASE}-${alias}${factory_ext}"
  35. done
  36. fi
  37. if [ "$sysupgrade_ext" ]; then
  38. rm -f "${GLUON_IMAGEDIR}/sysupgrade/gluon-"*"-${output}-sysupgrade${sysupgrade_ext}"
  39. cp "lede/bin/targets/${LEDE_BINDIR}/lede-${LEDE_TARGET}${profile}${sysupgrade_suffix}${sysupgrade_ext}" \
  40. "${GLUON_IMAGEDIR}/sysupgrade/gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}-sysupgrade${sysupgrade_ext}"
  41. for alias in $aliases; do
  42. rm -f "${GLUON_IMAGEDIR}/sysupgrade/gluon-"*"-${alias}-sysupgrade${sysupgrade_ext}"
  43. ln -s "gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}-sysupgrade${sysupgrade_ext}" \
  44. "${GLUON_IMAGEDIR}/sysupgrade/gluon-${SITE_CODE}-${GLUON_RELEASE}-${alias}-sysupgrade${sysupgrade_ext}"
  45. done
  46. fi
  47. }
  48. . scripts/common.inc.sh
  49. device() {
  50. copy
  51. output="$1"
  52. profile="-$2"
  53. aliases=
  54. factory_ext="$default_factory_ext"
  55. factory_suffix="$default_factory_suffix"
  56. sysupgrade_ext="$default_sysupgrade_ext"
  57. sysupgrade_suffix="$default_sysupgrade_suffix"
  58. }
  59. factory_image() {
  60. copy
  61. output="$1"
  62. aliases=
  63. if [ "$3" ]; then
  64. profile="-$2"
  65. factory_ext="$3"
  66. else
  67. profile=""
  68. factory_ext="$2"
  69. fi
  70. factory_suffix=
  71. sysupgrade_ext=
  72. sysupgrade_suffix=
  73. }
  74. sysupgrade_image() {
  75. copy
  76. output="$1"
  77. aliases=
  78. if [ "$3" ]; then
  79. profile="-$2"
  80. sysupgrade_ext="$3"
  81. else
  82. profile=""
  83. sysupgrade_ext="$2"
  84. fi
  85. factory_ext=
  86. factory_suffix=
  87. sysupgrade_suffix=
  88. }
  89. alias() {
  90. aliases="$aliases $1"
  91. }
  92. factory() {
  93. if [ "$2" ]; then
  94. factory_suffix="$1"
  95. factory_ext="$2"
  96. else
  97. factory_ext="$1"
  98. fi
  99. if [ -z "$profile" ]; then
  100. default_factory_ext="$factory_ext"
  101. default_factory_suffix="$factory_suffix"
  102. fi
  103. }
  104. sysupgrade() {
  105. if [ "$2" ]; then
  106. sysupgrade_suffix="$1"
  107. sysupgrade_ext="$2"
  108. else
  109. sysupgrade_ext="$1"
  110. fi
  111. if [ -z "$output" ]; then
  112. default_sysupgrade_ext="$sysupgrade_ext"
  113. default_sysupgrade_suffix="$sysupgrade_suffix"
  114. fi
  115. }
  116. no_opkg() {
  117. no_opkg=1
  118. }
  119. . targets/"$1"; copy
  120. # Copy opkg repo
  121. if [ -z "$no_opkg" -a -z "$DEVICES" ]; then
  122. rm -f "$GLUON_PACKAGEDIR"/*/"$LEDE_BINDIR"/*
  123. rmdir -p "$GLUON_PACKAGEDIR"/*/"$LEDE_BINDIR" 2>/dev/null || true
  124. mkdir -p "${GLUON_PACKAGEDIR}/${PACKAGE_PREFIX}/${LEDE_BINDIR}"
  125. cp "lede/bin/targets/${LEDE_BINDIR}/packages"/* "${GLUON_PACKAGEDIR}/${PACKAGE_PREFIX}/${LEDE_BINDIR}"
  126. fi