buildarmimg 1.93 KB
Newer Older
1
#! /bin/bash
2

3
# Set globals
4
LIBDIR=/usr/share/manjaro-arm-tools/lib
5
KEEPROOTFS=true
6
EXTRACTED=false
7
FACTORY=false
8 9

#imports
10
source $LIBDIR/functions.sh
11

12
# check if root
Dan Johansen's avatar
Dan Johansen committed
13 14 15 16
if [ "$EUID" -ne 0 ]
  then echo "This script requires root permissions to run. Please run as root or with sudo!"
  exit
fi
17

18
#Arguments 
19
opt=":e:d:v:i:b:nfxh"
20 21 22 23

while getopts "${opt}" arg; do
  case $arg in
    e)
24
      EDITION="${OPTARG}"
25 26
      ;;
    d)
27
      DEVICE="${OPTARG}"
28 29
      ;;
    v)
30
      VERSION="${OPTARG}"
31
      ;;
32
    n)
33
      KEEPROOTFS=false
34
      ;;
35 36 37
    x)
      EXTRACTED=true
      ;;
38 39 40
    i)
      ADD_PACKAGE="${OPTARG}"
      ;;
Dan Johansen's avatar
Dan Johansen committed
41 42 43
    b)
      BRANCH="${OPTARG}"
      ;;
44 45 46
    f)
      FACTORY=true
      ;;
47 48 49 50 51
    \?)
      echo "Invalid option: -${OPTARG}"
      exit 1
      ;;
    h|?)
52
      usage_build_img
53 54 55 56 57 58 59 60 61 62
      exit 1
      ;;
    :)
      echo "Option -${OPTARG} requires an argument."
      exit 1
      ;;
  esac
done


63
IMGNAME=Manjaro-ARM-$EDITION-$DEVICE-$VERSION
64

Dan Johansen's avatar
Dan Johansen committed
65

Dan Johansen's avatar
Dan Johansen committed
66
ARCH='aarch64'
Dan Johansen's avatar
Dan Johansen committed
67

Dan Johansen's avatar
Dan Johansen committed
68 69 70 71 72
if [ ! -d "$PROFILES/arm-profiles" ]; then
    getarmprofiles
fi

#Make sure only a known branch is used
73 74
if [[ "$BRANCH" != "arm-stable" && "$BRANCH" != "arm-testing" && "$BRANCH" != "arm-unstable" ]]; then
    msg "Unknown branch. Please use either, arm-stable, arm-testing or arm-unstable!"
Dan Johansen's avatar
Dan Johansen committed
75 76
    exit 1
fi
77

Dan Johansen's avatar
Dan Johansen committed
78
# start the timer
Dan Johansen's avatar
Dan Johansen committed
79
timer_start=$(get_timer)
Dan Johansen's avatar
Dan Johansen committed
80

81
#Package lists
Dan Johansen's avatar
Dan Johansen committed
82 83 84
PKG_DEVICE=$(grep "^[^#;]" $PROFILES/arm-profiles/devices/$DEVICE | awk '{print $1}')
PKG_EDITION=$(grep "^[^#;]" $PROFILES/arm-profiles/editions/$EDITION | awk '{print $1}')
SRV_EDITION=$(grep "^[^#;]" $PROFILES/arm-profiles/services/$EDITION | awk '{print $1}')
85

86
#start timer
87
#timer=$(get_timer)
88

89
# Creating the rootfs used for the image.
Dan Johansen's avatar
Dan Johansen committed
90 91 92 93 94
create_rootfs_img
create_img
if [[ "$EXTRACTED" = "true" ]]; then
info "Image not compressed, because you supplied the -x option!"
else
Dan Johansen's avatar
Dan Johansen committed
95
# Create the compressed file, from the .img file which will get deleted.
Dan Johansen's avatar
Dan Johansen committed
96 97 98
compress
fi

99
# show timer
Dan Johansen's avatar
Dan Johansen committed
100
show_elapsed_time "${FUNCNAME}" "${timer_start}"